复查结果更换
This commit is contained in:
parent
007ead7a1d
commit
afd7aa5f7c
@ -330,5 +330,13 @@ export function clinicInfo(query?: Object) {
|
|||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 指定为某样本复查结果
|
||||||
|
export function setredoSample(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/lisworkoper/setredosample',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,10 @@ const getDataValue = (val: any) => {
|
|||||||
emits('getDataValue', val);
|
emits('getDataValue', val);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(() => props.data, (val) => {
|
||||||
|
modelValue.value = val;
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 初始化时同步一次父级值(如果有)到内部 modelValue
|
// 初始化时同步一次父级值(如果有)到内部 modelValue
|
||||||
if (props.data !== undefined && props.data !== null) {
|
if (props.data !== undefined && props.data !== null) {
|
||||||
|
|||||||
@ -74,10 +74,8 @@ const handleItemClick = (item: ContextMenuItem) => {
|
|||||||
|
|
||||||
// 隐藏菜单
|
// 隐藏菜单
|
||||||
const hideMenu = () => {
|
const hideMenu = () => {
|
||||||
if (visible.value) {
|
visible.value = false;
|
||||||
visible.value = false;
|
emit('close');
|
||||||
emit('close');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击外部区域关闭菜单
|
// 点击外部区域关闭菜单
|
||||||
@ -87,11 +85,12 @@ const handleClickOutside = (e: MouseEvent) => {
|
|||||||
|
|
||||||
// 键盘事件处理
|
// 键盘事件处理
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (!visible.value) return;
|
||||||
// console.log('e==>', e);
|
// console.log('e==>', e);
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
hideMenu();
|
hideMenu();
|
||||||
}
|
}
|
||||||
if (e.key === 'e' && visible.value) {
|
if (e.key === 'e') {
|
||||||
console.log('e==>', e);
|
console.log('e==>', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -331,6 +331,10 @@ const setCurrentRow = (row: Object) => {
|
|||||||
tableRef.value?.setCurrentRow(row);
|
tableRef.value?.setCurrentRow(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setScrollTop = (top: number) => {
|
||||||
|
tableRef.value?.setScrollTop(top);
|
||||||
|
};
|
||||||
|
|
||||||
const clearSort = () => {
|
const clearSort = () => {
|
||||||
tableRef.value?.clearSort();
|
tableRef.value?.clearSort();
|
||||||
};
|
};
|
||||||
@ -349,6 +353,7 @@ defineExpose({
|
|||||||
toggleRowSelection,
|
toggleRowSelection,
|
||||||
toggleAllSelection,
|
toggleAllSelection,
|
||||||
setCurrentRow,
|
setCurrentRow,
|
||||||
|
setScrollTop,
|
||||||
clearSort,
|
clearSort,
|
||||||
doLayout,
|
doLayout,
|
||||||
sort,
|
sort,
|
||||||
|
|||||||
@ -1,19 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dict-input-wrapper">
|
<div class="dict-input-wrapper">
|
||||||
<!-- <el-input v-model="displayValue" :placeholder="placeholder" :clearable="clearable"
|
|
||||||
:disabled="isDictLoading || disabled" @blur="handleBlur" @clear="handleClear" @dblclick="handleDblClick">
|
|
||||||
<template #prefix>
|
|
||||||
<el-icon v-if="isDictLoading" size="16">
|
|
||||||
<Loading />
|
|
||||||
</el-icon>
|
|
||||||
</template>
|
|
||||||
<template #suffix>
|
|
||||||
<el-icon @click="openDictSelector" size="16" class="select-icon">
|
|
||||||
<ArrowDown />
|
|
||||||
</el-icon>
|
|
||||||
</template>
|
|
||||||
</el-input> -->
|
|
||||||
|
|
||||||
<!-- 字典选择弹窗 -->
|
<!-- 字典选择弹窗 -->
|
||||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="30vw" :close-on-click-modal="false" :draggable="true"
|
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="30vw" :close-on-click-modal="false" :draggable="true"
|
||||||
@close="handleDialogClose">
|
@close="handleDialogClose">
|
||||||
@ -31,55 +17,52 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, watch, onMounted } from 'vue';
|
import { ref, computed, watch, onMounted } from 'vue';
|
||||||
import { Loading, ArrowDown } from '@element-plus/icons-vue';
|
import { queryXmInfo } from '@/api/liswork/work/LisWork'
|
||||||
|
|
||||||
import { getFirstLetter } from '@/utils/pinyin.js'; // 引入拼音处理工具
|
import { getFirstLetter } from '@/utils/pinyin.js'; // 引入拼音处理工具
|
||||||
// 组件参数
|
// 组件参数
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: { type: [String, Number], default: '' },
|
modelValue: { type: [String, Number], default: '' },
|
||||||
dictType: { type: String, required: true },
|
dictType: { type: String },
|
||||||
placeholder: { type: String, default: '请输入或双击选择' },
|
placeholder: { type: String, default: '请输入或双击选择' },
|
||||||
clearable: { type: Boolean, default: true },
|
clearable: { type: Boolean, default: true },
|
||||||
disabled: { type: Boolean, default: false },
|
disabled: { type: Boolean, default: false },
|
||||||
fetchDict: { type: Function, required: true },
|
|
||||||
dialogTitle: { type: String, default: '选择字典项' },
|
dialogTitle: { type: String, default: '选择字典项' },
|
||||||
loadOnMount: { type: Boolean, default: true }
|
tableKey: { type: Object, default: () => { } },
|
||||||
});
|
});
|
||||||
|
|
||||||
// 组件事件
|
// 组件事件
|
||||||
const emit = defineEmits(['update:modelValue', 'update:labelValue', 'select']);
|
const emit = defineEmits(['select']);
|
||||||
|
|
||||||
|
|
||||||
// 内部状态
|
|
||||||
const tempValue = ref('');
|
|
||||||
const labelValue = ref('');
|
|
||||||
const dictData = ref([]); // 存储带简拼的字典数据
|
const dictData = ref([]); // 存储带简拼的字典数据
|
||||||
const filteredDictData = ref([]);
|
const filteredDictData = ref([]);
|
||||||
const isDictLoading = ref(false);
|
const isDictLoading = ref(false);
|
||||||
const dialogVisible = ref(false);
|
const dialogVisible = ref(false);
|
||||||
const searchKey = ref('');
|
const searchKey = ref('');
|
||||||
|
|
||||||
// 显示值计算
|
|
||||||
const displayValue = computed({
|
|
||||||
get() {
|
|
||||||
return labelValue.value || tempValue.value || props.modelValue || '';
|
|
||||||
},
|
|
||||||
set(newValue) {
|
|
||||||
tempValue.value = newValue;
|
|
||||||
if (labelValue.value && newValue !== labelValue.value) {
|
|
||||||
labelValue.value = '';
|
|
||||||
emit('update:labelValue', '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 加载字典数据(并添加简拼字段)
|
// 加载字典数据(并添加简拼字段)
|
||||||
const loadDictData = async () => {
|
const loadDictData = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
isDictLoading.value = true;
|
isDictLoading.value = true;
|
||||||
const rawData = await props.fetchDict(props.dictType);
|
const requestParams = {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 1000, // 加载足够多的项目
|
||||||
|
yq: props.tableKey.yq, // 当前选中的仪器
|
||||||
|
};
|
||||||
|
const response = await queryXmInfo(requestParams);
|
||||||
|
|
||||||
|
const rawData = response.data.map((item, index) => {
|
||||||
|
return {
|
||||||
|
value: item.xmdh || `未知编码_${index}`, // 确保value存在
|
||||||
|
label: item.xmmc || `未知名称_${index}`, // 确保label存在
|
||||||
|
dw: item.dw || "",
|
||||||
|
refs: item.refs || "",
|
||||||
|
};
|
||||||
|
});
|
||||||
// 为每个字典项添加简拼字段
|
// 为每个字典项添加简拼字段
|
||||||
dictData.value = (rawData || []).map(item => ({
|
dictData.value = (rawData || []).map(item => ({
|
||||||
...item,
|
...item,
|
||||||
@ -117,12 +100,7 @@ const filterDictData = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 双击事件处理
|
|
||||||
const handleDblClick = () => {
|
|
||||||
if (!props.disabled && !isDictLoading.value) {
|
|
||||||
dialogVisible.value = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// 关键修改:打开弹窗时重新加载数据
|
// 关键修改:打开弹窗时重新加载数据
|
||||||
const openDictSelector = async () => {
|
const openDictSelector = async () => {
|
||||||
if (props.disabled || isDictLoading.value) {
|
if (props.disabled || isDictLoading.value) {
|
||||||
@ -141,39 +119,18 @@ const openDictSelector = async () => {
|
|||||||
|
|
||||||
// 选择字典项
|
// 选择字典项
|
||||||
const selectItem = (item) => {
|
const selectItem = (item) => {
|
||||||
emit('update:modelValue', item.value);
|
|
||||||
emit('update:labelValue', item.label);
|
|
||||||
emit('select', item);
|
emit('select', item);
|
||||||
tempValue.value = item.value;
|
|
||||||
labelValue.value = item.label;
|
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 其他方法(失焦、清空等)保持不变
|
|
||||||
const handleBlur = () => { /* ... */
|
|
||||||
};
|
|
||||||
const handleClear = () => { /* ... */
|
|
||||||
};
|
|
||||||
const handleDialogClose = () => {
|
const handleDialogClose = () => {
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 监听初始值变化
|
|
||||||
watch(() => props.modelValue, (newVal) => {
|
|
||||||
tempValue.value = newVal || '';
|
|
||||||
if (newVal && !isDictLoading.value) {
|
|
||||||
const matched = dictData.value.find(item => String(item.value) === String(newVal));
|
|
||||||
labelValue.value = matched?.label || newVal;
|
|
||||||
emit('update:labelValue', labelValue.value);
|
|
||||||
}
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
// 组件挂载时加载字典
|
|
||||||
onMounted(async () => {
|
|
||||||
if (props.loadOnMount) { // 仅当loadOnMount为true时(默认),才在挂载时加载
|
|
||||||
await loadDictData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDictSelector, // 暴露打开弹窗的方法
|
openDictSelector, // 暴露打开弹窗的方法
|
||||||
// 可选:暴露其他可能需要的方法(如刷新字典数据)
|
// 可选:暴露其他可能需要的方法(如刷新字典数据)
|
||||||
@ -63,10 +63,10 @@
|
|||||||
<div class="form-box">
|
<div class="form-box">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<span>仪器:</span>
|
<span>仪器:</span>
|
||||||
<yqSelectTable v-model:data="tableKey.yq" :instrGroup="tableKey.instrGroup" />
|
<yqSelectTable v-model:data="fcYq" :instrGroup="tableKey.instrGroup" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mt10">请输入复查的样本号:</div>
|
<div class="mt10">请输入复查的样本号:</div>
|
||||||
<el-input v-model="fcYbh" />
|
<el-input v-model="fcYbh" @keyup.enter="subHandle()" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mt10" 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>
|
||||||
@ -77,11 +77,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, nextTick, onMounted } from 'vue'
|
import { ref, nextTick, onMounted, watch } from 'vue'
|
||||||
import CommonTable from '@/components/vxeTable/index.vue'
|
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 { setredoSample } from '@/api/liswork/work/LisWork'
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
labPatList: {
|
labPatList: {
|
||||||
@ -106,13 +107,21 @@ const emits = defineEmits(['select'])
|
|||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
|
|
||||||
const fcYbh = ref('')
|
const fcYbh = ref('')
|
||||||
|
const fcYq = ref('')
|
||||||
|
|
||||||
const subHandle = () => {
|
const subHandle = () => {
|
||||||
if (!fcYbh.value.trim()) return ElMessage.warning('请输入复查的样本号')
|
if (!fcYbh.value.trim()) return ElMessage.warning('请输入复查的样本号')
|
||||||
const data = {
|
const data = {
|
||||||
fcYbh: fcYbh.value,
|
newybh: fcYbh.value,
|
||||||
|
newyq: fcYq.value,
|
||||||
...props.tableKey
|
...props.tableKey
|
||||||
}
|
}
|
||||||
console.log('data==>', data);
|
setredoSample(data).then((res: any) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
ElMessage.success('操作成功')
|
||||||
|
closeHandle()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const closeHandle = () => {
|
const closeHandle = () => {
|
||||||
fcYbh.value = ''
|
fcYbh.value = ''
|
||||||
@ -124,6 +133,7 @@ const contextMenuItems = computed<ContextMenuItem[]>(() => [
|
|||||||
]);
|
]);
|
||||||
const handleMenuSelect = ((item: ContextMenuItem) => {
|
const handleMenuSelect = ((item: ContextMenuItem) => {
|
||||||
show.value = true
|
show.value = true
|
||||||
|
fcYq.value = props.tableKey.yq
|
||||||
})
|
})
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
const tableColumns = ref([
|
const tableColumns = ref([
|
||||||
|
|||||||
@ -73,9 +73,7 @@
|
|||||||
label="qz" />
|
label="qz" />
|
||||||
|
|
||||||
<!-- 新增明细 -->
|
<!-- 新增明细 -->
|
||||||
<ItemInput ref="itemDictRef" v-model="selectedItemValue" :label-value.sync="selectedItemLabel"
|
<ProjectDetails ref="itemDictRef" :dialog-title="'选择检验项目'" :tableKey="tableKey" @select="handleItemSelect" />
|
||||||
:dict-type="'LAB_ITEM'" :fetch-dict="fetchLabItemDict" :dialog-title="'选择检验项目'" :disabled="false"
|
|
||||||
:load-on-mount="false" :table-data.sync="labResuts" class="hidden-dict-input" @select="handleItemSelect" />
|
|
||||||
|
|
||||||
<!-- 校验用户 -->
|
<!-- 校验用户 -->
|
||||||
<el-dialog v-model="checkShow" title="用户身份验证" width="500" :close-on-click-modal="false" :draggable="true"
|
<el-dialog v-model="checkShow" title="用户身份验证" width="500" :close-on-click-modal="false" :draggable="true"
|
||||||
@ -165,7 +163,7 @@ import {
|
|||||||
newresult, queryXmVal, printListwork, getresultchangelog, setinputmdl, saveResult
|
newresult, queryXmVal, printListwork, getresultchangelog, setinputmdl, saveResult
|
||||||
} from "@/api/liswork/work/LisWork";
|
} from "@/api/liswork/work/LisWork";
|
||||||
import { ElMessageBox, ElMessage } from "element-plus";
|
import { ElMessageBox, ElMessage } from "element-plus";
|
||||||
import ItemInput from "@/views/liswork/work/components/ItemInput.vue";
|
import ProjectDetails from "@/components/projectDetails/index.vue";
|
||||||
import projectsJg from "@/components/projectsjg/index.vue"
|
import projectsJg from "@/components/projectsjg/index.vue"
|
||||||
import { classCom } from '@/utils/classCom'
|
import { classCom } from '@/utils/classCom'
|
||||||
import CustomTable from '@/components/elTable/index.vue'
|
import CustomTable from '@/components/elTable/index.vue'
|
||||||
@ -261,13 +259,12 @@ const contextMenuItems = computed(() => [
|
|||||||
|
|
||||||
// 处理菜单选择
|
// 处理菜单选择
|
||||||
const handleMenuSelect = (item) => {
|
const handleMenuSelect = (item) => {
|
||||||
// 根据不同的操作执行相应逻辑
|
|
||||||
switch (item.action) {
|
switch (item.action) {
|
||||||
case 'view':
|
case 'view':
|
||||||
alert(`打印预览`);
|
printHandle() //打印预览
|
||||||
break;
|
break;
|
||||||
case 'bgyl':
|
case 'bgyl':
|
||||||
alert(`PDF报告预览`);
|
previewHandle() //PDF报告预览
|
||||||
break;
|
break;
|
||||||
case 'merge':
|
case 'merge':
|
||||||
alert(`合并病人当前其他结果`);
|
alert(`合并病人当前其他结果`);
|
||||||
@ -413,39 +410,8 @@ const rules = ref(
|
|||||||
const csjgRef = ref();
|
const csjgRef = ref();
|
||||||
|
|
||||||
const itemDictRef = ref(); // DictInput组件引用
|
const itemDictRef = ref(); // DictInput组件引用
|
||||||
const selectedItemValue = ref(""); // 选择的项目编码xmdh
|
|
||||||
const selectedItemLabel = ref(""); // 选择的项目名称xmmc
|
|
||||||
const labResuts = ref([])
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const fetchLabItemDict = async (dictType) => {
|
|
||||||
try {
|
|
||||||
// 1. 验证必要参数(如当前仪器yq)
|
|
||||||
if (!tableKey.value.yq) {
|
|
||||||
ElMessage.error("请先选择仪器");
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const requestParams = {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 1000, // 加载足够多的项目
|
|
||||||
yq: tableKey.value.yq, // 当前选中的仪器
|
|
||||||
};
|
|
||||||
const response = await queryXmInfo(requestParams);
|
|
||||||
|
|
||||||
const formattedData = response.data.map((item, index) => {
|
|
||||||
return {
|
|
||||||
value: item.xmdh || `未知编码_${index}`, // 确保value存在
|
|
||||||
label: item.xmmc || `未知名称_${index}`, // 确保label存在
|
|
||||||
dw: item.dw || "",
|
|
||||||
refs: item.refs || "",
|
|
||||||
};
|
|
||||||
});
|
|
||||||
return formattedData;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`[fetchLabItemDict] 加载失败:`, error.message);
|
|
||||||
return []; // 失败时返回空数组,避免弹窗报错
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const handleCheck = (checkType) => {
|
const handleCheck = (checkType) => {
|
||||||
@ -579,11 +545,7 @@ const resetForm = () => {
|
|||||||
};
|
};
|
||||||
// 2. 打开项目选择弹窗
|
// 2. 打开项目选择弹窗
|
||||||
const openItemDictDialog = () => {
|
const openItemDictDialog = () => {
|
||||||
if (itemDictRef.value && typeof itemDictRef.value.openDictSelector === 'function') {
|
itemDictRef.value.openDictSelector();
|
||||||
itemDictRef.value.openDictSelector(); // 确保方法存在再调用
|
|
||||||
} else {
|
|
||||||
console.warn("DictInput组件未加载完成或方法未暴露");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3. 处理项目选择结果:传递给labresult子组件新增行
|
// 3. 处理项目选择结果:传递给labresult子组件新增行
|
||||||
@ -605,6 +567,31 @@ const handleItemSelect = async (selectedItem) => {
|
|||||||
// ElMessage.success(`已新增项目:${newRow.xmmc}`);
|
// ElMessage.success(`已新增项目:${newRow.xmmc}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 新增行核心方法:接收父组件传递的项目数据
|
||||||
|
const addRowFromDict = async (rowData) => {
|
||||||
|
if (!rowData.xmdh) return ElMessage.error("新增失败:项目编码不能为空");
|
||||||
|
|
||||||
|
const isDuplicate = tableData.value.some(item => item.xmdh === rowData.xmdh);
|
||||||
|
if (isDuplicate) return ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
|
||||||
|
|
||||||
|
const newRow = { ...rowData, csjg: "" };
|
||||||
|
tableData.value.push(newRow);
|
||||||
|
|
||||||
|
// 5. 自动聚焦
|
||||||
|
nextTick(() => {
|
||||||
|
selectedRows.value = [newRow];
|
||||||
|
tableRef.value.setCurrentRow(newRow);
|
||||||
|
tableRef.value.setScrollTop(23 * tableData.value.length)
|
||||||
|
// 聚焦到新行的输入框
|
||||||
|
const inputs = document.querySelectorAll('.full-width-input .el-input__inner');
|
||||||
|
if (inputs.length > 0) {
|
||||||
|
inputs[inputs.length - 1].focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// 事件定义
|
// 事件定义
|
||||||
const emits = defineEmits([
|
const emits = defineEmits([
|
||||||
'fetchLabResults',
|
'fetchLabResults',
|
||||||
@ -708,62 +695,6 @@ const handleAdd = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 新增行核心方法:接收父组件传递的项目数据
|
|
||||||
const addRowFromDict = async (rowData) => {
|
|
||||||
if (!rowData?.xmdh) {
|
|
||||||
ElMessage.error("项目编码不能为空");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 1. 校验输入数据有效性
|
|
||||||
if (!rowData || !rowData.xmdh) {
|
|
||||||
ElMessage.error("新增失败:项目编码不能为空");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 检查是否重复添加同一项目(根据xmdh判断)
|
|
||||||
const isDuplicate = tableData.value.some(item => item.xmdh === rowData.xmdh);
|
|
||||||
if (isDuplicate) {
|
|
||||||
ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 补全新增行的必要字段(如无则初始化)
|
|
||||||
const newRow = { ...rowData, csjg: "" };
|
|
||||||
|
|
||||||
// 4. 添加到表格数据
|
|
||||||
tableData.value.push(newRow);
|
|
||||||
console.log("子组件新增行:", newRow);
|
|
||||||
|
|
||||||
|
|
||||||
// // 4. 同步缓存
|
|
||||||
// await nextTick();
|
|
||||||
// updateOriginalCsjgMap();
|
|
||||||
|
|
||||||
|
|
||||||
// 5. 自动聚焦
|
|
||||||
nextTick(() => {
|
|
||||||
selectedRows.value = [newRow];
|
|
||||||
tableRef.value.setCurrentRow(newRow);
|
|
||||||
nextTick(() => {
|
|
||||||
tableRef.value.setScrollTop(23 * tableRef.value.length)
|
|
||||||
})
|
|
||||||
nextTick(() => {
|
|
||||||
const tableBody = document.querySelector('.el-table__body-wrapper');
|
|
||||||
if (tableBody) {
|
|
||||||
tableBody.scrollTop = tableBody.scrollHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 聚焦到新行的输入框
|
|
||||||
const inputs = document.querySelectorAll('.full-width-input .el-input__inner');
|
|
||||||
if (inputs.length > 0) {
|
|
||||||
inputs[inputs.length - 1].focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -141,7 +141,7 @@ import CheckUser from './components/CheckUser.vue'
|
|||||||
import uploadwarning from './components/uploadwarning.vue'
|
import uploadwarning from './components/uploadwarning.vue'
|
||||||
import UCKDictInput from './components/DictInput.vue';
|
import UCKDictInput from './components/DictInput.vue';
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import ItemInput from "@/views/liswork/work/components/ItemInput.vue";
|
import ItemInput from "@/components/projectDetails/index.vue";
|
||||||
|
|
||||||
|
|
||||||
const showuploadwarning = ref(false);
|
const showuploadwarning = ref(false);
|
||||||
|
|||||||
@ -99,7 +99,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 结果复查 -->
|
<!-- 结果复查 -->
|
||||||
<template v-if="activeTab == 4">
|
<template v-if="activeTab == 4">
|
||||||
<Reexamination :queryParams="queryParams" @fetchResults="fetchLabResults" />
|
<Reexamination :queryParams="queryParams" @fetchResults="fetchLabResults" :tablekey="queryParams" />
|
||||||
</template>
|
</template>
|
||||||
<!-- 收费信息 -->
|
<!-- 收费信息 -->
|
||||||
<template v-if="activeTab == 5">
|
<template v-if="activeTab == 5">
|
||||||
|
|||||||
@ -19,10 +19,8 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<!-- 新增明细 -->
|
<!-- 新增明细-->
|
||||||
<ItemInput ref="itemDictRef" v-model="selectedItemValue" :label-value.sync="selectedItemLabel"
|
<ProjectDetails ref="itemDictRef" :dialog-title="'选择检验项目'" :tableKey="tablekey" @select="handleItemSelect" />
|
||||||
:dict-type="'LAB_ITEM'" :fetch-dict="fetchLabItemDict" :dialog-title="'选择检验项目'" :disabled="false"
|
|
||||||
:load-on-mount="false" :table-data.sync="labResuts" class="hidden-dict-input" @select="handleItemSelect" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -31,7 +29,7 @@ import { ref, watch, toRefs, onMounted, nextTick } from 'vue'
|
|||||||
import { redoResult, queryXmInfo, saveRedo, swapRedo, delRedo } from "@/api/liswork/work/LisWork";
|
import { redoResult, queryXmInfo, saveRedo, swapRedo, delRedo } from "@/api/liswork/work/LisWork";
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import ItemInput from '../components/ItemInput.vue'
|
import ProjectDetails from '@/components/projectDetails/index.vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// 主键
|
// 主键
|
||||||
@ -39,6 +37,10 @@ const props = defineProps({
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: {}
|
default: {}
|
||||||
},
|
},
|
||||||
|
tablekey: {
|
||||||
|
type: Object,
|
||||||
|
default: () => { }
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 解构 props
|
// 解构 props
|
||||||
@ -58,51 +60,16 @@ watch(() => queryParams.value, () => {
|
|||||||
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const itemDictRef = ref(); // DictInput组件引用
|
const itemDictRef = ref(); // DictInput组件引用
|
||||||
const selectedItemValue = ref(""); // 选择的项目编码xmdh
|
|
||||||
const labResuts = ref([])
|
|
||||||
const selectedItemLabel = ref(""); // 选择的项目名称xmmc
|
|
||||||
|
|
||||||
|
|
||||||
// 事件定义
|
// 事件定义
|
||||||
const emits = defineEmits(['fetchResults',]);
|
const emits = defineEmits(['fetchResults',]);
|
||||||
|
|
||||||
const openItemDictDialog = () => {
|
const openItemDictDialog = () => {
|
||||||
if (itemDictRef.value && typeof itemDictRef.value.openDictSelector === 'function') {
|
itemDictRef.value.openDictSelector(); // 确保方法存在再调用
|
||||||
itemDictRef.value.openDictSelector(); // 确保方法存在再调用
|
|
||||||
} else {
|
|
||||||
console.warn("DictInput组件未加载完成或方法未暴露");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchLabItemDict = async (dictType: string) => {
|
|
||||||
try {
|
|
||||||
// 1. 验证必要参数(如当前仪器yq)
|
|
||||||
if (!queryParams.value.yq) {
|
|
||||||
ElMessage.error("请先选择仪器");
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const requestParams = {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 1000, // 加载足够多的项目
|
|
||||||
yq: queryParams.value.yq, // 当前选中的仪器
|
|
||||||
};
|
|
||||||
const response = await queryXmInfo(requestParams);
|
|
||||||
|
|
||||||
const formattedData = response.data.map((item: any, index: number) => {
|
|
||||||
return {
|
|
||||||
value: item.xmdh || `未知编码_${index}`, // 确保value存在
|
|
||||||
label: item.xmmc || `未知名称_${index}`, // 确保label存在
|
|
||||||
dw: item.dw || "",
|
|
||||||
refs: item.refs || "",
|
|
||||||
};
|
|
||||||
});
|
|
||||||
return formattedData;
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error(`[fetchLabItemDict] 加载失败:`, error.message);
|
|
||||||
return []; // 失败时返回空数组,避免弹窗报错
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleItemSelect = async (selectedItem: any) => {
|
const handleItemSelect = async (selectedItem: any) => {
|
||||||
// 1. 构造新增行数据
|
// 1. 构造新增行数据
|
||||||
@ -123,50 +90,24 @@ const handleItemSelect = async (selectedItem: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addRowFromDict = async (rowData: any) => {
|
const addRowFromDict = async (rowData: any) => {
|
||||||
if (!rowData?.xmdh) {
|
if (!rowData.xmdh) return ElMessage.error("新增失败:项目编码不能为空");
|
||||||
ElMessage.error("项目编码不能为空");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 1. 校验输入数据有效性
|
|
||||||
if (!rowData || !rowData.xmdh) {
|
|
||||||
ElMessage.error("新增失败:项目编码不能为空");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 检查是否重复添加同一项目(根据xmdh判断)
|
|
||||||
const isDuplicate = tableData.value.some((item: any) => item.xmdh === rowData.xmdh);
|
const isDuplicate = tableData.value.some((item: any) => item.xmdh === rowData.xmdh);
|
||||||
if (isDuplicate) {
|
if (isDuplicate) return ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
|
||||||
ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 补全新增行的必要字段(如无则初始化)
|
|
||||||
const newRow = { ...rowData, csjg: "" };
|
const newRow = { ...rowData, csjg: "" };
|
||||||
|
|
||||||
// 4. 添加到表格数据
|
|
||||||
tableData.value.push(newRow);
|
tableData.value.push(newRow);
|
||||||
|
|
||||||
// 5. 自动聚焦
|
// 5. 自动聚焦
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
tableRef.value.setCurrentRow(newRow);
|
tableRef.value.setCurrentRow(newRow);
|
||||||
nextTick(() => {
|
tableRef.value.setScrollTop(23 * tableData.value.length)
|
||||||
tableRef.value.setScrollTop(23 * tableRef.value.length)
|
// 聚焦到新行的输入框
|
||||||
})
|
const inputs = document.querySelectorAll('.full-width-input .el-input__inner') as NodeListOf<HTMLInputElement>;
|
||||||
nextTick(() => {
|
if (inputs.length > 0) {
|
||||||
const tableBody = document.querySelector('.el-table__body-wrapper');
|
inputs[inputs.length - 1]?.focus();
|
||||||
if (tableBody) {
|
}
|
||||||
tableBody.scrollTop = tableBody.scrollHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 聚焦到新行的输入框
|
|
||||||
const inputs = document.querySelectorAll('.full-width-input .el-input__inner') as NodeListOf<HTMLInputElement>;
|
|
||||||
if (inputs.length > 0) {
|
|
||||||
inputs[inputs.length - 1]?.focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCsjgEnter = (row: any) => {
|
const handleCsjgEnter = (row: any) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user