89 lines
2.4 KiB
Vue
89 lines
2.4 KiB
Vue
<template>
|
|
<el-form ref="form" :rules="rules" label-width="110px" :model="form">
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="产品名称" prop="product">
|
|
<el-input v-model="form.product"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="24">
|
|
<el-form-item label="规格" prop="spec">
|
|
<el-input v-model="form.spec"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="24">
|
|
<el-form-item label="工艺" prop="process">
|
|
<el-select v-model="form.process" placeholder="请选择" style="width: 100%;">
|
|
<el-option v-for='item in processList' :key='item.value' :label="item.label" :value= 'item.value' ></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
</template>
|
|
<script>
|
|
import { addProductConfig, updateProductConfig, getProductConfig } from '@/api/basicInfoConfig'
|
|
import {getDictDatas } from '@/utils/dict'
|
|
export default {
|
|
name: 'ProductInfoAdd',
|
|
data() {
|
|
return {
|
|
form: {
|
|
id: '',
|
|
product: '',
|
|
spec: '',
|
|
process:'',
|
|
},
|
|
isEdit: false, //是否是编辑
|
|
rules: {
|
|
product: [{ required: true, message: '请输入产品名称', trigger: 'blur' }]
|
|
},
|
|
processList:getDictDatas('process')
|
|
}
|
|
},
|
|
methods: {
|
|
init(id) {
|
|
if (id) {
|
|
this.isEdit = true
|
|
this.form.id = id
|
|
getProductConfig({id}).then((res) => {
|
|
if (res.code === 0) {
|
|
this.form = res.data
|
|
}
|
|
})
|
|
}else{
|
|
this.form.id = ''
|
|
}
|
|
},
|
|
submitForm() {
|
|
this.$refs['form'].validate((valid) => {
|
|
if (valid) {
|
|
if (this.isEdit) {
|
|
//编辑
|
|
updateProductConfig({ ...this.form }).then((res) => {
|
|
if (res.code === 0) {
|
|
this.$modal.msgSuccess("操作成功");
|
|
this.$emit('successSubmit')
|
|
}
|
|
})
|
|
} else {
|
|
addProductConfig({ ...this.form }).then((res) => {
|
|
if (res.code === 0) {
|
|
this.$modal.msgSuccess("操作成功");
|
|
this.$emit('successSubmit')
|
|
}
|
|
})
|
|
}
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
formClear() {
|
|
this.$refs.form.resetFields()
|
|
this.isEdit = false
|
|
}
|
|
}
|
|
}
|
|
</script>
|