Blame view

src/views/owner/ownerBindRoom.vue 6.68 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
88f005b5   wuxw   业主页面开发完成
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
      <div class="room-bind-owner-container">
          <el-card class="box-card">
              <div slot="header" class="flex justify-between">
                  <div>{{ $t('roomBindOwner.title') }}</div>
                  <div class="header-tools">
                      <el-button type="primary" size="small" icon="el-icon-close" @click="_goBack">
                          {{ $t('common.back') }}
                      </el-button>
                  </div>
              </div>
  
              <el-row>
                  <el-col :span="24">
                      <el-form label-width="120px">
                          <el-form-item :label="$t('roomBindOwner.owner')">
                              <el-input v-model.trim="roomBindOwnerInfo.ownerName"
                                  :placeholder="$t('roomBindOwner.ownerPlaceholder')" disabled />
                          </el-form-item>
                          <el-form-item :label="$t('roomBindOwner.room')">
                              <el-col :span="18">
                                  <el-input v-model.trim="roomBindOwnerInfo.roomName"
                                      :placeholder="$t('roomBindOwner.roomPlaceholder')" disabled />
                              </el-col>
                              <el-col :span="4" :offset="1">
                                  <el-button type="primary" size="small" icon="el-icon-plus" @click="_openChooseRoom">
                                      {{ $t('listOwner.selectRoom') }}
                                  </el-button>
                              </el-col>
                          </el-form-item>
  
  
  
                          <el-form-item :label="$t('roomBindOwner.startTime')">
                              <el-date-picker v-model="roomBindOwnerInfo.startTime" type="date"
                                  :placeholder="$t('roomBindOwner.startTimePlaceholder')" value-format="yyyy-MM-dd"
                                  class="addStartTime" />
                          </el-form-item>
  
                          <el-form-item :label="$t('roomBindOwner.endTime')">
                              <el-date-picker v-model="roomBindOwnerInfo.endTime" type="date"
                                  :placeholder="$t('roomBindOwner.endTimePlaceholder')" value-format="yyyy-MM-dd"
                                  class="addEndTime" />
                          </el-form-item>
                      </el-form>
                  </el-col>
              </el-row>
          </el-card>
  
          <el-row>
              <el-col :span="24" class="text-right" style="margin-top: 20px;">
                  <el-button type="primary" icon="el-icon-check" @click="saveRoomBindOwnerInfo">
                      {{ $t('common.submit') }}
                  </el-button>
              </el-col>
          </el-row>
  
c65859c6   wuxw   v1.9 优化房屋 商铺 业主功能
58
          <search-room ref="searchRoomRef" :roomFlag="roomFlag" @chooseRoom="handleChooseRoom" />
88f005b5   wuxw   业主页面开发完成
59
60
      </div>
  </template>
84ba0155   wuxw   家庭成员测试
61
  
88f005b5   wuxw   业主页面开发完成
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  <script>
  import { sellRoom } from '@/api/owner/roomBindOwnerApi'
  import { getCommunityId } from '@/api/community/communityApi'
  import searchRoom from '@/components/room/searchRoom'
  import { getDateYYYYMMDD } from '@/utils/dateUtil'
  import { queryOwners } from '@/api/owner/ownerApi'
  
  export default {
      name: 'RoomBindOwnerList',
      components: {
          searchRoom
      },
      data() {
          return {
c65859c6   wuxw   v1.9 优化房屋 商铺 业主功能
76
              roomFlag: '2',
88f005b5   wuxw   业主页面开发完成
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
              roomBindOwnerInfo: {
                  roomId: '',
                  roomName: '',
                  ownerId: '',
                  ownerName: '',
                  state: '2001',
                  startTime: '',
                  endTime: '2099-01-01',
              },
              communityId: ''
          }
      },
      created() {
          this.communityId = getCommunityId()
          this.roomBindOwnerInfo.startTime = getDateYYYYMMDD()
          this.initData()
      },
      methods: {
          initData() {
              const ownerId = this.$route.query.ownerId
              if (ownerId) {
                  this.roomBindOwnerInfo.ownerId = ownerId
                  this.listOwner(ownerId)
              }
          },
          async listOwner(ownerId) {
              try {
                  const params = {
                      page: 1,
                      row: 1,
                      memberId: ownerId,
                      communityId: this.communityId
                  }
                  const { data } = await queryOwners(params)
                  this.roomBindOwnerInfo.ownerName = data[0].name
              } catch (error) {
                  this.$message.error(this.$t('roomBindOwner.fetchRoomError'))
              }
          },
          handleChooseRoom(room) {
              this.roomBindOwnerInfo.roomName = room.roomName
              this.roomBindOwnerInfo.roomId = room.roomId
          },
          _openChooseRoom() {
              this.$refs.searchRoomRef.open()
          },
          _goBack() {
              this.$router.go(-1)
          },
          roomBindOwnerValidate() {
              const rules = {
                  ownerId: { required: true, message: this.$t('roomBindOwner.ownerRequired') },
                  roomId: { required: true, message: this.$t('roomBindOwner.roomRequired') },
                  startTime: { required: true, message: this.$t('roomBindOwner.startTimeRequired') },
                  endTime: { required: true, message: this.$t('roomBindOwner.endTimeRequired') }
              }
  
              const errors = []
              Object.keys(rules).forEach(key => {
                  if (!this.roomBindOwnerInfo[key]) {
                      errors.push(rules[key].message)
                  }
              })
  
              if (errors.length > 0) {
                  this.$message.error(errors[0])
                  return false
              }
  
              const start = new Date(this.roomBindOwnerInfo.startTime)
              const end = new Date(this.roomBindOwnerInfo.endTime)
              if (start >= end) {
                  this.$message.error(this.$t('roomBindOwner.timeError'))
                  return false
              }
  
              return true
          },
          async saveRoomBindOwnerInfo() {
              if (!this.roomBindOwnerValidate()) return
  
              try {
                  const data = {
                      ...this.roomBindOwnerInfo,
                      communityId: this.communityId
                  }
  
                  const res = await sellRoom(data)
                  if (res.code === 0) {
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
166
                      this.$message.success(this.$t('common.operationSuccess'))
88f005b5   wuxw   业主页面开发完成
167
168
169
170
171
172
173
174
175
176
177
                      this._goBack()
                  } else {
                      this.$message.error(res.msg || this.$t('common.submitFailed'))
                  }
              } catch (error) {
                  this.$message.error(this.$t('common.requestError'))
              }
          }
      }
  }
  </script>
84ba0155   wuxw   家庭成员测试
178
  
88f005b5   wuxw   业主页面开发完成
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  <style scoped>
  .room-bind-owner-container {
      padding: 20px;
  }
  
  .header-tools {}
  
  .text-right {
      text-align: right;
  }
  
  .addStartTime,
  .addEndTime {
      width: 100%;
  }
  </style>