index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="couponName">
  5. <el-input
  6. v-model="queryParams.couponName"
  7. placeholder="请输入优惠券名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="优惠券面值" prop="couponPrice">
  14. <el-input
  15. v-model="queryParams.couponPrice"
  16. placeholder="请输入优惠券面值"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="优惠券类型" prop="couponType">
  23. <el-select v-model="queryParams.couponType" placeholder="请选择优惠券类型" clearable size="small" >
  24. <el-option
  25. v-for="item in couponTypeOptions"
  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. size="mini"
  45. @click="handleRefresh"
  46. >刷新</el-button>
  47. </el-col>
  48. </el-row>
  49. <el-table height="500" border v-loading="loading" :data="storeCouponIssueList" @selection-change="handleSelectionChange">
  50. <el-table-column type="selection" width="55" align="center" />
  51. <el-table-column label="ID" align="center" prop="id" />
  52. <el-table-column label="优惠券" align="center" prop="couponName" />
  53. <el-table-column label="优惠券领取开始时间" align="center" prop="startTime" width="180">
  54. <template slot-scope="scope">
  55. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="优惠券领取结束时间" align="center" prop="limitTime" width="180">
  59. <template slot-scope="scope">
  60. <span>{{ parseTime(scope.row.limitTime, '{y}-{m}-{d}') }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="优惠券面值" align="center" prop="couponPrice" />
  64. <el-table-column label="最低消费" align="center" prop="useMinPrice" />
  65. <el-table-column label="优惠券有效期限(天)" align="center" prop="couponTime" />
  66. <el-table-column label="总数量" align="center" prop="totalCount" />
  67. <el-table-column label="剩余领取数量" align="center" prop="remainCount" />
  68. <el-table-column label="类型" align="center" prop="couponType" >
  69. <template slot-scope="scope">
  70. <el-tag prop="couponType" v-for="(item, index) in couponTypeOptions" v-if="scope.row.couponType==item.dictValue">{{item.dictLabel}}</el-tag>
  71. </template>
  72. </el-table-column>
  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-column label="发布时间" align="center" prop="createTime" />
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template slot-scope="scope">
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-edit"
  85. @click="handleUpdate(scope.row)"
  86. v-hasPermi="['store:storeCouponIssue:edit']"
  87. >修改</el-button>
  88. <el-button
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. v-hasPermi="['store:storeCouponIssue:remove']"
  94. >删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 添加或修改优惠券领取对话框 -->
  106. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  107. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  108. <el-form-item label="状态">
  109. <el-radio-group v-model="form.status">
  110. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  111. </el-radio-group>
  112. </el-form-item>
  113. </el-form>
  114. <div slot="footer" class="dialog-footer">
  115. <el-button type="primary" @click="submitForm">确 定</el-button>
  116. <el-button @click="cancel">取 消</el-button>
  117. </div>
  118. </el-dialog>
  119. </div>
  120. </template>
  121. <script>
  122. import { listStoreCouponIssue, getStoreCouponIssue, delStoreCouponIssue, addStoreCouponIssue, updateStoreCouponIssue, exportStoreCouponIssue } from "@/api/hisStore/storeCouponIssue";
  123. export default {
  124. name: "HisStoreCouponIssue",
  125. data() {
  126. return {
  127. couponTypeOptions:[],
  128. statusOptions:[],
  129. dateRange:[],
  130. // 遮罩层
  131. loading: true,
  132. // 选中数组
  133. ids: [],
  134. // 非单个禁用
  135. single: true,
  136. // 非多个禁用
  137. multiple: true,
  138. // 显示搜索条件
  139. showSearch: true,
  140. // 总条数
  141. total: 0,
  142. // 优惠券领取表格数据
  143. storeCouponIssueList: [],
  144. // 弹出层标题
  145. title: "",
  146. // 是否显示弹出层
  147. open: false,
  148. // 查询参数
  149. queryParams: {
  150. pageNum: 1,
  151. pageSize: 10,
  152. couponName: null,
  153. couponId: null,
  154. couponType: null,
  155. startTime: null,
  156. endTime: null,
  157. totalCount: null,
  158. remainCount: null,
  159. isPermanent: null,
  160. status: null,
  161. isDel: null,
  162. },
  163. // 表单参数
  164. form: {},
  165. // 表单校验
  166. rules: {
  167. isPermanent: [
  168. { required: true, message: "是否无限张数不能为空", trigger: "blur" }
  169. ],
  170. status: [
  171. { required: true, message: "1 正常 0 未开启 -1 已无效不能为空", trigger: "blur" }
  172. ],
  173. isDel: [
  174. { required: true, message: "1 正常 0 未开启 -1 已无效不能为空", trigger: "blur" }
  175. ],
  176. }
  177. };
  178. },
  179. created() {
  180. this.getDicts("common_status").then((response) => {
  181. this.statusOptions = response.data;
  182. });
  183. this.getDicts("store_coupon_type").then((response) => {
  184. this.couponTypeOptions = response.data;
  185. });
  186. this.getList();
  187. },
  188. methods: {
  189. handleRefresh(){
  190. this.getList();
  191. },
  192. /** 查询优惠券领取列表 */
  193. getList() {
  194. this.loading = true;
  195. listStoreCouponIssue(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  196. this.storeCouponIssueList = response.rows;
  197. this.total = response.total;
  198. this.loading = false;
  199. });
  200. },
  201. // 取消按钮
  202. cancel() {
  203. this.open = false;
  204. this.reset();
  205. },
  206. // 表单重置
  207. reset() {
  208. this.form = {
  209. id: null,
  210. couponName: null,
  211. couponId: null,
  212. couponType: null,
  213. startTime: null,
  214. endTime: null,
  215. totalCount: null,
  216. remainCount: null,
  217. isPermanent: null,
  218. status: 0,
  219. isDel: null,
  220. createTime: null,
  221. updateTime: null
  222. };
  223. this.resetForm("form");
  224. },
  225. /** 搜索按钮操作 */
  226. handleQuery() {
  227. this.queryParams.pageNum = 1;
  228. this.getList();
  229. },
  230. /** 重置按钮操作 */
  231. resetQuery() {
  232. this.dateRange = [];
  233. this.resetForm("queryForm");
  234. this.handleQuery();
  235. },
  236. // 多选框选中数据
  237. handleSelectionChange(selection) {
  238. this.ids = selection.map(item => item.id)
  239. this.single = selection.length!==1
  240. this.multiple = !selection.length
  241. },
  242. /** 新增按钮操作 */
  243. handleAdd() {
  244. this.reset();
  245. this.open = true;
  246. this.title = "添加优惠券领取";
  247. },
  248. /** 修改按钮操作 */
  249. handleUpdate(row) {
  250. this.reset();
  251. const id = row.id || this.ids
  252. getStoreCouponIssue(id).then(response => {
  253. this.form = response.data;
  254. this.form.status = response.data.status.toString();
  255. this.open = true;
  256. this.title = "修改优惠券领取";
  257. });
  258. },
  259. /** 提交按钮 */
  260. submitForm() {
  261. this.$refs["form"].validate(valid => {
  262. if (valid) {
  263. if (this.form.id != null) {
  264. updateStoreCouponIssue(this.form).then(response => {
  265. if (response.code === 200) {
  266. this.msgSuccess("修改成功");
  267. this.open = false;
  268. this.getList();
  269. }
  270. });
  271. } else {
  272. addStoreCouponIssue(this.form).then(response => {
  273. if (response.code === 200) {
  274. this.msgSuccess("新增成功");
  275. this.open = false;
  276. this.getList();
  277. }
  278. });
  279. }
  280. }
  281. });
  282. },
  283. /** 删除按钮操作 */
  284. handleDelete(row) {
  285. const ids = row.id || this.ids;
  286. this.$confirm('是否确认删除优惠券领取编号为"' + ids + '"的数据项?', "警告", {
  287. confirmButtonText: "确定",
  288. cancelButtonText: "取消",
  289. type: "warning"
  290. }).then(function() {
  291. return delStoreCouponIssue(ids);
  292. }).then(() => {
  293. this.getList();
  294. this.msgSuccess("删除成功");
  295. }).catch(function() {});
  296. },
  297. /** 导出按钮操作 */
  298. handleExport() {
  299. const queryParams = this.queryParams;
  300. this.$confirm('是否确认导出所有优惠券领取数据项?', "警告", {
  301. confirmButtonText: "确定",
  302. cancelButtonText: "取消",
  303. type: "warning"
  304. }).then(function() {
  305. return exportStoreCouponIssue(queryParams);
  306. }).then(response => {
  307. this.download(response.msg);
  308. }).catch(function() {});
  309. }
  310. }
  311. };
  312. </script>