feat(store): 添加仓库类型字段和工艺流程管理功能

This commit is contained in:
zxy 2026-04-10 17:48:25 +08:00
parent 83c128b2f9
commit 4c93ff75e2
22 changed files with 810 additions and 12 deletions

View File

@ -0,0 +1,11 @@
package jnpf.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.model.techproc.TechProcEntity;
/**
* 工艺流程主数据 Mapper
*/
public interface TechProcMapper extends BaseMapper<TechProcEntity> {
}

View File

@ -0,0 +1,28 @@
package jnpf.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.model.techproc.TechProcEntity;
import jnpf.model.techproc.TechProcForm;
import jnpf.model.techproc.TechProcPagination;
import java.util.List;
/**
* 工艺流程主数据 Service
*/
public interface TechProcService extends IService<TechProcEntity> {
List<TechProcEntity> getList(TechProcPagination techProcPagination);
TechProcEntity getInfo(String id);
void delete(TechProcEntity entity);
void create(TechProcEntity entity);
boolean update(String id, TechProcEntity entity);
String checkForm(TechProcForm form, int type);
void saveOrUpdate(TechProcForm techProcForm, String id, boolean isSave) throws Exception;
}

View File

@ -38,6 +38,9 @@ public class StoreAreaServiceImpl extends ServiceImpl<StoreAreaMapper, StoreArea
public List<StoreAreaEntity> getList(StoreAreaPagination storeAreaPagination) {
LambdaQueryWrapper<StoreAreaEntity> storeAreaWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(storeAreaPagination.getStoreType())) {
storeAreaWrapper.eq(StoreAreaEntity::getStoreType, storeAreaPagination.getStoreType());
}
if (ObjectUtil.isNotEmpty(storeAreaPagination.getStoreAreCd())) {
storeAreaWrapper.like(StoreAreaEntity::getStoreAreCd, storeAreaPagination.getStoreAreCd());
}
@ -61,7 +64,7 @@ public class StoreAreaServiceImpl extends ServiceImpl<StoreAreaMapper, StoreArea
storeAreaList = this.list(storeAreaWrapper);
}
for (StoreAreaEntity storeAreaEntity : storeAreaList) {
StoreHouseEntity storeHouseEntity = storeHouseService.getInfo(storeAreaEntity.getStoreHouseId());
StoreHouseEntity storeHouseEntity = storeHouseService.getInfo(String.valueOf(storeAreaEntity.getStoreHouseId()));
if (storeHouseEntity != null) {
storeAreaEntity.setStoreHouseName(storeHouseEntity.getStoreHouseName());
}

View File

@ -32,7 +32,9 @@ public class StoreHouseServiceImpl extends ServiceImpl<StoreHouseMapper, StoreHo
@Override
public List<StoreHouseEntity> getList(StoreHousePagination storeHousePagination) {
LambdaQueryWrapper<StoreHouseEntity> storeHouseWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(storeHousePagination.getStoreType())) {
storeHouseWrapper.eq(StoreHouseEntity::getStoreType, storeHousePagination.getStoreType());
}
if (ObjectUtil.isNotEmpty(storeHousePagination.getStoreHouseCd())) {
storeHouseWrapper.like(StoreHouseEntity::getStoreHouseCd, storeHousePagination.getStoreHouseCd());
}

View File

@ -0,0 +1,139 @@
package jnpf.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.base.UserInfo;
import jnpf.mapper.TechProcMapper;
import jnpf.model.techproc.TechProcEntity;
import jnpf.model.techproc.TechProcForm;
import jnpf.model.techproc.TechProcPagination;
import jnpf.service.TechProcService;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* 工艺流程主数据 ServiceImpl
*/
@Service
public class TechProcServiceImpl extends ServiceImpl<TechProcMapper, TechProcEntity> implements TechProcService {
@Resource
private UserProvider userProvider;
@Resource
private TechProcService self;
@Override
public List<TechProcEntity> getList(TechProcPagination techProcPagination) {
LambdaQueryWrapper<TechProcEntity> techProcWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(techProcPagination.getTechProc())) {
techProcWrapper.like(TechProcEntity::getTechProc, techProcPagination.getTechProc());
}
if (ObjectUtil.isNotEmpty(techProcPagination.getEnabledStatus())) {
techProcWrapper.eq(TechProcEntity::getEnabledStatus, techProcPagination.getEnabledStatus());
}
techProcWrapper.eq(TechProcEntity::getDeleteMark, 0);
techProcWrapper.orderByDesc(TechProcEntity::getCreatorTime);
if ("0".equals(techProcPagination.getDataType())) {
Page<TechProcEntity> page = new Page<>(techProcPagination.getCurrentPage(), techProcPagination.getPageSize());
IPage<TechProcEntity> userIPage = this.page(page, techProcWrapper);
return techProcPagination.setData(userIPage.getRecords(), userIPage.getTotal());
} else {
return this.list(techProcWrapper);
}
}
@Override
public TechProcEntity getInfo(String id) {
QueryWrapper<TechProcEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(TechProcEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public void create(TechProcEntity entity) {
this.save(entity);
}
@Override
public boolean update(String id, TechProcEntity entity) {
return this.updateById(entity);
}
@Override
public void delete(TechProcEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
/**
* 验证表单唯一字段正则非空 i-0新增-1修改
*/
@Override
public String checkForm(TechProcForm form, int type) {
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
String id = "";
String countRecover = "";
if (isUp) {
id = form.getId();
}
// 工艺流程唯一性验证
if (ObjectUtil.isNotEmpty(form.getTechProc())) {
LambdaQueryWrapper<TechProcEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TechProcEntity::getTechProc, form.getTechProc());
if (isUp) {
wrapper.ne(TechProcEntity::getId, id);
}
long count = this.count(wrapper);
if (count > 0) {
countRecover += "工艺流程已存在,请重新输入!";
}
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
*
* @param id
* @param techProcForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(TechProcForm techProcForm, String id, boolean isSave) throws Exception {
UserInfo userInfo = userProvider.get();
TechProcEntity entity;
if (isSave) {
// 新增
entity = new TechProcEntity();
} else {
// 更新先查询原数据
entity = getInfo(id);
if (entity == null) {
throw new RuntimeException("数据不存在");
}
}
// 使用 BeanUtils.copyProperties 只复制 Form 中有的字段保留系统字段
BeanUtils.copyProperties(techProcForm, entity);
// 通过注入的 self 调用确保事务生效
self.saveOrUpdate(entity);
}
}

View File

@ -0,0 +1,115 @@
package jnpf.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.model.techproc.TechProcEntity;
import jnpf.model.techproc.TechProcForm;
import jnpf.model.techproc.TechProcPagination;
import jnpf.service.TechProcService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 工艺流程主数据 控制类
*/
@Tag(name = "工艺流程主数据", description = "TechProc")
@RestController
@RequestMapping("/api/example/techproc")
public class TechProcController {
@Autowired
private TechProcService techProcService;
/**
* 列表
* @param techProcPagination 分页查询对象
* @return 列表结果集
*/
@Operation(summary = "获取工艺流程列表")
@PostMapping("/getList")
public ActionResult getList(@RequestBody TechProcPagination techProcPagination) {
List<TechProcEntity> list = techProcService.getList(techProcPagination);
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(techProcPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 详情
* @param id 主键
* @return 详情结果集
*/
@Operation(summary = "获取工艺流程详情")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id) {
TechProcEntity entity = techProcService.getInfo(id);
if (entity != null) {
return ActionResult.success(JsonUtil.entityToMap(entity));
}
return ActionResult.fail("数据不存在");
}
/**
* 新建
* @param techProcForm 表单对象
* @return 新建结果
*/
@Operation(summary = "新建工艺流程")
@PostMapping
public ActionResult create(@RequestBody @Valid TechProcForm techProcForm) {
String b = techProcService.checkForm(techProcForm, 0);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
try {
techProcService.saveOrUpdate(techProcForm, "", true);
return ActionResult.success("新建成功");
} catch (Exception e) {
return ActionResult.fail("新建数据失败:" + e.getMessage());
}
}
/**
* 编辑
* @param id 主键
* @param techProcForm 表单对象
* @return 编辑结果
*/
@Operation(summary = "更新工艺流程")
@PutMapping("/{id}")
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid TechProcForm techProcForm) {
techProcForm.setId(id);
String b = techProcService.checkForm(techProcForm, 1);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
TechProcEntity entity = techProcService.getInfo(id);
if (entity != null) {
try {
techProcService.saveOrUpdate(techProcForm, id, false);
return ActionResult.success("更新成功");
} catch (Exception e) {
return ActionResult.fail("更新数据失败:" + e.getMessage());
}
} else {
return ActionResult.fail("更新失败,数据不存在");
}
}
}

View File

@ -56,8 +56,11 @@ public class StoreAreaEntity {
private String remark;
@TableField(value = "store_house_id", updateStrategy = FieldStrategy.IGNORED)
private String storeHouseId;
private Integer storeHouseId;
@TableField(exist = false)
private String storeHouseName;
@TableField(value = "store_type")
private String storeType;
}

View File

@ -36,4 +36,6 @@ public class StoreAreaForm {
@Schema(description = "流程任务ID")
private String flowTaskId;
private String storeType;
}

View File

@ -39,4 +39,7 @@ public class StoreAreaPagination extends Pagination {
@Schema(description = "仓库id")
private Integer storeHouseId;
@Schema(description = "仓库类型")
private String storeType;
}

View File

@ -40,4 +40,7 @@ public class StoreHouseEntity {
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
private String remark;
@TableField(value = "store_type")
private String storeType;
}

View File

@ -30,4 +30,5 @@ public class StoreHouseForm {
@Schema(description = "流程任务ID")
private String flowTaskId;
private String storeType;
}

View File

@ -31,4 +31,7 @@ public class StoreHousePagination extends Pagination {
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
@Schema(description = "仓储类型")
private String storeType;
}

View File

@ -0,0 +1,54 @@
package jnpf.model.techproc;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* 工艺流程主数据
*/
@Data
@TableName("tba_tech_proc")
public class TechProcEntity {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField(value = "f_creator_user_id", fill = FieldFill.INSERT)
private String creatorUserId;
@TableField(value = "f_creator_time", fill = FieldFill.INSERT)
private Date creatorTime;
@TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE)
private String lastModifyUserId;
@TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE)
private Date lastModifyTime;
@TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE)
private String deleteUserId;
@TableField(value = "f_delete_time", fill = FieldFill.UPDATE)
private Date deleteTime;
@TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED)
private Integer deleteMark;
@TableField(value = "f_flow_id", updateStrategy = FieldStrategy.IGNORED)
private String flowId;
@TableField(value = "f_flow_task_id", updateStrategy = FieldStrategy.IGNORED)
private String flowTaskId;
@TableField("tech_proc")
private String techProc;
@TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
private Integer enabledStatus;
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
private String remark;
}

