complete.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. /**
  22. * 已完成的任务
  23. */
  24. export default {
  25. name: 'TodoComplete',
  26. components: {DrawerTabsContainer},
  27. props: {
  28. canload: {
  29. type: Boolean,
  30. default: true
  31. },
  32. },
  33. mixins: [
  34. Task
  35. ],
  36. data () {
  37. return {
  38. loadYet: false,
  39. loadIng: 0,
  40. columns: [],
  41. lists: [],
  42. listPage: 1,
  43. listTotal: 0,
  44. noDataText: "数据加载中.....",
  45. }
  46. },
  47. created() {
  48. this.columns = [{
  49. "title": "任务名称",
  50. "key": 'title',
  51. "minWidth": 120,
  52. render: (h, params) => {
  53. return this.renderTaskTitle(h, params);
  54. }
  55. }, {
  56. "title": "创建人",
  57. "key": 'createuser',
  58. "minWidth": 80,
  59. }, {
  60. "title": "负责人",
  61. "key": 'username',
  62. "minWidth": 80,
  63. }, {
  64. "title": "完成时间",
  65. "width": 160,
  66. render: (h, params) => {
  67. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.completedate));
  68. }
  69. }];
  70. },
  71. mounted() {
  72. if (this.canload) {
  73. this.loadYet = true;
  74. this.getLists(true);
  75. }
  76. $A.setOnTaskInfoListener('components/project/todo/complete',(act, detail) => {
  77. if (detail.username != $A.getUserName()) {
  78. this.lists.some((task, i) => {
  79. if (task.id == detail.id) {
  80. this.lists.splice(i, 1);
  81. return true;
  82. }
  83. });
  84. return;
  85. }
  86. //
  87. this.lists.some((task, i) => {
  88. if (task.id == detail.id) {
  89. this.lists.splice(i, 1, detail);
  90. return true;
  91. }
  92. });
  93. //
  94. switch (act) {
  95. case "username": // 负责人
  96. case "delete": // 删除任务
  97. case "archived": // 归档
  98. this.lists.some((task, i) => {
  99. if (task.id == detail.id) {
  100. this.lists.splice(i, 1);
  101. return true;
  102. }
  103. });
  104. break;
  105. case "unarchived": // 取消归档
  106. let has = false;
  107. this.lists.some((task) => {
  108. if (task.id == detail.id) {
  109. return has = true;
  110. }
  111. });
  112. if (!has) {
  113. this.lists.unshift(detail);
  114. }
  115. break;
  116. }
  117. })
  118. },
  119. watch: {
  120. canload(val) {
  121. if (val && !this.loadYet) {
  122. this.loadYet = true;
  123. this.getLists(true);
  124. }
  125. }
  126. },
  127. methods: {
  128. setPage(page) {
  129. this.listPage = page;
  130. this.getLists();
  131. },
  132. setPageSize(size) {
  133. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  134. this.listPageSize = size;
  135. this.getLists();
  136. }
  137. },
  138. getLists(resetLoad) {
  139. if (resetLoad === true) {
  140. this.listPage = 1;
  141. }
  142. this.loadIng++;
  143. this.noDataText = "数据加载中.....";
  144. $A.aAjax({
  145. url: 'project/task/lists',
  146. data: {
  147. type: '已完成',
  148. page: Math.max(this.listPage, 1),
  149. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  150. },
  151. complete: () => {
  152. this.loadIng--;
  153. },
  154. error: () => {
  155. this.noDataText = "数据加载失败!";
  156. },
  157. success: (res) => {
  158. if (res.ret === 1) {
  159. this.lists = res.data.lists;
  160. this.listTotal = res.data.total;
  161. this.noDataText = "没有相关的数据";
  162. } else {
  163. this.lists = [];
  164. this.listTotal = 0;
  165. this.noDataText = res.msg;
  166. }
  167. }
  168. });
  169. },
  170. }
  171. }
  172. </script>