Blame view

src/components/fee/editFee.vue 5.56 KB
2e0fd29c   wuxw   开发报修
1
  <template>
24d3590f   wuxw   房屋收费页面开发完成
2
3
4
5
6
7
    <el-dialog
      :title="$t('editFee.title')"
      :visible.sync="visible"
      width="50%"
      :before-close="handleClose"
    >
2e0fd29c   wuxw   开发报修
8
      <el-form :model="editFeeInfo" label-width="120px">
24d3590f   wuxw   房屋收费页面开发完成
9
10
11
12
13
14
15
16
        <el-form-item :label="$t('editFee.startTime')" prop="startTime">
          <el-date-picker
            v-model="editFeeInfo.startTime"
            type="datetime"
            :placeholder="$t('editFee.startTimePlaceholder')"
            value-format="yyyy-MM-dd HH:mm:ss"
            @change="validateStartTime"
          ></el-date-picker>
2e0fd29c   wuxw   开发报修
17
        </el-form-item>
24d3590f   wuxw   房屋收费页面开发完成
18
19
20
21
22
23
24
25
        <el-form-item :label="$t('editFee.endTime')" prop="endTime">
          <el-date-picker
            v-model="editFeeInfo.endTime"
            type="date"
            :placeholder="$t('editFee.endTimePlaceholder')"
            value-format="yyyy-MM-dd"
            @change="validateEndTime"
          ></el-date-picker>
2e0fd29c   wuxw   开发报修
26
        </el-form-item>
24d3590f   wuxw   房屋收费页面开发完成
27
28
29
30
31
32
33
34
        <el-form-item :label="$t('editFee.maxEndTime')" prop="maxEndTime">
          <el-date-picker
            v-model="editFeeInfo.maxEndTime"
            type="date"
            :placeholder="$t('editFee.maxEndTimePlaceholder')"
            value-format="yyyy-MM-dd"
            @change="validateMaxEndTime"
          ></el-date-picker>
2e0fd29c   wuxw   开发报修
35
        </el-form-item>
24d3590f   wuxw   房屋收费页面开发完成
36
37
38
39
40
41
        <template v-if="editFeeInfo.computingFormula === '1102'">
          <el-form-item :label="$t('editFee.rateCycle')" prop="rateCycle">
            <el-input
              v-model="editFeeInfo.rateCycle"
              :placeholder="$t('editFee.rateCyclePlaceholder')"
            ></el-input>
2e0fd29c   wuxw   开发报修
42
          </el-form-item>
24d3590f   wuxw   房屋收费页面开发完成
43
44
45
46
47
          <el-form-item :label="$t('editFee.rate')" prop="rate">
            <el-input
              v-model="editFeeInfo.rate"
              :placeholder="$t('editFee.ratePlaceholder')"
            ></el-input>
2e0fd29c   wuxw   开发报修
48
          </el-form-item>
24d3590f   wuxw   房屋收费页面开发完成
49
50
51
52
53
54
55
56
          <el-form-item :label="$t('editFee.rateStartTime')" prop="rateStartTime">
            <el-date-picker
              v-model="editFeeInfo.rateStartTime"
              type="date"
              :placeholder="$t('editFee.rateStartTimePlaceholder')"
              value-format="yyyy-MM-dd"
              @change="validateRateStartTime"
            ></el-date-picker>
2e0fd29c   wuxw   开发报修
57
58
59
60
          </el-form-item>
        </template>
      </el-form>
      <span slot="footer" class="dialog-footer">
24d3590f   wuxw   房屋收费页面开发完成
61
        <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
