Blame view

src/views/owner/addOwnerCommitteeList.vue 12.7 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
20e526fa   wuxw   完成业务会功能
2
3
4
5
6
7
8
9
10
11
12
13
    <div class="add-owner-committee-container">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-card class="ibox">
            <div slot="header" class="flex justify-between">
              <div>{{ $t('addOwnerCommittee.title') }}</div>
              <div class="ibox-tools">
                <el-button type="primary" size="small" @click="goBack">
                  {{ $t('common.back') }}
                </el-button>
              </div>
            </div>
dc3c5a73   wuxw   优化代码
14
            <el-form ref="form" :model="addOwnerCommitteeInfo" :rules="rules" label-width="120px" label-position="right">
20e526fa   wuxw   完成业务会功能
15
16
17
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.name')" prop="name">
dc3c5a73   wuxw   优化代码
18
                    <el-input v-model="addOwnerCommitteeInfo.name" :placeholder="$t('addOwnerCommittee.requiredName')" />
20e526fa   wuxw   完成业务会功能
19
20
21
22
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.sex')" prop="sex">
dc3c5a73   wuxw   优化代码
23
24
                    <el-select v-model="addOwnerCommitteeInfo.sex" :placeholder="$t('addOwnerCommittee.requiredSex')"
                      style="width:100%">
20e526fa   wuxw   完成业务会功能
25
                      <el-option disabled value="">{{ $t('addOwnerCommittee.requiredSex') }}</el-option>
16eefcf0   wuxw   优化发票相关页面bug
26
27
                      <el-option :label="$t('addOwnerCommittee.male')" value="B">{{ $t('addOwnerCommittee.male') }}</el-option>
                      <el-option :label="$t('addOwnerCommittee.female')" value="G">{{ $t('addOwnerCommittee.female') }}</el-option>
20e526fa   wuxw   完成业务会功能
28
29
30
31
32
33
34
35
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
  
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.phone')" prop="link">
dc3c5a73   wuxw   优化代码
36
                    <el-input v-model="addOwnerCommitteeInfo.link" :placeholder="$t('addOwnerCommittee.requiredPhone')" />
20e526fa   wuxw   完成业务会功能
37
38
39
40
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.idCard')" prop="idCard">
dc3c5a73   wuxw   优化代码
41
42
                    <el-input v-model="addOwnerCommitteeInfo.idCard"
                      :placeholder="$t('addOwnerCommittee.requiredIdCard')" />
20e526fa   wuxw   完成业务会功能
43
44
45
46
47
48
49
                  </el-form-item>
                </el-col>
              </el-row>
  
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.address')" prop="address">
dc3c5a73   wuxw   优化代码
50
51
                    <el-input v-model="addOwnerCommitteeInfo.address"
                      :placeholder="$t('addOwnerCommittee.requiredAddress')" />
20e526fa   wuxw   完成业务会功能
52
53
54
55
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.position')" prop="position">
dc3c5a73   wuxw   优化代码
56
57
                    <el-input v-model="addOwnerCommitteeInfo.position"
                      :placeholder="$t('addOwnerCommittee.requiredPosition')" />
20e526fa   wuxw   完成业务会功能
58
59
60
61
62
63
64
                  </el-form-item>
                </el-col>
              </el-row>
  
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.post')" prop="post">
dc3c5a73   wuxw   优化代码
65
                    <el-input v-model="addOwnerCommitteeInfo.post" :placeholder="$t('addOwnerCommittee.requiredPost')" />
20e526fa   wuxw   完成业务会功能
66
67
68
69
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.postDesc')">
dc3c5a73   wuxw   优化代码
70
71
                    <el-input v-model="addOwnerCommitteeInfo.postDesc"
                      :placeholder="$t('addOwnerCommittee.optionalPostDesc')" />
20e526fa   wuxw   完成业务会功能
72
73
74
75
76
77
78
                  </el-form-item>
                </el-col>
              </el-row>
  
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.appointTime')" prop="appointTime">
dc3c5a73   wuxw   优化代码
79
80
                    <el-input v-model="addOwnerCommitteeInfo.appointTime"
                      :placeholder="$t('addOwnerCommittee.requiredAppointTime')" />
20e526fa   wuxw   完成业务会功能
81
82
83
84
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.curTime')" prop="curTime">
dc3c5a73   wuxw   优化代码
85
86
                    <el-input v-model="addOwnerCommitteeInfo.curTime"
                      :placeholder="$t('addOwnerCommittee.requiredCurTime')" />
20e526fa   wuxw   完成业务会功能
87
88
89
90
91
92
93
                  </el-form-item>
                </el-col>
              </el-row>
  
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.state')" prop="state">
dc3c5a73   wuxw   优化代码
94
95
                    <el-select v-model="addOwnerCommitteeInfo.state" :placeholder="$t('addOwnerCommittee.requiredState')"
                      style="width:100%">
