archived.vue 9.6 KB

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