Blame view

src/components/system/searchCommunityDataList.vue 13 KB
1db0a60c   wuxw   优化常用菜单 和搜索功能
1
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
58
59
60
61
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
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
  <template>
    <el-dialog
      :visible.sync="visible"
      :title="$t('searchCommunityData.title')"
      width="80%"
      @close="handleClose"
    >
      <el-row class="margin-bottom">
        <el-col :span="14" :offset="2">
          <el-input
            v-model="searchValue"
            :placeholder="$t('searchCommunityData.placeholder')"
            @keyup.enter.native="doSearch"
          />
        </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">
              <el-link
                v-for="(item, index) in rooms"
                :key="'room'+index"
                @click="toSimplifyAcceptance(item)"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in owners"
                :key="'owner'+index"
                :href="'/#/views/owner/ownerDetail?ownerId='+item.ownerId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in ownerMembers"
                :key="'ownerMember'+index"
                :href="'/#/views/owner/ownerDetail?ownerId='+item.ownerId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in cars"
                :key="'car'+index"
                :href="'/#/views/car/carDetail?memberId='+item.carId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in carMembers"
                :key="'carMember'+index"
                :href="'/#/views/car/carDetail?memberId='+item.carId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in contracts"
                :key="'contract'+index"
                :href="'/#/views/contract/contractDetail?contractId='+item.contractId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in repairs"
                :key="'repair'+index"
                :href="'/#/pages/property/ownerRepairDetail?repairId='+item.repairId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in visits"
                :key="'visit'+index"
                :href="'/#/pages/property/visitDetail?vId='+item.vId+'&flowId='+item.flowId"
                target="_blank"
              >
                {{ 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">
              <el-link
                v-for="(item, index) in staffs"
                :key="'staff'+index"
                :href="'/#/views/staff/staffDetail?staffId='+item.userId"
                target="_blank"
              >
                {{ 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
158
  import { searchCommunityData, getTelMachineInfo, saveTelMachineMsg } from '@/api/system/searchCommunityDataApi'
1db0a60c   wuxw   优化常用菜单 和搜索功能
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
  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
199
        getTelMachineInfo({
1db0a60c   wuxw   优化常用菜单 和搜索功能
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
          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
        }
        
        searchCommunityData({
          searchValue: this.searchValue,
          communityId: this.communityId
        }).then(res => {
          if (res.code !== 0) {
            this.$message.error(res.msg)
            return
          }
          
          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 || []
          
          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)
        }).catch(error => {
          console.error('Search failed:', error)
        })
      },
      toSimplifyAcceptance(room) {
e94f0676   wuxw   跳转到业务受理页面处理完成
250
251
        this.$router.push('/pages/property/simplifyAcceptance?tab=业务受理&searchType=1&searchValue=' + `${room.floorNum}-${room.unitNum}-${room.roomNum}`)
  
1db0a60c   wuxw   优化常用菜单 和搜索功能
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
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
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
      },
      clearSearchData() {
        const ws = this.ws
        const machine = this.machine
        
        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`
        
        const ws = new WebSocket(url)
        
        ws.onerror = (event) => {
          console.log('WebSocket error:', event)
          setTimeout(() => {
            this.connectTelMachine(machine)
          }, 2000)
        }
        
        ws.onclose = () => {
          console.log('WebSocket closed')
        }
        
        ws.onopen = () => {
          console.log('WebSocket connected')
        }
        
        ws.onmessage = (event) => {
          try {
            const data = JSON.parse(event.data)
            console.log('WebSocket message:', data)
            
            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
            }
            
            const param = data.param
            
            if (param && param.status === 'CallIn') {
              this.clearSearchData()
              this.searchValue = param.number
              this.visible = true
              this.doSearch()
              return
            }
            
            if (param && param.status === 'TalkingStart') {
              this.$emit('TalkingStart', param)
              return
            }
            
            if (param && param.status === 'TalkingEnd') {
              this.$emit('TalkingEnd', param)
              return
            }
            
            this.saveTelMachineMsg(data)
          } catch (error) {
            console.error('Error parsing WebSocket message:', error)
          }
        }
        
        this.ws = ws
      },
      saveTelMachineMsg(data) {
        data.communityId = this.communityId
        data.machineId = this.machine.machineId
        
56732765   wuxw   修改员工界面部分bug
358
        saveTelMachineMsg(data).then(res => {
1db0a60c   wuxw   优化常用菜单 和搜索功能
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
          if (res.code !== 0) {
            console.error('Failed to save tel machine message:', res.msg)
            return
          }
          
          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() {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
          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 {
    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>