<template>
|
<el-dialog
|
width="65%"
|
title="自动车间订单"
|
top="5vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
class="part-dialog"
|
:close-on-click-modal="false"
|
>
|
<div>
|
<div style="margin-bottom:20px;">
|
<div>
|
<el-table
|
:data="requiredTable"
|
border
|
style="width: 100%"
|
height="400"
|
>
|
<el-table-column
|
type="index"
|
label="序号"
|
width="50"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partNo"
|
label="零件号"
|
width="120"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
label="零件描述"
|
width="120"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="quantity"
|
label="计划需求数量"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="releasedQuantity"
|
label="已下达数量"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="workshopTypeCode"
|
label="车间订单类型"
|
width="150"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.workshopTypeCode"
|
placeholder=""
|
style="width:100%"
|
@change="(val) => changeWorkshopTypeCode(val, scope.$index)"
|
>
|
<el-option
|
v-for="(item, index) in bomTypeDbOptions"
|
:label="item.label"
|
:value="item.value"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="workShop"
|
label="车间"
|
width="150"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.workShop"
|
placeholder=""
|
style="width:100%"
|
@change="(val) => changeWorkShop(val, scope.$index)"
|
>
|
<el-option
|
v-for="item in workShopOptions"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="orderQuantity"
|
label="订单需求数量"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.orderQuantity"
|
placeholder=""
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="requiredDate"
|
label="订单需求日期"
|
width="195"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-date-picker
|
:clearable="false"
|
v-model="scope.row.requiredDate"
|
style="width: 100%"
|
type="datetime"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
@change="(val) => changeRequiredDate(val, scope.$index)"
|
>
|
</el-date-picker>
|
</template>
|
</el-table-column>
|
<el-table-column prop="unit" label="计量单位" align="center">
|
</el-table-column>
|
<el-table-column
|
prop="manufactureAttr"
|
label="制造属性"
|
width="150"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.manufactureAttr"
|
placeholder=""
|
style="width:100%"
|
disabled
|
>
|
<el-option
|
v-for="item in manufactureAttrs"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<!-- <el-table-column
|
prop="isReportOperation"
|
label="IFS车间订单接收时报告工序"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.isReportOperation ? '是' : '否' }}</span>
|
</template>
|
</el-table-column> -->
|
</el-table>
|
</div>
|
</div>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button type="primary" :disabled="isSubmit" v-thinclick="`createOrder`"
|
>创建订单</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import { remote } from '@/api/admin/dict'
|
import { getTheoryQuantity } from '@/api/plan/masterproductionschedule'
|
import { addBatch } from '@/api/plan/manufacturingorder'
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
masterProduction: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
},
|
isReportOperation: {
|
type: Boolean,
|
default: false
|
},
|
outPutBatchList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
},
|
qtyPlaned: {
|
type: Number,
|
default: 0
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
isSubmit: false,
|
requiredTable: [],
|
workShopOptions: [],
|
bomTypeDbOptions: [],
|
manufactureAttrs: []
|
}
|
},
|
created() {
|
this.getWorkShopOptions()
|
this.getBomTypeDbOptions()
|
this.getManufactureAttrs('manufacture_attr_type')
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.requiredTable = []
|
this.$nextTick(() => {
|
// 查询需要自动创建车间订单的零件列表
|
getTheoryQuantity(
|
this.masterProduction.id,
|
this.outPutBatchList
|
).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const theories = resData.data
|
if (theories.length > 0) {
|
let requiredItem
|
theories.forEach((item) => {
|
requiredItem = {
|
partId: item.partId,
|
partNo: item.partNo,
|
partName: item.partName,
|
routingId: item.routingId,
|
bomId: item.bomId,
|
orderQuantity: item.orderQuantity,
|
quantity: item.quantity,
|
releasedQuantity: item.releasedQuantity,
|
unit: item.unit,
|
workShop: null,
|
workshopTypeCode: 'M',
|
requiredDate: this.masterProduction.requiredDate,
|
id: item.id,
|
manufactureAttr: this.masterProduction.manufactureAttr,
|
isReportOperation: this.isReportOperation
|
}
|
this.requiredTable.push(requiredItem)
|
})
|
}
|
}
|
})
|
})
|
}
|
}
|
},
|
methods: {
|
getManufactureAttrs(type) {
|
remote(type).then((response) => {
|
const code = response.data.code
|
if (code === 0) {
|
const _data = response.data.data
|
this.manufactureAttrs = _data
|
}
|
})
|
},
|
createOrder() {
|
this.isSubmit = true
|
// 校验数据字段
|
let checkFlag = true
|
let checkMsg = ''
|
this.requiredTable.forEach((item, index) => {
|
if (item.workShop == null || item.workShop == '') {
|
checkFlag = false
|
checkMsg = checkMsg + '第' + (index + 1) + '行,车间不能为空;'
|
}
|
if (item.requiredDate == null || item.requiredDate == '') {
|
checkFlag = false
|
checkMsg =
|
checkMsg + '第' + (index + 1) + '行,订单需求日期不能为空;'
|
}
|
if (item.orderQuantity == null || item.orderQuantity == '') {
|
checkFlag = false
|
checkMsg =
|
checkMsg + '第' + (index + 1) + '行,订单需求数量不能为空;'
|
} else {
|
if (!this.checkZero(item.orderQuantity)) {
|
checkFlag = false
|
checkMsg =
|
checkMsg + '第' + (index + 1) + '行,订单需求数量不能为0;'
|
} else {
|
if (!this.checkPositive(item.orderQuantity)) {
|
checkFlag = false
|
checkMsg =
|
checkMsg + '第' + (index + 1) + '行,订单需求数量需为正数;'
|
} else {
|
if (!this.checkDecimal(item.orderQuantity)) {
|
checkFlag = false
|
checkMsg =
|
checkMsg +
|
'第' +
|
(index + 1) +
|
'行,订单需求数量最多六位小数;'
|
}
|
}
|
}
|
}
|
})
|
if (checkFlag) {
|
// 提交,创建车间订单
|
// addBatch()
|
const orderList = []
|
this.requiredTable.forEach((item) => {
|
orderList.push({
|
mpsId: this.masterProduction.id,
|
partId: item.partId,
|
partNo: item.partNo,
|
partName: item.partName,
|
technologyRoutingId: item.routingId,
|
bomId: item.bomId,
|
qtyRequired: item.orderQuantity,
|
requiredDate: item.requiredDate,
|
workShop: item.workShop,
|
workshopTypeCode: item.workshopTypeCode,
|
scheduleTheoryQuantityId: item.id,
|
manufactureAttr: item.manufactureAttr,
|
isReportOperation: item.isReportOperation,
|
outPutBatchList: this.outPutBatchList
|
})
|
})
|
addBatch(orderList)
|
.then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.$message.success('自动创建车间订单成功')
|
this.innerVisible = false
|
this.$emit('refreshDataList')
|
} else {
|
this.$message.error('自动创建车间订单失败')
|
}
|
this.isSubmit = false
|
})
|
.catch(() => {
|
this.isSubmit = false
|
})
|
} else {
|
this.$message.error(checkMsg)
|
this.isSubmit = false
|
}
|
},
|
checkZero(value) {
|
if (value == 0) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkPositive(value) {
|
if (!/^[0-9]+.?[0-9]*$/.test(value)) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkDecimal(value) {
|
if (
|
!/(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]{1,6}$)/.test(
|
value
|
)
|
) {
|
return false
|
} else {
|
return true
|
}
|
},
|
changeWorkshopTypeCode(val, param) {
|
if (param === 0) {
|
this.requiredTable.forEach((item) => {
|
item.workshopTypeCode = val
|
})
|
}
|
},
|
changeWorkShop(val, param) {
|
if (param === 0) {
|
this.requiredTable.forEach((item) => {
|
item.workShop = val
|
})
|
}
|
},
|
changeRequiredDate(val, param) {
|
if (param === 0) {
|
this.requiredTable.forEach((item) => {
|
item.requiredDate = val
|
})
|
}
|
},
|
// 查询结构类型字典
|
getBomTypeDbOptions() {
|
remote('bom_type_db').then((response) => {
|
if (response.data.code === 0) {
|
this.bomTypeDbOptions = response.data.data
|
} else {
|
this.bomTypeDbOptions = []
|
}
|
})
|
},
|
getWorkShopOptions() {
|
remote('work_shop').then((response) => {
|
if (response.data.code === 0) {
|
this.workShopOptions = response.data.data
|
} else {
|
this.workShopOptions = []
|
}
|
})
|
}
|
}
|
}
|
</script>
|
<style scoped></style>
|