couponComponent.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="标题" prop="title">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入标题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="有效期" prop="limitTime">
  14. <el-date-picker v-model="limitTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  15. </el-form-item>
  16. <el-form-item label="面额" prop="price">
  17. <el-input
  18. v-model="queryParams.price"
  19. placeholder="请输入面额"
  20. clearable
  21. size="small"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-row :gutter="10" class="mb8">
  31. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  32. </el-row>
  33. <el-table v-loading="loading" border :data="couponList">
  34. <el-table-column label="优惠券名称" align="center" prop="title" width="120px"/>
  35. <el-table-column label="面额" align="center" prop="price" />
  36. <el-table-column label="折扣" align="center" prop="rate" />
  37. <el-table-column label="数量" align="center" prop="number" />
  38. <el-table-column label="卷类型 " align="center" prop="couponType" width="120px">
  39. <template slot-scope="scope">
  40. <dict-tag :options="couponTypeOptions" :value="scope.row.couponType"/>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="状态" align="center" prop="status">
  44. <template slot-scope="scope">
  45. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="最低消费金额可用" align="center" prop="minPrice" />
  49. <el-table-column label="剩余数量" align="center" prop="remainNumber" />
  50. <el-table-column label="有效期" align="center" prop="limitTime" width="180"/>
  51. <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
  52. <el-table-column label="更改时间" align="center" prop="updateTime" width="180"/>
  53. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150px">
  54. <template slot-scope="scope">
  55. <el-button
  56. size="mini"
  57. type="text"
  58. @click="selectCoupon(scope.row)"
  59. >选择
  60. </el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination
  65. v-show="total>0"
  66. :total="total"
  67. :page.sync="queryParams.pageNum"
  68. :limit.sync="queryParams.pageSize"
  69. @pagination="getList"
  70. />
  71. </div>
  72. </template>
  73. <script>
  74. import { listCoupon } from "@/api/his/coupon";
  75. export default {
  76. name: "CouponComponent",
  77. data() {
  78. return {
  79. limitTime:[],
  80. // 遮罩层
  81. loading: true,
  82. // 显示搜索条件
  83. showSearch: true,
  84. // 总条数
  85. total: 0,
  86. // 优惠券表格数据
  87. couponList: [],
  88. statusOptions: [],
  89. // 卷类型 1代金券 字典
  90. couponTypeOptions: [],
  91. // 查询参数
  92. queryParams: {
  93. pageNum: 1,
  94. pageSize: 10,
  95. title: null,
  96. limitTime: null,
  97. price: null,
  98. number: null,
  99. couponType: 7,
  100. minPrice: null,
  101. remainNumber: null,
  102. sTime:null,
  103. eTime:null
  104. },
  105. };
  106. },
  107. created() {
  108. this.getList();
  109. this.getDicts("sys_coupon_type").then(response => {
  110. this.couponTypeOptions = response.data;
  111. });
  112. this.getDicts("sys_company_status").then(response => {
  113. this.statusOptions = response.data;
  114. });
  115. },
  116. methods: {
  117. selectCoupon(row) {
  118. this.$emit("select-coupon", {"id": row.couponId, "name": row.title });
  119. },
  120. /** 查询优惠券列表 */
  121. getList() {
  122. this.loading = true;
  123. listCoupon(this.queryParams).then(response => {
  124. this.couponList = response.rows;
  125. this.total = response.total;
  126. this.loading = false;
  127. });
  128. },
  129. // 取消按钮
  130. cancel() {
  131. this.reset();
  132. },
  133. // 表单重置
  134. reset() {
  135. this.form = {
  136. couponId: null,
  137. title: null,
  138. createTime: null,
  139. limitTime: null,
  140. price: null,
  141. number: null,
  142. couponType: null,
  143. minPrice: null,
  144. remainNumber: null,
  145. status:"1",
  146. rate:0,
  147. limitDay:1,
  148. limitCount:1,
  149. limitType:null,
  150. cateIds:null,
  151. };
  152. this.resetForm("form");
  153. },
  154. /** 搜索按钮操作 */
  155. handleQuery() {
  156. this.queryParams.pageNum = 1;
  157. this.getList();
  158. },
  159. /** 重置按钮操作 */
  160. resetQuery() {
  161. this.resetForm("queryForm");
  162. this.limitTime=null;
  163. this.queryParams.sTime=null;
  164. this.queryParams.eTime=null;
  165. this.handleQuery();
  166. },
  167. change(){
  168. if(this.limitTime!=null){
  169. this.queryParams.sTime=this.limitTime[0];
  170. this.queryParams.eTime=this.limitTime[1];
  171. }else{
  172. this.queryParams.sTime=null;
  173. this.queryParams.eTime=null;
  174. }
  175. },
  176. }
  177. };
  178. </script>
  179. <style scoped>
  180. ::v-deep .el-table--scrollable-x .el-table__body-wrapper {
  181. height: 70vh;
  182. }
  183. </style>