complete.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="project-complete">
  4. <!-- 列表 -->
  5. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  6. <!-- 分页 -->
  7. <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
  8. </div>
  9. </drawer-tabs-container>
  10. </template>
  11. <style lang="scss" scoped>
  12. .project-complete {
  13. .tableFill {
  14. margin: 12px 12px 20px;
  15. }
  16. }
  17. </style>
  18. <script>
  19. import DrawerTabsContainer from "../../DrawerTabsContainer";
  20. import Task from "../../../mixins/task";
  21. export default {
  22. name: 'TodoComplete',
  23. components: {DrawerTabsContainer},
  24. props: {
  25. canload: {
  26. type: Boolean,
  27. default: true
  28. },
  29. },
  30. mixins: [
  31. Task
  32. ],
  33. data () {
  34. return {
  35. loadYet: false,
  36. loadIng: 0,
  37. columns: [],
  38. lists: [],
  39. listPage: 1,
  40. listTotal: 0,
  41. noDataText: "数据加载中.....",
  42. }
  43. },
  44. created() {
  45. this.columns = [{
  46. "title": "任务名称",
  47. "key": 'title',
  48. "minWidth": 120,
  49. render: (h, params) => {
  50. return this.renderTaskTitle(h, params);
  51. }
  52. }, {
  53. "title": "创建人",
  54. "key": 'createuser',
  55. "minWidth": 80,
  56. }, {
  57. "title": "负责人",
  58. "key": 'username',
  59. "minWidth": 80,
  60. }, {
  61. "title": "完成时间",
  62. "width": 160,
  63. render: (h, params) => {
  64. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.completedate));
  65. }
  66. }];
  67. },
  68. mounted() {
  69. if (this.canload) {
  70. this.loadYet = true;
  71. this.getLists(true);
  72. }
  73. $A.setOnTaskInfoListener('components/project/todo/complete',(act, detail) => {
  74. this.lists.some((task, i) => {
  75. if (task.id == detail.id) {
  76. this.lists.splice(i, 1, detail);
  77. return true;
  78. }
  79. });
  80. //
  81. switch (act) {
  82. case "username": // 负责人
  83. case "delete": // 删除任务
  84. case "archived": // 归档
  85. this.lists.some((task, i) => {
  86. if (task.id == detail.id) {
  87. this.lists.splice(i, 1);
  88. return true;
  89. }
  90. });
  91. break;
  92. case "unarchived": // 取消归档
  93. let has = false;
  94. this.lists.some((task) => {
  95. if (task.id == detail.id) {
  96. return has = true;
  97. }
  98. });
  99. if (!has) {
  100. this.lists.unshift(detail);
  101. }
  102. break;
  103. }
  104. })
  105. },
  106. watch: {
  107. canload(val) {
  108. if (val && !this.loadYet) {
  109. this.loadYet = true;
  110. this.getLists(true);
  111. }
  112. }
  113. },
  114. methods: {
  115. setPage(page) {
  116. this.listPage = page;
  117. this.getLists();
  118. },
  119. setPageSize(size) {
  120. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  121. this.listPageSize = size;
  122. this.getLists();
  123. }
  124. },
  125. getLists(resetLoad) {
  126. if (resetLoad === true) {
  127. this.listPage = 1;
  128. }
  129. this.loadIng++;
  130. this.noDataText = "数据加载中.....";
  131. $A.aAjax({
  132. url: 'project/task/lists',
  133. data: {
  134. type: '已完成',
  135. page: Math.max(this.listPage, 1),
  136. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  137. },
  138. complete: () => {
  139. this.loadIng--;
  140. },
  141. error: () => {
  142. this.noDataText = "数据加载失败!";
  143. },
  144. success: (res) => {
  145. if (res.ret === 1) {
  146. this.lists = res.data.lists;
  147. this.listTotal = res.data.total;
  148. this.noDataText = "没有相关的数据";
  149. } else {
  150. this.lists = [];
  151. this.listTotal = 0;
  152. this.noDataText = res.msg;
  153. }
  154. }
  155. });
  156. },
  157. }
  158. }
  159. </script>