From a29cb267e67d4cc4d29438e5e3a4bbbb403a1f8b Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 07 七月 2026 14:32:18 +0800
Subject: [PATCH] 转正申请,调岗申请,工作交接申请,申请人可以根据配置得选项来源,选择数据

---
 src/views/officeProcessAutomation/HrManage/regular-apply/index.vue                                         |    1 
 src/views/officeProcessAutomation/ApproveManage/approve-template/useSelectOptionSources.js                 |   13 +++---
 src/views/officeProcessAutomation/HrManage/transfer-apply/index.vue                                        |    1 
 src/views/officeProcessAutomation/ApproveManage/approve-list/components/FormPayloadFields.vue              |   17 ++++----
 src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue   |    2 
 src/views/officeProcessAutomation/ApproveManage/approve-template/selectOptionSource.js                     |   77 ++++++++++++++++++++++++++++++++++----
 src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalInstanceSubmitDialog.vue |    2 +
 src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue  |    2 +
 src/views/officeProcessAutomation/HrManage/work-handover/index.vue                                         |    1 
 9 files changed, 93 insertions(+), 23 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/components/FormPayloadFields.vue b/src/views/officeProcessAutomation/ApproveManage/approve-list/components/FormPayloadFields.vue
index 7933db5..817a007 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/components/FormPayloadFields.vue
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/components/FormPayloadFields.vue
@@ -80,12 +80,12 @@
           clearable
           filterable
         >
-          <el-option
-            v-for="o in getOptions(field)"
-            :key="String(o.value)"
-            :label="o.label"
-            :value="o.value"
-          />
+        <el-option
+          v-for="o in getOptions(field, { moduleKey: props.moduleKey })"
+          :key="String(o.value)"
+          :label="o.label"
+          :value="o.value"
+        />
         </el-select>
         <span v-else class="field-value">{{ displayValue(field) }}</span>
       </el-form-item>
@@ -103,13 +103,14 @@
   fields: { type: Array, default: () => [] },
   formPayload: { type: Object, default: () => ({}) },
   readonly: { type: Boolean, default: false },
+  moduleKey: { type: String, default: "" },
 });
 
 const { loading: optionSourceLoading, ensureForFields, getOptions, getDisplayLabel } =
   useSelectOptionSources();
 
 async function loadOptionCaches() {
-  await ensureForFields(props.fields);
+  await ensureForFields(props.fields, { moduleKey: props.moduleKey });
 }
 
 onMounted(() => {
@@ -127,7 +128,7 @@
 function displayValue(field) {
   const val = props.formPayload?.[field.key];
   if (field.type === "select" && field.optionSource && field.optionSource !== "static") {
-    return getDisplayLabel(field, val);
+    return getDisplayLabel(field, val, { moduleKey: props.moduleKey });
   }
   return formatFieldDisplayValue(field, val);
 }
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalInstanceSubmitDialog.vue b/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalInstanceSubmitDialog.vue
index 53de9e1..0f9646c 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalInstanceSubmitDialog.vue
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalInstanceSubmitDialog.vue
@@ -24,6 +24,7 @@
         v-model:attachments="form.storageBlobDTOs"
         :template-attachments="form.templateAttachments"
         :user-options="userOptions"
+        :module-key="moduleKey"
         :show-template-name="!isEdit"
         :allow-change-template="false"
         :flow-attachments-only="flowAttachmentsOnly"
@@ -56,6 +57,7 @@
   fields: { type: Array, default: () => [] },
   activeTemplate: { type: Object, default: null },
   userOptions: { type: Array, default: () => [] },
+  moduleKey: { type: String, default: "" },
   isEdit: { type: Boolean, default: false },
   saving: { type: Boolean, default: false },
   formRef: { type: Object, default: null },
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue b/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue
index 409dd41..6d56084 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue
@@ -4,7 +4,7 @@
   鐢ㄦ硶锛�
   <ApprovalTemplateBindDialog
     v-model:visible="visible"
-    module-key="regular"
+    :module-key="APPROVAL_MODULE_KEYS.REGULAR"
     @confirm="onTemplateBound"
   />
 -->
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue b/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue
index d6e7073..ebc5ac4 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue
@@ -15,6 +15,7 @@
       v-if="!hideFormFields && !flowAttachmentsOnly && !flowOnly"
       :fields="fields"
       :form-payload="formPayload"
+      :module-key="moduleKey"
     />
 
     <el-form-item label="瀹℃壒娴佺▼" required>
@@ -87,6 +88,7 @@
   uploadLimit: { type: Number, default: 10 },
   /** 涓� true 鏃跺彲缂栬緫妯℃澘棰勭疆鐨勫鎵逛汉锛堜粎瀹℃壒妯℃澘绠$悊椤典娇鐢級 */
   flowEditable: { type: Boolean, default: false },
+  moduleKey: { type: String, default: "" },
 });
 
 const emit = defineEmits(["update:flowNodes", "update:attachments", "change-template"]);
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/selectOptionSource.js b/src/views/officeProcessAutomation/ApproveManage/approve-template/selectOptionSource.js
index 99706b4..3dbc6f0 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/selectOptionSource.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/selectOptionSource.js
@@ -1,30 +1,42 @@
 import { deptTreeSelect, userListNoPageByTenantId } from "@/api/system/user.js";
