point tier rule allow greater than 0 for min
This commit is contained in:
@@ -288,6 +288,7 @@ function createTierForm(tier?: PointRuleTier, isLast = false, valueUnit?: EventI
|
||||
const pointValue = tier?.pointValue;
|
||||
return {
|
||||
key: tierKey++,
|
||||
minText: tier?.min === undefined || tier.min === null ? "0" : formatTierBoundaryValue(tier.min, valueUnit),
|
||||
maxText: !isLast && tier?.max !== undefined && tier.max !== null ? formatTierBoundaryValue(tier.max, valueUnit) : "",
|
||||
pointAction: pointValue !== undefined && pointValue < 0 ? "CONSUME" : "EARN",
|
||||
pointValueText: pointValue === undefined ? "0" : String(Math.abs(pointValue))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="tier-editor">
|
||||
<div class="title">
|
||||
<div v-text="`累计数值分档(${valueUnitText})`" />
|
||||
<div class="tips gray" v-text="`首档从 0 开始,末档不设上限;分档单位为${valueUnitText},积分为 0 不产生流水`" />
|
||||
<div class="tips gray" v-text="`首档起点可自定义,末档不设上限;分档单位为${valueUnitText},积分为 0 不产生流水`" />
|
||||
</div>
|
||||
<div class="list">
|
||||
<div
|
||||
@@ -42,7 +42,17 @@
|
||||
>
|
||||
<div class="tier-editor-popup">
|
||||
<t-form v-if="tierEditorIndex >= 0" class="form" label-align="left" label-width="10rem">
|
||||
<t-form-item :label="`最小值(${valueUnitText})`" content-align="right">
|
||||
<t-form-item v-if="tierEditorIndex < 1" :label="`最小值(${valueUnitText})`" required-mark>
|
||||
<t-input
|
||||
v-model.trim="tierEditorDraft.minText"
|
||||
type="number"
|
||||
:step="valueUnit === 'CENT' ? '0.01' : '1'"
|
||||
align="right"
|
||||
borderless
|
||||
:placeholder="valueUnit === 'CENT' ? '最多两位小数' : '请输入非负整数'"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item v-else :label="`最小值(${valueUnitText})`" content-align="right">
|
||||
<span class="gray" v-text="getTierMinText(tiers, tierEditorIndex, valueUnit)" />
|
||||
</t-form-item>
|
||||
<t-form-item
|
||||
@@ -98,6 +108,7 @@ const tierEditorVisible = ref(false);
|
||||
const tierEditorIndex = ref(-1);
|
||||
const tierEditorAdding = ref(false);
|
||||
const tierEditorDraft = reactive({
|
||||
minText: "",
|
||||
maxText: "",
|
||||
pointAction: "EARN" as PointAction,
|
||||
pointValueText: ""
|
||||
@@ -139,6 +150,7 @@ function openTierEditor(index: number, adding = false): void {
|
||||
}
|
||||
tierEditorIndex.value = index;
|
||||
tierEditorAdding.value = adding;
|
||||
tierEditorDraft.minText = index < 1 ? tier.minText : "";
|
||||
tierEditorDraft.maxText = adding ? "" : tier.maxText;
|
||||
tierEditorDraft.pointAction = tier.pointAction === "CONSUME" ? "CONSUME" : "EARN";
|
||||
tierEditorDraft.pointValueText = tier.pointValueText;
|
||||
@@ -156,10 +168,14 @@ function confirmTierEditor(): void {
|
||||
if (!tier) {
|
||||
return;
|
||||
}
|
||||
const min = getTierMinValue(tiers.value, index, valueUnit.value);
|
||||
const min = index < 1
|
||||
? resolveTierBoundaryValue(tierEditorDraft.minText, valueUnit.value)
|
||||
: getTierMinValue(tiers.value, index, valueUnit.value);
|
||||
const pointValue = resolveNonNegativeInteger(tierEditorDraft.pointValueText);
|
||||
if (min === undefined) {
|
||||
Toast.warning("请先修正上一档的最大值");
|
||||
Toast.warning(index < 1
|
||||
? valueUnit.value === "CENT" ? "首档最小值必须是非负且最多两位小数" : "首档最小值必须是非负整数"
|
||||
: "请先修正上一档的最大值");
|
||||
return;
|
||||
}
|
||||
if (pointValue === undefined) {
|
||||
@@ -177,6 +193,9 @@ function confirmTierEditor(): void {
|
||||
} else {
|
||||
tier.maxText = "";
|
||||
}
|
||||
if (index < 1) {
|
||||
tier.minText = formatTierBoundaryValue(min, valueUnit.value);
|
||||
}
|
||||
tier.pointValueText = String(pointValue);
|
||||
tier.pointAction = tierEditorDraft.pointAction;
|
||||
if (shouldAddTier) {
|
||||
@@ -209,6 +228,7 @@ function createTierForm(): PointRuleTierForm {
|
||||
const key = tiers.value.reduce((max, tier) => Math.max(max, tier.key), -1) + 1;
|
||||
return {
|
||||
key,
|
||||
minText: "0",
|
||||
maxText: "",
|
||||
pointAction: "EARN",
|
||||
pointValueText: "0"
|
||||
|
||||
Reference in New Issue
Block a user