Compare commits

..

No commits in common. "007ead7a1df55c364dfd718bd8644a019b25d2e6" and "3417b2fdbc08a4af4ea8bc98e505567c8751f3c1" have entirely different histories.

2 changed files with 68 additions and 61 deletions

View File

@ -1,47 +1,47 @@
<!--仪器组件的封装--> <!--仪器组件的封装-->
<template> <template>
<SelectTable v-model:data="modelValue" :fields="fields" :tableData="instrOptions" label="yqmc" :size="props.size" <SelectTable v-model:data="modelValue" :fields="props.fields" :tableData="instrOptions" label="yqmc" size="small"
value="yq" objKey="yq" :border="true" :width="props.width" placeholder="请选择仪器" :clearable="props.clearable" value="yq" objKey="yq" :border="true" :width="props.width" placeholder="请选择仪器" :clearable="false" @getDataValue="getDataValue" />
@getDataValue="getDataValue" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import SelectTable from '@/components/SelectTable/index.vue'; import SelectTable from '@/components/SelectTable/index.vue';
import { getGroupInstrdList } from '@/api/liswork/work/LisWork'; 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<{ const props = withDefaults(defineProps<Props>(), {
width?: string | number, placeholder: "请选择",
size?: string, size: "default",
clearable?: boolean, isHighlight: true,
instrGroup?: string | number, //部门组代号 value: undefined,
data: string label: undefined,
}>(), { border: false,
width: '100%', width: "100%",
size: 'default', dictType: '',
clearable: false clearable: true,
}) fields: () => [
const instrOptions = ref<Array<{ yq: string; yqmc: string }>>([]);
const fields = ref(
[
{ prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true }, { prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true },
{ prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true }, { prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true },
] ] as Field[]
) });
const instrOptions = ref<Array<{ yq: string; yqmc: string }>>([]);
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 = () => {
const data = { getGroupInstrdList()
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,16 +53,48 @@ 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,17 +58,15 @@
</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 class="form-box"> <div>
<div class="item"> 仪器:
<span>仪器:</span> <yqSelectTable v-model:data="tableKey.yq" width="200px" />
<yqSelectTable v-model:data="tableKey.yq" :instrGroup="tableKey.instrGroup" /> <div>请输入复查的样本号:</div>
</div>
<div class="mt10">请输入复查的样本号:</div>
<el-input v-model="fcYbh" /> <el-input v-model="fcYbh" />
</div> </div>
<div class="mt10" style="text-align: center; width: 100%;"> <div 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>
@ -82,7 +80,6 @@ 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,
@ -107,15 +104,8 @@ 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
} }
@ -123,6 +113,7 @@ 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
}) })
// 表格列配置 // 表格列配置
@ -223,21 +214,5 @@ 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>