mt-ck-wms-ui/src/views/basicData/Warehouse/components/StorageBoxRack-add.vue

181 lines
5.3 KiB
Vue
Raw Normal View History

2022-01-14 16:41:37 +08:00
<!--
* @Author: zwq
* @Date: 2020-12-29 16:37:56
2022-03-10 21:15:33 +08:00
* @LastEditors: fzq
* @LastEditTime: 2022-03-10 18:44:36
2022-01-14 16:41:37 +08:00
* @Description:
-->
<template>
<el-dialog
:title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter"
:visible.sync="visible"
>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="120px" @keyup.enter.native="dataFormSubmit()">
2022-01-17 15:18:33 +08:00
<el-form-item :label="$t('module.basicData.Warehouse.LocationName')" prop="currLocationId">
<el-select
v-model="dataForm.currLocationId"
:placeholder="$i18nForm(['placeholder.input', $t('module.basicData.Warehouse.LocationName')])"
clearable
filterable
:style="{width: '100%'}"
@change="selectGetLabel1"
>
<el-option
v-for="(item, index) in LocationList"
:key="index"
:label="item.locationName"
:value="item.id"
/>
</el-select>
2022-01-14 16:41:37 +08:00
</el-form-item>
2022-01-17 15:18:33 +08:00
<el-form-item :label="$t('module.basicData.Warehouse.StorageBoxNumber')" prop="storageBoxId">
<el-select
v-model="dataForm.storageBoxId"
:placeholder="$i18nForm(['placeholder.input', $t('module.basicData.Warehouse.StorageBoxNumber')])"
clearable
filterable
:style="{width: '100%'}"
@change="selectGetLabel2"
>
<el-option
v-for="(item, index) in storageBoxList"
:key="index"
:label="item.code"
:value="item.id"
/>
</el-select>
2022-01-14 16:41:37 +08:00
</el-form-item>
2022-01-17 15:18:33 +08:00
<el-form-item :label="$t('module.basicData.Warehouse.BoxStatus')" prop="status">
<el-switch
v-model="dataForm.status"
:active-value="1"
:inactive-value="0"
active-color="#13ce66"
inactive-color="#AAAAAA"
/>
2022-01-14 16:41:37 +08:00
</el-form-item>
2022-01-17 15:18:33 +08:00
<el-form-item :label="$t('module.basicData.Warehouse.IsEmptyBox')" prop="isEmpty">
<el-switch
v-model="dataForm.isEmpty"
:active-value="1"
:inactive-value="0"
active-color="#13ce66"
inactive-color="#AAAAAA"
/>
2022-01-14 16:41:37 +08:00
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
<el-button type="primary" @click="dataFormSubmit()">{{ 'btn.confirm' | i18nFilter }}</el-button>
</span>
</el-dialog>
</template>
<script>
2022-01-17 15:18:33 +08:00
import { StorageBoxRackDetail, StorageBoxRackUpdate, StorageBoxRackAdd, StorageBoxRackCode, locationList } from '@/api/basicData/Warehouse/StorageBoxInfo'
2022-01-14 16:41:37 +08:00
export default {
data() {
return {
visible: false,
dataForm: {
id: 0,
code: '',
2022-01-17 15:18:33 +08:00
locationName: '',
currLocationId: '',
storageBoxId: '',
status: '',
isEmpty: ''
2022-01-14 16:41:37 +08:00
},
2022-01-17 15:18:33 +08:00
LocationList: [],
storageBoxList: [],
2022-01-14 16:41:37 +08:00
dataRule: {
2022-01-17 15:18:33 +08:00
currLocationId: [
2022-01-14 16:41:37 +08:00
{
required: true,
2022-01-17 15:18:33 +08:00
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.Warehouse.LocationName')]),
2022-01-14 16:41:37 +08:00
trigger: 'blur' }
],
2022-01-17 15:18:33 +08:00
storageBoxId: [
2022-01-14 16:41:37 +08:00
{
required: true,
2022-01-17 15:18:33 +08:00
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.Warehouse.StorageBoxNumber')]),
2022-01-14 16:41:37 +08:00
trigger: 'blur' }
]
}
}
},
methods: {
init(id) {
this.dataForm.id = id || ''
this.visible = true
2022-01-17 15:18:33 +08:00
const listQuery = {
current: 1,
size: 100
}
locationList(listQuery).then(response => {
this.LocationList = response.data
})
StorageBoxRackCode(listQuery).then(res => {
this.storageBoxList = res.data.records
})
2022-01-14 16:41:37 +08:00
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
2022-01-17 15:18:33 +08:00
StorageBoxRackDetail(this.dataForm.id).then(res => {
this.dataForm = res.data
2022-01-14 16:41:37 +08:00
})
}
})
},
2022-01-17 15:18:33 +08:00
selectGetLabel1(vId) {
let obj = {}
obj = this.LocationList.find((item) => {
return item.id === vId
})
this.dataForm.locationName = obj.locationName
},
selectGetLabel2(vId) {
let obj = {}
obj = this.storageBoxList.find((item) => {
return item.id === vId
})
this.dataForm.code = obj.code
},
2022-01-14 16:41:37 +08:00
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
2022-01-17 15:18:33 +08:00
const data = this.dataForm
2022-01-14 16:41:37 +08:00
if (this.dataForm.id) {
2022-01-17 15:18:33 +08:00
StorageBoxRackUpdate(data).then(res => {
2022-01-14 16:41:37 +08:00
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
} else {
2022-01-17 15:18:33 +08:00
StorageBoxRackAdd(data).then(res => {
2022-01-14 16:41:37 +08:00
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
}
}
})
}
}
}
</script>