Blame view

src/components/fee/addFeeConfig.vue 13.4 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
4a60bc89   wuxw   完成费用项页面
2
    <el-dialog :title="$t('common.add')" :visible.sync="visible" width="80%" @close="resetForm">
cbb75297   wuxw   优化代码
3
      <el-form :model="form" :rules="rules" label-width="150px" ref="form">
4a60bc89   wuxw   完成费用项页面
4
5
6
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.feeType')" prop="feeTypeCd" required>
963f5a4f   wuxw   车辆功能测试完成
7
8
              <el-select v-model="form.feeTypeCd" @change="changeAddFeeTypeCd"
                :placeholder="$t('feeConfigManage.feeType')" class="full-width-select">
4a60bc89   wuxw   完成费用项页面
9
10
11
12
13
14
15
16
17
18
19
                <el-option v-for="item in feeTypeCds" :key="item.statusCd" :label="item.name" :value="item.statusCd" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.feeItem')" prop="feeName" required>
              <el-input v-model="form.feeName" :placeholder="$t('feeConfigManage.enterFeeItem')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.feeFlag')" prop="feeFlag" required>
963f5a4f   wuxw   车辆功能测试完成
20
21
              <el-select v-model="form.feeFlag" :placeholder="$t('feeConfigManage.selectFeeFlag')"
                class="full-width-select">
4a60bc89   wuxw   完成费用项页面
22
23
24
25
26
27
                <el-option v-for="item in feeFlags" :key="item.statusCd" :label="item.name" :value="item.statusCd" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.paymentType')" prop="paymentCd" required>
963f5a4f   wuxw   车辆功能测试完成
28
29
              <el-select v-model="form.paymentCd" :placeholder="$t('feeConfigManage.selectPaymentType')"
                class="full-width-select">
4a60bc89   wuxw   完成费用项页面
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
                <el-option v-for="item in paymentCds" :key="item.statusCd" :label="item.name" :value="item.statusCd" />
              </el-select>
            </el-form-item>
          </el-col>
  
          <el-col :span="12" v-if="form.feeFlag != '2006012'">
            <el-form-item :label="$t('feeConfigManage.paymentCycle')" prop="paymentCycle" required>
              <el-input v-model="form.paymentCycle" :placeholder="$t('feeConfigManage.enterPaymentCycle')" />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.paymentCd == '1200'">
            <el-form-item :label="$t('feeConfigManage.prepaymentPeriod')" prop="prepaymentPeriod" required>
              <el-input v-model="form.prepaymentPeriod" :placeholder="$t('feeConfigManage.enterPrepaymentPeriod')" />
            </el-form-item>
          </el-col>
  
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.unit')" prop="units" required>
              <el-input v-model="form.units" :placeholder="$t('feeConfigManage.enterUnit')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.accountDeduction')" prop="deductFrom">
              <el-select v-model="form.deductFrom" class="full-width-select">
                <el-option :label="$t('common.yes')" value="Y" />
                <el-option :label="$t('common.no')" value="N" />
              </el-select>
            </el-form-item>
          </el-col>
  
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.mobilePayment')" prop="payOnline">
              <el-select v-model="form.payOnline" class="full-width-select">
                <el-option :label="$t('common.yes')" value="Y" />
                <el-option :label="$t('common.no')" value="N" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.roundingMethod')" prop="scale">
              <el-select v-model="form.scale" class="full-width-select">
                <el-option :label="$t('feeConfigManage.roundHalfUp')" value="1" />
                <el-option :label="$t('feeConfigManage.roundUp')" value="3" />
                <el-option :label="$t('feeConfigManage.roundDown')" value="4" />
              </el-select>
            </el-form-item>
          </el-col>
  
          <el-col :span="12">
            <el-form-item :label="$t('feeConfigManage.decimalPlaces')" prop="decimalPlace">
              <el-select v-model="form.decimalPlace" class="full-width-select">
                <el-option :label="$t('feeConfigManage.integer')" value="0" />
                <el-option :label="$t('feeConfigManage.oneDecimal')" value="1" />
                <el-option :label="$t('feeConfigManage.twoDecimal')" value="2" />
                <el-option :label="$t('feeConfigManage.threeDecimal')" value="3" />
                <el-option :label="$t('feeConfigManage.fourDecimal')" value="4" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('common.status')" prop="state">
              <el-select v-model="form.state" class="full-width-select">
                <el-option :label="$t('common.enabled')" value="Y" />
                <el-option :label="$t('common.disabled')" value="N" />
              </el-select>
            </el-form-item>
          </el-col>
  
          <el-col :span="24">
63ef3e7f   wuxw   v1.9 加入天麟收据模版
99
            <el-form-item :label="$t('feeConfigManage.formula')" prop="computingFormula" >
963f5a4f   wuxw   车辆功能测试完成
100
101
102
103
              <el-select v-model="form.computingFormula" :placeholder="$t('feeConfigManage.selectFormula')"
                class="full-width-select">
                <el-option v-for="item in computingFormulas" :key="item.statusCd" :label="item.name"
                  :value="item.statusCd" />
