新增getDict接口方法并重构菜单显示隐藏选项为动态字典数据
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
import request from '/@/utils/request';
|
||||
import {ref ,toRefs,ToRefs} from 'vue'
|
||||
// 根据字典类型查询字典数据信息
|
||||
export function getDict(dictType :string,defaultValue?:string):Promise<any> {
|
||||
let dv = defaultValue??''
|
||||
let params ={
|
||||
dictType:dictType,
|
||||
defaultValue:dv
|
||||
}
|
||||
return request({
|
||||
url: '/api/v1/system/dict/data/getDictData',
|
||||
method: 'get',
|
||||
params:params
|
||||
})
|
||||
}
|
||||
|
||||
// 根据字典类型查询字典数据信息
|
||||
export function getDicts(dictType :string,defaultValue?:string):Promise<any> {
|
||||
let dv = defaultValue??''
|
||||
@@ -14,6 +28,7 @@ export function getDicts(dictType :string,defaultValue?:string):Promise<any> {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
*/
|
||||
@@ -21,7 +36,7 @@ export function useDict(...args:string[]):ToRefs<any>{
|
||||
const res:any = ref({});
|
||||
args.forEach((d:string) => {
|
||||
res.value[d] = [];
|
||||
getDicts(d).then(resp => {
|
||||
getDict(d).then(resp => {
|
||||
res.value[d] = resp.data.values.map((p:any) => ({ label: p.value, value: p.key, isDefault: p.isDefault }))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user