常用取值、使用仪器

This commit is contained in:
wyuu 2025-12-12 18:02:04 +08:00
parent 06b5c8a595
commit 1c5f3c8cdb
3 changed files with 32 additions and 37 deletions

View File

@ -5,39 +5,29 @@ import { getGroupInstrdList } from '@/api/liswork/work/LisWork';
import { comDict } from '@/utils/dict'
const dictData = ref<DictData>({});
export const instrOptions = ref<{ yq: string; yqmc: string }[]>([]);
const instrOptions = ref<{ yq: string; yqmc: string }[]>([]);
// 2. 定义并导出加载数据的函数
export const getYqData = () => {
export const getYqData = (data?: any) => {
// 避免重复请求
if (instrOptions.value.length > 0) return Promise.resolve(instrOptions.value);
return getGroupInstrdList().then((res: any) => {
if (res.code === 0) {
if (instrOptions.value.length > 0) return;
getGroupInstrdList(data).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) || [] //国标代码
// 遍历传入的字典类型参数,动态处理赋值
args.forEach(key => {
if (dictRefs[key] !== undefined) {
dictData.value[key] = toRaw(dictRefs[key].value) || [];
}
});
}
//字典数据格式化方法
@ -51,4 +41,4 @@ export const formatInstr = (v: string) => {
return instrOptions.value.find((item: any) => item.yq == v.trim())?.yqmc;
}
export { dictData }
export { dictData, instrOptions }

View File

@ -18,12 +18,15 @@
<script setup lang="ts">
import CustomTable from '@/components/elTable/index.vue'
import { XmTextresultNew } from '@/types';
import { ElMessageBox } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import { ref } from 'vue';
import { delXmTextresultNew } from '@/api/liswork/labItem/labItemApi';
const modelParam = defineModel<any>()
watch(() => modelParam.value.commonDescriptionsData, (val) => {
selectRow.value = null
})
const tableRef = ref();
const columns = ref([
{ prop: 'textresult', label: '文字描述', visible: true, align: 'center', slot: 'textresult', width: 500, showOverflowTooltip: false },
@ -59,20 +62,22 @@ const onAddClick = () => {
const newData: XmTextresultNew = {
xmid: modelParam.value.basicData.xmid,
xmdh: modelParam.value.basicData.xmdh,
xh: maxXh.value
xh: maxXh.value,
textresult: ''
}
modelParam.value.commonDescriptionsData.push(newData)
}
const onDelClick = async () => {
if (selectRow.value) {
await ElMessageBox.confirm('是否要删除选中的数据?', '警告',
{ confirmButtonText: 'OK', cancelButtonText: 'Cancel', type: 'warning', });
//tableList.value = tableList.value.filter((item:any) => item.xh != selectRow.value.xh)
await delXmTextresultNew({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh })
emit('refreshTabData', modelParam.value.basicData)
const onDelClick = () => {
if (!selectRow.value) return ElMessage.warning('请选择要删除的数据!');
ElMessageBox.confirm('是否要删除选中的数据?', '警告',
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', }).then(() => {
delXmTextresultNew({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh }).then((res: any) => {
if (res.code == 0) {
modelParam.value.commonDescriptionsData = modelParam.value.commonDescriptionsData.filter((item: any) => item.xh != selectRow.value.xh)
}
})
})
}
</script>

View File

@ -37,7 +37,7 @@ import { XmInfoVs } from '@/types';
import SelectTable from '@/components/SelectTable/index.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { deleteXmInfoVs } from '@/api/liswork/labItem/labItemApi';
import { instrOptions, getYqData } from '@/hooks'
import { getYqData, instrOptions } from '@/hooks'
const modelParam = defineModel<any>()
const tableRef = ref<any>();
@ -112,8 +112,8 @@ const getDyckz = (row: XmInfoVs) => {
return `${row.ckxx || ''}--${row.cksx || ''}`;
}
}
onMounted(async () => {
await getYqData();
console.log('==>', instrOptions);
onMounted(() => {
getYqData();
});
</script>