分类获取字段列表方法,以保存后进行更新列表字段

This commit is contained in:
YUN-PC5\user 2023-10-08 16:37:30 +08:00
parent 425be9414a
commit 307b209791
2 changed files with 33 additions and 8 deletions

View File

@ -8,7 +8,7 @@ export const getModelList = () => {
}) })
} }
export const getFields = (params) => { export const getFields = (params: { fullName: string; roleId: any }) => {
return request({ return request({
url: url + 'getFields', url: url + 'getFields',
method: 'get', method: 'get',
@ -30,3 +30,11 @@ export const addOrUpdateSysRoleField = (roleId: any, data: any) => {
data data
}) })
} }
export const fieldDisplay = (params: { queryKey: string }) => {
return request({
url: url + 'fieldDisplay',
method: 'post',
params
})
}

View File

@ -85,22 +85,39 @@ const getList = async () => {
modelList.value = data modelList.value = data
cardLoading.value = false cardLoading.value = false
} }
const handleCurrentChange = async (val: any) => {
const currentRow = ref()
const handleCurrentChange = (val: any) => {
if (val) { if (val) {
fieldListLoading.value = true currentRow.value = val
const { data } = await getFields({ fullName: val.fullName, roleId: route.query.roleId }) handleLoadFieldList()
fieldList.value = data
fieldListLoading.value = false
} else { } else {
fieldList.value = [] fieldList.value = []
} }
} }
const handleLoadFieldList = async () => {
fieldListLoading.value = true
try {
const val = currentRow.value
const { data } = await getFields({ fullName: val.fullName, roleId: route.query.roleId })
fieldList.value = data
} catch (e) {
console.error(e)
}
fieldListLoading.value = false
}
const fieldListLoading = ref(false) const fieldListLoading = ref(false)
const saveBtnLoading = ref(false) const saveBtnLoading = ref(false)
const handleSave = async () => { const handleSave = async () => {
saveBtnLoading.value = true saveBtnLoading.value = true
try {
await addOrUpdateSysRoleField(route.query.roleId, fieldList.value) await addOrUpdateSysRoleField(route.query.roleId, fieldList.value)
modal.msgSuccess('保存成功') modal.msgSuccess('保存成功')
handleLoadFieldList()
} catch (e) {
console.error(e)
}
saveBtnLoading.value = false saveBtnLoading.value = false
} }
onMounted(() => { onMounted(() => {