<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增委外订单' : '编辑委外订单'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
:disabled="editable"
|
ref="dataForm"
|
label-width="110px"
|
class="l-mes"
|
>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="委外订单号" prop="outsourcingOrderNo">
|
<el-input
|
v-model="dataForm.outsourcingOrderNo"
|
:disabled="true"
|
></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()"
|
></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
|
style="width:100%"
|
v-model="dataForm.qtyRequired"
|
@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"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="是否外协直发" prop="foreignState">
|
<el-switch
|
v-model="dataForm.foreignState"
|
active-text="是"
|
inactive-text="否"
|
active-value="0"
|
inactive-value="1"
|
active-color="#13ce66">
|
</el-switch>
|
</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" />
|
</el-dialog>
|
</template>
|
|
<script>
|
import {
|
getOutsourcingOrder,
|
addOutsourcingOrder,
|
putOutsourcingOrder
|
} from '@/api/plan/outsourcingorder'
|
import { getObj } from '@/api/plan/masterproductionschedule'
|
import { validatePositiveInteger } from '@/util/validate'
|
import partDialog from '@/views/common/part.vue'
|
|
export default {
|
components: {
|
partDialog
|
},
|
data() {
|
return {
|
visible: false,
|
showPart: false,
|
dataForm: {
|
id: 0,
|
outsourcingOrderNo: '',
|
partName: '',
|
partNo: '',
|
partId: '',
|
qtyRequired: '',
|
requiredDate: '',
|
remark: '',
|
mpsId: null,
|
foreignState: null,
|
},
|
dataRule: {
|
partId: [{ required: true, message: '零件不能为空', trigger: 'blur' }],
|
qtyRequired: [
|
{ required: true, message: '需求数量不能为空', trigger: 'blur' },
|
{ validator: validatePositiveInteger, trigger: 'blur' },
|
],
|
requiredDate: [
|
{ required: true, message: '需求日期不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false
|
}
|
},
|
created() {},
|
methods: {
|
init(id, masterProductionSchedule,mpsId) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getOutsourcingOrder(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
})
|
}
|
|
// 从主生产计划过来的,带上零件
|
if (masterProductionSchedule) {
|
this.dataForm.qtyRequired = masterProductionSchedule.qtyRequired
|
this.dataForm.partNo = masterProductionSchedule.partNo
|
this.dataForm.partName = masterProductionSchedule.partName
|
this.dataForm.partId = masterProductionSchedule.partId
|
this.dataForm.mpsId = masterProductionSchedule.id
|
this.dataForm.requiredDate = masterProductionSchedule.requiredDate
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putOutsourcingOrder(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
} else {
|
addOutsourcingOrder(this.dataForm).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
}
|
} 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) => {})
|
}
|
},
|
// 检验需求数量
|
checkNumber() {
|
},
|
// 检验需求日期
|
checkDate() {}
|
},
|
computed: {
|
partStr: function() {
|
return this.dataForm.partId
|
? this.dataForm.partName +
|
' ' +
|
(this.dataForm.partNo ? this.dataForm.partNo : '')
|
: ''
|
},
|
editable: function() {
|
if (!this.dataForm.id) {
|
return false
|
} else {
|
// 待计划的可以修改
|
if (this.dataForm.state === '01planned') {
|
return false
|
}
|
}
|
return true
|
}
|
}
|
}
|
</script>
|