常用取值、使用仪器
This commit is contained in:
parent
06b5c8a595
commit
1c5f3c8cdb
@ -5,39 +5,29 @@ import { getGroupInstrdList } from '@/api/liswork/work/LisWork';
|
|||||||
import { comDict } from '@/utils/dict'
|
import { comDict } from '@/utils/dict'
|
||||||
|
|
||||||
const dictData = ref<DictData>({});
|
const dictData = ref<DictData>({});
|
||||||
export const instrOptions = ref<{ yq: string; yqmc: string }[]>([]);
|
const instrOptions = ref<{ yq: string; yqmc: string }[]>([]);
|
||||||
|
|
||||||
// 2. 定义并导出加载数据的函数
|
export const getYqData = (data?: any) => {
|
||||||
export const getYqData = () => {
|
|
||||||
// 避免重复请求
|
// 避免重复请求
|
||||||
if (instrOptions.value.length > 0) return Promise.resolve(instrOptions.value);
|
if (instrOptions.value.length > 0) return;
|
||||||
return getGroupInstrdList().then((res: any) => {
|
getGroupInstrdList(data).then((res: any) => {
|
||||||
if (res.code === 0) {
|
if (res.code == 0) {
|
||||||
instrOptions.value = res.data.map((item: any) => ({
|
instrOptions.value = res.data.map((item: any) => ({
|
||||||
yq: item.yq.trim(),
|
yq: item.yq.trim(),
|
||||||
yqmc: item.yqmc
|
yqmc: item.yqmc
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return instrOptions.value;
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
//'XMGL','ITEMCLASS', 'YQDL'
|
//'XMGL','ITEMCLASS', 'YQDL'
|
||||||
export const getDictData = async (...args: string[]) => {
|
export const getDictData = async (...args: string[]) => {
|
||||||
const dictRefs = await comDict(...args);
|
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) || []
|
args.forEach(key => {
|
||||||
if (dictRefs.YQDL != undefined) dictData.value.YQDL = toRaw(dictRefs.YQDL.value) || []
|
if (dictRefs[key] !== undefined) {
|
||||||
if (dictRefs.VA != undefined) dictData.value.VA = toRaw(dictRefs.VA.value) || []
|
dictData.value[key] = toRaw(dictRefs[key].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) || [] //国标代码
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//字典数据格式化方法
|
//字典数据格式化方法
|
||||||
@ -51,4 +41,4 @@ export const formatInstr = (v: string) => {
|
|||||||
return instrOptions.value.find((item: any) => item.yq == v.trim())?.yqmc;
|
return instrOptions.value.find((item: any) => item.yq == v.trim())?.yqmc;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { dictData }
|
export { dictData, instrOptions }
|
||||||
@ -18,12 +18,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import CustomTable from '@/components/elTable/index.vue'
|
import CustomTable from '@/components/elTable/index.vue'
|
||||||
import { XmTextresultNew } from '@/types';
|
import { XmTextresultNew } from '@/types';
|
||||||
import { ElMessageBox } from 'element-plus';
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { delXmTextresultNew } from '@/api/liswork/labItem/labItemApi';
|
import { delXmTextresultNew } from '@/api/liswork/labItem/labItemApi';
|
||||||
|
|
||||||
const modelParam = defineModel<any>()
|
const modelParam = defineModel<any>()
|
||||||
|
|
||||||
|
watch(() => modelParam.value.commonDescriptionsData, (val) => {
|
||||||
|
selectRow.value = null
|
||||||
|
})
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{ prop: 'textresult', label: '文字描述', visible: true, align: 'center', slot: 'textresult', width: 500, showOverflowTooltip: false },
|
{ prop: 'textresult', label: '文字描述', visible: true, align: 'center', slot: 'textresult', width: 500, showOverflowTooltip: false },
|
||||||
@ -59,20 +62,22 @@ const onAddClick = () => {
|
|||||||
const newData: XmTextresultNew = {
|
const newData: XmTextresultNew = {
|
||||||
xmid: modelParam.value.basicData.xmid,
|
xmid: modelParam.value.basicData.xmid,
|
||||||
xmdh: modelParam.value.basicData.xmdh,
|
xmdh: modelParam.value.basicData.xmdh,
|
||||||
xh: maxXh.value
|
xh: maxXh.value,
|
||||||
|
textresult: ''
|
||||||
}
|
}
|
||||||
modelParam.value.commonDescriptionsData.push(newData)
|
modelParam.value.commonDescriptionsData.push(newData)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDelClick = async () => {
|
const onDelClick = () => {
|
||||||
if (selectRow.value) {
|
if (!selectRow.value) return ElMessage.warning('请选择要删除的数据!');
|
||||||
await ElMessageBox.confirm('是否要删除选中的数据?', '警告',
|
ElMessageBox.confirm('是否要删除选中的数据?', '警告',
|
||||||
{ confirmButtonText: 'OK', cancelButtonText: 'Cancel', type: 'warning', });
|
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', }).then(() => {
|
||||||
//tableList.value = tableList.value.filter((item:any) => item.xh != selectRow.value.xh)
|
delXmTextresultNew({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh }).then((res: any) => {
|
||||||
await delXmTextresultNew({ xmid: modelParam.value.basicData.xmid, xh: selectRow.value.xh })
|
if (res.code == 0) {
|
||||||
emit('refreshTabData', modelParam.value.basicData)
|
modelParam.value.commonDescriptionsData = modelParam.value.commonDescriptionsData.filter((item: any) => item.xh != selectRow.value.xh)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import { XmInfoVs } from '@/types';
|
|||||||
import SelectTable from '@/components/SelectTable/index.vue'
|
import SelectTable from '@/components/SelectTable/index.vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { deleteXmInfoVs } from '@/api/liswork/labItem/labItemApi';
|
import { deleteXmInfoVs } from '@/api/liswork/labItem/labItemApi';
|
||||||
import { instrOptions, getYqData } from '@/hooks'
|
import { getYqData, instrOptions } from '@/hooks'
|
||||||
|
|
||||||
const modelParam = defineModel<any>()
|
const modelParam = defineModel<any>()
|
||||||
const tableRef = ref<any>();
|
const tableRef = ref<any>();
|
||||||
@ -112,8 +112,8 @@ const getDyckz = (row: XmInfoVs) => {
|
|||||||
return `${row.ckxx || ''}--${row.cksx || ''}`;
|
return `${row.ckxx || ''}--${row.cksx || ''}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
|
||||||
await getYqData();
|
onMounted(() => {
|
||||||
console.log('==>', instrOptions);
|
getYqData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
Loading…
x
Reference in New Issue
Block a user