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

140 lines
4.9 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
* @LastEditTime: 2022-03-03 19:42:43
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>
<el-form-item :label="$t('module.basicData.cache.status')" prop="status">
<el-input v-model="dataForm.status" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.status')])" clearable />
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: '',
columns: '',
layers: '',
status: '',
locationType: ''
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' }
]
}
}
},
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
})
} 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-03 20:48:59 +08:00
// console.log(data)
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>