archived.vue 10 KB

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