index.vue 9.1 KB

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