136 lines
4.4 KiB
Vue
136 lines
4.4 KiB
Vue
|
<template>
|
||
|
<el-dialog
|
||
|
:title="!dataForm.id ? '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.storageBox.name')" prop="storageBoxName">
|
||
|
<el-input v-model="dataForm.storageBoxName" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.storageBox.name')])" clearable />
|
||
|
</el-form-item>
|
||
|
<el-form-item :label="$t('module.basicData.storageBox.code')" prop="code">
|
||
|
<el-input v-model="dataForm.code" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.storageBox.code')])" clearable />
|
||
|
</el-form-item>
|
||
|
<el-form-item :label="$t('module.basicData.visual.EnglishName')" prop="enName">
|
||
|
<el-input v-model="dataForm.enName" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.EnglishName')])" clearable />
|
||
|
</el-form-item>
|
||
|
<el-form-item :label="$t('module.basicData.storageBox.status')" prop="status">
|
||
|
<el-select v-model="dataForm.status" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.storageBox.status')])" clearable>
|
||
|
<el-option
|
||
|
v-for="item in options"
|
||
|
:key="item.value"
|
||
|
:label="item.label"
|
||
|
:value="item.value"
|
||
|
/>
|
||
|
</el-select>
|
||
|
</el-form-item>
|
||
|
<el-form-item :label="$t('module.basicData.visual.Remarks')" prop="note">
|
||
|
<el-input v-model="dataForm.note" :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 { storageBoxDetail, storageBoxUpdate, storageBoxAdd, storageBoxCode } from '@/api/basicData/Cache/storageBox'
|
||
|
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
visible: false,
|
||
|
dataForm: {
|
||
|
id: 0,
|
||
|
storageBoxName: '',
|
||
|
code: '',
|
||
|
status: 0,
|
||
|
enName: '',
|
||
|
note: ''
|
||
|
},
|
||
|
options: [
|
||
|
{
|
||
|
value: 0,
|
||
|
label: '正常'
|
||
|
},
|
||
|
{
|
||
|
value: 1,
|
||
|
label: '维修中'
|
||
|
},
|
||
|
{
|
||
|
value: 2,
|
||
|
label: '报废'
|
||
|
}
|
||
|
],
|
||
|
dataRule: {
|
||
|
storageBoxName: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.storageBox.name')]),
|
||
|
trigger: 'blur' }
|
||
|
],
|
||
|
code: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.storageBox.code')]),
|
||
|
trigger: 'blur' }
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
init(id) {
|
||
|
this.dataForm.id = id || ''
|
||
|
this.visible = true
|
||
|
this.$nextTick(() => {
|
||
|
this.$refs['dataForm'].resetFields()
|
||
|
if (this.dataForm.id) {
|
||
|
storageBoxDetail(this.dataForm.id).then(res => {
|
||
|
this.dataForm = res.data
|
||
|
})
|
||
|
} else {
|
||
|
storageBoxCode().then(res => {
|
||
|
this.dataForm.code = res.data
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
// 表单提交
|
||
|
dataFormSubmit() {
|
||
|
this.$refs['dataForm'].validate((valid) => {
|
||
|
if (valid) {
|
||
|
const data = this.dataForm
|
||
|
data.id = this.dataForm.id
|
||
|
if (this.dataForm.id) {
|
||
|
storageBoxUpdate(data).then(res => {
|
||
|
this.$message({
|
||
|
message: this.$t('module.basicData.visual.success'),
|
||
|
type: 'success',
|
||
|
duration: 1500,
|
||
|
onClose: () => {
|
||
|
this.visible = false
|
||
|
this.$emit('refreshDataList')
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
} else {
|
||
|
storageBoxAdd(data).then(res => {
|
||
|
this.$message({
|
||
|
message: this.$t('module.basicData.visual.success'),
|
||
|
type: 'success',
|
||
|
duration: 1500,
|
||
|
onClose: () => {
|
||
|
this.visible = false
|
||
|
this.$emit('refreshDataList')
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|