Преглед изворни кода

类型课程选择添加同类限制

chenxiong пре 3 година
родитељ
комит
585b680a4b
1 измењених фајлова са 42 додато и 1 уклоњено
  1. 42 1
      pages2/plan/create.vue

+ 42 - 1
pages2/plan/create.vue

@@ -134,6 +134,7 @@ export default {
 			calendar_show: false,
 			maxDate: '2023-01-01',
 			minDate: '',
+			businessId:'',
 			list3: [
 				{
 					name: '一',
@@ -378,10 +379,49 @@ export default {
 				this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
 			}
 		},
-		checkboxChange(e) {},
+		checkboxChange(e) {
+			let goodsId = e.name;
+			if(e.value) { //勾选
+				this.businessId = this.list2.find(listItem => listItem.goodsId == goodsId).businessId;
+				this.list2.forEach(listItem => {
+					if(listItem.businessId != this.businessId) {
+						listItem.disabled = true;
+					}
+				})
+			} else { //取消
+				this.$nextTick(() => {
+					let checkedNum = this.list2.filter(listItem => {
+						if(listItem.checked) {
+							return true;
+						} else {
+							if(this.list.length) {
+								return true;
+							} else {
+								return false;
+							}
+						}
+					}).length;
+					
+					if(checkedNum == 0) { //全部取消,且没有已选择的
+						this.businessId = '';
+						this.list2.forEach(listItem => {
+							console.log(listItem)
+							listItem.disabled = false;
+						})
+					}
+				})
+				
+			}
+			
+		},
 		checkSameItem() {
 			this.list2.map(val => {
 				val.disabled = false;
+				if(this.businessId) {
+					if(val.businessId != this.businessId) {
+						val.disabled = true;
+					}
+				}
 				this.list.map(val1 => {
 					if (val.goodsId == val1.goodsId) {
 						val.disabled = true;
@@ -393,6 +433,7 @@ export default {
 		delItem(index) {
 			this.list.splice(index, 1);
 			if (this.list.length === 0) {
+				this.businessId = '';
 				this.form.category = '';
 			} else {
 				this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;