archived.vue 9.8 KB

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