库区 增加模块页面及接口

库区 增加模块页面及接口
master
siontion 9 months ago
parent 9b9ae5657d
commit 9d08576d0a

@ -35,6 +35,7 @@ public interface ErrorCodeConstants {
/*********库存管理************/
ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_003_001, "仓库不存在");
ErrorCode RG_NOT_EXISTS = new ErrorCode(1_003_002, "库区不存在");
ErrorCode PN_NOT_EXISTS = new ErrorCode(1_003_003, "库位不存在");

@ -0,0 +1,95 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.pn;
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.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO;
import com.chanko.yunxi.mes.module.heli.service.pn.PnService;
@Tag(name = "管理后台 - 库位")
@RestController
@RequestMapping("/heli/pn")
@Validated
public class PnController {
@Resource
private PnService pnService;
@PostMapping("/create")
@Operation(summary = "创建库位")
@PreAuthorize("@ss.hasPermission('heli:pn:create')")
public CommonResult<Long> createPn(@Valid @RequestBody PnSaveReqVO createReqVO) {
return success(pnService.createPn(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新库位")
@PreAuthorize("@ss.hasPermission('heli:pn:update')")
public CommonResult<Boolean> updatePn(@Valid @RequestBody PnSaveReqVO updateReqVO) {
pnService.updatePn(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除库位")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('heli:pn:delete')")
public CommonResult<Boolean> deletePn(@RequestParam("id") Long id) {
pnService.deletePn(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得库位")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('heli:pn:query')")
public CommonResult<PnRespVO> getPn(@RequestParam("id") Long id) {
PnDO pn = pnService.getPn(id);
return success(BeanUtils.toBean(pn, PnRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得库位分页")
@PreAuthorize("@ss.hasPermission('heli:pn:query')")
public CommonResult<PageResult<PnRespVO>> getPnPage(@Valid PnPageReqVO pageReqVO) {
PageResult<PnDO> pageResult = pnService.getPnPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PnRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出库位 Excel")
@PreAuthorize("@ss.hasPermission('heli:pn:export')")
@OperateLog(type = EXPORT)
public void exportPnExcel(@Valid PnPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PnDO> list = pnService.getPnPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "库位.xls", "数据", PnRespVO.class,
BeanUtils.toBean(list, PnRespVO.class));
}
}

@ -0,0 +1,50 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.chanko.yunxi.mes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 库位分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PnPageReqVO extends PageParam {
@Schema(description = "库位编号,唯一")
private String pnNo;
@Schema(description = "库位名称,唯一", example = "王五")
private String pnName;
@Schema(description = "库区 Id对应 wms_rg 表中的Id", example = "8575")
private Long rgId;
@Schema(description = "描述信息")
private String descr;
@Schema(description = "状态,1 表示正常2 表示禁用", example = "2")
private Integer pnStatus;
@Schema(description = "记录的创建人,对应员工表中的 Id")
private String creator;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "记录的修改人,对应员工表中的 Id")
private String updater;
@Schema(description = "更新时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] updateTime;
@Schema(description = "仓库 Id对应 wms_wh 表中的Id", example = "12289")
private Long whId;
}

@ -0,0 +1,52 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import com.chanko.yunxi.mes.framework.excel.core.annotations.DictFormat;
import com.chanko.yunxi.mes.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 库位 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PnRespVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15359")
@ExcelProperty("主键id")
private Long id;
@Schema(description = "库位编号,唯一")
@ExcelProperty("库位编号,唯一")
private String pnNo;
@Schema(description = "库位名称,唯一", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("库位名称,唯一")
private String pnName;
@Schema(description = "库区 Id对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8575")
@ExcelProperty(value = "库区 Id对应 wms_rg 表中的Id", converter = DictConvert.class)
@DictFormat("heli_common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Long rgId;
@Schema(description = "描述信息")
@ExcelProperty("描述信息")
private String descr;
@Schema(description = "状态,1 表示正常2 表示禁用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("状态,1 表示正常2 表示禁用")
private Integer pnStatus;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "仓库 Id对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12289")
@ExcelProperty(value = "仓库 Id对应 wms_wh 表中的Id", converter = DictConvert.class)
@DictFormat("heli_common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Long whId;
}

@ -0,0 +1,38 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.util.*;
@Schema(description = "管理后台 - 库位新增/修改 Request VO")
@Data
public class PnSaveReqVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15359")
private Long id;
@Schema(description = "库位编号,唯一")
private String pnNo;
@Schema(description = "库位名称,唯一", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "库位名称,唯一不能为空")
private String pnName;
@Schema(description = "库区 Id对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8575")
@NotNull(message = "库区 Id对应 wms_rg 表中的Id不能为空")
private Long rgId;
@Schema(description = "描述信息")
private String descr;
@Schema(description = "状态,1 表示正常2 表示禁用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "状态,1 表示正常2 表示禁用不能为空")
private Integer pnStatus;
@Schema(description = "仓库 Id对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12289")
@NotNull(message = "仓库 Id对应 wms_wh 表中的Id不能为空")
private Long whId;
}

@ -0,0 +1,59 @@
package com.chanko.yunxi.mes.module.heli.dal.dataobject.pn;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author
*/
@TableName("wms_pn")
@KeySequence("wms_pn_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PnDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
*
*/
private String pnNo;
/**
*
*/
private String pnName;
/**
* Id wms_rg Id
*
* {@link TODO heli_common_status }
*/
private Long rgId;
/**
*
*/
private String descr;
/**
* ,1 2
*/
private Integer pnStatus;
/**
* Id wms_wh Id
*
* {@link TODO heli_common_status }
*/
private Long whId;
}

@ -0,0 +1,35 @@
package com.chanko.yunxi.mes.module.heli.dal.mysql.pn;
import java.util.*;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO;
import org.apache.ibatis.annotations.Mapper;
import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*;
/**
* Mapper
*
* @author
*/
@Mapper
public interface PnMapper extends BaseMapperX<PnDO> {
default PageResult<PnDO> selectPage(PnPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PnDO>()
.likeIfPresent(PnDO::getPnNo, reqVO.getPnNo())
.likeIfPresent(PnDO::getPnName, reqVO.getPnName())
.eqIfPresent(PnDO::getRgId, reqVO.getRgId())
.eqIfPresent(PnDO::getDescr, reqVO.getDescr())
.eqIfPresent(PnDO::getPnStatus, reqVO.getPnStatus())
.eqIfPresent(PnDO::getCreator, reqVO.getCreator())
.betweenIfPresent(PnDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PnDO::getUpdater, reqVO.getUpdater())
.betweenIfPresent(PnDO::getUpdateTime, reqVO.getUpdateTime())
.eqIfPresent(PnDO::getWhId, reqVO.getWhId())
.orderByDesc(PnDO::getId));
}
}

@ -0,0 +1,55 @@
package com.chanko.yunxi.mes.module.heli.service.pn;
import java.util.*;
import javax.validation.*;
import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
/**
* Service
*
* @author
*/
public interface PnService {
/**
*
*
* @param createReqVO
* @return
*/
Long createPn(@Valid PnSaveReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updatePn(@Valid PnSaveReqVO updateReqVO);
/**
*
*
* @param id
*/
void deletePn(Long id);
/**
*
*
* @param id
* @return
*/
PnDO getPn(Long id);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<PnDO> getPnPage(PnPageReqVO pageReqVO);
}

@ -0,0 +1,74 @@
package com.chanko.yunxi.mes.module.heli.service.pn;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import com.chanko.yunxi.mes.module.heli.dal.mysql.pn.PnMapper;
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
/**
* Service
*
* @author
*/
@Service
@Validated
public class PnServiceImpl implements PnService {
@Resource
private PnMapper pnMapper;
@Override
public Long createPn(PnSaveReqVO createReqVO) {
// 插入
PnDO pn = BeanUtils.toBean(createReqVO, PnDO.class);
pnMapper.insert(pn);
// 返回
return pn.getId();
}
@Override
public void updatePn(PnSaveReqVO updateReqVO) {
// 校验存在
validatePnExists(updateReqVO.getId());
// 更新
PnDO updateObj = BeanUtils.toBean(updateReqVO, PnDO.class);
pnMapper.updateById(updateObj);
}
@Override
public void deletePn(Long id) {
// 校验存在
validatePnExists(id);
// 删除
pnMapper.deleteById(id);
}
private void validatePnExists(Long id) {
if (pnMapper.selectById(id) == null) {
throw exception(PN_NOT_EXISTS);
}
}
@Override
public PnDO getPn(Long id) {
return pnMapper.selectById(id);
}
@Override
public PageResult<PnDO> getPnPage(PnPageReqVO pageReqVO) {
return pnMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chanko.yunxi.mes.module.heli.dal.mysql.pn.PnMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,41 @@
import request from '@/config/axios'
export interface PnVO {
id: number
pnNo: string
pnName: string
rgId: number
descr: string
pnStatus: number
whId: number
}
// 查询库位分页
export const getPnPage = async (params) => {
return await request.get({ url: `/heli/pn/page`, params })
}
// 查询库位详情
export const getPn = async (id: number) => {
return await request.get({ url: `/heli/pn/get?id=` + id })
}
// 新增库位
export const createPn = async (data: PnVO) => {
return await request.post({ url: `/heli/pn/create`, data })
}
// 修改库位
export const updatePn = async (data: PnVO) => {
return await request.put({ url: `/heli/pn/update`, data })
}
// 删除库位
export const deletePn = async (id: number) => {
return await request.delete({ url: `/heli/pn/delete?id=` + id })
}
// 导出库位 Excel
export const exportPn = async (params) => {
return await request.download({ url: `/heli/pn/export-excel`, params })
}

@ -0,0 +1,134 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="库位编号,唯一" prop="pnNo">
<el-input v-model="formData.pnNo" placeholder="请输入库位编号,唯一" />
</el-form-item>
<el-form-item label="库位名称,唯一" prop="pnName">
<el-input v-model="formData.pnName" placeholder="请输入库位名称,唯一" />
</el-form-item>
<el-form-item label="库区 Id对应 wms_rg 表中的Id" prop="rgId">
<el-select v-model="formData.rgId" placeholder="请选择库区 Id对应 wms_rg 表中的Id">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="描述信息" prop="descr">
<el-input v-model="formData.descr" placeholder="请输入描述信息" />
</el-form-item>
<el-form-item label="状态,1 表示正常2 表示禁用" prop="pnStatus">
<el-radio-group v-model="formData.pnStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="仓库 Id对应 wms_wh 表中的Id" prop="whId">
<el-select v-model="formData.whId" placeholder="请选择仓库 Id对应 wms_wh 表中的Id">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as PnApi from '@/api/heli/pn'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
pnNo: undefined,
pnName: undefined,
rgId: undefined,
descr: undefined,
pnStatus: undefined,
whId: undefined,
})
const formRules = reactive({
pnName: [{ required: true, message: '库位名称,唯一不能为空', trigger: 'blur' }],
rgId: [{ required: true, message: '库区 Id对应 wms_rg 表中的Id不能为空', trigger: 'change' }],
pnStatus: [{ required: true, message: '状态,1 表示正常2 表示禁用不能为空', trigger: 'blur' }],
whId: [{ required: true, message: '仓库 Id对应 wms_wh 表中的Id不能为空', trigger: 'change' }],
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await PnApi.getPn(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as PnApi.PnVO
if (formType.value === 'create') {
await PnApi.createPn(data)
message.success(t('common.createSuccess'))
} else {
await PnApi.updatePn(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
pnNo: undefined,
pnName: undefined,
rgId: undefined,
descr: undefined,
pnStatus: undefined,
whId: undefined,
}
formRef.value?.resetFields()
}
</script>

@ -0,0 +1,295 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="库位编号,唯一" prop="pnNo">
<el-input
v-model="queryParams.pnNo"
placeholder="请输入库位编号,唯一"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="库位名称,唯一" prop="pnName">
<el-input
v-model="queryParams.pnName"
placeholder="请输入库位名称,唯一"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="库区 Id对应 wms_rg 表中的Id" prop="rgId">
<el-select
v-model="queryParams.rgId"
placeholder="请选择库区 Id对应 wms_rg 表中的Id"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="描述信息" prop="descr">
<el-input
v-model="queryParams.descr"
placeholder="请输入描述信息"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="状态,1 表示正常2 表示禁用" prop="pnStatus">
<el-select
v-model="queryParams.pnStatus"
placeholder="请选择状态,1 表示正常2 表示禁用"
clearable
class="!w-240px"
>
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="记录的创建人,对应员工表中的 Id" prop="creator">
<el-input
v-model="queryParams.creator"
placeholder="请输入记录的创建人,对应员工表中的 Id"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="记录的修改人,对应员工表中的 Id" prop="updater">
<el-input
v-model="queryParams.updater"
placeholder="请输入记录的修改人,对应员工表中的 Id"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="更新时间" prop="updateTime">
<el-date-picker
v-model="queryParams.updateTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="仓库 Id对应 wms_wh 表中的Id" prop="whId">
<el-select
v-model="queryParams.whId"
placeholder="请选择仓库 Id对应 wms_wh 表中的Id"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['heli:pn:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['heli:pn:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="主键id" align="center" prop="id" />
<el-table-column label="库位编号,唯一" align="center" prop="pnNo" />
<el-table-column label="库位名称,唯一" align="center" prop="pnName" />
<el-table-column label="库区 Id对应 wms_rg 表中的Id" align="center" prop="rgId">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_COMMON_STATUS" :value="scope.row.rgId" />
</template>
</el-table-column>
<el-table-column label="描述信息" align="center" prop="descr" />
<el-table-column label="状态,1 表示正常2 表示禁用" align="center" prop="pnStatus" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="仓库 Id对应 wms_wh 表中的Id" align="center" prop="whId">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_COMMON_STATUS" :value="scope.row.whId" />
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['heli:pn:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['heli:pn:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<PnForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as PnApi from '@/api/heli/pn'
import PnForm from './PnForm.vue'
defineOptions({ name: 'Pn' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
pnNo: undefined,
pnName: undefined,
rgId: undefined,
descr: undefined,
pnStatus: undefined,
creator: undefined,
createTime: [],
updater: undefined,
updateTime: [],
whId: undefined,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await PnApi.getPnPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await PnApi.deletePn(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await PnApi.exportPn(queryParams)
download.excel(data, '库位.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
Loading…
Cancel
Save