<template>
|
<el-dialog
|
append-to-body
|
:title="title"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="120px"
|
class="l-mes"
|
>
|
<el-form-item label="零件" prop="partId">
|
<el-input v-model="partStr" placeholder="" readonly>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openPartDialog()"
|
:disabled="partIsDisabled"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="消耗工序" prop="operationId">
|
<el-input v-model="dataForm.operationName" placeholder="" readonly>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openOperationDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="单位产出所需数量" prop="qpa">
|
<el-input v-model="dataForm.qpa" placeholder=""></el-input>
|
</el-form-item>
|
</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"
|
/>
|
<operation-dialog
|
:currshowlist.sync="showOperation"
|
@listenToOperationEvent="selectOperation"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import PartDialog from '@/views/common/part'
|
import OperationDialog from '@/views/common/operation'
|
import { validateSixDecimalNotNull } from '@/util/validate'
|
|
export default {
|
components: {
|
PartDialog,
|
OperationDialog
|
},
|
props: {
|
partIsDisabled: {
|
type: Boolean,
|
default: false
|
}
|
},
|
data() {
|
return {
|
title: '',
|
visible: false,
|
showPart: false,
|
showOperation: false,
|
dataForm: {
|
partName: '',
|
partNo: '',
|
partId: '',
|
operationName: '',
|
operationNo: '',
|
operationId: '',
|
qpa: ''
|
},
|
dataRule: {
|
partId: [{ required: true, message: '零件不能为空', trigger: 'blur' }],
|
operationId: [
|
{ required: true, message: '工序不能为空', trigger: 'blur' }
|
],
|
qpa: [
|
{
|
required: true,
|
message: '单位产出所需数量不能为空',
|
trigger: 'blur'
|
},
|
{ validator: validateSixDecimalNotNull, trigger: 'blur' }
|
]
|
},
|
components: [],
|
index: -1
|
}
|
},
|
computed: {
|
partStr: function() {
|
return this.dataForm.partId
|
? this.dataForm.partName + ' ' + this.dataForm.partNo
|
: ''
|
}
|
},
|
methods: {
|
init(row, index, components) {
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
this.components = components
|
if (row) {
|
this.title = '修改结构组件'
|
this.index = index
|
this.dataForm = JSON.parse(JSON.stringify(row))
|
} else {
|
this.title = '新增结构组件'
|
this.index = -1
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.index !== -1) {
|
this.$emit('modifyComp', {
|
partId: this.dataForm.partId,
|
partName: this.dataForm.partName,
|
partNo: this.dataForm.partNo,
|
operationId: this.dataForm.operationId,
|
operationName: this.dataForm.operationName,
|
operationNo: this.dataForm.operationNo,
|
qpa: this.dataForm.qpa
|
})
|
this.visible = false
|
} else {
|
this.$message.success('添加成功')
|
this.components.push(JSON.parse(JSON.stringify(this.dataForm)))
|
this.visible = false
|
}
|
}
|
})
|
},
|
|
// 零件选择
|
openPartDialog() {
|
this.showPart = true
|
},
|
selectPart(part) {
|
if (part) {
|
this.dataForm.partNo = part.partNo
|
this.dataForm.partName = part.partName
|
this.dataForm.partId = part.id
|
this.$refs.dataForm.validateField('partId', (valid) => {})
|
}
|
},
|
// 工序选择
|
openOperationDialog() {
|
this.showOperation = true
|
},
|
selectOperation(operation) {
|
if (operation) {
|
this.dataForm.operationName = operation.name
|
this.dataForm.operationNo = operation.operationNo
|
this.dataForm.operationId = operation.id
|
}
|
}
|
}
|
}
|
</script>
|