Преглед на файлове

修改未支付时间;修改团餐设置点击

付晓文。 преди 2 месеца
родител
ревизия
f4d25a8a0e
променени са 3 файла, в които са добавени 66 реда и са изтрити 37 реда
  1. 8 5
      pages/coupon/creatDiscount.vue
  2. 8 5
      pages/coupon/creatReduction.vue
  3. 50 27
      pages/groupMeal/goods/form-step2.vue

+ 8 - 5
pages/coupon/creatDiscount.vue

@@ -487,11 +487,14 @@ export default {
 			else {
 			else {
 				
 				
 				let temp = []
 				let temp = []
-				console.log(this.xqImage)
-				if ( this.xqImage.length > 0) {
-					this.xqImage.forEach((item => {
-						temp.push( configService.apiUrl +'/'+item.response.message)
-					}))
+				if (this.xqImage.length > 0) {
+					this.xqImage.forEach((item) => {
+						if (item.response && item.response.message) {
+							temp.push(configService.apiUrl + '/' + item.response.message)
+						} else if (item.url) {
+							temp.push(item.url)
+						}
+					})
 				}
 				}
 				
 				
 				
 				

+ 8 - 5
pages/coupon/creatReduction.vue

@@ -431,11 +431,14 @@ export default {
 				return
 				return
 			} else {
 			} else {
 				let temp = []
 				let temp = []
-				console.log(this.xqImage)
-				if ( this.xqImage.length > 0) {
-					this.xqImage.forEach((item => {
-						temp.push( configService.apiUrl +'/'+item.response.message)
-					}))
+				if (this.xqImage.length > 0) {
+					this.xqImage.forEach((item) => {
+						if (item.response && item.response.message) {
+							temp.push(configService.apiUrl + '/' + item.response.message)
+						} else if (item.url) {
+							temp.push(item.url)
+						}
+					})
 				}
 				}
 				
 				
 				
 				

+ 50 - 27
pages/groupMeal/goods/form-step2.vue

@@ -68,14 +68,14 @@
 								</view>
 								</view>
 							</view>
 							</view>
 							<view class="dish-form">
 							<view class="dish-form">
-								<u-form-item label="名称" :prop="`dishCategories.${catIndex}.items.${dishIndex}.name`" :required="isEdited(dish)">
+								<u-form-item label="名称" :prop="`dishCategories.${catIndex}.items.${dishIndex}.name`" :required="isRequired(dish, dishIndex)">
 									<u-input v-model="dish.name" height="41" placeholder="请输入" inputAlign="right"></u-input>
 									<u-input v-model="dish.name" height="41" placeholder="请输入" inputAlign="right"></u-input>
 								</u-form-item>
 								</u-form-item>
-								<u-form-item label="价格" :prop="`dishCategories.${catIndex}.items.${dishIndex}.price`" :required="isEdited(dish)">
+								<u-form-item label="价格" :prop="`dishCategories.${catIndex}.items.${dishIndex}.price`" :required="isRequired(dish, dishIndex)">
 									<u-input v-model.number="dish.price" type="digit" height="41" placeholder="输入金额" :clearable="false" inputAlign="right"></u-input>
 									<u-input v-model.number="dish.price" type="digit" height="41" placeholder="输入金额" :clearable="false" inputAlign="right"></u-input>
 									<text slot="right" style="color: #333333;">元</text>
 									<text slot="right" style="color: #333333;">元</text>
 								</u-form-item>
 								</u-form-item>
-								<u-form-item label="描述" :prop="`dishCategories.${catIndex}.items.${dishIndex}.description`" :required="isEdited(dish)">
+								<u-form-item label="描述" :prop="`dishCategories.${catIndex}.items.${dishIndex}.description`" :required="isRequired(dish, dishIndex)">
 									<u-input v-model="dish.description" height="41" placeholder="请描述菜品的使用素材" inputAlign="right"></u-input>
 									<u-input v-model="dish.description" height="41" placeholder="请描述菜品的使用素材" inputAlign="right"></u-input>
 								</u-form-item>
 								</u-form-item>
 							</view>
 							</view>
@@ -176,7 +176,7 @@ export default {
 	},
 	},
 	mounted() {
 	mounted() {
 		this.$nextTick(() => {
 		this.$nextTick(() => {
-			this.$refs.formRef.setRules(this.rules);
+			this.updateValidationRules();
 		});
 		});
 	},
 	},
 	methods: {
 	methods: {
@@ -184,6 +184,19 @@ export default {
 		isEdited(dish) {
 		isEdited(dish) {
 			return !!(dish.name || dish.price || dish.description);
 			return !!(dish.name || dish.price || dish.description);
 		},
 		},
+		// 首个菜品始终展示必填标识;填写任一项后该菜品全部字段必填
+		isRequired(dish, dishIndex) {
+			return dishIndex === 0 || this.isEdited(dish);
+		},
+		shouldValidate(dish) {
+			return this.isEdited(dish);
+		},
+		isComplete(dish) {
+			const name = (dish.name || '').trim();
+			const description = (dish.description || '').trim();
+			const price = dish.price;
+			return !!(name && description && (price === 0 || price));
+		},
 		isEditedShow(e) {
 		isEditedShow(e) {
 			const goods = uni.getStorageSync('gm_goods');
 			const goods = uni.getStorageSync('gm_goods');
 			return goods.gmMerchantPackageDetails && goods.gmMerchantPackageDetails.length > 0 && goods.gmMerchantPackageDetails.some(b => b.category == e.id);;
 			return goods.gmMerchantPackageDetails && goods.gmMerchantPackageDetails.length > 0 && goods.gmMerchantPackageDetails.some(b => b.category == e.id);;
@@ -194,8 +207,8 @@ export default {
 			const newRules = {};
 			const newRules = {};
 			this.form.dishCategories.forEach((category, catIndex) => {
 			this.form.dishCategories.forEach((category, catIndex) => {
 				category.items.forEach((dish, dishIndex) => {
 				category.items.forEach((dish, dishIndex) => {
-					if (this.isEdited(dish)) {
-						// 如果菜品的任一字段被填写,则所有字段都变为必填
+					if (this.shouldValidate(dish)) {
+						// 任一字段被填写后,该菜品全部字段必填
 						const nameProp = `dishCategories.${catIndex}.items.${dishIndex}.name`;
 						const nameProp = `dishCategories.${catIndex}.items.${dishIndex}.name`;
 						const priceProp = `dishCategories.${catIndex}.items.${dishIndex}.price`;
 						const priceProp = `dishCategories.${catIndex}.items.${dishIndex}.price`;
 						const descProp = `dishCategories.${catIndex}.items.${dishIndex}.description`;
 						const descProp = `dishCategories.${catIndex}.items.${dishIndex}.description`;
@@ -256,35 +269,45 @@ export default {
 				delta: 1
 				delta: 1
 			});
 			});
 		},
 		},
+		buildDetails() {
+			const details = [];
+			this.form.dishCategories.forEach(category => {
+				if (!category.items || !Array.isArray(category.items)) return;
+				category.items.forEach((item) => {
+					if (this.isEdited(item)) {
+						details.push({
+							category: category.id,
+							name: item.name,
+							price: item.price,
+							description: item.description
+						});
+					}
+				});
+			});
+			return details;
+		},
 		// 提交审核
 		// 提交审核
 		submit() {
 		submit() {
+			this.updateValidationRules();
+			const hasCompleteDish = this.form.dishCategories.some(category =>
+				category.items.some(item => this.isComplete(item))
+			);
+			if (!hasCompleteDish) {
+				this.$tip.error('请至少添加一个完整的菜品信息');
+				return;
+			}
 			this.$refs.formRef.validate().then(res => {
 			this.$refs.formRef.validate().then(res => {
 				const goods = uni.getStorageSync('gm_goods');
 				const goods = uni.getStorageSync('gm_goods');
-				const activeCategories = this.form.dishCategories.filter(c => c.items.some(this.isEdited));
-				const details = [];
-				// 遍历一级分类
-				activeCategories.forEach(category => {
-					// 检查是否有items属性且为数组
-					if (category.items && Array.isArray(category.items)) {
-						// 遍历二级菜品
-						category.items.forEach(item => {
-							// 创建新对象,只保留需要的属性
-							if (this.isEdited(item)) {
-								details.push({
-									category: category.id,
-									name: item.name,
-									price: item.price,
-									description: item.description
-								});
-							}
-						});
-					}
-				});
+				const details = this.buildDetails();
+				if (details.length === 0) {
+					this.$tip.error('请至少添加一个完整的菜品信息');
+					return;
+				}
 				let params = {
 				let params = {
 					...goods,
 					...goods,
 					gmMerchantPackageDetails: [...details]
 					gmMerchantPackageDetails: [...details]
 				};
 				};
-				console.log('表单校验成功, 提交的数据:', activeCategories, params);
+				console.log('表单校验成功, 提交的数据:', details, params);
 				this.$http.post('/groupmeal/gmMerchantPackage/submit', params).then(res => {
 				this.$http.post('/groupmeal/gmMerchantPackage/submit', params).then(res => {
 					let type = res.data.code === 200 ? 'success' : 'error';
 					let type = res.data.code === 200 ? 'success' : 'error';
 					this.$tip[type](res.data.message);
 					this.$tip[type](res.data.message);