2e0fd29c
wuxw
开发报修
|
1
|
<template>
|
24d3590f
wuxw
房屋收费页面开发完成
|
2
3
4
5
6
|
<el-dialog
:title="$t('doImportCreateFee.title')"
:visible.sync="visible"
width="70%"
:before-close="handleClose"
|
2e0fd29c
wuxw
开发报修
|
7
|
>
|
24d3590f
wuxw
房屋收费页面开发完成
|
8
|
<el-form label-width="120px">
|
2e0fd29c
wuxw
开发报修
|
9
10
11
|
<el-form-item :label="$t('doImportCreateFee.selectFile')">
<el-upload
class="upload-demo"
|
24d3590f
wuxw
房屋收费页面开发完成
|
12
13
14
|
action=""
:auto-upload="false"
:on-change="handleFileChange"
|
2e0fd29c
wuxw
开发报修
|
15
|
:show-file-list="false"
|
24d3590f
wuxw
房屋收费页面开发完成
|
16
|
accept=".xls,.xlsx"
|
2e0fd29c
wuxw
开发报修
|
17
|
>
|
24d3590f
wuxw
房屋收费页面开发完成
|
18
19
20
|
<el-button size="small" type="primary">{{ $t('doImportCreateFee.clickUpload') }}</el-button>
<div slot="tip" class="el-upload__tip">
{{ fileName || $t('doImportCreateFee.fileTip') }}
|
2e0fd29c
wuxw
开发报修
|
21
22
23
24
|
</div>
</el-upload>
</el-form-item>
</el-form>
|
24d3590f
wuxw
房屋收费页面开发完成
|
25
26
27
28
29
30
31
32
33
|
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
<el-button
type="primary"
@click="handleImport"
:disabled="!fileName"
>{{ $t('common.import') }}</el-button>
</span>
|
2e0fd29c
wuxw
开发报修
|
34
35
36
37
|
</el-dialog>
</template>
<script>
|
24d3590f
wuxw
房屋收费页面开发完成
|
38
39
|
import { importData } from '@/api/fee/doImportCreateFeeApi'
import { getCommunityId } from '@/api/community/communityApi'
|
2e0fd29c
wuxw
开发报修
|
40
41
42
43
44
45
46
47
48
49
|
export default {
name: 'DoImportCreateFee',
data() {
return {
visible: false,
file: null,
fileName: ''
}
},
|
24d3590f
wuxw
房屋收费页面开发完成
|
50
51
52
53
54
|
computed: {
communityId() {
return getCommunityId()
}
},
|
2e0fd29c
wuxw
开发报修
|
55
56
57
|
methods: {
open() {
this.visible = true
|
24d3590f
wuxw
房屋收费页面开发完成
|
58
|
this.reset()
|
2e0fd29c
wuxw
开发报修
|
59
|
},
|
24d3590f
wuxw
房屋收费页面开发完成
|
60
61
62
63
|
handleFileChange(file) {
if (!this.checkFileType(file.name)) {
this.$message.error(this.$t('doImportCreateFee.validate.invalidFileType'))
|
2e0fd29c
wuxw
开发报修
|
64
65
|
return false
}
|
24d3590f
wuxw
房屋收费页面开发完成
|
66
67
68
|
if (!this.checkFileSize(file.size)) {
this.$message.error(this.$t('doImportCreateFee.validate.fileTooLarge'))
|
2e0fd29c
wuxw
开发报修
|
69
70
71
|
return false
}
|
24d3590f
wuxw
房屋收费页面开发完成
|
72
|
this.file = file.raw
|
2e0fd29c
wuxw
开发报修
|
73
|
this.fileName = file.name
|
2e0fd29c
wuxw
开发报修
|
74
|
},
|
24d3590f
wuxw
房屋收费页面开发完成
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
checkFileType(filename) {
const ext = filename.split('.').pop().toLowerCase()
return ['xls', 'xlsx'].includes(ext)
},
checkFileSize(size) {
return size <= 2 * 1024 * 1024 // 2MB
},
handleImport() {
const formData = new FormData()
formData.append('uploadFile', this.file)
formData.append('communityId', this.communityId)
formData.append('importAdapt', 'importCustomFee')
|
2e0fd29c
wuxw
开发报修
|
90
|
|
24d3590f
wuxw
房屋收费页面开发完成
|
91
92
|
importData(formData).then(response => {
const res = response.data
|
2e0fd29c
wuxw
开发报修
|
93
|
if (res.code === 0) {
|
24d3590f
wuxw
房屋收费页面开发完成
|
94
95
96
|
this.$message.success(this.$t('doImportCreateFee.successMessage'))
this.handleClose()
this.$router.push(`/pages/property/assetImportLogDetail?logId=${res.data.logId}&logType=importCustomFee`)
|
2e0fd29c
wuxw
开发报修
|
97
|
} else {
|
24d3590f
wuxw
房屋收费页面开发完成
|
98
|
this.$message.error(res.msg)
|
2e0fd29c
wuxw
开发报修
|
99
|
}
|
24d3590f
wuxw
房屋收费页面开发完成
|
100
101
102
103
104
105
106
107
108
109
110
111
112
|
}).catch(error => {
this.$message.error(error.message)
})
},
handleClose() {
this.visible = false
this.reset()
},
reset() {
this.file = null
this.fileName = ''
|
2e0fd29c
wuxw
开发报修
|
113
114
115
116
|
}
}
}
</script>
|