<template>
|
<el-dialog
|
width="50%"
|
title="新增"
|
top="15vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
class="part-dialog"
|
>
|
<div>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="masterProductionDataForm"
|
label-width="80px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="零件" prop="partName">
|
<el-input v-model="dataForm.partName" placeholder="零件" readonly>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openSelectPart"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="需求数量" prop="qtyRequired">
|
<el-input
|
v-model="dataForm.qtyRequired"
|
placeholder="需求数量"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<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"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="制造属性" prop="manufactureAttr">
|
<el-select
|
v-model="dataForm.manufactureAttr"
|
placeholder=""
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in manufactureAttrs"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="单位" prop="unit">
|
<span>{{ dataForm.unit }}</span>
|
</el-form-item>
|
</el-col>
|
<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-form>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`createMasterProduction`"
|
>确定</el-button
|
>
|
</div>
|
<partDialog :currshowlist.sync="showPart" @listenToPartEvent="selectPart" />
|
</el-dialog>
|
</template>
|
<script>
|
import partDialog from '@/views/common/part.vue'
|
import { addObj } from '@/api/plan/masterproductionschedule'
|
import { validateSixDecimalPositive } from '../../../util/validate'
|
import { remote } from '@/api/admin/dict'
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
isSubmit: false,
|
dataForm: {
|
requiredDate: null,
|
remark: null,
|
partId: null,
|
partName: null,
|
partNo: null,
|
qtyRequired: null,
|
manufactureAttr: 'N',
|
unit: null
|
},
|
dataRule: {
|
partName: [
|
{ required: true, message: '零件不能为空', trigger: 'change' }
|
],
|
qtyRequired: [
|
{ required: true, message: '需求数量不能为空', trigger: 'blur' },
|
{ validator: validateSixDecimalPositive, trigger: 'blur' }
|
],
|
requiredDate: [
|
{ required: true, message: '需求日期不能为空', trigger: 'blur' }
|
]
|
},
|
showPart: false,
|
manufactureAttrs: []
|
}
|
},
|
components: {
|
partDialog
|
},
|
created() {
|
this.getManufactureAttrs('manufacture_attr_type')
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.$nextTick(() => {
|
this.initForm()
|
})
|
}
|
}
|
},
|
methods: {
|
getManufactureAttrs(type) {
|
remote(type).then((response) => {
|
const code = response.data.code
|
if (code === 0) {
|
const _data = response.data.data
|
this.manufactureAttrs = _data
|
}
|
})
|
},
|
initForm() {
|
this.dataForm.requiredDate = null
|
this.dataForm.remark = null
|
this.dataForm.partId = null
|
this.dataForm.partName = null
|
this.dataForm.partNo = null
|
this.dataForm.qtyRequired = null
|
this.dataForm.manufactureAttr = 'N'
|
this.dataForm.unit = null
|
},
|
openSelectPart() {
|
this.showPart = true
|
},
|
selectPart(param) {
|
if (typeof param !== 'undefined') {
|
this.dataForm.partId = param.id
|
this.dataForm.partName = param.partName
|
this.dataForm.partNo = param.partNo
|
this.dataForm.unit = param.unit
|
}
|
},
|
createMasterProduction() {
|
this.isSubmit = true
|
this.$refs.masterProductionDataForm.validate((valid) => {
|
if (valid) {
|
addObj(this.dataForm)
|
.then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.$message.success('新增成功')
|
} else {
|
this.$message.success('新增失败')
|
}
|
this.innerVisible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
.catch(() => {
|
this.isSubmit = false
|
})
|
} else {
|
this.isSubmit = false
|
}
|
})
|
},
|
checkZero(value) {
|
if (value == 0) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkPositive(value) {
|
if (!/^[0-9]+.?[0-9]*$/.test(value)) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkDecimal(value) {
|
if (
|
!/(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]{1,6}$)/.test(
|
value
|
)
|
) {
|
return false
|
} else {
|
return true
|
}
|
}
|
}
|
}
|
</script>
|
<style scoped></style>
|