favor.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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: 'ProjectMyFavor',
  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.uindate));
  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.$Modal.confirm({
  77. title: '取消收藏',
  78. content: '你确定要取消收藏此项目吗?',
  79. loading: true,
  80. onOk: () => {
  81. this.favorProject('cancel', params.row.id, () => {
  82. this.getLists();
  83. });
  84. }
  85. });
  86. }
  87. }
  88. }, '取消');
  89. }
  90. }];
  91. },
  92. mounted() {
  93. if (this.canload) {
  94. this.loadYet = true;
  95. this.getLists(true);
  96. }
  97. },
  98. watch: {
  99. canload(val) {
  100. if (val && !this.loadYet) {
  101. this.loadYet = true;
  102. this.getLists(true);
  103. }
  104. }
  105. },
  106. methods: {
  107. setPage(page) {
  108. this.listPage = page;
  109. this.getLists();
  110. },
  111. setPageSize(size) {
  112. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  113. this.listPageSize = size;
  114. this.getLists();
  115. }
  116. },
  117. getLists(resetLoad) {
  118. if (resetLoad === true) {
  119. this.listPage = 1;
  120. }
  121. this.loadIng++;
  122. $A.aAjax({
  123. url: 'project/lists',
  124. data: {
  125. act: 'favor',
  126. page: Math.max(this.listPage, 1),
  127. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  128. },
  129. complete: () => {
  130. this.loadIng--;
  131. },
  132. success: (res) => {
  133. if (res.ret === 1) {
  134. this.lists = res.data.lists;
  135. this.listTotal = res.data.total;
  136. } else {
  137. this.lists = [];
  138. this.listTotal = 0;
  139. this.noDataText = res.msg;
  140. }
  141. }
  142. });
  143. },
  144. }
  145. }
  146. </script>