complete.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="project-complete">
  3. <!-- 列表 -->
  4. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  5. <!-- 分页 -->
  6. <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>
  7. </div>
  8. </template>
  9. <style lang="scss" scoped>
  10. .project-complete {
  11. .tableFill {
  12. margin: 12px 12px 20px;
  13. }
  14. }
  15. </style>
  16. <script>
  17. export default {
  18. name: 'ProjectComplete',
  19. props: {
  20. projectid: {
  21. default: 0
  22. },
  23. canload: {
  24. type: Boolean,
  25. default: true
  26. },
  27. },
  28. data () {
  29. return {
  30. loadYet: false,
  31. loadIng: 0,
  32. columns: [],
  33. lists: [],
  34. listPage: 1,
  35. listTotal: 0,
  36. noDataText: "数据加载中.....",
  37. }
  38. },
  39. created() {
  40. this.columns = [{
  41. "title": "任务名称",
  42. "key": 'title',
  43. "minWidth": 100,
  44. }, {
  45. "title": "创建人",
  46. "key": 'createuser',
  47. "minWidth": 80,
  48. }, {
  49. "title": "负责人",
  50. "key": 'username',
  51. "minWidth": 80,
  52. }, {
  53. "title": "归档时间",
  54. "width": 160,
  55. render: (h, params) => {
  56. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.archiveddate));
  57. }
  58. }, {
  59. "title": "操作",
  60. "key": 'action',
  61. "width": 100,
  62. "align": 'center',
  63. render: (h, params) => {
  64. return h('Button', {
  65. props: {
  66. type: 'primary',
  67. size: 'small'
  68. },
  69. on: {
  70. click: () => {
  71. this.$Modal.confirm({
  72. title: '取消归档',
  73. content: '你确定要取消归档吗?',
  74. loading: true,
  75. onOk: () => {
  76. $A.aAjax({
  77. url: 'project/task/archived',
  78. data: {
  79. act: 'cancel',
  80. taskid: params.row.id,
  81. },
  82. error: () => {
  83. this.$Modal.remove();
  84. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  85. },
  86. success: (res) => {
  87. this.$Modal.remove();
  88. this.getLists();
  89. setTimeout(() => {
  90. if (res.ret === 1) {
  91. this.$Message.success(res.msg);
  92. }else{
  93. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  94. }
  95. }, 350);
  96. }
  97. });
  98. }
  99. });
  100. }
  101. }
  102. }, '取消归档');
  103. }
  104. }];
  105. },
  106. mounted() {
  107. if (this.canload) {
  108. this.loadYet = true;
  109. this.getLists(true);
  110. }
  111. },
  112. watch: {
  113. projectid() {
  114. if (this.loadYet) {
  115. this.getLists(true);
  116. }
  117. },
  118. canload(val) {
  119. if (val && !this.loadYet) {
  120. this.loadYet = true;
  121. this.getLists(true);
  122. }
  123. }
  124. },
  125. methods: {
  126. setPage(page) {
  127. this.listPage = page;
  128. this.getLists();
  129. },
  130. setPageSize(size) {
  131. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  132. this.listPageSize = size;
  133. this.getLists();
  134. }
  135. },
  136. getLists(resetLoad) {
  137. if (resetLoad === true) {
  138. this.listPage = 1;
  139. }
  140. if (this.projectid == 0) {
  141. this.lists = [];
  142. this.listTotal = 0;
  143. this.noDataText = "没有相关的数据";
  144. return;
  145. }
  146. this.loadIng++;
  147. $A.aAjax({
  148. url: 'project/task/lists',
  149. data: {
  150. page: Math.max(this.listPage, 1),
  151. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  152. projectid: this.projectid,
  153. archived: '已归档',
  154. },
  155. complete: () => {
  156. this.loadIng--;
  157. },
  158. success: (res) => {
  159. if (res.ret === 1) {
  160. this.lists = res.data.lists;
  161. this.listTotal = res.data.total;
  162. } else {
  163. this.lists = [];
  164. this.listTotal = 0;
  165. this.noDataText = res.msg;
  166. }
  167. }
  168. });
  169. },
  170. }
  171. }
  172. </script>