Просмотр исходного кода

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-wt into dev

xieyong 1 день назад
Родитель
Сommit
1cce35df02

+ 22 - 12
src/api/hr/hiringApproval.js

@@ -88,17 +88,19 @@ export function adaptHiringApproval(raw = {}, extras = {}) {
   const hireDate =
     dateOnly(raw.expectedEntryDate || extras.expectedEntryDate || raw.hireDate) ||
     "";
-  const departmentId =
-    extras.departmentId ||
-    raw.hiringDeptId ||
-    raw.departmentId ||
-    raw.deptId;
-  const departmentName =
-    extras.departmentName ||
+  const hiringDeptId =
+    extras.hiringDeptId ??
+    raw.hiringDeptId ??
+    extras.departmentId ??
+    raw.departmentId;
+  const hiringDeptName =
+    extras.hiringDeptName ||
     raw.hiringDeptName ||
+    extras.departmentName ||
     raw.departmentName ||
-    raw.deptName ||
     "";
+  const deptId = extras.deptId ?? raw.deptId;
+  const deptName = extras.deptName || raw.deptName || "";
   const phone =
     extras.phone ||
     extras.mobile ||
@@ -125,10 +127,12 @@ export function adaptHiringApproval(raw = {}, extras = {}) {
       extras.candidateName || raw.candidateName || raw.name || "",
     positionId: raw.positionId ?? extras.positionId,
     positionName: raw.positionName || extras.positionName || "",
-    hiringDeptId: raw.hiringDeptId ?? departmentId,
-    hiringDeptName: raw.hiringDeptName || departmentName,
-    departmentId,
-    departmentName,
+    hiringDeptId,
+    hiringDeptName,
+    departmentId: hiringDeptId,
+    departmentName: hiringDeptName,
+    deptId,
+    deptName,
     gender: extras.gender || raw.gender || "",
     education: extras.education ?? raw.education ?? "",
     phone,
@@ -237,6 +241,12 @@ export function serializeHiringApproval(form = {}) {
     gender: form.gender || undefined,
     name: name || undefined,
     positionId: keepBigIntId(form.positionId),
+    hiringDeptId: keepBigIntId(form.hiringDeptId ?? form.departmentId),
+    hiringDeptName:
+      String(form.hiringDeptName || form.departmentName || "").trim() ||
+      undefined,
+    deptId: keepBigIntId(form.deptId),
+    deptName: String(form.deptName || "").trim() || undefined,
     probationPeriod: toProbationMonths(form.probationPeriod ?? form.probation),
     proposedLevel: form.proposedLevel || undefined,
     proposedSalary: (() => {

+ 101 - 23
src/views/bpm/handleTask/components/hiringApproval/hiringApprovalDetail.vue

@@ -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;