favor.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 Project from "../../../mixins/project";
  20. import DrawerTabsContainer from "../../DrawerTabsContainer";
  21. export default {
  22. name: 'ProjectMyFavor',
  23. components: {DrawerTabsContainer},
  24. props: {
  25. canload: {
  26. type: Boolean,
  27. default: true
  28. },
  29. },
  30. mixins: [
  31. Project
  32. ],
  33. data () {
  34. return {
  35. loadYet: false,
  36. loadIng: 0,
  37. columns: [],
  38. lists: [],
  39. listPage: 1,
  40. listTotal: 0,
  41. noDataText: "数据加载中.....",
  42. }
  43. },
  44. created() {
  45. this.columns = [{
  46. "title": "项目名称",
  47. "key": 'title',
  48. "minWidth": 100,
  49. render: (h, params) => {
  50. return h('a', {
  51. attrs: {
  52. href: 'javascript:void(0)',
  53. },
  54. on: {
  55. click: () => {
  56. this.openProject(params.row.id);
  57. }
  58. }
  59. }, params.row.title);
  60. },
  61. }, {
  62. "title": "收藏时间",
  63. "minWidth": 160,
  64. render: (h, params) => {
  65. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.uindate));
  66. }
  67. }, {
  68. "title": "操作",
  69. "key": 'action',
  70. "width": 80,
  71. "align": 'center',
  72. render: (h, params) => {
  73. return h('Button', {
  74. props: {
  75. type: 'primary',
  76. size: 'small'
  77. },
  78. on: {
  79. click: () => {
  80. this.$Modal.confirm({
  81. title: '取消收藏',
  82. content: '你确定要取消收藏此项目吗?',
  83. loading: true,
  84. onOk: () => {
  85. this.favorProject('cancel', params.row.id, () => {
  86. this.getLists();
  87. });
  88. }
  89. });
  90. }
  91. }
  92. }, '取消');
  93. }
  94. }];
  95. },
  96. mounted() {
  97. if (this.canload) {
  98. this.loadYet = true;
  99. this.getLists(true);
  100. }
  101. },
  102. watch: {
  103. canload(val) {
  104. if (val && !this.loadYet) {
  105. this.loadYet = true;
  106. this.getLists(true);
  107. }
  108. }
  109. },
  110. methods: {
  111. setPage(page) {
  112. this.listPage = page;
  113. this.getLists();
  114. },
  115. setPageSize(size) {
  116. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  117. this.listPageSize = size;
  118. this.getLists();
  119. }
  120. },
  121. getLists(resetLoad) {
  122. if (resetLoad === true) {
  123. this.listPage = 1;
  124. }
  125. this.loadIng++;
  126. this.noDataText = "数据加载中.....";
  127. $A.aAjax({
  128. url: 'project/lists',
  129. data: {
  130. act: 'favor',
  131. page: Math.max(this.listPage, 1),
  132. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  133. },
  134. complete: () => {
  135. this.loadIng--;
  136. },
  137. error: () => {
  138. this.noDataText = "数据加载失败!";
  139. },
  140. success: (res) => {
  141. if (res.ret === 1) {
  142. this.lists = res.data.lists;
  143. this.listTotal = res.data.total;
  144. this.noDataText = "没有相关的数据";
  145. } else {
  146. this.lists = [];
  147. this.listTotal = 0;
  148. this.noDataText = res.msg;
  149. }
  150. }
  151. });
  152. },
  153. }
  154. }
  155. </script>