diff --git a/web/src/views/backend/mall/item/popupForm.vue b/web/src/views/backend/mall/item/popupForm.vue
index 5396c36..ddb1a50 100644
--- a/web/src/views/backend/mall/item/popupForm.vue
+++ b/web/src/views/backend/mall/item/popupForm.vue
@@ -29,6 +29,7 @@
:label-width="baTable.form.labelWidth + 'px'"
:rules="rules"
>
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -166,7 +175,10 @@ const isPhysical = computed(() => itemType.value === 2 || itemType.value === '2'
const isWithdraw = computed(() => itemType.value === 3 || itemType.value === '3')
const isBonusOrWithdraw = computed(() => isBonus.value || isWithdraw.value)
-// 切换类型后,清理不适用的字段,避免“隐藏字段仍保留上一次的值”导致提交脏数据
+/** 已选择商品类型(1/2/3)后,才展示其余表单项 */
+const hasItemType = computed(() => isBonus.value || isPhysical.value || isWithdraw.value)
+
+// 切换类型后,清理不适用的字段(严格:WITHDRAW 不保留红利类别字段)
watch(
itemType,
(n, o) => {
@@ -176,14 +188,20 @@ watch(
const typeNum = Number(n)
if (!Number.isFinite(typeNum)) return
- if (typeNum === 2) {
+ if (typeNum === 1) {
+ // BONUS:实物库存不适用
+ baTable.form.items.stock = 0
+ } else if (typeNum === 2) {
+ // PHYSICAL:现金/倍数/类别不适用
baTable.form.items.amount = 0
baTable.form.items.multiplier = 0
baTable.form.items.category = ''
baTable.form.items.category_title = ''
- } else {
- // BONUS / WITHDRAW
+ } else if (typeNum === 3) {
+ // WITHDRAW:提现接口不使用 category,清空避免误存
baTable.form.items.stock = 0
+ baTable.form.items.category = ''
+ baTable.form.items.category_title = ''
}
},
{ flush: 'post' },
@@ -191,10 +209,33 @@ watch(
const rules: Partial> = reactive({
title: [buildValidatorData({ name: 'required', title: t('mall.item.title') })],
- description: [buildValidatorData({ name: 'required', title: t('mall.item.description') })],
+ description: [
+ {
+ validator: (rule: any, val: any, callback: Function) => {
+ if (!hasItemType.value) return callback()
+ if (val === '' || val === null || val === undefined) {
+ return callback(new Error(t('Please input field', { field: t('mall.item.description') })))
+ }
+ return callback()
+ },
+ trigger: 'blur',
+ },
+ ],
score: [
- buildValidatorData({ name: 'number', title: t('mall.item.score') }),
- buildValidatorData({ name: 'required', title: t('mall.item.score') }),
+ {
+ validator: (rule: any, val: any, callback: Function) => {
+ if (!hasItemType.value) return callback()
+ if (val === '' || val === null || val === undefined) {
+ return callback(new Error(t('Please input field', { field: t('mall.item.score') })))
+ }
+ const num = Number(val)
+ if (!Number.isFinite(num)) {
+ return callback(new Error(t('Please enter the correct field', { field: t('mall.item.score') })))
+ }
+ return callback()
+ },
+ trigger: 'blur',
+ },
],
type: [buildValidatorData({ name: 'required', title: t('mall.item.type') })],
amount: [
@@ -238,7 +279,7 @@ const rules: Partial> = reactive({
category: [
{
validator: (rule: any, val: any, callback: Function) => {
- if (!isBonusOrWithdraw.value) return callback()
+ if (!isBonus.value) return callback()
if (!val) {
return callback(new Error(t('Please input field', { field: t('mall.item.category') })))
}
@@ -250,7 +291,7 @@ const rules: Partial> = reactive({
category_title: [
{
validator: (rule: any, val: any, callback: Function) => {
- if (!isBonusOrWithdraw.value) return callback()
+ if (!isBonus.value) return callback()
if (!val) {
return callback(new Error(t('Please input field', { field: t('mall.item.category_title') })))
}
diff --git a/web/types/tableRenderer.d.ts b/web/types/tableRenderer.d.ts
index 36e3560..8b5a7db 100644
--- a/web/types/tableRenderer.d.ts
+++ b/web/types/tableRenderer.d.ts
@@ -4,6 +4,7 @@ type TableRenderer =
| 'color'
| 'customRender'
| 'customTemplate'
+ | 'date'
| 'datetime'
| 'icon'
| 'image'