View File

@ -0,0 +1,32 @@
package jnpf.model.techproc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 工艺流程主数据 Form
*/
@Data
public class TechProcForm {
@Schema(description = "主键")
private String id;
@NotBlank(message = "工艺流程不能为空")
@Schema(description = "工艺流程")
private String techProc;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
@Schema(description = "备注")
private String remark;
@Schema(description = "流程ID")
private String flowId;
@Schema(description = "流程任务ID")
private String flowTaskId;
}

View File

@ -0,0 +1,37 @@
package jnpf.model.techproc;
import jnpf.base.Pagination;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 工艺流程主数据分页查询
*/
@Data
public class TechProcPagination extends Pagination {
@Schema(description = "selectKey")
private String[] selectKey;
@Schema(description = "json")
private String json;
@Schema(description = "数据类型")
private String dataType;
@Schema(description = "特殊查询json")
private String superQueryJson;
@Schema(description = "模块id")
private String moduleId;
@Schema(description = "菜单id")
private String menuId;
@Schema(description = "工艺流程")
private String techProc;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
}

View File

@ -7,6 +7,9 @@ export const customerMaps = {
creditRate: { '1': '优', '2': '良', '3': '中', '4': '差' },
payMeth: { '1': '预付', '2': '月付', '3': '承兑' },
enabledStatus: { '1': '启用', '2': '未启用' },
storeType: { '1': '原料库', '2': '在制品库', '3': '成品库' },
}
// 根据映射自动生成下拉选项

