index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="app-container">
  3. <doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
  4. <!-- 搜索工作栏 -->
  5. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  6. <el-form-item label="会员昵称" prop="nickname">
  7. <el-input v-model="queryParams.nickname" placeholder="请输入会员昵称" clearable @keyup.enter.native="handleQuery"/>
  8. </el-form-item>
  9. <el-form-item label="创建时间" prop="createTime">
  10. <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  11. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <!-- 操作工具栏 -->
  19. <el-row :gutter="10" class="mb8">
  20. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  21. </el-row>
  22. <!-- Tab 选项:真正的内容在 Lab -->
  23. <el-tabs v-model="activeTab" type="card" @tab-click="tabClick" style="margin-top: -40px;">
  24. <el-tab-pane v-for="tab in statusTabs" :key="tab.value" :label="tab.label" :name="tab.value" />
  25. </el-tabs>
  26. <!-- 列表 -->
  27. <el-table v-loading="loading" :data="list">
  28. <el-table-column label="会员信息" align="center" prop="nickname" /> <!-- TODO 芋艿:以后支持头像,支持跳转 -->
  29. <el-table-column label="优惠劵" align="center" prop="name" />
  30. <el-table-column label="优惠券类型" align="center" prop="discountType">
  31. <template v-slot="scope">
  32. <dict-tag :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :value="scope.row.discountType" />
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="领取方式" align="center" prop="takeType">
  36. <template v-slot="scope">
  37. <dict-tag :type="DICT_TYPE.PROMOTION_COUPON_TAKE_TYPE" :value="scope.row.takeType" />
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="状态" align="center" prop="status">
  41. <template v-slot="scope">
  42. <dict-tag :type="DICT_TYPE.PROMOTION_COUPON_STATUS" :value="scope.row.status" />
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="领取时间" align="center" prop="createTime" width="180">
  46. <template v-slot="scope">
  47. <span>{{ parseTime(scope.row.createTime) }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="使用时间" align="center" prop="useTime" width="180">
  51. <template v-slot="scope">
  52. <span>{{ parseTime(scope.row.useTime) }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  56. <template v-slot="scope">
  57. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  58. v-hasPermi="['promotion:coupon:delete']">回收</el-button>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. <!-- 分页组件 -->
  63. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  64. @pagination="getList"/>
  65. </div>
  66. </template>
  67. <script>
  68. import { deleteCoupon, getCouponPage } from "@/api/mall/promotion/coupon";
  69. import { DICT_TYPE, getDictDatas} from "@/utils/dict";
  70. export default {
  71. name: "PromotionCoupon",
  72. components: {
  73. },
  74. data() {
  75. return {
  76. // 遮罩层
  77. loading: true,
  78. // 导出遮罩层
  79. exportLoading: false,
  80. // 显示搜索条件
  81. showSearch: true,
  82. // 总条数
  83. total: 0,
  84. // 优惠劵列表
  85. list: [],
  86. // 弹出层标题
  87. title: "",
  88. // 是否显示弹出层
  89. open: false,
  90. // 查询参数
  91. queryParams: {
  92. pageNo: 1,
  93. pageSize: 10,
  94. createTime: [],
  95. status: undefined,
  96. },
  97. // Tab 筛选
  98. activeTab: 'all',
  99. statusTabs: [{
  100. label: '全部',
  101. value: 'all'
  102. }],
  103. };
  104. },
  105. created() {
  106. this.getList();
  107. // 设置 statuses 过滤
  108. for (const dict of getDictDatas(DICT_TYPE.PROMOTION_COUPON_STATUS)) {
  109. this.statusTabs.push({
  110. label: dict.label,
  111. value: dict.value
  112. })
  113. }
  114. },
  115. methods: {
  116. /** 查询列表 */
  117. getList() {
  118. this.loading = true;
  119. // 执行查询
  120. getCouponPage(this.queryParams).then(response => {
  121. this.list = response.data.list;
  122. this.total = response.data.total;
  123. this.loading = false;
  124. });
  125. },
  126. /** 取消按钮 */
  127. cancel() {
  128. this.open = false;
  129. this.reset();
  130. },
  131. /** 搜索按钮操作 */
  132. handleQuery() {
  133. this.queryParams.pageNo = 1;
  134. this.getList();
  135. },
  136. /** 重置按钮操作 */
  137. resetQuery() {
  138. this.resetForm("queryForm");
  139. this.handleQuery();
  140. },
  141. /** 删除按钮操作 */
  142. handleDelete(row) {
  143. const id = row.id;
  144. this.$modal.confirm('回收将会收回会员领取的待使用的优惠券,已使用的将无法回收,确定要回收所选优惠券吗?').then(function() {
  145. return deleteCoupon(id);
  146. }).then(() => {
  147. this.getList();
  148. this.$modal.msgSuccess("回收成功");
  149. }).catch(() => {});
  150. },
  151. /** tab 切换 */
  152. tabClick(tab) {
  153. this.queryParams.status = tab.name === 'all' ? undefined : tab.name;
  154. this.getList();
  155. }
  156. }
  157. };
  158. </script>