2e0fd29c   wuxw   开发报修
62
63
64
65
66
67
        <el-button type="primary" @click="_doEidtFee">{{ $t('common.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
24d3590f   wuxw   房屋收费页面开发完成
68
69
  import { updateFee } from '@/api/fee/editFeeApi'
  import { getCommunityId } from '@/api/community/communityApi'
2e0fd29c   wuxw   开发报修
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  
  export default {
    name: 'EditFee',
    data() {
      return {
        visible: false,
        editFeeInfo: {
          feeId: '',
          startTime: '',
          endTime: '',
          feeFlag: '',
          maxEndTime: '',
          computingFormula: '',
          rateCycle: '',
          rate: '',
          rateStartTime: ''
        }
      }
    },
    methods: {
      open(fee) {
24d3590f   wuxw   房屋收费页面开发完成
91
92
93
94
95
96
97
98
99
100
101
        this.editFeeInfo = {
          feeId: fee.feeId,
          startTime: fee.startTime.indexOf(":") === -1 ? fee.startTime + " 00:00:00" : fee.startTime,
          endTime: fee.endTime.split(' ')[0],
          feeFlag: fee.feeFlag,
          maxEndTime: fee.maxEndTime,
          computingFormula: fee.computingFormula,
          rateCycle: fee.rateCycle,
          rate: fee.rate,
          rateStartTime: fee.rateStartTime
        }
2e0fd29c   wuxw   开发报修
102
103
        this.visible = true
      },
24d3590f   wuxw   房屋收费页面开发完成
104
      handleClose() {
2e0fd29c   wuxw   开发报修
105
        this.visible = false
24d3590f   wuxw   房屋收费页面开发完成
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
        this.clearAddFeeConfigInfo()
      },
      validateStartTime(value) {
        const start = new Date(value)
        const end = new Date(this.editFeeInfo.endTime)
        if (start >= end) {
          this.$message.error(this.$t('editFee.startTimeError'))
          this.editFeeInfo.startTime = ''
        }
      },
      validateEndTime(value) {
        const start = new Date(this.editFeeInfo.startTime)
        const end = new Date(value)
        if (start >= end) {
          this.$message.error(this.$t('editFee.endTimeError'))
          this.editFeeInfo.endTime = ''
        }
      },
      validateMaxEndTime(value) {
        const start = new Date(this.editFeeInfo.startTime)
        const end = new Date(value)
        if (start >= end) {
          this.$message.error(this.$t('editFee.maxEndTimeError'))
          this.editFeeInfo.maxEndTime = ''
        }
      },
      validateRateStartTime(value) {
        const start = new Date(this.editFeeInfo.startTime)
        const end = new Date(value)
        if (start >= end) {
          this.$message.error(this.$t('editFee.rateStartTimeError'))
          this.editFeeInfo.rateStartTime = ''
        }
      },
      editFeeValidate() {
        if (!this.editFeeInfo.startTime) {
          this.$message.error(this.$t('editFee.startTimeRequired'))
          return false
        }
        if (!this.editFeeInfo.endTime) {
          this.$message.error(this.$t('editFee.endTimeRequired'))
          return false
        }
        return true
2e0fd29c   wuxw   开发报修
150
      },
24d3590f   wuxw   房屋收费页面开发完成
151
152
153
154
155
156
157
158
159
      async _doEidtFee() {
        if (!this.editFeeValidate()) return
        
        this.editFeeInfo.communityId = getCommunityId()
        
        try {
          const res = await updateFee(this.editFeeInfo)
          if (res.code === 0) {
            this.$message.success(this.$t('common.operateSuccess'))
2e0fd29c   wuxw   开发报修
160
            this.$emit('success')
24d3590f   wuxw   房屋收费页面开发完成
161
            this.handleClose()
2e0fd29c   wuxw   开发报修
162
          } else {
24d3590f   wuxw   房屋收费页面开发完成
163
            this.$message.error(res.msg)
2e0fd29c   wuxw   开发报修
164
          }
24d3590f   wuxw   房屋收费页面开发完成
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
        } catch (error) {
          console.error('请求失败:', error)
          this.$message.error(this.$t('common.operateFail'))
        }
      },
      clearAddFeeConfigInfo() {
        this.editFeeInfo = {
          feeId: '',
          startTime: '',
          endTime: '',
          feeFlag: '',
          maxEndTime: '',
          computingFormula: '',
          rateCycle: '',
          rate: '',
          rateStartTime: ''
        }
2e0fd29c   wuxw   开发报修
182
183
184
185
      }
    }
  }
  </script>