mt-ck-wms-ui/src/views/report-manage/components/report-edit.vue

88 lines
2.4 KiB
Vue
Raw Normal View History

2021-09-13 14:56:28 +08:00
<!--
* @Author: gtz
* @Date: 2021-04-22 19:31:36
* @LastEditors: gtz
* @LastEditTime: 2021-04-22 20:40:57
* @Description: file content
-->
<template>
<el-dialog
:title="'btn.edit' | i18nFilter"
:visible.sync="visible"
>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="120px" @keyup.enter.native="dataFormSubmit()">
<el-form-item :label="$t('module.report.reportList.reportName')" prop="fileName">
<el-input v-model="dataForm.fileName" :placeholder="$i18nForm(['placeholder.input', $t('module.report.reportList.reportName')])" 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 { getInfo, update } from '@/api/report-manage/report'
export default {
data() {
return {
visible: false,
dataForm: {
id: null,
fileName: '',
name: ''
},
dataRule: {
fileName: [
{
required: true,
message: this.$i18nForm(['placeholder.input', this.$t('module.report.reportList.reportName')]),
trigger: 'blur'
}
]
}
}
},
methods: {
init(id) {
this.dataForm.id = id || ''
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
getInfo({ id: this.dataForm.id }).then(res => {
this.dataForm.fileName = res.data.fileName
})
}
})
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
const data = {
'fileName': this.dataForm.fileName,
'id': this.dataForm.id
}
if (this.dataForm.id) {
update(data).then(res => {
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
}
}
})
}
}
}
</script>