Blame view

src/components/fee/roomCreateFeeAdd.vue 8.51 KB
24d3590f   wuxw   房屋收费页面开发完成
1
  <template>
814833f5   wuxw   优化费用缴费代码
2
    <el-dialog :title="$t('roomCreateFeeAdd.title')" :visible.sync="visible" width="40%" :before-close="handleClose">
24d3590f   wuxw   房屋收费页面开发完成
3
4
      <el-form ref="form" :model="formData" label-width="120px">
        <el-form-item :label="$t('roomCreateFeeAdd.location')">
814833f5   wuxw   优化费用缴费代码
5
6
          <el-input v-model="formData.locationTypeCdName" disabled
            :placeholder="$t('roomCreateFeeAdd.locationPlaceholder')"></el-input>
24d3590f   wuxw   房屋收费页面开发完成
7
        </el-form-item>
814833f5   wuxw   优化费用缴费代码
8
  
24d3590f   wuxw   房屋收费页面开发完成
9
        <el-form-item :label="$t('roomCreateFeeAdd.feeType')" prop="feeTypeCd">
814833f5   wuxw   优化费用缴费代码
10
11
          <el-select v-model="formData.feeTypeCd" @change="handleFeeTypeChange"
            :placeholder="$t('roomCreateFeeAdd.feeTypePlaceholder')" style="width: 100%">
24d3590f   wuxw   房屋收费页面开发完成
12
            <template v-for="item in feeTypeOptions">
814833f5   wuxw   优化费用缴费代码
13
14
              <el-option v-if="item.statusCd != '888800010017'" :key="item.statusCd" :label="item.name"
                :value="item.statusCd"></el-option>
24d3590f   wuxw   房屋收费页面开发完成
15
16
17
18
            </template>
          </el-select>
        </el-form-item>
  
814833f5   wuxw   优化费用缴费代码
19
20
21
22
23
        <el-form-item v-if="formData.feeTypeCd" :label="$t('roomCreateFeeAdd.feeItem')" prop="configId">
          <el-select v-model="formData.configId" @change="handleConfigChange"
            :placeholder="$t('roomCreateFeeAdd.feeItemPlaceholder')" style="width: 100%">
            <el-option v-for="item in feeConfigOptions" :key="item.configId" :label="item.feeName"
              :value="item.configId"></el-option>
24d3590f   wuxw   房屋收费页面开发完成
24
25
26
          </el-select>
        </el-form-item>
  
814833f5   wuxw   优化费用缴费代码
27
28
        <el-form-item v-if="formData.computingFormula == '4004'" :label="$t('roomCreateFeeAdd.amount')" prop="amount">
          <el-input v-model="formData.amount" :placeholder="$t('roomCreateFeeAdd.amountPlaceholder')"></el-input>
24d3590f   wuxw   房屋收费页面开发完成
29
30
31
        </el-form-item>
  
        <el-form-item :label="$t('roomCreateFeeAdd.startTime')" prop="startTime">
814833f5   wuxw   优化费用缴费代码
32
33
34
          <el-date-picker v-model="formData.startTime" type="date"
            :placeholder="$t('roomCreateFeeAdd.startTimePlaceholder')" value-format="yyyy-MM-dd"
            @change="validateStartTime"></el-date-picker>
24d3590f   wuxw   房屋收费页面开发完成
35
36
37
        </el-form-item>
  
        <el-form-item :label="$t('roomCreateFeeAdd.endTime')" prop="endTime">
814833f5   wuxw   优化费用缴费代码
38
39
          <el-date-picker v-model="formData.endTime" type="date" :placeholder="$t('roomCreateFeeAdd.endTimePlaceholder')"
            value-format="yyyy-MM-dd" @change="validateEndTime"></el-date-picker>
24d3590f   wuxw   房屋收费页面开发完成
40
41
        </el-form-item>
  
814833f5   wuxw   优化费用缴费代码
42
43
44
        <el-form-item v-show="formData.computingFormula == '1102'" :label="$t('roomCreateFeeAdd.rateCycle')"
          prop="rateCycle">
          <el-input v-model="formData.rateCycle" :placeholder="$t('roomCreateFeeAdd.rateCyclePlaceholder')"></el-input>
24d3590f   wuxw   房屋收费页面开发完成
45
46
        </el-form-item>
  
814833f5   wuxw   优化费用缴费代码
47
48
        <el-form-item v-show="formData.computingFormula == '1102'" :label="$t('roomCreateFeeAdd.rate')" prop="rate">
          <el-input v-model="formData.rate" :placeholder="$t('roomCreateFeeAdd.ratePlaceholder')"></el-input>
