From 4320e5c9f9456d67dd79422bad5e7d49b775dbaa Mon Sep 17 00:00:00 2001
From: lihaoyuan <18278596806@163.com>
Date: Wed, 24 Dec 2025 16:16:59 +0800
Subject: [PATCH] =?UTF-8?q?update:=E8=A1=A5=E5=85=85=E9=AA=B0=E5=AD=90?=
=?UTF-8?q?=E4=B8=AA=E6=95=B0=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BB=A5=E5=8F=8A?=
=?UTF-8?q?=E4=B8=80=E4=BA=9B=E8=A7=84=E5=88=99=E6=A3=80=E9=AA=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/StoreActivityBaseEdit.vue | 102 +++++++++++++++---
1 file changed, 90 insertions(+), 12 deletions(-)
diff --git a/src/views/store/activity/sellerBargain/components/StoreActivityBaseEdit.vue b/src/views/store/activity/sellerBargain/components/StoreActivityBaseEdit.vue
index eb8b486..163a8eb 100644
--- a/src/views/store/activity/sellerBargain/components/StoreActivityBaseEdit.vue
+++ b/src/views/store/activity/sellerBargain/components/StoreActivityBaseEdit.vue
@@ -57,15 +57,19 @@
-
-
+
+
-
+
@@ -112,7 +116,7 @@
:min="2"
/>
-
+
{{ __('首刀比例') }}
-
+
-
-
+
+
+
+
+
+
+
+
+
+
{
+ // 关键:先判断是否已选商品(item_id存在即视为已选),再判断库存
+ if (!this.form.item_id) {
+ callback(new Error(this.__('请先选择砍价商品')));
+ return;
+ }
+ // 库存为0时提示“商品库存为0,无法设置活动总数”
+ if (Number(this.form.item_quantity) <= 0) {
+ callback(new Error(this.__('该商品库存为0,无法设置活动商品总数')));
+ return;
+ }
+ const count = Number(value);
+ const max = Number(this.form.item_quantity);
+ if (isNaN(count)) {
+ callback(new Error(this.__('请输入有效的数字')));
+ } else if (count <= 0) {
+ callback(new Error(this.__('活动商品总数不能小于等于0')));
+ } else if (count > max) {
+ callback(new Error(this.__(`活动商品总数不能超过商品库存${max}件`)));
+ } else {
+ callback();
+ }
+ },
+ trigger: ['blur', 'change', 'submit']
+ }
],
},
}
@@ -332,6 +376,12 @@
getCheckItem(row) {
this.form.item_id = row.item_id
this.form.product_item_name = row.product_item_name
+ this.form.item_quantity = row.item_quantity;
+ // 可选:如果活动商品总数已有值,且超过库存,自动重置
+ if (this.form.product_count && Number(this.form.product_count) > Number(this.form.item_quantity)) {
+ this.form.product_count = this.form.item_quantity;
+ this.$baseMessage(`活动商品总数不能超过商品库存${this.form.item_quantity},已自动重置`, 'warning');
+ }
this.$refs['form'].validateField(
['product_item_name', 'item_id'],
(errorMsg) => {
@@ -361,6 +411,7 @@
cut_down_user_num: row.activity_rule.cut_down_user_num,
cut_hour:row.cut_hour,
product_count:row.product_count,
+ //item_quantity: row.activity_rule.item_quantity 后端暂时没返回 用于校验商品库存数量的
user_cutprice_num:row.activity_rule.user_cutprice_num,
cut_first_type:row.activity_rule.cut_first_type,//空初始化
cut_first_percent:row.activity_rule.cut_first_percent,
@@ -374,12 +425,29 @@
},
tranformData(lucky_turn){
if(this.form.cut_first_percent){
- this.form.cut_first_type=1
+ this.form.cut_first_type=1;
+ this.form.cut_first_price = ''
}else if(this.form.cut_first_price){
this.form.cut_first_type=2
+ this.form.cut_first_percent = ''
}
this.touzi=JSON.parse(lucky_turn)
},
+ // 父组件 methods
+ handleProductCountInput() {
+ if (!this.form.item_quantity) return;
+ const count = Number(this.form.product_count);
+ const max = Number(this.form.item_quantity);
+ // 如果输入值超过库存,自动截断为库存值
+ if (count > max) {
+ this.form.product_count = max;
+ this.$baseMessage(`活动商品总数最大为${max}件`, 'warning');
+ }
+ // 如果输入负数/非数字,清空
+ if (count <= 0 || isNaN(count)) {
+ this.form.product_count = '';
+ }
+ },
close() {
this.form = {
product_item_name: '',
@@ -402,6 +470,16 @@
showItemTable() {
this.$refs['productItemTable'].showTable()
},
+ // 处理砍价第一刀类型切换
+ handleCutFirstTypeChange(type) {
+ if (type === 1) {
+ // 选择首刀比例,清空首刀金额
+ this.form.cut_first_price = '';
+ } else if (type === 2) {
+ // 选择首刀金额,清空首刀比例
+ this.form.cut_first_percent = '';
+ }
+ },
diceObjToStr(){
this.form.diceObj = JSON.stringify(this.touzi);
},