Sfoglia il codice sorgente

教育经历,学历学位附件必填校验

huangguoce 2 settimane fa
parent
commit
c7f3c6f021

+ 34 - 4
src/views/human/enrollment/registration/components/EducationInfo.vue

@@ -52,8 +52,8 @@
 
 					<el-col :span="12">
 						<el-form-item label="学位" prop="degree">
-							<el-select size="default" v-model="inputForm.degree" placeholder="请选择学位"
-								style="width: 100%;">
+							<el-select size="default" @change="handleSelectDegree" v-model="inputForm.degree"
+								placeholder="请选择学位" style="width: 100%;">
 								<el-option v-for="item in $dictUtils.getDictList('degree')" :key="item.value"
 									:label="item.label" :value="item.value">
 								</el-option>
@@ -119,13 +119,16 @@
 					<!-- </el-col> -->
 
 					<el-col :span="12">
-						<el-form-item label="学历附件" prop="educationFile" class="fileUpload">
+						<el-form-item class="star-require fileUpload" label="学历附件" prop="educationFile">
 							<UpLoadComponent ref="educationUploadComponent"></UpLoadComponent>
 						</el-form-item>
 					</el-col>
 
 					<el-col :span="12">
-						<el-form-item label="学位附件" prop="degreeFile">
+						<el-form-item :class="{
+							fileUpload: true,
+							'star-require': degreeFileFlag ? true : false
+						}" label="学位附件" prop="degreeFile">
 							<UpLoadComponent ref="degreeUploadComponent"></UpLoadComponent>
 						</el-form-item>
 					</el-col>
@@ -174,6 +177,7 @@ export default {
 	},
 	data() {
 		return {
+			degreeFileFlag: false,
 			disabled: false,
 			title: '',
 			method: '',
@@ -375,6 +379,20 @@ export default {
 
 			this.$refs['inputForm'].validate((valid) => {
 				if (valid) {
+					let eduFiles = this.$refs.educationUploadComponent.getDataList()
+					if (!eduFiles || eduFiles.length === 0) {
+						this.$message.error('请上传学历附件')
+						return
+					}
+					if (this.inputForm.degree && this.inputForm.degree != '1') {
+						let degreeFiles = this.$refs.degreeUploadComponent.getDataList()
+						if (!degreeFiles || degreeFiles.length === 0) {
+							this.$message.error('请上传学位附件')
+							return
+						}
+					}
+
+
 					this.inputForm.startDate = new Date(this.inputForm.startDate).getTime(); // 转为时间戳
 					this.inputForm.endDate = new Date(this.inputForm.endDate).getTime(); // 转为时间戳
 					this.inputForm.educationFile = this.$refs.educationUploadComponent.getDataList()
@@ -395,6 +413,13 @@ export default {
 			this.$refs.inputForm.resetFields()
 			this.visible = false
 		},
+		handleSelectDegree(value) {
+			if (value === '1') {
+				this.degreeFileFlag = false
+			} else {
+				this.degreeFileFlag = true
+			}
+		},
 	}
 }
 </script>
@@ -406,4 +431,9 @@ export default {
 		width: 100%;
 	}
 }
+
+.star-require .el-form-item__label::before {
+	content: "*";
+	color: red;
+}
 </style>

+ 32 - 5
src/views/sys/user/components/EducationInfo.vue

@@ -52,8 +52,8 @@
 
 					<el-col :span="12">
 						<el-form-item label="学位" prop="degree">
-							<el-select size="default" v-model="inputForm.degree" placeholder="请选择学位"
-								style="width: 100%;">
+							<el-select size="default" @change="handleSelectDegree" v-model="inputForm.degree"
+								placeholder="请选择学位" style="width: 100%;">
 								<el-option v-for="item in $dictUtils.getDictList('degree')" :key="item.value"
 									:label="item.label" :value="item.value">
 								</el-option>
@@ -119,13 +119,16 @@
 					<!-- </el-col> -->
 
 					<el-col :span="12">
-						<el-form-item label="学历附件" prop="educationFile" class="fileUpload">
+						<el-form-item class="star-require fileUpload" label="学历附件" prop="educationFile">
 							<UpLoadComponent ref="educationUploadComponent"></UpLoadComponent>
 						</el-form-item>
 					</el-col>
 
 					<el-col :span="12">
-						<el-form-item label="学位附件" prop="degreeFile">
+						<el-form-item :class="{
+							fileUpload: true,
+							'star-require': degreeFileFlag ? true : false
+						}" label="学位附件" prop="degreeFile">
 							<UpLoadComponent ref="degreeUploadComponent"></UpLoadComponent>
 						</el-form-item>
 					</el-col>
@@ -174,6 +177,7 @@ export default {
 	},
 	data() {
 		return {
+			degreeFileFlag: false,
 			disabled: false,
 			title: '',
 			method: '',
@@ -357,9 +361,20 @@ export default {
 			if (this.$refs.educationUploadComponent.checkProgress() || this.$refs.degreeUploadComponent.checkProgress()) {
 				return
 			}
-
 			this.$refs['inputForm'].validate((valid) => {
 				if (valid) {
+					let eduFiles = this.$refs.educationUploadComponent.getDataList()
+					if (!eduFiles || eduFiles.length === 0) {
+						this.$message.error('请上传学历附件')
+						return
+					}
+					if (this.inputForm.degree && this.inputForm.degree != '1') {
+						let degreeFiles = this.$refs.degreeUploadComponent.getDataList()
+						if (!degreeFiles || degreeFiles.length === 0) {
+							this.$message.error('请上传学位附件')
+							return
+						}
+					}
 					this.inputForm.startDate = new Date(this.inputForm.startDate).getTime(); // 转为时间戳
 					this.inputForm.endDate = new Date(this.inputForm.endDate).getTime(); // 转为时间戳
 					this.inputForm.educationFile = this.$refs.educationUploadComponent.getDataList()
@@ -404,6 +419,13 @@ export default {
 			this.$refs.inputForm.resetFields()
 			this.visible = false
 		},
+		handleSelectDegree(value) {
+			if (value === '1') {
+				this.degreeFileFlag = false
+			} else {
+				this.degreeFileFlag = true
+			}
+		},
 	}
 }
 </script>
@@ -415,4 +437,9 @@ export default {
 		width: 100%;
 	}
 }
+
+.star-require .el-form-item__label::before {
+	content: "*";
+	color: red;
+}
 </style>