feat(biz): 添加质检方案下拉选择功能并优化物料管理

This commit is contained in:
zxy 2026-05-07 16:37:52 +08:00
parent a4fab917b0
commit 97008f1d5d
9 changed files with 290 additions and 224 deletions

View File

@ -1,95 +1,101 @@
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import static com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult.success;
import com.ningxia.yunxi.chemmes.framework.excel.core.util.ExcelUtils;
import com.ningxia.yunxi.chemmes.framework.operatelog.core.annotations.OperateLog;
import static com.ningxia.yunxi.chemmes.framework.operatelog.core.enums.OperateTypeEnum.*;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.*;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
import com.ningxia.yunxi.chemmes.module.biz.service.inspplan.InspPlanService;
@Tag(name = "管理后台 - 质检方案表主")
@RestController
@RequestMapping("/biz/insp-plan")
@Validated
public class InspPlanController {
@Resource
private InspPlanService inspPlanService;
@PostMapping("/create")
@Operation(summary = "创建质检方案表主")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:create')")
public CommonResult<String> createInspPlan(@Valid @RequestBody InspPlanSaveReqVO createReqVO) {
return success(inspPlanService.createInspPlan(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新质检方案表主")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:update')")
public CommonResult<Boolean> updateInspPlan(@Valid @RequestBody InspPlanSaveReqVO updateReqVO) {
inspPlanService.updateInspPlan(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除质检方案表主")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('biz:insp-plan:delete')")
public CommonResult<Boolean> deleteInspPlan(@RequestParam("id") String id) {
inspPlanService.deleteInspPlan(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得质检方案表主")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:query')")
public CommonResult<InspPlanRespVO> getInspPlan(@RequestParam("id") String id) {
InspPlanDO inspPlan = inspPlanService.getInspPlan(id);
return success(BeanUtils.toBean(inspPlan, InspPlanRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得质检方案表主分页")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:query')")
public CommonResult<PageResult<InspPlanRespVO>> getInspPlanPage(@Valid InspPlanPageReqVO pageReqVO) {
PageResult<InspPlanDO> pageResult = inspPlanService.getInspPlanPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, InspPlanRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出质检方案表主 Excel")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:export')")
@OperateLog(type = EXPORT)
public void exportInspPlanExcel(@Valid InspPlanPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<InspPlanDO> list = inspPlanService.getInspPlanPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "质检方案表主.xls", "数据", InspPlanRespVO.class,
BeanUtils.toBean(list, InspPlanRespVO.class));
}
}
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan;
import com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import com.ningxia.yunxi.chemmes.framework.excel.core.util.ExcelUtils;
import com.ningxia.yunxi.chemmes.framework.operatelog.core.annotations.OperateLog;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanRespVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
import com.ningxia.yunxi.chemmes.module.biz.service.inspplan.InspPlanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult.success;
import static com.ningxia.yunxi.chemmes.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Tag(name = "管理后台 - 质检方案表主")
@RestController
@RequestMapping("/biz/insp-plan")
@Validated
public class InspPlanController {
@Resource
private InspPlanService inspPlanService;
@PostMapping("/create")
@Operation(summary = "创建质检方案表主")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:create')")
public CommonResult<String> createInspPlan(@Valid @RequestBody InspPlanSaveReqVO createReqVO) {
return success(inspPlanService.createInspPlan(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新质检方案表主")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:update')")
public CommonResult<Boolean> updateInspPlan(@Valid @RequestBody InspPlanSaveReqVO updateReqVO) {
inspPlanService.updateInspPlan(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除质检方案表主")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('biz:insp-plan:delete')")
public CommonResult<Boolean> deleteInspPlan(@RequestParam("id") String id) {
inspPlanService.deleteInspPlan(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得质检方案表主")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:query')")
public CommonResult<InspPlanRespVO> getInspPlan(@RequestParam("id") String id) {
InspPlanDO inspPlan = inspPlanService.getInspPlan(id);
return success(BeanUtils.toBean(inspPlan, InspPlanRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得质检方案表主分页")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:query')")
public CommonResult<PageResult<InspPlanRespVO>> getInspPlanPage(@Valid InspPlanPageReqVO pageReqVO) {
PageResult<InspPlanDO> pageResult = inspPlanService.getInspPlanPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, InspPlanRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出质检方案表主 Excel")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:export')")
@OperateLog(type = EXPORT)
public void exportInspPlanExcel(@Valid InspPlanPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<InspPlanDO> list = inspPlanService.getInspPlanPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "质检方案表主.xls", "数据", InspPlanRespVO.class,
BeanUtils.toBean(list, InspPlanRespVO.class));
}
// 下拉框
@GetMapping("/dropdown")
@Operation(summary = "获取下拉框选项")
@PreAuthorize("@ss.hasPermission('biz:insp-plan:query')")
public CommonResult<List<InspPlanRespVO>> getInspPlanDropdown(@RequestParam(value = "keyWord", defaultValue = "", required = false) String keyWord) {
return success(BeanUtils.toBean(inspPlanService.getInspPlanList(keyWord), InspPlanRespVO.class));
}
}

View File

@ -14,6 +14,9 @@ import com.ningxia.yunxi.chemmes.framework.excel.core.convert.DictConvert;
@ExcelIgnoreUnannotated
public class MaterialRespVO {
@Schema(description = "编号", example = "1024")
private Integer id;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;

View File

@ -1,13 +1,14 @@
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.inspplan;
import java.util.*;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.*;
import java.util.List;
/**
* 质检方案表主 Mapper
@ -24,4 +25,12 @@ public interface InspPlanMapper extends BaseMapperX<InspPlanDO> {
.orderByDesc(InspPlanDO::getId));
}
}
default List<InspPlanDO> selectList(String keyWord) {
return selectList(new LambdaQueryWrapperX<InspPlanDO>()
.and(StringUtils.isNotBlank(keyWord), wrapper -> wrapper
.like(InspPlanDO::getSchemeName, keyWord)
.or()
.like(InspPlanDO::getSchemeNo, keyWord))
);
}
}

View File

@ -1,13 +1,11 @@
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.material;
import java.util.*;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.material.vo.MaterialPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.material.MaterialDO;
import org.apache.ibatis.annotations.Mapper;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.material.vo.*;
/**
* 物料主数据 Mapper
@ -19,11 +17,11 @@ public interface MaterialMapper extends BaseMapperX<MaterialDO> {
default PageResult<MaterialDO> selectPage(MaterialPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialDO>()
.eqIfPresent(MaterialDO::getMatCode, reqVO.getMatCode())
.likeIfPresent(MaterialDO::getMatCode, reqVO.getMatCode())
.likeIfPresent(MaterialDO::getMatName, reqVO.getMatName())
.eqIfPresent(MaterialDO::getMatType, reqVO.getMatType())
.eqIfPresent(MaterialDO::getEnabledStatus, reqVO.getEnabledStatus())
.orderByDesc(MaterialDO::getId));
}
}
}

View File

@ -1,55 +1,58 @@
package com.ningxia.yunxi.chemmes.module.biz.service.inspplan;
import java.util.*;
import javax.validation.*;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.*;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
/**
* 质检方案表主 Service 接口
*
* @author 管理员
*/
public interface InspPlanService {
/**
* 创建质检方案表主
*
* @param createReqVO 创建信息
* @return 编号
*/
String createInspPlan(@Valid InspPlanSaveReqVO createReqVO);
/**
* 更新质检方案表主
*
* @param updateReqVO 更新信息
*/
void updateInspPlan(@Valid InspPlanSaveReqVO updateReqVO);
/**
* 删除质检方案表主
*
* @param id 编号
*/
void deleteInspPlan(String id);
/**
* 获得质检方案表主
*
* @param id 编号
* @return 质检方案表主
*/
InspPlanDO getInspPlan(String id);
/**
* 获得质检方案表主分页
*
* @param pageReqVO 分页查询
* @return 质检方案表主分页
*/
PageResult<InspPlanDO> getInspPlanPage(InspPlanPageReqVO pageReqVO);
}
package com.ningxia.yunxi.chemmes.module.biz.service.inspplan;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
import javax.validation.Valid;
import java.util.List;
/**
* 质检方案表主 Service 接口
*
* @author 管理员
*/
public interface InspPlanService {
/**
* 创建质检方案表主
*
* @param createReqVO 创建信息
* @return 编号
*/
String createInspPlan(@Valid InspPlanSaveReqVO createReqVO);
/**
* 更新质检方案表主
*
* @param updateReqVO 更新信息
*/
void updateInspPlan(@Valid InspPlanSaveReqVO updateReqVO);
/**
* 删除质检方案表主
*
* @param id 编号
*/
void deleteInspPlan(String id);
/**
* 获得质检方案表主
*
* @param id 编号
* @return 质检方案表主
*/
InspPlanDO getInspPlan(String id);
/**
* 获得质检方案表主分页
*
* @param pageReqVO 分页查询
* @return 质检方案表主分页
*/
PageResult<InspPlanDO> getInspPlanPage(InspPlanPageReqVO pageReqVO);
List<InspPlanDO> getInspPlanList(String keyWord);
}

View File

@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
/**
* 质检方案表主 Service 实现类
@ -65,4 +66,8 @@ public class InspPlanServiceImpl implements InspPlanService {
return inspPlanMapper.selectPage(pageReqVO);
}
@Override
public List<InspPlanDO> getInspPlanList(String keyWord) {
return inspPlanMapper.selectList(keyWord);
}
}

View File

@ -1,45 +1,50 @@
import request from '@/config/axios'
export interface InspPlanVO {
id: string
schemeNo: string
schemeName: string
remark: string
schemeType: number
tiemClass: string
formCode: string
execStandard: string
testNum: number
printCode: string
printName: string
}
// 查询质检方案表主分页
export const getInspPlanPage = async (params) => {
return await request.get({ url: `/biz/insp-plan/page`, params })
}
// 查询质检方案表主详情
export const getInspPlan = async (id: number) => {
return await request.get({ url: `/biz/insp-plan/get?id=` + id })
}
// 新增质检方案表主
export const createInspPlan = async (data: InspPlanVO) => {
return await request.post({ url: `/biz/insp-plan/create`, data })
}
// 修改质检方案表主
export const updateInspPlan = async (data: InspPlanVO) => {
return await request.put({ url: `/biz/insp-plan/update`, data })
}
// 删除质检方案表主
export const deleteInspPlan = async (id: number) => {
return await request.delete({ url: `/biz/insp-plan/delete?id=` + id })
}
// 导出质检方案表主 Excel
export const exportInspPlan = async (params) => {
return await request.download({ url: `/biz/insp-plan/export-excel`, params })
}
import request from '@/config/axios'
export interface InspPlanVO {
id: string
schemeNo: string
schemeName: string
remark: string
schemeType: number
tiemClass: string
formCode: string
execStandard: string
testNum: number
printCode: string
printName: string
}
// 查询质检方案表主分页
export const getInspPlanPage = async (params) => {
return await request.get({ url: `/biz/insp-plan/page`, params })
}
// 查询质检方案表主详情
export const getInspPlan = async (id: number) => {
return await request.get({ url: `/biz/insp-plan/get?id=` + id })
}
// 新增质检方案表主
export const createInspPlan = async (data: InspPlanVO) => {
return await request.post({ url: `/biz/insp-plan/create`, data })
}
// 修改质检方案表主
export const updateInspPlan = async (data: InspPlanVO) => {
return await request.put({ url: `/biz/insp-plan/update`, data })
}
// 删除质检方案表主
export const deleteInspPlan = async (id: number) => {
return await request.delete({ url: `/biz/insp-plan/delete?id=` + id })
}
// 导出质检方案表主 Excel
export const exportInspPlan = async (params) => {
return await request.download({ url: `/biz/insp-plan/export-excel`, params })
}
// 查询质检方案下拉列表
export const getInspPlanDropdown = async (params) => {
return await request.get({ url: `/biz/insp-plan/dropdown`, params })
}

View File

@ -18,7 +18,7 @@
</el-select>
</el-form-item>
<el-form-item label="物料编码" prop="matCode">
<el-input v-model="formData.matCode" placeholder="请输入物料编码" />
<el-input v-model="formData.matCode" placeholder="请输入物料编码" :disabled="formType === 'update'" />
</el-form-item>
<el-form-item label="物料名称" prop="matName">
<el-input v-model="formData.matName" placeholder="请输入物料名称" />
@ -33,14 +33,32 @@
/>
</el-select>
</el-form-item>
<el-form-item label="规格型号" prop="spec">
<el-input v-model="formData.spec" placeholder="请输入规格型号" />
</el-form-item>
<el-form-item label="质检方案" prop="schemeId">
<el-input v-model="formData.schemeId" placeholder="请输入质检方案" />
<el-input
v-model="schemeName"
placeholder="请选择质检方案"
readonly
class="cursor-pointer"
@click="openInspPlanSelect"
/>
</el-form-item>
<el-form-item label="品牌" prop="brand">
<el-input v-model="formData.brand" placeholder="请输入品牌" />
</el-form-item>
<el-form-item label="状态" prop="enabledStatus">
<el-form-item label="安全库存" prop="safeStock">
<el-input-number
v-model="formData.safeStock"
:precision="2"
:min="0"
placeholder="请输入安全库存"
class="!w-full"
/>
</el-form-item>
<el-form-item label="启用状态" prop="enabledStatus">
<el-select v-model="formData.enabledStatus" placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
@ -50,17 +68,6 @@
/>
</el-select>
</el-form-item>
<el-form-item label="安全库存" prop="safeStock">
<el-input-number
v-model="formData.safeStock"
:precision="2"
:min="0"
placeholder="请输入安全库存"
class="!w-full"
/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" :rows="2" />
</el-form-item>
@ -70,18 +77,28 @@
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
<InspPlanSelect ref="inspPlanSelectRef" @confirm="confirmInspPlan" />
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useDialogClose } from '@/composables/useDialogClose'
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import * as MaterialApi from '@/api/biz/material'
import * as InspPlanApi from '@/api/biz/inspplan'
import InspPlanSelect from '@/views/biz/inspplan/InspPlanSelect.vue'
const { t } = useI18n() //
const message = useMessage() //
/** 定义事件 */
const emit = defineEmits(['success', 'close'])
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const schemeName = ref('') //
const inspPlanSelectRef = ref() //
const formData = ref({
id: undefined,
remark: undefined,
@ -138,15 +155,30 @@ const open = async (type: string, id?: number) => {
formLoading.value = true
try {
formData.value = await MaterialApi.getMaterial(id)
//
if (formData.value.schemeId) {
const inspPlan = await InspPlanApi.getInspPlan(formData.value.schemeId)
schemeName.value = inspPlan.schemeName
}
} finally {
formLoading.value = false
}
}
}
/** 打开质检方案选择弹窗 */
const openInspPlanSelect = () => {
inspPlanSelectRef.value.open(formData.value.schemeId)
}
/** 确认选择质检方案 */
const confirmInspPlan = async (inspPlan: any) => {
formData.value.schemeId = inspPlan.id
schemeName.value = inspPlan.schemeName
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
@ -169,8 +201,12 @@ const submitForm = async () => {
}
}
/** 弹窗关闭时通知父组件 */
useDialogClose(dialogVisible, emit)
/** 重置表单 */
const resetForm = () => {
schemeName.value = ''
formData.value = {
id: undefined,
remark: undefined,
@ -187,4 +223,4 @@ const resetForm = () => {
}
formRef.value?.resetFields()
}
</script>
</script>

View File

@ -132,10 +132,11 @@
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<MaterialForm ref="formRef" @success="getList" />
<MaterialForm ref="formRef" @success="getList" @close="handleQuery" />
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import download from '@/utils/download'
import * as MaterialApi from '@/api/biz/material'