complete.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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: 'TodoComplete',
  22. components: {DrawerTabsContainer},
  23. props: {
  24. canload: {
  25. type: Boolean,
  26. default: true
  27. },
  28. },
  29. data () {
  30. return {
  31. loadYet: false,
  32. loadIng: 0,
  33. columns: [],
  34. lists: [],
  35. listPage: 1,
  36. listTotal: 0,
  37. noDataText: "数据加载中.....",
  38. }
  39. },
  40. created() {
  41. this.columns = [{
  42. "title": "任务名称",
  43. "key": 'title',
  44. "minWidth": 100,
  45. }, {
  46. "title": "创建人",
  47. "key": 'createuser',
  48. "minWidth": 80,
  49. }, {
  50. "title": "负责人",
  51. "key": 'username',
  52. "minWidth": 80,
  53. }, {
  54. "title": "完成时间",
  55. "width": 160,
  56. render: (h, params) => {
  57. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.complete));
  58. }
  59. }];
  60. },
  61. mounted() {
  62. if (this.canload) {
  63. this.loadYet = true;
  64. this.getLists(true);
  65. }
  66. },
  67. watch: {
  68. canload(val) {
  69. if (val && !this.loadYet) {
  70. this.loadYet = true;
  71. this.getLists(true);
  72. }
  73. }
  74. },
  75. methods: {
  76. setPage(page) {
  77. this.listPage = page;
  78. this.getLists();
  79. },
  80. setPageSize(size) {
  81. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  82. this.listPageSize = size;
  83. this.getLists();
  84. }
  85. },
  86. getLists(resetLoad) {
  87. if (resetLoad === true) {
  88. this.listPage = 1;
  89. }
  90. this.loadIng++;
  91. $A.aAjax({
  92. url: 'project/task/lists',
  93. data: {
  94. type: '已完成',
  95. page: Math.max(this.listPage, 1),
  96. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  97. },
  98. complete: () => {
  99. this.loadIng--;
  100. },
  101. success: (res) => {
  102. if (res.ret === 1) {
  103. this.lists = res.data.lists;
  104. this.listTotal = res.data.total;
  105. } else {
  106. this.lists = [];
  107. this.listTotal = 0;
  108. this.noDataText = res.msg;
  109. }
  110. }
  111. });
  112. },
  113. }
  114. }
  115. </script>