<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增库存接收' : '编辑库存接收'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="100px"
|
class="l-mes"
|
>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="库位号" prop="locNo">
|
<el-input v-model="dataForm.locNo" placeholder="" readonly>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openLocationDialog()"
|
:disabled="!editable"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="零件" prop="partId">
|
<el-input v-model="partStr" readonly>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openPartDialog()"
|
:disabled="!editable"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="零件批号" prop="partBatchNo">
|
<el-input
|
v-model="dataForm.partBatchNo"
|
:disabled="!editable"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="接收数量" prop="receiveQuantity">
|
<el-input v-model="dataForm.receiveQuantity"></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"
|
:disabled="isSubmit"
|
v-thinclick="`dataFormSubmit`"
|
>确定</el-button
|
>
|
</span>
|
<partDialog :currshowlist.sync="showPart" @listenToPartEvent="selectPart" />
|
<locationDialog
|
:currshowlist.sync="showLocation"
|
@listenToLocationEvent="selectLocation"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { getObj, addObj, putObj } from '@/api/plan/outsourcingorderstock'
|
import { validateSixDecimalNotNull } from '@/util/validate'
|
import partDialog from '@/views/common/part.vue'
|
import locationDialog from '@/views/common/location.vue'
|
|
export default {
|
components: {
|
partDialog,
|
locationDialog
|
},
|
data() {
|
return {
|
showLocation: false,
|
visible: false,
|
showPart: false,
|
dataForm: {
|
id: 0,
|
outsourcingOrderId: '',
|
partId: '',
|
partBatchNo: '',
|
receiveQuantity: '',
|
locationId: '',
|
locNo: '',
|
stockId: '',
|
partName: '',
|
partNo: ''
|
},
|
dataRule: {
|
partId: [{ required: true, message: '零件不能为空', trigger: 'blur' }],
|
locNo: [{ required: true, message: '库位不能为空', trigger: 'blur' }],
|
receiveQuantity: [
|
{ required: true, message: '接收数量不能为空', trigger: 'blur' },
|
{ validator: validateSixDecimalNotNull, trigger: 'blur' }
|
],
|
partBatchNo: [
|
{ required: true, message: '零件批号不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false
|
}
|
},
|
created() {},
|
methods: {
|
init(id, outsourcingOrder) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getObj(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
})
|
} else {
|
this.dataForm.outsourcingOrderId = outsourcingOrder.id
|
this.dataForm.partId = outsourcingOrder.partId
|
this.dataForm.partName = outsourcingOrder.partName
|
this.dataForm.partNo = outsourcingOrder.partNo
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putObj(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
this.$emit('refreshOutsourcingOrder')
|
})
|
} else {
|
addObj(this.dataForm).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
this.$emit('refreshOutsourcingOrder')
|
})
|
}
|
} else {
|
this.isSubmit = 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) => {})
|
}
|
},
|
// 库位弹窗
|
openLocationDialog() {
|
this.showLocation = true
|
},
|
selectLocation(location) {
|
if (location) {
|
this.dataForm.locationId = location.id
|
this.dataForm.locNo = location.locNo
|
}
|
}
|
},
|
computed: {
|
partStr: function() {
|
return this.dataForm.partId
|
? this.dataForm.partName +
|
' ' +
|
(this.dataForm.partNo ? this.dataForm.partNo : '')
|
: ''
|
},
|
editable: function() {
|
if (!this.dataForm.id) {
|
return true
|
}
|
return false
|
}
|
}
|
}
|
</script>
|