<template>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
<a-row>
|
<a-col :span="24">
|
<a-form-model-item label="夹具" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fixtureInformation">
|
<a-input v-model="model.fixtureInformation" placeholder="请输入夹具" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="加工批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="processingBatch">
|
<a-input v-model="model.processingBatch" placeholder="请输入加工批次" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="加工数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="processingQuantity">
|
<a-input-number v-model="model.processingQuantity" placeholder="请输入加工数量" :min="1" style="width: 100%"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="加工设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="processingEquipment">
|
<a-input v-model="model.processingEquipment" placeholder="请输入加工设备" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="picture">
|
<j-image-upload :number="1" v-model="model.picture" ></j-image-upload>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="说明信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remake">
|
<a-textarea v-model="model.remake" rows="4" placeholder="请输入说明信息" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
</template>
|
|
<script>
|
|
import { httpAction, getAction } from '@api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
|
export default {
|
name: 'GuideCardBatchForm',
|
components: {
|
},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
data () {
|
return {
|
model:{
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
fixtureInformation: [
|
{ required: true, message: '请输入夹具!'},
|
],
|
picture: [
|
{ required: true, message: '请输入图片!'},
|
],
|
processingBatch: [
|
{ required: true, message: '请输入加工批次!'},
|
],
|
processingQuantity: [
|
{ required: true, message: '请输入加工数量!'},
|
],
|
processingEquipment: [
|
{ required: true, message: '请输入加工设备!'},
|
],
|
remake: [
|
{ required: true, message: '请输入说明信息!'},
|
],
|
},
|
url: {
|
edit: "/dnc/guideCardBatch/edit",
|
}
|
}
|
},
|
computed: {
|
formDisabled(){
|
return this.disabled
|
},
|
},
|
created () {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
methods: {
|
add () {
|
this.edit(this.modelDefault);
|
},
|
edit (record) {
|
this.model = Object.assign({}, record);
|
this.visible = true;
|
},
|
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;
|
method = 'put';
|
}
|
httpAction(httpurl,this.model,method).then((res)=>{
|
if(res.success){
|
that.$message.success(res.message);
|
that.$emit('ok');
|
}else{
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
})
|
}
|
|
})
|
},
|
}
|
}
|
</script>
|