<template>
|
<a-spin :spinning="confirmLoading">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="部件名称" prop="componentName">
|
<a-input v-model="model.componentName" placeholder="请输入部件名称"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="代号" prop="componentCode">
|
<a-input v-model="model.componentCode" placeholder="请输入代号"></a-input>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="部件型号">
|
<a-input v-model="model.componentModel" placeholder="请输入部件型号"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="规格">
|
<a-input v-model="model.componentScale" placeholder="请输入规格"></a-input>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="装配类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input v-model="model.assembleType" placeholder="请输入装配类型"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="重量">
|
<a-input v-model="model.componentWeight" placeholder="请输入重量"></a-input>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="物料编码">
|
<a-input v-model="model.materielCode" placeholder="请输入物料编码"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="结构类型">
|
<a-input v-model="model.structureType" placeholder="请输入结构类型"></a-input>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="处理类型">
|
<a-input v-model="model.processType" placeholder="请输入处理类型"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="生产类型">
|
<a-input v-model="model.produceType" placeholder="请输入生产类型"></a-input>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="24">
|
<a-form-model-item label="描述" :labelCol="labelColLong" :wrapperCol="wrapperColLong">
|
<a-textarea v-model="model.description" placeholder="请输入描述"></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
</template>
|
|
<script>
|
import { httpAction, getAction } from '@/api/manage'
|
|
export default {
|
name: 'ComponentModalForm',
|
components: {},
|
data() {
|
return {
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 14 }
|
},
|
labelColLong: {
|
xs: { span: 24 },
|
sm: { span: 4 }
|
},
|
wrapperColLong: {
|
xs: { span: 24 },
|
sm: { span: 19 }
|
},
|
confirmLoading: false,
|
validatorRules: {
|
componentName: [
|
{ required: true, message: '请输入部件名称!' }
|
],
|
componentCode: [
|
{ required: true, message: '请输入代号!' }
|
]
|
},
|
url: {
|
add: '/nc/component/add',
|
edit: '/nc/component/edit'
|
}
|
}
|
},
|
computed: {
|
formDisabled() {
|
return this.disabled
|
}
|
},
|
created() {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model))
|
},
|
methods: {
|
add(params) {
|
this.edit({ ...this.modelDefault, ...params })
|
},
|
|
edit(record) {
|
this.model = Object.assign({}, record)
|
console.log('model', this.model)
|
},
|
|
submitForm() {
|
const that = this
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true
|
let httpUrl = ''
|
let method = ''
|
if (!this.model.id) {
|
httpUrl += this.url.add
|
method = 'post'
|
} else {
|
httpUrl += this.url.edit + `/${this.model.id}`
|
method = 'put'
|
}
|
httpAction(httpUrl, this.model, method).then((res) => {
|
if (res.success) {
|
that.$notification.success({
|
message: '消息',
|
description: res.message
|
})
|
that.$emit('ok')
|
} else {
|
that.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
}).finally(() => {
|
that.confirmLoading = false
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|