检验项目设置-检验类型功能完成

This commit is contained in:
2025-12-22 16:28:05 +08:00
parent 0bfa7183f9
commit 91d673de77
3 changed files with 72 additions and 31 deletions

View File

@@ -35,6 +35,11 @@
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>

View File

@@ -43,6 +43,11 @@
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -26,21 +26,17 @@
新增 新增
</button> </button>
</div> </div>
<div class="table-container"> <div class="table-container" @click="handleTableClick">
<!-- 调试按钮 --> <table class="data-table data-table-type">
<div style="margin-bottom: 10px;">
<el-button @click="debugDepartments">调试科室数据</el-button>
</div>
<table class="data-table">
<thead> <thead>
<tr> <tr>
<th></th> <th style="width: 50px;"></th>
<th>*大类编码</th> <th style="width: 130px;">*大类编码</th>
<th>*大类项目名称</th> <th style="width: 200px;">*大类项目名称</th>
<th>*执行科室</th> <th style="width: 160px;">*执行科室</th>
<th>序号</th> <th style="width: 120px;">序号</th>
<th>备注</th> <th style="width: 160px;">备注</th>
<th>操作</th> <th style="width: 200px; text-align: left; padding-left: 60px;">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -864,18 +860,6 @@ function handlePackageDepartmentChange(selectedNode) {
} }
} }
// 调试科室数据
function debugDepartments() {
console.log('当前科室数据:', departments.value);
console.log('第一个检验项目科室:', inspectionItems.value[0]?.department);
// 尝试模拟选择一个科室
if (departments.value && departments.value.length > 0) {
const firstDept = departments.value[0];
console.log('尝试选择科室:', firstDept.name);
inspectionItems.value[0].department = firstDept.name;
}
}
// 费用套餐数据 // 费用套餐数据
const feePackages = ref([ const feePackages = ref([
{ value: '肝功能12项', label: '肝功能12项', amount: 120.00 }, { value: '肝功能12项', label: '肝功能12项', amount: 120.00 },
@@ -1294,6 +1278,30 @@ const handleSelectPackage = (item) => {
}; };
// 检验类型相关方法 // 检验类型相关方法
// 处理表格点击事件,用于自动删除空的编辑行
const handleTableClick = (event) => {
// 如果点击的是表格内部的元素,不处理
if (event.target.closest('input, select, button, .action-btn')) {
return;
}
// 如果当前有正在编辑的行,检查是否为空
if (editingRowId.value) {
const editingRow = tableData.value.find(row => row.id === editingRowId.value);
if (editingRow && (!editingRow.code || editingRow.code.trim() === '') &&
(!editingRow.name || editingRow.name.trim() === '') &&
(!editingRow.department || editingRow.department.trim() === '')) {
// 删除空的编辑行
const index = tableData.value.findIndex(row => row.id === editingRowId.value);
if (index !== -1) {
tableData.value.splice(index, 1);
editingRowId.value = null;
ElMessage.info('已自动删除空行');
}
}
}
};
const addNewRow = () => { const addNewRow = () => {
if (editingRowId.value) { if (editingRowId.value) {
ElMessage.warning('请先保存或取消当前正在编辑的行'); ElMessage.warning('请先保存或取消当前正在编辑的行');
@@ -1323,19 +1331,37 @@ const handleConfirm = (row) => {
console.log('原始row数据:', row); console.log('原始row数据:', row);
console.log('提交前的submitData:', submitData); console.log('提交前的submitData:', submitData);
// 验证必填字段 // 验证必填字段,如果为空则删除该行
if (!submitData.code || submitData.code.trim() === '') { if (!submitData.code || submitData.code.trim() === '') {
alert('检验类型编码不能为空'); // 删除空的编辑行
const index = tableData.value.findIndex(r => r.id === row.id);
if (index !== -1) {
tableData.value.splice(index, 1);
editingRowId.value = null;
ElMessage.info('已删除空行');
}
return; return;
} }
if (!submitData.name || submitData.name.trim() === '') { if (!submitData.name || submitData.name.trim() === '') {
alert('检验类型名称不能为空'); // 删除空的编辑行
const index = tableData.value.findIndex(r => r.id === row.id);
if (index !== -1) {
tableData.value.splice(index, 1);
editingRowId.value = null;
ElMessage.info('已删除空行');
}
return; return;
} }
if (!submitData.department || submitData.department.trim() === '') { if (!submitData.department || submitData.department.trim() === '') {
alert('执行科室不能为空'); // 删除空的编辑行
const index = tableData.value.findIndex(r => r.id === row.id);
if (index !== -1) {
tableData.value.splice(index, 1);
editingRowId.value = null;
ElMessage.info('已删除空行');
}
return; return;
} }
@@ -1886,6 +1912,11 @@ watch(packageItems, (newVal) => {
z-index: 10; z-index: 10;
} }
.data-table-type .action-cell {
justify-content: flex-start;
padding-left: 24px;
}
.action-btn { .action-btn {
width: 28px; width: 28px;
height: 28px; height: 28px;