diff --git a/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityCol.vue b/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityCol.vue index 1421fd2..5610f43 100644 --- a/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityCol.vue +++ b/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityCol.vue @@ -520,33 +520,68 @@ const getDeptTree = async () => { } }; +const loadSchemaList = async (dbRID) => { + const res = await getMetaMdlNameList(dbRID) + schemaList.value = res.data || [] +} + +const loadTableList = async (mdlName) => { + const res = await getMetaDataList({ + ssysId: form.value.dbRID, + mdlName, + pageNum: 1, + pageSize: 10000 + }) + tableList.value = res.data.rows.map(item => item.tabEngName) +} + +const loadColumnList = async (tabName) => { + const res = await getColumnList({ + ssysId: form.value.dbRID, + mdlName: form.value.dbSName, + tabName + }) + columnList.value = ["ALL", ...res.data.map(item => item.fldEngName)] +} + // 打开编辑对话框 -const handleEdit = (row) => { - reset(); - const colId = row.colId || ids.value; +const handleEdit = async (row) => { + reset() + dialogTitle.value = "编辑列配置" - getMetaSecurityCol(colId).then(response => { - const data = response.data; + const colId = row.colId || ids.value + const res = await getMetaSecurityCol(colId) + const data = res.data - // ⭐ 回显字段多选:字符串 → 数组 - if (data.dbCName && typeof data.dbCName === 'string') { - data.dbCName = data.dbCName.split(','); - } else if (!data.dbCName) { - data.dbCName = []; - } + // 字段字符串 → 数组 + data.dbCName = data.dbCName ? data.dbCName.split(',') : [] + + // 先赋基础数据 + form.value = data + + // ① 加载模式 + await loadSchemaList(form.value.dbRID) + + // ② 加载表 + if (form.value.dbSName) { + await loadTableList(form.value.dbSName) + } + + // ③ 加载字段 + if (form.value.dbTName) { + await loadColumnList(form.value.dbTName) + } + + // 对象类型切换 + if (data.objType === '0') { + userOrRoleList.value = userList.value + } else if (data.objType === '1') { + userOrRoleList.value = roleList.value + } + + dialogVisible.value = true +} - form.value = data; - if (data.objType === '0') { - userOrRoleList.value = userList.value; // 用户 - } else if (data.objType === '1') { - userOrRoleList.value = roleList.value; // 角色 - } else { - userOrRoleList.value = []; - } - dialogVisible.value = true; - dialogTitle.value = "编辑列配置"; - }); -}; // 保存数据 diff --git a/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityRow.vue b/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityRow.vue index 6c53e13..1d8ba33 100644 --- a/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityRow.vue +++ b/vue-fastapi-frontend/src/views/meta/metasercurity/MetaSecurityRow.vue @@ -472,33 +472,67 @@ const handlePagination = (pageNum, pageSize) => { // 打开编辑对话框 -const handleEdit = (row) => { - reset(); + +const handleEdit = async (row) => { + reset() + dialogTitle.value = "编辑行配置" + const rowId = row.rowId || ids.value; + const res = await getMetaSecurityRow(rowId) + const data = res.data - getMetaSecurityRow(rowId).then(response => { - const data = response.data; + // 字段字符串 → 数组 + data.dbCName = data.dbCName ? data.dbCName.split(',') : [] - // ⭐ 回显字段多选:字符串 → 数组 - if (data.dbCName && typeof data.dbCName === 'string') { - data.dbCName = data.dbCName.split(','); - } else if (!data.dbCName) { - data.dbCName = []; - } - if (data.objType === '0') { - userOrRoleList.value = userList.value; // 用户 - } else if (data.objType === '1') { - userOrRoleList.value = roleList.value; // 角色 - } else { - userOrRoleList.value = []; - } - form.value = data; + // 先赋基础数据 + form.value = data - dialogVisible.value = true; - dialogTitle.value = "编辑行配置"; - }); -}; + // ① 加载模式 + await loadSchemaList(form.value.dbRID) + + // ② 加载表 + if (form.value.dbSName) { + await loadTableList(form.value.dbSName) + } + + // ③ 加载字段 + if (form.value.dbTName) { + await loadColumnList(form.value.dbTName) + } + + // 对象类型切换 + if (data.objType === '0') { + userOrRoleList.value = userList.value + } else if (data.objType === '1') { + userOrRoleList.value = roleList.value + } + dialogVisible.value = true +} + +const loadSchemaList = async (dbRID) => { + const res = await getMetaMdlNameList(dbRID) + schemaList.value = res.data || [] +} + +const loadTableList = async (mdlName) => { + const res = await getMetaDataList({ + ssysId: form.value.dbRID, + mdlName, + pageNum: 1, + pageSize: 10000 + }) + tableList.value = res.data.rows.map(item => item.tabEngName) +} + +const loadColumnList = async (tabName) => { + const res = await getColumnList({ + ssysId: form.value.dbRID, + mdlName: form.value.dbSName, + tabName + }) + columnList.value = ["ALL", ...res.data.map(item => item.fldEngName)] +} // 保存数据 function handleSave() { proxy.$refs["formRef"].validate(valid => {