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 秒 过期 wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期
} }
}, },
getDictByType(type: string) {
if (!this.isSetDict) {
this.setDictMap()
}
return this.dictMap[type]
},
async resetDict() { async resetDict() {
wsCache.delete(CACHE_KEY.DICT_CACHE) wsCache.delete(CACHE_KEY.DICT_CACHE)
const res = await listSimpleDictDataApi() const res = await listSimpleDictDataApi()

View File

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

View File

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