计划管理优化

yangwl
wws 1 year ago
parent a9c306be5a
commit ce081cb573

@ -24,7 +24,6 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="订单编码" prop="orderCode"> <el-form-item label="订单编码" prop="orderCode">
<el-input <el-input
v-model="queryParams.orderCode" v-model="queryParams.orderCode"
@ -103,7 +102,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleUpdateDown" @click="handleUpdateDown"
v-hasPermi="['mes:pro:workorder:edit']" v-hasPermi="['mes:pro:workorder:edit']"
>派发工单</el-button> >派发工单
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -115,7 +115,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['mes:pro:workorder:edit']" v-hasPermi="['mes:pro:workorder:edit']"
>工单变更</el-button> >工单变更
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -126,7 +127,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['mes:pro:workorder:remove']" v-hasPermi="['mes:pro:workorder:remove']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -136,7 +138,8 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['mes:pro:workorder:export']" v-hasPermi="['mes:pro:workorder:export']"
>导出</el-button> >导出
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -147,7 +150,8 @@
size="mini" size="mini"
@click="showPrint" @click="showPrint"
v-hasPermi="['mes:pro:workorder:export']" v-hasPermi="['mes:pro:workorder:export']"
>打印预览</el-button> >打印预览
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -441,18 +445,16 @@
import { import {
getWorkOrders, getWorkOrders,
listWorkorder, listWorkorder,
getWorkorder,
delWorkorder, delWorkorder,
downWorkorder, downWorkorder,
addWorkorder,
updateWorkorder,
getOrderAndWork, getOrderAndWork,
getWorkBatchList, getWorkBatchList,
subChangeWorkOrder, subChangeWorkOrder,
checkWorkOrder checkWorkOrder
} from '@/api/plan/workorder' } from '@/api/plan/workorder'
import moment from 'moment'; import moment from 'moment';
import { getprodLineShift, getProEquipment, getProRoutes, getProShifts } from '@/api/plan/order' import { getProEquipment, getProRoutes, getProShifts} from '@/api/plan/order'
export default { export default {
name: "Workorder", name: "Workorder",
dicts: ['product_type', 'workorder_type', 'shift_type'], dicts: ['product_type', 'workorder_type', 'shift_type'],
@ -598,7 +600,123 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 线 // -
handleUpdateDown(row) {
var statusesArray = this.statuses;
for (var i = 0; i < statusesArray.length; i++) {
if (statusesArray[i] == 'w1') {//
this.$modal.msgError("已经下达的订单不允许操作");
return
}
}
const workorderIds = row.workorderCode || this.codes;
this.$modal.confirm('是否确认下发生产工单编号为"' + workorderIds + '"的数据项?').then(function () {
return downWorkorder(workorderIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("下发成功");
}).catch(() => {
});
},
// -
handleUpdate(row) {
//
checkWorkOrder(this.selectWork.workorderId).then(response => {
if (response.code == 500) {
this.$message({
message: '工单已生产,不可变更!',
type: 'warning'
})
return;
} else {
//
this.reset();
this.splitData = [];
this.productData = [];
this.splitForm = {
prodLineCodeArray: [],
splitNum: null,
productDate: null,
shiftId: null,
routeCode: null,
}
this.formFields = []
//
this.splitForm.productDate = new Date()
//
getProShifts().then(response => {
this.workShift = response.data
})
//
getProRoutes(this.selectWork.productCode).then(response => {
this.routes = response.data
getProEquipment(this.selectWork.routeCode).then(response => {
this.proline = response.data
})
})
//
getProEquipment(this.selectWork.routeCode).then(response2 => {
this.eRouteOptions = response2.data
})
// list
getWorkBatchList(this.selectWork).then(response => {
this.formFields = response.data
})
//
//
this.proLoading = true // true
this.workerLoading = true // true
getOrderAndWork(this.selectWork).then(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.prodLineCodeArray = response.data.workOrder.prodLineCodeArray
//
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]);
})
this.open = true;
this.title = "修改生产工单";
}
})
},
// -线
changeEquipment() { changeEquipment() {
if (this.splitForm.routeCode == null) { if (this.splitForm.routeCode == null) {
this.$message({ this.$message({
@ -608,43 +726,69 @@ export default {
return return
} }
}, },
// // -
handlePrint(params) { routeChange(e) {
printJS({ getProEquipment(e).then(response => {
printable: params.printable, // 'printFrom', // id this.eRouteOptions = response.data
type: params.type || 'html',
maxWidth: 1500, //
font_size: "",//
header: params.header, // '',
targetStyles: ['*'],
style: '@page {margin:0 10mm};', // -
ignoreElements: params.ignore || [], // ['no-print']
properties: params.properties || null
}) })
this.workForm.routeCode = e
}, },
// // -
showPrint() { shiftChange(e) {
// this.workForm.shiftId = e
this.printData.workCenter = "暂无数据"; },
this.printData.printDate = null; // -
this.printData.workTable = []; splitNumChange(e) {
this.printData.factory = null; //
this.printData.productDate = null; if (e <= 0) {
// e = 1
this.printDialogVisible = true; this.splitForm.splitNum = 1
this.printData.printDate = moment(new Date()).format('YYYY.MM.DD'); } else {
this.printData.manufacture = this.$store.state.user.name; //
this.newWorkerLoading = true // true let max = Number(this.productData[0].quantity) - Number(this.productData[0].quantitySplit)
this.refreshNewWorkerTable = false // refreshProTablefalse //
getWorkOrders(this.selectWork.workorderCode).then(response => { if (e > max) {
this.printData.workTable = response.data; this.$message({
this.printData.factory = response.data[0].factoryCode; message: '最大值不能超过' + max + '!',
this.printData.productDate = response.data[0].productDate; type: 'warning'
this.refreshNewWorkerTable = true // refreshProTabletrue })
this.newWorkerLoading = false // false 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) {
this.workForm.productDate = e
}, },
/** 动态添加表单 */ // -
addField() { addField() {
// //
let sum = 0 let sum = 0
@ -664,11 +808,11 @@ export default {
// //
this.formFields[this.formFields.length - 1].batchQuantity = Number(this.productData[0].atrr1) - Number(sum) this.formFields[this.formFields.length - 1].batchQuantity = Number(this.productData[0].atrr1) - Number(sum)
}, },
/** 动态删除表单 */ // -
removeField(index) { removeField(index) {
this.formFields.splice(index, 1) this.formFields.splice(index, 1)
}, },
/** 填写批次数量 */ // -
inBatch(e) { inBatch(e) {
// //
if (e <= 0) { if (e <= 0) {
@ -695,7 +839,7 @@ export default {
this.formFields[this.formFields.length - 1].batchQuantity = '' this.formFields[this.formFields.length - 1].batchQuantity = ''
} }
}, },
/** 检验批次编码是否重复 */ // -
batchCodeChange(e) { batchCodeChange(e) {
if (this.formFields.length > 1) { if (this.formFields.length > 1) {
for (let i = 0; i < this.formFields.length - 1; i++) { for (let i = 0; i < this.formFields.length - 1; i++) {
@ -713,69 +857,135 @@ export default {
} }
} }
}, },
/** 更改工艺 */ // -
routeChange(e){ submitForm() {
getProEquipment(e).then(response => { //
this.eRouteOptions = response.data let sum = 0
}) for (let i = 0; i < this.formFields.length; i++) {
this.workForm.routeCode = e 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 == '') {
/** 更改班次 */
shiftChange(e){
this.workForm.shiftId = e
},
/** 拆分数量 */
splitNumChange(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({ this.$message({
message: '最大值不能超过' + max + '!', message: '批次数据不能为空',
type: 'warning' type: 'warning'
}) })
this.splitForm.splitNum = max return
}
//
//
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)
} }
} }
if (sum != this.productData[0].atrr1) {
this.$message({
message: '批次数量之和不等于拆分数量',
type: 'warning'
})
return
} }
this.productData[0].atrr1 = this.splitForm.splitNum if (this.workForm.prodLineCode === undefined) {
setAtrr1(this.productData[0], this.splitForm.splitNum) this.workForm.prodLineCode = this.selectWork.prodLineName
}
this.refreshProTable = false // refreshProTablefalse //
this.$nextTick(() => { const data = {
// 使$nextTickDOM formFields: this.formFields,
this.refreshProTable = true // refreshProTabletrue prodLineCodeArray: this.splitForm.prodLineCodeArray,
this.proLoading = false // false 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.getList()
this.$modal.msgSuccess('提交成功')
}) })
this.workForm.splitNum = this.splitForm.splitNum let id = this.productData[0].id
//
this.splitForm = {
id: null,
prodLineCodeArray: [],
splitNum: null,
productDate: null,
shiftId: null,
formFields: []
} }
this.product = this.productData[0] this.formFields = [{
}, batchCode: '',
/** 工单日期选择 */ batchQuantity: ''
checkDate(e){ }]
this.workForm.productDate = e this.open = false
}, },
// -
handleDelete(row) {
/** 查询生产工单列表 */ var statusesArray = this.statuses;
for (var i = 0; i < statusesArray.length; i++) {
if (statusesArray[i] == 'w1') {//
this.$modal.msgError("已经下达的订单不允许操作");
return
}
}
const workorderIds = row.workorderId || this.ids;
const workorderCodes = row.workorderCode || this.codes;
this.$modal.confirm('是否确认删除生产工单编号为"' + workorderCodes + '"的数据项?').then(function () {
return delWorkorder(workorderIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
// -list
handleExport() {
this.download('plan/pro/workorder/export', {
...this.queryParams
}, `workorder_${new Date().getTime()}.xlsx`)
},
// -
handlePrint(params) {
printJS({
printable: params.printable, // 'printFrom', // id
type: params.type || 'html',
maxWidth: 1500, //
font_size: "",//
header: params.header, // '',
targetStyles: ['*'],
style: '@page {margin:0 10mm};', // -
ignoreElements: params.ignore || [], // ['no-print']
properties: params.properties || null
})
},
// -
showPrint() {
//
this.printData.workCenter = "暂无数据";
this.printData.printDate = null;
this.printData.workTable = [];
this.printData.factory = null;
this.printData.productDate = null;
//
this.printDialogVisible = true;
this.printData.printDate = moment(new Date()).format('YYYY.MM.DD');
this.printData.manufacture = this.$store.state.user.name;
this.newWorkerLoading = true // true
this.refreshNewWorkerTable = false // refreshProTablefalse
getWorkOrders(this.selectWork.workorderCode).then(response => {
this.printData.workTable = response.data;
this.printData.factory = response.data[0].factoryCode;
this.printData.productDate = response.data[0].productDate;
this.refreshNewWorkerTable = true // refreshProTabletrue
this.newWorkerLoading = false // false
})
},
// -
getList() { getList() {
this.loading = true; this.loading = true;
this.queryParams.endFlag = '1';// this.queryParams.endFlag = '1';//
@ -795,7 +1005,7 @@ export default {
this.open = false; this.open = false;
this.reset(); this.reset();
}, },
// // -
reset() { reset() {
this.form = { this.form = {
workorderId: null, workorderId: null,
@ -833,17 +1043,17 @@ export default {
}; };
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ // -
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getList(); this.getList();
}, },
/** 重置按钮操作 */ // -
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
// // -
handleSelectionChange(selection) { handleSelectionChange(selection) {
// -- // --
this.selectWork = selection[0] this.selectWork = selection[0]
@ -854,226 +1064,12 @@ export default {
this.multiple = !selection.length this.multiple = !selection.length
this.statuses = selection.map(item => item.status) this.statuses = selection.map(item => item.status)
}, },
/** 新增按钮操作 */ // -
handleAdd() { handleAdd() {
alert("待建设") alert("待建设")
//this.reset(); //this.reset();
//this.open = true; //this.open = true;
//this.title = ""; //this.title = "";
},
/** 修改按钮操作 */
handleUpdate(row) {
// ()
//if (this.selectWork.status == "w1"){
// this.$message({
// message:'',
// type:'warning'
// })
// return;
//}
//
checkWorkOrder(this.selectWork.workorderId).then(response => {
if (response.code == 500){
this.$message({
message:'该工单已有湿料计划,不可修改!',
type:'warning'
})
return;
}else {
//
this.reset();
this.splitData = [];
this.productData =[];
this.splitForm={
prodLineCodeArray: [],
splitNum: null,
productDate: null,
shiftId: null,
routeCode: null,
}
this.formFields=[]
//
this.splitForm.productDate = new Date()
//
getProShifts().then(response => {
this.workShift = response.data
})
//
getProRoutes(this.selectWork.productCode).then(response => {
this.routes = response.data
getProEquipment(this.selectWork.routeCode).then(response => {
this.proline = response.data
})
})
//
getProEquipment(this.selectWork.routeCode).then(response2 => {
this.eRouteOptions = response2.data
})
// list
getWorkBatchList(this.selectWork).then(response => {
this.formFields = response.data
})
//
//
this.proLoading = true // true
this.workerLoading = true // true
getOrderAndWork(this.selectWork).then(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.prodLineCodeArray = response.data.workOrder.prodLineCodeArray
//
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]);
})
this.open = true;
this.title = "修改生产工单";
}
})
},
/**下达工单**/
handleUpdateDown(row) {
var statusesArray = this.statuses;
for(var i=0; i<statusesArray.length; i++) {
if(statusesArray[i]=='w1'){//
this.$modal.msgError("已经下达的订单不允许操作");
return
}
}
const workorderIds = row.workorderCode || this.codes;
this.$modal.confirm('是否确认下发生产工单编号为"' + workorderIds + '"的数据项?').then(function() {
return downWorkorder(workorderIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("下发成功");
}).catch(() => {});
},
/** 拆分-提交按钮 */
submitForm() {
//
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
}
if (this.workForm.prodLineCode === undefined) {
this.workForm.prodLineCode = this.selectWork.prodLineName
}
//
const data = {
formFields: this.formFields,
prodLineCodeArray: this.splitForm.prodLineCodeArray,
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.getList()
this.$modal.msgSuccess('提交成功')
})
let id = this.productData[0].id
//
this.splitForm = {
id: null,
prodLineCodeArray: [],
splitNum: null,
productDate: null,
shiftId: null,
formFields: []
}
this.formFields = [{
batchCode: '',
batchQuantity: ''
}]
this.open = false
},
/** 删除按钮操作 */
handleDelete(row) {
var statusesArray = this.statuses;
for(var i=0; i<statusesArray.length; i++) {
if(statusesArray[i]=='w1'){//
this.$modal.msgError("已经下达的订单不允许操作");
return
}
}
const workorderIds = row.workorderId || this.ids;
const workorderCodes = row.workorderCode || this.codes;
this.$modal.confirm('是否确认删除生产工单编号为"' + workorderCodes + '"的数据项?').then(function() {
return delWorkorder(workorderIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('plan/pro/workorder/export', {
...this.queryParams
}, `workorder_${new Date().getTime()}.xlsx`)
} }
} }
}; };
@ -1114,17 +1110,21 @@ export default {
margin-top: 40px; margin-top: 40px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.my-print-head { .my-print-head {
margin-top: 20px; margin-top: 20px;
font-weight: bold; font-weight: bold;
} }
.my-print-nav { .my-print-nav {
margin-top: 15px; margin-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
.my-print-table { .my-print-table {
} }
.my-print-foot { .my-print-foot {
margin-top: 20px; margin-top: 20px;
} }

Loading…
Cancel
Save