fix point rule unit
This commit is contained in:
@@ -296,7 +296,15 @@ function getRuleConditionText(rule: PointRule): string {
|
||||
textList.push(`来源事件:${sourceEvent.value?.name || sourceEvent.value?.id || condition.sourceEventId}`);
|
||||
}
|
||||
if (condition.tiers?.length) {
|
||||
textList.push(condition.tiers.map(tier => `${tier.min}~${tier.max ?? "以上"}:${0 < tier.pointValue ? "发放" : "消耗"} ${Math.abs(tier.pointValue)} 分`).join(","));
|
||||
const tierSourceEvent = sourceEvent.value || (condition.sourceEventId === triggerEvent.value?.id ? triggerEvent.value : undefined);
|
||||
textList.push(condition.tiers.map(tier => {
|
||||
const minText = formatEventNumberValue(tierSourceEvent, tier.min);
|
||||
const maxText = tier.max === undefined || tier.max === null ? "以上" : formatEventNumberValue(tierSourceEvent, tier.max);
|
||||
const pointText = tier.pointValue === 0
|
||||
? "不产生积分流水"
|
||||
: `${0 < tier.pointValue ? "发放" : "消耗"} ${Math.abs(tier.pointValue)} 分`;
|
||||
return `${minText}~${maxText}:${pointText}`;
|
||||
}).join(","));
|
||||
}
|
||||
return textList.join(";") || "无额外条件";
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<t-form-item label="累计窗口(年)" label-width="8rem">
|
||||
<t-input v-model.trim="formModel.windowAmountText" type="number" align="right" borderless />
|
||||
</t-form-item>
|
||||
<point-rule-tier-editor v-model="formModel.tiers" />
|
||||
<point-rule-tier-editor v-model="formModel.tiers" :value-unit="selectedSourceValueUnit" />
|
||||
</template>
|
||||
</card-container>
|
||||
<card-container>
|
||||
@@ -91,9 +91,8 @@
|
||||
</t-form-item>
|
||||
</card-container>
|
||||
</t-form>
|
||||
<div class="bottom-actions">
|
||||
<div v-if="!isCreateMode" class="bottom-actions">
|
||||
<t-button
|
||||
v-if="!isCreateMode"
|
||||
v-can="permissionCodes.pointRule.delete"
|
||||
class="delete bg-white"
|
||||
theme="danger"
|
||||
@@ -103,15 +102,6 @@
|
||||
>
|
||||
删除
|
||||
</t-button>
|
||||
<t-button
|
||||
v-can="savePermissionCode"
|
||||
class="save"
|
||||
theme="primary"
|
||||
:loading="isSaving"
|
||||
@click="saveRule"
|
||||
>
|
||||
保存
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
||||
@@ -208,11 +198,13 @@ import EventAPI from "@/api/EventAPI";
|
||||
import PointAPI from "@/api/PointAPI";
|
||||
import PointRuleTierEditor from "@/pages/point/component/PointRuleTierEditor.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
import type { PointAction, PointRule, PointRuleMode, PointRuleStatus, PointRuleTier, PointRuleTierForm, PointRuleTriggerType } from "@/types/Point";
|
||||
import { getEventValueUnitText } from "@/utils/eventValue";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import { getTierMinValue, isLastTier, resolveNonNegativeInteger } from "@/utils/pointRule";
|
||||
import { formatTierBoundaryValue, getTierMinValue, isLastTier, resolveNonNegativeInteger, resolveTierBoundaryValue } from "@/utils/pointRule";
|
||||
|
||||
type PickerValue = string | number;
|
||||
|
||||
@@ -222,6 +214,7 @@ defineOptions({
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const navBarStore = useNavBarStore();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const routeId = computed(() => String(route.params.id || ""));
|
||||
@@ -282,20 +275,24 @@ const eventPickerColumns = computed(() => [
|
||||
const sourceEventPickerVisible = ref(false);
|
||||
const sourceEventPickerDraft = ref<PickerValue[]>([]);
|
||||
const sourceEventList = computed(() => eventList.value.filter(item => item.valueType === "NUMBER" && item.id));
|
||||
const selectedSourceEvent = computed(() => sourceEventList.value.find(item => item.id === formModel.sourceEventId));
|
||||
const selectedSourceValueUnit = computed(() => selectedSourceEvent.value?.valueUnit || null);
|
||||
const sourceEventPickerColumns = computed(() => [
|
||||
sourceEventList.value
|
||||
.map(item => ({ label: item.name || "未命名事件", value: item.id || "" }))
|
||||
.map(item => ({ label: `${item.name || "未命名事件"}(${getEventValueUnitText(item.valueUnit)})`, value: item.id || "" }))
|
||||
.filter(item => item.value)
|
||||
]);
|
||||
const selectedSourceEventName = computed(() => sourceEventList.value.find(item => item.id === formModel.sourceEventId)?.name || (formModel.sourceEventId ? `事件 ${formModel.sourceEventId}` : "请选择来源事件"));
|
||||
const selectedSourceEventName = computed(() => selectedSourceEvent.value
|
||||
? `${selectedSourceEvent.value.name || "未命名事件"}(${getEventValueUnitText(selectedSourceEvent.value.valueUnit)})`
|
||||
: formModel.sourceEventId ? `事件 ${formModel.sourceEventId}` : "请选择来源事件");
|
||||
|
||||
let tierKey = 0;
|
||||
|
||||
function createTierForm(tier?: PointRuleTier, isLast = false): PointRuleTierForm {
|
||||
function createTierForm(tier?: PointRuleTier, isLast = false, valueUnit?: EventItem["valueUnit"]): PointRuleTierForm {
|
||||
const pointValue = tier?.pointValue;
|
||||
return {
|
||||
key: tierKey++,
|
||||
maxText: !isLast && tier?.max !== undefined && tier.max !== null ? String(tier.max) : "",
|
||||
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))
|
||||
};
|
||||
@@ -360,6 +357,12 @@ function openSourceEventPicker(): void {
|
||||
function confirmSourceEventPicker(value: Array<string | number>): void {
|
||||
const sourceEventId = String(value[0] || "");
|
||||
if (sourceEventId) {
|
||||
const previousSourceEvent = sourceEventList.value.find(item => item.id === formModel.sourceEventId);
|
||||
const nextSourceEvent = sourceEventList.value.find(item => item.id === sourceEventId);
|
||||
if (formModel.sourceEventId && previousSourceEvent?.valueUnit !== nextSourceEvent?.valueUnit) {
|
||||
formModel.tiers = [createTierForm(undefined, true, nextSourceEvent?.valueUnit)];
|
||||
Toast.warning("来源事件单位已变化,原分档已清空,请重新配置");
|
||||
}
|
||||
formModel.sourceEventId = sourceEventId;
|
||||
}
|
||||
sourceEventPickerVisible.value = false;
|
||||
@@ -382,8 +385,11 @@ async function loadEventList(): Promise<void> {
|
||||
const options = isGlobalManager.value ? { storeId: formModel.storeId } : undefined;
|
||||
const result = await EventAPI.list({ index: 0, size: 1000 }, options);
|
||||
eventList.value = result.list || [];
|
||||
if (formModel.eventId && !eventList.value.some(item => item.id === formModel.eventId)) {
|
||||
eventList.value.push(await EventAPI.detail(formModel.eventId));
|
||||
const requiredEventIdList = [formModel.eventId, formModel.sourceEventId].filter((id, index, list) => id && list.indexOf(id) === index);
|
||||
for (const eventId of requiredEventIdList) {
|
||||
if (!eventList.value.some(item => item.id === eventId)) {
|
||||
eventList.value.push(await EventAPI.detail(eventId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,6 +577,7 @@ function resolveTimestamp(value: string): number | undefined {
|
||||
|
||||
function buildCondition(): PointRule["conditionJson"] {
|
||||
if (formModel.triggerType === "CUSTOMER_EVENT_VALUE_TIER") {
|
||||
const valueUnit = selectedSourceValueUnit.value;
|
||||
return {
|
||||
sourceEventId: formModel.sourceEventId,
|
||||
sourceValueField: "numberValue",
|
||||
@@ -580,12 +587,13 @@ function buildCondition(): PointRule["conditionJson"] {
|
||||
unit: "YEAR"
|
||||
},
|
||||
tiers: formModel.tiers.map((tier, index) => {
|
||||
const min = getTierMinValue(formModel.tiers, index, valueUnit);
|
||||
const result: PointRuleTier = {
|
||||
min: getTierMinValue(formModel.tiers, index) || 0,
|
||||
min: min ?? 0,
|
||||
pointValue: (tier.pointAction === "CONSUME" ? -1 : 1) * (resolveNonNegativeInteger(tier.pointValueText) || 0)
|
||||
};
|
||||
if (!isLastTier(formModel.tiers, index)) {
|
||||
result.max = resolveNonNegativeInteger(tier.maxText);
|
||||
result.max = resolveTierBoundaryValue(tier.maxText, valueUnit);
|
||||
}
|
||||
return result;
|
||||
})
|
||||
@@ -628,10 +636,14 @@ function validateForm(): boolean {
|
||||
Toast.warning("分档规则必须使用分档积分模式");
|
||||
return false;
|
||||
}
|
||||
if (!sourceEventList.value.some(item => item.id === formModel.sourceEventId)) {
|
||||
if (!selectedSourceEvent.value) {
|
||||
Toast.warning("请选择 NUMBER 类型的来源事件");
|
||||
return false;
|
||||
}
|
||||
if (selectedSourceValueUnit.value !== "CENT" && selectedSourceValueUnit.value !== "COUNT") {
|
||||
Toast.warning("来源事件必须配置数值单位");
|
||||
return false;
|
||||
}
|
||||
if (!resolvePositiveInteger(formModel.windowAmountText)) {
|
||||
Toast.warning("累计窗口必须是正整数");
|
||||
return false;
|
||||
@@ -642,7 +654,7 @@ function validateForm(): boolean {
|
||||
}
|
||||
for (let i = 0; i < formModel.tiers.length; i++) {
|
||||
const tier = formModel.tiers[i];
|
||||
const min = getTierMinValue(formModel.tiers, i);
|
||||
const min = getTierMinValue(formModel.tiers, i, selectedSourceValueUnit.value);
|
||||
const pointValue = resolveNonNegativeInteger(tier.pointValueText);
|
||||
if (min === undefined) {
|
||||
Toast.warning(`第 ${i + 1} 档的上一档最大值无效`);
|
||||
@@ -653,9 +665,11 @@ function validateForm(): boolean {
|
||||
return false;
|
||||
}
|
||||
if (!isLastTier(formModel.tiers, i)) {
|
||||
const max = resolveNonNegativeInteger(tier.maxText);
|
||||
const max = resolveTierBoundaryValue(tier.maxText, selectedSourceValueUnit.value);
|
||||
if (max === undefined || max < min) {
|
||||
Toast.warning(`第 ${i + 1} 档最大值必须是不小于最小值的整数`);
|
||||
Toast.warning(selectedSourceValueUnit.value === "CENT"
|
||||
? `第 ${i + 1} 档最大值必须是不小于最小值且最多两位小数`
|
||||
: `第 ${i + 1} 档最大值必须是不小于最小值的整数`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -786,31 +800,43 @@ async function fillForm(): Promise<void> {
|
||||
maxText: current.conditionJson?.max === undefined ? "" : String(Math.abs(current.conditionJson.max)),
|
||||
sourceEventId: current.conditionJson?.sourceEventId || "",
|
||||
windowAmountText: current.conditionJson?.window?.amount === undefined ? "1" : String(current.conditionJson.window.amount),
|
||||
tiers: current.conditionJson?.tiers?.length
|
||||
? current.conditionJson.tiers.map((tier, index, list) => createTierForm(tier, index === list.length - 1))
|
||||
: [createTierForm(undefined, true)],
|
||||
tiers: [],
|
||||
beginAtText: current.beginAt ? Time.toDateTime(current.beginAt) : "",
|
||||
endAtText: current.endAt ? Time.toDateTime(current.endAt) : "",
|
||||
priorityText: String(current.priority ?? 0),
|
||||
exclusive: current.exclusive ?? false,
|
||||
remark: current.remark || ""
|
||||
});
|
||||
await loadEventList();
|
||||
const valueUnit = selectedSourceValueUnit.value;
|
||||
formModel.tiers = current.conditionJson?.tiers?.length
|
||||
? current.conditionJson.tiers.map((tier, index, list) => createTierForm(tier, index === list.length - 1, valueUnit))
|
||||
: [createTierForm(undefined, true, valueUnit)];
|
||||
return;
|
||||
}
|
||||
await loadEventList();
|
||||
if (!formModel.tiers.length) {
|
||||
formModel.tiers.push(createTierForm(undefined, true, selectedSourceValueUnit.value));
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveRule);
|
||||
}
|
||||
try {
|
||||
await fillForm();
|
||||
} catch (error) {
|
||||
Toast.error(getErrorMessage(error, "积分规则加载失败"));
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => navBarStore.clearRight());
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.point-rule-edit {
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 5rem;
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 calc(1rem + env(safe-area-inset-bottom, 0));
|
||||
|
||||
.form {
|
||||
gap: 1rem;
|
||||
@@ -892,19 +918,12 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.bottom-actions {
|
||||
gap: .75rem;
|
||||
left: 1rem;
|
||||
right: 1rem;
|
||||
bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
|
||||
margin: 0 1rem;
|
||||
padding-top: 1rem;
|
||||
display: flex;
|
||||
position: fixed;
|
||||
|
||||
.delete {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.save {
|
||||
flex: 2;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="tier-editor">
|
||||
<div class="title">
|
||||
<div>累计数值分档</div>
|
||||
<div class="tips gray">首档从 0 开始,末档不设上限;积分为 0 不产生流水</div>
|
||||
<div v-text="`累计数值分档(${valueUnitText})`" />
|
||||
<div class="tips gray" v-text="`首档从 0 开始,末档不设上限;分档单位为${valueUnitText},积分为 0 不产生流水`" />
|
||||
</div>
|
||||
<div class="list">
|
||||
<div
|
||||
@@ -15,7 +15,11 @@
|
||||
<span class="index" v-text="`第 ${index + 1} 档`" />
|
||||
<strong v-text="getTierRangeText(index)" />
|
||||
</div>
|
||||
<div class="points text-bold" v-text="getTierPointText(tier)" />
|
||||
<div
|
||||
class="point text-bold"
|
||||
:class="{ 'consume': tier.pointAction === 'CONSUME' }"
|
||||
v-text="getTierPointText(tier)"
|
||||
/>
|
||||
<t-button
|
||||
v-if="1 < tiers.length"
|
||||
theme="danger"
|
||||
@@ -38,20 +42,28 @@
|
||||
>
|
||||
<div class="tier-editor-popup">
|
||||
<t-form v-if="tierEditorIndex >= 0" class="form" label-align="left" label-width="10rem">
|
||||
<t-form-item label="最小值" content-align="right">
|
||||
<span class="gray" v-text="getTierMinText(tiers, tierEditorIndex)" />
|
||||
<t-form-item :label="`最小值(${valueUnitText})`" content-align="right">
|
||||
<span class="gray" v-text="getTierMinText(tiers, tierEditorIndex, valueUnit)" />
|
||||
</t-form-item>
|
||||
<t-form-item v-if="!isLastTier(tiers, tierEditorIndex) || tierEditorAdding" :label="tierEditorAdding ? '当前档最大值' : '最大值'" required-mark>
|
||||
<t-form-item
|
||||
v-if="!isLastTier(tiers, tierEditorIndex) || tierEditorAdding"
|
||||
:label="`${tierEditorAdding ? '当前档最大值' : '最大值'}(${valueUnitText})`"
|
||||
required-mark
|
||||
>
|
||||
<t-input
|
||||
v-model.trim="tierEditorDraft.maxText"
|
||||
type="number"
|
||||
:step="valueUnit === 'CENT' ? '0.01' : '1'"
|
||||
align="right"
|
||||
borderless
|
||||
placeholder="请输入最大值"
|
||||
:placeholder="valueUnit === 'CENT' ? '最多两位小数' : '请输入整数'"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="积分动作" arrow @click="openActionPicker">
|
||||
<span class="picker-text" v-text="getPointActionText(tierEditorDraft.pointAction)" />
|
||||
<t-form-item label="积分动作" content-align="right">
|
||||
<t-radio-group v-model="tierEditorDraft.pointAction" variant="default-filled">
|
||||
<t-radio :block="false" borderless value="EARN">发放</t-radio>
|
||||
<t-radio :block="false" borderless value="CONSUME">消耗</t-radio>
|
||||
</t-radio-group>
|
||||
</t-form-item>
|
||||
<t-form-item label="积分数量" required-mark>
|
||||
<t-input
|
||||
@@ -66,26 +78,21 @@
|
||||
</t-form>
|
||||
</div>
|
||||
</bottom-popup>
|
||||
<t-popup v-model="actionPickerVisible" placement="bottom">
|
||||
<t-picker
|
||||
v-model="actionPickerDraft"
|
||||
:columns="actionPickerColumns"
|
||||
title="积分动作"
|
||||
@cancel="actionPickerVisible = false"
|
||||
@confirm="confirmActionPicker"
|
||||
/>
|
||||
</t-popup>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { EventValueUnit } from "@/types/EventItem";
|
||||
import type { PointAction, PointRuleTierForm } from "@/types/Point";
|
||||
import { getTierMinText, getTierMinValue, isLastTier, resolveNonNegativeInteger } from "@/utils/pointRule";
|
||||
import { formatTierBoundaryValue, getTierMinText, getTierMinValue, isLastTier, resolveNonNegativeInteger, resolveTierBoundaryValue } from "@/utils/pointRule";
|
||||
import { Toast } from "tdesign-mobile-vue";
|
||||
|
||||
defineOptions({
|
||||
name: "PointRuleTierEditor"
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
valueUnit?: EventValueUnit | null;
|
||||
}>();
|
||||
const tiers = defineModel<PointRuleTierForm[]>({ required: true });
|
||||
const tierEditorVisible = ref(false);
|
||||
const tierEditorIndex = ref(-1);
|
||||
@@ -95,31 +102,26 @@ const tierEditorDraft = reactive({
|
||||
pointAction: "EARN" as PointAction,
|
||||
pointValueText: ""
|
||||
});
|
||||
const actionOptions: Array<{ label: string; value: PointAction }> = [
|
||||
{ label: "发放积分", value: "EARN" },
|
||||
{ label: "消耗积分", value: "CONSUME" }
|
||||
];
|
||||
const actionPickerVisible = ref(false);
|
||||
const actionPickerDraft = ref<Array<string | number>>([]);
|
||||
const actionPickerColumns = [actionOptions];
|
||||
const tierEditorTitle = computed(() => {
|
||||
if (tierEditorIndex.value < 0) {
|
||||
return "编辑分档";
|
||||
}
|
||||
return tierEditorAdding.value ? `编辑第 ${tierEditorIndex.value + 1} 档并新增下一档` : `编辑第 ${tierEditorIndex.value + 1} 档`;
|
||||
});
|
||||
const valueUnit = computed(() => props.valueUnit);
|
||||
const valueUnitText = computed(() => valueUnit.value === "CENT" ? "元" : valueUnit.value === "COUNT" ? "次" : "数值");
|
||||
|
||||
function getTierRangeText(index: number): string {
|
||||
const tier = tiers.value[index];
|
||||
if (!tier) {
|
||||
return "待填写";
|
||||
}
|
||||
const minText = getTierMinText(tiers.value, index);
|
||||
const minText = getTierMinText(tiers.value, index, valueUnit.value);
|
||||
if (isLastTier(tiers.value, index)) {
|
||||
return `${minText} 及以上`;
|
||||
}
|
||||
const max = resolveNonNegativeInteger(tier.maxText);
|
||||
return max === undefined ? `${minText} - 待填写` : `${minText}-${max}`;
|
||||
const max = resolveTierBoundaryValue(tier.maxText, valueUnit.value);
|
||||
return max === undefined ? `${minText} - 待填写` : `${minText}-${formatTierBoundaryValue(max, valueUnit.value)}`;
|
||||
}
|
||||
|
||||
function getTierPointText(tier: PointRuleTierForm): string {
|
||||
@@ -127,7 +129,7 @@ function getTierPointText(tier: PointRuleTierForm): string {
|
||||
if (pointValue === undefined) {
|
||||
return "待填写";
|
||||
}
|
||||
return `${tier.pointAction === "CONSUME" ? "消耗" : "发放"} ${pointValue} 分`;
|
||||
return `${tier.pointAction === "CONSUME" ? "-" : "+"}${pointValue} 分`;
|
||||
}
|
||||
|
||||
function openTierEditor(index: number, adding = false): void {
|
||||
@@ -138,7 +140,7 @@ function openTierEditor(index: number, adding = false): void {
|
||||
tierEditorIndex.value = index;
|
||||
tierEditorAdding.value = adding;
|
||||
tierEditorDraft.maxText = adding ? "" : tier.maxText;
|
||||
tierEditorDraft.pointAction = tier.pointAction;
|
||||
tierEditorDraft.pointAction = tier.pointAction === "CONSUME" ? "CONSUME" : "EARN";
|
||||
tierEditorDraft.pointValueText = tier.pointValueText;
|
||||
tierEditorVisible.value = true;
|
||||
}
|
||||
@@ -154,7 +156,7 @@ function confirmTierEditor(): void {
|
||||
if (!tier) {
|
||||
return;
|
||||
}
|
||||
const min = getTierMinValue(tiers.value, index);
|
||||
const min = getTierMinValue(tiers.value, index, valueUnit.value);
|
||||
const pointValue = resolveNonNegativeInteger(tierEditorDraft.pointValueText);
|
||||
if (min === undefined) {
|
||||
Toast.warning("请先修正上一档的最大值");
|
||||
@@ -166,12 +168,12 @@ function confirmTierEditor(): void {
|
||||
}
|
||||
const shouldAddTier = tierEditorAdding.value && isLastTier(tiers.value, index);
|
||||
if (!isLastTier(tiers.value, index) || shouldAddTier) {
|
||||
const max = resolveNonNegativeInteger(tierEditorDraft.maxText);
|
||||
const max = resolveTierBoundaryValue(tierEditorDraft.maxText, valueUnit.value);
|
||||
if (max === undefined || max < min) {
|
||||
Toast.warning("当前档最大值必须是不小于最小值的整数");
|
||||
Toast.warning(valueUnit.value === "CENT" ? "当前档最大值必须是不小于最小值且最多两位小数" : "当前档最大值必须是不小于最小值的整数");
|
||||
return;
|
||||
}
|
||||
tier.maxText = String(max);
|
||||
tier.maxText = formatTierBoundaryValue(max, valueUnit.value);
|
||||
} else {
|
||||
tier.maxText = "";
|
||||
}
|
||||
@@ -203,23 +205,6 @@ function removeTier(index: number): void {
|
||||
tiers.value.splice(index, 1);
|
||||
}
|
||||
|
||||
function openActionPicker(): void {
|
||||
actionPickerDraft.value = [tierEditorDraft.pointAction];
|
||||
actionPickerVisible.value = true;
|
||||
}
|
||||
|
||||
function confirmActionPicker(value: Array<string | number>): void {
|
||||
const action = value[0];
|
||||
if (action === "EARN" || action === "CONSUME") {
|
||||
tierEditorDraft.pointAction = action;
|
||||
}
|
||||
actionPickerVisible.value = false;
|
||||
}
|
||||
|
||||
function getPointActionText(action: PointAction): string {
|
||||
return action === "CONSUME" ? "消耗积分" : "发放积分";
|
||||
}
|
||||
|
||||
function createTierForm(): PointRuleTierForm {
|
||||
const key = tiers.value.reduce((max, tier) => Math.max(max, tier.key), -1) + 1;
|
||||
return {
|
||||
@@ -271,13 +256,17 @@ function createTierForm(): PointRuleTierForm {
|
||||
}
|
||||
}
|
||||
|
||||
.points {
|
||||
.point {
|
||||
gap: .25rem;
|
||||
color: var(--td-brand-color);
|
||||
display: flex;
|
||||
font-size: 1.5rem;
|
||||
align-items: baseline;
|
||||
white-space: nowrap;
|
||||
|
||||
&.consume {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,6 +286,7 @@ function createTierForm(): PointRuleTierForm {
|
||||
padding: 0 1rem;
|
||||
font-size: .75rem;
|
||||
line-height: 1.5;
|
||||
margin-top: .5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user