119 lines
4.0 KiB
Vue
Raw Normal View History

2025-10-21 17:43:57 +08:00
<template>
2025-12-05 17:44:21 +08:00
<!-- 使用仪器 -->
2025-10-31 15:22:51 +08:00
<div>
2025-12-05 17:44:21 +08:00
<div>
<el-button type="primary" @click="onClickAdd">新增</el-button>
<el-button type="primary" @click="onClickDel">删除</el-button>
</div>
<CustomTable ref="tableRef" :data="modelParam.userInstrData" :columns="columns" :enable-column-drag="true"
@column-drag-end="handleColumnDragEnd" :config="tableConfig" @row-click="onRowClick">
<template #yq="{ row }">
2025-12-12 15:49:03 +08:00
<SelectTable v-model:data="row.yq" :fields="yqFields" :tableData="instrOptions" label="yqmc" value="yq"
objKey="yq" :border="true" placeholder="请选择仪器" :clearable="false" class="full-width-input" />
2025-12-05 17:44:21 +08:00
</template>
<template #xs="{ row }">
<el-input v-model="row.xs" class="full-width-input" />
</template>
<template #zkxm="{ row }">
<el-checkbox :checked="row.zkxm === '1'" @change="(val: any) => row.zkxm = val ? 1 : 0" />
</template>
<template #ckxx="{ row }">
<el-input v-model="row.ckxx" class="full-width-input"></el-input>
</template>
<template #cksx="{ row }">
<el-input v-model="row.cksx" class="full-width-input"></el-input>
</template>
<template #dyckz="{ row }">
<el-input :model-value="getDyckz(row)" disabled class="full-width-input"></el-input>
</template>
</CustomTable>
2025-10-31 15:22:51 +08:00
</div>
2025-10-21 17:43:57 +08:00
</template>
2025-10-24 15:37:24 +08:00
<script setup lang="ts">
2025-10-28 16:22:44 +08:00
import CustomTable from '@/components/elTable/index.vue'
2025-11-18 18:12:25 +08:00
import { XmInfoVs } from '@/types';
2025-12-12 15:49:03 +08:00
import SelectTable from '@/components/SelectTable/index.vue'
2025-12-10 18:02:35 +08:00
import { ElMessage, ElMessageBox } from 'element-plus'
2025-12-02 18:14:03 +08:00
import { deleteXmInfoVs } from '@/api/liswork/labItem/labItemApi';
2025-12-12 15:49:03 +08:00
import { instrOptions, getYqData } from '@/hooks'
2025-11-17 17:42:09 +08:00
2025-12-02 18:14:03 +08:00
const modelParam = defineModel<any>()
2025-11-17 17:42:09 +08:00
const tableRef = ref<any>();
2025-10-28 16:22:44 +08:00
const columns = ref([
2025-12-02 18:14:03 +08:00
{ prop: 'vsid', label: '对照编码', visible: false, align: 'center' },
2025-12-08 17:49:43 +08:00
{ prop: 'yq', label: '仪器代号', visible: true, align: 'center', slot: 'yq', width: 200, showOverflowTooltip: false },
{ prop: 'xs', label: '调整系数', visible: true, align: 'center', slot: 'xs', showOverflowTooltip: false },
2025-11-18 18:12:25 +08:00
{ prop: 'zkxm', label: '质控', visible: true, align: 'center', slot: 'zkxm', width: 40 },
2025-12-08 17:49:43 +08:00
{ prop: 'ckxx', label: '参考下限', visible: true, align: 'center', slot: 'ckxx', showOverflowTooltip: false },
{ prop: 'cksx', label: '参考上限', visible: true, align: 'center', slot: 'cksx', showOverflowTooltip: false },
{ prop: 'dyckz', label: '打印参考值', visible: true, align: 'center', slot: 'dyckz', showOverflowTooltip: false },
2025-10-28 16:22:44 +08:00
]);
const tableConfig = ref({
border: true, // 边框
2025-12-08 17:49:43 +08:00
height: '78vh', // 高度
2025-10-28 16:22:44 +08:00
highlightCurrentRow: true, // 高亮当前行
// cellStyle: cellStyleHd
})
2025-12-12 15:49:03 +08:00
const yqFields = ref([
{ prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true },
{ prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true },
])
2025-11-18 18:12:25 +08:00
const selectRow = ref<XmInfoVs>({
yq: '',
xmid: 0
})
2025-10-28 16:22:44 +08:00
2025-12-02 18:14:03 +08:00
const emit = defineEmits(['refreshTabData'])
2025-10-28 16:22:44 +08:00
//退拽属性
2025-11-17 17:42:09 +08:00
const handleColumnDragEnd = (data: any) => {
// 更新列配置
columns.value = data.columns;
}
2025-10-31 15:22:51 +08:00
const handInputChange = () => {
2025-12-05 17:44:21 +08:00
2025-10-31 15:22:51 +08:00
}
2025-11-17 17:42:09 +08:00
const onClickAdd = () => {
2025-11-18 18:12:25 +08:00
const newData: XmInfoVs = {
yq: '',
2025-12-02 18:14:03 +08:00
xmid: modelParam.value.basicData.xmid,
2025-11-18 18:12:25 +08:00
}
2025-12-05 17:44:21 +08:00
modelParam.value.userInstrData.push(newData)
2025-11-17 17:42:09 +08:00
}
2025-12-10 18:02:35 +08:00
const onClickDel = () => {
if (!selectRow.value.vsid) return ElMessage.warning('请选择要删除的行!')
ElMessageBox.confirm('是否要删除选中的数据?', '警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
await deleteXmInfoVs({ vsid: selectRow.value.vsid || 0 })
emit('refreshTabData', modelParam.value.basicData)
})
2025-11-18 18:12:25 +08:00
}
2025-11-17 17:42:09 +08:00
2025-11-18 18:12:25 +08:00
const onRowClick = (row: any) => {
selectRow.value = row
2025-11-17 17:42:09 +08:00
}
2025-10-31 15:22:51 +08:00
2025-12-02 18:14:03 +08:00
const getDyckz = (row: XmInfoVs) => {
2025-12-05 17:44:21 +08:00
if (!row.cksx && !row.ckxx) {
return '';
} else {
2025-12-02 18:14:03 +08:00
return `${row.ckxx || ''}--${row.cksx || ''}`;
}
2025-12-05 17:44:21 +08:00
}
2025-12-12 15:49:03 +08:00
onMounted(async () => {
await getYqData();
console.log('==>', instrOptions);
});
2025-10-21 17:43:57 +08:00
</script>