Blame view

src/components/room/editPropertyRightRegistrationDetail.vue 8.55 KB
f92fd6ac   wuxw   开发我的小区下的功能
1
2
3
4
5
6
7
8
9
10
11
12
13
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
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
  <template>
    <el-dialog :title="$t('propertyRightDetail.edit.title')" :visible.sync="visible" width="70%"
      :before-close="handleClose">
      <el-form ref="form" :model="editPropertyRightRegistrationDetailInfo" label-width="120px">
        <el-form-item :label="$t('propertyRightDetail.edit.materialType')">
          <el-input v-model="editPropertyRightRegistrationDetailInfo.securitiesName"
            :placeholder="$t('propertyRightDetail.edit.materialTypePlaceholder')" disabled />
        </el-form-item>
  
        <template v-if="editPropertyRightRegistrationDetailInfo.securities === '001'">
          <el-form-item :label="$t('propertyRightDetail.edit.idCardPhoto')">
            <upload-image-url ref="idCardUpload" :image-count="2" @notifyUploadCoverImage="handleIdCardImageChange" />
            <p class="help-block">*{{ $t('propertyRightDetail.edit.idCardPhotoTip') }}*</p>
          </el-form-item>
        </template>
  
        <template v-if="editPropertyRightRegistrationDetailInfo.securities === '002'">
          <el-form-item :label="$t('propertyRightDetail.edit.houseContract')">
            <upload-image-url ref="housePurchaseUpload" :image-count="10" @notifyUploadCoverImage="handleHousePurchaseImageChange" />
            <p class="help-block">*{{ $t('propertyRightDetail.edit.houseContractTip') }}*</p>
          </el-form-item>
        </template>
  
        <template v-if="editPropertyRightRegistrationDetailInfo.securities === '003'">
          <el-form-item :label="$t('propertyRightDetail.edit.repairFund')">
            <el-select v-model="editPropertyRightRegistrationDetailInfo.isTrue" style="width: 100%"
              :placeholder="$t('propertyRightDetail.edit.repairFundPlaceholder')">
              <el-option value="" disabled :label="$t('propertyRightDetail.edit.repairFundPlaceholder')" />
              <el-option :label="$t('common.yes')" value="true" />
              <el-option :label="$t('common.no')" value="false" />
            </el-select>
          </el-form-item>
  
          <template v-if="editPropertyRightRegistrationDetailInfo.isTrue === 'true'">
            <el-form-item :label="$t('propertyRightDetail.edit.repairFundPhoto')">
              <upload-image-url ref="repairUpload" :image-count="3" @notifyUploadCoverImage="handleRepairImageChange" />
            </el-form-item>
          </template>
        </template>
  
        <template v-if="editPropertyRightRegistrationDetailInfo.securities === '004'">
          <el-form-item :label="$t('propertyRightDetail.edit.deedTax')">
            <el-select v-model="editPropertyRightRegistrationDetailInfo.isTrue" style="width: 100%"
              :placeholder="$t('propertyRightDetail.edit.deedTaxPlaceholder')">
              <el-option value="" disabled :label="$t('propertyRightDetail.edit.deedTaxPlaceholder')" />
              <el-option :label="$t('common.yes')" value="true" />
              <el-option :label="$t('common.no')" value="false" />
            </el-select>
          </el-form-item>
  
          <template v-if="editPropertyRightRegistrationDetailInfo.isTrue === 'true'">
            <el-form-item :label="$t('propertyRightDetail.edit.deedTaxPhoto')">
              <upload-image-url ref="deedTaxUpload" :image-count="3" @notifyUploadCoverImage="handleDeedTaxImageChange" />
            </el-form-item>
          </template>
        </template>
  
        <el-form-item class="dialog-footer">
          <el-button type="primary" @click="editPropertyRightRegistrationDetail">
            <i class="el-icon-check"></i>
            {{ $t('common.save') }}
          </el-button>
          <el-button @click="handleClose">
            <i class="el-icon-close"></i>
            {{ $t('common.cancel') }}
          </el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </template>
  
  <script>
  import { updatePropertyRightRegistrationDetail } from '@/api/room/listPropertyRightRegistrationDetailApi'
  import UploadImageUrl from '@/components/upload/UploadImageUrl'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'EditPropertyRightRegistrationDetail',
    components: {
      UploadImageUrl
    },
    props: {
      visible: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        editPropertyRightRegistrationDetailInfo: {
          prrdId: '',
          prrId: '',
          securities: '',
          securitiesName: '',
          idCardUrl: '',
          housePurchaseUrl: '',
          repairUrl: '',
          deedTaxUrl: '',
          isTrue: '',
          idCardPhotos: [],
          housePurchasePhotos: [],
          repairPhotos: [],
          deedTaxPhotos: [],
          communityId: ''
        }
      }
    },
    methods: {
      open(row) {
        this.resetForm()
        this.editPropertyRightRegistrationDetailInfo = { ...row }
        this.editPropertyRightRegistrationDetailInfo.communityId = getCommunityId()
        this.loadPhotos()
        this.visible = true
      },
      loadPhotos() {
20ddb876   wuxw   优化房屋产权
117
        setTimeout(() => {
f92fd6ac   wuxw   开发我的小区下的功能
118
        if (this.editPropertyRightRegistrationDetailInfo.securities === '001' && this.editPropertyRightRegistrationDetailInfo.idCardUrl) {
20ddb876   wuxw   优化房屋产权
119
          const urls = this.editPropertyRightRegistrationDetailInfo.idCardUrl
f92fd6ac   wuxw   开发我的小区下的功能
120
121
122
123
124
          if (urls) {
            this.$refs.idCardUpload.setImages(urls.split(','))
          }
        }
        if (this.editPropertyRightRegistrationDetailInfo.securities === '002' && this.editPropertyRightRegistrationDetailInfo.housePurchaseUrl) {
20ddb876   wuxw   优化房屋产权
125
          const urls = this.editPropertyRightRegistrationDetailInfo.housePurchaseUrl
f92fd6ac   wuxw   开发我的小区下的功能
126
127
128
129
130
          if (urls) {
            this.$refs.housePurchaseUpload.setImages(urls.split(','))
          }
        }
        if (this.editPropertyRightRegistrationDetailInfo.securities === '003' && this.editPropertyRightRegistrationDetailInfo.repairUrl) {
20ddb876   wuxw   优化房屋产权
131
          const urls = this.editPropertyRightRegistrationDetailInfo.repairUrl
f92fd6ac   wuxw   开发我的小区下的功能
132
133
134
135
136
          if (urls) {
            this.$refs.repairUpload.setImages(urls.split(','))
          }
        }
        if (this.editPropertyRightRegistrationDetailInfo.securities === '004' && this.editPropertyRightRegistrationDetailInfo.deedTaxUrl) {
20ddb876   wuxw   优化房屋产权
137
          const urls = this.editPropertyRightRegistrationDetailInfo.deedTaxUrl
f92fd6ac   wuxw   开发我的小区下的功能
138
          if (urls) {
20ddb876   wuxw   优化房屋产权
139
140
              this.$refs.deedTaxUpload.setImages(urls.split(','))
            }
f92fd6ac   wuxw   开发我的小区下的功能
141
          }
20ddb876   wuxw   优化房屋产权
142
        }, 1000)
f92fd6ac   wuxw   开发我的小区下的功能
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
      },
      handleIdCardImageChange(photos) {
        this.editPropertyRightRegistrationDetailInfo.idCardPhotos = photos
      },
      handleHousePurchaseImageChange(photos) {
        this.editPropertyRightRegistrationDetailInfo.housePurchasePhotos = photos
      },
      handleRepairImageChange(photos) {
        this.editPropertyRightRegistrationDetailInfo.repairPhotos = photos
      },
      handleDeedTaxImageChange(photos) {
        this.editPropertyRightRegistrationDetailInfo.deedTaxPhotos = photos
      },
      editPropertyRightRegistrationDetail() {
        if (!this.validateForm()) {
          return
        }
  
        const params = { ...this.editPropertyRightRegistrationDetailInfo }
        if (params.securities === '001') {
          params.idCardUrl = params.idCardPhotos && params.idCardPhotos.length > 0 ? params.idCardPhotos.join(',') : ''
        } else if (params.securities === '002') {
          params.housePurchaseUrl = params.housePurchasePhotos && params.housePurchasePhotos.length > 0 ? params.housePurchasePhotos.join(',') : ''
        } else if (params.securities === '003') {
          params.repairUrl = params.repairPhotos && params.repairPhotos.length > 0 ? params.repairPhotos.join(',') : ''
        } else if (params.securities === '004') {
          params.deedTaxUrl = params.deedTaxPhotos && params.deedTaxPhotos.length > 0 ? params.deedTaxPhotos.join(',') : ''
        }
  
        updatePropertyRightRegistrationDetail(params)
          .then(() => {
            this.$message.success(this.$t('common.updateSuccess'))
            this.$emit('success')
            this.handleClose()
          })
          .catch(error => {
            this.$message.error(error.message || this.$t('common.updateFailed'))
          })
      },
      validateForm() {
        if (!this.editPropertyRightRegistrationDetailInfo.securities) {
          this.$message.error(this.$t('propertyRightDetail.edit.materialTypeRequired'))
          return false
        }
        return true
      },
      handleClose() {
        this.visible = false
      },
      resetForm() {
        this.editPropertyRightRegistrationDetailInfo = {
          prrdId: '',
          prrId: '',
          securities: '',
          securitiesName: '',
          idCardUrl: '',
          housePurchaseUrl: '',
          repairUrl: '',
          deedTaxUrl: '',
          isTrue: '',
          idCardPhotos: [],
          housePurchasePhotos: [],
          repairPhotos: [],
          deedTaxPhotos: [],
          communityId: ''
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .dialog-footer {
    text-align: right;
    margin-top: 20px;
  }
  
  .help-block {
    color: #f56c6c;
    font-size: 12px;
    margin-top: 5px;
  }
  </style>