Browse Source

新增用户和新增入职-手机号根据租户校验唯一性

huangguoce 7 hours atrás
parent
commit
8d4fc9ca92

+ 9 - 0
src/api/human/enrollment/EnrollmentRegistrationService.js

@@ -199,6 +199,15 @@ export default {
 			params: { mobilePhone: mobilePhone },
 		});
 	},
+	findMobilePhoneOnlyByTenantId(params) {
+		return request({
+			url:
+				prefix +
+				"/enrollmentRegistration/findMobilePhoneOnlyByTenantId",
+			method: "get",
+			params: params,
+		});
+	},
 	findByUserId(userId) {
 		return request({
 			url: prefix + "/enrollmentRegistration/findByUserId",

+ 27 - 11
src/views/human/enrollment/registration/EnrollmentRegistrationAddForm.vue

@@ -206,9 +206,8 @@
 			</el-row>
 			<el-divider content-position="left"><i class="el-icon-document"></i> 部门信息</el-divider>
 			<el-row :gutter="26">
-				<el-form v-if="status === 'audit'" style="width: 100%" :model="inputForm" ref="inputForm"
-					v-loading="loading" :class="method === 'view' ? 'readonly' : ''" label-width="110px"
-					@submit.native.prevent>
+				<el-form style="width: 100%" :model="inputForm" ref="inputForm" v-loading="loading"
+					:class="method === 'view' ? 'readonly' : ''" label-width="110px" @submit.native.prevent>
 					<el-row :gutter="26">
 						<el-col :span="12">
 							<el-form-item label="所属部门" prop="department" :rules="[
@@ -219,7 +218,7 @@
 									label: 'name',         // 显示名称
 									children: 'children'    // 子级字段名
 								}" :url="`/system-server/sys/office/treeData?type=2`" :value="inputForm.department" :accordion="true"
-									size="default" @getValue="(value) => { inputForm.department = value }" />
+									size="default" @getValue="setDepartmentValue" />
 							</el-form-item>
 						</el-col>
 						<el-col :span="12">
@@ -263,7 +262,7 @@
 						</el-col>
 					</el-row>
 				</el-form>
-				<el-form v-else-if="inputForm.type !== '0'" style="width: 100%" :model="inputForm" ref="inputForm"
+				<!-- <el-form v-else-if="inputForm.type !== '0'" style="width: 100%" :model="inputForm" ref="inputForm"
 					v-loading="loading" :class="method === 'view' ? 'readonly' : ''" :disabled="true"
 					label-width="110px" @submit.native.prevent>
 					<el-row :gutter="26">
@@ -280,7 +279,6 @@
 						</el-col>
 						<el-col :span="12">
 							<el-form-item label="员工类型" prop="onJobStatus" :rules="[]">
-								<!--						<el-input v-model="inputForm.politicalOutlook"></el-input>-->
 								<el-select v-model="inputForm.onJobStatus" placeholder="请选择员工类型" style="width:100%;">
 									<el-option v-for="item in $dictUtils.getDictList('on_job_status')" :key="item.value"
 										:label="item.label" :value="item.value">
@@ -313,7 +311,7 @@
 							</el-form-item>
 						</el-col>
 					</el-row>
-				</el-form>
+				</el-form> -->
 			</el-row>
 			<el-divider content-position="left"><i class="el-icon-document"></i> 社保信息(选填)</el-divider>
 			<el-row :gutter="26" v-if="status === 'audit' || status === 'taskFormDetail'">
@@ -511,6 +509,7 @@
 <script>
 import SelectTree from '@/components/treeSelect/treeSelect.vue'
 import enrollmentRegistrationService from '@/api/human/enrollment/EnrollmentRegistrationService'
+import officeService from '@/api/sys/officeService'
 import OSSSerivce, {
 	httpRequest,
 	fileName,
@@ -534,6 +533,7 @@ export default {
 	},
 	data() {
 		return {
+			tenantId: null,
 			hideUploadEdit: false, //隐藏上传按钮
 			hideUploadEdit2: false, //隐藏上传按钮
 			limitNum: 1,
@@ -975,7 +975,12 @@ export default {
 					this.inputForm.mobilePhone = ''
 					throw new Error('”联系电话“填写不正确,请重新填写')
 				}
-				enrollmentRegistrationService.findMobilePhoneOnly(mobilePhone).then((data) => {
+			}
+			if (this.commonJS.isNotEmpty(mobilePhone) && this.commonJS.isNotEmpty(this.tenantId)) {
+				enrollmentRegistrationService.findMobilePhoneOnlyByTenantId({
+					mobilePhone: mobilePhone,
+					tenantId: this.tenantId
+				}).then((data) => {
 					if (data !== 0) {
 						this.$message.error('联系电话已存在,请重新确认')
 						this.inputForm.mobilePhone = ''
@@ -983,8 +988,6 @@ export default {
 					}
 				})
 			}
-
-
 		},
 		checkBankNumber(bankNumber) {
 			if (!this.validateXG.isBankNum(bankNumber)) {
@@ -1025,7 +1028,20 @@ export default {
 		validateInput() {
 			// 使用正则表达式验证输入内容,禁止中文
 			this.inputForm.socialSecurityNumber = this.inputForm.socialSecurityNumber.replace(/[\u4e00-\u9fa5]/g, '');
-		}
+		},
+		async setDepartmentValue(value) {
+			if (value !== null && value !== undefined) {
+				let res = await officeService.queryById(value)
+				if (res) {
+					this.tenantId = res.tenantId
+					this.inputForm.department = value;
+					this.mobilePhoneOnly(this.inputForm.mobilePhone)
+				}
+			} else {
+				this.tenantId = null
+			}
+		},
+
 	}
 }
 </script>

+ 37 - 2
src/views/sys/user/UserForm.vue

@@ -114,9 +114,9 @@
 				</el-col>
 				<el-col :span="12">
 					<el-form-item label="手机" prop="mobile" :rules="[
-						{ validator: validator.isMobile, trigger: 'blur' },
 					]">
-						<el-input v-model="inputForm.mobile" maxlength="50" placeholder=""></el-input>
+						<el-input v-model="inputForm.mobile" maxlength="50" placeholder=""
+							@blur="mobilePhoneOnly(inputForm.mobile)"></el-input>
 					</el-form-item>
 				</el-col>
 				<el-col :span="12">
@@ -323,6 +323,7 @@ import enrollmentRegistrationService from '@/api/human/enrollment/EnrollmentRegi
 export default {
 	data() {
 		return {
+			tenantId: null,
 			visible: false,
 			loading: false,
 			title: "",
@@ -386,6 +387,7 @@ export default {
 				if (this.$refs.inputForm !== undefined) {
 					this.$refs.inputForm.resetFields();
 				}
+				this.tenantId = null
 				this.inputForm.oldLoinName = "";
 				this.inputForm.id = id;
 				this.inputForm.tenantDTO.id = tenantId;
@@ -395,6 +397,9 @@ export default {
 					this.initTenant(p).then((data) => {
 						this.inputForm = this.recover(this.inputForm, data);
 						this.inputForm.oldLoginName = this.inputForm.loginName;
+						if (data.tenantDTO.id) {
+							this.tenantId = data.tenantDTO.id
+						}
 					});
 				} else {
 					this.initTenant();
@@ -465,6 +470,12 @@ export default {
 					this.officeTreeData = data;
 					this.inputForm.officeDTO.id = "";
 					this.inputForm.officeDTO.name = "";
+					if (this.inputForm.companyDTO.id) {
+						this.tenantId = data[0].tenantDTO.id
+						this.mobilePhoneOnly(this.inputForm.mobile)
+					} else {
+						this.tenantId = null
+					}
 				});
 		},
 		handleChangeTenant(tenantId) {
@@ -595,6 +606,30 @@ export default {
 				})
 			}
 		},
+		//联系电话唯一性判断
+		mobilePhoneOnly(mobilePhone) {
+			if (this.commonJS.isNotEmpty(mobilePhone)) {
+				if (!this.validateXG.isPhoneOrMobile(mobilePhone)) {
+					this.$message.error('”联系电话“填写不正确,请重新填写')
+					this.loading = false
+					this.inputForm.mobile = ''
+					throw new Error('”联系电话“填写不正确,请重新填写')
+				}
+			}
+			if (this.commonJS.isNotEmpty(mobilePhone) && this.commonJS.isNotEmpty(this.tenantId)) {
+				enrollmentRegistrationService.findMobilePhoneOnlyByTenantId({
+					mobilePhone: mobilePhone,
+					tenantId: this.tenantId,
+					userId: this.inputForm.id
+				}).then((data) => {
+					if (data !== 0) {
+						this.$message.error('联系电话已存在,请重新确认')
+						this.inputForm.mobile = ''
+						throw new Error('联系电话已存在,请重新确认')
+					}
+				})
+			}
+		},
 	},
 };
 </script>