复查结果

This commit is contained in:
wyuu 2025-10-31 18:07:30 +08:00
parent 72dcbd0ff6
commit 1603aee96c
2 changed files with 61 additions and 68 deletions

View File

@ -1,7 +1,8 @@
<!--仪器组件的封装--> <!--仪器组件的封装-->
<template> <template>
<SelectTable v-model:data="modelValue" :fields="props.fields" :tableData="instrOptions" label="yqmc" size="small" <SelectTable v-model:data="modelValue" :fields="fields" :tableData="instrOptions" label="yqmc" :size="props.size"
value="yq" objKey="yq" :border="true" :width="props.width" placeholder="请选择仪器" :clearable="false" @getDataValue="getDataValue" /> value="yq" objKey="yq" :border="true" :width="props.width" placeholder="请选择仪器" :clearable="props.clearable"
@getDataValue="getDataValue" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -10,38 +11,37 @@ import { getGroupInstrdList } from '@/api/liswork/work/LisWork';
import { Emits, Props, Field } from '@/types'; import { Emits, Props, Field } from '@/types';
import { ref, watch, onMounted } from 'vue'; import { ref, watch, onMounted } from 'vue';
const modelValue = ref<string | null>(''); const modelValue = ref<string | null>('');
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<{
placeholder: "请选择", width?: string | number,
size: "default", size?: string,
isHighlight: true, clearable?: boolean,
value: undefined, instrGroup?: string | number, //部门组代号
label: undefined, data: string
border: false, }>(), {
width: "100%", width: '100%',
dictType: '', size: 'default',
clearable: true, clearable: false
fields: () => [ })
{ prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true },
{ prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true },
] as Field[]
});
const instrOptions = ref<Array<{ yq: string; yqmc: string }>>([]); const instrOptions = ref<Array<{ yq: string; yqmc: string }>>([]);
const fields = ref(
[
{ prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true },
{ prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true },
]
)
const emits = defineEmits<Emits>(); const emits = defineEmits<Emits>();
// 当父组件使用 v-model:data 绑定时,props.data 代表父传入的值。
// 需要将其同步到内部的 modelValue,以便 SelectTable 的 v-model:data 能正确反向绑定。
watch(() => props.data, (newVal) => {
// 仅当内部值与外部值不一致时进行同步,避免不必要覆盖用户交互时的临时值。
if (newVal !== modelValue.value) {
modelValue.value = newVal ?? '';
}
});
const getYqConfig = () => { const getYqConfig = () => {
getGroupInstrdList() const data = {
lisgroup: props.instrGroup
}
getGroupInstrdList(data)
.then((res: any) => { .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) => ({
@ -53,48 +53,16 @@ const getYqConfig = () => {
} }
const getDataValue = (val: any) => { const getDataValue = (val: any) => {
emits('update:data', val.yq);
emits('getDataValue', val); emits('getDataValue', val);
}; };
const handleDataEcho = (val: any) => {
// if (modelValue.value === null || modelValue.value === undefined) {
// modelValue.value = '';
// emits('update:data', null);
// return;
// }
// const matchedInstr = instrOptions.value.find(item => item.yq === modelValue.value);
// if (matchedInstr) {
// emits('update:data', matchedInstr.yq);
// } else {
// emits('update:data', '');
// }
emits('update:data', val);
};
// 监听表格数据和字典类型变化
watch(() => instrOptions, (newVal) => {
if (newVal) {
handleDataEcho(newVal);
}
}, { deep: true });
// 监听绑定值数据变化,重新处理
watch(() => modelValue, (newVal) => {
if (newVal) {
// 数据回显
handleDataEcho(newVal);
}
}, { deep: true });
onMounted(() => { onMounted(() => {
getYqConfig();
// 初始化时同步一次父级值(如果有)到内部 modelValue // 初始化时同步一次父级值(如果有)到内部 modelValue
if (props.data !== undefined && props.data !== null) { if (props.data !== undefined && props.data !== null) {
modelValue.value = props.data as any; modelValue.value = props.data as any;
} }
getYqConfig();
}); });

View File

@ -58,15 +58,17 @@
</ContextMenu> </ContextMenu>
<el-dialog v-model="show" title="标准结果作为某标本复查结果" width="300" :close-on-click-modal="false" :draggable="true" <el-dialog v-model="show" title="操作" width="300" :close-on-click-modal="false" :draggable="true"
@close="closeHandle"> @close="closeHandle">
<div> <div class="form-box">
仪器: <div class="item">
<yqSelectTable v-model:data="tableKey.yq" width="200px" /> <span>仪器:</span>
<div>请输入复查的样本号:</div> <yqSelectTable v-model:data="tableKey.yq" :instrGroup="tableKey.instrGroup" />
</div>
<div class="mt10">请输入复查的样本号:</div>
<el-input v-model="fcYbh" /> <el-input v-model="fcYbh" />
</div> </div>
<div style="text-align: center; width: 100%;"> <div class="mt10" style="text-align: center; width: 100%;">
<el-button type="primary" @click="subHandle()"> 确认 </el-button> <el-button type="primary" @click="subHandle()"> 确认 </el-button>
<el-button @click="closeHandle">取消</el-button> <el-button @click="closeHandle">取消</el-button>
</div> </div>
@ -80,6 +82,7 @@ import CommonTable from '@/components/vxeTable/index.vue'
import ContextMenu from "@/components/contextMenu/index.vue"; import ContextMenu from "@/components/contextMenu/index.vue";
import { ContextMenuItem } from '@/types/index' import { ContextMenuItem } from '@/types/index'
import yqSelectTable from '@/components/SelectTable/YQSelectTable/index.vue' import yqSelectTable from '@/components/SelectTable/YQSelectTable/index.vue'
import { ElMessage } from 'element-plus';
const props = defineProps({ const props = defineProps({
labPatList: { labPatList: {
type: Array, type: Array,
@ -104,8 +107,15 @@ const show = ref(false)
const fcYbh = ref('') const fcYbh = ref('')
const subHandle = () => { const subHandle = () => {
if (!fcYbh.value.trim()) return ElMessage.warning('请输入复查的样本号')
const data = {
fcYbh: fcYbh.value,
...props.tableKey
}
console.log('data==>', data);
} }
const closeHandle = () => { const closeHandle = () => {
fcYbh.value = ''
show.value = false show.value = false
} }
@ -113,7 +123,6 @@ const contextMenuItems = computed<ContextMenuItem[]>(() => [
{ label: '标准结果作为某标本复查结果', action: 'view' } { label: '标准结果作为某标本复查结果', action: 'view' }
]); ]);
const handleMenuSelect = ((item: ContextMenuItem) => { const handleMenuSelect = ((item: ContextMenuItem) => {
console.log('item==>', item);
show.value = true show.value = true
}) })
// 表格列配置 // 表格列配置
@ -214,5 +223,21 @@ defineExpose({
<style lang="scss" scoped> <style lang="scss" scoped>
.table-container { .table-container {
height: 76vh; height: 76vh;
.form-box {
font-family: SourceHanSansCN, SourceHanSansCN;
.item {
display: flex;
align-items: center;
span {
display: inline-block;
width: 3.75rem;
}
}
}
} }
</style> </style>