archived.vue 9.0 KB

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