archived.vue 7.9 KB

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