diff --git a/src/hooks/lisData/dictData.ts b/src/hooks/lisData/dictData.ts index ca34233..738b9d3 100644 --- a/src/hooks/lisData/dictData.ts +++ b/src/hooks/lisData/dictData.ts @@ -5,38 +5,44 @@ import { getGroupInstrdList } from '@/api/liswork/work/LisWork'; import { comDict } from '@/utils/dict' const dictData = ref({}); -const instrOptions = ref<{ yq: string; yqmc: string }[]>([]) +export const instrOptions = ref<{ yq: string; yqmc: string }[]>([]); +// 2. 定义并导出加载数据的函数 export const getYqData = () => { - getGroupInstrdList() - .then((res: any) => { - if (res.code == 0) { - instrOptions.value = res.data.map((item: any) => ({ - yq: item.yq.trim(), - yqmc: item.yqmc - })) - } - }) -} + // 避免重复请求 + if (instrOptions.value.length > 0) return Promise.resolve(instrOptions.value); + return getGroupInstrdList().then((res: any) => { + if (res.code === 0) { + instrOptions.value = res.data.map((item: any) => ({ + yq: item.yq.trim(), + yqmc: item.yqmc + })); + } + return instrOptions.value; + }) + .catch(() => { + return []; + }); +}; //'XMGL','ITEMCLASS', 'YQDL' export const getDictData = async (...args: string[]) => { const dictRefs = await comDict(...args); - if(dictRefs.XMGL != undefined) dictData.value.XMGL = toRaw(dictRefs.XMGL.value) || [] - if(dictRefs.ITEMCLASS != undefined) dictData.value.ITEMCLASS = toRaw(dictRefs.ITEMCLASS.value) || [] - if(dictRefs.YQDL != undefined) dictData.value.YQDL = toRaw(dictRefs.YQDL.value) || [] - if(dictRefs.VA != undefined) dictData.value.VA = toRaw(dictRefs.VA.value) || [] - if(dictRefs.LF != undefined) dictData.value.LF = toRaw(dictRefs.LF.value) || [] - if(dictRefs.BT != undefined) dictData.value.BT = toRaw(dictRefs.BT.value) || [] - if(dictRefs.SLZQ != undefined) dictData.value.SLZQ = toRaw(dictRefs.SLZQ.value) || [] - if(dictRefs.UT != undefined) dictData.value.UT = toRaw(dictRefs.UT.value) || [] //单位 - if(dictRefs.MD != undefined) dictData.value.MD = toRaw(dictRefs.MD.value) || [] //测试方法 - if(dictRefs.ITEMCLASS != undefined) dictData.value.ITEMCLASS = toRaw(dictRefs.ITEMCLASS.value) || [] //细菌项目类别 - if(dictRefs.GBDM != undefined) dictData.value.GBDM = toRaw(dictRefs.GBDM.value) || [] //国标代码 + if (dictRefs.XMGL != undefined) dictData.value.XMGL = toRaw(dictRefs.XMGL.value) || [] + if (dictRefs.ITEMCLASS != undefined) dictData.value.ITEMCLASS = toRaw(dictRefs.ITEMCLASS.value) || [] + if (dictRefs.YQDL != undefined) dictData.value.YQDL = toRaw(dictRefs.YQDL.value) || [] + if (dictRefs.VA != undefined) dictData.value.VA = toRaw(dictRefs.VA.value) || [] + if (dictRefs.LF != undefined) dictData.value.LF = toRaw(dictRefs.LF.value) || [] + if (dictRefs.BT != undefined) dictData.value.BT = toRaw(dictRefs.BT.value) || [] + if (dictRefs.SLZQ != undefined) dictData.value.SLZQ = toRaw(dictRefs.SLZQ.value) || [] + if (dictRefs.UT != undefined) dictData.value.UT = toRaw(dictRefs.UT.value) || [] //单位 + if (dictRefs.MD != undefined) dictData.value.MD = toRaw(dictRefs.MD.value) || [] //测试方法 + if (dictRefs.ITEMCLASS != undefined) dictData.value.ITEMCLASS = toRaw(dictRefs.ITEMCLASS.value) || [] //细菌项目类别 + if (dictRefs.GBDM != undefined) dictData.value.GBDM = toRaw(dictRefs.GBDM.value) || [] //国标代码 } //字典数据格式化方法 -export const formatDict = (v: string, dictType: string) => { - if(v == undefined) return ; +export const formatDict = (v: string, dictType: string) => { + if (v == undefined) return; return dictData.value[dictType]?.find((item: any) => item.value == v.trim())?.label; } @@ -45,4 +51,4 @@ export const formatInstr = (v: string) => { return instrOptions.value.find((item: any) => item.yq == v.trim())?.yqmc; } -export {dictData} \ No newline at end of file +export { dictData } \ No newline at end of file diff --git a/src/store/modules/commonStore.ts b/src/store/modules/commonStore.ts index 31951b9..76708b6 100644 --- a/src/store/modules/commonStore.ts +++ b/src/store/modules/commonStore.ts @@ -28,9 +28,9 @@ export const useCommonStore = defineStore('commonStore', { // 持久化配置 persist: { // 指定要持久化的状态字段 - paths: ['fingerprint', 'defaultConfig',], + pick: ['fingerprint', 'defaultConfig'], // 可选配置:自定义存储键名(默认是store的id) - key: 'common_store', + // key: 'common_store', // 可选配置:指定存储位置(默认是localStorage 也可以用sessionStorage) storage: localStorage, } diff --git a/src/types/pinia.d.ts b/src/types/pinia.d.ts index 59b8e57..00bb262 100644 --- a/src/types/pinia.d.ts +++ b/src/types/pinia.d.ts @@ -9,7 +9,7 @@ declare module 'pinia' { // 定义持久化配置的类型(根据插件实际参数调整) interface PersistOptions { - paths?: string[] + pick?: string[] key?: string storage?: Storage } \ No newline at end of file diff --git a/src/views/checkCode/index.vue b/src/views/checkCode/index.vue index 2249782..856fe0a 100644 --- a/src/views/checkCode/index.vue +++ b/src/views/checkCode/index.vue @@ -74,8 +74,8 @@ + :scrollYConfig="{ enabled: true, rSize: 30, height: '100%', }" @selection-change="selectionChange" + :config="tableConfig" :enable-column-drag="true" @column-drag-end="handleColumnDragEnd"> @@ -370,7 +370,6 @@ const handleColumnDragEnd = (data: any) => { // 左侧表格配置 const tableConfig = ref({ - height: '76.5vh', // 高度 // 复选框配置 checkboxConfig: { // 可选配置项 @@ -397,7 +396,7 @@ const rightColumns = ref([ const rightTableConfig = ref({ // stripe: true, // 斑马纹 border: true, // 边框 - height: '', // 高度 + height: '78vh', // 高度 highlightCurrentRow: true, // 高亮当前行 }) @@ -572,8 +571,6 @@ onMounted(async () => { getList() } - - adjustTableHeight(); // 加载病人来源字典 const dictRefs = await comDict('PT', 'HOS', 'ST'); @@ -590,22 +587,6 @@ const formatDict = (v: string, dictType: string) => { return dictData.value[dictType]?.find((item: any) => item.value == v)?.label || v; }; -// 计算table高度 -watch(showSearch, () => { - nextTick(() => { - adjustTableHeight(); - }) -}, { immediate: true }); - -function adjustTableHeight() { - if (compactForm.value) { - // 获取高度 - heightForm.value = compactForm.value.offsetHeight; - tableConfig.value.height = `calc(80vh - ${heightForm.value}px)`; // 设置表格容器的高度 - rightTableConfig.value.height = `calc(80vh - ${heightForm.value}px)`; - } -} - const handletime = (val: Array) => { // console.log('时间', val); // 校验日期格式 @@ -737,7 +718,7 @@ const printPdf = () => {