<template>
|
<el-dialog
|
:title=" type ?'修改节点': '新增节点' "
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
append-to-body>
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px" class="l-mes">
|
<el-row :gutter="10">
|
<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="openPartDialog()"></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="数量" prop="qpa">
|
<el-input v-model="dataForm.qpa" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
</span>
|
|
<part-dialog :currshowlist.sync="showPart" @listenToPartEvent="selectPart"/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {insertMpsStructureComponent, updateMpsStructureComponent} from '@/api/plan/masterproductionschedule'
|
import {validateSixDecimalNotNull} from '@/util/validate'
|
import PartDialog from '@/views/common/part'
|
|
export default {
|
components: {
|
PartDialog
|
},
|
data() {
|
return {
|
visible: false,
|
showPart: false,
|
mpsId: 0,
|
type: 0,
|
dataForm: {
|
qpa: '',
|
label: '',
|
partNo: '',
|
partId: '',
|
},
|
dataRule: {
|
qpa: [
|
{required: true, message: '需求数量不能为空', trigger: 'blur'},
|
{validator: validateSixDecimalNotNull, trigger: 'blur'}
|
],
|
partId: [
|
{required: true, message: '零件不能为空', trigger: 'blur'}
|
]
|
}
|
}
|
},
|
computed: {
|
partStr: function () {
|
return this.dataForm.partId ? (this.dataForm.label + ' ' + (this.dataForm.partNo ? this.dataForm.partNo : '') ) : ''
|
}
|
},
|
methods: {
|
clearDataForm() {
|
this.dataForm = {
|
qpa: '',
|
label: '',
|
partNo: '',
|
partId: '',
|
}
|
},
|
init(currentComponent, type) {
|
this.type = type
|
this.clearDataForm()
|
if (this.type) {
|
this.dataForm = currentComponent
|
this.visible = true
|
} else {
|
this.mpsId = currentComponent.mpsId
|
this.dataForm.parentId = currentComponent.id
|
this.visible = true
|
}
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.$refs['dataForm'].validate((valid) => {
|
if (valid) {
|
if (this.type) {
|
updateMpsStructureComponent(this.dataForm).then(response => {
|
this.$message.success('修改成功')
|
this.visible = false
|
})
|
} else {
|
insertMpsStructureComponent(this.dataForm, this.mpsId).then(response => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.$emit('refreshDataList', response.data.data)
|
})
|
}
|
}
|
})
|
},
|
// 零件选择
|
openPartDialog() {
|
this.showPart = true
|
},
|
selectPart(part) {
|
if (part) {
|
this.dataForm.partNo = part.partNo
|
this.dataForm.label = part.partName
|
this.dataForm.partId = part.id
|
this.$refs['dataForm'].validateField('partId', valid => {
|
})
|
}
|
},
|
},
|
}
|
</script>
|