131 lines
4.4 KiB
Vue
131 lines
4.4 KiB
Vue
|
<!--
|
||
|
* @Author: zwq
|
||
|
* @Date: 2020-12-29 16:37:56
|
||
|
* @LastEditors: zwq
|
||
|
* @LastEditTime: 2021-03-25 16:23:03
|
||
|
* @Description:
|
||
|
-->
|
||
|
<template>
|
||
|
<el-dialog
|
||
|
:title="!dataForm.shelfId ? 'btn.add' : 'btn.edit' | i18nFilter"
|
||
|
:visible.sync="visible"
|
||
|
>
|
||
|
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="130px" @keyup.enter.native="dataFormSubmit()">
|
||
|
<el-form-item :label="$t('module.basicData.cache.LocationName')" prop="name">
|
||
|
<el-input v-model="dataForm.name" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.LocationName')])" clearable />
|
||
|
</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>
|
||
|
<el-form-item :label="$t('module.basicData.cache.anotherName')" prop="anotherName">
|
||
|
<el-input v-model="dataForm.anotherName" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.anotherName')])" clearable />
|
||
|
</el-form-item>
|
||
|
<el-form-item :label="$t('module.basicData.cache.place')" prop="place">
|
||
|
<el-input v-model="dataForm.place" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.place')])" clearable />
|
||
|
</el-form-item>
|
||
|
<el-form-item :label="$t('module.basicData.visual.Remarks')" prop="remark">
|
||
|
<el-input v-model="dataForm.remark" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.Remarks')])" clearable />
|
||
|
</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,
|
||
|
name: '',
|
||
|
code: '',
|
||
|
anotherName: '',
|
||
|
place: '',
|
||
|
remark: ''
|
||
|
},
|
||
|
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 = {
|
||
|
'name': this.dataForm.name,
|
||
|
'code': this.dataForm.code,
|
||
|
'anotherName': this.dataForm.anotherName,
|
||
|
'place': this.dataForm.place,
|
||
|
'remark': this.dataForm.remark,
|
||
|
'shelfId': this.shelfId,
|
||
|
'id': this.dataForm.id
|
||
|
}
|
||
|
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 => {
|
||
|
this.$message({
|
||
|
message: this.$t('module.basicData.visual.success'),
|
||
|
type: 'success',
|
||
|
duration: 1500,
|
||
|
onClose: () => {
|
||
|
this.visible = false
|
||
|
this.$emit('refreshDataList')
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|