archived.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. style: {
  91. fontSize: '12px'
  92. },
  93. on: {
  94. click: () => {
  95. this.$Modal.confirm({
  96. title: '取消归档',
  97. content: '你确定要取消归档吗?',
  98. loading: true,
  99. onOk: () => {
  100. $A.aAjax({
  101. url: 'project/task/edit',
  102. data: {
  103. act: 'unarchived',
  104. taskid: params.row.id,
  105. },
  106. error: () => {
  107. this.$Modal.remove();
  108. alert(this.$L('网络繁忙,请稍后再试!'));
  109. },
  110. success: (res) => {
  111. this.$Modal.remove();
  112. this.getLists();
  113. setTimeout(() => {
  114. if (res.ret === 1) {
  115. this.$Message.success(res.msg);
  116. $A.triggerTaskInfoListener('unarchived', res.data);
  117. } else {
  118. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  119. }
  120. }, 350);
  121. }
  122. });
  123. }
  124. });
  125. }
  126. }
  127. }, '取消归档');
  128. }
  129. }];
  130. },
  131. mounted() {
  132. if (this.canload) {
  133. this.loadYet = true;
  134. this.getLists(true);
  135. }
  136. $A.setOnTaskInfoListener('components/project/archived', (act, detail) => {
  137. if (detail.projectid != this.projectid) {
  138. return;
  139. }
  140. //
  141. this.lists.some((task, i) => {
  142. if (task.id == detail.id) {
  143. this.lists.splice(i, 1, detail);
  144. return true;
  145. }
  146. });
  147. //
  148. switch (act) {
  149. case "delete": // 删除任务
  150. case "unarchived": // 取消归档
  151. this.lists.some((task, i) => {
  152. if (task.id == detail.id) {
  153. this.lists.splice(i, 1);
  154. return true;
  155. }
  156. });
  157. break;
  158. case "archived": // 归档
  159. let has = false;
  160. this.lists.some((task) => {
  161. if (task.id == detail.id) {
  162. return has = true;
  163. }
  164. });
  165. if (!has) {
  166. this.lists.unshift(detail);
  167. }
  168. break;
  169. }
  170. });
  171. },
  172. watch: {
  173. projectid() {
  174. if (this.loadYet) {
  175. this.getLists(true);
  176. }
  177. },
  178. canload(val) {
  179. if (val && !this.loadYet) {
  180. this.loadYet = true;
  181. this.getLists(true);
  182. }
  183. }
  184. },
  185. methods: {
  186. setPage(page) {
  187. this.listPage = page;
  188. this.getLists();
  189. },
  190. setPageSize(size) {
  191. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  192. this.listPageSize = size;
  193. this.getLists();
  194. }
  195. },
  196. getLists(resetLoad) {
  197. if (resetLoad === true) {
  198. this.listPage = 1;
  199. }
  200. if (this.projectid == 0) {
  201. this.lists = [];
  202. this.listTotal = 0;
  203. this.noDataText = "没有相关的数据";
  204. return;
  205. }
  206. this.loadIng++;
  207. this.noDataText = "数据加载中.....";
  208. $A.aAjax({
  209. url: 'project/task/lists',
  210. data: {
  211. page: Math.max(this.listPage, 1),
  212. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  213. projectid: this.projectid,
  214. archived: '已归档',
  215. },
  216. complete: () => {
  217. this.loadIng--;
  218. },
  219. error: () => {
  220. this.noDataText = "数据加载失败!";
  221. },
  222. success: (res) => {
  223. if (res.ret === 1) {
  224. this.lists = res.data.lists;
  225. this.listTotal = res.data.total;
  226. this.noDataText = "没有相关的数据";
  227. } else {
  228. this.lists = [];
  229. this.listTotal = 0;
  230. this.noDataText = res.msg;
  231. }
  232. }
  233. });
  234. },
  235. }
  236. }
  237. </script>