mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-22 10:55:54 +08:00
提交促销以己部分页面商家端功能迁移,接口对接
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.promotionName"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
placeholder="活动名称"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
@@ -19,7 +19,7 @@
|
||||
<DatePicker
|
||||
type="datetimerange"
|
||||
v-model="form.rangeTime"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
placeholder="请选择"
|
||||
:options="options"
|
||||
@@ -30,7 +30,7 @@
|
||||
<FormItem label="活动描述" prop="description">
|
||||
<Input
|
||||
v-model="form.description"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
clearable
|
||||
@@ -45,7 +45,7 @@
|
||||
<Input
|
||||
type="text"
|
||||
v-model="form.fullMoney"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
placeholder="优惠门槛"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
@@ -58,8 +58,8 @@
|
||||
button-style="solid"
|
||||
v-model="form.discountType"
|
||||
>
|
||||
<Radio label="fullMinusFlag" disabled>减现金</Radio>
|
||||
<Radio label="fullRateFlag" disabled>打折</Radio>
|
||||
<Radio label="fullMinusFlag" :disabled="form.promotionStatus != 'NEW'">减现金</Radio>
|
||||
<Radio label="fullRateFlag" :disabled="form.promotionStatus != 'NEW'">打折</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
@@ -69,7 +69,7 @@
|
||||
>
|
||||
<Input
|
||||
type="text"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
v-model="form.fullMinus"
|
||||
placeholder="优惠金额"
|
||||
clearable
|
||||
@@ -85,24 +85,24 @@
|
||||
type="text"
|
||||
v-model="form.fullRate"
|
||||
placeholder="优惠折扣"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
<span class="describe">优惠折扣为0-10之间数字,可有一位小数</span>
|
||||
</FormItem>
|
||||
<FormItem label="额外赠送">
|
||||
<Checkbox v-model="form.freeFreightFlag" disabled>免邮费</Checkbox
|
||||
<Checkbox v-model="form.freeFreightFlag" :disabled="form.promotionStatus != 'NEW'">免邮费</Checkbox
|
||||
>
|
||||
<Checkbox v-model="form.couponFlag" disabled>送优惠券</Checkbox
|
||||
<Checkbox v-model="form.couponFlag" :disabled="form.promotionStatus != 'NEW'">送优惠券</Checkbox
|
||||
>
|
||||
<Checkbox v-model="form.giftFlag" disabled>送赠品</Checkbox>
|
||||
<Checkbox v-model="form.pointFlag" disabled>送积分</Checkbox>
|
||||
<Checkbox v-model="form.giftFlag" :disabled="form.promotionStatus != 'NEW'">送赠品</Checkbox>
|
||||
<Checkbox v-model="form.pointFlag" :disabled="form.promotionStatus != 'NEW'">送积分</Checkbox>
|
||||
</FormItem>
|
||||
<FormItem v-if="form.couponFlag" label="赠送优惠券" prop="couponId">
|
||||
<Select
|
||||
v-model="form.couponId"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
::disabled="form.promotionStatus != 'NEW'"
|
||||
filterable
|
||||
:remote-method="getCouponList"
|
||||
placeholder="输入优惠券名称搜索"
|
||||
@@ -123,7 +123,7 @@
|
||||
filterable
|
||||
:remote-method="getGiftList"
|
||||
placeholder="输入赠品名称搜索"
|
||||
disabled
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
:loading="giftLoading"
|
||||
style="width: 260px"
|
||||
>
|
||||
@@ -136,10 +136,10 @@
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem v-if="form.pointFlag" label="赠积分" prop="point">
|
||||
<Input
|
||||
<InputNumber
|
||||
v-model="form.point"
|
||||
type="number"
|
||||
disabled
|
||||
:min="0"
|
||||
:disabled="form.promotionStatus != 'NEW'"
|
||||
style="width: 260px"
|
||||
/>
|
||||
</FormItem>
|
||||
@@ -149,8 +149,8 @@
|
||||
button-style="solid"
|
||||
v-model="form.scopeType"
|
||||
>
|
||||
<Radio label="ALL" disabled>全品类</Radio>
|
||||
<Radio label="PORTION_GOODS" disabled>指定商品</Radio>
|
||||
<Radio label="ALL" :disabled="form.promotionStatus != 'NEW'">全品类</Radio>
|
||||
<Radio label="PORTION_GOODS" :disabled="form.promotionStatus != 'NEW'">指定商品</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
|
||||
@@ -185,25 +185,32 @@
|
||||
</Poptip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</Table>
|
||||
</FormItem>
|
||||
|
||||
<div>
|
||||
<Button
|
||||
@click="$router.push({ name: 'promotions/full-discount' })"
|
||||
>返回</Button
|
||||
>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<FormItem label="操作" >
|
||||
<div>
|
||||
<Button
|
||||
@click="$router.push({ name: 'promotions/full-discount' })"
|
||||
>返回</Button
|
||||
>
|
||||
<Button type="primary" class="ml_10" :disabled="form.promotionStatus != 'NEW' && !!id" :loading="submitLoading"
|
||||
@click="handleSubmit">提交</Button>
|
||||
</div>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPlatformCouponList, getFullDiscountById } from "@/api/promotion";
|
||||
import { getPlatformCouponList, getFullDiscountById, newFullDiscount, editFullDiscount,} from "@/api/promotion";
|
||||
import { getGoodsSkuData } from "@/api/goods";
|
||||
import { regular } from "@/utils";
|
||||
import vueQr from "vue-qr";
|
||||
export default {
|
||||
name: "add-full-discount",
|
||||
@@ -211,15 +218,66 @@ export default {
|
||||
"vue-qr": vueQr,
|
||||
},
|
||||
data() {
|
||||
const checkPrice = (rule, value, callback) => {
|
||||
if (!value && value !== 0) {
|
||||
return callback(new Error("面额不能为空"));
|
||||
} else if (!regular.money.test(value)) {
|
||||
callback(new Error("请输入正整数或者两位小数"));
|
||||
} else if (parseFloat(value) > 99999999) {
|
||||
callback(new Error("面额设置超过上限值"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const checkWeight = (rule, value, callback) => {
|
||||
if (!value && typeof value !== "number") {
|
||||
callback(new Error("优惠门槛不能为空"));
|
||||
} else if (!regular.money.test(value)) {
|
||||
callback(new Error("请输入正整数或者两位小数"));
|
||||
} else if (parseFloat(value) > 99999999) {
|
||||
callback(new Error("优惠门槛设置超过上限值"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
form: {
|
||||
// 表单
|
||||
discountType: "fullMinusFlag",
|
||||
scopeType: "ALL",
|
||||
promotionGoodsList: [],
|
||||
promotionStatus: "NEW",
|
||||
},
|
||||
id: this.$route.query.id, // 活动id
|
||||
couponList: [], // 优惠券列表
|
||||
selectedGoods: [], // 已选商品列表,便于删除
|
||||
submitLoading: false, // 添加或编辑提交状态
|
||||
formRule: {
|
||||
// 验证规则
|
||||
promotionName: [{ required: true, message: "活动名称不能为空" }],
|
||||
rangeTime: [{ required: true, message: "请选择活动时间" }],
|
||||
description: [{ required: true, message: "请填写活动描述" }],
|
||||
price: [
|
||||
{ required: true, message: "请输入面额" },
|
||||
{ validator: checkPrice },
|
||||
],
|
||||
consumptionLimit: [{ required: true, validator: checkWeight }],
|
||||
fullMoney: [{ required: true, validator: checkWeight }],
|
||||
fullMinus: [
|
||||
{ required: true, message: "请填写优惠金额" },
|
||||
{ pattern: regular.money, message: "请输入正确金额" },
|
||||
],
|
||||
fullRate: [
|
||||
{ required: true, message: "请填写优惠折扣" },
|
||||
{
|
||||
pattern: regular.discount,
|
||||
message: "请输入0-10的数字,可有一位小数",
|
||||
},
|
||||
],
|
||||
couponId: [{ required: true, message: "请选择优惠券" }],
|
||||
giftId: [{ required: true, message: "请选择赠品" }],
|
||||
point: [{ required: true, message: "请填写积分" }],
|
||||
},
|
||||
couponList: [], // 优惠券列表
|
||||
giftList: [], // 赠品列表
|
||||
giftLoading: false, // 赠品加载状态
|
||||
columns: [
|
||||
@@ -257,6 +315,8 @@ export default {
|
||||
async mounted() {
|
||||
if (this.id) {
|
||||
this.getDetail();
|
||||
this.columns.shift()
|
||||
this.columns.pop()
|
||||
}
|
||||
this.getCouponList();
|
||||
this.getGiftList();
|
||||
@@ -318,6 +378,122 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/** 保存 */
|
||||
handleSubmit () {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const params = JSON.parse(JSON.stringify(this.form));
|
||||
const strat = this.$options.filters.unixToDate(
|
||||
this.form.rangeTime[0] / 1000
|
||||
);
|
||||
const end = this.$options.filters.unixToDate(
|
||||
this.form.rangeTime[1] / 1000
|
||||
);
|
||||
params.startTime = strat;
|
||||
params.endTime = end;
|
||||
|
||||
if (
|
||||
params.scopeType == "PORTION_GOODS" &&
|
||||
(!params.promotionGoodsList ||
|
||||
params.promotionGoodsList.length == 0)
|
||||
) {
|
||||
this.$Modal.warning({ title: "提示", content: "请选择指定商品" });
|
||||
return;
|
||||
}
|
||||
if (params.scopeType == "ALL") {
|
||||
delete params.promotionGoodsList;
|
||||
params.number = -1;
|
||||
} else {
|
||||
let scopeId = [];
|
||||
params.number = 1;
|
||||
params.promotionGoodsList.forEach((e) => {
|
||||
e.startTime = params.startTime;
|
||||
e.endTime = params.endTime;
|
||||
scopeId.push(e.skuId);
|
||||
});
|
||||
params.scopeId = scopeId.toString();
|
||||
}
|
||||
if (params.discountType == "fullMinusFlag") {
|
||||
params.fullMinusFlag = true;
|
||||
} else {
|
||||
params.fullRateFlag = true;
|
||||
}
|
||||
delete params.rangeTime;
|
||||
// this.submitLoading = true;
|
||||
if (!this.id) {
|
||||
// 添加 避免编辑后传入id等数据 记得删除
|
||||
delete params.id;
|
||||
newFullDiscount(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("添加活动成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 编辑
|
||||
delete params.updateTime;
|
||||
|
||||
editFullDiscount(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
if (res.success) {
|
||||
this.$Message.success("编辑活动成功");
|
||||
this.closeCurrentPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
changeSelect (e) {
|
||||
// 已选商品批量选择
|
||||
this.selectedGoods = e;
|
||||
},
|
||||
|
||||
delSelectGoods () {
|
||||
// 多选删除商品
|
||||
if (this.selectedGoods.length <= 0) {
|
||||
this.$Message.warning("您还未选择要删除的数据");
|
||||
return;
|
||||
}
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
content: "您确认要删除所选商品吗?",
|
||||
onOk: () => {
|
||||
let ids = [];
|
||||
this.selectedGoods.forEach(function (e) {
|
||||
ids.push(e.id);
|
||||
});
|
||||
this.form.promotionGoodsList = this.form.promotionGoodsList.filter(
|
||||
(item) => {
|
||||
return !ids.includes(item.id);
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
delGoods (index) {
|
||||
// 删除商品
|
||||
this.form.promotionGoodsList.splice(index, 1);
|
||||
},
|
||||
selectedGoodsData (item) {
|
||||
// 回显已选商品
|
||||
let list = [];
|
||||
item.forEach((e) => {
|
||||
list.push({
|
||||
goodsName: e.goodsName,
|
||||
price: e.price,
|
||||
quantity: e.quantity,
|
||||
storeId: e.storeId,
|
||||
storeName: e.storeName,
|
||||
thumbnail: e.thumbnail,
|
||||
skuId: e.id,
|
||||
});
|
||||
});
|
||||
this.form.promotionGoodsList = list;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user