+import { staffOnJobListPage } from "@/api/personnelManagement/staffOnJob.js";
 
 /** 涓嬫媺閫夐」鏉ユ簮锛堝啓鍏� formConfig锛屾彁浜ら〉鎸夋潵婧愭媺鍙栨暟鎹級 */
 export const SELECT_OPTION_SOURCE = {
   STATIC: "static",
   USER: "user",
   DEPT: "dept",
+  EMPLOYEE: "employee",
 };
 
 export const SELECT_OPTION_SOURCE_OPTIONS = [
   { value: SELECT_OPTION_SOURCE.STATIC, label: "鎵嬪姩閰嶇疆", desc: "鍦ㄦā鏉夸腑鑷畾涔夐�夐」鏂囨湰涓庡��" },
   { value: SELECT_OPTION_SOURCE.USER, label: "浜哄憳鍒楄〃", desc: "浠庣郴缁熺敤鎴蜂腑閫夋嫨锛屽�间负鐢ㄦ埛 ID" },
   { value: SELECT_OPTION_SOURCE.DEPT, label: "閮ㄩ棬鍒楄〃", desc: "浠庣粍缁囨灦鏋勪腑閫夋嫨锛屽�间负閮ㄩ棬 ID" },
+  { value: SELECT_OPTION_SOURCE.EMPLOYEE, label: "鍛樺伐鍒楄〃", desc: "浠庡湪鑱屽憳宸ヤ腑閫夋嫨锛屽�间负鍛樺伐 ID" },
 ];
+
+const EMPLOYEE_APPLICANT_MODULE_KEYS = new Set(["regular"]);
 
 export function selectOptionSourceLabel(source) {
   return SELECT_OPTION_SOURCE_OPTIONS.find((x) => x.value === source)?.label || "鈥�";
 }
 
 export function isDynamicOptionSource(source) {
-  return source === SELECT_OPTION_SOURCE.USER || source === SELECT_OPTION_SOURCE.DEPT;
+  return (
+    source === SELECT_OPTION_SOURCE.USER ||
+    source === SELECT_OPTION_SOURCE.DEPT ||
+    source === SELECT_OPTION_SOURCE.EMPLOYEE
+  );
 }
 
 function unwrapArray(payload) {
   if (Array.isArray(payload)) return payload;
+  if (Array.isArray(payload?.records)) return payload.records;
   if (payload?.data && Array.isArray(payload.data)) return payload.data;
+  if (Array.isArray(payload?.data?.records)) return payload.data.records;
   if (payload?.rows && Array.isArray(payload.rows)) return payload.rows;
+  if (Array.isArray(payload?.data?.rows)) return payload.data.rows;
   return [];
 }
 
