Blame view

src/components/fee/editFeeRule.vue 3.23 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
24d3590f   wuxw   房屋收费页面开发完成
2
3
4
5
6
7
8
9
10
11
    <el-dialog
      :title="$t('editFeeRule.title')"
      :visible.sync="visible"
      width="50%"
      :before-close="handleClose"
    >
      <el-form :model="editFeeRuleInfo" label-width="120px">
        <el-form-item :label="$t('editFeeRule.maxTime')" prop="maxTime">
          <el-date-picker
            v-model="editFeeRuleInfo.maxTime"
b25b036d   wuxw   v1.9 优化日期
12
13
            type="datetime" value-format="yyyy-MM-dd HH:mm:ss"          :placeholder="$t('editFeeRule.maxTimePlaceholder')"
            
24d3590f   wuxw   房屋收费页面开发完成
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
          ></el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('editFeeRule.curYearMonth')" prop="curYearMonth">
          <el-date-picker
            v-model="editFeeRuleInfo.curYearMonth"
            type="date"
            :placeholder="$t('editFeeRule.curYearMonthPlaceholder')"
            value-format="yyyy-MM-dd"
            @change="validateCurYearMonth"
          ></el-date-picker>
        </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="_doEidtFee">{{ $t('common.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { updatePayFeeRule } from '@/api/fee/editFeeRuleApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'EditFeeRule',
    data() {
      return {
        visible: false,
        editFeeRuleInfo: {
          ruleId: '',
          maxTime: '',
          curYearMonth: '',
          oldCurYearMonth: ''
        }
      }
    },
    methods: {
      open(fee) {
        this.editFeeRuleInfo = {
          ruleId: fee.ruleId,
          maxTime: fee.maxTime,
          curYearMonth: fee.curYearMonth,
          oldCurYearMonth: fee.curYearMonth
        }
        this.visible = true
      },
      handleClose() {
        this.visible = false
        this.clearEditFeeRuleInfoData()
      },
      validateCurYearMonth(value) {
        const start = new Date(this.editFeeRuleInfo.oldCurYearMonth)
        const end = new Date(value)
        if (start >= end) {
          this.$message.error(this.$t('editFeeRule.dateError', { date: this.editFeeRuleInfo.oldCurYearMonth }))
          this.editFeeRuleInfo.curYearMonth = ''
        }
      },
      editFeeRuleValidate() {
        if (!this.editFeeRuleInfo.maxTime) {
          this.$message.error(this.$t('editFeeRule.maxTimeRequired'))
          return false
        }
        if (!this.editFeeRuleInfo.curYearMonth) {
          this.$message.error(this.$t('editFeeRule.curYearMonthRequired'))
          return false
        }
        return true
      },
      async _doEidtFee() {
        if (!this.editFeeRuleValidate()) return
        
        this.editFeeRuleInfo.communityId = getCommunityId()
        
        try {
          const res = await updatePayFeeRule(this.editFeeRuleInfo)
          if (res.code === 0) {
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
91
            this.$message.success(this.$t('common.operationSuccess'))
24d3590f   wuxw   房屋收费页面开发完成
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
            this.$emit('success')
            this.handleClose()
          } else {
            this.$message.error(res.msg)
          }
        } catch (error) {
          console.error('请求失败:', error)
          this.$message.error(this.$t('common.operateFail'))
        }
      },
      clearEditFeeRuleInfoData() {
        this.editFeeRuleInfo = {
          ruleId: '',
          maxTime: '',
          curYearMonth: '',
          oldCurYearMonth: ''
        }
      }
    }
  }
  </script>