feat: 新增根据权限标识获取用户列表功能
- 新增SysUserController.listUsersByPermission接口 - 新增SysUserService.selectUserListByPermission方法 - 支持多租户和权限关联查询 - 更新变更记录文档
This commit is contained in:
1 parent
90b13a6e0c
commit
661a513f57
86 files changed
+22988
-199
No files matched your search
+55
-18
@@ -1,26 +1,63 @@
|
||||
import { reactive } from 'vue';
|
||||
import { getDicts } from '@/api/system/dict/data';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
*/
|
||||
export const useDict = (...args: string[]): { [key: string]: DictDataOption[] } => {
|
||||
const res = ref<{
|
||||
[key: string]: DictDataOption[];
|
||||
}>({});
|
||||
export const useDict = (...args: string[]) => {
|
||||
const res = reactive<{ [key: string]: DictDataOption[] }>({});
|
||||
|
||||
args.forEach(async (dictType) => {
|
||||
res.value[dictType] = [];
|
||||
const dicts = useDictStore().getDict(dictType);
|
||||
if (dicts) {
|
||||
res.value[dictType] = dicts;
|
||||
} else {
|
||||
await getDicts(dictType).then((resp) => {
|
||||
res.value[dictType] = resp.data.map(
|
||||
(p): DictDataOption => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass })
|
||||
);
|
||||
useDictStore().setDict(dictType, res.value[dictType]);
|
||||
});
|
||||
}
|
||||
// 初始化所有字典类型为空数组
|
||||
args.forEach(dictType => {
|
||||
res[dictType] = [];
|
||||
});
|
||||
return res.value;
|
||||
|
||||
// 使用Promise.all确保所有字典数据都能正确加载
|
||||
const loadDict = async () => {
|
||||
try {
|
||||
const promises = args.map(async (dictType) => {
|
||||
const dicts = useDictStore().getDict(dictType);
|
||||
if (dicts && dicts.length > 0) {
|
||||
res[dictType] = dicts;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(`开始加载字典类型: ${dictType}`);
|
||||
const resp = await getDicts(dictType);
|
||||
console.log(`字典 ${dictType} API响应:`, resp);
|
||||
|
||||
if (resp && resp.data && Array.isArray(resp.data) && resp.data.length > 0) {
|
||||
const dictData = resp.data.map(
|
||||
(p): DictDataOption => ({
|
||||
label: p.dictLabel,
|
||||
value: p.dictValue,
|
||||
elTagType: p.listClass,
|
||||
elTagClass: p.cssClass
|
||||
})
|
||||
);
|
||||
res[dictType] = dictData;
|
||||
useDictStore().setDict(dictType, dictData);
|
||||
console.log(`字典 ${dictType} 加载成功,数据:`, dictData);
|
||||
} else {
|
||||
console.warn(`字典类型 ${dictType} 没有返回有效数据,响应:`, resp);
|
||||
res[dictType] = [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`获取字典类型 ${dictType} 失败:`, error);
|
||||
res[dictType] = [];
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
} catch (error) {
|
||||
console.error('字典数据批量加载失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 立即执行异步加载
|
||||
loadDict();
|
||||
|
||||
return res;
|
||||
};
|
||||
Reference in new issue
Block a user