@@ -39,6 +51,15 @@
   const value = u.userId ?? u.id;
   return {
     label: u.nickName || u.userName || `鐢ㄦ埛${value}`,
+    value,
+  };
+}
+
+/** 鍦ㄨ亴鍛樺伐 鈫� 涓嬫媺 option */
+export function mapEmployeeToSelectOption(u) {
+  const value = u.id ?? u.staffOnJobId ?? u.staffId;
+  return {
+    label: u.staffName || u.name || u.userName || `鍛樺伐${value}`,
     value,
   };
 }
@@ -70,21 +91,41 @@
 }
 
 /** 鎸夊瓧娈甸厤缃В鏋愪笅鎷� options锛堥渶浼犲叆宸插姞杞界殑缂撳瓨锛� */
-export function resolveFieldSelectOptions(field, caches = {}) {
+function isApplicantField(field) {
+  const key = String(field?.key || "").toLowerCase();
+  const label = String(field?.label || "");
+  return (
+    key === "applicant" ||
+    key === "applicantname" ||
+    label.includes("鐢宠浜�")
+  );
+}
+
+export function resolveFieldSelectOptions(field, caches = {}, context = {}) {
   const source = field?.optionSource || SELECT_OPTION_SOURCE.STATIC;
+  if (
+    source === SELECT_OPTION_SOURCE.USER &&
+    EMPLOYEE_APPLICANT_MODULE_KEYS.has(context.moduleKey) &&
+    isApplicantField(field)
+  ) {
+    return (caches.employees || []).map(mapEmployeeToSelectOption);
+  }
   if (source === SELECT_OPTION_SOURCE.USER) {
     return (caches.users || []).map(mapUserToSelectOption);
   }
   if (source === SELECT_OPTION_SOURCE.DEPT) {
     return caches.deptOptions || [];
   }
+  if (source === SELECT_OPTION_SOURCE.EMPLOYEE) {
+    return (caches.employees || []).map(mapEmployeeToSelectOption);
+  }
   return (field?.options || []).filter((o) => o.value !== "" && o.value != null);
 }
 
 /** 鏍规嵁宸茶В鏋愮殑 options 鍙嶆煡灞曠ず鏂囨湰 */
-export function resolveSelectDisplayLabel(field, val, caches = {}) {
+export function resolveSelectDisplayLabel(field, val, caches = {}, context = {}) {
   if (val == null || val === "") return "鈥�";
-  const options = resolveFieldSelectOptions(field, caches);
+  const options = resolveFieldSelectOptions(field, caches, context);
   const hit = options.find((o) => String(o.value) === String(val));
   return hit?.label || String(val);
 }
@@ -93,9 +134,10 @@
 export async function fetchSelectOptionCaches(sources = []) {
   const needUser = sources.includes(SELECT_OPTION_SOURCE.USER);
   const needDept = sources.includes(SELECT_OPTION_SOURCE.DEPT);
-  const caches = { users: [], deptOptions: [] };
+  const needEmployee = sources.includes(SELECT_OPTION_SOURCE.EMPLOYEE);
+  const caches = { users: [], deptOptions: [], employees: [] };
 
-  if (!needUser && !needDept) return caches;
+  if (!needUser && !needDept && !needEmployee) return caches;
 
   const tasks = [];
   if (needUser) {
@@ -123,17 +165,36 @@
         })
     );
   }
+  if (needEmployee) {
+    tasks.push(
+      staffOnJobListPage({ current: -1, size: -1, staffState: 1 })
+        .then((res) => {
+          caches.employees = unwrapArray(res);
+        })
+        .catch(() => {
+          caches.employees = [];
+        })
+    );
+  }
 
   await Promise.all(tasks);
   return caches;
 }
 
 /** 浠庡瓧娈靛垪琛ㄦ敹闆嗛渶瑕侀鍔犺浇鐨勫姩鎬佹潵婧� */
