This commit is contained in:
闫晓茹 2023-03-06 11:13:53 +08:00
parent b4395f9dac
commit 07e7e28bf5

View File

@ -26,8 +26,16 @@
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
@ -40,7 +48,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['system:coupon:add']"
>新增</el-button>
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -51,7 +60,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:coupon:edit']"
>修改</el-button>
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -62,7 +72,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:coupon:remove']"
>删除</el-button>
>删除</el-button
>
</el-col>
<!-- <el-col :span="1.5">
<el-button
@ -75,13 +86,25 @@
>导出</el-button
>
</el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="couponList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="couponList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="主键id" align="center" prop="id" /> -->
<el-table-column label="优惠券名称" align="center" prop="couponTitle" show-overflow-tooltip />
<el-table-column
label="优惠券名称"
align="center"
prop="couponTitle"
show-overflow-tooltip
/>
<el-table-column label="优惠券编码" align="center" prop="couponCode" />
<el-table-column label="优惠券类型" align="center" prop="couponType">
<template slot-scope="scope">
@ -92,9 +115,17 @@
</template>
</el-table-column>
<el-table-column label="优惠券有效期(天)" align="center" prop="couponReductionDays" />
<el-table-column
label="优惠券有效期(天)"
align="center"
prop="couponReductionDays"
/>
<el-table-column label="优惠券面额" align="center" prop="couponPrice" />
<el-table-column label="优惠券适用门槛" align="center" prop="couponConsumePrice" />
<el-table-column
label="优惠券适用门槛"
align="center"
prop="couponConsumePrice"
/>
<el-table-column label="领取方式" align="center" prop="receiveType">
<template slot-scope="scope">
{{ scope.row.receiveType == "NEW_PEOPLE_WELFARE" ? "新人福利" : "" }}
@ -114,7 +145,11 @@
</template>
</el-table-column>-->
<el-table-column label="显示顺序" align="center" prop="showSort" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -122,14 +157,16 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:coupon:edit']"
>修改</el-button>
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:coupon:remove']"
>删除</el-button>
>删除</el-button
>
</template>
</el-table-column>
</el-table>
@ -150,7 +187,13 @@
append-to-body
:before-close="cancel"
>
<el-form ref="form" :model="form" :rules="rules" label-width="130px" :inline="true">
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="130px"
:inline="true"
>
<el-form-item label="优惠券名称" prop="couponTitle">
<el-input
v-model="form.couponTitle"
@ -164,15 +207,16 @@
<el-input
maxlength="5"
oninput="value=value.replace(/[^\d]/g,'')"
v-model="form.couponReductionDays"
v-model.number="form.couponReductionDays"
placeholder="请输入优惠券有效期,单位:天"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="优惠券面额" prop="couponPrice">
<el-input
@keyup.native="form.couponPrice =oninput(form.couponPrice) "
@keyup.native="form.couponPrice = oninput(form.couponPrice)"
v-model="form.couponPrice"
maxlength="8"
placeholder="请输入优惠券面额,单位:元"
style="width: 220px"
@ -181,6 +225,7 @@
<el-form-item label="优惠券适用门槛" prop="couponConsumePrice">
<el-input
:change="checkPrice()"
maxlength="8"
v-model="form.couponConsumePrice"
placeholder="请输入优惠券适用门槛"
@ -236,28 +281,6 @@
placeholder="请输入优惠券概述,包括使用范围,使用注意事项等信息"
/>
</el-form-item>
<!-- <el-form-item label="发放数量" prop="receiveCount">
<el-input v-model="form.receiveCount" placeholder="请输入发放数量" />
</el-form-item>
<el-form-item label="发放数量上限" prop="receiveLimitCount">
<el-input v-model="form.receiveLimitCount" placeholder="请输入发放数量上限" />
</el-form-item>-->
<!-- <el-form-item label="全部商品" prop="useScope">
<el-select
style="width: 220px"
clearable
v-model="form.useScope"
placeholder="请选择全部商品"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>-->
<!-- </el-form-item> -->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -273,7 +296,7 @@ import {
getCoupon,
delCoupon,
addCoupon,
updateCoupon
updateCoupon,
} from "@/api/system/coupon";
export default {
@ -299,8 +322,8 @@ export default {
couponTypeoption: [
{
value: "FULL_REDUCTION_COUPON",
label: "满减券"
}
label: "满减券",
},
// {
// value: "CASH_COUPON",
// label: "",
@ -327,8 +350,8 @@ export default {
option: [
{
value: "NEW_PEOPLE_WELFARE",
label: "新人福利"
}
label: "新人福利",
},
// {
// value: "EVENT_GIFT",
// label: "",
@ -356,7 +379,7 @@ export default {
receiveCount: null,
receiveLimitCount: null,
useScope: null,
showSort: null
showSort: null,
},
//
form: {},
@ -366,50 +389,51 @@ export default {
{
required: true,
message: "请输入优惠券名称",
trigger: "blur"
}
trigger: "blur",
},
],
couponType: [
{
required: true,
message: "请选择优惠券类型",
trigger: "blur"
}
trigger: "blur",
},
],
couponReductionDays: [
{
required: true,
message: "请输入优惠券有效期",
trigger: "blur"
}
trigger: "blur",
},
],
couponPrice: [
{
required: true,
message: "请输入优惠券面额",
trigger: "blur"
}
trigger: "blur",
},
],
couponConsumePrice: [
{
required: true,
message: "请输入优惠券适用门槛",
trigger: "blur"
}
trigger: "blur",
},
],
couponDescription: [
{
required: true,
message: "请输入优惠券概述",
trigger: "blur"
}
trigger: "blur",
},
],
receiveType: [
{
required: true,
message: "请选择领取方式",
trigger: "blur"
}
trigger: "blur",
},
],
// useScope: [
// {
@ -422,10 +446,10 @@ export default {
{
required: true,
message: "请输入显示顺序",
trigger: "blur"
}
]
}
trigger: "blur",
},
],
},
};
},
created() {
@ -472,10 +496,7 @@ export default {
}
//
str = str.replace(/[^\d^.\\ .]+/g, ""); //
str = str
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", "."); //
str = str.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); //
str = str.replace(/^(-)*(\d+)\.(\d\d).*$/, "$1$2.$3");
return str;
},
@ -483,7 +504,7 @@ export default {
/** 查询优惠券信息列表 */
getList() {
this.loading = true;
listCoupon(this.queryParams).then(response => {
listCoupon(this.queryParams).then((response) => {
this.couponList = response.rows;
this.total = response.total;
this.loading = false;
@ -522,7 +543,7 @@ export default {
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
updateTime: null,
};
this.resetForm("form");
},
@ -538,7 +559,7 @@ export default {
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id);
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
@ -552,7 +573,7 @@ export default {
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getCoupon(id).then(response => {
getCoupon(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改优惠券信息";
@ -567,16 +588,16 @@ export default {
this.form.couponConsumePrice = Number(this.form.couponConsumePrice);
}
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateCoupon(this.form).then(response => {
updateCoupon(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addCoupon(this.form).then(response => {
addCoupon(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
@ -587,11 +608,11 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
const couponTitles = row.couponTitle || this.couponTitles;
this.$modal
.confirm('是否确认删除优惠券信息编号为"' + ids + '"的数据项?')
.then(function() {
return delCoupon(ids);
.confirm('是否确认删除优惠券名称为"' + couponTitles + '"的数据项?')
.then(function () {
return delCoupon(couponTitles);
})
.then(() => {
this.getList();
@ -604,11 +625,11 @@ export default {
this.download(
"system/coupon/export",
{
...this.queryParams
...this.queryParams,
},
`coupon_${new Date().getTime()}.xlsx`
);
}
}
},
},
};
</script>