|
@@ -72,29 +72,31 @@ const state = reactive<any>({
|
|
|
},
|
|
|
dictypeList: [],
|
|
|
parentData: [],
|
|
|
+ currentId:''
|
|
|
});
|
|
|
const ruleFormRef = ref<FormInstance>();
|
|
|
let loading = ref<boolean>(false);
|
|
|
-// 格式化数据 剔除自己
|
|
|
-const formatDta = (arr: Array<any>, id: string) => {
|
|
|
+// 格式化数据 排除自己
|
|
|
+const formatData = (arr: Array<any>, id: string) => {
|
|
|
if (!arr) return [];
|
|
|
arr.forEach((v: any, i: number) => {
|
|
|
if (v.id === id) arr.splice(i, 1);
|
|
|
- if (v.children?.length) {
|
|
|
- formatDta(v.children, id);
|
|
|
+ if (v.children && v.children.length) {
|
|
|
+ formatData(v.children, id);
|
|
|
}
|
|
|
});
|
|
|
return arr;
|
|
|
};
|
|
|
// 打开弹窗
|
|
|
const openDialog = async (row: any, tableData: any) => {
|
|
|
+ state.currentId = row.id ?? ''
|
|
|
// 获取详情
|
|
|
if (!auth('100602')) ElMessage.warning('抱歉,您没有获取字典对象权限!');
|
|
|
else {
|
|
|
ruleFormRef.value?.clearValidate();
|
|
|
try {
|
|
|
const res: any = await Promise.all([getDetail(row.id), dictypeList()]);
|
|
|
- state.parentData = formatDta(JSON.parse(JSON.stringify(tableData)), row.id);
|
|
|
+ state.parentData = formatData(JSON.parse(JSON.stringify(tableData)), row.id);
|
|
|
state.ruleForm = res[0].result;
|
|
|
state.dictypeList = res[1].result ?? [];
|
|
|
state.isShowDialog = true;
|
|
@@ -115,6 +117,7 @@ const onCancel = () => {
|
|
|
const changeDicType = (val: string) => {
|
|
|
getDataByTypeid({ typeid: val }).then((response: any) => {
|
|
|
state.parentData = response?.result ?? [];
|
|
|
+ state.parentData = formatData(JSON.parse(JSON.stringify(state.parentData)), state.currentId);
|
|
|
});
|
|
|
};
|
|
|
// 保存
|