订单管理模块(拆分数量问题修复)、湿料计划管理(优化显示)、工单管理(工单修改功能完成)

master
wws 2 years ago
parent b7ab73d87c
commit f4c6e61cff

@ -1,5 +1,40 @@
import request from '@/utils/request'
// 校验工单是否可以修改
export function checkWorkOrder(workorderId){
return request({
url:'/plan/pro/workorder/checkWorkOrder/'+workorderId,
method:'get'
})
}
// 提交修改工单接口
export function subChangeWorkOrder(data){
return request({
url:'/plan/pro/workorder/subChangeWorkOrder',
method:'post',
data:data
})
}
// 通过子工单查询父工单对应的批次list
export function getWorkBatchList(data){
return request({
url:'/plan/pro/workorder/getWorkBatchList',
method:'post',
data: data
})
}
// 通过子工单查询订单信息和工单信息
export function getOrderAndWork(data) {
return request({
url: '/plan/pro/workorder/getOrderAndWorkInfo',
method: 'post',
data: data
})
}
// 查询生产工单列表
export function listWorkorder(query) {
return request({

@ -78,7 +78,7 @@
icon="el-icon-plus"
size="mini"
@click="dialogVisible = true"
v-hasPermi="['order:order:add']"
v-hasPermi="['mes:pro:order:add']"
>新增
</el-button>
</el-col>
@ -163,7 +163,7 @@
type="text"
icon="el-icon-plus"
@click="splitBtn(scope.row)"
v-hasPermi="['mes:pro:order:add']"
v-hasPermi="['mes:pro:order:edit']"
v-if="scope.row.parentOrder == 0"
>拆分
</el-button>
@ -179,7 +179,7 @@
<!-- 第一列 -->
<el-col :offset="1" :span="8">
<el-form-item label-width="100px" label="物料号" prop="prodCode">
<el-input type="number" v-model="form.prodCode" placeholder="请输入物料号"/>
<el-input v-model="form.prodCode" placeholder="请输入物料号"/>
</el-form-item>
</el-col>
<!-- 第二列 -->
@ -570,11 +570,12 @@ export default {
//
this.proLoading = true // true
var num = this.productData[0].quantity;
//
function setAtrr1(data, splitNum) {
if (data.children !== undefined) {
for (let i = 0; i < data.children.length; i++) {
data.children[i].atrr1 = splitNum * (data.children[i].quantity / data.quantity)
data.children[i].atrr1 = splitNum * (data.children[i].quantity / num)
setAtrr1(data.children[i], splitNum)
}
}
@ -609,7 +610,7 @@ export default {
.catch(_ => {
})
},
/** 提交按钮 */
/** 新增-提交按钮 */
submitForm() {
//
if (this.checkNull(this.form.prodCode) == 0 || this.checkNull(this.form.planProDate) == 0 || this.checkNull(this.form.prodDesc) == 0 || this.checkNull(this.form.planComplete) == 0 || this.checkNull(this.form.quantity) == 0 || this.checkNull(this.form.unit) == 0 || this.checkNull(this.form.prodType) == 0) {

@ -628,11 +628,11 @@ export default {
//
var productDate = moment(e).format('YYYY-MM-DD')
//
this.workLoading = true // true
getWorkOrderList(productDate).then(response => {
this.workOrderList = response.data
//
//
this.workLoading = true // true
this.refreshWorkTable = false // refreshProTablefalse
this.$nextTick(() => {
// 使$nextTickDOM

@ -167,11 +167,11 @@
<template slot-scope="scope">
<dict-tag :options="dict.type.workorder_type" :value="scope.row.status"/>
</template>
</el-table-column>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="产品类型" align="center" prop="prodType" />
</el-table>
<pagination
v-show="total>0"
:total="total"
@ -181,100 +181,184 @@
/>
<!-- 添加或修改生产工单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="工单编码" prop="workorderCode">
<el-input v-model="form.workorderCode" placeholder="请输入工单编码" />
</el-form-item>
<el-form-item label="工单名称" prop="workorderName">
<el-input v-model="form.workorderName" placeholder="请输入工单名称" />
</el-form-item>
<el-form-item label="订单id" prop="orderId">
<el-input v-model="form.orderId" placeholder="请输入订单id" />
</el-form-item>
<el-form-item label="订单编码" prop="orderCode">
<el-input v-model="form.orderCode" placeholder="请输入订单编码" />
</el-form-item>
<el-form-item label="产品ID" prop="productId">
<el-input v-model="form.productId" placeholder="请输入产品ID" />
</el-form-item>
<el-form-item label="产品编号" prop="productCode">
<el-input v-model="form.productCode" placeholder="请输入产品编号" />
</el-form-item>
<el-form-item label="产品名称" prop="productName">
<el-input v-model="form.productName" placeholder="请输入产品名称" />
</el-form-item>
<el-form-item label="规格型号" prop="productSpc">
<el-input v-model="form.productSpc" placeholder="请输入规格型号" />
</el-form-item>
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入单位" />
</el-form-item>
<el-form-item label="已生产数量" prop="quantityProduced">
<el-input v-model="form.quantityProduced" placeholder="请输入已生产数量" />
</el-form-item>
<el-form-item label="已拆分数量" prop="quantitySplit">
<el-input v-model="form.quantitySplit" placeholder="请输入已拆分数量" />
</el-form-item>
<el-form-item label="工艺id" prop="routeCode">
<el-input v-model="form.routeCode" placeholder="请输入工艺id" />
</el-form-item>
<el-form-item label="产线设备" prop="prodLineCode">
<el-input v-model="form.prodLineCode" placeholder="请输入产线设备" />
</el-form-item>
<el-form-item label="工单生产日期" prop="productDate">
<el-date-picker
v-model="form.productDate"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="班次" prop="shiftId">
<el-input v-model="form.shiftId" placeholder="请输入班次" />
</el-form-item>
<el-form-item label="父工单" prop="parentOrder">
<el-input v-model="form.parentOrder" placeholder="请输入父工单" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="预留字段1" prop="attr1">
<el-input v-model="form.attr1" placeholder="请输入预留字段1" />
</el-form-item>
<el-form-item label="预留字段2" prop="attr2">
<el-input v-model="form.attr2" placeholder="请输入预留字段2" />
</el-form-item>
<el-form-item label="预留字段3" prop="attr3">
<el-input v-model="form.attr3" placeholder="请输入预留字段3" />
</el-form-item>
<el-form-item label="预留字段4" prop="attr4">
<el-input v-model="form.attr4" placeholder="请输入预留字段4" />
</el-form-item>
<el-form-item label="${comment}" prop="factoryCode">
<el-input v-model="form.factoryCode" placeholder="请输入${comment}" />
</el-form-item>
<el-form-item label="是否为底层节点(1是0不是)" prop="isEnd">
<el-input v-model="form.isEnd" placeholder="请输入是否为底层节点(1是0不是)" />
</el-form-item>
</el-form>
<!-- 工单修改模块 -->
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<!-- 拆分头pro -->
<el-table
border
v-if="refreshProTable"
v-loading="proLoading"
:data="productData"
row-key="orderCode"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column width="60" align="center" label="序号" type="index" :index="indexMethod"></el-table-column>
<el-table-column width="150" label="订单编号" prop="orderCode"/>
<el-table-column width="380" label="产品名称" align="center" prop="prodDesc"/>
<el-table-column width="60" label="单位" align="center" prop="unit"/>
<el-table-column width="130" label="产品数量" align="center" prop="quantity"/>
<el-table-column label="已拆分数量" align="center" prop="quantitySplit"/>
<el-table-column label="拆分数量" align="center" prop="atrr1"/>
</el-table>
<el-form class="my-margin" :model="splitForm" ref="dynamicForm" label-width="80px">
<!-- 编辑框 -->
<!-- 第一行 -->
<el-row>
<!-- 选择产线 -->
<el-col :span="6">
<el-form-item label="选择机型:">
<el-select @change="machineType" size="small" v-model="splitForm.prodLineCode" placeholder="请选择成型机">
<el-option v-for="item in proline" :key="item.key" :label="item.label" :value="item.key"></el-option>
</el-select>
</el-form-item>
</el-col>
<!-- 拆分数量 -->
<el-col :offset="2" :span="7">
<el-form-item size="small" label="拆分数量:">
<el-input required type="number" @input="splitNumChange" v-model="splitForm.splitNum"></el-input>
</el-form-item>
</el-col>
<!-- 工单日期 -->
<el-col :offset="1" :span="5">
<el-form-item size="small" label="工单日期: ">
<el-date-picker value-format="yyyy-MM-dd" @change="checkDate" v-model="splitForm.productDate" type="date" placeholder="选择日期"
></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<!-- 第二行 -->
<el-row>
<el-col :span="6">
<!-- 选择班次 -->
<el-form-item size="small" label="选择班次:" class="my-select my-first">
<el-select @change="shiftChange" v-model="splitForm.shiftId" placeholder="请选择班次">
<el-option v-for="item in workShift" :key="item.shiftId" :label="item.shiftDesc"
:value="item.shiftId"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :offset="2" :span="6">
<!-- 选择工艺 -->
<el-form-item size="small" label="选择工艺:" class="my-select my-first">
<el-select @change="routeChange" v-model="splitForm.routeCode" placeholder="请选择工艺">
<el-option v-for="item in routes" :key="item.routeCode" :label="item.routeName"
:value="item.routeCode"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<!-- 第三行 -->
<el-row v-for="(item, index) in formFields" :key="index">
<!-- 批次编号 -->
<el-col :span="7">
<el-form-item size="small" label="批次编号">
<el-input @blur="batchCodeChange" v-model="item.batchCode"></el-input>
</el-form-item>
</el-col>
<!-- 批次数量 -->
<el-col :offset="1" :span="4">
<el-form-item size="small" label="批次数量">
<el-input required @input="inBatch" type="number" v-model="item.batchQuantity"></el-input>
</el-form-item>
</el-col>
<!-- 操作 -->
<el-col :offset="1" :span="4">
<el-button size="small" v-if="formFields.length > 1" @click="removeField(index)" type="danger">
</el-button>
<el-button size="small" v-if="index === formFields.length - 1" @click="addField" type="primary">
</el-button>
</el-col>
</el-row>
</el-form>
<!-- 拆分尾 -->
<el-table
border
:data="splitData"
v-if="refreshWorkerTable"
v-loading="workerLoading"
row-key="workorderCode"
style="width: 100%"
max-height="240"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column width="60" align="center" label="序号" type="index" :index="indexMethod"></el-table-column>
<el-table-column width="200" align="center" prop="workorderCode" label="工单号"></el-table-column>
<el-table-column width="100" align="center" prop="productDate" label="工单日期"></el-table-column>
<el-table-column width="100" align="center" prop="prodLineCode" label="成型机"></el-table-column>
<el-table-column width="80" align="center" prop="quantitySplit" label="数量"></el-table-column>
<el-table-column width="60" label="单位" align="center" prop="unit"/>
<el-table-column width="90" label="工艺编码" align="center" prop="routeCode"/>
<el-table-column width="90" label="班次" align="center" prop="shiftDesc"/>
<el-table-column align="center" prop="batchCodeList" label="批次号"></el-table-column>
</el-table>
<!-- 测试 -->
<!-- 操作按钮 -->
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listWorkorder, getWorkorder, delWorkorder,downWorkorder, addWorkorder, updateWorkorder } from "@/api/plan/workorder";
import {
listWorkorder,
getWorkorder,
delWorkorder,
downWorkorder,
addWorkorder,
updateWorkorder,
getOrderAndWork,
getWorkBatchList,
subChangeWorkOrder,
checkWorkOrder
} from '@/api/plan/workorder'
import moment from 'moment';
import { getprodLineShift } from '@/api/plan/order'
export default {
name: "Workorder",
dicts: ['workorder_type'],
data() {
return {
// form
workForm: {},
// --
selectWork: null,
//
workerLoading: false,
//
refreshWorkerTable: true,
// list
splitData: [],
//
formFields: [{
batchCode: '',
batchQuantity: ''
}],
// list
routes: [],
// list
workShift: [],
// list
proline: [],
//
productData: [],
//
proLoading: false,
//
refreshProTable: true,
// form
splitForm:{
prodLineCode: null,
splitNum: null,
productDate: null,
shiftId: null,
routeCode: null,
},
//
loading: true,
//
@ -356,6 +440,151 @@ export default {
this.getList();
},
methods: {
/** 动态添加表单 */
addField() {
//
let sum = 0
for (let i = 0; i < this.formFields.length; i++) {
sum += Number(this.formFields[i].batchQuantity)
}
if (sum >= this.productData[0].atrr1) {
this.$message({
message: '无法添加!您的批次数量已满!',
type: 'warning'
})
return
}
this.formFields.push({ batchCode: '', batchQuantity: '' })
//
this.formFields[this.formFields.length - 1].batchQuantity = Number(this.productData[0].atrr1) - Number(sum)
},
/** 动态删除表单 */
removeField(index) {
this.formFields.splice(index, 1)
},
/** 填写批次数量 */
inBatch(e) {
//
if (e <= 0) {
this.formFields[this.formFields.length - 1].batchQuantity = 1
}
//
let sum = 0
for (let i = 0; i < this.formFields.length; i++) {
sum += Number(this.formFields[i].batchQuantity)
}
//
if (sum > this.productData[0].atrr1) {
this.$message({
message: '你的批次数量总和不能超过拆分数量!',
type: 'warning'
})
this.formFields[this.formFields.length - 1].batchQuantity = Number(this.productData[0].atrr1) - Number(Number(sum) - Number(e))
}
//
if (this.productData[0].atrr1 == '' || this.productData[0].atrr1 == null) {
this.formFields[this.formFields.length - 1].batchQuantity = ''
}
},
/** 检验批次编码是否重复 */
batchCodeChange(e) {
if (this.formFields.length > 1) {
for (let i = 0; i < this.formFields.length - 1; i++) {
if (this.formFields[this.formFields.length - 1].batchCode == this.formFields[i].batchCode) {
this.$message({
message: '批次号不能重复!',
type: 'warning'
})
this.formFields = [{
batchCode: '',
batchQuantity: ''
}]
return
}
}
}
},
/** 更改工艺 */
routeChange(e){
console.log("您更改了工艺")
console.log(e)
this.workForm.routeCode = e
console.log("这里是全部数据")
console.log(this.workForm)
console.log("这里是订单数据")
console.log(this.productData)
},
/** 更改班次 */
shiftChange(e){
console.log("您更改了班次")
console.log(e)
this.workForm.shiftId = e
},
/** 拆分数量 */
splitNumChange(e){
console.log("拆分数量改变")
console.log(e)
//
if (e <= 0) {
e = 1
this.splitForm.splitNum = 1
} else {
//
let max = Number(this.productData[0].quantity) - Number(this.productData[0].quantitySplit)
//
if (e > max) {
this.$message({
message: '最大值不能超过' + max + '!',
type: 'warning'
})
this.splitForm.splitNum = max
}
//
//
this.proLoading = true // true
var num = this.productData[0].quantity;
//
function setAtrr1(data, splitNum) {
if (data.children !== undefined) {
for (let i = 0; i < data.children.length; i++) {
data.children[i].atrr1 = splitNum * (data.children[i].quantity / num)
setAtrr1(data.children[i], splitNum)
}
}
}
this.productData[0].atrr1 = this.splitForm.splitNum
setAtrr1(this.productData[0], this.splitForm.splitNum)
this.refreshProTable = false // refreshProTablefalse
this.$nextTick(() => {
// 使$nextTickDOM
this.refreshProTable = true // refreshProTabletrue
this.proLoading = false // false
})
this.workForm.splitNum = this.splitForm.splitNum
}
this.product = this.productData[0]
},
/** 工单日期选择 */
checkDate(e){
console.log("工单日期改变")
console.log(e)
this.workForm.productDate = e
},
/** 成型机选择 */
machineType(e) {
console.log("成型机选择改变")
console.log(e)
console.log(this.proline)
this.workForm.prodLineCode = e
},
/** 查询生产工单列表 */
getList() {
this.loading = true;
@ -425,6 +654,9 @@ export default {
},
//
handleSelectionChange(selection) {
// --
this.selectWork = selection[0]
this.ids = selection.map(item => item.workorderId)
this.codes = selection.map(item => item.workorderCode)
this.single = selection.length!==1
@ -440,16 +672,111 @@ export default {
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const workorderId = row.workorderId || this.ids
getWorkorder(workorderId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改生产工单";
});
//
let check = 0;
checkWorkOrder(this.selectWork.workorderId).then(response => {
if (response.code == 500){
check = 1;
}
})
if (check == 1){
this.$message({
message:'该工单已有湿料计划,不可修改!',
type:'warning'
})
return;
}
console.log("这里是你要的数据")
console.log(this.selectWork)
//
this.reset();
this.splitData = [];
this.productData =[];
this.splitForm={
prodLineCode: null,
splitNum: null,
productDate: null,
shiftId: null,
routeCode: null,
}
this.formFields=[]
//
this.splitForm.productDate = new Date()
//
getprodLineShift(row.orderType).then(response => {
this.proline = response.data.lines
this.workShift = response.data.shifts
this.routes = response.data.routes
})
// list
getWorkBatchList(this.selectWork).then(response => {
this.formFields = response.data
console.log("这里是批次数据")
console.log(response.data)
})
//
//
this.proLoading = true // true
this.workerLoading = true // true
getOrderAndWork(this.selectWork).then(response =>{
console.log("这里是返回数据")
console.log(response)
this.splitData.push(response.data.workOrder)
this.productData.push(response.data.order)
this.refreshProTable = false // refreshProTablefalse
this.refreshWorkerTable = false // refreshProTablefalse
this.$nextTick(() => {
// 使$nextTickDOM
this.refreshProTable = true // refreshProTabletrue
this.proLoading = false // false
})
this.$nextTick(() => {
// 使$nextTickDOM
this.refreshWorkerTable = true // refreshProTabletrue
this.workerLoading = false // false
})
//
this.splitForm.splitNum = this.splitData[0].quantitySplit
//
this.splitForm.prodLineCode = this.splitData[0].prodLineCode
//
this.splitForm.shiftId = this.splitData[0].shiftDesc
//
this.splitForm.routeCode = this.splitData[0].routeCode
//
function setAtrr1(order, work) {
order.quantitySplit = Number(order.quantitySplit) - Number(work.quantitySplit);
order.atrr1 = work.quantitySplit;
if (order.children !== undefined && work.children !== undefined) {
setAtrr1(order.children[0], work.children[0]);
}
}
setAtrr1(this.productData[0], this.splitData[0]);
})
// function setAtrr1(order,work) {
// order.quantitySplit = Number(order.quantitySplit) - Number(work.quantitySplit)
// order.atrr1 = work.quantitySplit
// if (order.children !== undefined) {
// setAtrr1(order.children[0],work.children[0])
// }
// }
//
// setAtrr1(this.productData[0],this.splitData[0])
this.open = true;
this.title = "修改生产工单";
},
/**下达工单**/
handleUpdateDown(row) {
handleUpdateDown(row) {
var statusesArray = this.statuses;
for(var i=0; i<statusesArray.length; i++) {
if(statusesArray[i]=='w1'){//
@ -466,25 +793,81 @@ export default {
this.$modal.msgSuccess("下发成功");
}).catch(() => {});
},
/** 提交按钮 */
/** 拆分-提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.workorderId != null) {
updateWorkorder(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addWorkorder(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
//
if (this.splitForm.splitNum == null || this.splitForm.shiftId == null || this.splitForm.prodLineCode == null || this.splitForm.routeCode == null) {
this.$message({
message: '数据不能为空!',
type: 'warning'
})
return
}
if (this.splitForm.routeCode == null) {
this.$message({
message: '数据不能为空!',
type: 'warning'
})
return
}
//
let sum = 0
for (let i = 0; i < this.formFields.length; i++) {
sum = Number(sum) + Number(this.formFields[i].batchQuantity)
if (this.formFields[i].batchQuantity == '' || this.formFields[i].batchQuantity == null || this.formFields[i].batchCode == null || this.formFields[i].batchCode == '') {
this.$message({
message: '批次数据不能为空',
type: 'warning'
})
return
}
}
if (sum != this.productData[0].atrr1) {
this.$message({
message: '批次数量之和不等于拆分数量',
type: 'warning'
})
return
}
//
const data = {
formFields: this.formFields,
prodLineCode: this.workForm.prodLineCode,
productDate: this.splitForm.productDate,
shiftId: this.workForm.shiftId,
splitNum: this.workForm.splitNum,
product: this.productData[0],
routeCode: this.workForm.routeCode,
proOrderWorkorder: this.selectWork
}
subChangeWorkOrder(data).then(response => {
if (response.code == 500) {
this.$modal.msgError(response.msg)
return
}
this.$modal.msgSuccess('提交成功')
})
let id = this.productData[0].id
//
this.splitForm = {
id: null,
prodLineCode: null,
splitNum: null,
productDate: null,
shiftId: null,
formFields: []
}
this.formFields = [{
batchCode: '',
batchQuantity: ''
}]
this.getList()
// 1
this.open = false
},
/** 删除按钮操作 */
handleDelete(row) {
@ -516,4 +899,41 @@ export default {
}
}
};
</script>
</script>
<style>
.el-row {
margin: 0;
padding: 0;
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf;
}
.bg-purple {
background: #d3dce6;
}
.bg-purple-light {
background: #e5e9f2;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
.my-margin {
margin-top: 40px;
margin-bottom: 10px;
}
</style>

Loading…
Cancel
Save