fix: dict map

pull/2/head
xingyu 2023-01-17 15:13:23 +08:00
parent dbfc485bb1
commit 34f3e68558
3 changed files with 20 additions and 31 deletions

View File

@ -66,6 +66,12 @@ export const useDictStore = defineStore('dict', {
wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期
}
},
getDictByType(type: string) {
if (!this.isSetDict) {
this.setDictMap()
}
return this.dictMap[type]
},
async resetDict() {
wsCache.delete(CACHE_KEY.DICT_CACHE)
const res = await listSimpleDictDataApi()

View File

@ -21,7 +21,7 @@ export interface DictDataType {
}
export const getDictOptions = (dictType: string) => {
return dictStore.getDictMap[dictType]
return dictStore.getDictByType(dictType)
}
export const getIntDictOptions = (dictType: string) => {

View File

@ -9,7 +9,7 @@
preIcon="ep:zoom-in"
:title="t('action.add')"
v-hasPermi="['system:post:create']"
@click="handleCreate()"
@click="openModel('create')"
/>
<!-- 操作导出 -->
<XButton
@ -24,21 +24,18 @@
<!-- 操作修改 -->
<XTextButton
preIcon="ep:edit"
:title="t('action.edit')"
v-hasPermi="['system:post:update']"
@click="handleUpdate(row.id)"
@click="openModel('update', row.id)"
/>
<!-- 操作详情 -->
<XTextButton
preIcon="ep:view"
:title="t('action.detail')"
v-hasPermi="['system:post:query']"
@click="handleDetail(row.id)"
@click="openModel('detail', row.id)"
/>
<!-- 操作删除 -->
<XTextButton
preIcon="ep:delete"
:title="t('action.del')"
v-hasPermi="['system:post:delete']"
@click="deleteData(row.id)"
/>
@ -103,34 +100,20 @@ const actionLoading = ref(false) // 按钮 Loading
const formRef = ref<FormExpose>() // Ref
const detailData = ref() // Ref
//
const setDialogTile = (type: string) => {
const openModel = async (type: string, rowId?: number) => {
modelLoading.value = true
modelTitle.value = t('action.' + type)
actionType.value = type
modelVisible.value = true
}
//
const handleCreate = () => {
setDialogTile('create')
modelLoading.value = false
}
//
const handleUpdate = async (rowId: number) => {
setDialogTile('update')
//
const res = await PostApi.getPostApi(rowId)
unref(formRef)?.setValues(res)
modelLoading.value = false
}
//
const handleDetail = async (rowId: number) => {
setDialogTile('detail')
const res = await PostApi.getPostApi(rowId)
detailData.value = res
if (rowId) {
const res = await PostApi.getPostApi(rowId)
if (type === 'update') {
unref(formRef)?.setValues(res)
} else if (type === 'detail') {
detailData.value = res
}
}
modelLoading.value = false
}
@ -155,7 +138,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reload()
reload()
}
}
})