Browse Source

处理冲突

zhangli 2 years ago
parent
commit
e3f44f599c
4 changed files with 194 additions and 14 deletions
  1. 4 1
      config/api.js
  2. 58 1
      pagesClass/addClassForm.vue
  3. 45 4
      pagesClass/classDetail.vue
  4. 87 8
      pagesClass/updateClassForm.vue

+ 4 - 1
config/api.js

@@ -5,7 +5,8 @@
 
 //const API_BASE = 'http://192.168.1.117:8089'
 // const API_BASE = 'http://192.168.1.109/newApi'
-//const API_BASE = 'http://192.168.1.145/newApi'
+// const API_BASE = 'http://192.168.1.145/newApi'
+// const API_BASE = 'http://starfire.jihengcc.cn/newApi'
 const API_BASE = 'https://starfire.jihengcc.cn/newApi'
 // const API_BASE = 'http://192.168.1.126:30000'
 // const API_BASE = 'http://192.168.1.117:8089'
@@ -49,6 +50,8 @@ module.exports = {
 	getSignStudentList: API_BASE + '/v2/sale/class/getSignStudentList',
 	//  获取非本课程学员列表
 	getOtherSignStudentList: API_BASE + '/v2/sale/class/getOtherSignStudentList',
+	//  获取班级修改详情
+	findById: API_BASE + '/v2/sale/class/findById',
 	//  提交签到表单
 	submitSignForm: API_BASE + '/v2/sale/class/signSubmit',
 	//  班级详情->扫码

+ 58 - 1
pagesClass/addClassForm.vue

@@ -10,6 +10,12 @@
 			<u-form-item label="班级名称" prop="name" required>
 				<u-input v-model="form.name" placeholder="请输入班级名称" />
 			</u-form-item>
+			<u-form-item label="培训方式" prop="classTypeInfo" required>
+				<u-input v-model="form.classTypeInfo" placeholder="请选择培训方式" type="select" @click="trainShow = true" />
+			</u-form-item>
+			<u-form-item v-if="form.classTypeDesc == 5" label="其他方式" prop="otherType">
+				<u-input v-model="form.otherType" placeholder="请填写其他方式" />
+			</u-form-item>
 			<u-form-item label="课程周期开始时间" prop="startDate" right-icon="arrow-right" required @click.native="startDateShow = true">
 				<u-input v-model="form.startDate" placeholder="请选择课程周期开始时间" disabled @click="startDateShow = true" />
 			</u-form-item>
@@ -65,6 +71,8 @@
 		<u-action-sheet :list="classTypeList" v-model="classShow" @click="handleClassClick"></u-action-sheet>
 		<!-- 体验班 -->
 		<u-action-sheet :list="lessonsTypeList" v-model="lessonsShow" @click="handleLessonsClick"></u-action-sheet>
+		<!-- 培训方式 -->
+		<u-action-sheet :list="trainList" v-model="trainShow" @click="setTrain"></u-action-sheet>
 		<view class="handle-fix-box">
 			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm">保存</u-button>
 		</view>
@@ -91,6 +99,9 @@
 					name: '',
 					classType: 0,
 					className: '',
+					classTypeDesc: '',
+					classTypeInfo: '',
+					otherType: '',
 					useLessonsType: 1,
 					useLessonsName: '',
 					startDate: '',
@@ -125,6 +136,12 @@
 						message: '请输入班级名称',
 						trigger: 'change'
 					}],
+					classTypeInfo: [
+						{
+						required: true,
+						message: '请选择培训方式',
+						trigger: 'change'
+					}],
 					startDate: [{
 						required: true,
 						message: '请选择课程周期开始时间',
@@ -163,6 +180,29 @@
 						text: '体能'
 					}
 				],
