archived.vue 8.2 KB

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