Blame view

src/components/system/searchCommunityDataList.vue 12.3 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
2
    <el-dialog :visible.sync="visible" :title="$t('searchCommunityData.title')" width="80%" @close="handleClose">
1db0a60c   wuxw   优化常用菜单 和搜索功能
3
4
      <el-row class="margin-bottom">
        <el-col :span="14" :offset="2">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
5
6
          <el-input v-model="searchValue" :placeholder="$t('searchCommunityData.placeholder')"
            @keyup.enter.native="doSearch" />
1db0a60c   wuxw   优化常用菜单 和搜索功能
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
        </el-col>
        <el-col :span="3" :offset="1">
          <el-button type="primary" @click="doSearch">
            {{ $t('common.search') }}
          </el-button>
        </el-col>
        <el-col :span="3">
          <el-button @click="queryCallInTel">
            {{ $t('searchCommunityData.callInNumber') }}
          </el-button>
        </el-col>
      </el-row>
      <el-divider />
      <div class="margin-top margin-bottom" style="min-height: 200px;">
        <template v-if="!noData">
          <div class="vc-search-community-item" v-if="rooms.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.roomInfo') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
25
              <el-link v-for="(item, index) in rooms" :key="'room' + index" @click="toSimplifyAcceptance(item)">
1db0a60c   wuxw   优化常用菜单 和搜索功能
26
27
28
29
30
31
32
                {{ item.roomName }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="owners.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.ownerInfo') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
33
34
              <el-link v-for="(item, index) in owners" :key="'owner' + index"
                :href="'/#/views/owner/ownerDetail?ownerId=' + item.ownerId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
35
36
37
38
39
40
41
                {{ item.name }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="ownerMembers.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.ownerMember') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
42
43
              <el-link v-for="(item, index) in ownerMembers" :key="'ownerMember' + index"
                :href="'/#/views/owner/ownerDetail?ownerId=' + item.ownerId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
44
45
46
47
48
49
50
                {{ item.name }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="cars.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.communityCar') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
51
52
              <el-link v-for="(item, index) in cars" :key="'car' + index"
                :href="'/#/views/car/carDetail?memberId=' + item.carId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
53
54
55
56
57
58
59
                {{ item.carNum }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="carMembers.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.memberCar') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
60
61
              <el-link v-for="(item, index) in carMembers" :key="'carMember' + index"
                :href="'/#/views/car/carDetail?memberId=' + item.carId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
62
63
64
65
66
67
68
                {{ item.carNum }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="contracts.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.contract') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
69
70
              <el-link v-for="(item, index) in contracts" :key="'contract' + index"
                :href="'/#/views/contract/contractDetail?contractId=' + item.contractId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
71
72
73
74
75
76
77
                {{ item.contractName }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="repairs.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.repairOrder') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
78
79
              <el-link v-for="(item, index) in repairs" :key="'repair' + index"
                :href="'/#/pages/property/ownerRepairDetail?repairId=' + item.repairId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
80
81
82
83
84
85
86
                {{ item.repairName }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="visits.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.visitor') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
87
88
              <el-link v-for="(item, index) in visits" :key="'visit' + index"
                :href="'/#/pages/property/visitDetail?vId=' + item.vId + '&flowId=' + item.flowId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
89
90
91
92
93
94
95
                {{ item.vName }}
              </el-link>
            </div>
          </div>
          <div class="vc-search-community-item" v-if="staffs.length > 0">
            <div class="item-title">{{ $t('searchCommunityData.staff') }}</div>
            <div class="item-content">
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
96
97
              <el-link v-for="(item, index) in staffs" :key="'staff' + index"
                :href="'/#/views/staff/staffDetail?staffId=' + item.userId" target="_blank">
1db0a60c   wuxw   优化常用菜单 和搜索功能
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
                {{ item.name }}
              </el-link>
            </div>
          </div>
        </template>
        <div v-else class="text-center" style="font-size: 38px;color: #aaa;margin-top: 100px;">
          {{ $t('searchCommunityData.noData') }}
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.close') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
56732765   wuxw   修改员工界面部分bug
114
  import { searchCommunityData, getTelMachineInfo, saveTelMachineMsg } from '@/api/system/searchCommunityDataApi'
1db0a60c   wuxw   优化常用菜单 和搜索功能
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
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'SearchCommunityData',
    data() {
      return {
        visible: false,
        searchValue: '',
        rooms: [],
        owners: [],
        ownerMembers: [],
        cars: [],
        carMembers: [],
        contracts: [],
        repairs: [],
        visits: [],
        staffs: [],
        noData: true,
        machine: {},
        ws: null,
        componentName: '',
        communityId: ''
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.initTelMachine()
    },
    methods: {
      open() {
        this.visible = true
        this.clearSearchData()
      },
      handleClose() {
        this.clearSearchData()
      },
      initTelMachine() {
        if (!this.communityId || this.communityId === '-1') {
          return
        }
56732765   wuxw   修改员工界面部分bug
155
        getTelMachineInfo({
1db0a60c   wuxw   优化常用菜单 和搜索功能
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
          page: 1,
          row: 1,
          communityId: this.communityId
        }).then(res => {
          if (res.code !== 0 || res.data.length < 1) {
            return
          }
          this.machine = res.data[0]
          this.connectTelMachine(this.machine)
        }).catch(error => {
          console.error('Failed to get tel machine:', error)
        })
      },
      doSearch() {
        if (!this.searchValue) {
          this.$message.warning(this.$t('searchCommunityData.inputTip'))
          return
        }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
174
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
175
176
177
178
179
180
181
182
        searchCommunityData({
          searchValue: this.searchValue,
          communityId: this.communityId
        }).then(res => {
          if (res.code !== 0) {
            this.$message.error(res.msg)
            return
          }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
183
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
184
185
186
187
188
189
190
191
192
193
194
          this.noData = false
          const data = res.data
          this.rooms = data.rooms || []
          this.owners = data.owners || []
          this.ownerMembers = data.ownerMembers || []
          this.cars = data.cars || []
          this.carMembers = data.carMembers || []
          this.contracts = data.contracts || []
          this.repairs = data.repairs || []
          this.visits = data.visitDtos || []
          this.staffs = data.staffs || []
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
195
196
197
198
199
200
  
          this.noData = !(this.rooms.length > 0 || this.owners.length > 0 ||
            this.ownerMembers.length > 0 || this.cars.length > 0 ||
            this.carMembers.length > 0 || this.contracts.length > 0 ||
            this.repairs.length > 0 || this.visits.length > 0 ||
            this.staffs.length > 0)
1db0a60c   wuxw   优化常用菜单 和搜索功能
201
202
203
204
205
        }).catch(error => {
          console.error('Search failed:', error)
        })
      },
      toSimplifyAcceptance(room) {
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
206
        this.visible = false
e94f0676   wuxw   跳转到业务受理页面处理完成
207
208
        this.$router.push('/pages/property/simplifyAcceptance?tab=业务受理&searchType=1&searchValue=' + `${room.floorNum}-${room.unitNum}-${room.roomNum}`)
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
209
210
211
212
      },
      clearSearchData() {
        const ws = this.ws
        const machine = this.machine
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
213
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
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
        this.searchValue = ''
        this.noData = true
        this.rooms = []
        this.owners = []
        this.ownerMembers = []
        this.cars = []
        this.carMembers = []
        this.contracts = []
        this.repairs = []
        this.visits = []
        this.staffs = []
        this.machine = machine
        this.ws = ws
      },
      queryCallInTel() {
        if (!this.ws) {
          this.$message.warning(this.$t('searchCommunityData.telNotConnected'))
          return
        }
        this.ws.send(JSON.stringify({
          action: 'Query',
          type: 'Device',
          cb: 'cb_data'
        }))
      },
      connectTelMachine(machine) {
        const protocol = window.location.protocol
        let url = "ws://"
        if (protocol.startsWith('https')) {
          url = "wss://"
        }
        url = `${url}${machine.machineIp}:${machine.machinePort}/APP_2AD85C71-BEF8-463C-9B4B-B672F603542A_fast`
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
246
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
247
        const ws = new WebSocket(url)
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
248
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
249
250
251
252
253
254
        ws.onerror = (event) => {
          console.log('WebSocket error:', event)
          setTimeout(() => {
            this.connectTelMachine(machine)
          }, 2000)
        }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
255
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
256
257
258
        ws.onclose = () => {
          console.log('WebSocket closed')
        }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
259
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
260
261
262
        ws.onopen = () => {
          console.log('WebSocket connected')
        }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
263
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
264
265
266
267
        ws.onmessage = (event) => {
          try {
            const data = JSON.parse(event.data)
            console.log('WebSocket message:', data)
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
268
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
269
270
271
272
273
274
275
276
277
278
279
280
281
            if (data.message === 'query') {
              if (data.name === 'Device' && data.param.CallerId) {
                this.clearSearchData()
                this.searchValue = data.param.CallerId
                this.doSearch()
                return
              }
              if (data.name === 'Device' && Object.prototype.hasOwnProperty.call(data.param, 'CallerId')) {
                this.$message.warning(this.$t('searchCommunityData.noCallInNumber'))
                return
              }
              return
            }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
282
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
283
            const param = data.param
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
284
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
285
286
287
288
289
290
291
            if (param && param.status === 'CallIn') {
              this.clearSearchData()
              this.searchValue = param.number
              this.visible = true
              this.doSearch()
              return
            }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
292
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
293
294
295
296
            if (param && param.status === 'TalkingStart') {
              this.$emit('TalkingStart', param)
              return
            }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
297
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
298
299
300
301
            if (param && param.status === 'TalkingEnd') {
              this.$emit('TalkingEnd', param)
              return
            }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
302
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
303
304
305
306
307
            this.saveTelMachineMsg(data)
          } catch (error) {
            console.error('Error parsing WebSocket message:', error)
          }
        }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
308
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
309
310
311
312
313
        this.ws = ws
      },
      saveTelMachineMsg(data) {
        data.communityId = this.communityId
        data.machineId = this.machine.machineId
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
314
  
56732765   wuxw   修改员工界面部分bug
315
        saveTelMachineMsg(data).then(res => {
1db0a60c   wuxw   优化常用菜单 和搜索功能
316
317
318
319
          if (res.code !== 0) {
            console.error('Failed to save tel machine message:', res.msg)
            return
          }
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
320
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
          const param = res.data || {}
          if (param.action === 'sms') {
            this.$emit('sendTelMsg', {
              tel: param.tel,
              msgText: param.msgText
            })
          }
        }).catch(error => {
          console.error('Failed to post tel machine message:', error)
        })
      },
      playTts(data) {
        if (this.ws) {
          this.ws.send(JSON.stringify({
            action: 'PlayMusic',
            url: data.url,
            file_name: this.uuid() + '.wav',
            volume: 100,
            loop: true
          }))
        }
      },
      hangup() {
        if (this.ws) {
          this.ws.send(JSON.stringify({
            action: 'Hangup'
          }))
        }
      },
      callTel(data) {
        if (this.ws) {
          this.ws.send(JSON.stringify({
            action: 'CallOut',
            number: data.tel,
            cb: 'callout_cb'
          }))
          this.componentName = data.componentName
        }
      },
      sendTelMsg(data) {
        if (this.ws) {
          this.ws.send(JSON.stringify({
            action: 'SmsSend',
            number: data.tel,
            content: data.msgText
          }))
        }
      },
      uuid() {
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
370
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1db0a60c   wuxw   优化常用菜单 和搜索功能
371
372
373
374
375
376
377
378
379
380
381
          const r = Math.random() * 16 | 0
          const v = c === 'x' ? r : (r & 0x3 | 0x8)
          return v.toString(16)
        })
      }
    }
  }
  </script>
  
  <style scoped>
  .vc-search-community-item {
222dee41   wuxw   v1.9 系统菜单 部分bug 修复
382
    text-align: left;
1db0a60c   wuxw   优化常用菜单 和搜索功能
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
    margin-bottom: 20px;
  }
  
  .item-title {
    font-weight: bold;
    margin-bottom: 10px;
  }
  
  .item-content {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .margin-top {
    margin-top: 20px;
  }
  
  .margin-bottom {
    margin-bottom: 20px;
  }
  
  .text-center {
    text-align: center;
  }
  </style>