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

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({
url: url + 'getFields',
method: 'get',
@ -30,3 +30,11 @@ export const addOrUpdateSysRoleField = (roleId: any, data: any) => {
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
cardLoading.value = false
}
const handleCurrentChange = async (val: any) => {
const currentRow = ref()
const handleCurrentChange = (val: any) => {
if (val) {
fieldListLoading.value = true
const { data } = await getFields({ fullName: val.fullName, roleId: route.query.roleId })
fieldList.value = data
fieldListLoading.value = false
currentRow.value = val
handleLoadFieldList()
} else {
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 saveBtnLoading = ref(false)
const handleSave = async () => {
saveBtnLoading.value = true
try {
await addOrUpdateSysRoleField(route.query.roleId, fieldList.value)
modal.msgSuccess('保存成功')
handleLoadFieldList()
} catch (e) {
console.error(e)
}
saveBtnLoading.value = false
}
onMounted(() => {