Blame view

src/components/account/prestoreAccount.vue 6.19 KB
1c380d6d   wuxw   开发完成账户和账户详情
1
2
  <template>
    <el-dialog :title="$t('prestoreAccount.title')" :visible.sync="visible" width="800px" @close="handleClose">
911b5549   wuxw   修改平凉客户 反馈的bug 修复
3
      <el-form ref="form" :model="formData" :rules="rules" label-width="120px">
1c380d6d   wuxw   开发完成账户和账户详情
4
        <el-form-item :label="$t('prestoreAccount.accountType')" prop="acctType" required>
dd88fe5d   wuxw   优化业主详情页面
5
          <el-select v-model="formData.acctType" class="w-full" :placeholder="$t('prestoreAccount.accountType')">
1c380d6d   wuxw   开发完成账户和账户详情
6
7
8
9
10
            <el-option v-for="(type, index) in acctTypes" :key="index" :label="type.name" :value="type.statusCd" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.ownerPhone')" prop="tel" required>
911b5549   wuxw   修改平凉客户 反馈的bug 修复
11
          <el-input v-model="formData.tel" :placeholder="$t('prestoreAccount.ownerPhone')" @blur="handleTelChange" />
1c380d6d   wuxw   开发完成账户和账户详情
12
13
14
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.ownerName')" prop="ownerId" required>
dd88fe5d   wuxw   优化业主详情页面
15
          <el-select v-model="formData.ownerId" class="w-full" :placeholder="$t('prestoreAccount.ownerName')"
1c380d6d   wuxw   开发完成账户和账户详情
16
17
18
19
20
21
22
            @change="loadOwnerRooms">
            <el-option v-for="owner in owners" :key="owner.ownerId" :label="owner.name" :value="owner.ownerId" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-if="formData.acctType === '2004' || formData.acctType === '2005'"
          :label="$t('prestoreAccount.deductionRoom')" prop="roomId" required>
dd88fe5d   wuxw   优化业主详情页面
23
          <el-select v-model="formData.roomId" class="w-full" :placeholder="$t('prestoreAccount.deductionRoom')">
1c380d6d   wuxw   开发完成账户和账户详情
24
25
26
27
28
            <el-option v-for="room in rooms" :key="room.roomId" :label="room.roomName" :value="room.roomId" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.prestoreAmount')" prop="amount" required>
dd88fe5d   wuxw   优化业主详情页面
29
          <el-input v-model="formData.amount" type="number" :placeholder="$t('prestoreAccount.prestoreAmount')" />
1c380d6d   wuxw   开发完成账户和账户详情
30
31
32
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.paymentMethod')" prop="primeRate" required>
dd88fe5d   wuxw   优化业主详情页面
33
34
35
36
          <el-select v-model="formData.primeRate" class="w-full" :placeholder="$t('prestoreAccount.paymentMethod')">
            <template v-for="(item, index) in primeRates">
              <el-option :key="index" v-if="item.statusCd !== '5' && item.statusCd !== '6'" :label="item.name"
                :value="item.statusCd" />
1c380d6d   wuxw   开发完成账户和账户详情
37
38
39
40
41
            </template>
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.remark')" prop="remark">
911b5549   wuxw   修改平凉客户 反馈的bug 修复
42
          <el-input v-model="formData.remark" type="textarea" :placeholder="$t('prestoreAccount.remark')" :rows="3" />
