archived.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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: 'ProjectArchived',
  26. components: {DrawerTabsContainer},
  27. props: {
  28. projectid: {
  29. default: 0
  30. },
  31. canload: {
  32. type: Boolean,
  33. default: true
  34. },
  35. },
  36. mixins: [
  37. Task
  38. ],
  39. data () {
  40. return {
  41. loadYet: false,
  42. loadIng: 0,
  43. columns: [],
  44. lists: [],
  45. listPage: 1,
  46. listTotal: 0,
  47. noDataText: "数据加载中.....",
  48. }
  49. },
  50. created() {
  51. this.columns = [{
  52. "title": "任务名称",
  53. "key": 'title',
  54. "minWidth": 120,
  55. render: (h, params) => {
  56. return this.renderTaskTitle(h, params);
  57. }
  58. }, {
  59. "title": "创建人",
  60. "key": 'createuser',
  61. "minWidth": 80,
  62. }, {
  63. "title": "负责人",
  64. "key": 'username',
  65. "minWidth": 80,
  66. }, {
  67. "title": "完成",
  68. "minWidth": 70,
  69. "align": "center",
  70. render: (h, params) => {
  71. return h('span', params.row.complete ? '√' : '-');
  72. }
  73. }, {
  74. "title": "归档时间",
  75. "width": 160,
  76. render: (h, params) => {
  77. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.archiveddate));
  78. }
  79. }, {
  80. "title": "操作",
  81. "key": 'action',
  82. "width": 100,
  83. "align": 'center',
  84. render: (h, params) => {
  85. return h('Button', {
  86. props: {
  87. type: 'primary',
  88. size: 'small'
  89. },
  90. on: {
  91. click: () => {
  92. this.$Modal.confirm({
  93. title: '取消归档',
  94. content: '你确定要取消归档吗?',
  95. loading: true,
  96. onOk: () => {
  97. $A.aAjax({
  98. url: 'project/task/edit',
  99. data: {
  100. act: 'unarchived',
  101. taskid: params.row.id,
  102. },
  103. error: () => {
  104. this.$Modal.remove();
  105. alert(this.$L('网络繁忙,请稍后再试!'));
  106. },
  107. success: (res) => {
  108. this.$Modal.remove();
  109. this.getLists();
  110. setTimeout(() => {
  111. if (res.ret === 1) {
  112. this.$Message.success(res.msg);
  113. $A.triggerTaskInfoListener('unarchived', res.data);
  114. } else {
  115. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  116. }
  117. }, 350);
  118. }
  119. });
  120. }
  121. });
  122. }
  123. }
  124. }, '取消归档');
  125. }
  126. }];
  127. },
  128. mounted() {
  129. if (this.canload) {
  130. this.loadYet = true;
  131. this.getLists(true);
  132. }
  133. $A.setOnTaskInfoListener('components/project/archived', (act, detail) => {
  134. if (detail.projectid != this.projectid) {
  135. return;
  136. }
  137. //
  138. this.lists.some((task, i) => {
  139. if (task.id == detail.id) {
  140. this.lists.splice(i, 1, detail);
  141. return true;
  142. }
  143. });
  144. //
  145. switch (act) {
  146. case "delete": // 删除任务
  147. case "unarchived": // 取消归档
  148. this.lists.some((task, i) => {
  149. if (task.id == detail.id) {
  150. this.lists.splice(i, 1);
  151. return true;
  152. }
  153. });
  154. break;
  155. case "archived": // 归档
  156. let has = false;
  157. this.lists.some((task) => {
  158. if (task.id == detail.id) {
  159. return has = true;
  160. }
  161. });
  162. if (!has) {
  163. this.lists.unshift(detail);
  164. }
  165. break;
  166. }
  167. });
  168. },
  169. watch: {
  170. projectid() {
  171. if (this.loadYet) {
  172. this.getLists(true);
  173. }
  174. },
  175. canload(val) {
  176. if (val && !this.loadYet) {
  177. this.loadYet = true;
  178. this.getLists(true);
  179. }
  180. }
  181. },
  182. methods: {
  183. setPage(page) {
  184. this.listPage = page;
  185. this.getLists();
  186. },
  187. setPageSize(size) {
  188. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  189. this.listPageSize = size;
  190. this.getLists();
  191. }
  192. },
  193. getLists(resetLoad) {
  194. if (resetLoad === true) {
  195. this.listPage = 1;
  196. }
  197. if (this.projectid == 0) {
  198. this.lists = [];
  199. this.listTotal = 0;
  200. this.noDataText = "没有相关的数据";
  201. return;
  202. }
  203. this.loadIng++;
  204. this.noDataText = "数据加载中.....";
  205. $A.aAjax({
  206. url: 'project/task/lists',
  207. data: {
  208. page: Math.max(this.listPage, 1),
  209. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  210. projectid: this.projectid,
  211. archived: '已归档',
  212. },
  213. complete: () => {
  214. this.loadIng--;
  215. },
  216. error: () => {
  217. this.noDataText = "数据加载失败!";
  218. },
  219. success: (res) => {
  220. if (res.ret === 1) {
  221. this.lists = res.data.lists;
  222. this.listTotal = res.data.total;
  223. this.noDataText = "没有相关的数据";
  224. } else {
  225. this.lists = [];
  226. this.listTotal = 0;
  227. this.noDataText = res.msg;
  228. }
  229. }
  230. });
  231. },
  232. }
  233. }
  234. </script>