complete.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total></Page>
  7. </div>
  8. </template>
  9. <style lang="scss" scoped>
  10. .project-complete {
  11. .tableFill {
  12. margin: 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. "minWidth": 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": 80,
  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. }
  72. }
  73. }, '取消归档');
  74. }
  75. }];
  76. },
  77. mounted() {
  78. if (this.canload) {
  79. this.loadYet = true;
  80. this.getLists(true);
  81. }
  82. },
  83. watch: {
  84. projectid() {
  85. if (this.loadYet) {
  86. this.loadYet = true;
  87. this.getLists(true);
  88. }
  89. },
  90. canload(val) {
  91. if (val && !this.loadYet) {
  92. this.loadYet = true;
  93. this.getLists(true);
  94. }
  95. }
  96. },
  97. methods: {
  98. setPage(page) {
  99. this.listPage = page;
  100. this.getLists();
  101. },
  102. setPageSize(size) {
  103. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  104. this.listPageSize = size;
  105. this.getLists();
  106. }
  107. },
  108. getLists(resetLoad) {
  109. if (resetLoad === true) {
  110. this.listPage = 1;
  111. }
  112. if (this.projectid == 0) {
  113. this.lists = [];
  114. this.listTotal = 0;
  115. this.noDataText = "没有相关的数据";
  116. return;
  117. }
  118. this.loadIng++;
  119. $A.aAjax({
  120. url: 'project/task/lists',
  121. data: {
  122. page: Math.max(this.listPage, 1),
  123. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  124. projectid: this.projectid,
  125. archived: 1,
  126. },
  127. complete: () => {
  128. this.loadIng--;
  129. },
  130. success: (res) => {
  131. if (res.ret === 1) {
  132. this.lists = res.data.lists;
  133. this.listTotal = res.data.total;
  134. } else {
  135. this.lists = [];
  136. this.listTotal = 0;
  137. this.noDataText = res.msg;
  138. }
  139. }
  140. });
  141. },
  142. }
  143. }
  144. </script>