archived.vue 9.4 KB

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