+				trainShow: false,
+				trainList: [
+					{
+						id: 1,
+						text: '一对一(或一对多)面授'
+					},
+					{
+						id: 2,
+						text: '大班额面授课'
+					},
+					{
+						id: 3,
+						text: '小班额面授课'
+					},
+					{
+						id: 4,
+						text: '本班开班不受最低人数限制'
+					},
+					{
+						id: 5,
+						text: '其他方式'
+					},
+				],
 				lessonsShow: false,
 				lessonsTypeList: [
 					{
@@ -255,6 +295,14 @@
 				this.form.classType = this.classTypeList[index].classType
 				this.form.className = this.classTypeList[index].text
 			},
+			//  选择培训方式
+			setTrain(index) {
+				this.form.classTypeDesc = this.trainList[index].id
+				this.form.classTypeInfo = this.trainList[index].text
+				if(this.trainList[index].id = 5) {
+					this.form.otherType = ''
+				}
+			},
 			// 是否为体验班(1是 2否)
 			handleLessonsClick(index) {
 				this.form.useLessonsType = this.lessonsTypeList[index].useLessonsType
@@ -317,10 +365,19 @@
 			},
 			//  提交表单
 			submitForm() {
+				if(this.form.classTypeDesc == 5) {
+					if(!this.form.otherType) {
+						this.$refs.uTips.show({
+							title: '请输入培训方式',
+							type: 'warning',
+						})
+						return 
+					}
+				}
 				this.$refs.form.validate(valid => {
 					if (valid) {
 						NET.request(API.submitClassForm, {
-							...this.form,
+							...this.form, classTypeDesc : this.form.classTypeDesc == 5 ? this.form.otherType : this.form.classTypeDesc
 						}, 'POST').then(res => {
 							uni.removeStorageSync({
 								key: 'extraLessonsUserList'

+ 45 - 4
pagesClass/classDetail.vue

@@ -189,6 +189,28 @@
 				orderId:'',
 				cardId:'',
 				vtCardList: [],
+				trainList: [
+					{
+						id: 1,
+						text: '一对一(或一对多)面授'
+					},
+					{
+						id: 2,
+						text: '大班额面授课'
+					},
+					{
+						id: 3,
+						text: '小班额面授课'
+					},
+					{
+						id: 4,
+						text: '本班开班不受最低人数限制'
+					},
+					{
+						id: 5,
+						text: '其他方式'
+					},
+				],
 			}
 		},
 		onLoad(options) {
@@ -499,17 +521,36 @@
 			},
 			//  跳转修改班级
 			handleUpdateClassClick() {
+				let getInfo = this.trainList.find(item => item.id == this.classInfo.classTypeDesc)
+				let info = ''
+				if(!getInfo) {
+					info = '其他方式'
+					this.classInfo.otherType = this.classInfo.classTypeDesc
+					this.classInfo.classTypeDesc = 5
+				} else {
+					info = getInfo.text
+				}
 				const form = {
 					classId: this.classId,
 					name: this.classInfo.name,
+					classTypeDesc: this.classInfo.classTypeDesc,
+					classTypeInfo: info,
+					otherType: this.classInfo.otherType,
 					startDate: this.classInfo.classStartDate,
 					endDate: this.classInfo.classEndDate,
 					timeReqList: this.classInfo.classExtrasList,
-					maxStudentCount: this.classInfo.maxStudentCount
+					maxStudentCount: this.classInfo.maxStudentCount,
 				}
-				uni.navigateTo({
-					url: '/pagesClass/updateClassForm?form=' + encodeURIComponent(JSON.stringify(form))
-				});
+				if(this.classInfo.state == 3 || this.classInfo.state == 1) {
+					uni.navigateTo({
+						url: '/pagesClass/updateClassForm?form=' + encodeURIComponent(JSON.stringify(form))
+					});
+				} else {
+					uni.navigateTo({
+						url: '/pagesClass/updateClassForm?classId=' + this.classId
+					});
+				}
+				
 			},
 			//  跳转学生详情
 			goToStudentInfo(item) {

+ 87 - 8
pagesClass/updateClassForm.vue

@@ -4,6 +4,12 @@
 			<u-form-item label="班级名称" prop="name" required>
 				<u-input v-model="form.name" placeholder="请输入班级名称" />
 			</u-form-item>
+			<u-form-item label="培训方式" prop="classTypeInfo" required>
+				<u-input v-model="form.classTypeInfo" placeholder="请选择培训方式" type="select" @click="trainShow = true" />
+			</u-form-item>
+			<u-form-item v-if="form.classTypeDesc == 5" label="其他方式" prop="otherType">
+				<u-input v-model="form.otherType" placeholder="请填写其他方式" />
+			</u-form-item>
 			<u-form-item label="课程周期开始时间" prop="startDate" right-icon="arrow-right" required @click.native="startDateShow = true">
 				<u-input v-model="form.startDate" placeholder="请选择课程周期开始时间" disabled @click="startDateShow = true" />
 			</u-form-item>
@@ -51,6 +57,8 @@
 		<u-picker mode="time" v-model="startTimeShow" :params="startTimeParams" @confirm="setStartTime"></u-picker>
 		<u-picker mode="time" v-model="startDateShow" :params="cycleParams" @confirm="setStartDate"></u-picker>
 		<u-picker mode="time" v-model="endDateShow" :params="cycleParams" @confirm="setEndDate"></u-picker>
+		<!-- 培训方式 -->
+		<u-action-sheet :list="trainList" v-model="trainShow" @click="setTrain"></u-action-sheet>
 		<u-top-tips ref="uTips"></u-top-tips>
 	</view>
 </template>
@@ -73,6 +81,9 @@
 				form: {
 					classId: 0,
 					name: '',
+					classTypeDesc: '',
+					classTypeInfo: '',
+					otherType: '',
 					startDate: '',
 					endDate: '',
 					timeReqList: [{
@@ -88,6 +99,12 @@
 						message: '请输入班级名称',
 						trigger: 'change'
 					}],
+					classTypeInfo: [
+						{
+						required: true,
+						message: '请选择培训方式',
+						trigger: 'change'
+					}],
 					startDate: [{
 						required: true,
 						message: '请选择课程周期开始时间',
@@ -111,6 +128,29 @@
 						trigger: 'change'
 					},
 				},
+				trainShow: false,
+				trainList: [
+					{
+						id: 1,
+						text: '一对一(或一对多)面授'
+					},
+					{
+						id: 2,
+						text: '大班额面授课'
+					},
+					{
+						id: 3,
+						text: '小班额面授课'
+					},
+					{
+						id: 4,
+						text: '本班开班不受最低人数限制'
+					},
+					{
+						id: 5,
+						text: '其他方式'
+					},
+				],
 				startTimeShow: false,
 				startTimeParams: {
 					year: false,
@@ -167,14 +207,49 @@
 			}
 		},
 		onLoad(options) {
-			this.form = JSON.parse(decodeURIComponent(options.form));
-			this.form.id = parseInt(this.form.classId)
+			if(options.classId) {
+				this.form.id = parseInt(options.classId)
+				this.getClassInfo()
+			} else {
+				this.form = JSON.parse(decodeURIComponent(options.form));
+				this.form.id = parseInt(this.form.classId)
+			}
 		},
 		onReady() {
 			this.$refs.form.setRules(this.rules);
 		},
 		onShow() {},
 		methods: {
+			//  获取班级详情
+			getClassInfo() {
+				console.log(this.form.id);
+				NET.request(API.findById, {
+					id: this.form.id
+				}, 'POST').then( res => {
+					let getInfo = this.trainList.find(item => item.id == res.data.classTypeDesc)
+					let info = ''
+					if(!getInfo) {
+						info = '其他方式'
+						this.form = { ...res.data, classTypeInfo: info, classTypeDesc: 5, otherType: res.data.classTypeDesc, maxStudentCount: res.data.peopleNumber }
+					} else {
+						info = getInfo.text
+						this.form = { ...res.data, classTypeInfo: info, maxStudentCount: res.data.peopleNumber  }
+					}
+				}).catch(error => {
+							this.$refs.uTips.show({
+								title: error.message,
+								type: 'warning',
+							})
+						})
+			},
+			//  选择培训方式
+			setTrain(index) {
+				this.form.classTypeDesc = this.trainList[index].id
+				this.form.classTypeInfo = this.trainList[index].text
+				if(this.trainList[index].id = 5) {
+					this.form.otherType = ''
+				}
+			},
 			//  设置课程周期开始时间
 			setStartDate(date) {
 				this.form.startDate = date.year + '-' + date.month + '-' + date.day
@@ -226,10 +301,19 @@
 			},
 			//  提交表单
 			submitForm() {
+				if(this.form.classTypeDesc == 5) {
+					if(!this.form.otherType) {
+						this.$refs.uTips.show({
+							title: '请输入培训方式',
+							type: 'warning',
+						})
+						return 
+					}
+				}
 				this.$refs.form.validate(valid => {
 					if (valid) {
 						NET.request(API.classUpdate, {
-							...this.form,
+							...this.form, classTypeDesc : this.form.classTypeDesc == 5 ? this.form.otherType : this.form.classTypeDesc
 						}, 'POST').then(res => {
 							uni.removeStorageSync({
 								key: 'extraLessonsUserList'
@@ -238,11 +322,6 @@
 								title: '提交成功',
 								type: 'success',
 							})
-							// setTimeout(() => {
-							// 	uni.reLaunch({
-							// 		url: '/pagesClass/classList' 
-							// 	})
-							// }, 1000)
 							setTimeout(() => {
 								uni.navigateBack({})
 							}, 1000)