<template>
|
<el-dialog
|
top="5vh"
|
:fullscreen="isFullScreen"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
append-to-body
|
>
|
<template slot="title">
|
<i
|
:class="isFullScreen ? 'icon-zuixiaohua' : 'icon-quanpingzuidahua'"
|
style="position: absolute; right: 52px; float: right"
|
@click="fullscreen"
|
>
|
</i>
|
<span>{{ !dataForm.id ? '新增' : '修改' }}</span>
|
</template>
|
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
@keyup.enter.native="dataFormSubmit()"
|
label-width="100px"
|
class="l-mes"
|
:disabled="!editable"
|
>
|
<el-tabs type="border-card" ref="tabs">
|
<el-tab-pane label="主要">
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="工厂" prop="factoryId">
|
<el-select
|
v-model="dataForm.factoryId"
|
filterable
|
placeholder=""
|
style="width:100%"
|
>
|
<el-option
|
v-for="item in this.factoryOptions"
|
:key="item.id"
|
:label="item.factoryName"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="零件" prop="partId">
|
<el-input v-model="partStr" placeholder="" readonly>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openRoutingDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="需求数量" prop="qtyRequired">
|
<el-input
|
v-model="dataForm.qtyRequired"
|
placeholder=""
|
@change="checkNumber()"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="需求日期" prop="requiredDate">
|
<el-date-picker
|
v-model="dataForm.requiredDate"
|
style="width: 100%"
|
type="datetime"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
@change="checkDate()"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="dataForm.remark" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
|
<el-tab-pane label="工艺路线">
|
<!-- 之后把工艺界面嵌入进来 -->
|
|
<el-row :gutter="10">
|
<el-col :span="8">
|
<el-form-item label="工艺路线号">
|
<el-select
|
@change="routingSelectChanged"
|
v-model="dataForm.technologyRoutingId"
|
placeholder=""
|
>
|
<el-option
|
v-for="item in dataForm.routingList"
|
:key="item.id"
|
:label="item.routingNo"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="4">
|
<el-form-item label-width="0px">
|
<el-checkbox v-model="currentRouting.master" disabled
|
>默认工艺路线</el-checkbox
|
>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="工艺路线备注">
|
<el-input
|
v-model="currentRouting.description"
|
placeholder=""
|
disabled
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-table
|
:data="operations"
|
border
|
style="width: 100%"
|
height="240px"
|
highlight-current-row
|
:default-sort="{ prop: 'index' }"
|
>
|
<el-table-column type="selection" width="55" fixed="left" />
|
<el-table-column prop="index" label="序号"></el-table-column>
|
<el-table-column
|
prop="operationNo"
|
header-align="center"
|
align="center"
|
label="工序号"
|
/>
|
<el-table-column
|
prop="operationName"
|
header-align="center"
|
align="center"
|
label="工序描述"
|
/>
|
<el-table-column
|
prop="remark"
|
header-align="center"
|
align="center"
|
label="备注"
|
/>
|
</el-table>
|
</el-row>
|
</el-tab-pane>
|
|
<el-tab-pane label="产品结构">
|
<el-row :gutter="10">
|
<el-col :span="11">
|
<el-form-item label="产品结构号">
|
<el-select
|
@change="structureSelectChanged"
|
v-model="dataForm.technologyStructureId"
|
placeholder=""
|
>
|
<el-option
|
v-for="item in dataForm.structureList"
|
:key="item.id"
|
:label="item.structureType"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="11">
|
<el-form-item label="产品结构备注">
|
<el-input
|
v-model="currentStructure.remark"
|
placeholder=""
|
disabled
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="2" style="text-align: center">
|
<el-form-item label-width="0px">
|
<el-button
|
type="success"
|
plain
|
circle
|
icon="el-icon-plus"
|
@click="addOrUpdateHandle()"
|
></el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-table
|
:data="components"
|
border
|
style="width: 100%"
|
height="240px"
|
:default-sort="{ prop: 'index' }"
|
>
|
<el-table-column type="selection" width="40" fixed="left" />
|
<el-table-column
|
type="index"
|
width="60"
|
header-align="center"
|
align="center"
|
label="行项号"
|
/>
|
<el-table-column
|
prop="operationNo"
|
width="60"
|
header-align="center"
|
align="center"
|
label="工序号"
|
/>
|
<el-table-column
|
prop="operationName"
|
width="80"
|
header-align="center"
|
align="center"
|
label="工序描述"
|
/>
|
<el-table-column
|
prop="partNo"
|
width="80"
|
header-align="center"
|
align="center"
|
label="零件号"
|
/>
|
<el-table-column
|
prop="partName"
|
width="80"
|
header-align="center"
|
align="center"
|
label="零件"
|
/>
|
<el-table-column
|
prop="qpa"
|
width="120"
|
header-align="center"
|
align="center"
|
label="单位产出所需数量"
|
/>
|
<el-table-column
|
prop="total"
|
width="80"
|
header-align="center"
|
align="center"
|
label="需求总量"
|
>
|
<template slot-scope="scope">
|
{{ mul(scope.row.qpa, dataForm.qtyRequired) }}
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="remark"
|
width=""
|
header-align="center"
|
align="center"
|
label="备注"
|
/>
|
<el-table-column
|
header-align="center"
|
align="center"
|
label="操作"
|
fixed="right"
|
width="130"
|
>
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="small"
|
icon="el-icon-edit"
|
@click="addOrUpdateHandle(scope.row, scope.$index)"
|
>修改
|
</el-button>
|
<el-button
|
type="text"
|
size="small"
|
icon="el-icon-delete"
|
@click="deleteRow(scope.$index, components)"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-row>
|
</el-tab-pane>
|
|
<el-tab-pane label="产出批次" v-if="dataForm.id">
|
<el-row :gutter="10">
|
<el-table
|
:data="dataForm.outBatchList"
|
border
|
style="width: 100%"
|
height="250px"
|
>
|
<el-table-column type="selection" width="55" fixed="left" />
|
<el-table-column
|
prop="partNo"
|
header-align="center"
|
align="center"
|
label="零件号"
|
/>
|
<el-table-column
|
prop="partDescription"
|
header-align="center"
|
align="center"
|
label="零件名称"
|
/>
|
<el-table-column
|
prop="batchNo"
|
header-align="center"
|
align="center"
|
label="批次号"
|
/>
|
<el-table-column
|
prop="batchQty"
|
header-align="center"
|
align="center"
|
label="需求总量"
|
/>
|
<el-table-column
|
prop="canBeSplited"
|
header-align="center"
|
align="center"
|
label="允许拆分"
|
>
|
<template slot-scope="scope">
|
<el-checkbox
|
v-model="scope.row.canBeSplited"
|
onclick="return false"
|
></el-checkbox>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="canBeMerged"
|
header-align="center"
|
align="center"
|
label="允许合并"
|
>
|
<template slot-scope="scope">
|
<el-checkbox
|
v-model="scope.row.canBeMerged"
|
onclick="return false"
|
></el-checkbox>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="remark"
|
header-align="center"
|
align="center"
|
label="备注"
|
/>
|
</el-table>
|
</el-row>
|
</el-tab-pane>
|
</el-tabs>
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button type="primary" @click="dataFormSubmit()" v-if="editable"
|
>确定</el-button
|
>
|
</span>
|
|
<!-- 结构组件弹窗, 新增 / 修改 -->
|
<component-form
|
v-if="addOrUpdateVisible"
|
ref="addOrUpdate"
|
></component-form>
|
<routingDialog
|
:currshowlist.sync="showRouting"
|
:queryParam="queryParam"
|
@listenToRoutingEvent="selectRouting"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {
|
getManufacturingOrder,
|
addManufacturingOrder,
|
putManufacturingOrder,
|
checkPart
|
} from '@/api/plan/manufacturingorder'
|
import { loadFactoryList } from '@/api/basic/factory'
|
import { getObj } from '@/api/technology/routing'
|
import { getObj as getStructure } from '@/api/technology/structure'
|
import ComponentForm from './structurecomponent-form'
|
import { validateSixDecimalNotNull } from '@/util/validate'
|
import { highPrecisionMul } from '@/util/highPrecision'
|
import routingDialog from './routing'
|
export default {
|
components: {
|
ComponentForm,
|
routingDialog
|
},
|
data() {
|
return {
|
state: '',
|
numberState: false,
|
dateState: false,
|
queryParam: {},
|
showRouting: false,
|
isFullScreen: false,
|
addOrUpdateVisible: false,
|
visible: false,
|
showPart: false,
|
dataForm: {
|
id: 0,
|
factoryId: '',
|
moNo: '',
|
partName: '',
|
partNo: '',
|
partId: '',
|
qtyRequired: '',
|
requiredDate: '',
|
remark: '',
|
technologyRoutingId: null,
|
technologyStructureId: null,
|
routingList: [],
|
structureList: [],
|
outBatchList: [],
|
componentList: []
|
},
|
currentRouting: {}, // 当前选择的工艺
|
operations: [], // 当前选择工艺对应的工序
|
currentStructure: {}, // 当前选择的产品结构
|
components: [], // 当前选择产品结构对应的结构组件
|
factoryOptions: [],
|
dataRule: {
|
factoryId: [
|
{ required: true, message: '工厂不能为空', trigger: 'blur' }
|
],
|
partId: [{ required: true, message: '零件不能为空', trigger: 'blur' }],
|
qtyRequired: [
|
{ required: true, message: '需求数量不能为空', trigger: 'blur' },
|
{ validator: validateSixDecimalNotNull, trigger: 'blur' }
|
],
|
requiredDate: [
|
{ required: true, message: '需求日期不能为空', trigger: 'blur' }
|
]
|
}
|
}
|
},
|
created() {
|
this.initFactorySelect()
|
},
|
watch: {
|
'dataForm.partId'(newValue, oldValue) {
|
if (this.dataForm.id) {
|
if (oldValue != '' && newValue != oldValue && newValue != '') {
|
this.getFacturing(newValue)
|
}
|
} else {
|
if (newValue != oldValue) {
|
this.getFacturing(newValue)
|
}
|
}
|
},
|
|
currentRouting(newValue, oldValue) {
|
if (newValue && newValue.id) {
|
// 查询工艺对应的工序
|
getObj(newValue.id).then((response) => {
|
if (response.data.data) {
|
this.operations = response.data.data.operations
|
}
|
})
|
}
|
},
|
currentStructure(newValue, oldValue) {
|
if (newValue && newValue.id) {
|
// 查询产品结构对应的组件
|
getStructure(newValue.id).then((response) => {
|
if (
|
this.dataForm.technologyStructureId &&
|
this.dataForm.componentList &&
|
this.dataForm.componentList.length > 0
|
) {
|
this.components = this.dataForm.componentList
|
} else {
|
if (response.data.data) {
|
this.components = response.data.data.components
|
}
|
}
|
})
|
}
|
}
|
},
|
computed: {
|
partStr: function() {
|
return this.dataForm.partId
|
? this.dataForm.partName +
|
' ' +
|
(this.dataForm.partNo ? this.dataForm.partNo : '')
|
: ''
|
},
|
editable: function() {
|
if (!this.dataForm.id) {
|
return true
|
}
|
if (this.dataForm.id && this.state == '01planned') {
|
return true
|
}
|
if (this.dataForm.id && this.state == '02issued') {
|
return true
|
}
|
return false
|
}
|
},
|
methods: {
|
init(id, state, part) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.state = state
|
this.$nextTick(() => {
|
this.clearData()
|
if (this.dataForm.id) {
|
getManufacturingOrder(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
// 把工艺挂上去
|
if (
|
this.dataForm.technologyRoutingId &&
|
this.dataForm.routingList &&
|
this.dataForm.routingList.length > 0
|
) {
|
var currentRouting = this.dataForm.routingList.find(
|
(item) => item.id == this.dataForm.technologyRoutingId
|
)
|
if (currentRouting) {
|
this.currentRouting = currentRouting
|
this.dataForm.technologyRoutingId = this.currentRouting.id
|
}
|
}
|
// 把产品结构组件挂上去
|
if (
|
this.dataForm.technologyStructureId &&
|
this.dataForm.componentList &&
|
this.dataForm.componentList.length > 0
|
) {
|
this.components = this.dataForm.componentList
|
}
|
})
|
} else {
|
this.$refs.tabs.currentName = '0'
|
if (part) {
|
this.dataForm = part
|
}
|
}
|
})
|
},
|
// 根据零件号去获取制造订单对应的数据
|
getFacturing(value) {
|
checkPart(value)
|
.then((response) => {
|
var manufacturingOrderDTO = response.data.data
|
this.dataForm.routingList = manufacturingOrderDTO.routingList
|
this.dataForm.structureList = manufacturingOrderDTO.structureList
|
this.dataForm.technologyRoutingId =
|
manufacturingOrderDTO.technologyRoutingId
|
if (manufacturingOrderDTO.technologyRoutingId) {
|
this.routingSelectChanged(manufacturingOrderDTO.technologyRoutingId)
|
} else {
|
this.operations = []
|
}
|
this.dataForm.technologyStructureId =
|
manufacturingOrderDTO.technologyStructureId
|
if (manufacturingOrderDTO.technologyStructureId) {
|
this.structureSelectChanged(
|
manufacturingOrderDTO.technologyStructureId
|
)
|
} else {
|
this.components = []
|
}
|
})
|
.catch((e) => {
|
this.operations = []
|
this.components = []
|
this.dataForm.technologyRoutingId = null
|
this.dataForm.routingList = []
|
this.dataForm.structureList = []
|
this.dataForm.technologyStructureId = null
|
})
|
},
|
// 需求数量与订单需求数量的比较
|
checkNumber() {
|
if (this.dataForm.qtyRequired > this.dataForm.qtyProductionRequired) {
|
this.$message.error('需求数量大于订单需求数量')
|
this.numberState = true
|
} else {
|
this.numberState = false
|
}
|
},
|
checkDate() {
|
if (this.dataForm.requiredDate > this.dataForm.requiredProductionDate) {
|
this.$message.error('制造订单需求日期大于主生产计划需求日期')
|
this.dateState = true
|
} else {
|
this.dateState = false
|
}
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
this.dataForm.componentList = this.components
|
if (this.numberState) {
|
this.$message.error('需求数量大于订单需求数量')
|
return
|
}
|
if (this.dateState) {
|
this.$message.error('制造订单需求日期大于主生产计划需求日期')
|
return
|
}
|
if (this.dataForm.id) {
|
putManufacturingOrder(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
})
|
} else {
|
addManufacturingOrder(this.dataForm).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
})
|
}
|
}
|
})
|
},
|
// 1.tabs-主要
|
// 零件选择
|
openRoutingDialog() {
|
this.showRouting = true
|
},
|
selectRouting(param) {
|
if (param) {
|
this.dataForm.partNo = param.partNo
|
this.dataForm.partName = param.partName
|
this.dataForm.partId = param.partId
|
this.$refs.dataForm.validateField('partId', (valid) => {})
|
}
|
},
|
// 获取工厂的数据
|
initFactorySelect() {
|
loadFactoryList().then((res) => {
|
this.factoryOptions = res.data
|
})
|
},
|
// 2.tabs-工艺路线
|
// 工艺路线选择
|
routingSelectChanged(routingId) {
|
this.currentRouting = this.dataForm.routingList.find(
|
(item) => item.id === routingId
|
)
|
},
|
// 产品结构选择
|
structureSelectChanged(structureId) {
|
// ********这边默认选择产品结构组件的表,而不是使用制造订单的备份组件表********
|
this.currentStructure = this.dataForm.structureList.find(
|
(item) => item.id === structureId
|
)
|
},
|
// 3.tabs-产品结构
|
// 新增 / 修改
|
addOrUpdateHandle(row, index) {
|
this.addOrUpdateVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdate.init(row, index, this.components)
|
})
|
},
|
// 删除
|
deleteRow(index, rows) {
|
rows.splice(index, 1)
|
},
|
// 精度计算需求总量
|
mul(a, b) {
|
if (!b) {
|
return
|
}
|
return highPrecisionMul(a, b)
|
},
|
// 4.其他辅助方法
|
// 全屏
|
fullscreen() {
|
this.isFullScreen = !this.isFullScreen
|
},
|
// 清数据
|
clearData() {
|
this.$refs.dataForm.resetFields()
|
this.currentRouting = {}
|
this.currentStructure = {}
|
this.operations = []
|
this.components = []
|
this.dataForm.routingList = []
|
this.dataForm.structureList = []
|
this.dataForm.technologyRoutingId = null
|
this.dataForm.technologyStructureId = null
|
}
|
}
|
}
|
</script>
|