manage.vue 4.5 KB

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