维护系统->检查方法前端页面优化、接口功能完善(搜索栏和导出表格未处理),后端接口优化。

This commit is contained in:
qk123
2025-12-03 16:00:24 +08:00
parent 601ae40666
commit b3c27ec789
6 changed files with 242 additions and 145 deletions

View File

@@ -2,7 +2,8 @@ package com.openhis.web.check.appservice;
import com.core.common.core.domain.R;
import com.openhis.web.check.dto.CheckMethodDto;
import com.openhis.check.domain.CheckMethod;
/**
* 检查方法Service接口
@@ -14,11 +15,11 @@ public interface ICheckMethodAppService{
R<?> getCheckMethodList();
R<?> addCheckMethod(CheckMethodDto checkMethodDto);
R<?> addCheckMethod(CheckMethod checkMethod);
R<?> updateCheckMethod(CheckMethodDto checkPartDto);
R<?> updateCheckMethod(CheckMethod checkPart);
R<?> removeCheckMethod(Long code);
R<?> removeCheckMethod(Integer checkMethodId);
}

View File

@@ -28,63 +28,48 @@ public class CheckMethodAppServiceImpl implements ICheckMethodAppService {
}
@Override
public R<?> addCheckMethod(CheckMethodDto checkMethodDto) {
//1.数校验
if(ObjectUtil.isEmpty(checkMethodDto.getName())){
return R.fail("检查方法名称不能为空");
public R<?> addCheckMethod(CheckMethod checkMethod) {
//1.数校验
if (ObjectUtil.isEmpty(checkMethod.getId())) {
return R.fail("检查方法id不能为空");
}
if(ObjectUtil.isEmpty(checkMethodDto.getCheckType())){
return R.fail("检查类型不能为空");
if (ObjectUtil.isEmpty(checkMethod.getName())) {
return R.fail("检查方法名称不能为空");
}
if(ObjectUtil.isEmpty(checkMethodDto.getCode())){
return R.fail("代码不能为空");
if (ObjectUtil.isEmpty(checkMethod.getCode())) {
return R.fail("检查方法代码不能为空");
}
//2.判断是否有重复
LambdaQueryWrapper<CheckMethod> wrapper = new LambdaQueryWrapper<CheckMethod>()
.eq(CheckMethod::getName, checkMethodDto.getName())
.eq(CheckMethod::getCheckType, checkMethodDto.getCheckType())
.eq(CheckMethod::getCode, checkMethodDto.getCode());
if (checkMethodService.getOne(wrapper) != null){
return R.fail("检查方法已存在");
if (ObjectUtil.isEmpty(checkMethod.getCheckType())) {
return R.fail("检查方法的检查类型不能为空!");
}
//3.封装实体检查方法
CheckMethod checkMethod = new CheckMethod();
checkMethod.setName(checkMethodDto.getName());
checkMethod.setCheckType(checkMethodDto.getCheckType());
checkMethod.setCode(checkMethodDto.getCode());
checkMethod.setPackageName(checkMethodDto.getPackageName());
checkMethod.setExposureNum(checkMethodDto.getExposureNum());
checkMethod.setOrderNum(checkMethodDto.getOrderNum());
checkMethod.setRemark(checkMethodDto.getRemark());
//4.保存添加
//2.保存
boolean save = checkMethodService.save(checkMethod);
return R.ok();
}
@Override
public R<?> updateCheckMethod(CheckMethodDto checkMethodDto) {
//1.数校验
if(ObjectUtil.isEmpty(checkMethodDto.getName())){
return R.fail("检查方法名称不能为空");
public R<?> updateCheckMethod(CheckMethod checkMethod) {
//1.数校验
if (ObjectUtil.isEmpty(checkMethod.getId())) {
return R.fail("检查方法id不能为空");
}
if(ObjectUtil.isEmpty(checkMethodDto.getCheckType())){
return R.fail("检查类型不能为空");
if (ObjectUtil.isEmpty(checkMethod.getName())) {
return R.fail("检查方法名称不能为空");
}
if(ObjectUtil.isEmpty(checkMethodDto.getCode())){
return R.fail("代码不能为空");
if (ObjectUtil.isEmpty(checkMethod.getCode())) {
return R.fail("检查方法代码不能为空");
}
//2.
return R.ok();
if (ObjectUtil.isEmpty(checkMethod.getCheckType())) {
return R.fail("检查方法的检查类型不能为空!");
}
//2.更新
boolean b = checkMethodService.updateById(checkMethod);
return R.ok(b);
}
@Override
public R<?> removeCheckMethod(Long code) {
if (ObjectUtil.isEmpty(code)){
return R.fail("检查方法代码不能为空");
}
LambdaQueryWrapper<CheckMethod> wrapper = new LambdaQueryWrapper<CheckMethod>().eq(CheckMethod::getCode, code);
boolean remove = checkMethodService.remove(wrapper);
public R<?> removeCheckMethod(Integer checkMethodId) {
boolean remove = checkMethodService.removeById(checkMethodId);
return R.ok(remove);
}

View File

@@ -1,8 +1,8 @@
package com.openhis.web.check.controller;
import com.core.common.core.domain.R;
import com.openhis.check.domain.CheckMethod;
import com.openhis.web.check.appservice.ICheckMethodAppService;
import com.openhis.web.check.dto.CheckMethodDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -30,17 +30,17 @@ public class CheckMethodController {
* @Param
*/
@PostMapping("/add")
public R<?> addCheckMethod(@RequestBody CheckMethodDto checkMethodDto){
return R.ok(checkMethodAppService.addCheckMethod(checkMethodDto));
public R<?> addCheckMethod(@RequestBody CheckMethod checkMethod){
return R.ok(checkMethodAppService.addCheckMethod(checkMethod));
}
/*
* 删除检查方法
* @Param code代码
*/
@DeleteMapping("/delete/{code}")
public R<?> deleteCheckMethod(@PathVariable Long code){
return R.ok(checkMethodAppService.removeCheckMethod(code));
@DeleteMapping("/delete/{checkMethodId}")
public R<?> deleteCheckMethod(@PathVariable Integer checkMethodId){
return R.ok(checkMethodAppService.removeCheckMethod(checkMethodId));
}
/*
@@ -48,7 +48,7 @@ public class CheckMethodController {
* @Param
*/
@PutMapping("/update")
public R<?> updateCheckMethod(@RequestBody CheckMethodDto checkMethodDto){
return R.ok(checkMethodAppService.updateCheckMethod(checkMethodDto));
public R<?> updateCheckMethod(@RequestBody CheckMethod checkMethod){
return R.ok(checkMethodAppService.updateCheckMethod(checkMethod));
}
}

View File

@@ -26,7 +26,7 @@ public class CheckMethod {
* 检查方法ID
*/
@TableId(type = IdType.AUTO)
private Long id;
private Integer id;
/* 检查类型 */
private String checkType;

View File

@@ -46,12 +46,38 @@ export function delCheckType(checkTypeId) {
// 查询检查方法列表
export function listCheckMethod(query) {
return request({
url: '/system/check-method/list',
url: '/check/method/list',
method: 'get',
params: query
})
}
// 新增检查方法
export function addCheckMethod(data) {
return request({
url: '/check/method/add',
method: 'post',
data: data
})
}
// 修改检查方法
export function updateCheckMethod(data) {
return request({
url: '/check/method/update',
method: 'put',
data: data
})
}
// 删除检查方法
export function delCheckMethod(checkMethodId) {
return request({
url: '/check/method/delete/' + checkMethodId,
method: 'delete'
})
}
// 查询检查部位列表
export function listCheckPart(query) {
return request({

View File

@@ -83,7 +83,7 @@
v-for="(item, index) in tableData"
:key="index"
:class="{ 'editing-row': item.editing, 'child-row': item.row.includes('.') }"
@click="handleRowClick(item)"
@click="handleEdit(index)"
>
<td>{{ item.row }}</td>
<td>
@@ -198,39 +198,37 @@
<template v-else-if="activeMenu === '检查方法'">
<div class="header">
<h1>{{ activeMenu }}管理</h1>
<div class="header-actions">
<button class="btn btn-add-new" @click="handleAddNewRow">+
</button>
</div>
</div>
<div class="search-bar">
<div class="search-item">
<label>检查类型</label>
<el-select v-model="searchParams.checkMethod" placeholder="选择检查方类型" style="width: 150px">
<el-option
v-for="type in checkTypes"
:key="type"
:label="type"
:value="type"
>
</el-option>
</el-select>
</div>
<div class="search-item">
<label>名称</label>
<el-input placeholder="名称/编码" v-model="searchParams.name" />
</div>
<div class="search-item">
<label>费用套餐</label>
<el-select v-model="searchParams.packageId" placeholder="选择使用套餐" style="width: 150px">
<el-option
v-for="pkg in checkPackages"
:key="pkg.id"
:label="pkg.name"
:value="pkg.id"
>
</el-option>
</el-select>
<div class="search-bar search-bar-method">
<div class="search-filters">
<div class="search-item">
<label>检查方法</label>
<el-select v-model="searchParams.checkMethod" placeholder="选择检查方法" style="width: 150px">
<el-option
v-for="type in checkTypes"
:key="type"
:label="type"
:value="type"
>
</el-option>
</el-select>
</div>
<div class="search-item">
<label>名称</label>
<el-input placeholder="名称/编码" v-model="searchParams.name" />
</div>
<div class="search-item">
<label>费用套餐</label>
<el-select v-model="searchParams.packageId" placeholder="选择使用套餐" style="width: 150px">
<el-option
v-for="pkg in checkPackages"
:key="pkg.id"
:label="pkg.name"
:value="pkg.id"
>
</el-option>
</el-select>
</div>
</div>
<div class="search-actions">
<el-button type="primary" :style="{ backgroundColor: hoverAddButton ? '#8a49e0' : '#722ED1', borderColor: hoverAddButton ? '#8a49e0' : '#722ED1' }" @mouseenter="hoverAddButton = true" @mouseleave="hoverAddButton = false" @click="handleAddNewRow">新增</el-button>
@@ -260,7 +258,7 @@
v-for="(item, index) in tableData"
:key="index"
:class="{ 'editing-row': item.editing }"
@click="handleRowClick(item)"
@click=""
>
<td>{{ item.row }}</td>
<td>
@@ -321,6 +319,9 @@
</template>
</td>
<td class="actions">
<button class="btn btn-edit" @click.stop="handleEdit(index)">
</button>
<button class="btn btn-confirm" @click.stop="handleConfirm(index)">
</button>
@@ -338,12 +339,8 @@
<template v-else-if="activeMenu === '检查部位'">
<div class="header">
<h1>{{ activeMenu }}管理</h1>
<div class="header-actions">
<button class="btn btn-add-new" @click="handleAddNewRow">+
</button>
</div>
</div>
<div class="search-bar">
<div class="search-bar search-bar-part">
<div class="search-item">
<label>检查类型</label>
<el-select v-model="searchParams.checkType" placeholder="选择检查类型" style="width: 150px">
@@ -379,12 +376,12 @@
<tr>
<th style="width: 50px;"></th>
<th style="width: 100px;">*编码</th>
<th style="width: 150px;">*名称</th>
<th style="width: 100px;">*名称</th>
<th style="width: 120px;">检查类型</th>
<th style="width: 100px;">曝光次数</th>
<th style="width: 80px;">曝光次数</th>
<th style="width: 120px;">费用套餐</th>
<th style="width: 100px;">金额</th>
<th style="width: 80px;">序号</th>
<th style="width: 80px;">金额</th>
<th style="width: 50px;">序号</th>
<th style="width: 120px;">服务范围</th>
<th style="width: 120px;">下级医技类型</th>
<th style="width: 150px;">备注</th>
@@ -396,7 +393,7 @@
v-for="(item, index) in tableData"
:key="index"
:class="{ 'editing-row': item.editing }"
@click="handleRowClick(item)"
@click=""
>
<td>{{ item.row }}</td>
<td>
@@ -480,6 +477,9 @@
</template>
</td>
<td class="actions">
<button class="btn btn-edit" @click.stop="handleEdit(index)">
</button>
<button class="btn btn-confirm" @click.stop="handleConfirm(index)">
</button>
@@ -504,9 +504,9 @@
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import { getDicts } from '@/api/system/dict/data';
import { listCheckType, listCheckMethod, listCheckPart, listCheckPackage, addCheckType, updateCheckType, delCheckType } from '@/api/system/checkType';
import { listCheckType, listCheckMethod, listCheckPart, listCheckPackage, addCheckType, updateCheckType, delCheckType, addCheckMethod, updateCheckMethod, delCheckMethod } from '@/api/system/checkType';
import PackageSettings from './components/PackageSettings.vue';
import PackageManagement from './components/PackageManagement.vue';
@@ -688,22 +688,45 @@ async function loadMenuData(menu) {
break;
case '检查方法':
const methodResponse = await listCheckMethod();
if (methodResponse && methodResponse.data) {
methodResponse.data.forEach((item, index) => {
tableData.push({
id: item.id, // 保存id字段用于判断是新增还是修改
row: (index + 1).toString(),
code: item.code,
name: item.name,
checkType: item.checkType || '',
packageName: item.packageName || '',
exposureNum: item.exposureNum || 0,
orderNum: item.orderNum || 0,
remark: item.remark || '',
actions: true
try {
const methodResponse = await listCheckMethod();
// 确保data是数组
let dataArray = [];
if (methodResponse) {
if (Array.isArray(methodResponse)) {
// 如果整个响应就是数组
dataArray = methodResponse;
} else if (methodResponse.data && Array.isArray(methodResponse.data)) {
// 如果响应对象的data属性是数组
dataArray = methodResponse.data;
} else if (methodResponse.data && methodResponse.data.data && Array.isArray(methodResponse.data.data)) {
// 如果响应对象的data.data属性是数组可能是后端包装了两层
dataArray = methodResponse.data.data;
}
}
// 处理数组数据
if (dataArray.length > 0) {
dataArray.forEach((item, index) => {
tableData.push({
id: item.id, // 保存id字段用于判断是新增还是修改
row: (index + 1).toString(),
code: item.code,
name: item.name,
checkType: item.checkType || '',
packageName: item.packageName || '',
exposureNum: item.exposureNum || 0,
orderNum: item.orderNum || 0,
remark: item.remark || '',
actions: true
});
});
});
} else {
ElMessage.warning('未获取到检查方法数据');
}
} catch (error) {
ElMessage.error(`加载检查方法数据失败: ${error.message || '未知错误'}`);
}
break;
@@ -750,54 +773,75 @@ async function loadMenuData(menu) {
}
}
// 处理行点击,进入编辑状态
function handleRowClick(item) {
if (!item.editing) {
item.editing = true;
}
// 处理编辑按钮点击
function handleEdit(index) {
const item = tableData[index];
item.editing = true;
}
// 处理确认按钮点击
async function handleConfirm(index) {
const item = tableData[index];
try {
// 根据是否有id判断是新增还是修改
if (item.id) {
// 修改操作
await updateCheckType(item);
// 根据当前激活的菜单调用不同的API
if (activeMenu.value === '检查方法') {
// 检查方法的保存逻辑
if (item.id) {
// 修改操作
await updateCheckMethod(item);
} else {
// 新增操作
const newItem = await addCheckMethod(item);
// 将新增的id赋值给本地数据
item.id = newItem.id;
}
} else {
// 新增操作
const newItem = await addCheckType(item);
// 将新增的id赋值给本地数据
item.id = newItem.id;
// 检查类型的保存逻辑
if (item.id) {
// 修改操作
await updateCheckType(item);
} else {
// 新增操作
const newItem = await addCheckType(item);
// 将新增的id赋值给本地数据
item.id = newItem.id;
}
}
// 退出编辑状态
tableData[index].editing = false;
// 显示保存成功提示
alert(`${item.row} 行数据已保存`);
ElMessage.success(`${item.row} 行数据已保存`);
} catch (error) {
console.error('保存失败:', error);
alert('保存失败,请稍后重试');
ElMessage.error('保存失败,请稍后重试');
}
}
// 处理删除按钮点击
async function handleDelete(index) {
if (confirm('确定要删除这一行吗?')) {
ElMessageBox.confirm('确定要删除这一行吗?', '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
const item = tableData[index];
try {
// 如果有id调用API删除数据库中的数据
if (item.id) {
await delCheckType(item.id);
if (activeMenu.value === '检查方法') {
await delCheckMethod(item.id);
} else {
await delCheckType(item.id);
}
}
// 从数组中删除该行数据
tableData.splice(index, 1);
alert('删除成功!');
ElMessage.success('删除成功!');
} catch (error) {
console.error('删除失败:', error);
alert('删除失败,请稍后重试');
ElMessage.error('删除失败,请稍后重试');
}
}
}).catch(() => {
// 用户取消删除操作
});
}
// 处理添加新行按钮点击
@@ -834,10 +878,10 @@ function handleAddNewRow() {
row: String(maxRowNum + 1),
code: '',
name: '',
type: '',
department: '',
amount: '0.00',
number: '999999',
checkType: '',
packageName: '',
exposureNum: 0,
orderNum: 0,
remark: '',
editing: true, // 新行默认进入编辑状态
isNew: true, // 标记为新增行
@@ -1039,6 +1083,26 @@ select {
gap: 16px;
}
/* 检查方法搜索栏特定样式 */
.search-bar-method {
display: flex;
flex-direction: column;
gap: 16px;
}
.search-bar-method .search-filters {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
}
.search-bar-method .search-actions {
margin-left: auto;
display: flex;
gap: 8px;
}
.search-item {
display: flex;
align-items: center;
@@ -1148,7 +1212,7 @@ th {
font-size: 14px;
font-weight: 500;
line-height: 24px;
text-align: left;
text-align: center;
border-bottom: 1px solid #D9D9D9;
}
@@ -1159,13 +1223,16 @@ td {
font-weight: 400;
line-height: 24px;
border-bottom: 1px solid #e8e8e8;
text-align: center;
}
/* 操作按钮样式 */
.actions {
display: flex;
justify-content: flex-end;
justify-content: center;
gap: 8px;
position: relative;
z-index: 10;
}
.btn {
@@ -1180,6 +1247,18 @@ td {
transition: all 0.2s ease;
font-size: 16px;
font-weight: bold;
position: relative;
z-index: 10;
background-color: #66b1ff;
color: white;
}
.btn-delete {
background-color: #FF4D4F;
color: white;
font-size: 14px;
z-index: 20;
pointer-events: auto;
}
.btn-confirm {
@@ -1187,6 +1266,12 @@ td {
color: white;
}
.btn-edit {
background-color: #FFC107;
color: white;
font-size: 14px;
}
.btn-add {
background-color: #1890FF;
color: white;