archived.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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: 'HeaderArchived',
  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. "minWidth": 70,
  63. "align": "center",
  64. render: (h, params) => {
  65. return h('span', params.row.complete ? '√' : '-');
  66. }
  67. }, {
  68. "title": "归档时间",
  69. "width": 160,
  70. render: (h, params) => {
  71. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.archiveddate));
  72. }
  73. }, {
  74. "title": "操作",
  75. "key": 'action',
  76. "width": 100,
  77. "align": 'center',
  78. render: (h, params) => {
  79. return h('Button', {
  80. props: {
  81. type: 'primary',
  82. size: 'small'
  83. },
  84. on: {
  85. click: () => {
  86. this.$Modal.confirm({
  87. title: '取消归档',
  88. content: '你确定要取消归档吗?',
  89. loading: true,
  90. onOk: () => {
  91. $A.aAjax({
  92. url: 'project/task/edit',
  93. data: {
  94. act: 'unarchived',
  95. taskid: params.row.id,
  96. },
  97. error: () => {
  98. this.$Modal.remove();
  99. alert(this.$L('网络繁忙,请稍后再试!'));
  100. },
  101. success: (res) => {
  102. this.$Modal.remove();
  103. this.getLists();
  104. setTimeout(() => {
  105. if (res.ret === 1) {
  106. this.$Message.success(res.msg);
  107. $A.triggerTaskInfoListener('unarchived', res.data);
  108. } else {
  109. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  110. }
  111. }, 350);
  112. }
  113. });
  114. }
  115. });
  116. }
  117. }
  118. }, '取消归档');
  119. }
  120. }];
  121. },
  122. mounted() {
  123. if (this.canload) {
  124. this.loadYet = true;
  125. this.getLists(true);
  126. }
  127. $A.setOnTaskInfoListener('components/project/header/archived', (act, detail) => {
  128. this.lists.some((task, i) => {
  129. if (task.id == detail.id) {
  130. this.lists.splice(i, 1, detail);
  131. return true;
  132. }
  133. });
  134. //
  135. switch (act) {
  136. case "delete": // 删除任务
  137. case "unarchived": // 取消归档
  138. this.lists.some((task, i) => {
  139. if (task.id == detail.id) {
  140. this.lists.splice(i, 1);
  141. return true;
  142. }
  143. });
  144. break;
  145. case "archived": // 归档
  146. let has = false;
  147. this.lists.some((task) => {
  148. if (task.id == detail.id) {
  149. return has = true;
  150. }
  151. });
  152. if (!has) {
  153. this.lists.unshift(detail);
  154. }
  155. break;
  156. }
  157. });
  158. },
  159. watch: {
  160. canload(val) {
  161. if (val && !this.loadYet) {
  162. this.loadYet = true;
  163. this.getLists(true);
  164. }
  165. }
  166. },
  167. methods: {
  168. setPage(page) {
  169. this.listPage = page;
  170. this.getLists();
  171. },
  172. setPageSize(size) {
  173. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  174. this.listPageSize = size;
  175. this.getLists();
  176. }
  177. },
  178. getLists(resetLoad) {
  179. if (resetLoad === true) {
  180. this.listPage = 1;
  181. }
  182. this.loadIng++;
  183. $A.aAjax({
  184. url: 'project/task/lists',
  185. data: {
  186. page: Math.max(this.listPage, 1),
  187. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  188. archived: '已归档',
  189. },
  190. complete: () => {
  191. this.loadIng--;
  192. },
  193. success: (res) => {
  194. if (res.ret === 1) {
  195. this.lists = res.data.lists;
  196. this.listTotal = res.data.total;
  197. this.noDataText = "没有相关的数据";
  198. } else {
  199. this.lists = [];
  200. this.listTotal = 0;
  201. this.noDataText = res.msg;
  202. }
  203. }
  204. });
  205. },
  206. }
  207. }
  208. </script>