| | |
| | | </a-col> |
| | | <a-col :span="12"> |
| | | <a-form-model-item label="货架名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shelfName"> |
| | | <a-input v-model="model.shelfName" placeholder="请输入货架名称" ></a-input> |
| | | <a-input v-model="model.shelfName" placeholder="请输入货架名称" :disabled="shelfNameDisabled"></a-input> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | <a-col :span="12"> |
| | |
| | | }, |
| | | autoLocationCode: '', // 自动拼接的库位号 |
| | | userEditedLocationCode: false, |
| | | shelfNameDisabled: false, // 控制货架名称是否禁用 |
| | | lastEchoedShelfName: '', // 保存上次回显的货架名称 |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 5 }, |
| | |
| | | }, |
| | | confirmLoading: false, |
| | | validatorRules: { |
| | | warehouseId: [ |
| | | { required: true, message: '请输入仓库编号!'}, |
| | | ], |
| | | locationCode: [ |
| | | { required: true, message: '请输入库位号!'}, |
| | | ], |
| | | storey: [ |
| | | { required: true, message: '请输入层数!'}, |
| | | ], |
| | | shelfNumber: [ |
| | | { required: true, message: '请输入货架号!'}, |
| | | { validator: this.validateShelfNumber }, |
| | | { required: true, message: '请输入货架编号!'}, |
| | | { validator: this.validateShelfName } |
| | | ], |
| | | shelfName: [ |
| | | { required: true, message: '请输入货架名称!'}, |
| | | { required: true, message: '请输入货架名称!'}, |
| | | ], |
| | | storey: [ |
| | | { required: true, message: '请输入层数!'}, |
| | | ], |
| | | arrange: [ |
| | | { required: true, message: '请输入排数!'}, |
| | | ], |
| | | columnNumber: [ |
| | | { required: true, message: '请输入列数!'}, |
| | | ], |
| | | cellsNum: [ |
| | | { required: true, message: '请输入格数!'}, |
| | | { validator: this.validateDuplicate } |
| | | ] |
| | | }, |
| | | url: { |
| | | add: "/tms/goodsShelves/add", |
| | | edit: "/tms/goodsShelves/edit", |
| | | queryById: "/tms/goodsShelves/queryById", |
| | | checkShelfNum:"/tms/goodsShelves/checkShelfNum" |
| | | checkShelfName:"/tms/goodsShelves/checkShelfName", |
| | | checkDuplicate:"/tms/goodsShelves/checkDuplicate" |
| | | }, |
| | | warehouseId:'' |
| | | } |
| | |
| | | this.modelDefault.warehouseId = treeSelected.key |
| | | this.modelDefault.warehouseNum = treeSelected.entity.warehouseId |
| | | this.modelDefault.warehouseName = treeSelected.entity.warehouseName |
| | | this.modelDefault.cellsNum = '1' //格数设置默认值1 |
| | | this.edit(this.modelDefault); |
| | | }, |
| | | edit (record) { |
| | | this.model = Object.assign({}, record); |
| | | this.visible = true; |
| | | this.shelfNameDisabled = false |
| | | // 重置回显标记 |
| | | this.lastEchoedShelfName = '' |
| | | this.warehouseId = record.warehouseId |
| | | }, |
| | | submitForm () { |
| | |
| | | }) |
| | | }, |
| | | //验证 货架号 |
| | | validateShelfNumber(rule, value, callback) { |
| | | validateShelfName(rule, value, callback) { |
| | | var params = { |
| | | warehouseId: this.warehouseId, |
| | | shelfNumber: value, |
| | | }; |
| | | getAction(this.url.checkShelfNum,params).then((res) => { |
| | | getAction(this.url.checkShelfName,params).then((res) => { |
| | | if (res.success) { |
| | | this.shelfNameDisabled = false |
| | | // 只有在校验通过且当前货架名称是之前回显的值时才清空 |
| | | // 这通常发生在用户修改了已存在的货架编号为不存在的编号时 |
| | | if (this.model.shelfName === this.lastEchoedShelfName) { |
| | | this.model.shelfName = '' |
| | | } |
| | | callback(); |
| | | } else { |
| | | callback("货架编号已存在!"); |
| | | //存在该货架号,直接将结果回显到货架名称字段并禁用该字段 |
| | | this.model.shelfName = res.result; |
| | | this.lastEchoedShelfName = res.result; // 保存回显的值 |
| | | this.shelfNameDisabled = true; |
| | | callback(); |
| | | } |
| | | }) |
| | | }, |
| | | validateDuplicate(rule, value, callback) { |
| | | getAction(this.url.checkDuplicate, this.model).then(res => { |
| | | if (res.success) { |
| | | callback(); |
| | | } else { |
| | | callback(res.message); |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | watch: { |
| | | autoGeneratedLocationCode(newVal) { |