archived.vue 9.3 KB

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