feat(biz): 添加质检方案下拉选择功能并优化物料管理
This commit is contained in:
parent
a4fab917b0
commit
97008f1d5d
@ -1,33 +1,31 @@
|
||||
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.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.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.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
|
||||
@ -84,12 +82,20 @@ public class InspPlanController {
|
||||
@PreAuthorize("@ss.hasPermission('biz:insp-plan:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportInspPlanExcel(@Valid InspPlanPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -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))
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -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,7 +17,7 @@ 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())
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
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;
|
||||
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 接口
|
||||
@ -52,4 +53,6 @@ public interface InspPlanService {
|
||||
*/
|
||||
PageResult<InspPlanDO> getInspPlanPage(InspPlanPageReqVO pageReqVO);
|
||||
|
||||
List<InspPlanDO> getInspPlanList(String keyWord);
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,3 +43,8 @@ export const deleteInspPlan = async (id: number) => {
|
||||
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 })
|
||||
}
|
||||
|
||||
@ -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,24 +33,22 @@
|
||||
/>
|
||||
</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-select v-model="formData.enabledStatus" placeholder="请选择状态">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="安全库存" prop="safeStock">
|
||||
<el-input-number
|
||||
v-model="formData.safeStock"
|
||||
@ -60,7 +58,16 @@
|
||||
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)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</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) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
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,
|
||||
|
||||
@ -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'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user