20e526fa   wuxw   完成业务会功能
96
                      <el-option disabled value="">{{ $t('addOwnerCommittee.requiredState') }}</el-option>
16eefcf0   wuxw   优化发票相关页面bug
97
98
                      <el-option :label="$t('addOwnerCommittee.onJob')" value="1000">{{ $t('addOwnerCommittee.onJob') }}</el-option>
                      <el-option :label="$t('addOwnerCommittee.leaveJob')" value="2000">{{ $t('addOwnerCommittee.leaveJob') }}</el-option>
20e526fa   wuxw   完成业务会功能
99
100
101
102
103
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('addOwnerCommittee.remark')">
dc3c5a73   wuxw   优化代码
104
105
                    <el-input v-model="addOwnerCommitteeInfo.remark" type="textarea"
                      :placeholder="$t('addOwnerCommittee.optionalRemark')" />
20e526fa   wuxw   完成业务会功能
106
107
108
109
110
111
112
113
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
  
dc3c5a73   wuxw   优化代码
114
      <el-row :gutter="20" class="">
20e526fa   wuxw   完成业务会功能
115
116
117
118
119
120
121
122
123
124
125
126
127
        <el-col :span="24">
          <el-card class="ibox">
            <div slot="header" class="flex justify-between">
              <div>{{ $t('addOwnerCommittee.emergencyContact') }}</div>
              <div class="ibox-tools">
                <el-button type="primary" size="small" @click="addContract">
                  <i class="el-icon-plus"></i> {{ $t('common.add') }}
                </el-button>
              </div>
            </div>
            <el-table :data="addOwnerCommitteeInfo.contracts" border style="width: 100%">
              <el-table-column :label="$t('addOwnerCommittee.contactRelationship')" align="center">
                <template slot-scope="scope">
dc3c5a73   wuxw   优化代码
128
                  <el-input v-model="scope.row.relName" :placeholder="$t('addOwnerCommittee.requiredRelationship')" />
20e526fa   wuxw   完成业务会功能
129
130
131
132
                </template>
              </el-table-column>
              <el-table-column :label="$t('addOwnerCommittee.contactName')" align="center">
                <template slot-scope="scope">
dc3c5a73   wuxw   优化代码
133
                  <el-input v-model="scope.row.name" :placeholder="$t('addOwnerCommittee.requiredName')" />
20e526fa   wuxw   完成业务会功能
134
135
136
137
                </template>
              </el-table-column>
              <el-table-column :label="$t('addOwnerCommittee.contactPhone')" align="center">
                <template slot-scope="scope">
dc3c5a73   wuxw   优化代码
138
                  <el-input v-model="scope.row.link" :placeholder="$t('addOwnerCommittee.requiredPhone')" />
20e526fa   wuxw   完成业务会功能
139
140
141
142
                </template>
              </el-table-column>
              <el-table-column :label="$t('addOwnerCommittee.contactAddress')" align="center" width="250">
                <template slot-scope="scope">
dc3c5a73   wuxw   优化代码
143
                  <el-input v-model="scope.row.address" :placeholder="$t('addOwnerCommittee.requiredAddress')" />
20e526fa   wuxw   完成业务会功能
144
145
146
147
                </template>
              </el-table-column>
              <el-table-column :label="$t('common.operation')" align="center" width="100">
                <template slot-scope="scope">
dc3c5a73   wuxw   优化代码
148
                  <el-button type="danger" size="mini" @click="deleteContract(scope.row)">
