complete.vue 6.5 KB

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