Blame view

src/components/room/searchRoom.vue 5.39 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
88f005b5   wuxw   业主页面开发完成
2
3
4
    <el-dialog :title="$t('searchRoom.title')" :visible.sync="dialogVisible" width="70%" @close="handleClose">
      <div class="ibox">
        <el-row v-if="showSearchCondition">
84ba0155   wuxw   家庭成员测试
5
          <el-col :span="4">
88f005b5   wuxw   业主页面开发完成
6
7
8
            <el-input :placeholder="$t('searchRoom.floorNumPlaceholder')" :readonly="floorNumInputReadonly"
              v-model.trim="currentFloorNum" clearable />
          </el-col>
84ba0155   wuxw   家庭成员测试
9
          <el-col :span="4" :offset="1">
88f005b5   wuxw   业主页面开发完成
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
            <el-input :placeholder="$t('searchRoom.roomNumPlaceholder')" v-model.trim="currentRoomNum" clearable />
          </el-col>
          <el-col :span="6" :offset="1">
            <el-button type="primary" @click="searchRooms">
              <i class="el-icon-search"></i>
              {{ $t('searchRoom.search') }}
            </el-button>
            <el-button type="primary" @click="resetRooms">
              <i class="el-icon-refresh"></i>
              {{ $t('searchRoom.reset') }}
            </el-button>
          </el-col>
        </el-row>
  
        <el-table :data="rooms" style="width: 100%; margin-top: 15px" border stripe>
          <el-table-column prop="roomId" :label="$t('searchRoom.roomId')" align="center" />
          <el-table-column prop="floorNum" :label="$t('searchRoom.floorNum')" align="center">
            <template #default="{ row }">
              {{ row.floorNum }}{{ $t('searchRoom.building') }}
            </template>
          </el-table-column>
          <el-table-column prop="unitNum" :label="$t('searchRoom.unitNum')" align="center">
            <template #default="{ row }">
              {{ row.unitNum }}{{ $t('searchRoom.unit') }}
            </template>
          </el-table-column>
          <el-table-column prop="roomNum" :label="$t('searchRoom.roomNum')" align="center">
            <template #default="{ row }">
              {{ row.roomNum }}{{ $t('searchRoom.room') }}
            </template>
          </el-table-column>
          <el-table-column prop="layer" :label="$t('searchRoom.layer')" align="center">
            <template #default="{ row }">
              {{ row.layer }}{{ $t('searchRoom.floor') }}
            </template>
          </el-table-column>
          <el-table-column :label="$t('searchRoom.operation')" align="center" width="120">
            <template #default="{ row }">
              <el-button type="primary" size="mini" @click="chooseRoom(row)">
                {{ $t('searchRoom.choose') }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
  
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="pagination.currentPage" :page-sizes="[10, 15, 20, 30]" :page-size="pagination.pageSize"
          layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" style="margin-top: 15px" />
      </div>
    </el-dialog>
  </template>
84ba0155   wuxw   家庭成员测试
61
  
88f005b5   wuxw   业主页面开发完成
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
  <script>
  import { queryRooms, queryRoomsWithSell, queryRoomsWithOutSell } from '@/api/room/roomApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'SearchRoom',
    props: {
      roomFlag: {
        type: String,
        default: ''
      },
      showSearchCondition: {
        type: String,
        default: 'true'
      }
    },
    data() {
      return {
        dialogVisible: false,
        rooms: [],
        currentRoomNum: '',
        currentFloorNum: '',
        floorNumInputReadonly: false,
        pagination: {
          currentPage: 1,
          pageSize: 10,
          total: 0
        }
      }
    },
    computed: {
      isShowSearchCondition() {
        return this.showSearchCondition === 'true'
      }
    },
    methods: {
      open() {
        this.dialogVisible = true
        this.refreshSearchRoomData()
        this.loadAllRoomInfo()
      },
      handleClose() {
        this.dialogVisible = false
      },
      async loadAllRoomInfo() {
        try {
          const params = {
            page: this.pagination.currentPage,
            row: this.pagination.pageSize,
            communityId: getCommunityId(),
            roomNum: this.currentRoomNum,
            floorNum: this.currentFloorNum,
            roomFlag: this.roomFlag
          }
  
          let response
c65859c6   wuxw   v1.9 优化房屋 商铺 业主功能
118
          if (this.roomFlag == '1') {
88f005b5   wuxw   业主页面开发完成
119
            response = await queryRoomsWithSell(params)
c65859c6   wuxw   v1.9 优化房屋 商铺 业主功能
120
          } else if (this.roomFlag == '2') {
88f005b5   wuxw   业主页面开发完成
121
122
123
124
125
126
            response = await queryRoomsWithOutSell(params)
          } else {
            response = await queryRooms(params)
          }
  
          this.rooms = response.rooms || []
f9f29297   wuxw   v1.9 分页 record 传给...
127
          this.pagination.total = response.total || 0
88f005b5   wuxw   业主页面开发完成
128
129
        } catch (error) {
          console.error('Failed to load room info:', error)
c65859c6   wuxw   v1.9 优化房屋 商铺 业主功能
130
          this.$message.error(error)
88f005b5   wuxw   业主页面开发完成
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
        }
      },
      chooseRoom(room) {
        this.$emit('chooseRoom', room)
        this.$emit('load-data', { roomId: room.roomId })
        this.dialogVisible = false
      },
      searchRooms() {
        this.pagination.currentPage = 1
        this.loadAllRoomInfo()
      },
      resetRooms() {
        this.currentFloorNum = ''
        this.currentRoomNum = ''
        this.pagination.currentPage = 1
        this.loadAllRoomInfo()
      },
      refreshSearchRoomData() {
        this.currentRoomNum = ''
      },
      handleSizeChange(val) {
        this.pagination.pageSize = val
        this.loadAllRoomInfo()
      },
      handleCurrentChange(val) {
        this.pagination.currentPage = val
        this.loadAllRoomInfo()
      },
      listenerFloorInfo(floorInfo) {
        this.currentFloorNum = floorInfo.floorNum
        this.floorNumInputReadonly = true
        this.searchRooms()
      },
      showOwnerRooms(rooms) {
        this.dialogVisible = true
        this.rooms = rooms
      }
    },
88f005b5   wuxw   业主页面开发完成
169
170
  }
  </script>
84ba0155   wuxw   家庭成员测试
171
  
88f005b5   wuxw   业主页面开发完成
172
173
174
175
176
  <style scoped>
  .el-input {
    width: 100%;
  }
  </style>