index.vue 9.4 KB

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