1c380d6d   wuxw   开发完成账户和账户详情
43
44
45
46
47
48
49
50
51
52
53
54
        </el-form-item>
      </el-form>
  
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('prestoreAccount.cancel') }}</el-button>
        <el-button type="primary" @click="handleSave">{{ $t('prestoreAccount.save') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { ownerPrestoreAccount, queryOwners, queryRoomsByOwner } from '@/api/account/accountManageApi'
dd88fe5d   wuxw   优化业主详情页面
55
  import { getDict } from '@/api/community/communityApi'
1c380d6d   wuxw   开发完成账户和账户详情
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  export default {
    name: 'PrestoreAccount',
    data() {
      return {
        visible: false,
        formData: {
          tel: '',
          ownerId: '',
          amount: '',
          remark: '',
          acctType: '2003',
          primeRate: '',
          roomId: ''
        },
        acctTypes: [],
        primeRates: [],
        owners: [],
911b5549   wuxw   修改平凉客户 反馈的bug 修复
73
74
75
76
77
78
79
80
81
        rooms: [],
        rules: {
          acctType: [{ required: true, message: this.$t('prestoreAccount.accountType'), trigger: 'change' }],
          tel: [{ required: true, message: this.$t('prestoreAccount.ownerPhone'), trigger: 'blur' }],
          ownerId: [{ required: true, message: this.$t('prestoreAccount.ownerName'), trigger: 'change' }],
          roomId: [{ required: true, message: this.$t('prestoreAccount.deductionRoom'), trigger: 'change' }],
          amount: [{ required: true, message: this.$t('prestoreAccount.prestoreAmount'), trigger: 'blur' }],
          primeRate: [{ required: true, message: this.$t('prestoreAccount.paymentMethod'), trigger: 'change' }]
        }
1c380d6d   wuxw   开发完成账户和账户详情
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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
      }
    },
    methods: {
      open(params = {}) {
        this.visible = true
        this.resetForm()
  
        // 加载字典数据
        Promise.all([
          getDict('account', 'acct_type'),
          getDict('pay_fee_detail', 'prime_rate')
        ]).then(([acctTypes, primeRates]) => {
          this.acctTypes = acctTypes
          this.primeRates = primeRates
  
          // 设置传入参数
          if (params.tel) {
            this.formData = {
              ...this.formData,
              tel: params.tel,
              ownerId: params.ownerId,
              acctType: params.acctType,
              roomId: params.roomId
            }
            this.handleTelChange()
          }
        })
      },
  
      resetForm() {
        this.formData = {
          tel: '',
          ownerId: '',
          amount: '',
          remark: '',
          acctType: '2003',
          primeRate: '',
          roomId: ''
        }
        this.$refs.form && this.$refs.form.resetFields()
      },
  
      handleClose() {
        this.resetForm()
      },
  
      async handleTelChange() {
        if (!this.formData.tel) return
  
        try {
          const res = await queryOwners({
            row: 50,
            page: 1,
            link: this.formData.tel
          })
  
          this.owners = res.data
        } catch (error) {
          console.log(error)
          this.$message.error(this.$t('common.fetchError'))
          this.owners = []
        }
      },
  
      async loadOwnerRooms() {
        if (!this.formData.ownerId) return
  
        try {
          const res = await queryRoomsByOwner({
            row: 50,
            page: 1,
            ownerId: this.formData.ownerId
          })
          this.rooms = res.rooms || []
        } catch (error) {
          this.$message.error(this.$t('common.fetchError'))
          this.rooms = []
        }
      },
  
      validateForm() {
911b5549   wuxw   修改平凉客户 反馈的bug 修复
163
164
165
166
167
        return new Promise((resolve) => {
          this.$refs.form.validate((valid) => {
            resolve(valid)
          })
        })
1c380d6d   wuxw   开发完成账户和账户详情
168
169
170
      },
  
      async handleSave() {
911b5549   wuxw   修改平凉客户 反馈的bug 修复
171
172
        const valid = await this.validateForm()
        if (!valid) return
1c380d6d   wuxw   开发完成账户和账户详情
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
  
        try {
          await ownerPrestoreAccount(this.formData)
          this.$message.success(this.$t('common.saveSuccess'))
          this.visible = false
          this.$emit('success')
        } catch (error) {
          this.$message.error(error.message || this.$t('common.saveError'))
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .w-full {
    width: 100%;
  }
  </style>