20e526fa   wuxw   完成业务会功能
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
                    {{ $t('common.delete') }}
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-card>
        </el-col>
      </el-row>
  
      <div class="margin-top">
        <el-button type="primary" class="float-right" @click="saveOwnerCommitteeInfo">
          <i class="el-icon-check"></i>&nbsp;
          {{ $t('common.save') }}
        </el-button>
        <el-button type="warning" class="float-right" style="margin-right:20px;" @click="goBack">
          {{ $t('common.back') }}
        </el-button>
      </div>
    </div>
  </template>
  
  <script>
  import { saveOwnerCommittee } from '@/api/owner/addOwnerCommitteeApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'AddOwnerCommitteeList',
    data() {
      return {
        addOwnerCommitteeInfo: {
          ocId: '',
          name: '',
          sex: '',
          link: '',
          idCard: '',
          address: '',
          position: '',
          post: '',
          postDesc: '',
          appointTime: '',
          curTime: '',
          state: '',
          remark: '',
          contracts: []
        },
        rules: {
          name: [
            { required: true, message: this.$t('addOwnerCommittee.requiredName'), trigger: 'blur' },
            { max: 30, message: this.$t('addOwnerCommittee.maxName', { max: 30 }), trigger: 'blur' }
          ],
          sex: [
            { required: true, message: this.$t('addOwnerCommittee.requiredSex'), trigger: 'change' },
            { max: 12, message: this.$t('addOwnerCommittee.maxSex', { max: 12 }), trigger: 'blur' }
          ],
          link: [
            { required: true, message: this.$t('addOwnerCommittee.requiredPhone'), trigger: 'blur' },
            { max: 11, message: this.$t('addOwnerCommittee.maxPhone', { max: 11 }), trigger: 'blur' }
          ],
          idCard: [
            { required: true, message: this.$t('addOwnerCommittee.requiredIdCard'), trigger: 'blur' },
            { max: 18, message: this.$t('addOwnerCommittee.maxIdCard', { max: 18 }), trigger: 'blur' }
          ],
          address: [
            { required: true, message: this.$t('addOwnerCommittee.requiredAddress'), trigger: 'blur' },
            { max: 256, message: this.$t('addOwnerCommittee.maxAddress', { max: 256 }), trigger: 'blur' }
          ],
          position: [
            { required: true, message: this.$t('addOwnerCommittee.requiredPosition'), trigger: 'blur' },
            { max: 64, message: this.$t('addOwnerCommittee.maxPosition', { max: 64 }), trigger: 'blur' }
          ],
          post: [
            { required: true, message: this.$t('addOwnerCommittee.requiredPost'), trigger: 'blur' },
            { max: 64, message: this.$t('addOwnerCommittee.maxPost', { max: 64 }), trigger: 'blur' }
          ],
          postDesc: [
            { max: 64, message: this.$t('addOwnerCommittee.maxPostDesc', { max: 64 }), trigger: 'blur' }
          ],
          appointTime: [
            { required: true, message: this.$t('addOwnerCommittee.requiredAppointTime'), trigger: 'blur' },
            { max: 256, message: this.$t('addOwnerCommittee.maxAppointTime', { max: 256 }), trigger: 'blur' }
          ],
          curTime: [
            { required: true, message: this.$t('addOwnerCommittee.requiredCurTime'), trigger: 'blur' },
            { max: 256, message: this.$t('addOwnerCommittee.maxCurTime', { max: 256 }), trigger: 'blur' }
          ],
          state: [
            { required: true, message: this.$t('addOwnerCommittee.requiredState'), trigger: 'change' },
            { max: 12, message: this.$t('addOwnerCommittee.maxState', { max: 12 }), trigger: 'blur' }
          ],
          remark: [
            { max: 200, message: this.$t('addOwnerCommittee.maxRemark', { max: 200 }), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      goBack() {
        this.$router.go(-1)
      },
      addContract() {
        this.addOwnerCommitteeInfo.contracts.push({
          id: this.generateUUID(),
          relName: '',
          name: '',
          link: '',
          address: ''
        })
      },
      deleteContract(contract) {
        const index = this.addOwnerCommitteeInfo.contracts.findIndex(item => item.id === contract.id)
        if (index !== -1) {
          this.addOwnerCommitteeInfo.contracts.splice(index, 1)
        }
      },
      generateUUID() {
dc3c5a73   wuxw   优化代码
264
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
20e526fa   wuxw   完成业务会功能
265
266
267
268
269
270
271
272
          const r = Math.random() * 16 | 0
          const v = c === 'x' ? r : (r & 0x3 | 0x8)
          return v.toString(16)
        })
      },
      async saveOwnerCommitteeInfo() {
        try {
          await this.$refs.form.validate()
dc3c5a73   wuxw   优化代码
273
  
20e526fa   wuxw   完成业务会功能
274
275
          this.addOwnerCommitteeInfo.communityId = getCommunityId()
          const response = await saveOwnerCommittee(this.addOwnerCommitteeInfo)
dc3c5a73   wuxw   优化代码
276
  
20e526fa   wuxw   完成业务会功能
277
          if (response.code === 0) {
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
278
            this.$message.success(this.$t('common.operationSuccess'))
20e526fa   wuxw   完成业务会功能
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
            this.goBack()
          } else {
            this.$message.error(response.msg || this.$t('addOwnerCommittee.saveError'))
          }
        } catch (error) {
          console.error('保存失败:', error)
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .add-owner-committee-container {
    padding: 20px;
  }
  
  .ibox {
    margin-bottom: 20px;
  }
  
  .ibox-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #e7eaec;
  }
  
  .margin-top {
    margin-top: 20px;
  }
  
  .float-right {
    float: right;
  }
  
  .clearfix:after {
    content: "";
    display: table;
    clear: both;
  }
  </style>