index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="app-container live-page">
  3. <div class="live-page__header">
  4. <h2 class="live-page__title">优惠券用户</h2>
  5. </div>
  6. <div class="live-panel" v-show="showSearch">
  7. <el-form class="live-search-form" :model="queryParams" ref="queryForm" :inline="true" label-width="100px">
  8. <el-form-item label="优惠券名称" prop="couponTitle">
  9. <el-input
  10. v-model="queryParams.couponTitle"
  11. placeholder="请输入优惠券名称"
  12. clearable
  13. size="small"
  14. @keyup.enter.native="handleQuery"
  15. />
  16. </el-form-item>
  17. <el-form-item label="状态" prop="status">
  18. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small" >
  19. <el-option
  20. v-for="item in statusOptions"
  21. :key="item.dictValue"
  22. :label="item.dictLabel"
  23. :value="item.dictValue"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="领取时间">
  28. <el-date-picker v-model="dateRange" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. </div>
  36. <div class="live-panel live-panel--table">
  37. <el-row :gutter="10" class="mb8">
  38. <!-- <el-col :span="1.5">
  39. <el-button
  40. type="danger"
  41. icon="el-icon-delete"
  42. size="mini"
  43. :disabled="multiple"
  44. @click="handleDelete"
  45. v-hasPermi="['company:companySmsLogs:remove']"
  46. >删除</el-button>
  47. </el-col> -->
  48. <el-col :span="1.5">
  49. <el-button
  50. type="warning"
  51. icon="el-icon-download"
  52. size="mini"
  53. @click="handleExport"
  54. v-hasPermi="['store:storeCouponUser:export']"
  55. >导出</el-button>
  56. </el-col>
  57. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. <el-table height="500" border v-loading="loading" :data="storeCouponUserList" @selection-change="handleSelectionChange" class="live-table">
  60. <el-table-column type="selection" width="55" align="center" />
  61. <el-table-column label="ID" align="center" prop="id" />
  62. <el-table-column label="会员昵称" align="center" prop="nickname" />
  63. <el-table-column label="会员手机号" align="center" prop="phone" />
  64. <el-table-column label="优惠券名称" align="center" prop="couponTitle" />
  65. <el-table-column label="优惠券的面值" align="center" prop="couponPrice" />
  66. <el-table-column label="最低消费" align="center" prop="useMinPrice" />
  67. <el-table-column label="优惠券结束时间" align="center" prop="limitTime" width="180">
  68. </el-table-column>
  69. <el-table-column label="领取时间" align="center" prop="createTime" width="180"></el-table-column>
  70. <el-table-column label="使用时间" align="center" prop="useTime" width="180">
  71. </el-table-column>
  72. <!-- <el-table-column label="获取方式" align="center" prop="type" /> -->
  73. <el-table-column label="状态" align="center" prop="status" >
  74. <template slot-scope="scope">
  75. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. </div>
  80. <pagination
  81. v-show="total>0"
  82. :total="total"
  83. :page.sync="queryParams.pageNum"
  84. :limit.sync="queryParams.pageSize"
  85. @pagination="getList"
  86. />
  87. </div>
  88. </template>
  89. <script>
  90. import { listStoreCouponUser, getStoreCouponUser, delStoreCouponUser, addStoreCouponUser, updateStoreCouponUser, exportStoreCouponUser } from "@/api/live/liveCouponUser";
  91. export default {
  92. name: "StoreCouponUser",
  93. data() {
  94. return {
  95. statusOptions:[],
  96. // 遮罩层
  97. loading: true,
  98. // 选中数组
  99. ids: [],
  100. dateRange:[],
  101. // 非单个禁用
  102. single: true,
  103. // 非多个禁用
  104. multiple: true,
  105. // 显示搜索条件
  106. showSearch: true,
  107. // 总条数
  108. total: 0,
  109. // 优惠券发放记录表格数据
  110. storeCouponUserList: [],
  111. // 弹出层标题
  112. title: "",
  113. // 是否显示弹出层
  114. open: false,
  115. // 查询参数
  116. queryParams: {
  117. pageNum: 1,
  118. pageSize: 10,
  119. couponId: null,
  120. userId: null,
  121. couponTitle: null,
  122. couponPrice: null,
  123. useMinPrice: null,
  124. endTime: null,
  125. useTime: null,
  126. type: null,
  127. status: null,
  128. isFail: null,
  129. isDel: null
  130. },
  131. // 表单参数
  132. form: {},
  133. // 表单校验
  134. rules: {
  135. couponId: [
  136. { required: true, message: "兑换的项目id不能为空", trigger: "blur" }
  137. ],
  138. userId: [
  139. { required: true, message: "优惠券所属用户不能为空", trigger: "blur" }
  140. ],
  141. couponTitle: [
  142. { required: true, message: "优惠券名称不能为空", trigger: "blur" }
  143. ],
  144. couponPrice: [
  145. { required: true, message: "优惠券的面值不能为空", trigger: "blur" }
  146. ],
  147. useMinPrice: [
  148. { required: true, message: "最低消费多少金额可用优惠券不能为空", trigger: "blur" }
  149. ],
  150. createTime: [
  151. { required: true, message: "优惠券创建时间不能为空", trigger: "blur" }
  152. ],
  153. endTime: [
  154. { required: true, message: "优惠券结束时间不能为空", trigger: "blur" }
  155. ],
  156. type: [
  157. { required: true, message: "获取方式不能为空", trigger: "change" }
  158. ],
  159. status: [
  160. { required: true, message: "状态不能为空", trigger: "blur" }
  161. ],
  162. isFail: [
  163. { required: true, message: "是否有效不能为空", trigger: "blur" }
  164. ],
  165. }
  166. };
  167. },
  168. created() {
  169. this.getDicts("store_coupon_user_status").then((response) => {
  170. this.statusOptions = response.data;
  171. });
  172. this.getList();
  173. },
  174. methods: {
  175. /** 查询优惠券发放记录列表 */
  176. getList() {
  177. this.loading = true;
  178. listStoreCouponUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  179. this.storeCouponUserList = response.rows;
  180. this.total = response.total;
  181. this.loading = false;
  182. });
  183. },
  184. // 取消按钮
  185. cancel() {
  186. this.open = false;
  187. this.reset();
  188. },
  189. // 表单重置
  190. reset() {
  191. this.form = {
  192. id: null,
  193. couponId: null,
  194. userId: null,
  195. couponTitle: null,
  196. couponPrice: null,
  197. useMinPrice: null,
  198. createTime: null,
  199. updateTime: null,
  200. endTime: null,
  201. useTime: null,
  202. type: null,
  203. status: 0,
  204. isFail: null,
  205. isDel: null
  206. };
  207. this.resetForm("form");
  208. },
  209. /** 搜索按钮操作 */
  210. handleQuery() {
  211. this.queryParams.pageNum = 1;
  212. this.getList();
  213. },
  214. /** 重置按钮操作 */
  215. resetQuery() {
  216. this.resetForm("queryForm");
  217. this.handleQuery();
  218. },
  219. // 多选框选中数据
  220. handleSelectionChange(selection) {
  221. this.ids = selection.map(item => item.id)
  222. this.single = selection.length!==1
  223. this.multiple = !selection.length
  224. },
  225. /** 新增按钮操作 */
  226. handleAdd() {
  227. this.reset();
  228. this.open = true;
  229. this.title = "添加优惠券发放记录";
  230. },
  231. /** 修改按钮操作 */
  232. handleUpdate(row) {
  233. this.reset();
  234. const id = row.id || this.ids
  235. getStoreCouponUser(id).then(response => {
  236. this.form = response.data;
  237. this.open = true;
  238. this.title = "修改优惠券发放记录";
  239. });
  240. },
  241. /** 提交按钮 */
  242. submitForm() {
  243. this.$refs["form"].validate(valid => {
  244. if (valid) {
  245. if (this.form.id != null) {
  246. updateStoreCouponUser(this.form).then(response => {
  247. if (response.code === 200) {
  248. this.msgSuccess("修改成功");
  249. this.open = false;
  250. this.getList();
  251. }
  252. });
  253. } else {
  254. addStoreCouponUser(this.form).then(response => {
  255. if (response.code === 200) {
  256. this.msgSuccess("新增成功");
  257. this.open = false;
  258. this.getList();
  259. }
  260. });
  261. }
  262. }
  263. });
  264. },
  265. /** 删除按钮操作 */
  266. handleDelete(row) {
  267. const ids = row.id || this.ids;
  268. this.$confirm('是否确认删除优惠券发放记录编号为"' + ids + '"的数据项?', "警告", {
  269. confirmButtonText: "确定",
  270. cancelButtonText: "取消",
  271. type: "warning"
  272. }).then(function() {
  273. return delStoreCouponUser(ids);
  274. }).then(() => {
  275. this.getList();
  276. this.msgSuccess("删除成功");
  277. }).catch(function() {});
  278. },
  279. /** 导出按钮操作 */
  280. handleExport() {
  281. const queryParams = this.queryParams;
  282. this.$confirm('是否确认导出所有优惠券发放记录数据项?', "警告", {
  283. confirmButtonText: "确定",
  284. cancelButtonText: "取消",
  285. type: "warning"
  286. }).then(function() {
  287. return exportStoreCouponUser(queryParams);
  288. }).then(response => {
  289. this.download(response.msg);
  290. }).catch(function() {});
  291. }
  292. }
  293. };
  294. </script>