复查结果更换
This commit is contained in:
parent
007ead7a1d
commit
afd7aa5f7c
@ -330,5 +330,13 @@ export function clinicInfo(query?: Object) {
|
||||
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);
|
||||
};
|
||||
|
||||
watch(() => props.data, (val) => {
|
||||
modelValue.value = val;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化时同步一次父级值(如果有)到内部 modelValue
|
||||
if (props.data !== undefined && props.data !== null) {
|
||||
|
||||
@ -74,10 +74,8 @@ const handleItemClick = (item: ContextMenuItem) => {
|
||||
|
||||
// 隐藏菜单
|
||||
const hideMenu = () => {
|
||||
if (visible.value) {
|
||||
visible.value = false;
|
||||
emit('close');
|
||||
}
|
||||
visible.value = false;
|
||||
emit('close');
|
||||
};
|
||||
|
||||
// 点击外部区域关闭菜单
|
||||
@ -87,11 +85,12 @@ const handleClickOutside = (e: MouseEvent) => {
|
||||
|
||||
// 键盘事件处理
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (!visible.value) return;
|
||||
// console.log('e==>', e);
|
||||
if (e.key === 'Escape') {
|
||||
hideMenu();
|
||||
}
|
||||
if (e.key === 'e' && visible.value) {
|
||||
if (e.key === 'e') {
|
||||
console.log('e==>', e);
|
||||
}
|
||||
|
||||
|
||||
@ -331,6 +331,10 @@ const setCurrentRow = (row: Object) => {
|
||||
tableRef.value?.setCurrentRow(row);
|
||||
};
|
||||
|
||||
const setScrollTop = (top: number) => {
|
||||
tableRef.value?.setScrollTop(top);
|
||||
};
|
||||
|
||||
const clearSort = () => {
|
||||
tableRef.value?.clearSort();
|
||||
};
|
||||
@ -349,6 +353,7 @@ defineExpose({
|
||||
toggleRowSelection,
|
||||
toggleAllSelection,
|
||||
setCurrentRow,
|
||||
setScrollTop,
|
||||
clearSort,
|
||||
doLayout,
|
||||
sort,
|
||||
|
||||
@ -1,19 +1,5 @@
|
||||
<template>
|
||||
<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"
|
||||
@close="handleDialogClose">
|
||||
@ -31,55 +17,52 @@
|
||||
|
||||
<script setup>
|
||||
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'; // 引入拼音处理工具
|
||||
// 组件参数
|
||||
const props = defineProps({
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
dictType: { type: String, required: true },
|
||||
dictType: { type: String },
|
||||
placeholder: { type: String, default: '请输入或双击选择' },
|
||||
clearable: { type: Boolean, default: true },
|
||||
disabled: { type: Boolean, default: false },
|
||||
fetchDict: { type: Function, required: true },
|
||||
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 filteredDictData = ref([]);
|
||||
const isDictLoading = ref(false);
|
||||
const dialogVisible = ref(false);
|
||||
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 () => {
|
||||
try {
|
||||
|
||||
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 => ({
|
||||
...item,
|
||||
@ -117,12 +100,7 @@ const filterDictData = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 双击事件处理
|
||||
const handleDblClick = () => {
|
||||
if (!props.disabled && !isDictLoading.value) {
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
// 关键修改:打开弹窗时重新加载数据
|
||||
const openDictSelector = async () => {
|
||||
if (props.disabled || isDictLoading.value) {
|
||||
@ -141,39 +119,18 @@ const openDictSelector = async () => {
|
||||
|
||||
// 选择字典项
|
||||
const selectItem = (item) => {
|
||||
emit('update:modelValue', item.value);
|
||||
emit('update:labelValue', item.label);
|
||||
emit('select', item);
|
||||
tempValue.value = item.value;
|
||||
labelValue.value = item.label;
|
||||
dialogVisible.value = false;
|
||||
};
|
||||
|
||||
// 其他方法(失焦、清空等)保持不变
|
||||
const handleBlur = () => { /* ... */
|
||||
};
|
||||
const handleClear = () => { /* ... */
|
||||
};
|
||||
|
||||
const handleDialogClose = () => {
|
||||
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({
|
||||
openDictSelector, // 暴露打开弹窗的方法
|
||||
// 可选:暴露其他可能需要的方法(如刷新字典数据)
|
||||
@ -63,10 +63,10 @@
|
||||
<div class="form-box">
|
||||
<div class="item">
|
||||
<span>仪器:</span>
|
||||
<yqSelectTable v-model:data="tableKey.yq" :instrGroup="tableKey.instrGroup" />
|
||||
<yqSelectTable v-model:data="fcYq" :instrGroup="tableKey.instrGroup" />
|
||||
</div>
|
||||
<div class="mt10">请输入复查的样本号:</div>
|
||||
<el-input v-model="fcYbh" />
|
||||
<el-input v-model="fcYbh" @keyup.enter="subHandle()" />
|
||||
</div>
|
||||
<div class="mt10" style="text-align: center; width: 100%;">
|
||||
<el-button type="primary" @click="subHandle()"> 确认 </el-button>
|
||||
@ -77,11 +77,12 @@
|
||||
</template>
|
||||
|
||||
<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 ContextMenu from "@/components/contextMenu/index.vue";
|
||||
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';
|
||||
const props = defineProps({
|
||||
labPatList: {
|
||||
@ -106,13 +107,21 @@ const emits = defineEmits(['select'])
|
||||
const show = ref(false)
|
||||
|
||||
const fcYbh = ref('')
|
||||
const fcYq = ref('')
|
||||
|
||||
const subHandle = () => {
|
||||
if (!fcYbh.value.trim()) return ElMessage.warning('请输入复查的样本号')
|
||||
const data = {
|
||||
fcYbh: fcYbh.value,
|
||||
newybh: fcYbh.value,
|
||||
newyq: fcYq.value,
|
||||
...props.tableKey
|
||||
}
|
||||
console.log('data==>', data);
|
||||
setredoSample(data).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
ElMessage.success('操作成功')
|
||||
closeHandle()
|
||||
}
|
||||
})
|
||||
}
|
||||
const closeHandle = () => {
|
||||
fcYbh.value = ''
|
||||
@ -124,6 +133,7 @@ const contextMenuItems = computed<ContextMenuItem[]>(() => [
|
||||
]);
|
||||
const handleMenuSelect = ((item: ContextMenuItem) => {
|
||||
show.value = true
|
||||
fcYq.value = props.tableKey.yq
|
||||
})
|
||||
// 表格列配置
|
||||
const tableColumns = ref([
|
||||
|
||||
@ -73,9 +73,7 @@
|
||||
label="qz" />
|
||||
|
||||
<!-- 新增明细 -->
|
||||
<ItemInput ref="itemDictRef" v-model="selectedItemValue" :label-value.sync="selectedItemLabel"
|
||||
: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" />
|
||||
<ProjectDetails ref="itemDictRef" :dialog-title="'选择检验项目'" :tableKey="tableKey" @select="handleItemSelect" />
|
||||
|
||||
<!-- 校验用户 -->
|
||||
<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
|
||||
} from "@/api/liswork/work/LisWork";
|
||||
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 { classCom } from '@/utils/classCom'
|
||||
import CustomTable from '@/components/elTable/index.vue'
|
||||
@ -261,13 +259,12 @@ const contextMenuItems = computed(() => [
|
||||
|
||||
// 处理菜单选择
|
||||
const handleMenuSelect = (item) => {
|
||||
// 根据不同的操作执行相应逻辑
|
||||
switch (item.action) {
|
||||
case 'view':
|
||||
alert(`打印预览`);
|
||||
printHandle() //打印预览
|
||||
break;
|
||||
case 'bgyl':
|
||||
alert(`PDF报告预览`);
|
||||
previewHandle() //PDF报告预览
|
||||
break;
|
||||
case 'merge':
|
||||
alert(`合并病人当前其他结果`);
|
||||
@ -413,39 +410,8 @@ const rules = ref(
|
||||
const csjgRef = ref();
|
||||
|
||||
const itemDictRef = ref(); // DictInput组件引用
|
||||
const selectedItemValue = ref(""); // 选择的项目编码xmdh
|
||||
const selectedItemLabel = ref(""); // 选择的项目名称xmmc
|
||||
const labResuts = 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) => {
|
||||
@ -579,11 +545,7 @@ const resetForm = () => {
|
||||
};
|
||||
// 2. 打开项目选择弹窗
|
||||
const openItemDictDialog = () => {
|
||||
if (itemDictRef.value && typeof itemDictRef.value.openDictSelector === 'function') {
|
||||
itemDictRef.value.openDictSelector(); // 确保方法存在再调用
|
||||
} else {
|
||||
console.warn("DictInput组件未加载完成或方法未暴露");
|
||||
}
|
||||
itemDictRef.value.openDictSelector();
|
||||
};
|
||||
|
||||
// 3. 处理项目选择结果:传递给labresult子组件新增行
|
||||
@ -605,6 +567,31 @@ const handleItemSelect = async (selectedItem) => {
|
||||
// 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([
|
||||
'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 UCKDictInput from './components/DictInput.vue';
|
||||
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);
|
||||
|
||||
@ -99,7 +99,7 @@
|
||||
</template>
|
||||
<!-- 结果复查 -->
|
||||
<template v-if="activeTab == 4">
|
||||
<Reexamination :queryParams="queryParams" @fetchResults="fetchLabResults" />
|
||||
<Reexamination :queryParams="queryParams" @fetchResults="fetchLabResults" :tablekey="queryParams" />
|
||||
</template>
|
||||
<!-- 收费信息 -->
|
||||
<template v-if="activeTab == 5">
|
||||
|
||||
@ -19,10 +19,8 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 新增明细 -->
|
||||
<ItemInput ref="itemDictRef" v-model="selectedItemValue" :label-value.sync="selectedItemLabel"
|
||||
: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" />
|
||||
<!-- 新增明细-->
|
||||
<ProjectDetails ref="itemDictRef" :dialog-title="'选择检验项目'" :tableKey="tablekey" @select="handleItemSelect" />
|
||||
</div>
|
||||
</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 { ElMessage } from 'element-plus'
|
||||
// @ts-ignore
|
||||
import ItemInput from '../components/ItemInput.vue'
|
||||
import ProjectDetails from '@/components/projectDetails/index.vue'
|
||||
|
||||
const props = defineProps({
|
||||
// 主键
|
||||
@ -39,6 +37,10 @@ const props = defineProps({
|
||||
type: Object,
|
||||
default: {}
|
||||
},
|
||||
tablekey: {
|
||||
type: Object,
|
||||
default: () => { }
|
||||
}
|
||||
})
|
||||
|
||||
// 解构 props
|
||||
@ -58,51 +60,16 @@ watch(() => queryParams.value, () => {
|
||||
|
||||
const tableRef = ref();
|
||||
const itemDictRef = ref(); // DictInput组件引用
|
||||
const selectedItemValue = ref(""); // 选择的项目编码xmdh
|
||||
const labResuts = ref([])
|
||||
const selectedItemLabel = ref(""); // 选择的项目名称xmmc
|
||||
|
||||
|
||||
|
||||
// 事件定义
|
||||
const emits = defineEmits(['fetchResults',]);
|
||||
|
||||
const openItemDictDialog = () => {
|
||||
if (itemDictRef.value && typeof itemDictRef.value.openDictSelector === 'function') {
|
||||
itemDictRef.value.openDictSelector(); // 确保方法存在再调用
|
||||
} else {
|
||||
console.warn("DictInput组件未加载完成或方法未暴露");
|
||||
}
|
||||
itemDictRef.value.openDictSelector(); // 确保方法存在再调用
|
||||
};
|
||||
|
||||
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) => {
|
||||
// 1. 构造新增行数据
|
||||
@ -123,50 +90,24 @@ const handleItemSelect = async (selectedItem: any) => {
|
||||
};
|
||||
|
||||
const addRowFromDict = async (rowData: any) => {
|
||||
if (!rowData?.xmdh) {
|
||||
ElMessage.error("项目编码不能为空");
|
||||
return;
|
||||
}
|
||||
// 1. 校验输入数据有效性
|
||||
if (!rowData || !rowData.xmdh) {
|
||||
ElMessage.error("新增失败:项目编码不能为空");
|
||||
return false;
|
||||
}
|
||||
if (!rowData.xmdh) return ElMessage.error("新增失败:项目编码不能为空");
|
||||
|
||||
// 2. 检查是否重复添加同一项目(根据xmdh判断)
|
||||
const isDuplicate = tableData.value.some((item: any) => item.xmdh === rowData.xmdh);
|
||||
if (isDuplicate) {
|
||||
ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
|
||||
return;
|
||||
}
|
||||
if (isDuplicate) return ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
|
||||
|
||||
// 3. 补全新增行的必要字段(如无则初始化)
|
||||
const newRow = { ...rowData, csjg: "" };
|
||||
|
||||
// 4. 添加到表格数据
|
||||
tableData.value.push(newRow);
|
||||
|
||||
// 5. 自动聚焦
|
||||
nextTick(() => {
|
||||
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') as NodeListOf<HTMLInputElement>;
|
||||
if (inputs.length > 0) {
|
||||
inputs[inputs.length - 1]?.focus();
|
||||
}
|
||||
});
|
||||
tableRef.value.setScrollTop(23 * tableData.value.length)
|
||||
// 聚焦到新行的输入框
|
||||
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) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user