feat(proorder): 添加生产订单编辑功能并优化相关组件
This commit is contained in:
parent
c9723e97a7
commit
494e5e1690
@ -1,10 +1,7 @@
|
||||
package jnpf.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jnpf.model.order.ExampleOrderForm;
|
||||
import jnpf.model.order.ProOrderEntity;
|
||||
import jnpf.model.order.ProOrderPagination;
|
||||
import jnpf.model.order.ProOrderVO;
|
||||
import jnpf.model.order.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -36,6 +33,8 @@ public interface ProOrderService extends IService<ProOrderEntity> {
|
||||
|
||||
void generate(ExampleOrderForm proOrderForm);
|
||||
|
||||
String update(ProOrderForm proOrderForm);
|
||||
|
||||
String generateCheck(ExampleOrderForm proOrderForm);
|
||||
|
||||
String removeInfo(ProOrderEntity proOrderEntity);
|
||||
|
||||
@ -212,6 +212,42 @@ public class ProOrderServiceImpl extends ServiceImpl<ProOrderMapper, ProOrderEnt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String update(ProOrderForm proOrderForm) {
|
||||
ProOrderEntity proOrderEntity = this.getById(proOrderForm.getId());
|
||||
if (proOrderEntity == null) {
|
||||
return "选择订单不存在,请刷新页面!";
|
||||
}
|
||||
ProOrderEntity entity = JsonUtil.getJsonToBean(proOrderForm, ProOrderEntity.class);
|
||||
this.updateById(entity);
|
||||
// 查询产线信息
|
||||
List<OrderLineForm> lineList = proOrderForm.getProLines();
|
||||
proOrderLineService.removeByProId(entity.getId());
|
||||
for (OrderLineForm lineForm : lineList) {
|
||||
ProOrderLineEntity lineEntity = JsonUtil.getJsonToBean(lineForm, ProOrderLineEntity.class);
|
||||
lineEntity.setProId(entity.getId());
|
||||
lineEntity.setProNo(entity.getProNo());
|
||||
lineEntity.setRemark(lineForm.getRemark());
|
||||
lineEntity.setProBgDate(lineForm.getPlanStartDate());
|
||||
lineEntity.setProEndDate(lineForm.getPlanEndDate());
|
||||
lineEntity.setLineId(Integer.valueOf(lineForm.getLineId()));
|
||||
lineEntity.setLineCd(lineForm.getLineCode());
|
||||
lineEntity.setLineName(lineForm.getLineName());
|
||||
lineEntity.setPlanQty(lineForm.getAllocateQty());
|
||||
lineEntity.setCompleteQty(BigDecimal.ZERO);
|
||||
proOrderLineService.save(lineEntity);
|
||||
}
|
||||
List<OrderDetailForm> orderItems = proOrderForm.getOrderItems();
|
||||
for (OrderDetailForm orderItem : orderItems) {
|
||||
OrderDetailEntity detailEntity = orderDetailService.getById(orderItem.getItemId());
|
||||
detailEntity.setProduceQty(orderItem.getPlanQty());
|
||||
orderDetailService.updateById(detailEntity);
|
||||
}
|
||||
// 计算
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateCheck(ExampleOrderForm proOrderForm) {
|
||||
// 校验订单状态
|
||||
@ -243,7 +279,7 @@ public class ProOrderServiceImpl extends ServiceImpl<ProOrderMapper, ProOrderEnt
|
||||
List<ProSoRelationEntity> soRelationEntityList = proSoRelationService.getListByProId(proOrderEntity.getId());
|
||||
for (ProSoRelationEntity proSoRelationEntity : soRelationEntityList) {
|
||||
OrderDetailEntity detailEntity = orderDetailService.getById(proSoRelationEntity.getProItemId());
|
||||
detailEntity.setProduceQty(detailEntity.getProduceQty().add(proSoRelationEntity.getChangProQty()));
|
||||
detailEntity.setProduceQty(detailEntity.getProduceQty().subtract(proSoRelationEntity.getChangProQty()));
|
||||
if (detailEntity.getProduceQty().compareTo(BigDecimal.ZERO) == 0) {
|
||||
detailEntity.setOrdItemStatus("0");
|
||||
} else {
|
||||
|
||||
@ -126,9 +126,10 @@ public class ProOrderController {
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public ActionResult<ProOrderForm> update(@RequestBody ProOrderForm proOrderForm) {
|
||||
ProOrderEntity entity = JsonUtil.getJsonToBean(proOrderForm, ProOrderEntity.class);
|
||||
entity.setId(proOrderForm.getId());
|
||||
proOrderService.updateById(entity);
|
||||
String message = proOrderService.update(proOrderForm);
|
||||
if (ObjectUtil.isNotEmpty(message)) {
|
||||
return ActionResult.fail(message);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
|
||||
@ -37,9 +37,6 @@ public class OrderLineForm implements Serializable {
|
||||
@Schema(description = "分配数量")
|
||||
private BigDecimal allocateQty;
|
||||
|
||||
@Schema(description = "完成数量")
|
||||
private BigDecimal completedQty;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package jnpf.model.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jnpf.model.orderdetail.OrderDetailForm;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 生产订单 Form
|
||||
@ -82,5 +84,9 @@ public class ProOrderForm implements Serializable {
|
||||
@Schema(description = "流程任务主键")
|
||||
private String flowTaskId;
|
||||
|
||||
private List<OrderLineForm> proLines;
|
||||
|
||||
private List<OrderDetailForm> orderItems;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -87,5 +87,16 @@ const baseRouter = [{
|
||||
icon: 'icon-ym icon-ym-btn-add',
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/example/proorder/form',
|
||||
component: (resolve) => require(['@/views/example/proorder/form'], resolve),
|
||||
name: 'proorderForm',
|
||||
meta: {
|
||||
title: 'proorderForm',
|
||||
affix: false,
|
||||
zhTitle: '生产订单编辑',
|
||||
icon: 'icon-ym icon-ym-btn-add',
|
||||
}
|
||||
},
|
||||
]
|
||||
export default baseRouter
|
||||
@ -126,6 +126,7 @@ export default {
|
||||
}).catch((err) => {
|
||||
this.loading = false
|
||||
this.dialogVisible = false
|
||||
this.$emit('close')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: err.message || '获取数据失败'
|
||||
@ -150,6 +151,7 @@ export default {
|
||||
},
|
||||
handleClose() {
|
||||
this.dialogVisible = false
|
||||
this.$emit('close')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<JNPFForm v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
|
||||
<EqPatrolConfigDetail ref="detail"/>
|
||||
<EqPatrolConfigDetail ref="detail" @close="refresh"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
677
jnpf-java-boot/jnpf-web/src/views/example/proorder/form.vue
Normal file
677
jnpf-java-boot/jnpf-web/src/views/example/proorder/form.vue
Normal file
@ -0,0 +1,677 @@
|
||||
<template>
|
||||
<div class="generate-order-container">
|
||||
<div class="main-content">
|
||||
<!-- 基础信息 -->
|
||||
<div class="main-section">
|
||||
<div class="section-title-row">
|
||||
<span class="section-title">基础信息</span>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataFormRef" size="small" label-width="120px" label-position="right" v-loading="loading" class="base-form">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="订单编号" prop="proNo">
|
||||
<el-input v-model="dataForm.proNo" :disabled="isEdit" placeholder="自动带出" style="width: 100%;"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="订单日期" prop="proDate">
|
||||
<el-date-picker v-model="dataForm.proDate" type="date" :disabled="isEdit" placeholder="选择日期" style="width: 100%;"></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="订单状态" prop="planStatus">
|
||||
<el-select v-model="dataForm.planStatus" :disabled="isEdit" style="width: 100%;">
|
||||
<el-option label="未下发" value="0"/>
|
||||
<el-option label="已下发" value="1"/>
|
||||
<el-option label="执行中" value="2"/>
|
||||
<el-option label="已完成" value="3"/>
|
||||
<el-option label="暂停" value="4"/>
|
||||
<el-option label="关闭" value="5"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品名称" prop="materialName">
|
||||
<el-input v-model="dataForm.materialName" :disabled="true" placeholder="自动带出" style="width: 100%;"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="规格型号" prop="spec">
|
||||
<el-input v-model="dataForm.spec" :disabled="true" placeholder="自动带出" style="width: 100%;"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="单位" prop="unit">
|
||||
<el-input v-model="dataForm.unitText" :disabled="true" placeholder="自动带出" style="width: 100%;"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="计划数量" prop="planQty">
|
||||
<el-input v-model.number="dataForm.planQty" :disabled="isEdit" placeholder="请输入计划数量" style="width: 100%;"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="开始日期" prop="planBgDate">
|
||||
<el-date-picker
|
||||
v-model="dataForm.planBgDate"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
style="width: 100%;"
|
||||
:picker-options="{ disabledDate: (time) => {
|
||||
if (this.dataForm.planEndDate) {
|
||||
return time.getTime() > new Date(this.dataForm.planEndDate).getTime();
|
||||
}
|
||||
return false;
|
||||
}}"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="完成日期" prop="planEndDate">
|
||||
<el-date-picker
|
||||
v-model="dataForm.planEndDate"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
style="width: 100%;"
|
||||
:picker-options="{ disabledDate: (time) => {
|
||||
if (this.dataForm.planBgDate) {
|
||||
return time.getTime() < new Date(this.dataForm.planBgDate).getTime();
|
||||
}
|
||||
return false;
|
||||
}}"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="工艺流程" prop="processFlow">
|
||||
<el-select
|
||||
v-model="dataForm.processFlow"
|
||||
filterable
|
||||
:remote-method="searchProcessFlow"
|
||||
:loading="processFlowLoading"
|
||||
placeholder="请选择"
|
||||
style="width: 100%;"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in processFlowList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="String(item.id)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="dataForm.isAllLine" true-label="0" false-label="1"/>
|
||||
<span style="margin-left: 5px;">所有产线</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="dataForm.remark" type="textarea" :rows="2" placeholder="请输入备注"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 销售订单信息 -->
|
||||
<div class="main-section">
|
||||
<div class="section-title-row">
|
||||
<span class="section-title">销售订单信息</span>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<el-table :data="dataForm.orderList || []" border size="small">
|
||||
<el-table-column type="index" label="序号" width="60" align="center"/>
|
||||
<el-table-column prop="saleOrdNo" label="订单编码" align="center" min-width="120"/>
|
||||
<el-table-column label="转生产数量" align="center" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="scope.row.planQty"
|
||||
type="number"
|
||||
size="small"
|
||||
style="width: 100px;"
|
||||
@input="handleOrderPlanQtyInput(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="materialName" label="产品名称" align="center" min-width="120"/>
|
||||
<el-table-column prop="spec" label="规格型号" align="center" min-width="120"/>
|
||||
<el-table-column prop="custName" label="客户名称" align="center" min-width="120"/>
|
||||
<el-table-column label="单位" align="center" min-width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ getUnitText(scope.row.unit) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 下发产线信息 -->
|
||||
<div class="main-section">
|
||||
<div class="section-title-row" style="display: flex; align-items: center; justify-content: flex-start;">
|
||||
<span class="section-title">下发产线信息</span>
|
||||
<el-button type="primary" size="small" @click="addLine" style="margin-left: 30px;">
|
||||
<i class="el-icon-plus"></i> 新 增
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<div v-if="!allocateQtyMatch && dataForm.lineList.length > 0" style="color: #e6a23c; margin-bottom: 10px; font-size: 14px;">
|
||||
<i class="el-icon-warning"></i> 产线分配数量不等于计划数量,请确认!
|
||||
</div>
|
||||
<el-table :data="dataForm.lineList" border size="small">
|
||||
<el-table-column type="index" label="序号" width="60" align="center"/>
|
||||
<el-table-column prop="lineCd" label="产线编码" align="center"/>
|
||||
<el-table-column prop="lineName" label="产线名称" align="center"/>
|
||||
<el-table-column prop="planQty" label="分配数量(*)" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="scope.row.planQty"
|
||||
type="text"
|
||||
placeholder="分配数量"
|
||||
style="width: 100%;"
|
||||
@input="handleAllocateQtyInput(scope.row)"
|
||||
></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="completeQty" label="已完成数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model.number="scope.row.completeQty" type="number" disabled placeholder="0" style="width: 100%;"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="proBgDate" label="计划开工日期" align="center" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-date-picker v-model="scope.row.proBgDate" type="date" placeholder="选择日期" style="width: 100%;"></el-date-picker>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="proEndDate" label="计划完成日期" align="center" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-date-picker v-model="scope.row.proEndDate" type="date" placeholder="选择日期" style="width: 100%;"></el-date-picker>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.remark" placeholder="备注" style="width: 100%;"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="removeLine(scope.$index)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<div class="footer-btn-row">
|
||||
<el-button type="primary" @click="handleSubmit" :loading="btnLoading">保 存</el-button>
|
||||
<el-button type="success" @click="handleIssue" :loading="btnLoading" v-if="dataForm.planStatus === '0'" class="mr10">下 发</el-button>
|
||||
<el-button @click="goBack" class="mr10">取 消</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 产线选择弹窗 -->
|
||||
<ProLineSelect
|
||||
:visible.sync="lineModalVisible"
|
||||
:selected-line-codes="selectedLineCodes"
|
||||
@confirm="handleProLineConfirm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getProOrderInfo, updateProOrder, createProOrder} from "./api";
|
||||
import ProLineSelect from "@/views/example/proline/select";
|
||||
import request from "@/utils/request";
|
||||
|
||||
export default {
|
||||
name: "ProOrderForm",
|
||||
components: {
|
||||
ProLineSelect
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
btnLoading: false,
|
||||
isEdit: false,
|
||||
lineModalVisible: false,
|
||||
selectedLineCodes: [],
|
||||
allocateQtyMatch: true,
|
||||
processFlowList: [],
|
||||
allProcessFlowList: [],
|
||||
processFlowLoading: false,
|
||||
dataRule: {
|
||||
proNo: [
|
||||
{required: true, message: '请输入订单编号', trigger: 'blur'}
|
||||
],
|
||||
proDate: [
|
||||
{required: true, message: '请选择订单日期', trigger: 'change'}
|
||||
],
|
||||
planStatus: [
|
||||
{required: true, message: '请选择订单状态', trigger: 'change'}
|
||||
],
|
||||
materialName: [
|
||||
{required: true, message: '请选择产品名称', trigger: 'blur'}
|
||||
],
|
||||
spec: [
|
||||
{required: true, message: '请选择规格型号', trigger: 'blur'}
|
||||
],
|
||||
unit: [
|
||||
{required: true, message: '请选择单位', trigger: 'blur'}
|
||||
],
|
||||
planQty: [
|
||||
{required: true, message: '请输入计划数量', trigger: 'blur'},
|
||||
{type: 'number', min: 0, message: '计划数量必须大于等于0', trigger: 'blur'}
|
||||
],
|
||||
planBgDate: [
|
||||
{required: true, message: '请选择开始日期', trigger: 'change'}
|
||||
],
|
||||
planEndDate: [
|
||||
{required: true, message: '请选择完成日期', trigger: 'change'}
|
||||
],
|
||||
processFlow: [
|
||||
{required: true, message: '请选择工艺流程', trigger: 'change'}
|
||||
]
|
||||
},
|
||||
dataForm: {
|
||||
id: null,
|
||||
proNo: '',
|
||||
proDate: null,
|
||||
materialCode: '',
|
||||
materialName: '',
|
||||
spec: '',
|
||||
unit: '',
|
||||
unitText: '',
|
||||
planQty: null,
|
||||
completeQty: null,
|
||||
storeInQty: null,
|
||||
planBgDate: null,
|
||||
planEndDate: null,
|
||||
planEmpName: '',
|
||||
isAllLine: '1',
|
||||
planStatus: '0',
|
||||
remark: '',
|
||||
processFlow: '',
|
||||
lineList: [],
|
||||
orderList: []
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const id = this.$route.query.id;
|
||||
this.loadProcessFlow(id);
|
||||
},
|
||||
methods: {
|
||||
init(id = null) {
|
||||
this.loading = true
|
||||
this.isEdit = !!id
|
||||
|
||||
if (id) {
|
||||
getProOrderInfo(id).then((res) => {
|
||||
// 给orderList设置planQty默认值
|
||||
const orderList = (res.data.orderList || []).map(item => ({
|
||||
...item,
|
||||
planQty: item.planQty || item.changProQty || 0
|
||||
}));
|
||||
this.dataForm = {
|
||||
...res.data,
|
||||
isAllLine: String(res.data.isAllLine || '1'),
|
||||
planStatus: String(res.data.planStatus || '0'),
|
||||
lineList: res.data.lineList || [],
|
||||
orderList: orderList,
|
||||
unitText: this.getUnitText(res.data.unit),
|
||||
processFlow: String(res.data.processFlow || '')
|
||||
}
|
||||
// 同步已选择的产线编码
|
||||
this.selectedLineCodes = (res.data.lineList || []).map(line => line.lineCd || line.lineCode);
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
} else {
|
||||
this.dataForm = {
|
||||
id: null,
|
||||
proNo: '',
|
||||
proDate: new Date(),
|
||||
materialCode: '',
|
||||
materialName: '',
|
||||
spec: '',
|
||||
unit: '',
|
||||
unitText: '',
|
||||
planQty: null,
|
||||
completeQty: null,
|
||||
storeInQty: null,
|
||||
planBgDate: null,
|
||||
planEndDate: null,
|
||||
planEmpName: '',
|
||||
isAllLine: '1',
|
||||
planStatus: '0',
|
||||
remark: '',
|
||||
processFlow: '',
|
||||
lineList: [],
|
||||
orderList: []
|
||||
}
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
loadProcessFlow(id) {
|
||||
this.processFlowLoading = true;
|
||||
request({
|
||||
url: "/api/example/techproc/getSelect",
|
||||
method: "get",
|
||||
data: {}
|
||||
}).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.processFlowList = res.data || [];
|
||||
this.allProcessFlowList = res.data || [];
|
||||
}
|
||||
this.processFlowLoading = false;
|
||||
// 工艺列表加载完成后再初始化订单数据
|
||||
this.init(id);
|
||||
}).catch(() => {
|
||||
this.processFlowLoading = false;
|
||||
this.init(id);
|
||||
});
|
||||
},
|
||||
|
||||
searchProcessFlow(keyword) {
|
||||
if (!keyword) {
|
||||
this.processFlowList = this.allProcessFlowList;
|
||||
} else {
|
||||
this.processFlowList = this.allProcessFlowList.filter(item =>
|
||||
item.name && item.name.toLowerCase().includes(keyword.toLowerCase())
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
getUnitText(unit) {
|
||||
const map = {'1': '件', '2': '公斤', '3': '吨'};
|
||||
return map[unit] || unit;
|
||||
},
|
||||
addLine() {
|
||||
this.dataForm.isAllLine = "1";
|
||||
this.lineModalVisible = true;
|
||||
},
|
||||
|
||||
handleProLineConfirm(data) {
|
||||
data.forEach(item => {
|
||||
const lineCode = item.lineCode || item.lineCd;
|
||||
const exists = this.dataForm.lineList.some(line => line.lineCd === lineCode);
|
||||
if (!exists) {
|
||||
this.dataForm.lineList.push({
|
||||
id: item.lineId || item.id || null,
|
||||
lineCd: lineCode,
|
||||
lineName: item.lineName,
|
||||
planQty: null,
|
||||
completeQty: 0,
|
||||
proBgDate: null,
|
||||
proEndDate: null,
|
||||
remark: item.remark || ''
|
||||
});
|
||||
this.selectedLineCodes.push(lineCode);
|
||||
}
|
||||
});
|
||||
this.lineModalVisible = false;
|
||||
},
|
||||
removeLine(index) {
|
||||
const lineCd = this.dataForm.lineList[index].lineCd;
|
||||
this.dataForm.lineList.splice(index, 1);
|
||||
const codeIndex = this.selectedLineCodes.indexOf(lineCd);
|
||||
if (codeIndex > -1) {
|
||||
this.selectedLineCodes.splice(codeIndex, 1);
|
||||
}
|
||||
this.validateAllocateQty();
|
||||
},
|
||||
|
||||
handleAllocateQtyInput(row) {
|
||||
let value = row.planQty;
|
||||
if (!value) return;
|
||||
value = value.toString().replace(/[^\d.]/g, '');
|
||||
value = value.replace(/\.{2,}/g, '.');
|
||||
value = value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
|
||||
const parts = value.split('.');
|
||||
if (parts.length > 2) {
|
||||
value = parts[0] + '.' + parts[1].slice(0, 2);
|
||||
} else if (parts.length === 2 && parts[1].length > 2) {
|
||||
value = parts[0] + '.' + parts[1].slice(0, 2);
|
||||
}
|
||||
if (value.startsWith('.')) {
|
||||
value = '0' + value;
|
||||
}
|
||||
row.planQty = value;
|
||||
this.checkAllocateQtyTotal();
|
||||
},
|
||||
|
||||
// 转生产数量输入处理
|
||||
handleOrderPlanQtyInput(row) {
|
||||
let value = row.planQty;
|
||||
if (!value) return;
|
||||
value = value.toString().replace(/[^\d.]/g, '');
|
||||
value = value.replace(/\.{2,}/g, '.');
|
||||
value = value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
|
||||
const parts = value.split('.');
|
||||
if (parts.length > 2) {
|
||||
value = parts[0] + '.' + parts[1].slice(0, 2);
|
||||
} else if (parts.length === 2 && parts[1].length > 2) {
|
||||
value = parts[0] + '.' + parts[1].slice(0, 2);
|
||||
}
|
||||
if (value.startsWith('.')) {
|
||||
value = '0' + value;
|
||||
}
|
||||
row.planQty = value;
|
||||
},
|
||||
|
||||
checkAllocateQtyTotal() {
|
||||
const totalPlanQty = Number(this.dataForm.planQty || 0);
|
||||
const totalAllocateQty = this.dataForm.lineList.reduce((sum, item) => sum + Number(item.planQty || 0), 0);
|
||||
if (totalPlanQty !== totalAllocateQty && totalAllocateQty > 0) {
|
||||
this.allocateQtyMatch = false;
|
||||
} else {
|
||||
this.allocateQtyMatch = true;
|
||||
}
|
||||
},
|
||||
|
||||
validateOrderPlanQty() {
|
||||
if (!this.dataForm.planQty || Number(this.dataForm.planQty) <= 0) {
|
||||
this.$message.warning('计划数量必须大于0,请确认!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
validateAllocateQty() {
|
||||
const totalPlanQty = Number(this.dataForm.planQty || 0);
|
||||
const totalAllocateQty = this.dataForm.lineList.reduce((sum, item) => sum + Number(item.planQty || 0), 0);
|
||||
|
||||
if (totalPlanQty !== totalAllocateQty && totalAllocateQty > 0) {
|
||||
this.allocateQtyMatch = false;
|
||||
return false;
|
||||
} else {
|
||||
this.allocateQtyMatch = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
handleSubmit() {
|
||||
this.$refs.dataFormRef.validate((valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.validateOrderPlanQty()) return;
|
||||
|
||||
if (this.dataForm.isAllLine !== "0" && (!this.dataForm.lineList || this.dataForm.lineList.length === 0)) {
|
||||
this.$message.warning("请选择产线信息!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dataForm.isAllLine !== "0" && this.dataForm.lineList.length > 0 && !this.validateAllocateQty()) {
|
||||
this.$message.warning('产线分配数量不等于计划数量,请确认!');
|
||||
return;
|
||||
}
|
||||
|
||||
this.btnLoading = true
|
||||
const proLines = this.dataForm.lineList.map(item => ({
|
||||
lineId: item.id || item.lineId || '',
|
||||
lineCode: item.lineCd || '',
|
||||
lineName: item.lineName || '',
|
||||
allocateQty: item.planQty || 0,
|
||||
completedQty: item.completeQty || 0,
|
||||
planStartDate: item.proBgDate || '',
|
||||
planEndDate: item.proEndDate || '',
|
||||
remark: item.remark || ''
|
||||
}));
|
||||
// 转换orderList为orderItems
|
||||
const orderItems = this.dataForm.orderList.map(item => ({
|
||||
id: item.id || item.itemId,
|
||||
planQty: item.planQty
|
||||
}));
|
||||
const { lineList, orderList, ...rest } = this.dataForm;
|
||||
const data = {
|
||||
...rest,
|
||||
planStatus: "0", // 保存时设置为未下发
|
||||
proLines: proLines,
|
||||
orderItems: orderItems
|
||||
}
|
||||
|
||||
const promise = this.isEdit
|
||||
? updateProOrder(this.dataForm.id, data)
|
||||
: createProOrder(data)
|
||||
|
||||
promise.then(() => {
|
||||
this.$message.success(this.isEdit ? '修改成功' : '新增成功')
|
||||
this.btnLoading = false
|
||||
this.goBack()
|
||||
}).catch((err) => {
|
||||
const msg = err?.response?.data?.message || err?.message || (this.isEdit ? '修改失败' : '新增失败')
|
||||
this.$message.error(msg)
|
||||
this.btnLoading = false
|
||||
})
|
||||
});
|
||||
},
|
||||
handleIssue() {
|
||||
this.$refs.dataFormRef.validate((valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.validateOrderPlanQty()) return;
|
||||
|
||||
if (this.dataForm.isAllLine !== "0" && (!this.dataForm.lineList || this.dataForm.lineList.length === 0)) {
|
||||
this.$message.warning("生产订单下发必须指定产线,请确认!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dataForm.isAllLine !== "0" && this.dataForm.lineList.length > 0 && !this.validateAllocateQty()) {
|
||||
this.$message.warning('产线分配数量不等于计划数量,请确认!');
|
||||
return;
|
||||
}
|
||||
|
||||
this.btnLoading = true
|
||||
const proLines = this.dataForm.lineList.map(item => ({
|
||||
lineId: item.id || item.lineId || '',
|
||||
lineCode: item.lineCd || '',
|
||||
lineName: item.lineName || '',
|
||||
allocateQty: item.planQty || 0,
|
||||
completedQty: item.completeQty || 0,
|
||||
planStartDate: item.proBgDate || '',
|
||||
planEndDate: item.proEndDate || '',
|
||||
remark: item.remark || ''
|
||||
}));
|
||||
// 转换orderList为orderItems
|
||||
const orderItems = this.dataForm.orderList.map(item => ({
|
||||
id: item.id || item.itemId,
|
||||
planQty: item.planQty
|
||||
}));
|
||||
const { lineList, orderList, ...rest } = this.dataForm;
|
||||
const data = {
|
||||
...rest,
|
||||
planStatus: "1", // 下发时设置为已下发
|
||||
proLines: proLines,
|
||||
orderItems: orderItems,
|
||||
isIssue: true // 下发标识
|
||||
}
|
||||
|
||||
updateProOrder(this.dataForm.id, data).then(() => {
|
||||
this.$message.success('下发成功')
|
||||
this.btnLoading = false
|
||||
this.goBack()
|
||||
}).catch((err) => {
|
||||
const msg = err?.response?.data?.message || err?.message || '下发失败'
|
||||
this.$message.error(msg)
|
||||
this.btnLoading = false
|
||||
})
|
||||
});
|
||||
},
|
||||
goBack() {
|
||||
this.$router.push({path: "/example/proorder", query: {refresh: new Date().getTime()}})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.generate-order-container {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
min-height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
.main-section {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.section-title-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.section-content {
|
||||
background: #fafafa;
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.base-form {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.footer-btn-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 20px;
|
||||
background: #fafafa;
|
||||
border-radius: 4px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.mr10 {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
@ -43,14 +43,8 @@
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<div class="JNPF-common-layout-main" style="flex: 1; overflow: visible;">
|
||||
<!-- <div class="JNPF-common-head">
|
||||
<div>
|
||||
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="generateHandle()">生成生产订单</el-button>
|
||||
</div>
|
||||
<div class="JNPF-common-head-right"></div>
|
||||
</div> -->
|
||||
<div style="overflow-x: auto; min-height: 400px;">
|
||||
<div class="JNPF-common-layout-main" style="display: flex; flex-direction: column; height: calc(100vh - 200px);">
|
||||
<div style="flex: 1; overflow: auto;">
|
||||
<JNPF-table
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
@ -64,15 +58,15 @@
|
||||
:highlight-current-row="true">
|
||||
<el-table-column type="index" label="序号" align="center" width="60" fixed="left"/>
|
||||
<el-table-column type="selection" align="center" :reserve-selection="true" fixed="left"/>
|
||||
<el-table-column prop="proNo" label="生产订单号" align="center" min-width="140" fixed="left"/>
|
||||
<el-table-column prop="proNo" label="生产订单号" align="center" min-width="120" fixed="left"/>
|
||||
<el-table-column prop="materialName" label="产品名称" align="center" min-width="150"/>
|
||||
<el-table-column prop="spec" label="规格型号" align="center" min-width="120"/>
|
||||
<el-table-column prop="spec" label="规格型号" align="center" min-width="100"/>
|
||||
<el-table-column prop="unit" label="单位" align="center" min-width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.unit == '1' ? 'kg' : scope.row.unit == '2' ? 'T' : scope.row.unit }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planQty" label="订单数量" align="center" min-width="100">
|
||||
<el-table-column prop="planQty" label="订单数量" align="center" min-width="90">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.planQty || 0 }}
|
||||
</template>
|
||||
@ -100,7 +94,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="detailHandle(scope.row)">详情</el-button>
|
||||
<el-button type="text" @click="editHandle(scope.row)">编辑</el-button>
|
||||
<el-button type="text" @click="deleteHandle(scope.row)">删除</el-button>
|
||||
<!-- <el-button type="text" @click="closeHandle(scope.row)" v-if="canClose(scope.row)">关闭</el-button> -->
|
||||
</template>
|
||||
@ -110,19 +104,19 @@
|
||||
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
|
||||
@pagination="initData"/>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<div style="border: 1px solid #ebeef5; border-radius: 4px; padding: 10px;">
|
||||
<div style="flex: 1; margin-top: 20px; overflow: hidden;">
|
||||
<el-row :gutter="20" style="height: 100%;">
|
||||
<el-col :span="12" style="height: 100%;">
|
||||
<div style="border: 1px solid #ebeef5; border-radius: 4px; padding: 10px; height: 100%; display: flex; flex-direction: column;">
|
||||
<div style="margin-bottom: 10px; font-weight: bold;">关联销售订单</div>
|
||||
<JNPF-table
|
||||
:data="orderList"
|
||||
border>
|
||||
<el-table-column prop="saleOrdNo" label="销售订单编号" align="center" min-width="120"/>
|
||||
<el-table-column prop="custName" label="客户名称" align="center" min-width="120"/>
|
||||
<el-table-column prop="materialName" label="产品名称" align="center" min-width="120"/>
|
||||
<el-table-column prop="spec" label="规格型号" align="center" min-width="100"/>
|
||||
<el-table-column prop="changProQty" label="转生产数量" align="center" min-width="100">
|
||||
border style="flex: 1; width: 100%;">
|
||||
<el-table-column prop="saleOrdNo" label="销售订单编号" align="center"/>
|
||||
<el-table-column prop="custName" label="客户名称" align="center"/>
|
||||
<el-table-column prop="materialName" label="产品名称" align="center"/>
|
||||
<el-table-column prop="spec" label="规格型号" align="center"/>
|
||||
<el-table-column prop="changProQty" label="转生产数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.changProQty || 0 }}
|
||||
</template>
|
||||
@ -130,30 +124,30 @@
|
||||
</JNPF-table>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<div style="border: 1px solid #ebeef5; border-radius: 4px; padding: 10px;">
|
||||
<el-col :span="12" style="height: 100%;">
|
||||
<div style="border: 1px solid #ebeef5; border-radius: 4px; padding: 10px; height: 100%; display: flex; flex-direction: column;">
|
||||
<div style="margin-bottom: 10px; font-weight: bold;">产线订单信息</div>
|
||||
<JNPF-table
|
||||
:data="lineList"
|
||||
border>
|
||||
<el-table-column prop="lineCd" label="产线编码" align="center" min-width="100"/>
|
||||
border style="flex: 1; width: 100%;">
|
||||
<el-table-column prop="lineCd" label="产线编码" align="center"/>
|
||||
<!-- <el-table-column prop="lineName" label="产线名称" align="center" min-width="120"/> -->
|
||||
<el-table-column prop="proBgDate" label="开工时间" align="center" min-width="110" :formatter="jnpf.tableDateFormat1"/>
|
||||
<el-table-column prop="proEndDate" label="完工时间" align="center" min-width="110" :formatter="jnpf.tableDateFormat1"/>
|
||||
<el-table-column prop="planQty" label="计划数量" align="center" min-width="100"/>
|
||||
<el-table-column prop="completeQty" label="完成数量" align="center" min-width="100">
|
||||
<el-table-column prop="proBgDate" label="开工时间" align="center" :formatter="jnpf.tableDateFormat1"/>
|
||||
<el-table-column prop="proEndDate" label="完工时间" align="center" :formatter="jnpf.tableDateFormat1"/>
|
||||
<el-table-column prop="planQty" label="计划数量" align="center"/>
|
||||
<el-table-column prop="completeQty" label="完成数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.completeQty || 0 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planStatus" label="计划状态" align="center" min-width="100">
|
||||
<el-table-column prop="planStatus" label="计划状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="getPlanStatusType(scope.row.planStatus)" size="small">
|
||||
{{ getPlanStatusLabel(scope.row.planStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="180">
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="detailHandle(scope.row)">详情</el-button>
|
||||
</template>
|
||||
@ -165,8 +159,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<GenerateForm v-if="generateVisible" ref="GenerateForm" @refresh="refresh"/>
|
||||
<GenerateForm v-if="generateVisible" ref="GenerateForm" @close="refresh"/>
|
||||
<Detail v-if="detailVisible" ref="Detail" @close="detailVisible = false"/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -229,6 +224,11 @@ export default {
|
||||
this.initDefaultDate();
|
||||
this.initData();
|
||||
},
|
||||
watch: {
|
||||
'$route.query.refresh'() {
|
||||
this.initData();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initDefaultDate() {
|
||||
const now = new Date();
|
||||
@ -329,6 +329,12 @@ export default {
|
||||
this.$refs.Detail.init(row.id);
|
||||
});
|
||||
},
|
||||
editHandle(row) {
|
||||
this.$router.push({
|
||||
path: '/example/proorder/form',
|
||||
query: { id: row.id }
|
||||
});
|
||||
},
|
||||
closeHandle(row) {
|
||||
this.$confirm('此操作将关闭该生产订单, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user