manage.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. import Project from "../../../mixins/project";
  18. export default {
  19. name: 'ProjectMyManage',
  20. props: {
  21. canload: {
  22. type: Boolean,
  23. default: true
  24. },
  25. },
  26. mixins: [
  27. Project
  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. "minWidth": 160,
  48. render: (h, params) => {
  49. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  50. }
  51. }, {
  52. "title": "操作",
  53. "key": 'action',
  54. "width": 80,
  55. "align": 'center',
  56. render: (h, params) => {
  57. return h('Button', {
  58. props: {
  59. type: 'primary',
  60. size: 'small'
  61. },
  62. on: {
  63. click: () => {
  64. this.deleteProject(params.row.id, () => {
  65. this.getLists();
  66. });
  67. }
  68. }
  69. }, '删除');
  70. }
  71. }];
  72. },
  73. mounted() {
  74. if (this.canload) {
  75. this.loadYet = true;
  76. this.getLists(true);
  77. }
  78. },
  79. watch: {
  80. canload(val) {
  81. if (val && !this.loadYet) {
  82. this.loadYet = true;
  83. this.getLists(true);
  84. }
  85. }
  86. },
  87. methods: {
  88. setPage(page) {
  89. this.listPage = page;
  90. this.getLists();
  91. },
  92. setPageSize(size) {
  93. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  94. this.listPageSize = size;
  95. this.getLists();
  96. }
  97. },
  98. getLists(resetLoad) {
  99. if (resetLoad === true) {
  100. this.listPage = 1;
  101. }
  102. this.loadIng++;
  103. $A.aAjax({
  104. url: 'project/lists',
  105. data: {
  106. act: 'manage',
  107. page: Math.max(this.listPage, 1),
  108. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  109. },
  110. complete: () => {
  111. this.loadIng--;
  112. },
  113. success: (res) => {
  114. if (res.ret === 1) {
  115. this.lists = res.data.lists;
  116. this.listTotal = res.data.total;
  117. } else {
  118. this.lists = [];
  119. this.listTotal = 0;
  120. this.noDataText = res.msg;
  121. }
  122. }
  123. });
  124. },
  125. }
  126. }
  127. </script>