瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/views/attendance/daily/index.vue
lucw 1 周之前
父節點
當前提交
5f49ec6f61

+ 12 - 0
src/BIZComponents/processSubmitDialog/api.js

@@ -21,6 +21,18 @@ export async function getTaskAssignRuleList(query) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+// 预览任务分配规则算出的审批人(提交审核弹窗的执行人展示,支持表单字段驱动审批人)
+export async function previewTaskAssignees(data) {
+  const res = await request({
+    url: '/bpm/task-assign-rule/preview-assignees',
+    method: 'post',
+    data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 export async function processInstanceCreateAPI(data) {
   const res = await request(
     {

+ 61 - 1
src/BIZComponents/processSubmitDialog/processSubmitDialog.vue

@@ -99,8 +99,23 @@
           min-width="140px"
         >
           <template v-slot="scope">
+            <template v-if="scope.row.type === 90">
+              <div v-if="(scope.row.previewNames || []).length > 0">
+                <el-tag
+                  size="medium"
+                  :key="name"
+                  v-for="name in scope.row.previewNames"
+                >
+                  {{ name }}
+                </el-tag>
+              </div>
+              <div v-else-if="scope.row.previewMessage" class="assign-preview-tip">
+                {{ scope.row.previewMessage }}
+              </div>
+              <span v-else class="assign-preview-loading">按表单字段动态获取</span>
+            </template>
             <div
-              v-if="
+              v-else-if="
                 scope.row.type !== 60 &&
                 scope.row.type !== 70 &&
                 scope.row.type !== 80 &&
@@ -183,6 +198,7 @@
     getProcessDefinitionBpmnXML,
     getProcessDefinitionInfo,
     getTaskAssignRuleList,
+    previewTaskAssignees,
     listAllUserBind,
     listSimpleUserGroups,
     processInstanceCreateAPI,
@@ -487,6 +503,39 @@
         } catch (e) {
           this.datasource = [];
         }
+        await this.loadAssignRulePreview(find);
+      },
+      /**
+       * 预览动态规则(type=90 表单字段驱动审批人)算出的审批人。
+       * 流程实例还没创建,服务端按 businessKey/businessId 回源单据字段后试算,
+       * 这里只负责把结果贴回对应节点,让弹窗的执行人列不再是空白。
+       */
+      async loadAssignRulePreview(find) {
+        if (!(this.datasource || []).some((row) => row.type === 90)) return;
+        try {
+          const list = await previewTaskAssignees({
+            modelId: find.modelId,
+            processDefinitionId: find.processDefinitionId,
+            businessKey: this.form.businessKey,
+            businessId: this.form.businessId,
+            variables: this.form.variables
+          });
+          const previewMap = {};
+          (list || []).forEach((item) => {
+            previewMap[item.taskDefinitionKey] = item;
+          });
+          this.datasource = this.datasource.map((row) => {
+            const preview = previewMap[row.taskDefinitionKey];
+            if (!preview) return row;
+            return {
+              ...row,
+              previewNames: preview.assignNames || [],
+              previewMessage: preview.message || ''
+            };
+          });
+        } catch (e) {
+          // 预览失败不影响提交,执行人列退回「按表单字段动态获取」提示
+        }
       },
       getAssignRuleOptionName(row, option) {
         if (row.type == 10) {
@@ -635,6 +684,17 @@
   };
 </script>
 <style scoped lang="scss">
+  .assign-preview-tip {
+    font-size: 12px;
+    line-height: 1.4;
+    color: #f56c6c;
+    text-align: left;
+    word-break: break-all;
+  }
+  .assign-preview-loading {
+    font-size: 12px;
+    color: #909399;
+  }
   .process-submit-viewer {
     display: block;
     border: 1px solid #ebeef5;

+ 4 - 1
src/api/hr/attendance.js

@@ -1896,7 +1896,10 @@ export function adaptDailyAttendance(raw = {}) {
     sourceType: item.sourceTypeName || '',
     /* 上下班分组「打卡地点」列:punchRecords 内的 address 直取(2026-11-03 用户指定字段) */
     address: item.address || '',
-    status: item.statusName || '',
+    /* 打卡状态判定码:后端 punchRecords[].status 原始码(VALID=正常、其它码=异常,2026-11-11 用户口径),
+       只用于列表 tag 上色。显示文案仍直取中文 statusName,前端不做码→文案映射、不编造默认状态。 */
+    status: item.status || '',
+    statusName: item.statusName || '',
     statusText: item.statusName || '',
     punchAddress: item.punchAddress || '',
   });

+ 5 - 1
src/utils/employee-template.js

@@ -3,7 +3,8 @@ import * as XLSX from "xlsx";
 /**
  * 员工档案「导入/导出模板」唯一来源。
  *
- * 表头文案、顺序、工作表名、样例行 100% 对齐用户拍板的《员工档案导入模板.xlsx》(28 列,含「微信号」「用户账号」),
+ * 表头文案、顺序、工作表名、样例行 100% 对齐用户拍板的《员工档案导入模板.xlsx》(29 列,含「微信号」「用户账号」
+ * 「户籍地址」),
  * 「导出当前结果 / 导出已选」与「下载导入模板」都从这里生成,两处口径不允许再各写一份。
  * 2026-10-20 用户拍板:删掉原文模板里第 14 列重复的「*工号」(与第 3 列同名同值)。
  * 剩余 1 处重复表头(第 11 列「岗位」与第 15 列「*岗位」,原文模板自带)原样保留,不做「优化」,否则回导对不上列。
@@ -110,6 +111,7 @@ export const EMPLOYEE_TEMPLATE_COLUMNS = [
   },
   { header: "*入职时间", value: (row) => toExcelDate(row.hireDate) },
   { header: "籍贯", value: (row) => textOf(row.nativePlace) },
+  { header: "户籍地址", value: (row) => textOf(row.registeredAddress) },
   {
     header: "工种",
     value: (row) =>
@@ -162,6 +164,8 @@ export function buildEmployeeTemplateSampleRow() {
     /* 入职时间:原文件为日期序列号 40987 = 2012-03-19 */
     new Date(2012, 2, 19),
     "湖南",
+    /* 户籍地址(2026-11-09 新增,紧随籍贯) */
+    null,
     null,
     111,
     "湖南测试学院",

+ 51 - 16
src/views/attendance/daily/index.vue

@@ -38,8 +38,11 @@
       <ele-pro-table ref="table" row-key="id" :columns="columns" :datasource="fetchPage" :need-page="true"
         :page-size="20" :page-sizes="[10, 20, 50]" :cache-key="$tableCacheKey('hr-attendance-daily-v9')">
         <template v-slot:toolbar>
-          <el-button icon="el-icon-upload2" @click="onImport">导入excel</el-button>
-          <el-button type="primary" icon="el-icon-download" @click="onExport">excel导出</el-button>
+          <!-- 导入/导出按钮权限:统一用 hr:hrAttendanceRuleDaily:importExcel(2026-11-12 用户指定) -->
+          <el-button v-if="$hasPermission('hr:hrAttendanceRuleDaily:importExcel')" icon="el-icon-upload2"
+            @click="onImport">导入excel</el-button>
+          <el-button v-if="$hasPermission('hr:hrAttendanceRuleDaily:importExcel')" type="primary" icon="el-icon-download"
+            @click="onExport">excel导出</el-button>
         </template>
 
         <template slot="name" slot-scope="{ row }">
@@ -49,8 +52,10 @@
         </template>
 
         <template slot="statusNameList" slot-scope="{ row }">
+          <!-- 文案直取后端中文 statusNameList;颜色按同序英文码 statusList 判断(2026-11-11 用户口径) -->
           <div v-for="(name, index) in row.statusNameList" :key="index" class="status-tag-line">
-            <el-tag size="mini" :type="attendanceStatusTagType(name)" class="punch-tag">
+            <el-tag size="mini" :type="attendanceStatusTagType(row.statusList[index])"
+              :style="attendanceStatusTagStyle(row.statusList[index])" class="punch-tag">
               {{ name }}
             </el-tag>
           </div>
@@ -215,6 +220,15 @@ const STATUS_OPTIONS = [
   { value: 'OVERTIME', label: '加班' },
 ];
 
+/* 出差蓝色、外出青色、加班用另一种绿(不与「正常」的 success 绿撞色);请假回内置 info 灰。
+   (2026-11-11 用户指定)内置 el-tag 四色不够区分,自定义色的用浅底 + 同色系文字/边框。
+   纯展示配色,不参与数据判断;色值可直接在此调整。 */
+const EXTRA_STATUS_TAG_STYLE = {
+  BUSINESS_TRIP: { backgroundColor: '#ecf5ff', borderColor: '#b3d8ff', color: '#409EFF' }, // 蓝
+  OUTING: { backgroundColor: '#e6fffb', borderColor: '#87e8de', color: '#08979C' },        // 青(待用户看图确认)
+  OVERTIME: { backgroundColor: '#e8f7ef', borderColor: '#a8e0c2', color: '#0F9D58' },     // 翡翠绿,区别于正常 success 绿
+};
+
 export default {
   name: 'AttendanceDaily',
   components: {
@@ -335,20 +349,41 @@ export default {
       return { list: this.currentRows, count: data.count };
     },
     punchStatusTagType(item) {
-      /* 文案与色值均按后端中文字段判断:statusName=有效/已作废/地点异常,sourceType=移动端/考勤设备/补卡 */
-      if (item.sourceType === '补卡' || item.statusText === '已作废') return 'danger';
-      if (item.statusText === '有效') return 'success';
-      if (item.statusText === '待审批') return 'warning';
-      return 'info';
+      /* 打卡状态 tag 颜色按 punchRecords[].status 原始码判断(2026-11-11 用户口径):
+         VALID = 正常 → 绿色 success;其它码 = 异常 → 红色 danger。
+         status 未返回时没有判定依据 → 灰色 info,绝不把「字段缺失」当成异常;
+         文案仍是后端中文 statusName 直取,未返回就留空,前端不兜底。 */
+      const code = String(item.status || '');
+      if (!code) return 'info';
+      return code === 'VALID' ? 'success' : 'danger';
+    },
+    /* 出勤情况 tag 颜色:按行级 statusList 英文码判断(2026-11-11 用户口径:英文值判色、
+       中文 statusNameList 显示)。两者同序,按 index 配对。
+       码表 = 用户提供的 AttendanceConstants.DAILY_*(前 6 项,实际字符串按本页 STATUS_OPTIONS
+       一直在用的 NORMAL/LATE/EARLY_LEAVE/MISSING_IN/MISSING_OUT/ABSENT)+ LEAVE/BUSINESS_TRIP/OUTING/OVERTIME。
+       码未返回、两数组不同序或出现码表外的值 → 灰(没有配色依据),不把缺失/未知当成异常。 */
+    attendanceStatusTagType(code) {
+      const types = {
+        NORMAL: 'success',
+        LATE: 'warning',
+        EARLY_LEAVE: 'warning',
+        MISSING_IN: 'warning',
+        MISSING_OUT: 'warning',
+        ABSENT: 'danger',
+        /* 请假回内置 info 灰;出差/外出/加班走 EXTRA_STATUS_TAG_STYLE 自定义色,
+           不套内置 type(否则底色被覆盖成灰) */
+        LEAVE: 'info',
+        BUSINESS_TRIP: '',
+        OUTING: '',
+        OVERTIME: '',
+      };
+      const value = String(code || '');
+      if (!value) return 'info';
+      return Object.prototype.hasOwnProperty.call(types, value) ? types[value] : 'info';
     },
-    /* 出勤情况 tag 颜色:按后端状态中文字段判断(正常=绿,迟到/早退/缺卡=橙,旷工=红,其他=灰) */
-    attendanceStatusTagType(name) {
-      const text = String(name || '');
-      if (!text) return 'info';
-      if (text.includes('正常')) return 'success';
-      if (text.includes('旷工')) return 'danger';
-      if (text.includes('迟到') || text.includes('早退') || text.includes('缺')) return 'warning';
-      return 'info';
+    /* 四个自定义色:返回 el-tag 的 inline style;其余码返回 null,Vue 不追加样式 */
+    attendanceStatusTagStyle(code) {
+      return EXTRA_STATUS_TAG_STYLE[String(code || '')] || null;
     },
     minuteText(value) {
       return value === null || value === undefined ? '' : String(value);

+ 23 - 5
src/views/attendance/report/index.vue

@@ -89,7 +89,7 @@
 <script>
 import * as echarts from 'echarts';
 import { listOrganizations } from '@/api/organization';
-import { flattenOrganizationTree, buildOrganizationTree } from '@/utils/organization-tree';
+import { getCurrentOrgId } from '@/utils/current-org';
 import {
   getDepartmentAttendanceReport,
   getAttendanceExceptionReport,
@@ -172,10 +172,28 @@ export default {
     async loadDepartments() {
       try {
         const list = await listOrganizations();
-        const flat = flattenOrganizationTree(buildOrganizationTree(list || []));
-        this.departmentOptions = [{ value: '', label: '全部部门' }].concat(
-          flat.map((item) => ({ value: item.id, label: item.name }))
-        );
+        /* 只展示当前账号所属公司子树下的部门(2026-11-09 用户要求):
+           按 parentId 从当前机构向下递归收集;getGroupList 不含公司根节点,
+           不能用「建树找根取 children」的写法(会整批落空 → 无数据)。 */
+        const orgId = getCurrentOrgId();
+        const byParent = new Map();
+        (list || []).forEach((item) => {
+          const key = String(item.parentId);
+          if (!byParent.has(key)) byParent.set(key, []);
+          byParent.get(key).push(item);
+        });
+        const options = [];
+        const seen = new Set();
+        const walk = (parentId) => {
+          (byParent.get(String(parentId)) || []).forEach((item) => {
+            if (seen.has(String(item.id))) return;
+            seen.add(String(item.id));
+            options.push({ value: item.id, label: item.name });
+            walk(item.id);
+          });
+        };
+        walk(orgId);
+        this.departmentOptions = [{ value: '', label: '全部部门' }].concat(options);
       } catch (error) {
         this.departmentOptions = [{ value: '', label: '全部部门' }];
       }

+ 43 - 30
src/views/hiring/hiringApproval/components/ApprovalFormDrawer.vue

@@ -397,12 +397,29 @@ export default {
       return window.innerWidth < 720 ? "96%" : "960px";
     },
     departmentOptions() {
-      if (this.form.deptId == null || this.form.deptId === "") {
-        return [];
-      }
-      return this.allDepartments.filter(
-        (item) => String(item.legalId) === String(this.form.deptId),
-      );
+      /* 入职部门:从所选机构往下递归收集整棵子树(与转正页 positionCascade mixin 同口径)。
+         旧实现按 parentId 向上回溯找根再过滤,父链断裂时部门会被误判成根节点整批滤掉,
+         表现为下拉「无数据」(2026-11-09 用户反馈),改为向下遍历规避。 */
+      const rootId = this.form.deptId;
+      if (rootId == null || rootId === "") return [];
+      const byParent = new Map();
+      this.allDepartments.forEach((item) => {
+        const key = String(item.parentId);
+        if (!byParent.has(key)) byParent.set(key, []);
+        byParent.get(key).push(item);
+      });
+      const options = [];
+      const seen = new Set();
+      const walk = (parentId) => {
+        (byParent.get(String(parentId)) || []).forEach((item) => {
+          if (seen.has(String(item.id))) return;
+          seen.add(String(item.id));
+          options.push({ id: item.id, name: item.name });
+          walk(item.id);
+        });
+      };
+      walk(rootId);
+      return options;
     },
   },
   watch: {
@@ -657,36 +674,15 @@ export default {
       try {
         /* 所属机构选项:登录缓存 loginChangeGroupVOList */
         this.legalEntities = getOrgOptions();
-        /* 部门选项仍需组织列表回溯归属机构 */
+        /* 部门选项:组织平铺列表(入职部门下拉按 parentId 向下遍历,见 departmentOptions) */
         const list = await listOrganizations().catch(() => []);
-        const records = (Array.isArray(list) ? list : asList(list))
+        this.allDepartments = (Array.isArray(list) ? list : asList(list))
           .map((item) => ({
             id: item.id,
             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]));
-        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,
-            };
-          })
-          /* 公司根节点(上级链顶到自己)不是部门,不进入职部门下拉 */
-          .filter((item) => String(item.id) !== String(item.legalId));
       } catch (error) {
         /* 机构选项来自登录缓存,不因组织列表接口失败而清空 */
         this.allDepartments = [];
@@ -770,12 +766,29 @@ export default {
         null
       );
     },
+    /** 按组织 parentId 向上回溯根节点(仅提交兜底用:deptId 为空时反推所属机构) */
+    orgRootOf(id) {
+      const byId = new Map(
+        this.allDepartments.map((item) => [String(item.id), item]),
+      );
+      let current = this.findDept(id);
+      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 current?.id ?? null;
+    },
     /** 提交前把入职部门 / 所属机构的 id、名称同步到接口字段 */
     syncOrgAndDeptFields() {
       const departmentId =
         this.form.departmentId ?? this.form.hiringDeptId ?? null;
       const dept = this.findDept(departmentId);
-      const orgId = this.form.deptId ?? dept?.legalId ?? null;
+      const orgId = this.form.deptId ?? this.orgRootOf(departmentId) ?? null;
       const org = this.findOrg(orgId);
       this.form.deptId = orgId;
       this.form.deptName = org?.name || this.form.deptName || "";

+ 6 - 5
src/views/hrManagement/employeeArchive/index.vue

@@ -97,9 +97,10 @@
                     class="ele-btn-icon" @click="openCreate">
                     新增
                   </el-button>
-                  <!-- 导入入口暂时隐藏(2026-10-29 用户要求,只保留导出);
-                       handleImportCommand / onImportFile 方法保留,恢复时放开下面注释即可 -->
-                  <!-- <el-dropdown v-if="$hasPermission('main:hrEmployee:import')
+                  <!-- 导入入口(2026-10-29 曾按用户要求隐藏,2026-11-10 恢复:
+                       员工档案导入需支持「户籍地址」,模板已含 29 列;
+                       「下载导入模板」走本地生成(employee-template.js),不再调后端旧模板) -->
+                  <el-dropdown v-if="$hasPermission('main:hrEmployee:import')
                     || $hasPermission('main:hrEmployee:importTemplate')" trigger="click"
                     @command="handleImportCommand">
                     <el-button icon="el-icon-upload2" class="ele-btn-icon">
@@ -113,7 +114,7 @@
                     </el-dropdown-menu>
                   </el-dropdown>
                   <input ref="importInput" type="file" accept=".xlsx,.xls" style="display: none"
-                    @change="onImportFile" /> -->
+                    @change="onImportFile" />
 
                   <el-dropdown v-if="$hasPermission('main:hrEmployee:export')" trigger="click"
                     @command="handleExport">
@@ -778,7 +779,7 @@ export default {
     },
     async handleImportCommand(command) {
       if (command === 'template') {
-        // 「下载导入模板」= 本地按《员工档案导入模板.xlsx》生成(28 列 + 样例行),
+        // 「下载导入模板」= 本地按《员工档案导入模板.xlsx》生成(29 列 + 样例行,含户籍地址),
         // 不再调后端 downLoadTemplate(后端下发的是旧 22 列,和页面导出/回导口径对不上)
         try {
           const fileName = downloadEmployeeTemplate(`员工档案导入模板_${new Date().toISOString().slice(0, 10)}.xlsx`);

+ 23 - 12
src/views/position/positionManagement/index.vue

@@ -72,9 +72,10 @@
               </el-select>
             </el-form-item>
             <el-form-item label="部门">
-              <!-- 树形:部门有二级三级,扁平下拉只剩一级 → 用级联树 + 可搜索 + 允许选父级 -->
-              <el-cascader v-model="deptFilter" :options="filterDepartmentTree" :props="departmentCascaderProps"
-                clearable filterable popper-class="position-dept-cascader" placeholder="请选择" style="width: 100%" />
+              <!-- 2026-11-09:与薪资模板筛选条同款 ele-tree-select,直接展示部门树(不带公司层,保留 二级/三级 部门层级) -->
+              <ele-tree-select v-model="deptFilter" :data="filterDeptTreeSelect" value-key="id" label-key="name"
+                children-key="children" clearable filterable default-expand-all placeholder="请选择"
+                style="width: 100%" />
             </el-form-item>
             <el-form-item label="状态" class="status-item">
               <el-select v-model="statusFilter" clearable placeholder="请选择">
@@ -262,15 +263,6 @@ export default {
       /* 所属机构筛选:默认带出登录机构列表第一个(左侧序列与岗位列表共用) */
       legalFilter: getCurrentOrgId() || "",
       deptFilter: "",
-      /* 部门级联:按 id 取值(emitPath: false 直接拿部门 id);checkStrictly 允许只选父级部门 */
-      departmentCascaderProps: {
-        value: "id",
-        label: "name",
-        children: "children",
-        emitPath: false,
-        checkStrictly: true,
-        expandTrigger: "hover",
-      },
       statusFilter: "",
       /* 更换 cacheKey 使旧的本体列顺序缓存(含拖拽/显隐记录)失效,让代码列顺序生效 */
       cacheKeyUrl: "fc7bccc0-hr-pc-position-management-v3",
@@ -526,6 +518,25 @@ export default {
         }, []);
       return prune(this.departmentTree || []);
     },
+    /**
+     * 部门筛选树(ele-tree-select 直接展示):剥离机构根节点层,
+     * 只留 一级 → 二级 → 三级 部门(2026-11-09 用户要求与薪资模板筛选条同款)。
+     */
+    filterDeptTreeSelect() {
+      const strip = (nodes) =>
+        (nodes || []).flatMap((node) => {
+          const isLegal = this.legalEntities.some(
+            (item) => String(item.id) === String(node.id),
+          );
+          if (isLegal) return strip(node.children);
+          const next = { id: node.id, name: node.name };
+          if (node.children && node.children.length) {
+            next.children = strip(node.children);
+          }
+          return [next];
+        });
+      return strip(this.filterDepartmentTree);
+    },
   },
   created() {
     this.loadData();

+ 32 - 10
src/views/salary/components/user-search.vue

@@ -73,8 +73,8 @@ export default {
       where: { ...defaultWhere },
       defaultWhere,
       legalEntities: [],
-      /* 全量组织树:所属部门下拉按所选公司取子树(见 deptTree),不直接整棵展示 */
-      fullOrgTree: [],
+      /* 组织平铺列表:所属部门下拉按所选公司向下递归取子树(见 deptTree) */
+      fullOrgList: [],
       // 默认公司(当前登录用户所在法人):初始化与重置共用
       defaultOrganizationId: '',
       statusOptions: TEMPLATE_STATUS_OPTIONS
@@ -88,14 +88,36 @@ export default {
      * 所属部门树:只显示**当前所选公司(所属公司)子树**下的组织。
      * 复测问题:原来整棵组织树直接进下拉,能看到其他公司(测试公司等)的部门。
      * 公司节点自身不进下拉(整个公司 = 清空部门筛选「全部部门」)。
+     * 2026-11-09:getGroupList 返回的组织列表不含公司根节点(只有部门),
+     * 原来按公司 id 在树里找根节点取 children 会落空 → 下拉「无数据」;
+     * 改为按 parentId 从所选公司向下递归收集子树(与转正页 positionCascade 同口径)。
      */
     deptTree() {
       const companyId = this.where.organizationId;
-      if (!companyId) return [];
-      const root = (this.fullOrgTree || []).find(
-        (node) => String(node.id) === String(companyId)
-      );
-      return root ? root.children || [] : [];
+      if (!companyId || !this.fullOrgList.length) return [];
+      const byParent = new Map();
+      this.fullOrgList.forEach((item) => {
+        const key = String(item.parentId);
+        if (!byParent.has(key)) byParent.set(key, []);
+        byParent.get(key).push(item);
+      });
+      /* 向下收集公司子树内全部节点 id(防环) */
+      const ids = new Set();
+      const collect = (parentId) => {
+        (byParent.get(String(parentId)) || []).forEach((item) => {
+          if (ids.has(String(item.id))) return;
+          ids.add(String(item.id));
+          collect(item.id);
+        });
+      };
+      collect(companyId);
+      const subtree = this.fullOrgList.filter((item) => ids.has(String(item.id)));
+      const tree = buildOrganizationTree(subtree);
+      /* 公司节点若在返回列表里会成为唯一根:剥掉公司层只留部门 */
+      if (tree.length === 1 && String(tree[0].id) === String(companyId)) {
+        return tree[0].children || [];
+      }
+      return tree;
     },
     /* 当前公司子树内全部节点 id,用于切换公司时清掉已失效的部门筛选值 */
     deptIdsInScope() {
@@ -122,13 +144,13 @@ export default {
     this.loadOrgTree();
   },
   methods: {
-    /* 全量组织树(扁平列表 → 树):部门下拉只取其中所选公司的子树 */
+    /* 组织平铺列表(扁平含 parentId):部门下拉按所选公司向下递归取子树 */
     async loadOrgTree() {
       try {
         const list = await listOrganizations();
-        this.fullOrgTree = buildOrganizationTree(Array.isArray(list) ? list : []);
+        this.fullOrgList = Array.isArray(list) ? list : [];
       } catch (error) {
-        this.fullOrgTree = [];
+        this.fullOrgList = [];
       }
     },
     init() {