archived.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. data: {
  118. act: 'unarchived',
  119. taskid: params.row.id,
  120. },
  121. error: () => {
  122. this.$Modal.remove();
  123. alert(this.$L('网络繁忙,请稍后再试!'));
  124. },
  125. success: (res) => {
  126. this.$Modal.remove();
  127. this.getLists();
  128. setTimeout(() => {
  129. if (res.ret === 1) {
  130. this.$Message.success(res.msg);
  131. $A.triggerTaskInfoListener('unarchived', res.data);
  132. $A.triggerTaskInfoChange(params.row.id);
  133. } else {
  134. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  135. }
  136. }, 350);
  137. }
  138. });
  139. }
  140. });
  141. }
  142. }
  143. }, this.$L('取消归档'));
  144. }
  145. }];
  146. },
  147. mounted() {
  148. if (this.canload) {
  149. this.loadYet = true;
  150. this.getLists(true);
  151. }
  152. $A.setOnTaskInfoListener('components/project/archived', (act, detail) => {
  153. if (detail.projectid != this.projectid) {
  154. return;
  155. }
  156. //
  157. this.lists.some((task, i) => {
  158. if (task.id == detail.id) {
  159. this.lists.splice(i, 1, detail);
  160. return true;
  161. }
  162. });
  163. //
  164. switch (act) {
  165. case "delete": // 删除任务
  166. case "unarchived": // 取消归档
  167. this.lists.some((task, i) => {
  168. if (task.id == detail.id) {
  169. this.lists.splice(i, 1);
  170. return true;
  171. }
  172. });
  173. break;
  174. case "archived": // 归档
  175. let has = false;
  176. this.lists.some((task) => {
  177. if (task.id == detail.id) {
  178. return has = true;
  179. }
  180. });
  181. if (!has) {
  182. this.lists.unshift(detail);
  183. }
  184. break;
  185. }
  186. });
  187. },
  188. watch: {
  189. projectid() {
  190. if (this.loadYet) {
  191. this.getLists(true);
  192. }
  193. },
  194. canload(val) {
  195. if (val && !this.loadYet) {
  196. this.loadYet = true;
  197. this.getLists(true);
  198. }
  199. }
  200. },
  201. methods: {
  202. setPage(page) {
  203. this.listPage = page;
  204. this.getLists();
  205. },
  206. setPageSize(size) {
  207. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  208. this.listPageSize = size;
  209. this.getLists();
  210. }
  211. },
  212. getLists(resetLoad) {
  213. if (resetLoad === true) {
  214. this.listPage = 1;
  215. }
  216. if (this.projectid == 0) {
  217. this.lists = [];
  218. this.listTotal = 0;
  219. this.noDataText = this.$L("没有相关的数据");
  220. return;
  221. }
  222. this.loadIng++;
  223. this.noDataText = this.$L("数据加载中.....");
  224. $A.apiAjax({
  225. url: 'project/task/lists',
  226. data: {
  227. page: Math.max(this.listPage, 1),
  228. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  229. projectid: this.projectid,
  230. archived: '已归档',
  231. },
  232. complete: () => {
  233. this.loadIng--;
  234. },
  235. error: () => {
  236. this.noDataText = this.$L("数据加载失败!");
  237. },
  238. success: (res) => {
  239. if (res.ret === 1) {
  240. this.lists = res.data.lists;
  241. this.listTotal = res.data.total;
  242. this.noDataText = this.$L("没有相关的数据");
  243. } else {
  244. this.lists = [];
  245. this.listTotal = 0;
  246. this.noDataText = res.msg;
  247. }
  248. }
  249. });
  250. },
  251. }
  252. }
  253. </script>