favor.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. }, {
  46. "title": "收藏时间",
  47. "minWidth": 160,
  48. render: (h, params) => {
  49. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.uindate));
  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.$Modal.confirm({
  65. title: '取消收藏',
  66. content: '你确定要取消收藏此项目吗?',
  67. loading: true,
  68. onOk: () => {
  69. this.favorProject('cancel', params.row.id, () => {
  70. this.getLists();
  71. });
  72. }
  73. });
  74. }
  75. }
  76. }, '取消');
  77. }
  78. }];
  79. },
  80. mounted() {
  81. if (this.canload) {
  82. this.loadYet = true;
  83. this.getLists(true);
  84. }
  85. },
  86. watch: {
  87. canload(val) {
  88. if (val && !this.loadYet) {
  89. this.loadYet = true;
  90. this.getLists(true);
  91. }
  92. }
  93. },
  94. methods: {
  95. setPage(page) {
  96. this.listPage = page;
  97. this.getLists();
  98. },
  99. setPageSize(size) {
  100. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  101. this.listPageSize = size;
  102. this.getLists();
  103. }
  104. },
  105. getLists(resetLoad) {
  106. if (resetLoad === true) {
  107. this.listPage = 1;
  108. }
  109. this.loadIng++;
  110. $A.aAjax({
  111. url: 'project/lists',
  112. data: {
  113. act: 'favor',
  114. page: Math.max(this.listPage, 1),
  115. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  116. },
  117. complete: () => {
  118. this.loadIng--;
  119. },
  120. success: (res) => {
  121. if (res.ret === 1) {
  122. this.lists = res.data.lists;
  123. this.listTotal = res.data.total;
  124. } else {
  125. this.lists = [];
  126. this.listTotal = 0;
  127. this.noDataText = res.msg;
  128. }
  129. }
  130. });
  131. },
  132. }
  133. }
  134. </script>