list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="app-list-content">
  3. <cl-crud class="liu-crud-wrap" @load="onLoad">
  4. <template #slot-tabs="{ scope }">
  5. <el-tabs
  6. class="liu-tabs"
  7. type="border-card"
  8. v-model="tabIndex"
  9. @tab-click="handleClick"
  10. >
  11. <el-tab-pane
  12. v-for="(item, index) in tabsData"
  13. :key="index"
  14. :label="`${item.text}(${item.val})`"
  15. :name="item.key"
  16. ></el-tab-pane>
  17. </el-tabs>
  18. </template>
  19. <template #table-column-addTime="{scope}">
  20. <span>{{ scope.row.addTime | formatTime }}</span>
  21. </template>
  22. <template #table-column-deadline="{scope}">
  23. <span>{{ scope.row.deadline | formatTime }}</span>
  24. </template>
  25. <template #table-column-status="{scope}">
  26. <span v-if="scope.row.status == 1">
  27. <i class="iconfont icondagou"></i>
  28. </span>
  29. <span v-else>{{ scope.row.status | constantfilter('COUPON_STATUS') }}</span>
  30. </template>
  31. </cl-crud>
  32. </div>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. // cl-crud
  39. app: null,
  40. tabIndex: '-1',
  41. tabsData: [
  42. {
  43. text: '全部',
  44. key: '-1',
  45. val: 0
  46. },
  47. {
  48. text: '待使用',
  49. key: '0',
  50. val: 0
  51. },
  52. {
  53. text: '已使用',
  54. key: '1',
  55. val: 0
  56. },
  57. {
  58. text: '已失效',
  59. key: '2',
  60. val: 0
  61. }
  62. ]
  63. };
  64. },
  65. mounted() {},
  66. methods: {
  67. handleClick() {
  68. this.app.refresh({ status: this.tabIndex });
  69. },
  70. // crud
  71. onLoad({ ctx, app }) {
  72. this.app = app;
  73. ctx.service(this.$service.coupon)
  74. .set('table', {
  75. columns: [
  76. {
  77. prop: 'userId',
  78. label: 'ID',
  79. align: 'center'
  80. },
  81. {
  82. prop: 'userName',
  83. label: '持有人',
  84. align: 'center'
  85. },
  86. {
  87. prop: 'mobile',
  88. label: '手机号',
  89. align: 'center'
  90. },
  91. {
  92. prop: 'amount',
  93. label: '金额',
  94. align: 'center'
  95. },
  96. {
  97. prop: 'miniCost',
  98. label: '最低消费',
  99. align: 'center',
  100. emptyText: '无'
  101. },
  102. {
  103. prop: 'addTime',
  104. label: '领取时间',
  105. align: 'center',
  106. width: 150
  107. },
  108. {
  109. prop: 'deadline',
  110. label: '到期时间',
  111. align: 'center',
  112. width: 150
  113. },
  114. {
  115. prop: 'source',
  116. label: '来源',
  117. align: 'center'
  118. },
  119. {
  120. prop: 'status',
  121. label: '状态',
  122. align: 'center'
  123. }
  124. ],
  125. // 操作列
  126. op: {
  127. visible: false, // 是否显示
  128. // 同 element-ui Table-column Attributes
  129. props: {
  130. width: 150,
  131. align: 'center',
  132. fixed: 'right',
  133. label: '操作'
  134. },
  135. // 布局,请移步 `layout`
  136. layout: ['slot-recharge', 'slot-upgrade', 'slot-ship']
  137. }
  138. })
  139. .set('layout', [
  140. ['slot-tabs'],
  141. ['flex1', 'refresh-btn'],
  142. ['data-table'],
  143. ['flex1', 'pagination']
  144. ])
  145. .on('refresh', async (params, { next }) => {
  146. // 继续执行刷新
  147. let { asset } = await next(params);
  148. this.tabsData[0].val = asset.totalNum;
  149. this.tabsData[1].val = asset.unUseNum;
  150. this.tabsData[2].val = asset.useNum;
  151. this.tabsData[3].val = asset.invalidNum;
  152. })
  153. .done();
  154. app.refresh({ status: this.tabIndex });
  155. }
  156. }
  157. };
  158. </script>