index.vue 10 KB

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