Blame view

src/views/room/roomStructureList.vue 6.01 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
f92fd6ac   wuxw   开发我的小区下的功能
2
3
4
    <div class="room-structure-container">
      <el-row :gutter="20">
        <el-col :span="4">
1a8a946d   wuxw   优化代码
5
          <floor-unit-room-shop-tree ref="floorUnitRoomShopTree" @switchFloorUnit="switchFloorUnit" />
f92fd6ac   wuxw   开发我的小区下的功能
6
7
        </el-col>
        <el-col :span="20">
1a8a946d   wuxw   优化代码
8
          <el-card v-if="roomStructureInfo.layerRoomCount < 5" class="room-list-card ">
f92fd6ac   wuxw   开发我的小区下的功能
9
            <el-row :gutter="10">
1a8a946d   wuxw   优化代码
10
11
12
13
14
15
              <el-col
                v-for="(room, index) in roomStructureInfo.rooms"
                :key="index"
                :span="3"
                class="room-item"
              >
f92fd6ac   wuxw   开发我的小区下的功能
16
17
18
19
20
21
22
23
24
25
26
27
28
29
                <div class="room-card" :style="{ 'background-color': getBgColor(room) }"
                  @dblclick="toSimplifyAcceptance(room)">
                  <div class="room-number">{{ room.floorNum }}-{{ room.unitNum }}-{{ room.roomNum }}</div>
                  <div class="room-state">{{ room.stateName }}</div>
                  <div class="room-owner">{{ room.ownerName || $t('roomStructure.noOwner') }}</div>
                  <div class="room-debt">
                    <span>{{ $t('roomStructure.owe') }}</span>:{{ room.oweAmount }}
                    <span>{{ $t('roomStructure.yuan') }}</span>
                  </div>
                </div>
              </el-col>
            </el-row>
          </el-card>
  
1a8a946d   wuxw   优化代码
30
          <el-card v-else class="room-list-card ">
f92fd6ac   wuxw   开发我的小区下的功能
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
            <div v-for="(val, key, index) in roomStructureInfo.parkRooms" :key="index">
              <div class="floor-title">{{ key }}F</div>
              <el-row :gutter="10" class="floor-row">
                <el-col v-for="(room, index) in val" :key="index" :xs="12" :sm="8" :md="6" :lg="4" :xl="3"
                  class="room-item">
                  <div class="room-card" :style="{ 'background-color': getBgColor(room) }"
                    @dblclick="toSimplifyAcceptance(room)">
                    <div class="room-number">{{ room.floorNum }}-{{ room.unitNum }}-{{ room.roomNum }}</div>
                    <div class="room-state">{{ room.stateName }}</div>
                    <div class="room-owner">{{ room.ownerName || $t('roomStructure.noOwner') }}</div>
                    <div class="room-debt">
                      <span>{{ $t('roomStructure.owe') }}</span>:{{ room.oweAmount }}
                      <span>{{ $t('roomStructure.yuan') }}</span>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
1a8a946d   wuxw   优化代码
56
  import floorUnitRoomShopTree from '@/components/room/floorUnitRoomShopTree'
f92fd6ac   wuxw   开发我的小区下的功能
57
58
59
60
61
62
  import { listRoomStructure } from '@/api/room/roomStructureApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'RoomStructureList',
    components: {
1a8a946d   wuxw   优化代码
63
      floorUnitRoomShopTree
f92fd6ac   wuxw   开发我的小区下的功能
64
65
66
67
68
69
70
71
72
73
74
75
76
    },
    data() {
      return {
        roomStructureInfo: {
          rooms: [],
          parkRooms: {},
          layerRoomCount: 4
        },
        communityId: ''
      }
    },
    created() {
      this.communityId = getCommunityId()
20ddb876   wuxw   优化房屋产权
77
      setTimeout(() => {
1a8a946d   wuxw   优化代码
78
        this.$refs.floorUnitRoomShopTree.selectFirstUnit()
20ddb876   wuxw   优化房屋产权
79
      }, 1500)
f92fd6ac   wuxw   开发我的小区下的功能
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
    },
    methods: {
      handleSwitchUnit(params) {
        this.loadRooms(params.unitId)
      },
      switchFloorUnit(data) {
        if (!data.unitId) {
          return
        }
        this.loadRooms(data.unitId)
      },
      async loadRooms(unitId) {
        this.roomStructureInfo.rooms = []
        this.roomStructureInfo.parkRooms = {}
  
        try {
          const params = {
            page: 1,
            row: 100,
            unitId: unitId,
            communityId: this.communityId
          }
  
          const { data } = await listRoomStructure(params)
          this.roomStructureInfo.rooms = data
          this.supportPark()
        } catch (error) {
          console.error('Failed to load rooms:', error)
        }
      },
      getBgColor(room) {
        if (room.oweAmount > 0) {
          return "#DC3545"
        }
        if (!room.ownerName) {
          return "#1AB394"
        }
        if (room.state === '2001') {
          return '#1296db'
        }
        if (room.state === '2003') {
          return '#4C8CDE'
        }
        if (room.state === '2005') {
          return '#085DC9'
        }
        if (room.state === '2004') {
          return '#9DBFEA'
        }
        if (room.state === '2006') {
          return '#365A87'
        }
        if (room.state === '2007') {
          return '#1053A8'
        }
        if (room.state === '2008') {
          return '#4E79AF'
        }
        if (room.state === '2009') {
          return '#5B81B1'
        }
        return "#1296db"
      },
      toSimplifyAcceptance(room) {
e94f0676   wuxw   跳转到业务受理页面处理完成
144
        this.$router.push('/pages/property/simplifyAcceptance?tab=业务受理&searchType=1&searchValue=' + `${room.floorNum}-${room.unitNum}-${room.roomNum}`)
f92fd6ac   wuxw   开发我的小区下的功能
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
      },
      supportPark() {
        const parkRooms = this.roomStructureInfo.parkRooms
        if (!this.roomStructureInfo.rooms || this.roomStructureInfo.rooms.length < 1) {
          return
        }
  
        this.roomStructureInfo.rooms.forEach(item => {
          if (!parkRooms[item.layer]) {
            parkRooms[item.layer] = []
          }
          parkRooms[item.layer].push(item)
        })
  
        this.roomStructureInfo.parkRooms = parkRooms
        if (Object.keys(parkRooms).length > 0) {
          this.roomStructureInfo.layerRoomCount = parkRooms[Object.keys(parkRooms)[0]].length
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .room-structure-container {
    padding: 20px;
    height: 100%;
  
    .room-list-card {
      margin-bottom: 20px;
      min-height: calc(100vh - 120px);
  
      .floor-title {
        font-size: 16px;
        font-weight: bold;
        padding: 10px 0;
      }
  
      .floor-row {
        margin-bottom: 20px;
      }
  
      .room-item {
        margin-bottom: 10px;
      }
  
      .room-card {
        color: #fff;
        border-radius: 5px;
        padding: 10px;
        cursor: pointer;
        transition: all 0.3s;
1a8a946d   wuxw   优化代码
197
198
        height: 125px;
        box-sizing: border-box;
f92fd6ac   wuxw   开发我的小区下的功能
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
  
        &:hover {
          transform: translateY(-3px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
  
        .room-number {
          font-weight: bold;
          margin-bottom: 5px;
        }
  
        .room-state,
        .room-owner,
        .room-debt {
          margin-bottom: 3px;
          font-size: 12px;
        }
      }
    }
  }
  </style>