24d3590f   wuxw   房屋收费页面开发完成
49
50
        </el-form-item>
  
814833f5   wuxw   优化费用缴费代码
51
52
53
54
        <el-form-item v-show="formData.computingFormula == '1102'" :label="$t('roomCreateFeeAdd.rateStartTime')"
          prop="rateStartTime">
          <el-date-picker v-model="formData.rateStartTime" type="date"
            :placeholder="$t('roomCreateFeeAdd.rateStartTimePlaceholder')" value-format="yyyy-MM-dd"></el-date-picker>
24d3590f   wuxw   房屋收费页面开发完成
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
        </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="handleSubmit">{{ $t('common.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { saveRoomCreateFee, listFeeConfigs } from '@/api/fee/roomCreateFeeAddApi'
  import { getDict, getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'RoomCreateFeeAdd',
    data() {
      return {
        visible: false,
        formData: {
          feeTypeCds: [],
          feeConfigs: [],
          locationTypeCd: '',
          locationObjId: '',
          feeTypeCd: '',
          configId: '',
          locationTypeCdName: '',
          startTime: '',
          endTime: '2050-01-01',
          computingFormula: '',
          amount: '',
          rateCycle: '',
          rate: '',
          rateStartTime: '',
          feeFlag: ''
        },
        feeTypeOptions: [],
        feeConfigOptions: [],
        rules: {
          locationObjId: [
            { required: true, message: this.$t('roomCreateFeeAdd.validate.locationRequired'), trigger: 'blur' }
          ],
          feeTypeCd: [
            { required: true, message: this.$t('roomCreateFeeAdd.validate.feeTypeRequired'), trigger: 'change' }
          ],
          configId: [
            { required: true, message: this.$t('roomCreateFeeAdd.validate.feeItemRequired'), trigger: 'change' }
          ],
          startTime: [
            { required: true, message: this.$t('roomCreateFeeAdd.validate.startTimeRequired'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(room) {
        this.resetForm()
        this.formData.locationObjId = room.roomId
        this.formData.locationTypeCdName = `${room.floorNum}-${room.unitNum}-${room.roomNum}(${room.ownerName})`
814833f5   wuxw   优化费用缴费代码
114
  
24d3590f   wuxw   房屋收费页面开发完成
115
116
117
        if (room.roomName) {
          this.formData.locationTypeCdName = room.roomName
        }
814833f5   wuxw   优化费用缴费代码
118
  
24d3590f   wuxw   房屋收费页面开发完成
119
120
121
122
        this.formData.roomType = room.roomType
        if (room.roomType === '2020602') {
          this.formData.locationTypeCdName = `${room.floorNum}-${room.roomNum}(${room.ownerName})`
        }
814833f5   wuxw   优化费用缴费代码
123
  
24d3590f   wuxw   房屋收费页面开发完成
124
125
126
        this.loadFeeTypes()
        this.visible = true
      },
814833f5   wuxw   优化费用缴费代码
127
  
24d3590f   wuxw   房屋收费页面开发完成
128
129
      loadFeeTypes() {
        getDict('pay_fee_config', 'fee_type_cd').then(data => {
814833f5   wuxw   优化费用缴费代码
130
          this.feeTypeOptions = data.filter(item =>
24d3590f   wuxw   房屋收费页面开发完成
131
132
133
134
            item.statusCd !== '888800010015' && item.statusCd !== '888800010016'
          )
        })
      },
814833f5   wuxw   优化费用缴费代码
135
  
24d3590f   wuxw   房屋收费页面开发完成
136
137
138
139
140
      handleFeeTypeChange(value) {
        if (value === '888800010006' || value === '888800010014') {
          this.formData.startTime = this.$dayjs().format('YYYY-MM-DD')
          this.formData.endTime = this.$dayjs().add(1, 'month').format('YYYY-MM-DD')
        }
814833f5   wuxw   优化费用缴费代码
141
  
24d3590f   wuxw   房屋收费页面开发完成
142
143
144
        this.formData.configId = ''
        this.loadFeeConfigs(value)
      },
814833f5   wuxw   优化费用缴费代码
145
  
24d3590f   wuxw   房屋收费页面开发完成
146
147
148
149
150
151
152
153
154
      loadFeeConfigs(feeTypeCd) {
        listFeeConfigs({
          page: 1,
          row: 500,
          communityId: getCommunityId(),
          feeTypeCd,
          isDefault: 'F',
          state: 'Y'
        }).then(response => {
814833f5   wuxw   优化费用缴费代码
155
          this.feeConfigOptions = response.feeConfigs
24d3590f   wuxw   房屋收费页面开发完成
156
157
        })
      },
814833f5   wuxw   优化费用缴费代码
158
  
24d3590f   wuxw   房屋收费页面开发完成
159
      handleConfigChange(configId) {
814833f5   wuxw   优化费用缴费代码
160
161
162
        if (this.formData.feeTypeCd !== '888800010006' &&
          this.formData.feeTypeCd !== '888800010014' &&
          this.formData.feeFlag === '1003006') {
24d3590f   wuxw   房屋收费页面开发完成
163
164
          this.formData.endTime = ''
        }
814833f5   wuxw   优化费用缴费代码
165
  
24d3590f   wuxw   房屋收费页面开发完成
166
167
168
169
170
171
        const config = this.feeConfigOptions.find(item => item.configId === configId)
        if (config) {
          this.formData.feeFlag = config.feeFlag
          this.formData.computingFormula = config.computingFormula
        }
      },
814833f5   wuxw   优化费用缴费代码
172
  
24d3590f   wuxw   房屋收费页面开发完成
173
174
175
176
177
178
179
180
181
182
      validateStartTime(value) {
        if (!this.formData.feeFlag && !this.formData.feeTypeCd) {
          const start = new Date(value)
          const end = new Date(this.formData.endTime)
          if (start >= end) {
            this.$message.error(this.$t('roomCreateFeeAdd.validate.startBeforeEnd'))
            this.formData.startTime = ''
          }
        }
      },
814833f5   wuxw   优化费用缴费代码
183
  
24d3590f   wuxw   房屋收费页面开发完成
184
185
186
187
188
189
190
191
      validateEndTime(value) {
        const start = new Date(this.formData.startTime)
        const end = new Date(value)
        if (start >= end) {
          this.$message.error(this.$t('roomCreateFeeAdd.validate.endAfterStart'))
          this.formData.endTime = ''
        }
      },
814833f5   wuxw   优化费用缴费代码
192
  
24d3590f   wuxw   房屋收费页面开发完成
193
194
195
      handleSubmit() {
        this.$refs.form.validate(valid => {
          if (!valid) return
814833f5   wuxw   优化费用缴费代码
196
  
24d3590f   wuxw   房屋收费页面开发完成
197
198
199
200
201
202
          if (this.formData.feeTypeCd !== '888800010006' && this.formData.feeFlag !== '1003006') {
            if (!this.formData.endTime) {
              this.$message.error(this.$t('roomCreateFeeAdd.validate.endTimeRequired'))
              return
            }
          }
814833f5   wuxw   优化费用缴费代码
203
  
24d3590f   wuxw   房屋收费页面开发完成
204
205
206
207
          const params = {
            ...this.formData,
            communityId: getCommunityId()
          }
814833f5   wuxw   优化费用缴费代码
208
  
24d3590f   wuxw   房屋收费页面开发完成
209
210
211
212
213
214
215
216
217
          saveRoomCreateFee(params).then(() => {
            this.$message.success(this.$t('roomCreateFeeAdd.successMessage'))
            this.$emit('success')
            this.handleClose()
          }).catch(error => {
            this.$message.error(error.message)
          })
        })
      },
814833f5   wuxw   优化费用缴费代码
218
  
24d3590f   wuxw   房屋收费页面开发完成
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
      resetForm() {
        if (this.$refs.form) {
          this.$refs.form.resetFields()
        }
        this.formData = {
          feeTypeCds: [],
          feeConfigs: [],
          locationTypeCd: '',
          locationObjId: '',
          feeTypeCd: '',
          configId: '',
          locationTypeCdName: '',
          startTime: '',
          endTime: '2050-01-01',
          computingFormula: '',
          amount: '',
          rateCycle: '',
          rate: '',
          rateStartTime: '',
          feeFlag: ''
        }
      },
814833f5   wuxw   优化费用缴费代码
241
  
24d3590f   wuxw   房屋收费页面开发完成
242
243
244
245
246
247
      handleClose() {
        this.visible = false
        this.resetForm()
      }
    }
  }
814833f5   wuxw   优化费用缴费代码
248
249
250
251
252
253
254
255
256
257
258
259
260
  </script>
  <style scoped>
  .el-form-item{
    width: 90%;
    text-align: left;
  }
  .el-select{
    width: 100%;
  }
  .el-date-editor{  
    width: 100%;
  }
  </style>