4a60bc89   wuxw   完成费用项页面
104
105
106
107
108
109
              </el-select>
            </el-form-item>
          </el-col>
  
          <template v-if="shouldShowUnitPrice">
            <el-col :span="24">
63ef3e7f   wuxw   v1.9 加入天麟收据模版
110
              <el-form-item :label="$t('feeConfigManage.unitPrice')" prop="squarePrice" >
4a60bc89   wuxw   完成费用项页面
111
112
113
114
115
116
117
                <el-input v-model="form.squarePrice" :placeholder="$t('feeConfigManage.enterUnitPrice')" />
              </el-form-item>
            </el-col>
          </template>
  
          <template v-if="shouldShowAdditionalAmount">
            <el-col :span="24">
63ef3e7f   wuxw   v1.9 加入天麟收据模版
118
              <el-form-item :label="additionalAmountLabel" prop="additionalAmount" >
4a60bc89   wuxw   完成费用项页面
119
120
121
122
123
124
125
                <el-input v-model="form.additionalAmount" :placeholder="$t('feeConfigManage.enterAdditionalFee')" />
              </el-form-item>
            </el-col>
          </template>
  
          <template v-if="form.computingFormula == '7007'">
            <el-col :span="24">
63ef3e7f   wuxw   v1.9 加入天麟收据模版
126
              <el-form-item :label="$t('feeConfigManage.formula')" prop="computingFormulaText" >
963f5a4f   wuxw   车辆功能测试完成
127
128
                <el-input type="textarea" v-model="form.computingFormulaText"
                  :placeholder="$t('feeConfigManage.enterFormula')" :rows="4" />
4a60bc89   wuxw   完成费用项页面
129
130
              </el-form-item>
            </el-col>
0e772b97   wuxw   v1.9 优化一些细微bug
131
            <el-col :span="24" class="text-left">
