mt-ck-wms-ui/src/views/basicData/Cache/components/locationAttr-add.vue

179 lines
6.1 KiB
Vue
Raw Normal View History

2021-09-13 14:56:28 +08:00
<!--
* @Author: zwq
* @Date: 2020-12-29 16:37:56
2022-03-03 20:48:59 +08:00
* @LastEditors: fzq
2022-03-13 14:44:14 +08:00
* @LastEditTime: 2022-03-11 11:03:31
2021-09-13 14:56:28 +08:00
* @Description:
-->
<template>
<el-dialog
2022-03-03 20:48:59 +08:00
:title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter"
2021-09-13 14:56:28 +08:00
:visible.sync="visible"
>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="130px" @keyup.enter.native="dataFormSubmit()">
2022-03-03 20:48:59 +08:00
<el-form-item :label="$t('module.basicData.cache.LocationName')" prop="locationName">
<el-input v-model="dataForm.locationName" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.LocationName')])" clearable />
2021-09-13 14:56:28 +08:00
</el-form-item>
<el-form-item :label="$t('module.basicData.cache.LocationCode')" prop="code">
<el-input v-model="dataForm.code" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.LocationCode')])" clearable />
</el-form-item>
2022-03-03 20:48:59 +08:00
<el-form-item :label="$t('module.basicData.cache.anotherName')" prop="locationNameAlias">
<el-input v-model="dataForm.locationNameAlias" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.anotherName')])" clearable />
2021-09-13 14:56:28 +08:00
</el-form-item>
2022-03-03 20:48:59 +08:00
<el-form-item :label="$t('module.basicData.cache.rowMark')" prop="layers">
<el-input v-model="dataForm.layers" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.rowMark')])" clearable />
2021-09-13 14:56:28 +08:00
</el-form-item>
2022-03-03 20:48:59 +08:00
<el-form-item :label="$t('module.basicData.cache.columnMark')" prop="columns">
<el-input v-model="dataForm.columns" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.columnMark')])" clearable />
</el-form-item>
2022-03-13 14:44:14 +08:00
<!-- <el-form-item :label="$t('module.basicData.cache.locationType')" prop="locationType">
2022-03-05 19:43:42 +08:00
<el-input v-model="dataForm.locationType" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.locationType')])" clearable />
2022-03-13 14:44:14 +08:00
</el-form-item> -->
2022-03-10 21:15:33 +08:00
<!-- <el-form-item :label="$t('module.basicData.cache.status')" prop="status">
2022-03-03 20:48:59 +08:00
<el-input v-model="dataForm.status" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.status')])" clearable />
2022-03-10 21:15:33 +08:00
</el-form-item> -->
<el-form-item :label="$t('module.basicData.cache.status')" prop="status">
<el-select v-model="dataForm.status">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
2021-09-13 14:56:28 +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>
import { locationDetail, locationUpdate, locationAdd, locationCode } from '@/api/basicData/Cache/location'
export default {
props: {
shelfId: {
type: String,
default: () => {
return ''
}
}
},
data() {
return {
visible: false,
dataForm: {
id: 0,
2022-03-03 20:48:59 +08:00
locationName: '',
2021-09-13 14:56:28 +08:00
code: '',
2022-03-03 20:48:59 +08:00
locationNameAlias: '',
rowNum: '',
2022-03-10 21:15:33 +08:00
columns: 0,
layers: 0,
status: null,
2022-03-03 20:48:59 +08:00
locationType: ''
2021-09-13 14:56:28 +08:00
},
2022-03-10 21:15:33 +08:00
options: [
{
value: 1,
label: 'Working Port'
},
{
value: 2,
label: 'Buffer Port'
},
{
value: 3,
label: 'Exception Port'
}
],
2021-09-13 14:56:28 +08:00
dataRule: {
name: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.cache.LocationName')]), trigger: 'blur' }
],
code: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.cache.LocationCode')]), trigger: 'blur' }
]
2022-03-10 21:15:33 +08:00
// layers: [{
// type: 'number',
// message: this.$t('module.basicData.cache.warning'),
// trigger: "blur"
// }],
// columns: [{
// type: 'number',
// message: this.$t('module.basicData.cache.warning'),
// trigger: "blur"
// }]
2021-09-13 14:56:28 +08:00
}
}
},
methods: {
init(id) {
this.dataForm.id = id || ''
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
locationDetail(this.dataForm.id).then(res => {
this.dataForm = res.data
2022-03-10 21:15:33 +08:00
console.log(this.dataForm)
2021-09-13 14:56:28 +08:00
})
} else {
locationCode().then(res => {
this.dataForm.code = res.data
})
}
})
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
const data = {
2022-03-03 20:48:59 +08:00
'locationName': this.dataForm.locationName,
2021-09-13 14:56:28 +08:00
'code': this.dataForm.code,
2022-03-03 20:48:59 +08:00
'locationNameAlias': this.dataForm.locationNameAlias,
'columns': this.dataForm.columns,
'layers': this.dataForm.layers,
2021-09-13 14:56:28 +08:00
'shelfId': this.shelfId,
2022-03-03 20:48:59 +08:00
'id': this.dataForm.id,
'status': this.dataForm.status,
'locationType': this.dataForm.locationType
2021-09-13 14:56:28 +08:00
}
if (this.dataForm.id) {
locationUpdate(data).then(res => {
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
} else {
locationAdd(data).then(res => {
2022-03-05 19:43:42 +08:00
console.log(data)
console.log(res)
2021-09-13 14:56:28 +08:00
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
}
}
})
}
}
}
</script>