<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="prefix"> <a-input v-model="model.prefix" placeholder="请输入编码前缀" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="起始行" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="firstRow"> <a-input v-model="model.firstRow" placeholder="请输入起始行" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="最后行" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lastRow"> <a-input v-model="model.lastRow" placeholder="请输入最后行" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="起始列" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="firstColumn"> <a-input v-model="model.firstColumn" placeholder="请输入起始列" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="最后列" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lastColumn"> <a-input v-model="model.lastColumn" placeholder="请输入最后列" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="起始层" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="firstLayer"> <a-input v-model="model.firstLayer" placeholder="请输入起始层" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="最后层" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lastLayer"> <a-input v-model="model.lastLayer" placeholder="请输入最后层" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="巷道" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="roadWay"> <a-input v-model="model.roadWay" placeholder="请输入巷道" ></a-input> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="高低位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="high"> <j-dict-select-tag type="list" v-model="model.high" dictCode="high_status" placeholder="请选择高低位" /> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="库区" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zoneCode"> <a-select show-search placeholder="请选择库区" option-filter-prop="children" :filter-option="filterOption" v-model="model.zoneCode"> <a-select-option v-for="item in zoneList" :key="item.name" :value="item.code">{{ item.name }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="24"> <a-form-model-item label="库位类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="locationTypeCode"> <a-select show-search placeholder="请选择库位类型" option-filter-prop="children" :filter-option="filterOption" v-model="model.locationTypeCode"> <a-select-option v-for="item in locationTypeList" :key="item.name" :value="item.code">{{ item.name }}</a-select-option> </a-select> </a-form-model-item> </a-col> <!-- <a-col :span="24">--> <!-- <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">--> <!-- <j-dict-select-tag type="list" v-model="model.status" dictCode="location_status" placeholder="请选择状态" />--> <!-- </a-form-model-item>--> <!-- </a-col>--> <!-- <a-col :span="24">--> <!-- <a-form-model-item label="是否可用" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="enable">--> <!-- <j-dict-select-tag type="list" v-model="model.enable" dictCode="enable_status" 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' import {getZoneList} from '@/api/api' import {getLocationTypeList} from '@/api/api' export default { name: 'LocationBatchAddForm', 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, zoneList:[], locationTypeList:[], validatorRules: { prefix: [ { required: true, message: '请输入编码前缀!'}, ], firstRow: [ { required: true, message: '请输入起始行!'}, ], lastRow: [ { required: true, message: '请输入最后行'}, ], firstColumn: [ { required: true, message: '请输入起始列!'}, ], lastColumn: [ { required: true, message: '请输入最后列'}, ], firstLayer: [ { required: true, message: '请输入起始层!'}, ], lastLayer: [ { required: true, message: '请输入最后层'}, ], roadWay: [ { required: true, message: '请输入巷道!'}, ], zoneCode: [ { required: true, message: '请输入库区!'}, ], locationTypeCode: [ { required: true, message: '请输入库位类型!'}, ], high: [ { required: true, message: '请输入高低位!'}, ], }, url: { add: "/config/location/batchAdd", edit: "/config/location/edit", queryById: "/config/location/queryById" } } }, computed: { formDisabled(){ return this.disabled }, }, created () { //备份model原始值 this.modelDefault = JSON.parse(JSON.stringify(this.model)); this.loadFrom(); }, methods: { add () { this.edit(this.modelDefault); }, edit (record) { this.model = Object.assign({}, record); this.visible = true; }, loadFrom() { getZoneList().then((res) => { if (res.success) { this.zoneList = res.result } }); getLocationTypeList().then((res) => { if (res.success) { this.locationTypeList = res.result } }) }, submitForm () { const that = this; // 触发表单验证 this.$refs.form.validate(valid => { if (valid) { that.confirmLoading = true; let httpurl = ''; let method = ''; httpurl+=this.url.add; method = 'post'; 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>