|
|
@@ -82,11 +82,29 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="所属机构" prop="deptId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.deptId"
|
|
|
+ class="full-width"
|
|
|
+ filterable
|
|
|
+ placeholder="—"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in legalEntities"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="入职部门" prop="departmentId">
|
|
|
<el-select
|
|
|
v-model="form.departmentId"
|
|
|
class="full-width"
|
|
|
+ filterable
|
|
|
placeholder="—"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -130,7 +148,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <p class="field-hint">先选入职部门,再按部门加载应聘岗位。</p>
|
|
|
+ <p class="field-hint">先选所属机构,再选入职部门,再按部门加载应聘岗位。</p>
|
|
|
</section>
|
|
|
|
|
|
<section class="info-card">
|
|
|
@@ -252,8 +270,12 @@ const emptyForm = () => ({
|
|
|
workYears: undefined,
|
|
|
positionId: null,
|
|
|
positionName: '',
|
|
|
+ hiringDeptId: null,
|
|
|
+ hiringDeptName: '',
|
|
|
departmentId: null,
|
|
|
departmentName: '',
|
|
|
+ deptId: null,
|
|
|
+ deptName: '',
|
|
|
proposedSalary: undefined,
|
|
|
expectedEntryDate: '',
|
|
|
probationPeriod: 3,
|
|
|
@@ -312,10 +334,21 @@ export default {
|
|
|
educationOptions: [...DEFAULT_EDUCATION_OPTIONS],
|
|
|
positionNatureOptions: [],
|
|
|
positionOptions: [],
|
|
|
- departmentOptions: [],
|
|
|
+ legalEntities: [],
|
|
|
+ allDepartments: [],
|
|
|
resumeFileIds: []
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ departmentOptions() {
|
|
|
+ if (this.form.deptId == null || this.form.deptId === '') {
|
|
|
+ return this.allDepartments;
|
|
|
+ }
|
|
|
+ return this.allDepartments.filter(
|
|
|
+ (item) => String(item.legalId) === String(this.form.deptId)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
watch: {
|
|
|
businessId: {
|
|
|
immediate: true,
|
|
|
@@ -343,7 +376,7 @@ export default {
|
|
|
await Promise.all([
|
|
|
this.loadPositionNatureOptions(),
|
|
|
this.loadDictOptions(),
|
|
|
- this.loadDepartments()
|
|
|
+ this.loadOrganizations()
|
|
|
]);
|
|
|
const detail = await getHiringApprovalById(id);
|
|
|
this.applyDetail(detail);
|
|
|
@@ -377,16 +410,14 @@ export default {
|
|
|
: undefined,
|
|
|
positionId: detail.positionId ?? null,
|
|
|
positionName: detail.positionName || '',
|
|
|
- departmentId:
|
|
|
- detail.departmentId ??
|
|
|
- detail.hiringDeptId ??
|
|
|
- detail.deptId ??
|
|
|
- null,
|
|
|
+ hiringDeptId: detail.hiringDeptId ?? detail.departmentId ?? null,
|
|
|
+ hiringDeptName:
|
|
|
+ detail.hiringDeptName || detail.departmentName || '',
|
|
|
+ departmentId: detail.hiringDeptId ?? detail.departmentId ?? null,
|
|
|
departmentName:
|
|
|
- detail.departmentName ||
|
|
|
- detail.hiringDeptName ||
|
|
|
- detail.deptName ||
|
|
|
- '',
|
|
|
+ detail.hiringDeptName || detail.departmentName || '',
|
|
|
+ deptId: detail.deptId ?? null,
|
|
|
+ deptName: detail.deptName || '',
|
|
|
resumeAttachmentFileIds: detail.resumeAttachmentFileIds || '',
|
|
|
proposedSalary:
|
|
|
detail.proposedSalary === '' || detail.proposedSalary == null
|
|
|
@@ -508,23 +539,73 @@ export default {
|
|
|
this.positionLoading = false;
|
|
|
}
|
|
|
},
|
|
|
- async loadDepartments() {
|
|
|
+ async loadOrganizations() {
|
|
|
this.departmentLoading = true;
|
|
|
try {
|
|
|
const list = await listOrganizations();
|
|
|
- const records = Array.isArray(list) ? list : asList(list);
|
|
|
- this.departmentOptions = records
|
|
|
+ const records = (Array.isArray(list) ? list : asList(list))
|
|
|
.map((item) => ({
|
|
|
id: item.id,
|
|
|
- name: item.name || item.orgName || item.groupName || ''
|
|
|
+ name: item.name || item.orgName || item.groupName || '',
|
|
|
+ parentId: item.parentId
|
|
|
}))
|
|
|
.filter((item) => item.id != null && item.name);
|
|
|
+ const byId = new Map(records.map((item) => [String(item.id), item]));
|
|
|
+ const legalEntities = records
|
|
|
+ .filter((item) => !byId.has(String(item.parentId || 0)))
|
|
|
+ .map((item) => ({ id: item.id, name: item.name }));
|
|
|
+ this.legalEntities = legalEntities.length
|
|
|
+ ? legalEntities
|
|
|
+ : records.map((item) => ({ id: item.id, name: item.name }));
|
|
|
+ this.allDepartments = records.map((item) => {
|
|
|
+ let current = item;
|
|
|
+ const seen = new Set();
|
|
|
+ while (
|
|
|
+ current &&
|
|
|
+ byId.has(String(current.parentId)) &&
|
|
|
+ !seen.has(String(current.id))
|
|
|
+ ) {
|
|
|
+ seen.add(String(current.id));
|
|
|
+ current = byId.get(String(current.parentId));
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ name: item.name,
|
|
|
+ legalId: current?.id
|
|
|
+ };
|
|
|
+ });
|
|
|
} catch (error) {
|
|
|
- this.departmentOptions = [];
|
|
|
+ this.legalEntities = [];
|
|
|
+ this.allDepartments = [];
|
|
|
} finally {
|
|
|
this.departmentLoading = false;
|
|
|
}
|
|
|
},
|
|
|
+ syncOrgDeptNames() {
|
|
|
+ if (this.form.deptId != null && !this.form.deptName) {
|
|
|
+ this.form.deptName =
|
|
|
+ this.legalEntities.find(
|
|
|
+ (item) => String(item.id) === String(this.form.deptId)
|
|
|
+ )?.name || '';
|
|
|
+ }
|
|
|
+ if (this.form.departmentId != null) {
|
|
|
+ const hit = this.allDepartments.find(
|
|
|
+ (item) => String(item.id) === String(this.form.departmentId)
|
|
|
+ );
|
|
|
+ if (hit) {
|
|
|
+ this.form.departmentName = hit.name || this.form.departmentName;
|
|
|
+ this.form.hiringDeptId = this.form.departmentId;
|
|
|
+ this.form.hiringDeptName = this.form.departmentName;
|
|
|
+ if (this.form.deptId == null || this.form.deptId === '') {
|
|
|
+ this.form.deptId = hit.legalId ?? null;
|
|
|
+ this.form.deptName =
|
|
|
+ this.legalEntities.find(
|
|
|
+ (item) => String(item.id) === String(this.form.deptId)
|
|
|
+ )?.name || this.form.deptName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
async fillRelatedInfo() {
|
|
|
if (
|
|
|
this.form.positionId != null &&
|
|
|
@@ -536,6 +617,8 @@ export default {
|
|
|
this.form.departmentId = pos.deptId;
|
|
|
this.form.departmentName =
|
|
|
pos.deptName || this.form.departmentName || '';
|
|
|
+ this.form.hiringDeptId = this.form.departmentId;
|
|
|
+ this.form.hiringDeptName = this.form.departmentName;
|
|
|
if (!this.form.positionName) {
|
|
|
this.form.positionName = pos.name || pos.positionName || '';
|
|
|
}
|
|
|
@@ -544,12 +627,7 @@ export default {
|
|
|
/* ignore */
|
|
|
}
|
|
|
}
|
|
|
- if (this.form.departmentId != null && !this.form.departmentName) {
|
|
|
- this.form.departmentName =
|
|
|
- this.departmentOptions.find(
|
|
|
- (item) => String(item.id) === String(this.form.departmentId)
|
|
|
- )?.name || '';
|
|
|
- }
|
|
|
+ this.syncOrgDeptNames();
|
|
|
if (this.form.departmentId != null && this.form.departmentId !== '') {
|
|
|
const keepPositionId = this.form.positionId;
|
|
|
const keepPositionName = this.form.positionName;
|