Blame view

src/components/account/prestoreAccount.vue 6 KB
1c380d6d   wuxw   开发完成账户和账户详情
1
2
3
4
  <template>
    <el-dialog :title="$t('prestoreAccount.title')" :visible.sync="visible" width="800px" @close="handleClose">
      <el-form ref="form" :model="formData" label-width="120px">
        <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>
dd88fe5d   wuxw   优化业主详情页面
11
12
          <el-input v-model="formData.tel" :placeholder="$t('prestoreAccount.ownerPhone')"
            @blur="handleTelChange" />
1c380d6d   wuxw   开发完成账户和账户详情
13
14
15
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.ownerName')" prop="ownerId" required>
dd88fe5d   wuxw   优化业主详情页面
16
          <el-select v-model="formData.ownerId" class="w-full" :placeholder="$t('prestoreAccount.ownerName')"
1c380d6d   wuxw   开发完成账户和账户详情
17
18
19
20
21
22
23
            @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   优化业主详情页面
24
          <el-select v-model="formData.roomId" class="w-full" :placeholder="$t('prestoreAccount.deductionRoom')">
1c380d6d   wuxw   开发完成账户和账户详情
25
26
27
28
29
            <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   优化业主详情页面
30
          <el-input v-model="formData.amount" type="number" :placeholder="$t('prestoreAccount.prestoreAmount')" />
1c380d6d   wuxw   开发完成账户和账户详情
31
32
33
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.paymentMethod')" prop="primeRate" required>
dd88fe5d   wuxw   优化业主详情页面
34
35
36
37
          <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   开发完成账户和账户详情
38
39
40
41
42
            </template>
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('prestoreAccount.remark')" prop="remark">
dd88fe5d   wuxw   优化业主详情页面
43
          <el-input v-model="formData.remark" type="textarea" :placeholder="$t('prestoreAccount.remark')"
1c380d6d   wuxw   开发完成账户和账户详情
44
45
46
47
48
49
50
51
52
53
54
55
56
            :rows="3" />
        </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   优化业主详情页面
57
  import { getDict } from '@/api/community/communityApi'
1c380d6d   wuxw   开发完成账户和账户详情
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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
  export default {
    name: 'PrestoreAccount',
    data() {
      return {
        visible: false,
        formData: {
          tel: '',
          ownerId: '',
          amount: '',
          remark: '',
          acctType: '2003',
          primeRate: '',
          roomId: ''
        },
        acctTypes: [],
        primeRates: [],
        owners: [],
        rooms: []
      }
    },
    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() {
        const requiredFields = [
          'ownerId', 'amount', 'acctType', 'primeRate'
        ]
  
        if (this.formData.acctType === '2004' || this.formData.acctType === '2005') {
          requiredFields.push('roomId')
        }
  
        for (const field of requiredFields) {
          if (!this.formData[field]) {
            this.$message.warning(this.$t('prestoreAccount.placeholder' + field.charAt(0).toUpperCase() + field.slice(1)))
            return false
          }
        }
  
        if (!this.formData.amount) {
          this.$message.warning(this.$t('prestoreAccount.placeholderAmount'))
          return false
        }
  
        return true
      },
  
      async handleSave() {
        if (!this.validateForm()) return
  
        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>