Blame view

src/components/fee/addPayFeeConfigDiscount.vue 5.86 KB
f0032091   wuxw   完成费用项页面
1
  <template>
76d4c8fc   wuxw   优惠需要申请测试中
2
3
    <el-dialog :title="$t('addPayFeeConfigDiscount.addTitle')" :visible.sync="visible" width="800px"
      :close-on-click-modal="false" @closed="resetForm">
f0032091   wuxw   完成费用项页面
4
5
      <el-form ref="form" :model="form" :rules="rules" label-width="160px">
        <el-form-item :label="$t('addPayFeeConfigDiscount.discountType')" prop="discountType">
76d4c8fc   wuxw   优惠需要申请测试中
6
7
          <el-select v-model="form.discountType" :placeholder="$t('addPayFeeConfigDiscount.requiredPlaceholder')"
            @change="changeDiscountType" style="width: 100%">
f0032091   wuxw   完成费用项页面
8
            <el-option disabled value="">{{ $t('addPayFeeConfigDiscount.selectDiscountType') }}</el-option>
76d4c8fc   wuxw   优惠需要申请测试中
9
10
11
12
            <el-option value="1001" :label="$t('addPayFeeConfigDiscount.discount')">{{
              $t('addPayFeeConfigDiscount.discount') }}</el-option>
            <el-option value="2002" :label="$t('addPayFeeConfigDiscount.penalty')">{{
              $t('addPayFeeConfigDiscount.penalty') }}</el-option>
f0032091   wuxw   完成费用项页面
13
14
15
16
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('addPayFeeConfigDiscount.discountName')" prop="discountId">
76d4c8fc   wuxw   优惠需要申请测试中
17
18
          <el-select v-model="form.discountId" :placeholder="$t('addPayFeeConfigDiscount.requiredPlaceholder')"
            style="width: 100%">
f0032091   wuxw   完成费用项页面
19
            <el-option disabled value="">{{ $t('addPayFeeConfigDiscount.selectDiscountName') }}</el-option>
76d4c8fc   wuxw   优惠需要申请测试中
20
21
            <el-option v-for="item in discounts" :key="item.discountId" :label="item.discountName"
              :value="item.discountId" />
f0032091   wuxw   完成费用项页面
22
23
24
25
26
27
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('addPayFeeConfigDiscount.paymentPeriod')" required>
          <el-col :span="11">
            <el-form-item prop="startTime">
76d4c8fc   wuxw   优惠需要申请测试中
28
29
30
              <el-date-picker v-model="form.startTime" type="datetime"
                :placeholder="$t('addPayFeeConfigDiscount.startTimePlaceholder')" style="width: 100%"
                value-format="yyyy-MM-dd HH:mm:ss" />
f0032091   wuxw   完成费用项页面
31
32
33
34
35
36
            </el-form-item>
            <div class="el-form-item__tip">{{ $t('addPayFeeConfigDiscount.paymentPeriodTip') }}</div>
          </el-col>
          <el-col :span="2" class="text-center">-</el-col>
          <el-col :span="11">
            <el-form-item prop="endTime">
76d4c8fc   wuxw   优惠需要申请测试中
37
38
39
              <el-date-picker v-model="form.endTime" type="datetime"
                :placeholder="$t('addPayFeeConfigDiscount.endTimePlaceholder')" style="width: 100%"
                value-format="yyyy-MM-dd HH:mm:ss" />
f0032091   wuxw   完成费用项页面
40
41
42
43
            </el-form-item>
          </el-col>
        </el-form-item>
  
76d4c8fc   wuxw   优惠需要申请测试中
44
45
46
47
48
        <el-form-item v-if="form.discountType !== '2002'" :label="$t('addPayFeeConfigDiscount.discountEndTime')"
          prop="payMaxEndTime">
          <el-date-picker v-model="form.payMaxEndTime" type="datetime"
            :placeholder="$t('addPayFeeConfigDiscount.discountEndTimePlaceholder')" style="width: 100%"
            value-format="yyyy-MM-dd HH:mm:ss" />
f0032091   wuxw   完成费用项页面
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
          <div class="el-form-item__tip">{{ $t('addPayFeeConfigDiscount.discountEndTimeTip') }}</div>
        </el-form-item>
      </el-form>
  
      <div slot="footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="savePayFeeConfigDiscount" :loading="loading">
          {{ $t('common.save') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { savePayFeeConfigDiscount, getFeeDiscountList } from '@/api/fee/payFeeConfigDiscountManageApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'AddPayFeeConfigDiscount',
    data() {
      return {
        visible: false,
        loading: false,
        form: {
          configDiscountId: '',
          discountId: '',
          configId: '',
          discountType: '',
          startTime: '',
          endTime: '',
          payMaxEndTime: '',
          communityId: ''
        },
        discounts: [],
        rules: {
          discountType: [
            { required: true, message: this.$t('addPayFeeConfigDiscount.discountTypeRequired'), trigger: 'change' }
          ],
          discountId: [
            { required: true, message: this.$t('addPayFeeConfigDiscount.discountNameRequired'), trigger: 'change' }
          ],
          startTime: [
            { required: true, message: this.$t('addPayFeeConfigDiscount.startTimeRequired'), trigger: 'change' }
          ],
          endTime: [
            { required: true, message: this.$t('addPayFeeConfigDiscount.endTimeRequired'), trigger: 'change' }
          ]
        }
      }
    },
    methods: {
      open(configId) {
        this.form.configId = configId
        this.form.communityId = getCommunityId()
        this.visible = true
      },
      resetForm() {
        this.$refs.form.resetFields()
        this.form = {
          configDiscountId: '',
          discountId: '',
          configId: this.form.configId,
          discountType: '',
          startTime: '',
          endTime: '',
          payMaxEndTime: '',
          communityId: this.form.communityId
        }
        this.discounts = []
      },
      async changeDiscountType() {
        if (!this.form.discountType) return
76d4c8fc   wuxw   优惠需要申请测试中
121
  
f0032091   wuxw   完成费用项页面
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
        try {
          const params = {
            page: 1,
            row: 100,
            communityId: this.form.communityId,
            discountType: this.form.discountType
          }
          const response = await getFeeDiscountList(params)
          this.discounts = response.data
        } catch (error) {
          this.$message.error(this.$t('addPayFeeConfigDiscount.fetchDiscountsError'))
        }
      },
      async savePayFeeConfigDiscount() {
        this.$refs.form.validate(async valid => {
          if (!valid) return
76d4c8fc   wuxw   优惠需要申请测试中
138
  
f0032091   wuxw   完成费用项页面
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
          try {
            this.loading = true
            await savePayFeeConfigDiscount(this.form)
            this.$message.success(this.$t('addPayFeeConfigDiscount.saveSuccess'))
            this.visible = false
            this.$emit('success')
          } catch (error) {
            this.$message.error(error.message || this.$t('addPayFeeConfigDiscount.saveError'))
          } finally {
            this.loading = false
          }
        })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .text-center {
    text-align: center;
  }
76d4c8fc   wuxw   优惠需要申请测试中
160
  
f0032091   wuxw   完成费用项页面
161
162
163
164
165
  .el-form-item__tip {
    text-align: left;
    color: #999;
  }
  </style>