View File

@ -8,6 +8,10 @@
>
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px" label-position="right">
<template v-if="!loading">
<el-form-item label="仓库" prop="storeHouseId">
<JnpfSelect v-model="dataForm.storeHouseId" placeholder="请选择仓库" :options="warehouseOptions" :props="warehouseProps" clearable :style="{ width: '100%' }">
</JnpfSelect>
</el-form-item>
<el-form-item label="库区编码" prop="storeAreCd">
<JnpfInput v-model="dataForm.storeAreCd" placeholder="请输入库区编码" clearable :disabled="!!dataForm.id" :style="{ width: '100%' }">
</JnpfInput>
@ -16,10 +20,6 @@
<JnpfInput v-model="dataForm.storeAreaName" placeholder="请输入库区名称" clearable :style="{ width: '100%' }">
</JnpfInput>
</el-form-item>
<el-form-item label="仓库" prop="storeHouseId">
<JnpfSelect v-model="dataForm.storeHouseId" placeholder="请选择仓库" :options="warehouseOptions" :props="warehouseProps" clearable :style="{ width: '100%' }">
</JnpfSelect>
</el-form-item>
<el-form-item label="状态" prop="enabledStatus">
<JnpfSelect v-model="dataForm.enabledStatus" placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable :style="{ width: '100%' }">
</JnpfSelect>
@ -74,6 +74,13 @@ export default {
trigger: 'blur',
},
],
storeHouseId: [
{
required: true,
message: '请选择仓库',
trigger: 'change',
},
],
enabledStatus: [
{
required: true,

View File

@ -3,6 +3,18 @@
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="14">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="仓库类型">
<JnpfSelect v-model="query.storeType" placeholder="请选择" clearable :options="storeTypeOptions"
:props="storeTypeProps">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="仓库名称">
<el-input v-model="query.storeHouseName" placeholder="请输入" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="状态">
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
@ -26,13 +38,14 @@
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="storeHouseName" label="仓库名称" align="center"/>
<el-table-column prop="storeType" label="仓库类型" align="center"/>
<el-table-column prop="storeAreCd" label="库区编码" align="center"/>
<el-table-column prop="storeAreaName" label="库区名称" align="center"/>
<el-table-column prop="storeHouseName" label="仓储名称" align="center"/>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
{{ scope.row.enabledStatus == 1 ? '启用' : scope.row.enabledStatus == 2 ? '未启用' : scope.row.enabledStatus }}
<el-tag :type="scope.row.enabledStatus === 1 ? 'success' : 'info'" size="small">
{{ getCustomerLabel('enabledStatus', scope.row.enabledStatus) }}
</el-tag>
</template>
</el-table-column>
@ -57,6 +70,7 @@ import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import jnpf from "@/utils/jnpf";
import { getCustomerLabel } from "../customer/options";
export default {
name: "storearea",
@ -107,6 +121,7 @@ export default {
this.initData();
},
methods: {
getCustomerLabel,
initData() {
this.listLoading = true;
let _query = {

View File

@ -9,6 +9,11 @@ NEW_FILE_CODE
>
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px" label-position="right">
<template v-if="!loading">
<el-form-item label="仓库类型" prop="storeType">
<JnpfSelect v-model="dataForm.storeType" placeholder="请选择" clearable :options="storeTypeOptions"
:props="storeTypeProps" :style="{ width: '100%' }">
</JnpfSelect>
</el-form-item>
<el-form-item label="仓储编码" prop="storeHouseCd">
<JnpfInput v-model="dataForm.storeHouseCd" placeholder="请输入仓储编码" clearable :disabled="!!dataForm.id" :style="{ width: '100%' }">
</JnpfInput>
@ -50,12 +55,20 @@ export default {
eventType: '',
dataForm: {
id: '',
storeType: undefined,
storeHouseCd: undefined,
storeHouseName: undefined,
enabledStatus: 1,
remark: undefined,
},
dataRule: {
storeType: [
{
required: true,
message: '请选择仓库类型',
trigger: 'change',
},
],
storeHouseCd: [
{
required: true,
@ -82,6 +95,12 @@ export default {
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
storeTypeOptions: [
{ fullName: "原料库", id: 1 },
{ fullName: "在制品库", id: 2 },
{ fullName: "成品库", id: 3 },
],
storeTypeProps: { label: "fullName", value: "id" },
enabledStatusProps: { label: "fullName", value: "id" },
}
},
@ -101,6 +120,7 @@ export default {
method: 'get'
}).then(res => {
this.dataForm = res.data
this.dataForm.storeType = res.data.storeType != null ? Number(res.data.storeType) : undefined
this.loading = false
})
} else {

View File

@ -4,6 +4,13 @@ NEW_FILE_CODE
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="14">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="仓库类型">
<JnpfSelect v-model="query.storeType" placeholder="请选择" clearable :options="storeTypeOptions"
:props="storeTypeProps">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="状态">
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
@ -27,12 +34,17 @@ NEW_FILE_CODE
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="storeType" label="仓库类型" align="center">
<template slot-scope="scope">
{{ getCustomerLabel('storeType', scope.row.storeType) || scope.row.storeType }}
</template>
</el-table-column>
<el-table-column prop="storeHouseCd" label="仓储编码" align="center"/>
<el-table-column prop="storeHouseName" label="仓储名称" align="center"/>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
{{ scope.row.enabledStatus == 1 ? '启用' : scope.row.enabledStatus == 2 ? '未启用' : scope.row.enabledStatus }}
<el-tag :type="scope.row.enabledStatus === 1 ? 'success' : 'info'" size="small">
{{ getCustomerLabel('enabledStatus', scope.row.enabledStatus) }}
</el-tag>
</template>
</el-table-column>
@ -57,6 +69,7 @@ import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import jnpf from "@/utils/jnpf";
import { getCustomerLabel } from "../customer/options";
export default {
name: "storehouse",
@ -67,6 +80,7 @@ export default {
return {
keyword: "",
query: {
storeType: undefined,
storeHouseCd: undefined,
storeHouseName: undefined,
enabledStatus: undefined,
@ -90,6 +104,12 @@ export default {
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
storeTypeOptions: [
{ fullName: "原料库", id: 1 },
{ fullName: "在制品库", id: 2 },
{ fullName: "成品库", id: 3 },
],
storeTypeProps: { label: "fullName", value: "id" },
enabledStatusProps: { label: "fullName", value: "id" },
};
},
@ -106,6 +126,7 @@ export default {
this.initData();
},
methods: {
getCustomerLabel,
initData() {
this.listLoading = true;
let _query = {

View File

@ -0,0 +1,137 @@
NEW_FILE_CODE
<template>
<el-dialog
:title="!dataForm.id ? '新建' : '编辑'"
:visible.sync="dialogVisible"
width="600px"
:close-on-click-modal="false"
@close="handleClose"
>
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px" label-position="right">
<template v-if="!loading">
<el-form-item label="工艺流程" prop="techProc">
<JnpfInput v-model="dataForm.techProc" placeholder="请输入工艺流程" clearable :style="{ width: '100%' }">
</JnpfInput>
</el-form-item>
<el-form-item label="状态" prop="enabledStatus">
<JnpfSelect v-model="dataForm.enabledStatus" placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable :style="{ width: '100%' }">
</JnpfSelect>
</el-form-item>
<el-form-item label="备注" prop="remark">
<JnpfTextarea v-model="dataForm.remark" placeholder="请输入备注" :style="{ width: '100%' }" :autoSize="{ minRows: 4, maxRows: 4 }" type="textarea">
</JnpfTextarea>
</el-form-item>
</template>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading"> </el-button>
<el-button @click="handleClose"> </el-button>
</div>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import { mapGetters } from 'vuex'
export default {
components: {},
props: [],
data() {
return {
dialogVisible: false,
loading: false,
btnLoading: false,
formRef: 'formRef',
eventType: '',
dataForm: {
id: '',
techProc: undefined,
enabledStatus: 1,
remark: undefined,
},
dataRule: {
techProc: [
{
required: true,
message: '请输入工艺流程',
trigger: 'blur',
},
],
enabledStatus: [
{
required: true,
message: '请选择状态',
trigger: 'change',
},
],
},
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
}
},
computed: {
...mapGetters(['userInfo']),
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.dialogVisible = true;
this.loading = true;
this.$nextTick(() => {
this.$refs.formRef.resetFields();
if (this.dataForm.id) {
request({
url: `/api/example/techproc/${this.dataForm.id}`,
method: 'get'
}).then(res => {
this.dataForm = res.data
this.loading = false
})
} else {
this.loading = false
}
});
},
dataFormSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {
this.btnLoading = true;
const isEdit = !!this.dataForm.id;
const url = isEdit ? `/api/example/techproc/${this.dataForm.id}` : '/api/example/techproc';
const method = isEdit ? 'put' : 'post';
request({
url: url,
method: method,
data: this.dataForm
}).then(res => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.btnLoading = false;
this.dialogVisible = false;
this.$emit('refresh', true)
}
})
}).catch(() => {
this.btnLoading = false
})
}
})
},
handleClose() {
this.dialogVisible = false;
this.$emit('refresh',true)
},
changeData(model, index) {
this.isEdit = true
}
}
}
</script>

View File

@ -0,0 +1,159 @@
NEW_FILE_CODE
<template>
<div class="JNPF-common-layout techproc_data">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="14">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="工艺流程">
<el-input v-model="query.techProc" placeholder="请输入" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="状态">
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
:props="enabledStatusProps">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item class="btn">
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">新建</el-button>
</div>
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="techProc" label="工艺流程" align="center"/>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
{{ scope.row.enabledStatus == 1 ? '启用' : scope.row.enabledStatus == 2 ? '未启用' : scope.row.enabledStatus }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center"/>
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"/>
<el-table-column label="操作" fixed="right" align="center" width="100">
<template slot-scope="scope">
<el-button type="text" @click="addOrUpdateHandle(scope.row)">编辑</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
@pagination="initData" />
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
</div>
</template>
<script>
import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import jnpf from "@/utils/jnpf";
export default {
name: "techproc",
components: {
JNPFForm,
},
data() {
return {
keyword: "",
query: {
techProc: undefined,
enabledStatus: undefined,
},
defListQuery: {
sort: "desc",
sidx: "",
},
list: [],
listLoading: false,
multipleSelection: [],
total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "",
sidx: "",
},
formVisible: false,
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
};
},
computed: {
jnpf() {
return jnpf
},
...mapGetters(["userInfo"]),
menuId() {
return this.$route.meta.modelId || "";
},
},
created() {
this.initData();
},
methods: {
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
dataType: 0,
};
request({
url: `/api/example/techproc/getList`,
method: "post",
data: _query,
}).then((res) => {
var _list = [];
for (let i = 0; i < res.data.list.length; i++) {
let _data = res.data.list[i];
_list.push(_data);
}
this.list = _list;
this.total = res.data.pagination.total;
this.listLoading = false;
});
},
addOrUpdateHandle(row) {
let id = row ? row.id : "";
this.formVisible = true;
this.$nextTick(() => {
this.$refs.JNPFForm.init(id);
});
},
search() {
this.listQuery.currentPage = 1;
this.listQuery.pageSize = 20;
this.initData();
},
refresh(isrRefresh) {
this.formVisible = false;
if (isrRefresh) this.search();
},
reset() {
this.query = {
techProc: undefined,
enabledStatus: undefined,
};
this.search();
},
},
};
</script>