-export function collectOptionSourcesFromFields(fields) {
+export function collectOptionSourcesFromFields(fields, context = {}) {
   const set = new Set();
   (fields || []).forEach((f) => {
     if (f?.type === "select" && isDynamicOptionSource(f.optionSource)) {
-      set.add(f.optionSource);
+      if (
+        EMPLOYEE_APPLICANT_MODULE_KEYS.has(context.moduleKey) &&
+        f.optionSource === SELECT_OPTION_SOURCE.USER &&
+        isApplicantField(f)
+      ) {
+        set.add(SELECT_OPTION_SOURCE.EMPLOYEE);
+      } else {
+        set.add(f.optionSource);
+      }
     }
   });
   return [...set];
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/useSelectOptionSources.js b/src/views/officeProcessAutomation/ApproveManage/approve-template/useSelectOptionSources.js
index 8397288..5d246e1 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/useSelectOptionSources.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/useSelectOptionSources.js
@@ -14,25 +14,26 @@
     deptOptions: [],
   });
 
-  async function ensureForFields(fields) {
-    const sources = collectOptionSourcesFromFields(fields);
+  async function ensureForFields(fields, context = {}) {
+    const sources = collectOptionSourcesFromFields(fields, context);
     if (!sources.length) return;
     loading.value = true;
     try {
       const next = await fetchSelectOptionCaches(sources);
       caches.users = next.users;
       caches.deptOptions = next.deptOptions;
+      caches.employees = next.employees || [];
     } finally {
       loading.value = false;
     }
   }
 
-  function getOptions(field) {
-    return resolveFieldSelectOptions(field, caches);
+  function getOptions(field, context = {}) {
+    return resolveFieldSelectOptions(field, caches, context);
   }
 
-  function getDisplayLabel(field, val) {
-    return resolveSelectDisplayLabel(field, val, caches);
+  function getDisplayLabel(field, val, context = {}) {
+    return resolveSelectDisplayLabel(field, val, caches, context);
   }
 
   return {
diff --git a/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue b/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue
index 291d57d..df70f4f 100644
--- a/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue
+++ b/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue
@@ -48,6 +48,7 @@
       :fields="submitFormFields"
       :active-template="activeTemplate"
       :user-options="flowUserOptions"
+      :module-key="APPROVAL_MODULE_KEYS.REGULAR"
       :is-edit="isSubmitEdit"
       :saving="submitSaving"
       :form-ref="submitFormRef"
diff --git a/src/views/officeProcessAutomation/HrManage/transfer-apply/index.vue b/src/views/officeProcessAutomation/HrManage/transfer-apply/index.vue
index f731d57..8b43805 100644
--- a/src/views/officeProcessAutomation/HrManage/transfer-apply/index.vue
+++ b/src/views/officeProcessAutomation/HrManage/transfer-apply/index.vue
@@ -58,6 +58,7 @@
       :fields="submitFormFields"
       :active-template="activeTemplate"
       :user-options="flowUserOptions"
+      :module-key="APPROVAL_MODULE_KEYS.TRANSFER"
       :is-edit="isSubmitEdit"
       :saving="submitSaving"
       :form-ref="submitFormRef"
diff --git a/src/views/officeProcessAutomation/HrManage/work-handover/index.vue b/src/views/officeProcessAutomation/HrManage/work-handover/index.vue
index a9b96ae..37ff223 100644
--- a/src/views/officeProcessAutomation/HrManage/work-handover/index.vue
+++ b/src/views/officeProcessAutomation/HrManage/work-handover/index.vue
@@ -58,6 +58,7 @@
       :fields="submitFormFields"
       :active-template="activeTemplate"
       :user-options="flowUserOptions"
+      :module-key="APPROVAL_MODULE_KEYS.WORK_HANDOVER"
       :is-edit="isSubmitEdit"
       :saving="submitSaving"
       :form-ref="submitFormRef"

--
Gitblit v1.9.3