|
|
@@ -203,6 +203,22 @@
|
|
|
showOverflowTooltip: true,
|
|
|
minWidth: 110
|
|
|
},
|
|
|
+ {
|
|
|
+ prop: 'groupName',
|
|
|
+ label: '公司',
|
|
|
+ // sortable: 'custom',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: (row) => {
|
|
|
+ if (!row.groupRoleList || !row.groupRoleList.length) return '';
|
|
|
+ const names = row.groupRoleList.map((item) => {
|
|
|
+ if (item.groupName) return item.groupName;
|
|
|
+ if (item.groupId) return this.companyMap[item.groupId] || '';
|
|
|
+ return '';
|
|
|
+ });
|
|
|
+ return names.filter(Boolean).join('、');
|
|
|
+ }
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'name',
|
|
|
label: '姓名',
|
|
|
@@ -271,6 +287,8 @@
|
|
|
// 是否显示导入弹窗
|
|
|
showImport: false,
|
|
|
organizationList: [],
|
|
|
+ // 组织 id -> 顶层公司名 的扁平映射,给 table formatter 查公司名用
|
|
|
+ companyMap: {},
|
|
|
pageSize: this.$store.state.tablePageSize,
|
|
|
cacheKeyUrl: '763607fc-system-user'
|
|
|
};
|
|
|
@@ -294,6 +312,34 @@
|
|
|
idField: 'id',
|
|
|
parentIdField: 'parentId'
|
|
|
});
|
|
|
+ // 构建 id -> parentId 的映射,再为每个 id 算出"顶层公司名"
|
|
|
+ const parentMap = {};
|
|
|
+ const idToName = {};
|
|
|
+ _list.forEach((item) => {
|
|
|
+ parentMap[item.id] = item.parentId;
|
|
|
+ idToName[item.id] = item.name;
|
|
|
+ });
|
|
|
+ const findRootName = (id, visited) => {
|
|
|
+ visited = visited || new Set();
|
|
|
+ if (visited.has(id)) return ''; // 防成环
|
|
|
+ visited.add(id);
|
|
|
+ const parentId = parentMap[id];
|
|
|
+ // 顶层判断——parentId 为空 / 0 / 或不在我们这张表里
|
|
|
+ if (
|
|
|
+ parentId == null ||
|
|
|
+ parentId === '' ||
|
|
|
+ parentId === 0 ||
|
|
|
+ !parentMap.hasOwnProperty(parentId)
|
|
|
+ ) {
|
|
|
+ return idToName[id] || '';
|
|
|
+ }
|
|
|
+ return findRootName(parentId, visited);
|
|
|
+ };
|
|
|
+ const companyMap = {};
|
|
|
+ _list.forEach((item) => {
|
|
|
+ companyMap[item.id] = findRootName(item.id);
|
|
|
+ });
|
|
|
+ this.companyMap = companyMap;
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
this.loading = false;
|