维护系统->检查方法、部位条件搜索前后端实现
This commit is contained in:
@@ -3,6 +3,7 @@ package com.openhis.web.check.appservice;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckMethod;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
|
||||
/**
|
||||
@@ -21,5 +22,5 @@ public interface ICheckMethodAppService{
|
||||
|
||||
R<?> removeCheckMethod(Integer checkMethodId);
|
||||
|
||||
|
||||
R<?> searchCheckMethodList(Integer pageNo, Integer pageSize, String checkTpye, String name, String packageName);
|
||||
}
|
||||
|
||||
@@ -11,4 +11,6 @@ public interface ICheckPartAppService {
|
||||
R<?> removeCheckPart(Integer checkPartId);
|
||||
|
||||
R<?> updateCheckPart(CheckPart checkPart);
|
||||
|
||||
R<?> searchCheckPartList(Integer pageNo, Integer pageSize, String checkTpye, String name, String packageName);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.openhis.web.check.appservice.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckMethod;
|
||||
import com.openhis.check.service.ICheckMethodService;
|
||||
import com.openhis.web.check.appservice.ICheckMethodAppService;
|
||||
import com.openhis.web.check.dto.CheckMethodDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -27,6 +25,22 @@ public class CheckMethodAppServiceImpl implements ICheckMethodAppService {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> searchCheckMethodList(Integer pageNo, Integer pageSize, String checkTpye, String name, String packageName) {
|
||||
LambdaQueryWrapper<CheckMethod> wrapper = new LambdaQueryWrapper<>();
|
||||
if (checkTpye != null && ObjectUtil.isNotEmpty(checkTpye)) {
|
||||
wrapper.eq(CheckMethod::getCheckType, checkTpye);
|
||||
}
|
||||
if (name != null && ObjectUtil.isNotEmpty(name)) {
|
||||
wrapper.like(CheckMethod::getName, name);
|
||||
}
|
||||
if (packageName != null && ObjectUtil.isNotEmpty(packageName)) {
|
||||
wrapper.eq(CheckMethod::getPackageName, packageName);
|
||||
}
|
||||
List<CheckMethod> list = checkMethodService.list(wrapper);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addCheckMethod(CheckMethod checkMethod) {
|
||||
//1.数据校验
|
||||
@@ -66,6 +80,4 @@ public class CheckMethodAppServiceImpl implements ICheckMethodAppService {
|
||||
boolean remove = checkMethodService.removeById(checkMethodId);
|
||||
return R.ok(remove);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.openhis.web.check.appservice.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckMethod;
|
||||
import com.openhis.check.domain.CheckPart;
|
||||
import com.openhis.check.service.ICheckPartService;
|
||||
import com.openhis.web.check.appservice.ICheckPartAppService;
|
||||
import com.openhis.web.check.dto.CheckPartDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -23,6 +23,22 @@ public class CheckPartAppServiceImpl implements ICheckPartAppService {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> searchCheckPartList(Integer pageNo, Integer pageSize, String checkTpye, String name, String packageName) {
|
||||
LambdaQueryWrapper<CheckPart> wrapper = new LambdaQueryWrapper<>();
|
||||
if (checkTpye != null && ObjectUtil.isNotEmpty(checkTpye)) {
|
||||
wrapper.eq(CheckPart::getCheckType, checkTpye);
|
||||
}
|
||||
if (name != null && ObjectUtil.isNotEmpty(name)) {
|
||||
wrapper.like(CheckPart::getName, name);
|
||||
}
|
||||
if (packageName != null && ObjectUtil.isNotEmpty(packageName)) {
|
||||
wrapper.eq(CheckPart::getPackageName, packageName);
|
||||
}
|
||||
List<CheckPart> list = checkPartService.list(wrapper);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addCheckPart(CheckPart checkPart) {
|
||||
//数据检验
|
||||
|
||||
@@ -18,13 +18,27 @@ public class CheckMethodController {
|
||||
|
||||
/*
|
||||
* 获取检查方法
|
||||
* @Param检查方法 此处参数注释有问题,完全是按照需求给的图来注释的
|
||||
* @Param 此处参数注释有问题,完全是按照需求给的图来注释的
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<?> getCheckMethodList(){
|
||||
return R.ok(checkMethodAppService.getCheckMethodList());
|
||||
}
|
||||
|
||||
/*
|
||||
* 条件查询检查方法
|
||||
* @Para
|
||||
* */
|
||||
@GetMapping("/search")
|
||||
public R<?> searchCheckMethodList(
|
||||
@RequestParam(required = false) Integer pageNo,
|
||||
@RequestParam(required = false) Integer pageSize,
|
||||
@RequestParam(required = false) String checkTpye,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String packageName) {
|
||||
return R.ok(checkMethodAppService.searchCheckMethodList(pageNo,pageSize,checkTpye,name,packageName));
|
||||
}
|
||||
|
||||
/*
|
||||
* 新增检查方法
|
||||
* @Param
|
||||
|
||||
@@ -24,6 +24,19 @@ public class CheckPartController {
|
||||
return R.ok(checkPartAppService.getCheckPartList());
|
||||
}
|
||||
|
||||
/*
|
||||
* 条件搜索检查部位
|
||||
* @Param
|
||||
* */
|
||||
@GetMapping("/search")
|
||||
public R<?> searchCheckPartList(@RequestParam(required = false) Integer pageNo,
|
||||
@RequestParam(required = false) Integer pageSize,
|
||||
@RequestParam(required = false) String checkTpye,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String packageName){
|
||||
return R.ok(checkPartAppService.searchCheckPartList(pageNo,pageSize,checkTpye,name,packageName));
|
||||
}
|
||||
|
||||
/*
|
||||
* 新增检查部位
|
||||
* @Param
|
||||
|
||||
@@ -52,6 +52,15 @@ export function listCheckMethod(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 搜索检查方法列表
|
||||
export function searchCheckMethod(query) {
|
||||
return request({
|
||||
url: '/check/method/search',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 新增检查方法
|
||||
export function addCheckMethod(data) {
|
||||
return request({
|
||||
@@ -87,6 +96,15 @@ export function listCheckPart(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 搜索检查部位列表
|
||||
export function searchCheckPart(query) {
|
||||
return request({
|
||||
url: '/check/part/search',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 新增检查部位
|
||||
export function addCheckPart(data) {
|
||||
|
||||
@@ -202,8 +202,8 @@
|
||||
<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">
|
||||
<label>检查类型</label>
|
||||
<el-select v-model="searchParamsMethod.checkType" placeholder="选择检查类型" style="width: 150px">
|
||||
<el-option
|
||||
v-for="type in checkTypes"
|
||||
:key="type"
|
||||
@@ -215,16 +215,16 @@
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>名称</label>
|
||||
<el-input placeholder="名称/编码" v-model="searchParams.name" />
|
||||
<el-input placeholder="名称/编码" v-model="searchParamsMethod.name" />
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>费用套餐</label>
|
||||
<el-select v-model="searchParams.packageId" placeholder="选择使用套餐" style="width: 150px">
|
||||
<el-select v-model="searchParamsMethod.packageName" placeholder="选择使用套餐" style="width: 150px">
|
||||
<el-option
|
||||
v-for="pkg in checkPackages"
|
||||
:key="pkg.id"
|
||||
:label="pkg.name"
|
||||
:value="pkg.id"
|
||||
:value="pkg.name"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
@@ -255,7 +255,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(item, index) in tableData"
|
||||
v-for="(item, index) in checkMethodData"
|
||||
:key="index"
|
||||
:class="{ 'editing-row': item.editing }"
|
||||
@click=""
|
||||
@@ -343,7 +343,7 @@
|
||||
<div class="search-bar search-bar-part">
|
||||
<div class="search-item">
|
||||
<label>检查类型</label>
|
||||
<el-select v-model="searchParams.checkType" placeholder="选择检查类型" style="width: 150px">
|
||||
<el-select v-model="searchParamsPart.checkType" placeholder="选择检查类型" style="width: 150px">
|
||||
<el-option
|
||||
v-for="type in checkTypes"
|
||||
:key="type"
|
||||
@@ -355,11 +355,11 @@
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>名称</label>
|
||||
<el-input placeholder="名称/编码" v-model="searchParams.name" />
|
||||
<el-input placeholder="名称/编码" v-model="searchParamsPart.name" />
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>费用套餐</label>
|
||||
<el-input placeholder="费用套餐" v-model="searchParams.packageName" />
|
||||
<el-input placeholder="费用套餐" v-model="searchParamsPart.packageName" />
|
||||
</div>
|
||||
|
||||
<div class="search-actions">
|
||||
@@ -390,7 +390,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(item, index) in tableData"
|
||||
v-for="(item, index) in checkPartData"
|
||||
:key="index"
|
||||
:class="{ 'editing-row': item.editing }"
|
||||
@click=""
|
||||
@@ -503,10 +503,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { getDicts } from '@/api/system/dict/data';
|
||||
import { listCheckType, listCheckMethod, listCheckPart, listCheckPackage, addCheckType, updateCheckType, delCheckType, addCheckMethod, updateCheckMethod, delCheckMethod,addCheckPart, updateCheckPart, delCheckPart } from '@/api/system/checkType';
|
||||
import { listCheckType, listCheckMethod, listCheckPart, listCheckPackage, searchCheckMethod, searchCheckPart, addCheckType, updateCheckType, delCheckType, addCheckMethod, updateCheckMethod, delCheckMethod, addCheckPart, updateCheckPart, delCheckPart } from '@/api/system/checkType';
|
||||
import PackageSettings from './components/PackageSettings.vue';
|
||||
import PackageManagement from './components/PackageManagement.vue';
|
||||
|
||||
@@ -528,19 +528,55 @@ const checkParts = ref([]);
|
||||
const checkPackages = ref([]);
|
||||
const departments = ref([]);
|
||||
|
||||
// 表格数据
|
||||
const tableData = reactive([]);
|
||||
// 表格数据 - 为每个菜单创建独立的数据存储
|
||||
const checkTypeData = reactive([]);
|
||||
const checkMethodData = reactive([]);
|
||||
const checkPartData = reactive([]);
|
||||
const packageData = reactive([]);
|
||||
|
||||
// 搜索条件
|
||||
const searchParams = reactive({
|
||||
checkMethod: '',
|
||||
name: '',
|
||||
packageId: '',
|
||||
packageName: '',
|
||||
// 当前显示的表格数据
|
||||
const tableData = computed(() => {
|
||||
switch(activeMenu.value) {
|
||||
case '检查类型':
|
||||
return checkTypeData;
|
||||
case '检查方法':
|
||||
return checkMethodData;
|
||||
case '检查部位':
|
||||
return checkPartData;
|
||||
case '套餐设置':
|
||||
return packageData;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
// 搜索条件 - 为每个菜单创建独立的搜索参数
|
||||
const searchParamsType = reactive({});
|
||||
const searchParamsMethod = reactive({
|
||||
checkType: '',
|
||||
checkPartCode: '',
|
||||
checkPartName: '',
|
||||
visible: ''
|
||||
name: '',
|
||||
packageName: ''
|
||||
});
|
||||
const searchParamsPart = reactive({
|
||||
checkType: '',
|
||||
name: '',
|
||||
packageName: ''
|
||||
});
|
||||
|
||||
// 获取当前菜单对应的搜索参数
|
||||
const currentSearchParams = computed(() => {
|
||||
switch(activeMenu.value) {
|
||||
case '检查类型':
|
||||
return searchParamsType;
|
||||
case '检查方法':
|
||||
return searchParamsMethod;
|
||||
case '检查部位':
|
||||
return searchParamsPart;
|
||||
case '套餐设置':
|
||||
return searchParamsMethod; // 套餐设置可能共享检查方法的搜索参数
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
});
|
||||
|
||||
// 按钮悬停状态
|
||||
@@ -564,10 +600,10 @@ onMounted(async () => {
|
||||
// 获取所有不重复的检查类型值
|
||||
checkTypes.value = [...new Set(types.map(item => item.type))];
|
||||
|
||||
// 构建表格数据
|
||||
tableData.splice(0, tableData.length);
|
||||
// 构建检查类型表格数据
|
||||
checkTypeData.splice(0, checkTypeData.length);
|
||||
types.forEach((item, index) => {
|
||||
tableData.push({
|
||||
checkTypeData.push({
|
||||
id: item.id, // 保存id字段,用于判断是新增还是修改
|
||||
row: (index + 1).toString(),
|
||||
code: item.code,
|
||||
@@ -669,10 +705,11 @@ function handleSaveSuccess() {
|
||||
// 根据菜单加载对应数据
|
||||
async function loadMenuData(menu) {
|
||||
try {
|
||||
tableData.splice(0, tableData.length);
|
||||
|
||||
switch(menu) {
|
||||
case '检查类型':
|
||||
// 清空检查类型数据
|
||||
checkTypeData.splice(0, checkTypeData.length);
|
||||
|
||||
const typeResponse = await listCheckType();
|
||||
if (typeResponse && typeResponse.data) {
|
||||
// 确保data是数组类型
|
||||
@@ -683,7 +720,7 @@ async function loadMenuData(menu) {
|
||||
|
||||
typeData.forEach((item, index) => {
|
||||
// 直接使用数据库中的department值,不进行转换
|
||||
tableData.push({
|
||||
checkTypeData.push({
|
||||
id: item.id, // 保存id字段,用于判断是新增还是修改
|
||||
row: (index + 1).toString(),
|
||||
code: item.code,
|
||||
@@ -700,28 +737,38 @@ async function loadMenuData(menu) {
|
||||
break;
|
||||
|
||||
case '检查方法':
|
||||
// 清空检查方法数据
|
||||
checkMethodData.splice(0, checkMethodData.length);
|
||||
|
||||
// 构建检查方法的搜索参数
|
||||
const methodParams = {
|
||||
pageNo: 1,
|
||||
pageSize: 100, // 默认获取100条数据,可以根据需要调整
|
||||
checkType: searchParamsMethod.checkType,
|
||||
name: searchParamsMethod.name,
|
||||
packageName: searchParamsMethod.packageName
|
||||
};
|
||||
try {
|
||||
const methodResponse = await listCheckMethod();
|
||||
const methodResponse = await searchCheckMethod(methodParams);
|
||||
|
||||
// 确保data是数组
|
||||
let dataArray = [];
|
||||
// 确保data是数组,适配不同的后端返回格式
|
||||
let methodData = [];
|
||||
if (methodResponse) {
|
||||
if (Array.isArray(methodResponse)) {
|
||||
// 如果整个响应就是数组
|
||||
dataArray = methodResponse;
|
||||
methodData = methodResponse;
|
||||
} else if (methodResponse.data && Array.isArray(methodResponse.data)) {
|
||||
// 如果响应对象的data属性是数组
|
||||
dataArray = methodResponse.data;
|
||||
methodData = methodResponse.data;
|
||||
} else if (methodResponse.data && methodResponse.data.data && Array.isArray(methodResponse.data.data)) {
|
||||
// 如果响应对象的data.data属性是数组(可能是后端包装了两层)
|
||||
dataArray = methodResponse.data.data;
|
||||
methodData = methodResponse.data.data;
|
||||
} else if (methodResponse.data && methodResponse.data.records) {
|
||||
methodData = methodResponse.data.records;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数组数据
|
||||
if (dataArray.length > 0) {
|
||||
dataArray.forEach((item, index) => {
|
||||
tableData.push({
|
||||
if (methodData.length > 0) {
|
||||
methodData.forEach((item, index) => {
|
||||
checkMethodData.push({
|
||||
id: item.id, // 保存id字段,用于判断是新增还是修改
|
||||
row: (index + 1).toString(),
|
||||
code: item.code,
|
||||
@@ -743,36 +790,38 @@ async function loadMenuData(menu) {
|
||||
break;
|
||||
|
||||
case '检查部位':
|
||||
// 清空检查部位数据
|
||||
checkPartData.splice(0, checkPartData.length);
|
||||
|
||||
// 构建检查部位的搜索参数
|
||||
const partSearchParams = {
|
||||
code: searchParams.checkPartCode,
|
||||
name: searchParams.name,
|
||||
checkType: searchParams.checkType,
|
||||
packageName: searchParams.packageName,
|
||||
visible: searchParams.visible
|
||||
const partParams = {
|
||||
pageNo: 1,
|
||||
pageSize: 100, // 默认获取100条数据,可以根据需要调整
|
||||
checkType: searchParamsPart.checkType,
|
||||
name: searchParamsPart.name,
|
||||
packageName: searchParamsPart.packageName
|
||||
};
|
||||
try {
|
||||
const partResponse = await listCheckPart(partSearchParams);
|
||||
const partResponse = await searchCheckPart(partParams);
|
||||
|
||||
// 确保data是数组,适配不同的后端返回格式
|
||||
let partData = [];
|
||||
if (partResponse) {
|
||||
if (Array.isArray(partResponse)) {
|
||||
// 如果整个响应就是数组
|
||||
partData = partResponse;
|
||||
} else if (partResponse.data && Array.isArray(partResponse.data)) {
|
||||
// 如果响应对象的data属性是数组
|
||||
partData = partResponse.data;
|
||||
} else if (partResponse.data && partResponse.data.data && Array.isArray(partResponse.data.data)) {
|
||||
// 如果响应对象的data.data属性是数组(可能是后端包装了两层)
|
||||
partData = partResponse.data.data;
|
||||
} else if (partResponse.data && partResponse.data.records) {
|
||||
partData = partResponse.data.records;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数组数据
|
||||
if (partData.length > 0) {
|
||||
partData.forEach((item, index) => {
|
||||
tableData.push({
|
||||
checkPartData.push({
|
||||
id: item.id, // 保存id字段,用于判断是新增还是修改
|
||||
row: (index + 1).toString(),
|
||||
code: item.code,
|
||||
@@ -1066,29 +1115,153 @@ function handleAdd(index) {
|
||||
}
|
||||
|
||||
// 处理搜索功能
|
||||
function handleSearch() {
|
||||
console.log('搜索条件:', searchParams);
|
||||
// 这里可以根据activeMenu和searchParams实现不同的搜索逻辑
|
||||
ElMessage.info(`正在搜索${activeMenu.value}数据...`);
|
||||
|
||||
// 模拟搜索延迟
|
||||
setTimeout(() => {
|
||||
// 根据activeMenu执行相应的搜索逻辑
|
||||
loadMenuData(activeMenu.value);
|
||||
}, 300);
|
||||
async function handleSearch() {
|
||||
try {
|
||||
console.log('搜索条件:', currentSearchParams.value);
|
||||
// ElMessage.info(`正在搜索${activeMenu.value}数据...`);
|
||||
|
||||
switch(activeMenu.value) {
|
||||
case '检查方法':
|
||||
// 清空检查方法数据
|
||||
checkMethodData.splice(0, checkMethodData.length);
|
||||
|
||||
// 构建检查方法的搜索参数
|
||||
const methodParams = {
|
||||
pageNo: 1,
|
||||
pageSize: 100, // 默认获取100条数据,可以根据需要调整
|
||||
checkType: searchParamsMethod.checkType,
|
||||
name: searchParamsMethod.name,
|
||||
packageName: searchParamsMethod.packageName
|
||||
};
|
||||
|
||||
const methodResponse = await searchCheckMethod(methodParams);
|
||||
|
||||
// 确保data是数组,适配不同的后端返回格式
|
||||
let methodData = [];
|
||||
if (methodResponse) {
|
||||
if (Array.isArray(methodResponse)) {
|
||||
methodData = methodResponse;
|
||||
} else if (methodResponse.data && Array.isArray(methodResponse.data)) {
|
||||
methodData = methodResponse.data;
|
||||
} else if (methodResponse.data && methodResponse.data.data && Array.isArray(methodResponse.data.data)) {
|
||||
methodData = methodResponse.data.data;
|
||||
} else if (methodResponse.data && methodResponse.data.records) {
|
||||
methodData = methodResponse.data.records;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数组数据
|
||||
if (methodData.length > 0) {
|
||||
methodData.forEach((item, index) => {
|
||||
checkMethodData.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
|
||||
});
|
||||
});
|
||||
ElMessage.success(`搜索到${methodData.length}条检查方法数据`);
|
||||
} else {
|
||||
ElMessage.warning('未搜索到检查方法数据');
|
||||
}
|
||||
break;
|
||||
|
||||
case '检查部位':
|
||||
// 清空检查部位数据
|
||||
checkPartData.splice(0, checkPartData.length);
|
||||
|
||||
// 构建检查部位的搜索参数
|
||||
const partParams = {
|
||||
pageNo: 1,
|
||||
pageSize: 100, // 默认获取100条数据,可以根据需要调整
|
||||
checkType: searchParamsPart.checkType,
|
||||
name: searchParamsPart.name,
|
||||
packageName: searchParamsPart.packageName
|
||||
};
|
||||
|
||||
const partResponse = await searchCheckPart(partParams);
|
||||
|
||||
// 确保data是数组,适配不同的后端返回格式
|
||||
let partData = [];
|
||||
if (partResponse) {
|
||||
if (Array.isArray(partResponse)) {
|
||||
partData = partResponse;
|
||||
} else if (partResponse.data && Array.isArray(partResponse.data)) {
|
||||
partData = partResponse.data;
|
||||
} else if (partResponse.data && partResponse.data.data && Array.isArray(partResponse.data.data)) {
|
||||
partData = partResponse.data.data;
|
||||
} else if (partResponse.data && partResponse.data.records) {
|
||||
partData = partResponse.data.records;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数组数据
|
||||
if (partData.length > 0) {
|
||||
partData.forEach((item, index) => {
|
||||
checkPartData.push({
|
||||
id: item.id, // 保存id字段,用于判断是新增还是修改
|
||||
row: (index + 1).toString(),
|
||||
code: item.code,
|
||||
name: item.name,
|
||||
checkType: item.checkType || '',
|
||||
exposureNum: item.exposureNum || 0,
|
||||
packageName: item.packageName || '',
|
||||
price: item.price || 0,
|
||||
number: item.number || '999999',
|
||||
serviceScope: item.serviceScope || '',
|
||||
subType: item.subType || '',
|
||||
remark: item.remark || '',
|
||||
actions: true
|
||||
});
|
||||
});
|
||||
ElMessage.success(`搜索到${partData.length}条检查部位数据`);
|
||||
} else {
|
||||
ElMessage.warning('未搜索到检查部位数据');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// 其他菜单使用原有的加载逻辑
|
||||
await loadMenuData(activeMenu.value);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索失败:', error);
|
||||
ElMessage.error(`搜索${activeMenu.value}数据失败: ${error.message || '未知错误'}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理重置功能
|
||||
function handleReset() {
|
||||
// 重置所有搜索条件
|
||||
searchParams.checkMethod = '';
|
||||
searchParams.name = '';
|
||||
searchParams.packageId = '';
|
||||
searchParams.packageName = '';
|
||||
searchParams.checkType = '';
|
||||
searchParams.checkPartCode = '';
|
||||
searchParams.checkPartName = '';
|
||||
searchParams.visible = '';
|
||||
// 根据当前活动菜单重置对应的搜索条件
|
||||
switch(activeMenu.value) {
|
||||
case '检查类型':
|
||||
for (const key in searchParamsType) {
|
||||
searchParamsType[key] = '';
|
||||
}
|
||||
break;
|
||||
|
||||
case '检查方法':
|
||||
searchParamsMethod.checkType = '';
|
||||
searchParamsMethod.name = '';
|
||||
searchParamsMethod.packageName = '';
|
||||
break;
|
||||
|
||||
case '检查部位':
|
||||
searchParamsPart.checkType = '';
|
||||
searchParamsPart.name = '';
|
||||
searchParamsPart.packageName = '';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ElMessage.info('搜索条件已重置');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user