Przeglądaj źródła

商品下架弹窗提示文案、餐盒金额校验负数

baijunde 3 tygodni temu
rodzic
commit
5316427e0f

+ 3 - 2
pages/merchantDish/dish/list.vue

@@ -431,8 +431,9 @@ export default {
 			});
 		},
 		async onOffShelf(item) {
-			// 团餐:展示未成团/已成团订单数确认弹窗
-			if (item.belong === 'group') {
+			// 团餐存在关联订单时,展示未成团/已成团订单数确认弹窗
+			const hasGroupOrders = Number(item.ungroupedOrderCount) > 0 || Number(item.groupedOrderCount) > 0;
+			if (item.belong === 'group' && hasGroupOrders) {
 				this.offShelfItem = item;
 				this.offShelfShow = true;
 				return;

+ 11 - 2
pages/merchantDish/settings/box-form.vue

@@ -10,7 +10,7 @@
 			</view>
 			<view class="row">
 				<text class="label">餐盒价格</text>
-				<input class="input" v-model="form.price" type="digit" placeholder="请输入金额 元" placeholder-class="ph" />
+				<input class="input" v-model="form.price" type="digit" placeholder="请输入金额 元" placeholder-class="ph" @blur="onPriceBlur" />
 			</view>
 			<view class="row link" @click="goBind">
 				<text class="label">已绑商品</text>
@@ -68,6 +68,10 @@ export default {
 		}
 	},
 	methods: {
+		onPriceBlur(event) {
+			const value = String((event.detail && event.detail.value) || '');
+			this.form.price = value.replace(/-/g, '');
+		},
 		/** 供绑定页回写选中商品 */
 		applyBindIds(ids) {
 			this.form.bindIds = ids || [];
@@ -161,12 +165,17 @@ export default {
 				uni.showToast({ title: '请输入餐盒名称', icon: 'none' });
 				return;
 			}
+			const boxPrice = Number(this.form.price || 0);
+			if (!Number.isFinite(boxPrice) || boxPrice < 0) {
+				uni.showToast({ title: '餐盒价格不能为负数', icon: 'none' });
+				return;
+			}
 			if (this.saving) return;
 			this.saving = true;
 			const packageIds = this.form.bindIds || [];
 			const base = {
 				boxName: this.form.name,
-				boxPrice: Number(this.form.price || 0),
+				boxPrice,
 				boxImage: this.form.image || '',
 				status: this.form.status != null ? this.form.status : 1,
 				sort: this.form.sort || 0