Blame view

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