Merge branch 'main' of http://47.97.125.165:8902/jiangs/lis8.0-vue3
This commit is contained in:
commit
8a13951dc8
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -56,6 +56,9 @@ importers:
|
||||
jsencrypt:
|
||||
specifier: 3.3.2
|
||||
version: 3.3.2
|
||||
mitt:
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1
|
||||
nprogress:
|
||||
specifier: 0.2.0
|
||||
version: 0.2.0
|
||||
@ -1918,6 +1921,9 @@ packages:
|
||||
resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
mitt@3.0.1:
|
||||
resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==}
|
||||
|
||||
mixin-deep@1.3.2:
|
||||
resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@ -4608,6 +4614,8 @@ snapshots:
|
||||
|
||||
minipass@7.1.2: {}
|
||||
|
||||
mitt@3.0.1: {}
|
||||
|
||||
mixin-deep@1.3.2:
|
||||
dependencies:
|
||||
for-in: 1.0.2
|
||||
@ -5460,7 +5468,7 @@ snapshots:
|
||||
debug: 4.4.0
|
||||
eslint: 9.27.0
|
||||
eslint-scope: 8.3.0
|
||||
eslint-visitor-keys: 4.2.0
|
||||
eslint-visitor-keys: 4.2.1
|
||||
espree: 10.3.0
|
||||
esquery: 1.6.0
|
||||
lodash: 4.17.21
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
<!--仪器组件的封装-->
|
||||
<template>
|
||||
<SelectTable v-model:data="modelValue" :fields="yqFields" :tableData="instrOptions" label="yqmc" size="small"
|
||||
value="yq" objKey="yq" :border="true" :width="props.width" placeholder="请选择仪器" :clearable="false" @getDataValue="getDataValue" />
|
||||
<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="false" @getDataValue="getDataValue" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import SelectTable from '@/components/SelectTable/index.vue';
|
||||
import { getGroupInstrdList } from '@/api/liswork/work/LisWork';
|
||||
import { Emits, Props } from '@/types';
|
||||
import { Emits,Props,Field } from '@/types';
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
|
||||
const modelValue = ref<string | null>('');
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
placeholder: "请选择",
|
||||
@ -18,17 +21,25 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
border: false,
|
||||
width: "100%",
|
||||
dictType: '',
|
||||
clearable: true
|
||||
clearable: true,
|
||||
fields: () => [
|
||||
{ prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true },
|
||||
{ prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true },
|
||||
] as Field[]
|
||||
});
|
||||
|
||||
const modelValue = ref('');
|
||||
const yqFields = ref([
|
||||
{ prop: 'yq', label: '代号', width: 80, enablePinyinSearch: true },
|
||||
{ prop: 'yqmc', label: '名称', width: 150, enablePinyinSearch: true },
|
||||
]);
|
||||
const instrOptions = ref<{ yq: string; yqmc: string }[]>([])
|
||||
const instrOptions = ref<Array<{ yq: string; yqmc: string }>>([]);
|
||||
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 = () => {
|
||||
getGroupInstrdList()
|
||||
.then((res: any) => {
|
||||
@ -45,7 +56,7 @@ const getDataValue = (val: any) => {
|
||||
emits('getDataValue', val);
|
||||
};
|
||||
|
||||
const handleDataEcho = () => {
|
||||
const handleDataEcho = (val: any) => {
|
||||
// if (modelValue.value === null || modelValue.value === undefined) {
|
||||
// modelValue.value = '';
|
||||
// emits('update:data', null);
|
||||
@ -57,26 +68,33 @@ const handleDataEcho = () => {
|
||||
// } else {
|
||||
// emits('update:data', '');
|
||||
// }
|
||||
emits('update:data', modelValue.value);
|
||||
emits('update:data', val);
|
||||
|
||||
};
|
||||
|
||||
// 监听表格数据和字典类型变化
|
||||
watch(() => instrOptions, (newVal) => {
|
||||
if (newVal) {
|
||||
handleDataEcho();
|
||||
handleDataEcho(newVal);
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
// 监听绑定值数据变化,重新处理
|
||||
watch(() => modelValue, (newVal) => {
|
||||
// 数据回显
|
||||
handleDataEcho();
|
||||
if (newVal) {
|
||||
// 数据回显
|
||||
handleDataEcho(newVal);
|
||||
}
|
||||
|
||||
}, { deep: true });
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getYqConfig();
|
||||
// 初始化时同步一次父级值(如果有)到内部 modelValue
|
||||
if (props.data !== undefined && props.data !== null) {
|
||||
modelValue.value = props.data as any;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!--报告单设定-->
|
||||
<el-form ref="form" :model="formData" label-width="80px" size="small">
|
||||
<el-form ref="form" :model="formData" label-width="80px">
|
||||
<el-form-item label="仪器" prop="yq">
|
||||
<YQSelectTable v-model:data="formData.yq" width="200px" @getDataValue="getList"/>
|
||||
</el-form-item>
|
||||
@ -11,7 +11,7 @@
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<el-table :data="tableData" border width="100%" height="700px" @selection-change="handSelectionChange">
|
||||
<el-table ref="reportTable" :data="tableData" border width="100%" height="700px" @row-click="onRowClick" highlight-current-row>
|
||||
<el-table-column label="仪器" prop="yq" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatInstr(scope.row.yq) }}
|
||||
@ -25,8 +25,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="医疗机构" prop="yljg" align="center"></el-table-column>
|
||||
<el-table-column label="使用类型" prop="type" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.type" placeholder="请选择" class="full-width-input">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.type" placeholder="请选择" class="full-width-input" @change="handleRowChange(scope.row, scope.$index)">
|
||||
<el-option label="默认" value="1"></el-option>
|
||||
<el-option label="参数" value="2"></el-option>
|
||||
<el-option label="根据项目来判断" value="3"></el-option>
|
||||
@ -34,8 +34,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="使用条件" prop="condition" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.condition" placeholder="请输入使用条件" class="full-width-input"></el-input>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.condition" placeholder="请输入使用条件" class="full-width-input" @change="handleRowChange(scope.row, scope.$index)"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -45,10 +45,9 @@
|
||||
import {addReportService,queryReportService,updateReportService,deleteReportService} from '@/api/liswork/xtwh/ReportSetting';
|
||||
import { LabReportInstr } from '@/types/index';
|
||||
import YQSelectTable from '@/components/SelectTable/YQSelectTable/index.vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ElMessage,ElMessageBox } from 'element-plus';
|
||||
import { formatInstr,getYqData } from '@/hooks/lisData/index';
|
||||
|
||||
|
||||
const formData = ref({
|
||||
yq: ''
|
||||
});
|
||||
@ -57,6 +56,11 @@ const tableData = ref<LabReportInstr[]>([]);
|
||||
//选中行的数据
|
||||
const selectedRows = ref<LabReportInstr>();
|
||||
|
||||
//序号最大值
|
||||
const maxXh = computed(() => {
|
||||
return tableData.value.length > 0 ? Math.max(...tableData.value.map(item => item.xh)) : 0;
|
||||
});
|
||||
|
||||
//新增数据
|
||||
const handAdd = () => {
|
||||
if(formData.value.yq === ''){
|
||||
@ -65,7 +69,7 @@ const handAdd = () => {
|
||||
}
|
||||
const newReport: LabReportInstr = {
|
||||
yq: formData.value.yq,
|
||||
xh: tableData.value.length + 1,
|
||||
xh: maxXh.value + 1,
|
||||
bgdh: '',
|
||||
yljg: '1',
|
||||
type: '1',
|
||||
@ -77,26 +81,38 @@ const handAdd = () => {
|
||||
|
||||
//删除数据
|
||||
const handDelete = async () => {
|
||||
const res = await deleteReportService([selectedRows.value?.xh || '']);
|
||||
await ElMessageBox.confirm('是否要删除选中的数据?','Warning',
|
||||
{
|
||||
confirmButtonText: 'OK',
|
||||
cancelButtonText: 'Cancel',
|
||||
type: 'warning',
|
||||
}
|
||||
);
|
||||
await deleteReportService({yq: selectedRows.value?.yq, xh: selectedRows.value?.xh,bgdh: selectedRows.value?.bgdh});
|
||||
ElMessage.success('删除成功');
|
||||
getList();
|
||||
};
|
||||
|
||||
//保存数据
|
||||
const handSave = async () => {
|
||||
let updateReports = tableData.value.filter(item => item.type === '1');
|
||||
if(updateReports.length > 1){
|
||||
ElMessage.error('默认的报告单类型不能有两个,请修改后再保存');
|
||||
return;
|
||||
}
|
||||
updateReports = tableData.value.filter(item => item.type === '2' && item.condition.trim() === '');
|
||||
if(updateReports.length > 0){
|
||||
ElMessage.error('参数类型的使用条件不能为空,请修改后再保存');
|
||||
return;
|
||||
}
|
||||
//过滤数据,只需要新增的数据
|
||||
let newReports = tableData.value.filter(item => item.status === 'new');
|
||||
let res = await addReportService(newReports);
|
||||
console.log('res',res);
|
||||
if(res.code !== '0'){
|
||||
ElMessage.error('保存失败:' + res.message);
|
||||
return;
|
||||
}
|
||||
newReports = tableData.value.filter(item => item.status === 'update');
|
||||
console.log('更新的数据',newReports);
|
||||
res = await updateReportService(newReports);
|
||||
if(res.code !== '0'){
|
||||
ElMessage.error('修改保存失败:' + res.message);
|
||||
return;
|
||||
}
|
||||
ElMessage.success('保存成功');
|
||||
getList();
|
||||
}
|
||||
|
||||
//刷新数据
|
||||
@ -112,11 +128,13 @@ const handleRowChange = (row: LabReportInstr, index: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handSelectionChange = (selection: LabReportInstr[]) => {
|
||||
selectedRows.value = selection[0];
|
||||
const reportTable = ref<any>(null);
|
||||
const onRowClick = (row: LabReportInstr) => {
|
||||
if (reportTable.value) {
|
||||
selectedRows.value = row;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getYqData();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user