Blame view

src/components/fee/exportFeeImportExcel.vue 4.1 KB
24d3590f   wuxw   房屋收费页面开发完成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
  <template>
    <el-dialog
      :title="$t('exportFeeImportExcel.title')"
      :visible.sync="visible"
      width="70%"
      :before-close="handleClose"
    >
      <el-form label-width="120px">
        <el-form-item :label="$t('exportFeeImportExcel.floor')">
          <div>
            <el-checkbox 
              v-model="isFloorAll" 
              @change="toggleAllFloors"
            >{{ $t('exportFeeImportExcel.all') }}</el-checkbox>
            <el-checkbox
              v-for="item in floors"
              :key="item.floorId"
              v-model="selectedFloorIds"
              :label="item.floorId"
              @change="handleFloorChange"
              class="margin-left"
            >{{ item.floorName }}</el-checkbox>
          </div>
        </el-form-item>
  
        <el-form-item :label="$t('exportFeeImportExcel.feeItem')">
          <div>
            <el-checkbox 
              v-model="isConfigAll" 
              @change="toggleAllConfigs"
            >{{ $t('exportFeeImportExcel.all') }}</el-checkbox>
            <el-checkbox
              v-for="item in configs"
              :key="item.configId"
              v-model="selectedConfigIds"
              :label="item.configId"
              @change="handleConfigChange"
              class="margin-left"
            >{{ item.feeName }}</el-checkbox>
          </div>
        </el-form-item>
      </el-form>
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleExport">{{ $t('common.export') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { exportData, listFeeConfigs, queryFloors } from '@/api/fee/exportFeeImportExcelApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'ExportFeeImportExcel',
    data() {
      return {
        visible: false,
        isFloorAll: true,
        isConfigAll: true,
        selectedFloorIds: [],
        selectedConfigIds: [],
        floors: [],
        configs: []
      }
    },
    computed: {
      communityId() {
        return getCommunityId()
      }
    },
    methods: {
      open() {
        this.visible = true
        this.loadFloors()
        this.loadConfigs()
      },
      
      loadFloors() {
        queryFloors({
          page: 1,
          row: 150,
          communityId: this.communityId
        }).then(response => {
          this.floors = response.data.apiFloorDataVoList
          this.selectedFloorIds = this.floors.map(item => item.floorId)
        })
      },
      
      loadConfigs() {
        listFeeConfigs({
          page: 1,
          row: 100,
          communityId: this.communityId,
          isDefault: 'F'
        }).then(response => {
          this.configs = response.data.feeConfigs
          this.selectedConfigIds = this.configs.map(item => item.configId)
        })
      },
      
      toggleAllFloors() {
        this.selectedFloorIds = this.isFloorAll 
          ? this.floors.map(item => item.floorId)
          : []
      },
      
      toggleAllConfigs() {
        this.selectedConfigIds = this.isConfigAll
          ? this.configs.map(item => item.configId)
          : []
      },
      
      handleFloorChange() {
        this.isFloorAll = this.selectedFloorIds.length === this.floors.length
      },
      
      handleConfigChange() {
        this.isConfigAll = this.selectedConfigIds.length === this.configs.length
      },
      
      handleExport() {
        const params = {
          floorIds: this.selectedFloorIds.join(','),
          configIds: this.selectedConfigIds.join(','),
          communityId: this.communityId,
          type: '1001',
          pagePath: 'exportCreateFeeTemplate'
        }
        
        exportData(params).then(response => {
          this.$message.success(response.data.msg)
          if (response.data.code === 0) {
            this.handleClose()
            this.$router.push('/pages/property/downloadTempFile?tab=下载中心')
          }
        }).catch(error => {
          this.$message.error(error.message)
        })
      },
      
      handleClose() {
        this.visible = false
        this.reset()
      },
      
      reset() {
        this.isFloorAll = true
        this.isConfigAll = true
        this.selectedFloorIds = []
        this.selectedConfigIds = []
      }
    }
  }
  </script>
  
  <style scoped>
  .margin-left {
    margin-left: 15px;
  }
  </style>