complete.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="project-todo-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 :simple="windowMax768"></Page>
  8. </div>
  9. </drawer-tabs-container>
  10. </template>
  11. <style lang="scss" scoped>
  12. .project-todo-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. mounted() {
  48. if (this.canload) {
  49. this.loadYet = true;
  50. this.getLists(true);
  51. }
  52. $A.setOnTaskInfoListener('components/project/todo/complete',(act, detail) => {
  53. if (detail.username != this.usrName) {
  54. this.lists.some((task, i) => {
  55. if (task.id == detail.id) {
  56. this.lists.splice(i, 1);
  57. return true;
  58. }
  59. });
  60. return;
  61. }
  62. //
  63. this.lists.some((task, i) => {
  64. if (task.id == detail.id) {
  65. this.lists.splice(i, 1, detail);
  66. return true;
  67. }
  68. });
  69. //
  70. switch (act) {
  71. case "username": // 负责人
  72. case "delete": // 删除任务
  73. case "archived": // 归档
  74. this.lists.some((task, i) => {
  75. if (task.id == detail.id) {
  76. this.lists.splice(i, 1);
  77. return true;
  78. }
  79. });
  80. break;
  81. case "unarchived": // 取消归档
  82. let has = false;
  83. this.lists.some((task) => {
  84. if (task.id == detail.id) {
  85. return has = true;
  86. }
  87. });
  88. if (!has) {
  89. this.lists.unshift(detail);
  90. }
  91. break;
  92. }
  93. })
  94. },
  95. watch: {
  96. canload(val) {
  97. if (val && !this.loadYet) {
  98. this.loadYet = true;
  99. this.getLists(true);
  100. }
  101. }
  102. },
  103. methods: {
  104. initLanguage() {
  105. this.noDataText = this.$L("数据加载中.....");
  106. this.columns = [{
  107. "title": this.$L("任务名称"),
  108. "key": 'title',
  109. "minWidth": 120,
  110. render: (h, params) => {
  111. return this.renderTaskTitle(h, params);
  112. }
  113. }, {
  114. "title": this.$L("创建人"),
  115. "key": 'createuser',
  116. "minWidth": 80,
  117. render: (h, params) => {
  118. return h('UserView', {
  119. props: {
  120. username: params.row.createuser
  121. }
  122. });
  123. }
  124. }, {
  125. "title": this.$L("负责人"),
  126. "key": 'username',
  127. "minWidth": 80,
  128. render: (h, params) => {
  129. return h('UserView', {
  130. props: {
  131. username: params.row.username
  132. }
  133. });
  134. }
  135. }, {
  136. "title": this.$L("完成时间"),
  137. "width": 160,
  138. render: (h, params) => {
  139. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.completedate));
  140. }
  141. }];
  142. },
  143. setPage(page) {
  144. this.listPage = page;
  145. this.getLists();
  146. },
  147. setPageSize(size) {
  148. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  149. this.listPageSize = size;
  150. this.getLists();
  151. }
  152. },
  153. getLists(resetLoad) {
  154. if (resetLoad === true) {
  155. this.listPage = 1;
  156. }
  157. this.loadIng++;
  158. this.noDataText = this.$L("数据加载中.....");
  159. $A.apiAjax({
  160. url: 'project/task/lists',
  161. data: {
  162. type: '已完成',
  163. page: Math.max(this.listPage, 1),
  164. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  165. },
  166. complete: () => {
  167. this.loadIng--;
  168. },
  169. error: () => {
  170. this.noDataText = this.$L("数据加载失败!");
  171. },
  172. success: (res) => {
  173. if (res.ret === 1) {
  174. this.lists = res.data.lists;
  175. this.listTotal = res.data.total;
  176. this.noDataText = this.$L("没有相关的数据");
  177. } else {
  178. this.lists = [];
  179. this.listTotal = 0;
  180. this.noDataText = res.msg;
  181. }
  182. }
  183. });
  184. },
  185. }
  186. }
  187. </script>