4a60bc89   wuxw   完成费用项页面
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
              <el-form-item :label="$t('common.explanation')">
                <div>C {{ $t('feeConfigManage.explanationC') }}</div>
                <div>F {{ $t('feeConfigManage.explanationF') }}</div>
                <div>U {{ $t('feeConfigManage.explanationU') }}</div>
                <div>R {{ $t('feeConfigManage.explanationR') }}</div>
                <div>X {{ $t('feeConfigManage.explanationX') }}</div>
                <div>L {{ $t('feeConfigManage.explanationL') }}</div>
                <div>{{ $t('feeConfigManage.example1') }}</div>
                <div>{{ $t('feeConfigManage.example2') }}</div>
              </el-form-item>
            </el-col>
          </template>
        </el-row>
      </el-form>
  
      <div slot="footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="saveFeeConfigInfo">{{ $t('common.save') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { saveFeeConfig } from '@/api/fee/feeConfigManageApi'
  import { getDict } from '@/api/community/communityApi'
  
  export default {
    name: 'AddFeeConfig',
    data() {
      return {
        visible: false,
        form: {
          feeTypeCd: '',
          feeName: '',
          feeFlag: '',
          paymentCd: '1200',
          paymentCycle: '',
          prepaymentPeriod: '1',
          computingFormula: '',
          squarePrice: '',
          additionalAmount: '0.00',
          units: '元',
          deductFrom: 'Y',
          payOnline: 'Y',
          scale: '1',
          decimalPlace: '2',
          state: 'Y',
          computingFormulaText: '',
963f5a4f   wuxw   车辆功能测试完成
180
181
182
          startTime: '2025-01-01',
          endTime: '2050-01-01',
          billType: '002',
4a60bc89   wuxw   完成费用项页面
183
184
185
186
187
          communityId: this.getCommunityId()
        },
        feeTypeCds: [],
        computingFormulas: [],
        feeFlags: [],
cbb75297   wuxw   优化代码
188
189
190
191
192
193
194
195
196
197
        paymentCds: [],
        rules: {
          feeTypeCd: [{ required: true, message: this.$t('feeConfigManage.feeType'), trigger: 'change' }],
          feeName: [{ required: true, message: this.$t('feeConfigManage.enterFeeItem'), trigger: 'blur' }],
          feeFlag: [{ required: true, message: this.$t('feeConfigManage.selectFeeFlag'), trigger: 'change' }],
          paymentCd: [{ required: true, message: this.$t('feeConfigManage.selectPaymentType'), trigger: 'change' }],
          paymentCycle: [{ required: true, message: this.$t('feeConfigManage.enterPaymentCycle'), trigger: 'blur' }],
          prepaymentPeriod: [{ required: true, message: this.$t('feeConfigManage.enterPrepaymentPeriod'), trigger: 'blur' }],
          units: [{ required: true, message: this.$t('feeConfigManage.enterUnit'), trigger: 'blur' }],
          computingFormula: [{ required: true, message: this.$t('feeConfigManage.selectFormula'), trigger: 'change' }],
cbb75297   wuxw   优化代码
198
199
          computingFormulaText: [{ required: true, message: this.$t('feeConfigManage.enterFormula'), trigger: 'blur' }]
        }
4a60bc89   wuxw   完成费用项页面
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
      }
    },
    computed: {
      shouldShowUnitPrice() {
        return !['2002', '7007', '8008', '1101', '1102', '4004', '9009'].includes(this.form.computingFormula)
      },
      shouldShowAdditionalAmount() {
        return !['7007', '8008', '1101', '1102', '4004', '9009'].includes(this.form.computingFormula)
      },
      additionalAmountLabel() {
        return this.form.computingFormula == '1001'
          ? this.$t('feeConfigManage.additionalFee')
          : this.$t('feeConfigManage.fixedFee')
      }
    },
    created() {
      this.loadDicts()
    },
    methods: {
      open() {
        this.visible = true
      },
  
      async loadDicts() {
        try {
          const [feeTypeCds, computingFormulas, feeFlags, paymentCds] = await Promise.all([
            getDict('pay_fee_config', 'fee_type_cd'),
            getDict('pay_fee_config', 'computing_formula'),
            getDict('pay_fee_config', 'fee_flag'),
            getDict('pay_fee_config', 'payment_cd')
          ])
963f5a4f   wuxw   车辆功能测试完成
231
  
4a60bc89   wuxw   完成费用项页面
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
          this.feeTypeCds = feeTypeCds
          this.computingFormulas = computingFormulas
          this.feeFlags = feeFlags
          this.paymentCds = paymentCds
        } catch (error) {
          console.error('Failed to load dictionaries:', error)
          this.$message.error(this.$t('common.loadFailed'))
        }
      },
  
      changeAddFeeTypeCd() {
        const feeTypeCd = this.form.feeTypeCd
  
        // 水费、电费、煤气费
        if (['888800010015', '888800010016', '888800010009'].includes(feeTypeCd)) {
          this.form.feeFlag = '2006012'
          this.form.computingFormula = '5005'
          this.form.paymentCd = '2100'
        }
  
        // 押金
        if (feeTypeCd === '888800010006') {
          this.form.feeFlag = '2006012'
        }
  
        // 取暖费
        if (feeTypeCd === '888800010011') {
          this.form.feeFlag = '4012024'
          this.form.computingFormula = '3003'
        }
  
        // 物业费
        if (feeTypeCd === '888800010001') {
          this.form.feeFlag = '1003006'
          this.form.computingFormula = '1001'
        }
  
        // 租金
        if (feeTypeCd === '888800010018') {
          this.form.feeFlag = '1003006'
          this.form.computingFormula = '1101'
        }
  
        // 停车费
        if (feeTypeCd === '888800010008') {
          this.form.feeFlag = '1003006'
          this.form.computingFormula = '2002'
          this.form.paymentCycle = '1'
        }
  
        // 公摊费
        if (feeTypeCd === '888800010017') {
          this.form.feeFlag = '2006012'
          this.form.computingFormula = '4004'
          this.form.paymentCd = '2100'
        }
      },
  
      async saveFeeConfigInfo() {
        try {
          // 处理特殊公式
          if (this.form.computingFormula === '2002') {
            this.form.squarePrice = "0.00"
          }
  
          if (['7007', '8008', '1101', '1102', '4004', '9009'].includes(this.form.computingFormula)) {
            this.form.squarePrice = "0.00"
            this.form.additionalAmount = "0.00"
          }
  
          if (this.form.feeFlag === '2006012') {
            this.form.paymentCycle = '1'
          }
  
          if (this.form.paymentCd !== '1200') {
            this.form.prepaymentPeriod = '0'
          }
  
          // 表单验证
          await this.$refs.form.validate()
  
          // 调用API保存
cd705b0a   wuxw   v1.9 优化群里反馈 admin...
314
315
316
317
318
         const {code,msg} = await saveFeeConfig(this.form)
         if(code != 0){
          this.$message.error(msg)
          return
         }
4a60bc89   wuxw   完成费用项页面
319
  
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
320
          this.$message.success(this.$t('common.operationSuccess'))
4a60bc89   wuxw   完成费用项页面
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
          this.visible = false
          this.$emit('success')
        } catch (error) {
          this.$message.error(error.message || this.$t('common.saveFail'))
        }
      },
  
      resetForm() {
        this.$refs.form.resetFields()
        this.form = {
          feeTypeCd: '',
          feeName: '',
          feeFlag: '',
          paymentCd: '1200',
          paymentCycle: '',
          prepaymentPeriod: '1',
          computingFormula: '',
          squarePrice: '',
          additionalAmount: '0.00',
          units: '元',
          deductFrom: 'Y',
          payOnline: 'Y',
          scale: '1',
          decimalPlace: '2',
          state: 'Y',
963f5a4f   wuxw   车辆功能测试完成
346
347
348
          startTime: '2025-01-01',
          endTime: '2050-01-01',
          billType: '002',
4a60bc89   wuxw   完成费用项页面
349
350
351
352
353
354
355
356
357
358
359
360
361
          computingFormulaText: '',
          communityId: this.getCommunityId()
        }
      },
    }
  }
  </script>
  
  <style scoped>
  .full-width-select {
    width: 100%;
  }
  </style>