Commit 2e94c9b5 by zhangxw

联调优化修改

1 parent 0d0fec04
......@@ -19,7 +19,9 @@
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'activityName'">
<div @click="handleAdd({...record, pageState: 'VIEW'})">
<a style="text-decoration: underline;" class="text_hide" :title="record.activityName">{{ record.activityName }}</a>
<a-tooltip :title="record.activityName">
<a style="text-decoration: underline;display: inline-block;width:145px;" class="text_hide">{{ record.activityName }}</a>
</a-tooltip>
<div class="text_hide second_text" :title="record.activityId">ID:{{ record.activityId }}</div>
</div>
</template>
......@@ -49,7 +51,7 @@
<template v-if="column.key === 'couponIds'">
<div v-if="record.couponTemplates?.length === 1">
<a-tooltip :title="`${record.couponTemplates[0].templateName} 券面额:${record.couponTemplates[0].faceAmount}`">
{{ record.couponTemplates[0].templateName }}
<div class="text_hide">{{ record.couponTemplates[0].templateName }}</div>
</a-tooltip>
</div>
<div style="text-decoration: underline;" v-else-if="record.couponTemplates?.length > 1">
......
......@@ -188,7 +188,7 @@
<div class="footer_btn">
<a-space v-if="!isViewMode">
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="handleOk()">创建</a-button>
<a-button type="primary" @click="handleOk()">{{pageState === 'EDIT' ? '保存' : '创建'}}</a-button>
</a-space>
<a-space v-else>
<a-button type="primary" @click="onClose">返回</a-button>
......@@ -225,6 +225,7 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
couponTemplateOptions: OptionItem[] = [];
relationAgreementOptions: AgreementOption[] = [];
activeAutoActivities: any[] = [];
priceRangeValidateTimer: any = null;
dialogVisible = false;
titleVisible = "创建发放活动";
......@@ -302,6 +303,36 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
return false;
}
isPriceRangeValid(index: number) {
const rule = this.postData.priceRanges?.[index];
const min = this.parsePositiveInt(rule?.priceMin);
const max = this.parsePositiveInt(rule?.priceMax);
if (min === null || max === null) return false;
if (!(max > min)) return false;
if (this.isTriggerRangeOverlapped(index, min, max)) return false;
return true;
}
scheduleClearPriceRangeValidate() {
if (this.priceRangeValidateTimer) {
clearTimeout(this.priceRangeValidateTimer);
this.priceRangeValidateTimer = null;
}
this.priceRangeValidateTimer = setTimeout(() => {
this.priceRangeValidateTimer = null;
const formRef: any = (this.$refs as any)?.formRef;
if (!formRef?.clearValidate) return;
const ranges = Array.isArray(this.postData.priceRanges) ? this.postData.priceRanges : [];
const clearNames: any[] = [];
for (let i = 0; i < ranges.length; i += 1) {
if (!this.isPriceRangeValid(i)) continue;
clearNames.push(["priceRanges", i, "priceMin"]);
clearNames.push(["priceRanges", i, "priceMax"]);
}
if (clearNames.length) formRef.clearValidate(clearNames);
}, 50);
}
priceMinRules(index: number) {
return [
{ required: true, message: "请输入下限" },
......@@ -382,6 +413,7 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
if (this.postData.priceRanges?.[index]) {
this.postData.priceRanges[index][field] = next;
}
this.scheduleClearPriceRangeValidate();
}
handlePerUserQuantityInput(e: any) {
......@@ -771,7 +803,7 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
color: rgba(0, 0, 0, 0.65);
}
.list-content {
height: 280px; /* 固定内容区域高度 */
max-height: 280px;
overflow-y: auto; /* 内容滚动 */
}
.footer_btn {
......
......@@ -207,7 +207,7 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
createVNode(
"p",
{ style: { marginBottom: "8px" } },
"停用后,当前优惠券将无法被新的发放活动关联,且已关联的【自动发放】活动同步停售。"
"停用后,当前优惠券将无法被新的发放活动关联,且已关联的【自动发放】活动将同步停售。"
),
createVNode(
"p",
......
......@@ -48,11 +48,11 @@
</a-form-item>
<template v-if="postData.couponType === 2">
<a-form-item name="faceAmount" label="券面额" :rules="ladderDisplayAmountRules" validate-trigger="blur">
<a-form-item name="faceAmount" label="展示面额" :rules="ladderDisplayAmountRules" validate-trigger="blur">
<div class="input-affix wid_376 affix-suffix-only">
<span class="affix suffix">元</span>
<a-input v-model:value="postData.faceAmount"
placeholder="请输入券面额" :disabled="isLadderDisplayAmountDisabled" @input="handleDecimalNativeInput('faceAmount', $event)" @blur="handleLadderDisplayAmountBlur" />
placeholder="建议填写最高抵扣金额" :disabled="isLadderDisplayAmountDisabled" @input="handleDecimalNativeInput('faceAmount', $event)" @blur="handleLadderDisplayAmountBlur" />
</div>
<div v-if="isLadderDisplayAmountDisabled" class="form-tip">已自动提取阶梯规则中的最高抵扣金额作为券面额</div>
</a-form-item>
......@@ -148,7 +148,7 @@
<div class="footer_btn">
<a-space v-if="!isViewMode">
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="handleOk()">创建</a-button>
<a-button type="primary" @click="handleOk()">{{pageState === 'EDIT' ? '保存' : '创建'}}</a-button>
</a-space>
<a-space v-else>
<a-button type="primary" @click="onClose">返回</a-button>
......@@ -159,15 +159,14 @@
</template>
<script lang="ts">
import { nextTick } from "vue";
import { nextTick, createVNode } from "vue";
import { Component, Watch } from "vue-facing-decorator";
import { EnhanceFormComponent } from "@/core/form/EnhanceFormComponent";
import { message } from "ant-design-vue";
import { message, Modal } from "ant-design-vue";
import TitleDivider from "@/components/TitleDivider.vue";
import { formatDate, parseDate } from "lib/src/utils/DateTimeUtils";
import { CloseOutlined } from "@ant-design/icons-vue";
import { CloseOutlined, InfoCircleFilled } from "@ant-design/icons-vue";
import { DiscountController } from "@/api/DiscountController";
@Component({
components: { TitleDivider, CloseOutlined }
})
......@@ -275,14 +274,14 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
return [
{
required: true,
message: "请输入券面额",
message: "请输入展示面额",
},
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.couponType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.resolve();
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入券面额"));
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入展示面额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
......@@ -527,21 +526,44 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
}
handleOk() {
this.$refs.formRef.validate().then(() => {
this.submitted = true;
const payload = this.buildSubmitPayload();
DiscountController[this.pageState === 'EDIT' ? 'editCouponTemplate' : 'createCouponTemplate'](this.axios, payload).then(res => {
let { code, message: msg } = res?.data || {};
if (code !== '200') {
message.error(msg || (this.pageState === 'EDIT' ? '更新失败' : '创建失败'));
return;
}
message.success(this.postData.templateId ? "更新成功" : "创建成功");
this.$emit("emitOk", payload);
this.dialogVisible = false;
})
if (this.postData.relatedActivities?.length > 0) {
Modal.confirm({
title: "风险提示:",
icon: createVNode(InfoCircleFilled, { style: { color: "#EB2F2F" } }),
content: createVNode("div", { style: { lineHeight: "22px" } }, [
createVNode(
"p",
{ style: { marginBottom: "8px" } },
`当前优惠券已关联发放活动,修改规则将立即对后续新发放的优惠券生效(已发放的不受影响),确认继续修改吗?`
)
]),
okText: "确认",
cancelText: "取消",
onOk: () => {
this.submitEvent()
},
});
} else {
this.submitEvent()
}
}).finally(() => this.submitted = false);
}
submitEvent() {
this.submitted = true;
const payload = this.buildSubmitPayload();
DiscountController[this.pageState === 'EDIT' ? 'editCouponTemplate' : 'createCouponTemplate'](this.axios, payload).then(res => {
let { code, message: msg } = res?.data || {};
if (code !== '200') {
message.error(msg || (this.pageState === 'EDIT' ? '更新失败' : '创建失败'));
return;
}
message.success(this.postData.templateId ? "更新成功" : "创建成功");
this.$emit("emitOk", payload);
this.dialogVisible = false;
})
}
buildSubmitPayload() {
const payload: any = {
id: this.postData.id || undefined,
......
<template>
<a-drawer width="936" title="手动发放优惠券" :maskClosable="false" :keyboard="false" placement="right" :open="dialogVisible" @close="onClose">
<a-form layout="vertical" :model="form" ref="formRef">
<a-form layout="vertical" :model="form" ref="formRef" style="padding-bottom: 10px;">
<a-form-item name="templateId" label="选择优惠券" :rules="[{ required: true, message: '请选择优惠券' }]">
<a-select v-model:value="form.templateId" placeholder="请选择优惠券" style="width: 376px;" :disabled="templateIdDisabled" @change="onTemplateChange">
<a-select-option v-for="option in couponTemplateOptions" :value="option.value" :key="option.value">
......@@ -80,13 +80,13 @@
</a-select>
</a-form-item>
<a-form-item name="remark" label="发放备注" :rules="[{ required: true, message: '请输入发放备注' }]">
<a-textarea v-model:value="form.remark" show-count :maxlength="200"
<a-textarea v-model:value="form.remark" show-count :maxlength="100"
placeholder="请说明本次发放的原因,如:XX活动用户补偿" :rows="4" />
</a-form-item>
</a-form>
<div class="footer_btn">
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="handleOk()">创建</a-button>
<a-button type="primary" @click="handleOk()">确认发放</a-button>
</div>
</a-drawer>
</template>
......@@ -125,6 +125,15 @@ export default class ManualIssuanceModal extends Vue {
couponTemplateOptions: OptionItem[] = [];
openByRecord(record: any) {
// 初始化数据
this.form = {
templateId: undefined as string | undefined,
templateName: "",
applicableType: "ACCOUNT",
accounts: [],
accountTags: [],
remark: ""
}
// 获取人员标签数据
AccountController.getAccountTags(this.axios).then(res => {
this.tags = res.data;
......@@ -164,7 +173,6 @@ export default class ManualIssuanceModal extends Vue {
delayDays: obj?.delayDays,
validDays: obj?.validDays,
}
console.log(obj)
}
onClose() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!