cnhis-design-vue 2.1.16 → 2.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +2219 -2219
  2. package/es/affix/index.js +8 -8
  3. package/es/age/index.js +10 -10
  4. package/es/alert/index.js +8 -8
  5. package/es/anchor/index.js +8 -8
  6. package/es/auto-complete/index.js +8 -8
  7. package/es/avatar/index.js +8 -8
  8. package/es/back-top/index.js +8 -8
  9. package/es/badge/index.js +8 -8
  10. package/es/base/index.js +8 -8
  11. package/es/big-table/index.js +167 -153
  12. package/es/big-table/style.css +1 -1
  13. package/es/breadcrumb/index.js +8 -8
  14. package/es/button/index.js +60 -54
  15. package/es/button/style.css +1 -1
  16. package/es/calendar/index.js +8 -8
  17. package/es/captcha/index.js +3 -3
  18. package/es/card/index.js +8 -8
  19. package/es/carousel/index.js +8 -8
  20. package/es/cascader/index.js +8 -8
  21. package/es/checkbox/index.js +9 -9
  22. package/es/col/index.js +8 -8
  23. package/es/collapse/index.js +8 -8
  24. package/es/color-picker/index.js +1 -1
  25. package/es/comment/index.js +8 -8
  26. package/es/config-provider/index.js +8 -8
  27. package/es/date-picker/index.js +8 -8
  28. package/es/descriptions/index.js +8 -8
  29. package/es/divider/index.js +8 -8
  30. package/es/drag-layout/index.js +3 -3
  31. package/es/drawer/index.js +8 -8
  32. package/es/dropdown/index.js +8 -8
  33. package/es/editor/index.js +1 -1
  34. package/es/empty/index.js +8 -8
  35. package/es/fabric-chart/index.js +480 -376
  36. package/es/fabric-chart/style.css +1 -1
  37. package/es/form/index.js +8 -8
  38. package/es/form-model/index.js +8 -8
  39. package/es/form-table/index.js +62 -62
  40. package/es/index/index.js +1181 -1041
  41. package/es/index/style.css +1 -1
  42. package/es/input/index.js +9 -9
  43. package/es/input-number/index.js +8 -8
  44. package/es/layout/index.js +8 -8
  45. package/es/list/index.js +8 -8
  46. package/es/locale-provider/index.js +8 -8
  47. package/es/map/index.js +9 -9
  48. package/es/mentions/index.js +8 -8
  49. package/es/menu/index.js +8 -8
  50. package/es/message/index.js +8 -8
  51. package/es/multi-chat/index.js +92 -92
  52. package/es/multi-chat-client/index.js +86 -86
  53. package/es/multi-chat-history/index.js +4 -4
  54. package/es/multi-chat-record/index.js +14 -14
  55. package/es/multi-chat-setting/index.js +81 -66
  56. package/es/multi-chat-setting/style.css +1 -1
  57. package/es/multi-chat-sip/index.js +1 -1
  58. package/es/notification/index.js +8 -8
  59. package/es/page-header/index.js +8 -8
  60. package/es/pagination/index.js +8 -8
  61. package/es/popconfirm/index.js +8 -8
  62. package/es/popover/index.js +8 -8
  63. package/es/progress/index.js +8 -8
  64. package/es/radio/index.js +9 -9
  65. package/es/rate/index.js +8 -8
  66. package/es/result/index.js +8 -8
  67. package/es/row/index.js +8 -8
  68. package/es/scale-view/index.js +33 -33
  69. package/es/select/index.js +11 -11
  70. package/es/select-label/index.js +11 -11
  71. package/es/select-person/index.js +20 -20
  72. package/es/skeleton/index.js +8 -8
  73. package/es/slider/index.js +8 -8
  74. package/es/space/index.js +8 -8
  75. package/es/spin/index.js +8 -8
  76. package/es/statistic/index.js +8 -8
  77. package/es/steps/index.js +8 -8
  78. package/es/switch/index.js +8 -8
  79. package/es/table-filter/index.js +171 -164
  80. package/es/table-filter/style.css +1 -1
  81. package/es/tabs/index.js +8 -8
  82. package/es/tag/index.js +9 -9
  83. package/es/time-picker/index.js +8 -8
  84. package/es/timeline/index.js +8 -8
  85. package/es/tooltip/index.js +8 -8
  86. package/es/transfer/index.js +8 -8
  87. package/es/tree/index.js +8 -8
  88. package/es/tree-select/index.js +8 -8
  89. package/es/upload/index.js +8 -8
  90. package/es/verification-code/index.js +2 -2
  91. package/lib/cui.common.js +1253 -1113
  92. package/lib/cui.umd.js +1253 -1113
  93. package/lib/cui.umd.min.js +80 -80
  94. package/package.json +107 -107
  95. package/packages/big-table/src/BigTable.vue +3039 -3038
  96. package/packages/big-table/src/assets/style/table-base.less +370 -370
  97. package/packages/big-table/src/components/AutoLayoutButton.vue +270 -270
  98. package/packages/big-table/src/utils/batchEditing.js +34 -27
  99. package/packages/big-table/src/utils/bigTableProps.js +95 -95
  100. package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
  101. package/packages/button/src/ButtonPrint/index.vue +728 -724
  102. package/packages/button/src/ButtonPrint/js/print.es.min.js +1 -1
  103. package/packages/fabric-chart/src/FabricChart.vue +15 -36
  104. package/packages/fabric-chart/src/components/TimeScaleValue.vue +113 -117
  105. package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
  106. package/packages/fabric-chart/src/fabric-chart/FabricCanvas.vue +4 -3
  107. package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +1035 -960
  108. package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +135 -133
  109. package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +558 -558
  110. package/packages/fabric-chart/src/fabric-chart2/FabricTop.vue +172 -172
  111. package/packages/fabric-chart/src/mixins/draw.js +70 -62
  112. package/packages/fabric-chart/src/mixins/eventCommon.js +9 -10
  113. package/packages/multi-chat/chat/chatFooter.vue +1598 -1598
  114. package/packages/multi-chat/chat/chatMain.vue +1442 -1442
  115. package/packages/multi-chat/chat/quickReply.vue +439 -439
  116. package/packages/multi-chat/chat/scrollList.vue +1232 -1232
  117. package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1302
  118. package/packages/multi-chat/store/actions.js +448 -448
  119. package/packages/multi-chat/store/state.js +112 -112
  120. package/packages/scale-view/formitem/r-choice.vue +714 -714
  121. package/packages/scale-view/scaleView.vue +2010 -2010
  122. package/packages/select-person/select-person.vue +1658 -1658
  123. package/packages/table-filter/src/base-search-com/BaseSearch.vue +2462 -2462
  124. package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
  125. package/packages/table-filter/src/components/multi-select/multi-select.vue +219 -219
  126. package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
  127. package/packages/table-filter/src/components/search-condition/SearchCondition.vue +3 -2
  128. package/packages/table-filter/src/const/dataOptions.js +43 -43
  129. package/packages/table-filter/src/mixins/mixins.js +695 -695
  130. package/packages/table-filter/src/quick-search/QuickSearch.vue +2083 -2083
  131. package/src/directive/preventReClick.js +12 -12
@@ -1,1442 +1,1442 @@
1
- <template>
2
- <div class="message-wrapper">
3
- <chat-header :hideHeader="hideHeader" @openPortraitPanel="handleOpenPortraitPanel" v-if="isServer && enable"></chat-header>
4
- <a-layout-content>
5
- <slot></slot>
6
- <div v-if="showBroadcast" class="broadcast-wrap">
7
- <div v-if="broadcastCarousel" class="carousel-item" :class="{ 'has-link': assemblySetting.broadcast.PC.list[0].url }" @click="goToBroadcastLink(assemblySetting.broadcast.PC.list[0])">
8
- <a-icon type="sound" />
9
- <span class="ellips">
10
- {{ assemblySetting.broadcast.PC.list[0].content }}
11
- </span>
12
- </div>
13
- <template v-else>
14
- <a-carousel dotPosition="right" autoplay :dots="false">
15
- <div class="carousel-item" v-for="(item, i) in assemblySetting.broadcast.PC.list" :key="i" :class="{ 'has-link': item.url }" @click="goToBroadcastLink(item)">
16
- <a-icon type="sound" />
17
- <span class="ellips">{{ item.content }}</span>
18
- </div>
19
- </a-carousel>
20
- </template>
21
- </div>
22
- <div v-if="sessionHistoryList.length > 1 && !(!onChating && currentTab === 'end') && !sessionEnd" style="position: absolute; top: 0; left: 20px; z-index: 1">
23
- <a-radio-group :value="selectedSession" @change="handleSessionIdChange" buttonStyle="solid">
24
- <a-radio-button :value="item.id + '-' + item.fromId" v-for="item in sessionHistoryList" :key="item.id + item.fromId">{{ item.fromName }}</a-radio-button>
25
- </a-radio-group>
26
- </div>
27
- <div class="online-message" ref="message-wrapper" v-infinite-scroll="handleInfiniteOnLoad" @scroll="scrollEvent">
28
- <template v-for="(item, index) in msgList">
29
- <div :key="index" v-if="item">
30
- <p v-if="isNeedShowTime(item, index)" class="message-time">
31
- {{ formatDate(item.createdTime) }}
32
- </p>
33
- <div v-if="item.recallFlag" style="margin: 10px 0">
34
- <template v-if="handleRecallFlag(item)">
35
- {{ getRecallText(item, isServer) }}
36
- <a style="text-decoration: underline" @click="reEditMessage(item)" v-if="[0, 4].includes(item.content && item.content.type) && onChating && isServer">,{{ i18nText('1.9.368') }}</a>
37
- </template>
38
- <template v-else>
39
- {{ getRecallText(item) || `${item.fromName} ${i18nText('1.9.365')}` }}
40
- </template>
41
- </div>
42
- <!-- 系统消息 -->
43
- <div class="system-msg" v-else-if="isSystemMsg(item)">
44
- <a-icon class="system-icon" theme="filled" type="exclamation-circle" />
45
- <div>
46
- <span v-html="getSystemMsgContent(item)"></span>
47
- <span class="system-btn" v-for="(btn, index) in getTemplateButton(item)" @click="handleTemplateButton(btn)" :key="index">{{ btn.title }}</span>
48
- </div>
49
- </div>
50
- <div
51
- v-else-if="!item.recallFlag"
52
- class="message-item"
53
- :class="[getMessageItemClass(item), { 'read-status': enableReadRecord && item.readStatus }]"
54
- :data-rid="item.readStatus === 'N' ? item.id : ''"
55
- >
56
- <img v-if="!isServer && item.fromPortrait" class="msg-avatar" :src="item.fromPortrait" />
57
-
58
- <div v-else-if="!isServer && item.fromName" class="first-name">
59
- {{ item.fromName && item.fromName.slice(0, 2) }}
60
- </div>
61
- <img v-else-if="!isServer" class="msg-avatar" :src="getAvatar(item)" width="40" height="40" />
62
-
63
- <template v-else>
64
- <img :src="customerStaffIcon" class="msg-avatar" width="40" height="40" v-if="item.fromId === 'SYSTEM'" />
65
-
66
- <img src="../img/system_message.png" class="msg-avatar" width="40" height="40" v-else-if="item.content && item.content.source === 1" />
67
-
68
- <img v-else-if="item.portrait" class="msg-avatar" :src="item.portrait" />
69
-
70
- <div v-else class="first-name">
71
- {{ item.fromName && item.fromName.slice(0, 2) }}
72
- </div>
73
- </template>
74
- <div @contextmenu="handleContextmenu($event, item)" style="display: flex">
75
- <a-spin v-if="item.sending">
76
- <a-icon slot="indicator" type="loading" style="font-size: 24px" spin />
77
- </a-spin>
78
- <a-popconfirm @confirm="handleSendFail(item)" :okText="i18nText('1.1.1.1.3')" :cancelText="i18nText('2.7.1.14')">
79
- <a-icon type="exclamation-circle" slot="icon" />
80
- <div slot="title">
81
- <span>确认重新发送该消息?</span>
82
- </div>
83
- <a-icon v-if="item.fail" theme="filled" type="exclamation-circle" style="font-size: 16px; display: flex; align-items: center; color: red" />
84
- </a-popconfirm>
85
- <div class="content-wrap" v-if="item.content.type === 0">
86
- <span class="right-time">
87
- {{ formatDate(item.createdTime || item.sendTime, true) }}
88
- </span>
89
- <div
90
- :class="{
91
- content: true,
92
- 'has-dictionary': item.dictionaryValues && item.dictionaryValues.length,
93
- 'has-intention': item.intentionList && item.intentionList.length
94
- }"
95
- >
96
- <p v-html="getContentHtml(item)"></p>
97
- <template v-if="item.content.attachments && item.content.attachments.length > 0">
98
- <div v-for="(v, index) in item.content.attachments" :key="index" class="robot-item">
99
- <a v-if="v.type == 1" :href="v.url" target="_blank"> {{ v.desc }}(超链) </a>
100
- <a @click.prevent.stop="$emit('sendQuestion', v, item)" v-if="v.type == 2 || v.type == 3" href="javascript:void(0);">
101
- {{ v.desc }}
102
- </a>
103
- </div>
104
- </template>
105
- <div v-if="item.intentionList && item.intentionList.length" class="intention-wrap">
106
- <div v-for="(v, index) in item.intentionList" :key="index" @click.prevent.stop="$emit('sendIntention', v)">
107
- <svg-icon :icon-class="v.icon || 'moren'" style="font-size: 26px"></svg-icon>
108
- <span>{{ v.name }}</span>
109
- </div>
110
- </div>
111
- </div>
112
- <ul class="dictionary-ul" v-if="item.dictionaryValues && item.dictionaryValues.length">
113
- <li v-for="(v, i) in item.dictionaryValues" :key="i" @click.prevent.stop="$emit('sendDictionary', v, item)">
114
- {{ v }}
115
- </li>
116
- </ul>
117
- <div class="client-btn" v-if="item.autoAccess && item.autoAccess === 'false'">
118
- <svg-icon icon-class="kefu"></svg-icon>
119
- <span @click="$emit('goCustomServe')">转人工客服</span>
120
- </div>
121
- </div>
122
- <div v-else-if="item.content.type === 1" class="upload-image">
123
- <MsgPicture style="max-width: 345px" :image="item.content.content" @click="show(item)" />
124
- </div>
125
- <div class="content-wrap" v-else-if="item.content.type === 2">
126
- <span class="right-time">
127
- {{ formatDate(item.createdTime || item.sendTime, true) }}
128
- </span>
129
- <div class="content">
130
- <img style="width: 16px;margin-right:8px" src="../img/multi-video.png" />
131
- {{ item.content.content }}&nbsp;
132
- <span @click.prevent.stop="reCall(item, 'video')" class="re-call" v-if="item.content.isRefuse == 1">
133
- {{ handleReCall(item) }}
134
- </span>
135
- </div>
136
- </div>
137
- <div class="content-wrap" v-else-if="item.content.type === 5">
138
- <span class="right-time">
139
- {{ formatDate(item.createdTime || item.sendTime, true) }}
140
- </span>
141
- <div class="content">
142
- <img style="width: 16px;margin-right:8px" src="../img/multi-voice.png" />
143
- {{ item.content.content }}&nbsp;
144
- <span @click.prevent.stop="reCall(item, 'voice')" class="re-call" v-if="item.content.isRefuse == 1">
145
- {{ handleReCall(item) }}
146
- </span>
147
- </div>
148
- </div>
149
- <div class="content-wrap" v-else-if="item.content.type === 6">
150
- <span class="right-time">
151
- {{ formatDate(item.createdTime || item.sendTime, true) }}
152
- </span>
153
- <div class="voice-bg content" @click.prevent.stop="playAudio(item)">
154
- <img v-if="item.content.isPlay" src="../img/audio-play.gif" alt="" />
155
- <img v-else src="../img/audio-new.png" alt="" />
156
- <span class="voice-text" :style="AudioStyle(item)"> {{ item.content.duration || 1 }}" </span>
157
- </div>
158
- </div>
159
- <template v-else-if="item.content.type === 4">
160
- <msg-describe v-if="isDescribeMsg(item)" :item="item" />
161
- <div v-else class="content-wrap">
162
- <span class="right-time">
163
- {{ formatDate(item.createdTime || item.sendTime, true) }}
164
- </span>
165
- <MsgPrescription :data="item" :isServer="isServer" :theme="isServer ? '' : 'customer'" @handleTemplateDetail="handleTemplateDetail" @handleTemplateButton="handleTemplateButton" />
166
- </div>
167
- </template>
168
- </div>
169
- <ReadStatus v-if="enableReadRecord" :status="item.readStatus" @click="openReadRecord($event, item)" />
170
- </div>
171
- </div>
172
- </template>
173
- <ul class="menu-main" ref="contextMenu" :style="contextMenuStyle" v-if="contextMenuShow">
174
- <template v-for="(item, index) in rightClickSetting">
175
- <li :key="index" class="menu-item" @click="() => handleRightClick(contextMenuItem, item)">
176
- {{ item.rightClickName }}
177
- </li>
178
- </template>
179
- </ul>
180
- <div class="session-end" v-if="sessionEnd && !isServer">
181
- <span class="end">{{ i18nText('1.9.370') }}</span>
182
- </div>
183
- <a-spin v-if="loading" class="loading-icon" />
184
- </div>
185
- <!-- 图片预览 -->
186
- <viewer class="viewer" ref="viewer" :images="images" @inited="inited" :options="options" style="display: none">
187
- <template slot-scope="scope">
188
- <img v-for="src in scope.images" :src="src" :key="src" />
189
- </template>
190
- </viewer>
191
- <!-- 卡片详情 -->
192
- <a-modal
193
- wrapClassName="chat-footer-modal-small"
194
- :title="modalData.title || i18nText('1.1.1.10')"
195
- :visible="modalShow"
196
- :maskClosable="false"
197
- :mask="true"
198
- width="80%"
199
- destroyOnClose
200
- :okText="i18nText('1.2.1.11.6')"
201
- :footer="null"
202
- @cancel="
203
- () => {
204
- this.modalShow = false;
205
- }
206
- "
207
- >
208
- <iframe id="chat-footer-modal" v-if="modalData.targetType === 'LINK_ADDRESS'" width="100%" height="100%" frameborder="0" :src="modalData.address" allow="camera;midi"></iframe>
209
- </a-modal>
210
- </a-layout-content>
211
- <audio style="display: none" controls autoplay ref="audio" preload="auto" crossOrigin="anonymous" media-player="audioPlayer" :src="curAudioUrl" @ended="audioEnd"></audio>
212
- <ReadRecord v-if="readRecordVisible" :style="readRecordStyle" :list="readRecordList" @close="closeReadRecord" />
213
- </div>
214
- </template>
215
-
216
- <script>
217
- import { Layout, Modal, Icon, Spin, Popconfirm, Carousel, Radio } from 'ant-design-vue';
218
- import SvgIcon from '@/component/svg/index.vue';
219
- import InfiniteScroll from '@/directive/scroll';
220
- import { mapGetters, mapMutations, mapActions } from '../store/helper';
221
- import fetch, { qs } from '@/utils/chatFetch';
222
- import MsgDescribe from '../components/msg-describe';
223
- import MsgPicture from '../components/msg-picture';
224
- import MsgPrescription from '../components/msg-prescription';
225
- import ReadStatus from '../components/read-status';
226
- import ReadRecord from '../components/read-record';
227
- import chatHeader from './chatHeader';
228
- import viewerOptions from './mixins/viewerOptions';
229
- import { getRecallText } from '../utils';
230
- import vexutils from '@/utils/vexutils';
231
- import ObserverScroll from '../utils/observer-scroll';
232
-
233
- const customerStaffIcon = require('../img/customer_staff.png');
234
- export default {
235
- mixins: [viewerOptions],
236
- inject: ['store', 'dispatchEvent', 'registerEvent', 'unregisterEvent', 'i18nText'],
237
- props: {
238
- hideHeader: {
239
- type: Boolean,
240
- default: false
241
- },
242
- robotAvatar: {
243
- type: String,
244
- default: ''
245
- },
246
- curChatType: {
247
- type: String
248
- },
249
- isShowPortraitPanel: {
250
- type: Boolean
251
- },
252
- activatedTime: {
253
- type: Number
254
- }
255
- },
256
- data() {
257
- return {
258
- loading: false,
259
- // 卡片详情
260
- modalShow: false,
261
- modalData: {},
262
- // 客户头像
263
- // 右键操作
264
- contextMenuStyle: {
265
- position: 'fixed',
266
- top: 0,
267
- left: 0
268
- },
269
- contextMenuShow: false,
270
- contextMenuItem: null,
271
- // 查看历史消息滚动定位
272
- scrollHeight: 0,
273
- curAudioUrl: '',
274
- lastAudioItem: null,
275
- readRecordStyle: '',
276
- readRecordVisible: false,
277
- readRecordList: []
278
- };
279
- },
280
- computed: {
281
- ...mapGetters([
282
- 'userInfo',
283
- 'currentTab',
284
- 'isAppendMsg',
285
- 'message',
286
- 'msgList',
287
- 'sessionId',
288
- 'serviceId',
289
- 'scrollTo',
290
- 'isServer',
291
- 'clientId',
292
- 'sessionEnd',
293
- 'assemblyId',
294
- 'footerMessage',
295
- 'portraitPanelParams',
296
- 'assemblySetting',
297
- 'clientParams',
298
- 'onChating',
299
- 'classify',
300
- 'collapsed',
301
- 'barStatus',
302
- 'sessionHistoryList',
303
- 'enable',
304
- 'appendList',
305
- 'queueItem',
306
- 'isRecorderVoice'
307
- ]),
308
- orgId() {
309
- const getters = this.store.getters;
310
- return this.isServer ? this.userInfo?.sysParams?.orgId : getters.accessParams.orgId || getters.queryParams.orgId;
311
- },
312
- userId() {
313
- const getters = this.store.getters;
314
- return this.isServer ? this.userInfo?.sysParams?.userId : getters.accessParams.userId || getters.chatUserId || getters.queryParams.userId;
315
- },
316
- enableReadRecord() {
317
- return this.assemblySetting?.readStatus === 'Y';
318
- },
319
- customerStaffIcon() {
320
- return this.robotAvatar || customerStaffIcon;
321
- },
322
- selectedSession() {
323
- let sessionMap = this.sessionHistoryList.find(item => item.fromId === this.serviceId);
324
- if (sessionMap) {
325
- return sessionMap.id + '-' + sessionMap.fromId;
326
- }
327
- return '';
328
- },
329
- isListClassify() {
330
- return this.assemblySetting.isListClassify === 'Y';
331
- },
332
- showPanel() {
333
- return this.assemblySetting.portraitPanelSetting?.targetIs;
334
- },
335
- showBroadcast() {
336
- let res = (!this.isServer && this.assemblySetting?.broadcast?.PC?.isChecked == 'Y' && this.assemblySetting?.broadcast?.PC?.list?.length > 0) || false;
337
- return res;
338
- },
339
- broadcastCarousel() {
340
- return (this.assemblySetting.broadcast && this.assemblySetting.broadcast.PC.list.length == 1) || false;
341
- },
342
- rightClickSetting() {
343
- const { isServer } = this;
344
- if (!isServer) return [];
345
- const isSelf = this.contextMenuItem.fromId === this.serviceId;
346
- const setting = this.assemblySetting?.rightClickSetting || [];
347
- const doArr = ['resend', 'rollBack'];
348
- return setting.filter(item => {
349
- const { rightClickDo } = item;
350
- return isSelf || doArr.indexOf(rightClickDo) < 0;
351
- });
352
- },
353
- handleReCall() {
354
- return function(item) {
355
- if (item.content?.source === 1) {
356
- return '[点击回拨]';
357
- } else if (item.senderFlag == 1) {
358
- return `[点击${this.isServer ? '回拨' : '重拨'}]`;
359
- }
360
- if (item.senderFlag == 2) {
361
- return `[点击${this.isServer ? '重拨' : '回拨'}]`;
362
- }
363
- if (this.isServer) {
364
- let isRight = item.fromId !== 'SYSTEM' && item.fromId && item.fromId === this.serviceId;
365
- return `[点击${isRight ? '重拨' : '回拨'}]`;
366
- } else {
367
- let isRight = (item.fromId !== 'SYSTEM' && item.toId === 'SYSTEM') || item.fromId === this.clientId || (item.mode === 'bot' && !item.fromId);
368
- return `[点击${isRight ? '重拨' : '回拨'}]`;
369
- }
370
- };
371
- },
372
- handleRecallFlag() {
373
- return function(item) {
374
- return this.serviceId == item.fromId;
375
- };
376
- },
377
- AudioStyle() {
378
- return function(item) {
379
- let { duration = 1 } = item.content;
380
- if (!duration) {
381
- duration = 1;
382
- }
383
- let curWidth = (+duration / 60) * 400;
384
- return {
385
- width: curWidth < 13 ? 13 : curWidth + 'px'
386
- };
387
- };
388
- },
389
- showTimeDuration() {
390
- let { variableSetting = null } = this.assemblySetting || {};
391
- if (!variableSetting) return 3;
392
- let matchItem = variableSetting.find(v => v.name === 'CHAT_SEPARATION_TIME');
393
- if (!matchItem) return 3;
394
- if (!+matchItem.value) return 3;
395
- return +matchItem.value;
396
- },
397
- images() {
398
- return this.msgList.filter(v => !v.recallFlag && v.content.type == 1)?.map(v => v.content?.content);
399
- }
400
- },
401
- created() {
402
- this.attachEvent();
403
- },
404
- methods: {
405
- ...mapMutations([
406
- 'setIsAppendMsg',
407
- 'setMsgList',
408
- 'setScrollTo',
409
- 'setFooterMessage',
410
- 'setIsScrollListChange',
411
- 'setListChangeItem',
412
- 'setSessionId',
413
- 'setOnChating',
414
- 'setServiceId',
415
- 'setShowAudio',
416
- 'setVideoMode',
417
- 'setVideoMembers',
418
- 'setIsRecorderVoice'
419
- ]),
420
- ...mapActions({
421
- getEarlierMsg: 'setMsgList',
422
- handleBotChat: 'handleBotChat',
423
- sendMessage: 'sendMessage'
424
- }),
425
- getMessageItemClass(item) {
426
- // content.source === 1, 代表为系统消息, 系统统一左侧展示
427
- if (item.content?.source === 1) {
428
- return {
429
- left: true
430
- };
431
- }
432
-
433
- // 服务端 senderFlag 1 左 2 右
434
- // 客户端 senderFlag 1 右 2 左
435
- if (item.content?.source === 1) {
436
- return {
437
- left: true
438
- };
439
- } else if (item.senderFlag == 1) {
440
- if (this.isServer) {
441
- return {
442
- left: true
443
- };
444
- } else {
445
- return {
446
- right: true
447
- };
448
- }
449
- }
450
- if (item.senderFlag == 2) {
451
- if (this.isServer) {
452
- return {
453
- right: true
454
- };
455
- } else {
456
- return {
457
- left: true
458
- };
459
- }
460
- }
461
- if (this.isServer) {
462
- return {
463
- right: item.fromId !== 'SYSTEM' && item.fromId && item.fromId === this.serviceId,
464
- left: item.fromId === 'SYSTEM' || item.fromId === this.clientId || item.content?.source === 1 || !item.fromId
465
- };
466
- } else {
467
- let isRight, isLeft;
468
- if (this.curChatType == 'robot') {
469
- isRight = item.fromId !== 'SYSTEM';
470
- isLeft = item.fromId === 'SYSTEM';
471
- } else {
472
- isRight = (item.fromId !== 'SYSTEM' && item.toId === 'SYSTEM') || item.fromId === this.clientId || (item.mode === 'bot' && !item.fromId);
473
- isLeft = item.fromId === 'SYSTEM' || item.fromId !== this.clientId || item.content?.source === 1;
474
- }
475
- return {
476
- right: isRight,
477
- left: isLeft
478
- };
479
- }
480
- },
481
- /* 向上滚动刷新 */
482
- handleInfiniteOnLoad() {
483
- if (this.curChatType === 'robot') return;
484
- this.loading = true;
485
- this.getEarlierMsg().then(msg => {
486
- if (msg) {
487
- this.$message.info(msg);
488
- }
489
- this.loading = false;
490
- });
491
- },
492
- show(item) {
493
- const src = item.content.content;
494
- // this.images = vexutils.imgs2imgArr(src);
495
- this.$viewer.view(this.images.findIndex(v => v === src));
496
- this.$viewer.show();
497
- this.readSingleMsg(item);
498
- },
499
- /* 滚动条定位 */
500
- handleScrollTo(scrollTo) {
501
- let target = this.$refs['message-wrapper'];
502
- this.$nextTick().then(() => {
503
- if (!target) return;
504
- let top = target.scrollHeight;
505
- if (scrollTo === 'current') {
506
- top = target.scrollHeight - this.scrollHeight;
507
- }
508
- if (typeof scrollTo === 'number') {
509
- top = scrollTo;
510
- }
511
- target.scrollTo({
512
- left: 0,
513
- top,
514
- behavior: 'instant'
515
- });
516
- this.scrollHeight = 0;
517
- });
518
- this.setScrollTo('');
519
- },
520
-
521
- /**
522
- * 是否需要显示时间
523
- */
524
- isNeedShowTime(item, index) {
525
- const curMsgTime = item.createdTime || new Date().getTime();
526
- let duration = 60 * 1000 * this.showTimeDuration;
527
- let lastMsgTime;
528
- if (index == 0) {
529
- lastMsgTime = 0;
530
- } else {
531
- lastMsgTime = this.msgList[index - 1].createdTime;
532
- }
533
- if (Number(curMsgTime) - Number(lastMsgTime) > duration) {
534
- return true;
535
- } else {
536
- return false;
537
- }
538
- },
539
- formatDate(date) {
540
- return vexutils.formatDate(date, true);
541
- },
542
- getAvatar(item) {
543
- if (item.content && item.content.source === 1) {
544
- return require('../img/system_message.png');
545
- }
546
- if (item.mode === 'bot' && !item.fromId) {
547
- return require('../img/default.png');
548
- }
549
- if (this.isServer) {
550
- if (item.fromId === this.clientId || !item.fromId) {
551
- return require('../img/default.png');
552
- } else {
553
- return this.customerStaffIcon;
554
- }
555
- } else {
556
- if (this.curChatType == 'robot') {
557
- if (item.fromId === 'SYSTEM') {
558
- return this.customerStaffIcon;
559
- } else {
560
- return require('../img/default.png');
561
- }
562
- } else {
563
- if (item.fromId !== this.clientId) {
564
- return this.customerStaffIcon;
565
- } else {
566
- return require('../img/default.png');
567
- }
568
- }
569
- }
570
- },
571
- getContent(item) {
572
- let content;
573
- if (vexutils.isJSON(item.content.content)) {
574
- content = JSON.parse(item.content.content);
575
- } else {
576
- content = item.content.content;
577
- }
578
- return content;
579
- },
580
- getContentHtml(item) {
581
- return !~item.content.content.indexOf('emoji') ? this.$xss(item.content.content) : item.content.content;
582
- },
583
- getTemplateTitle(item) {
584
- return this.getContent(item)?.title;
585
- },
586
- showArrow(item) {
587
- let setting = this.getContent(item)?.customerSetting || {};
588
- if (this.isServer) {
589
- setting = this.getContent(item)?.serverSetting || {};
590
- }
591
- let { address } = setting;
592
- if (!address) return false;
593
- return true;
594
- },
595
- getTemplateTitleIcon(item) {
596
- return this.getContent(item)?.icon;
597
- },
598
- getTemplateContent(item) {
599
- let content = this.getContent(item);
600
- let array = [];
601
- try {
602
- array = content.content.split('##');
603
- } catch {
604
- console.log(content, 'error');
605
- }
606
- array = array.map(item => `<div>${item}</div>`);
607
- return array.join('');
608
- },
609
- getSystemMsgContent(item) {
610
- let content = this.getContent(item);
611
- let array = [];
612
- try {
613
- array = content.content.split('##');
614
- } catch {
615
- console.log(content, 'error');
616
- }
617
- return array.join('<br>');
618
- },
619
- getTemplateButton(item) {
620
- let content = this.getContent(item);
621
- const setting = this.isServer ? content.serverSetting : content.customerSetting;
622
- return setting?.toolbar_button || [];
623
- },
624
- // 处理模板按钮,详情等跳转
625
- handleTemplate(data, dispatch = true) {
626
- let { targetType, address, params = [], openMode } = data;
627
- dispatch &&
628
- this.dispatchEvent('click_templateCard', {
629
- ...data
630
- });
631
- if (!address) return;
632
- if (targetType === 'LINK_ADDRESS') {
633
- let urlParams = [];
634
- params.forEach(({ p_name, p_value }) => {
635
- urlParams.push(`${p_name}=${p_value}`);
636
- });
637
- if (address.includes('?')) {
638
- address += `&${urlParams.join('&')}`;
639
- } else {
640
- address += `?${urlParams.join('&')}`;
641
- }
642
- if (openMode === 'WINDOW') {
643
- window.open(address);
644
- return;
645
- }
646
- if (openMode === 'EJECT') {
647
- this.modalShow = true;
648
- this.modalData = Object.assign({}, data, {
649
- address
650
- });
651
- return;
652
- }
653
- }
654
- },
655
- handleTemplateDetail(item) {
656
- let content = this.getContent(item) || {};
657
- let setting = content.customerSetting || {};
658
- if (this.isServer) {
659
- setting = content.serverSetting || {};
660
- }
661
- this.readSingleMsg(item);
662
- this.handleTemplate(setting);
663
- },
664
- handleTemplateButton(btn) {
665
- this.handleTemplate(btn);
666
- },
667
- // 消息撤回
668
- handleRecall(item) {
669
- let params = {
670
- assemblyId: this.assemblyId,
671
- sessionId: this.sessionId,
672
- messageId: item.id,
673
- messageType: item.content?.type,
674
- userId: this.userInfo?.sysParams?.userId || ''
675
- };
676
-
677
- fetch.post('/chat/service/recallMessage', qs.stringify(params)).then(({ data }) => {
678
- if (data.result === 'SUCCESS') {
679
- this.dispatchEvent('msg_recallSuccess', {
680
- message: { ...item },
681
- ...params
682
- });
683
- this.$set(item, 'recallFlag', 1);
684
- // 撤回成功提示
685
- let title = this.getContent(item)?.title;
686
- let text = title ? `已撤回[${title}]` : '已撤回';
687
- this.$message.success(text);
688
-
689
- if (!this.isLastMessage(item.id)) return;
690
- this.setIsScrollListChange(true);
691
- this.setListChangeItem({
692
- opt: 1,
693
- from: this.clientId,
694
- sessionId: this.sessionId,
695
- msgCount: 0,
696
- lastContentRecallFlag: 1,
697
- lastContent: vexutils.clone(item.content, true),
698
- lastTime: new Date().getTime()
699
- });
700
- } else {
701
- this.$message.error(data.resultMsg);
702
- }
703
- });
704
- },
705
- handleJumpUrl(contextMenuItem, item) {
706
- const title = item.rightClickName;
707
- const url = item.rightClickUrl.replace(/{(.*?)}/g, (match, p) => {
708
- return eval(p);
709
- });
710
- this.dispatchEvent('open_jumpUrl', {
711
- title: title,
712
- url: url
713
- });
714
- },
715
- // 右键菜单功能
716
- handleRightClick(contextMenuItem, item) {
717
- if (item.rightClickDo === 'rollBack') {
718
- this.handleRecall(contextMenuItem);
719
- } else if (item.rightClickDo === 'jumpUrl') {
720
- this.handleJumpUrl(contextMenuItem, item);
721
- } else if (item.rightClickDo === 'resend') {
722
- this.resendMessage(contextMenuItem);
723
- }
724
- },
725
- resendMessage(item) {
726
- fetch({
727
- method: 'POST',
728
- url: '/chat/service/resendMessage',
729
- data: qs.stringify({
730
- assemblyId: this.assemblyId,
731
- sessionId: this.sessionId,
732
- messageId: item.id
733
- })
734
- });
735
- },
736
- // 重新编辑
737
- reEditMessage(item) {
738
- if (item.content?.type === 4) {
739
- let content = this.getContent(item);
740
- this.handleTemplate(content.serverSetting.reEditSetting, false);
741
- return;
742
- }
743
- this.setFooterMessage(this.footerMessage + item.content.content.slice(5, -6));
744
- },
745
- observeMsg() {
746
- if (this.enableReadRecord) {
747
- if (!this._observer) {
748
- this._observer = new ObserverScroll(this.$refs['message-wrapper'], this.readMsg);
749
- this.$on('hook:beforeDestroy', () => {
750
- this._observer.remove();
751
- this._observer = null;
752
- });
753
- }
754
- this._observer.disconnect();
755
- if (this.msgList.length) {
756
- this.$nextTick(() => {
757
- const el = this.$refs['message-wrapper'];
758
- const els = el?.querySelectorAll('.message-item.left');
759
- els && this._observer.observe(Array.from(els).filter(item => item.getAttribute('data-rid')));
760
- });
761
- }
762
- }
763
- },
764
- readMsg(ids, enableVaid = true, notify = true, post = true) {
765
- const msgList = this.msgList;
766
- const idKeys = msgList.reduce((obj, item, i) => {
767
- const id = item?.id;
768
- if (id) obj[id] = i;
769
- return obj;
770
- }, {});
771
- const data = [];
772
- const validFn = (item, type) => {
773
- /**
774
- * 针对文本、表情消息类型,只要在聊天区域内,视为已读,
775
- * 图片、语音类型消息,需要点击查看后,才视为已读,
776
- * 模板 类型消息,如果没有详情链接,只要在聊天区域内,视为已读,若有详情链接,需要点击查看后,才视为已读
777
- */
778
- const jumpType = `,6,1,`;
779
- if (jumpType.includes(type)) return false;
780
- if (type == 4 && !this.isDescribeMsg(item)) {
781
- let content = this.getContent(item) || {};
782
- let setting = (this.isServer ? content.serverSetting : content.customerSetting) || {};
783
- return !setting?.address;
784
- }
785
- return true;
786
- };
787
- const value = ids.filter(id => {
788
- const i = idKeys[id];
789
- let item = msgList[i];
790
- if (item) {
791
- const type = item.content.type;
792
- if (!enableVaid || validFn(item, type)) {
793
- item.readStatus = 'Y';
794
- data.push({ id, type });
795
- return true;
796
- }
797
- return false;
798
- }
799
- });
800
- if (!value.length) return;
801
- notify &&
802
- this.dispatchEvent('msg_readed', {
803
- data,
804
- assemblyId: this.assemblyId,
805
- sessionId: this.sessionId
806
- });
807
- post && this.postReadMessage({ ids: value.join(',') });
808
- },
809
- postReadMessage(data) {
810
- fetch.post(
811
- `/chat/${this.isServer ? 'service' : 'access'}/readMessage`,
812
- qs.stringify({
813
- assemblyId: this.assemblyId,
814
- orgId: this.orgId,
815
- userId: this.userId,
816
- sessionId: this.sessionId,
817
- ...data
818
- })
819
- );
820
- },
821
- readSingleMsg(item) {
822
- if (this.enableReadRecord && item.readStatus === 'N') {
823
- const cls = this.getMessageItemClass(item);
824
- if (!cls?.left) return;
825
- this.readMsg([item.id], false);
826
- }
827
- },
828
- closeReadRecord() {
829
- this.readRecordVisible = false;
830
- this.readRecordList = [];
831
- },
832
- openReadRecord(event, item) {
833
- const readStatus = item.readStatus;
834
- if (readStatus) {
835
- const cls = this.getMessageItemClass(item);
836
- if (!cls.right) return;
837
- const rect = event.target.getBoundingClientRect();
838
- const w = 440;
839
- const h = 340;
840
- const top = Math.max(0, Math.min(document.body.clientHeight - h, rect.top - h / 2));
841
- const left = Math.max(0, Math.min(document.body.clientWidth - w, rect.left - w));
842
- fetch({
843
- url: `/chat/${this.isServer ? 'service' : 'access'}/getMessageMember`,
844
- method: 'get',
845
- params: {
846
- assemblyId: this.assemblyId,
847
- messageId: item.id,
848
- orgId: this.isServer ? undefined : this.orgId
849
- }
850
- }).then(res => {
851
- const list = res.data?.list || [];
852
- this.readRecordStyle = `top:${top}px;left:${left}px;position:fixed;z-index:10`;
853
- this.readRecordVisible = list.length > 0;
854
- this.readRecordList = Object.freeze(list);
855
- if (item.readStatus && list.length) {
856
- const unread = list.filter(item => item.readStatus == 'N').length;
857
- const single = list.length < 2;
858
- const status = unread > 0 ? (single ? 'N' : `${unread}`) : single ? 'Y' : 'ALL';
859
- // 检查是否更新人数
860
- if (item.readStatus != status) {
861
- item.readStatus = status;
862
- }
863
- }
864
- });
865
- }
866
- },
867
- isLastMessage(id) {
868
- return this.msgList.findIndex(msg => msg.id === id) === this.msgList.length - 1;
869
- },
870
- isSystemMsg(item) {
871
- return item.content.type == 4 && this.getContent(item).styleId == '2';
872
- },
873
- isDescribeMsg(item) {
874
- return this.getContent(item).styleId == '3';
875
- },
876
- async handleOpenPortraitPanel(item) {
877
- if (!this.showPanel || item.fromId === this.serviceId || !this.isServer || !this.isShowPortraitPanel) return;
878
- const { portraitPanelParams, clientParams } = this;
879
- const panelSetting = this.assemblySetting?.portraitPanelSetting;
880
- this.dispatchEvent('open_portraitPanel', {
881
- panelSetting,
882
- clientParams,
883
- panelParams: portraitPanelParams,
884
- targetId: panelSetting?.targetId,
885
- targetType: panelSetting?.targetType
886
- });
887
- },
888
- handleContextmenu(e, item) {
889
- // 系统消息,客户消息,待接入消息,历史消息不允许撤回
890
- // 模板-描述消息禁用右键
891
- if (item.content?.source === 1 || !this.sessionId || (this.sessionId && !this.onChating) || (item.content.type === 4 && this.isDescribeMsg(item))) return;
892
- this.contextMenuItem = item;
893
- if (this.rightClickSetting.length < 1) return;
894
- e.preventDefault();
895
- let left = e.pageX + 'px';
896
- let top = e.pageY + 'px';
897
- this.contextMenuStyle = Object.assign(this.contextMenuStyle, {
898
- top,
899
- left
900
- });
901
- this.contextMenuShow = true;
902
- },
903
- scrollEvent(e) {
904
- console.log('e.target.scrollTop->', e.target.scrollTop);
905
- this._scrollTop = e.target.scrollTop;
906
- },
907
- /* 事件绑定 */
908
- attachEvent() {
909
- this.scrollEvent = vexutils.debounce(this.scrollEvent, 800);
910
- const handleClick = () => {
911
- this.contextMenuShow = false;
912
- };
913
- const handleRasize = () => {
914
- if (this.readRecordVisible) {
915
- let style = this.readRecordStyle;
916
- const top = style.match(topReg)?.[1];
917
- const topReg = /top:([\d.]+)/;
918
- const maxH = document.body.clientHeight - 360;
919
- if (top && maxH < top) {
920
- style = style.replace(topReg, `top:${maxH}`);
921
- }
922
- const leftReg = /left:([\d.]+)/;
923
- const left = style.match(leftReg)?.[1];
924
- const maxW = document.body.clientWidth - 440;
925
- if (left && maxW < left) {
926
- style = style.replace(leftReg, `left:${maxW}`);
927
- }
928
- this.readRecordStyle = style;
929
- }
930
- };
931
- window.addEventListener('resize', handleRasize);
932
- document.addEventListener('click', handleClick);
933
- this.registerEvent('openPortraitPanel', this.handleOpenPortraitPanel);
934
- const readMessage = data => {
935
- this.readMsg(data.ids.split(','), false, false, false);
936
- this.postReadMessage(data);
937
- };
938
- this.registerEvent('readMessage', readMessage);
939
- this.$on('hook:beforeDestroy', () => {
940
- window.removeEventListener('resize', handleRasize);
941
- document.removeEventListener('click', handleClick);
942
- this.unregisterEvent('openPortraitPanel', this.handleOpenPortraitPanel);
943
- this.unregisterEvent('readMessage', readMessage);
944
- });
945
- },
946
- goToBroadcastLink(item) {
947
- if (!item.url) return;
948
- window.open(item.url);
949
- },
950
- /**
951
- * 客服切换
952
- */
953
- handleSessionIdChange(e) {
954
- let [sessionId, serviceId] = e.target.value.split('-');
955
- this.setSessionId(sessionId);
956
- this.setServiceId(serviceId);
957
- let isOnChating = this.sessionHistoryList.find(item => item.fromId === serviceId).onChating;
958
- this.setOnChating(!!isOnChating);
959
- this.setMsgList([]);
960
- this.getEarlierMsg();
961
- },
962
- handleSendFail(item) {
963
- this.sendMessage(Object.assign(item.content, { failItem: item }));
964
- },
965
- reCall(type) {
966
- this.setShowAudio(true);
967
- this.setVideoMode(type === 'voice' ? 1 : 2);
968
- this.$nextTick(() => {
969
- this.setVideoMembers([]);
970
- });
971
- },
972
- playAudio(item) {
973
- let { content = '' } = item?.content || {};
974
- if (!content) return;
975
- if (this.lastAudioItem && (item.id !== this.lastAudioItem.id || item.createdTime !== this.lastAudioItem.createdTime)) {
976
- this.$set(this.lastAudioItem.content, 'isPlay', false);
977
- }
978
-
979
- this.readSingleMsg(item);
980
- this.lastAudioItem = item;
981
- this.$set(item.content, 'isPlay', !item.content.isPlay);
982
- this.$nextTick(() => {
983
- this.curAudioUrl = content;
984
- let audioRef = this.$refs['audio'];
985
- if (!audioRef) return;
986
- audioRef.load();
987
- setTimeout(() => {
988
- if (item.content.isPlay) {
989
- let playPromise = audioRef.play();
990
- if (playPromise !== undefined) {
991
- playPromise.then(() => {
992
- audioRef.play();
993
- });
994
- }
995
- } else {
996
- audioRef.pause();
997
- this.curAudioUrl = '';
998
- }
999
- });
1000
- });
1001
- },
1002
- audioEnd() {
1003
- if (!this.lastAudioItem) return;
1004
- this.$set(this.lastAudioItem.content, 'isPlay', false);
1005
- },
1006
- getRecallText(item, flag = false) {
1007
- return getRecallText(this, item, flag);
1008
- }
1009
- },
1010
- directives: {
1011
- InfiniteScroll
1012
- },
1013
- components: {
1014
- AModal: Modal,
1015
- [Layout.Content.name]: Layout.Content,
1016
- [Spin.name]: Spin,
1017
- [Icon.name]: Icon,
1018
- [Popconfirm.name]: Popconfirm,
1019
- [Radio.Button.name]: Radio.Button,
1020
- [Radio.Group.name]: Radio.Group,
1021
- [Carousel.name]: Carousel,
1022
- SvgIcon,
1023
- MsgPrescription,
1024
- ReadStatus,
1025
- ReadRecord,
1026
- MsgPicture,
1027
- MsgDescribe,
1028
- chatHeader
1029
- },
1030
- watch: {
1031
- msgList() {
1032
- this.observeMsg();
1033
- },
1034
- isAppendMsg: {
1035
- immediate: true,
1036
- handler(isAppendMsg) {
1037
- if (isAppendMsg) {
1038
- let newArr = [];
1039
- if (vexutils.isPlainObject(this.message)) {
1040
- newArr = [...this.msgList, this.message];
1041
- } else if (vexutils.isArray(this.message)) {
1042
- newArr = [...this.msgList, ...this.message];
1043
- }
1044
- this.setMsgList(newArr);
1045
- this.setIsAppendMsg(false);
1046
- this.setScrollTo('bottom');
1047
- }
1048
- }
1049
- },
1050
- scrollTo: {
1051
- immediate: true,
1052
- handler(scrollTo) {
1053
- if (scrollTo) {
1054
- this.handleScrollTo(scrollTo);
1055
- }
1056
- }
1057
- },
1058
- activatedTime: {
1059
- immediate: true,
1060
- handler(value) {
1061
- this.handleScrollTo(this._scrollTop);
1062
- }
1063
- },
1064
- /**
1065
- * 图片懒加载处理
1066
- */
1067
- appendList: {
1068
- handler() {
1069
- if (!this.scrollHeight) {
1070
- let target = this.$refs['message-wrapper'];
1071
- this.scrollHeight = target.scrollHeight;
1072
- }
1073
- if (this.appendList.length === this.msgList.length || this.appendList.length === 1) {
1074
- this.setScrollTo('bottom');
1075
- } else {
1076
- this.setScrollTo('current');
1077
- }
1078
- }
1079
- },
1080
- isRecorderVoice: {
1081
- immediate: true,
1082
- handler(val) {
1083
- if (!val) return;
1084
- this.curAudioUrl = '';
1085
- this.setIsRecorderVoice(false);
1086
- if (!this.lastAudioItem) return;
1087
- this.$set(this.lastAudioItem.content, 'isPlay', false);
1088
- }
1089
- }
1090
- }
1091
- };
1092
- </script>
1093
-
1094
- <style lang="less" scoped>
1095
- @import '../style/emoji.css';
1096
- @import '../style/message.mixin.less';
1097
- .message-wrapper {
1098
- .createMessageStyle(#ebebeb, @primary-color);
1099
- flex: 1;
1100
- height: 0;
1101
- // position: relative;
1102
- display: flex;
1103
- flex-direction: column;
1104
- overflow-x: hidden;
1105
- .broadcast-wrap {
1106
- height: 30px;
1107
- text-align: center;
1108
- font-size: 14px;
1109
- background-color: #fffbe8;
1110
- /deep/ .carousel-item {
1111
- display: inline-flex !important;
1112
- justify-content: center;
1113
- align-items: center;
1114
- width: 100%;
1115
- height: 30px;
1116
- text-align: center;
1117
- &.has-link {
1118
- color: #ed6a0c;
1119
- cursor: pointer;
1120
- }
1121
- span {
1122
- display: inline-block;
1123
- max-width: calc(100% - 30px);
1124
- margin-left: 4px;
1125
- }
1126
- }
1127
- }
1128
-
1129
- .loading-icon {
1130
- position: absolute;
1131
- top: 0;
1132
- left: 50%;
1133
- }
1134
- }
1135
- /deep/ .ant-layout-content {
1136
- flex: 1;
1137
- display: flex;
1138
- flex-direction: column;
1139
- position: relative;
1140
- }
1141
- .online-message {
1142
- flex: 1;
1143
- height: 100%;
1144
- // height: 608px;
1145
- overflow-y: auto;
1146
- overflow-x: hidden;
1147
- padding: 10px 22px;
1148
- // margin: 10px 0;
1149
- text-align: center;
1150
- &::-webkit-scrollbar {
1151
- width: 5px;
1152
- }
1153
- .message-time {
1154
- display: inline-block;
1155
- color: #666;
1156
- font-size: 14px;
1157
- border-radius: 4px;
1158
- padding: 4px;
1159
- margin: 0 auto;
1160
- margin-bottom: 16px;
1161
- }
1162
- > div {
1163
- margin-bottom: 16px;
1164
- }
1165
- .message-item {
1166
- display: flex;
1167
- /deep/ .chat-read-status-text {
1168
- display: none;
1169
- }
1170
- &.right.read-status {
1171
- padding-bottom: 24px;
1172
- position: relative;
1173
- /deep/ .chat-read-status-text {
1174
- display: block;
1175
- position: absolute;
1176
- right: 50px;
1177
- bottom: 0;
1178
- }
1179
- }
1180
- .right-time {
1181
- display: none;
1182
- position: absolute;
1183
- top: -16px;
1184
- left: 10px;
1185
- font-size: 12px;
1186
- color: #b0b1b1;
1187
- white-space: nowrap;
1188
- }
1189
-
1190
- .content-wrap {
1191
- padding: 0 10px;
1192
- text-align: left;
1193
- position: relative;
1194
- &:hover {
1195
- .right-time {
1196
- display: block;
1197
- }
1198
- }
1199
-
1200
- .robot-item {
1201
- text-align: left;
1202
- a {
1203
- text-decoration: underline;
1204
- }
1205
- }
1206
- .intention-wrap {
1207
- display: flex;
1208
- flex-wrap: wrap;
1209
- padding: 8px 0 4px 0;
1210
- background-color: #fff;
1211
- border-radius: 0 0 8px 8px;
1212
- > div {
1213
- display: inline-flex;
1214
- flex-direction: column;
1215
- align-items: center;
1216
- width: 60px;
1217
- height: 54px;
1218
- cursor: pointer;
1219
-
1220
- &:hover {
1221
- color: #5585f5;
1222
- span {
1223
- color: #5585f5;
1224
- }
1225
- }
1226
- }
1227
- span {
1228
- margin-top: 8px;
1229
- max-width: 90%;
1230
- text-overflow: ellipsis;
1231
- overflow: hidden;
1232
- white-space: nowrap;
1233
- font-size: 12px;
1234
- color: #6a6a6a;
1235
- }
1236
- }
1237
- .dictionary-ul {
1238
- padding-top: 8px;
1239
- display: flex;
1240
- flex-wrap: wrap;
1241
- li {
1242
- padding: 4px 16px;
1243
- margin-right: 16px;
1244
- font-size: 14px;
1245
- color: #5585f5;
1246
- background: #efefef;
1247
- border-radius: 16px;
1248
- cursor: pointer;
1249
- }
1250
- }
1251
- .client-btn {
1252
- display: inline-block;
1253
- padding: 4px 8px;
1254
- margin-top: 8px;
1255
- color: #fff;
1256
- font-size: 12px;
1257
- border-radius: 20px;
1258
- background: #5585f5;
1259
- cursor: pointer;
1260
- }
1261
- .re-call {
1262
- cursor: pointer;
1263
- color: #5585f5;
1264
- }
1265
- .voice-bg {
1266
- display: flex;
1267
- align-items: center;
1268
- cursor: pointer;
1269
- img {
1270
- mix-blend-mode: difference;
1271
- display: inline-block;
1272
- width: 14px;
1273
- }
1274
- .voice-text {
1275
- display: inline-block;
1276
- }
1277
- span {
1278
- margin-left: 8px;
1279
- }
1280
- }
1281
- }
1282
- .has-dictionary {
1283
- padding: 0;
1284
- text-align: left;
1285
- background: unset;
1286
- }
1287
- .content {
1288
- padding: 10px;
1289
- background: #ebebeb;
1290
- border-radius: 0px 8px 8px 8px;
1291
- max-width: 500px;
1292
- margin: 0px;
1293
- line-height: 20px;
1294
- font-size: 14px;
1295
- color: #000;
1296
- text-align: left;
1297
- word-break: break-word;
1298
- /deep/ p {
1299
- margin: 0;
1300
- }
1301
- }
1302
- .upload-image {
1303
- margin-left: 8px;
1304
- }
1305
- &.right {
1306
- flex-direction: row-reverse;
1307
- .right-time {
1308
- left: unset;
1309
- right: 10px;
1310
- }
1311
- .content-wrap {
1312
- text-align: right;
1313
- .robot-item {
1314
- text-align: right;
1315
- }
1316
- .voice-bg {
1317
- flex-direction: row-reverse;
1318
- align-self: flex-end;
1319
- img {
1320
- transform: rotateY(180deg);
1321
- }
1322
- span {
1323
- margin-left: 0;
1324
- margin-right: 8px;
1325
- text-align: right;
1326
- }
1327
- }
1328
- }
1329
- .content-wrap .content {
1330
- background-color: #e7f0ff;
1331
- border-radius: 8px 0px 8px 8px;
1332
- border: 1px solid #e7f0ff;
1333
- box-sizing: border-box;
1334
- }
1335
- .upload-image {
1336
- margin-right: 8px;
1337
- }
1338
- }
1339
- }
1340
- .bot-message {
1341
- display: block;
1342
- text-decoration: underline;
1343
- color: #5585f5;
1344
- cursor: pointer;
1345
- }
1346
- .session-end {
1347
- display: flex;
1348
- justify-content: center;
1349
- margin-top: 15px;
1350
- margin-bottom: 25px;
1351
- .end {
1352
- display: flex;
1353
- justify-content: center;
1354
- width: 30%;
1355
- height: 36px;
1356
- line-height: 36px;
1357
- background-color: #e8e8e8;
1358
- color: #939393;
1359
- font-size: 14px;
1360
- border-radius: 18px;
1361
- }
1362
- }
1363
- .menu-tip {
1364
- font-size: 20px;
1365
- align-self: flex-end;
1366
- margin-bottom: 8px;
1367
- background: #f6f6f6;
1368
- height: 25px;
1369
- line-height: 25px;
1370
- width: 30px;
1371
- border-radius: 4px;
1372
- }
1373
- .menu-item {
1374
- :hover {
1375
- background: red;
1376
- }
1377
- }
1378
- .menu-main {
1379
- width: 100px;
1380
- background-color: #101627;
1381
- color: #fff;
1382
- text-align: left;
1383
- border-radius: 6px;
1384
- padding: 10px 0;
1385
- z-index: 3000;
1386
- cursor: pointer;
1387
- .menu-item {
1388
- padding: 0 10px;
1389
- }
1390
- .menu-item:hover {
1391
- background-color: #efefef;
1392
- color: #000;
1393
- }
1394
- }
1395
- .first-name {
1396
- width: 40px;
1397
- height: 40px;
1398
- line-height: 40px;
1399
- text-align: center;
1400
- background: #5585f5;
1401
- color: #fff;
1402
- border-radius: 100%;
1403
- font-size: 15px;
1404
- }
1405
- .msg-avatar {
1406
- width: 40px;
1407
- height: 40px;
1408
- border-radius: 50%;
1409
-
1410
- object-fit: cover;
1411
- background: #fff;
1412
- }
1413
- /deep/ .ant-spin-spinning {
1414
- display: flex;
1415
- align-items: center;
1416
- }
1417
- .system-msg {
1418
- margin: 10px 0;
1419
- text-align: left;
1420
- line-height: 20px;
1421
- word-wrap: break-word;
1422
- display: flex;
1423
- justify-content: center;
1424
- .system-icon {
1425
- font-size: 18px;
1426
- color: #ffc200;
1427
- vertical-align: middle;
1428
- margin-right: 10px;
1429
- margin-top: 1px;
1430
- }
1431
- .system-btn {
1432
- color: @primary-color;
1433
- margin-left: 8px;
1434
- cursor: pointer;
1435
- text-decoration: underline;
1436
- }
1437
- }
1438
- }
1439
- /deep/ p {
1440
- margin-bottom: 0;
1441
- }
1442
- </style>
1
+ <template>
2
+ <div class="message-wrapper">
3
+ <chat-header :hideHeader="hideHeader" @openPortraitPanel="handleOpenPortraitPanel" v-if="isServer && enable"></chat-header>
4
+ <a-layout-content>
5
+ <slot></slot>
6
+ <div v-if="showBroadcast" class="broadcast-wrap">
7
+ <div v-if="broadcastCarousel" class="carousel-item" :class="{ 'has-link': assemblySetting.broadcast.PC.list[0].url }" @click="goToBroadcastLink(assemblySetting.broadcast.PC.list[0])">
8
+ <a-icon type="sound" />
9
+ <span class="ellips">
10
+ {{ assemblySetting.broadcast.PC.list[0].content }}
11
+ </span>
12
+ </div>
13
+ <template v-else>
14
+ <a-carousel dotPosition="right" autoplay :dots="false">
15
+ <div class="carousel-item" v-for="(item, i) in assemblySetting.broadcast.PC.list" :key="i" :class="{ 'has-link': item.url }" @click="goToBroadcastLink(item)">
16
+ <a-icon type="sound" />
17
+ <span class="ellips">{{ item.content }}</span>
18
+ </div>
19
+ </a-carousel>
20
+ </template>
21
+ </div>
22
+ <div v-if="sessionHistoryList.length > 1 && !(!onChating && currentTab === 'end') && !sessionEnd" style="position: absolute; top: 0; left: 20px; z-index: 1">
23
+ <a-radio-group :value="selectedSession" @change="handleSessionIdChange" buttonStyle="solid">
24
+ <a-radio-button :value="item.id + '-' + item.fromId" v-for="item in sessionHistoryList" :key="item.id + item.fromId">{{ item.fromName }}</a-radio-button>
25
+ </a-radio-group>
26
+ </div>
27
+ <div class="online-message" ref="message-wrapper" v-infinite-scroll="handleInfiniteOnLoad" @scroll="scrollEvent">
28
+ <template v-for="(item, index) in msgList">
29
+ <div :key="index" v-if="item">
30
+ <p v-if="isNeedShowTime(item, index)" class="message-time">
31
+ {{ formatDate(item.createdTime) }}
32
+ </p>
33
+ <div v-if="item.recallFlag" style="margin: 10px 0">
34
+ <template v-if="handleRecallFlag(item)">
35
+ {{ getRecallText(item, isServer) }}
36
+ <a style="text-decoration: underline" @click="reEditMessage(item)" v-if="[0, 4].includes(item.content && item.content.type) && onChating && isServer">,{{ i18nText('1.9.368') }}</a>
37
+ </template>
38
+ <template v-else>
39
+ {{ getRecallText(item) || `${item.fromName} ${i18nText('1.9.365')}` }}
40
+ </template>
41
+ </div>
42
+ <!-- 系统消息 -->
43
+ <div class="system-msg" v-else-if="isSystemMsg(item)">
44
+ <a-icon class="system-icon" theme="filled" type="exclamation-circle" />
45
+ <div>
46
+ <span v-html="getSystemMsgContent(item)"></span>
47
+ <span class="system-btn" v-for="(btn, index) in getTemplateButton(item)" @click="handleTemplateButton(btn)" :key="index">{{ btn.title }}</span>
48
+ </div>
49
+ </div>
50
+ <div
51
+ v-else-if="!item.recallFlag"
52
+ class="message-item"
53
+ :class="[getMessageItemClass(item), { 'read-status': enableReadRecord && item.readStatus }]"
54
+ :data-rid="item.readStatus === 'N' ? item.id : ''"
55
+ >
56
+ <img v-if="!isServer && item.fromPortrait" class="msg-avatar" :src="item.fromPortrait" />
57
+
58
+ <div v-else-if="!isServer && item.fromName" class="first-name">
59
+ {{ item.fromName && item.fromName.slice(0, 2) }}
60
+ </div>
61
+ <img v-else-if="!isServer" class="msg-avatar" :src="getAvatar(item)" width="40" height="40" />
62
+
63
+ <template v-else>
64
+ <img :src="customerStaffIcon" class="msg-avatar" width="40" height="40" v-if="item.fromId === 'SYSTEM'" />
65
+
66
+ <img src="../img/system_message.png" class="msg-avatar" width="40" height="40" v-else-if="item.content && item.content.source === 1" />
67
+
68
+ <img v-else-if="item.portrait" class="msg-avatar" :src="item.portrait" />
69
+
70
+ <div v-else class="first-name">
71
+ {{ item.fromName && item.fromName.slice(0, 2) }}
72
+ </div>
73
+ </template>
74
+ <div @contextmenu="handleContextmenu($event, item)" style="display: flex">
75
+ <a-spin v-if="item.sending">
76
+ <a-icon slot="indicator" type="loading" style="font-size: 24px" spin />
77
+ </a-spin>
78
+ <a-popconfirm @confirm="handleSendFail(item)" :okText="i18nText('1.1.1.1.3')" :cancelText="i18nText('2.7.1.14')">
79
+ <a-icon type="exclamation-circle" slot="icon" />
80
+ <div slot="title">
81
+ <span>确认重新发送该消息?</span>
82
+ </div>
83
+ <a-icon v-if="item.fail" theme="filled" type="exclamation-circle" style="font-size: 16px; display: flex; align-items: center; color: red" />
84
+ </a-popconfirm>
85
+ <div class="content-wrap" v-if="item.content.type === 0">
86
+ <span class="right-time">
87
+ {{ formatDate(item.createdTime || item.sendTime, true) }}
88
+ </span>
89
+ <div
90
+ :class="{
91
+ content: true,
92
+ 'has-dictionary': item.dictionaryValues && item.dictionaryValues.length,
93
+ 'has-intention': item.intentionList && item.intentionList.length
94
+ }"
95
+ >
96
+ <p v-html="getContentHtml(item)"></p>
97
+ <template v-if="item.content.attachments && item.content.attachments.length > 0">
98
+ <div v-for="(v, index) in item.content.attachments" :key="index" class="robot-item">
99
+ <a v-if="v.type == 1" :href="v.url" target="_blank"> {{ v.desc }}(超链) </a>
100
+ <a @click.prevent.stop="$emit('sendQuestion', v, item)" v-if="v.type == 2 || v.type == 3" href="javascript:void(0);">
101
+ {{ v.desc }}
102
+ </a>
103
+ </div>
104
+ </template>
105
+ <div v-if="item.intentionList && item.intentionList.length" class="intention-wrap">
106
+ <div v-for="(v, index) in item.intentionList" :key="index" @click.prevent.stop="$emit('sendIntention', v)">
107
+ <svg-icon :icon-class="v.icon || 'moren'" style="font-size: 26px"></svg-icon>
108
+ <span>{{ v.name }}</span>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ <ul class="dictionary-ul" v-if="item.dictionaryValues && item.dictionaryValues.length">
113
+ <li v-for="(v, i) in item.dictionaryValues" :key="i" @click.prevent.stop="$emit('sendDictionary', v, item)">
114
+ {{ v }}
115
+ </li>
116
+ </ul>
117
+ <div class="client-btn" v-if="item.autoAccess && item.autoAccess === 'false'">
118
+ <svg-icon icon-class="kefu"></svg-icon>
119
+ <span @click="$emit('goCustomServe')">转人工客服</span>
120
+ </div>
121
+ </div>
122
+ <div v-else-if="item.content.type === 1" class="upload-image">
123
+ <MsgPicture style="max-width: 345px" :image="item.content.content" @click="show(item)" />
124
+ </div>
125
+ <div class="content-wrap" v-else-if="item.content.type === 2">
126
+ <span class="right-time">
127
+ {{ formatDate(item.createdTime || item.sendTime, true) }}
128
+ </span>
129
+ <div class="content">
130
+ <img style="width: 16px;margin-right:8px" src="../img/multi-video.png" />
131
+ {{ item.content.content }}&nbsp;
132
+ <span @click.prevent.stop="reCall(item, 'video')" class="re-call" v-if="item.content.isRefuse == 1">
133
+ {{ handleReCall(item) }}
134
+ </span>
135
+ </div>
136
+ </div>
137
+ <div class="content-wrap" v-else-if="item.content.type === 5">
138
+ <span class="right-time">
139
+ {{ formatDate(item.createdTime || item.sendTime, true) }}
140
+ </span>
141
+ <div class="content">
142
+ <img style="width: 16px;margin-right:8px" src="../img/multi-voice.png" />
143
+ {{ item.content.content }}&nbsp;
144
+ <span @click.prevent.stop="reCall(item, 'voice')" class="re-call" v-if="item.content.isRefuse == 1">
145
+ {{ handleReCall(item) }}
146
+ </span>
147
+ </div>
148
+ </div>
149
+ <div class="content-wrap" v-else-if="item.content.type === 6">
150
+ <span class="right-time">
151
+ {{ formatDate(item.createdTime || item.sendTime, true) }}
152
+ </span>
153
+ <div class="voice-bg content" @click.prevent.stop="playAudio(item)">
154
+ <img v-if="item.content.isPlay" src="../img/audio-play.gif" alt="" />
155
+ <img v-else src="../img/audio-new.png" alt="" />
156
+ <span class="voice-text" :style="AudioStyle(item)"> {{ item.content.duration || 1 }}" </span>
157
+ </div>
158
+ </div>
159
+ <template v-else-if="item.content.type === 4">
160
+ <msg-describe v-if="isDescribeMsg(item)" :item="item" />
161
+ <div v-else class="content-wrap">
162
+ <span class="right-time">
163
+ {{ formatDate(item.createdTime || item.sendTime, true) }}
164
+ </span>
165
+ <MsgPrescription :data="item" :isServer="isServer" :theme="isServer ? '' : 'customer'" @handleTemplateDetail="handleTemplateDetail" @handleTemplateButton="handleTemplateButton" />
166
+ </div>
167
+ </template>
168
+ </div>
169
+ <ReadStatus v-if="enableReadRecord" :status="item.readStatus" @click="openReadRecord($event, item)" />
170
+ </div>
171
+ </div>
172
+ </template>
173
+ <ul class="menu-main" ref="contextMenu" :style="contextMenuStyle" v-if="contextMenuShow">
174
+ <template v-for="(item, index) in rightClickSetting">
175
+ <li :key="index" class="menu-item" @click="() => handleRightClick(contextMenuItem, item)">
176
+ {{ item.rightClickName }}
177
+ </li>
178
+ </template>
179
+ </ul>
180
+ <div class="session-end" v-if="sessionEnd && !isServer">
181
+ <span class="end">{{ i18nText('1.9.370') }}</span>
182
+ </div>
183
+ <a-spin v-if="loading" class="loading-icon" />
184
+ </div>
185
+ <!-- 图片预览 -->
186
+ <viewer class="viewer" ref="viewer" :images="images" @inited="inited" :options="options" style="display: none">
187
+ <template slot-scope="scope">
188
+ <img v-for="src in scope.images" :src="src" :key="src" />
189
+ </template>
190
+ </viewer>
191
+ <!-- 卡片详情 -->
192
+ <a-modal
193
+ wrapClassName="chat-footer-modal-small"
194
+ :title="modalData.title || i18nText('1.1.1.10')"
195
+ :visible="modalShow"
196
+ :maskClosable="false"
197
+ :mask="true"
198
+ width="80%"
199
+ destroyOnClose
200
+ :okText="i18nText('1.2.1.11.6')"
201
+ :footer="null"
202
+ @cancel="
203
+ () => {
204
+ this.modalShow = false;
205
+ }
206
+ "
207
+ >
208
+ <iframe id="chat-footer-modal" v-if="modalData.targetType === 'LINK_ADDRESS'" width="100%" height="100%" frameborder="0" :src="modalData.address" allow="camera;midi"></iframe>
209
+ </a-modal>
210
+ </a-layout-content>
211
+ <audio style="display: none" controls autoplay ref="audio" preload="auto" crossOrigin="anonymous" media-player="audioPlayer" :src="curAudioUrl" @ended="audioEnd"></audio>
212
+ <ReadRecord v-if="readRecordVisible" :style="readRecordStyle" :list="readRecordList" @close="closeReadRecord" />
213
+ </div>
214
+ </template>
215
+
216
+ <script>
217
+ import { Layout, Modal, Icon, Spin, Popconfirm, Carousel, Radio } from 'ant-design-vue';
218
+ import SvgIcon from '@/component/svg/index.vue';
219
+ import InfiniteScroll from '@/directive/scroll';
220
+ import { mapGetters, mapMutations, mapActions } from '../store/helper';
221
+ import fetch, { qs } from '@/utils/chatFetch';
222
+ import MsgDescribe from '../components/msg-describe';
223
+ import MsgPicture from '../components/msg-picture';
224
+ import MsgPrescription from '../components/msg-prescription';
225
+ import ReadStatus from '../components/read-status';
226
+ import ReadRecord from '../components/read-record';
227
+ import chatHeader from './chatHeader';
228
+ import viewerOptions from './mixins/viewerOptions';
229
+ import { getRecallText } from '../utils';
230
+ import vexutils from '@/utils/vexutils';
231
+ import ObserverScroll from '../utils/observer-scroll';
232
+
233
+ const customerStaffIcon = require('../img/customer_staff.png');
234
+ export default {
235
+ mixins: [viewerOptions],
236
+ inject: ['store', 'dispatchEvent', 'registerEvent', 'unregisterEvent', 'i18nText'],
237
+ props: {
238
+ hideHeader: {
239
+ type: Boolean,
240
+ default: false
241
+ },
242
+ robotAvatar: {
243
+ type: String,
244
+ default: ''
245
+ },
246
+ curChatType: {
247
+ type: String
248
+ },
249
+ isShowPortraitPanel: {
250
+ type: Boolean
251
+ },
252
+ activatedTime: {
253
+ type: Number
254
+ }
255
+ },
256
+ data() {
257
+ return {
258
+ loading: false,
259
+ // 卡片详情
260
+ modalShow: false,
261
+ modalData: {},
262
+ // 客户头像
263
+ // 右键操作
264
+ contextMenuStyle: {
265
+ position: 'fixed',
266
+ top: 0,
267
+ left: 0
268
+ },
269
+ contextMenuShow: false,
270
+ contextMenuItem: null,
271
+ // 查看历史消息滚动定位
272
+ scrollHeight: 0,
273
+ curAudioUrl: '',
274
+ lastAudioItem: null,
275
+ readRecordStyle: '',
276
+ readRecordVisible: false,
277
+ readRecordList: []
278
+ };
279
+ },
280
+ computed: {
281
+ ...mapGetters([
282
+ 'userInfo',
283
+ 'currentTab',
284
+ 'isAppendMsg',
285
+ 'message',
286
+ 'msgList',
287
+ 'sessionId',
288
+ 'serviceId',
289
+ 'scrollTo',
290
+ 'isServer',
291
+ 'clientId',
292
+ 'sessionEnd',
293
+ 'assemblyId',
294
+ 'footerMessage',
295
+ 'portraitPanelParams',
296
+ 'assemblySetting',
297
+ 'clientParams',
298
+ 'onChating',
299
+ 'classify',
300
+ 'collapsed',
301
+ 'barStatus',
302
+ 'sessionHistoryList',
303
+ 'enable',
304
+ 'appendList',
305
+ 'queueItem',
306
+ 'isRecorderVoice'
307
+ ]),
308
+ orgId() {
309
+ const getters = this.store.getters;
310
+ return this.isServer ? this.userInfo?.sysParams?.orgId : getters.accessParams.orgId || getters.queryParams.orgId;
311
+ },
312
+ userId() {
313
+ const getters = this.store.getters;
314
+ return this.isServer ? this.userInfo?.sysParams?.userId : getters.accessParams.userId || getters.chatUserId || getters.queryParams.userId;
315
+ },
316
+ enableReadRecord() {
317
+ return this.assemblySetting?.readStatus === 'Y';
318
+ },
319
+ customerStaffIcon() {
320
+ return this.robotAvatar || customerStaffIcon;
321
+ },
322
+ selectedSession() {
323
+ let sessionMap = this.sessionHistoryList.find(item => item.fromId === this.serviceId);
324
+ if (sessionMap) {
325
+ return sessionMap.id + '-' + sessionMap.fromId;
326
+ }
327
+ return '';
328
+ },
329
+ isListClassify() {
330
+ return this.assemblySetting.isListClassify === 'Y';
331
+ },
332
+ showPanel() {
333
+ return this.assemblySetting.portraitPanelSetting?.targetIs;
334
+ },
335
+ showBroadcast() {
336
+ let res = (!this.isServer && this.assemblySetting?.broadcast?.PC?.isChecked == 'Y' && this.assemblySetting?.broadcast?.PC?.list?.length > 0) || false;
337
+ return res;
338
+ },
339
+ broadcastCarousel() {
340
+ return (this.assemblySetting.broadcast && this.assemblySetting.broadcast.PC.list.length == 1) || false;
341
+ },
342
+ rightClickSetting() {
343
+ const { isServer } = this;
344
+ if (!isServer) return [];
345
+ const isSelf = this.contextMenuItem.fromId === this.serviceId;
346
+ const setting = this.assemblySetting?.rightClickSetting || [];
347
+ const doArr = ['resend', 'rollBack'];
348
+ return setting.filter(item => {
349
+ const { rightClickDo } = item;
350
+ return isSelf || doArr.indexOf(rightClickDo) < 0;
351
+ });
352
+ },
353
+ handleReCall() {
354
+ return function(item) {
355
+ if (item.content?.source === 1) {
356
+ return '[点击回拨]';
357
+ } else if (item.senderFlag == 1) {
358
+ return `[点击${this.isServer ? '回拨' : '重拨'}]`;
359
+ }
360
+ if (item.senderFlag == 2) {
361
+ return `[点击${this.isServer ? '重拨' : '回拨'}]`;
362
+ }
363
+ if (this.isServer) {
364
+ let isRight = item.fromId !== 'SYSTEM' && item.fromId && item.fromId === this.serviceId;
365
+ return `[点击${isRight ? '重拨' : '回拨'}]`;
366
+ } else {
367
+ let isRight = (item.fromId !== 'SYSTEM' && item.toId === 'SYSTEM') || item.fromId === this.clientId || (item.mode === 'bot' && !item.fromId);
368
+ return `[点击${isRight ? '重拨' : '回拨'}]`;
369
+ }
370
+ };
371
+ },
372
+ handleRecallFlag() {
373
+ return function(item) {
374
+ return this.serviceId == item.fromId;
375
+ };
376
+ },
377
+ AudioStyle() {
378
+ return function(item) {
379
+ let { duration = 1 } = item.content;
380
+ if (!duration) {
381
+ duration = 1;
382
+ }
383
+ let curWidth = (+duration / 60) * 400;
384
+ return {
385
+ width: curWidth < 13 ? 13 : curWidth + 'px'
386
+ };
387
+ };
388
+ },
389
+ showTimeDuration() {
390
+ let { variableSetting = null } = this.assemblySetting || {};
391
+ if (!variableSetting) return 3;
392
+ let matchItem = variableSetting.find(v => v.name === 'CHAT_SEPARATION_TIME');
393
+ if (!matchItem) return 3;
394
+ if (!+matchItem.value) return 3;
395
+ return +matchItem.value;
396
+ },
397
+ images() {
398
+ return this.msgList.filter(v => !v.recallFlag && v.content.type == 1)?.map(v => v.content?.content);
399
+ }
400
+ },
401
+ created() {
402
+ this.attachEvent();
403
+ },
404
+ methods: {
405
+ ...mapMutations([
406
+ 'setIsAppendMsg',
407
+ 'setMsgList',
408
+ 'setScrollTo',
409
+ 'setFooterMessage',
410
+ 'setIsScrollListChange',
411
+ 'setListChangeItem',
412
+ 'setSessionId',
413
+ 'setOnChating',
414
+ 'setServiceId',
415
+ 'setShowAudio',
416
+ 'setVideoMode',
417
+ 'setVideoMembers',
418
+ 'setIsRecorderVoice'
419
+ ]),
420
+ ...mapActions({
421
+ getEarlierMsg: 'setMsgList',
422
+ handleBotChat: 'handleBotChat',
423
+ sendMessage: 'sendMessage'
424
+ }),
425
+ getMessageItemClass(item) {
426
+ // content.source === 1, 代表为系统消息, 系统统一左侧展示
427
+ if (item.content?.source === 1) {
428
+ return {
429
+ left: true
430
+ };
431
+ }
432
+
433
+ // 服务端 senderFlag 1 左 2 右
434
+ // 客户端 senderFlag 1 右 2 左
435
+ if (item.content?.source === 1) {
436
+ return {
437
+ left: true
438
+ };
439
+ } else if (item.senderFlag == 1) {
440
+ if (this.isServer) {
441
+ return {
442
+ left: true
443
+ };
444
+ } else {
445
+ return {
446
+ right: true
447
+ };
448
+ }
449
+ }
450
+ if (item.senderFlag == 2) {
451
+ if (this.isServer) {
452
+ return {
453
+ right: true
454
+ };
455
+ } else {
456
+ return {
457
+ left: true
458
+ };
459
+ }
460
+ }
461
+ if (this.isServer) {
462
+ return {
463
+ right: item.fromId !== 'SYSTEM' && item.fromId && item.fromId === this.serviceId,
464
+ left: item.fromId === 'SYSTEM' || item.fromId === this.clientId || item.content?.source === 1 || !item.fromId
465
+ };
466
+ } else {
467
+ let isRight, isLeft;
468
+ if (this.curChatType == 'robot') {
469
+ isRight = item.fromId !== 'SYSTEM';
470
+ isLeft = item.fromId === 'SYSTEM';
471
+ } else {
472
+ isRight = (item.fromId !== 'SYSTEM' && item.toId === 'SYSTEM') || item.fromId === this.clientId || (item.mode === 'bot' && !item.fromId);
473
+ isLeft = item.fromId === 'SYSTEM' || item.fromId !== this.clientId || item.content?.source === 1;
474
+ }
475
+ return {
476
+ right: isRight,
477
+ left: isLeft
478
+ };
479
+ }
480
+ },
481
+ /* 向上滚动刷新 */
482
+ handleInfiniteOnLoad() {
483
+ if (this.curChatType === 'robot') return;
484
+ this.loading = true;
485
+ this.getEarlierMsg().then(msg => {
486
+ if (msg) {
487
+ this.$message.info(msg);
488
+ }
489
+ this.loading = false;
490
+ });
491
+ },
492
+ show(item) {
493
+ const src = item.content.content;
494
+ // this.images = vexutils.imgs2imgArr(src);
495
+ this.$viewer.view(this.images.findIndex(v => v === src));
496
+ this.$viewer.show();
497
+ this.readSingleMsg(item);
498
+ },
499
+ /* 滚动条定位 */
500
+ handleScrollTo(scrollTo) {
501
+ let target = this.$refs['message-wrapper'];
502
+ this.$nextTick().then(() => {
503
+ if (!target) return;
504
+ let top = target.scrollHeight;
505
+ if (scrollTo === 'current') {
506
+ top = target.scrollHeight - this.scrollHeight;
507
+ }
508
+ if (typeof scrollTo === 'number') {
509
+ top = scrollTo;
510
+ }
511
+ target.scrollTo({
512
+ left: 0,
513
+ top,
514
+ behavior: 'instant'
515
+ });
516
+ this.scrollHeight = 0;
517
+ });
518
+ this.setScrollTo('');
519
+ },
520
+
521
+ /**
522
+ * 是否需要显示时间
523
+ */
524
+ isNeedShowTime(item, index) {
525
+ const curMsgTime = item.createdTime || new Date().getTime();
526
+ let duration = 60 * 1000 * this.showTimeDuration;
527
+ let lastMsgTime;
528
+ if (index == 0) {
529
+ lastMsgTime = 0;
530
+ } else {
531
+ lastMsgTime = this.msgList[index - 1].createdTime;
532
+ }
533
+ if (Number(curMsgTime) - Number(lastMsgTime) > duration) {
534
+ return true;
535
+ } else {
536
+ return false;
537
+ }
538
+ },
539
+ formatDate(date) {
540
+ return vexutils.formatDate(date, true);
541
+ },
542
+ getAvatar(item) {
543
+ if (item.content && item.content.source === 1) {
544
+ return require('../img/system_message.png');
545
+ }
546
+ if (item.mode === 'bot' && !item.fromId) {
547
+ return require('../img/default.png');
548
+ }
549
+ if (this.isServer) {
550
+ if (item.fromId === this.clientId || !item.fromId) {
551
+ return require('../img/default.png');
552
+ } else {
553
+ return this.customerStaffIcon;
554
+ }
555
+ } else {
556
+ if (this.curChatType == 'robot') {
557
+ if (item.fromId === 'SYSTEM') {
558
+ return this.customerStaffIcon;
559
+ } else {
560
+ return require('../img/default.png');
561
+ }
562
+ } else {
563
+ if (item.fromId !== this.clientId) {
564
+ return this.customerStaffIcon;
565
+ } else {
566
+ return require('../img/default.png');
567
+ }
568
+ }
569
+ }
570
+ },
571
+ getContent(item) {
572
+ let content;
573
+ if (vexutils.isJSON(item.content.content)) {
574
+ content = JSON.parse(item.content.content);
575
+ } else {
576
+ content = item.content.content;
577
+ }
578
+ return content;
579
+ },
580
+ getContentHtml(item) {
581
+ return !~item.content.content.indexOf('emoji') ? this.$xss(item.content.content) : item.content.content;
582
+ },
583
+ getTemplateTitle(item) {
584
+ return this.getContent(item)?.title;
585
+ },
586
+ showArrow(item) {
587
+ let setting = this.getContent(item)?.customerSetting || {};
588
+ if (this.isServer) {
589
+ setting = this.getContent(item)?.serverSetting || {};
590
+ }
591
+ let { address } = setting;
592
+ if (!address) return false;
593
+ return true;
594
+ },
595
+ getTemplateTitleIcon(item) {
596
+ return this.getContent(item)?.icon;
597
+ },
598
+ getTemplateContent(item) {
599
+ let content = this.getContent(item);
600
+ let array = [];
601
+ try {
602
+ array = content.content.split('##');
603
+ } catch {
604
+ console.log(content, 'error');
605
+ }
606
+ array = array.map(item => `<div>${item}</div>`);
607
+ return array.join('');
608
+ },
609
+ getSystemMsgContent(item) {
610
+ let content = this.getContent(item);
611
+ let array = [];
612
+ try {
613
+ array = content.content.split('##');
614
+ } catch {
615
+ console.log(content, 'error');
616
+ }
617
+ return array.join('<br>');
618
+ },
619
+ getTemplateButton(item) {
620
+ let content = this.getContent(item);
621
+ const setting = this.isServer ? content.serverSetting : content.customerSetting;
622
+ return setting?.toolbar_button || [];
623
+ },
624
+ // 处理模板按钮,详情等跳转
625
+ handleTemplate(data, dispatch = true) {
626
+ let { targetType, address, params = [], openMode } = data;
627
+ dispatch &&
628
+ this.dispatchEvent('click_templateCard', {
629
+ ...data
630
+ });
631
+ if (!address) return;
632
+ if (targetType === 'LINK_ADDRESS') {
633
+ let urlParams = [];
634
+ params.forEach(({ p_name, p_value }) => {
635
+ urlParams.push(`${p_name}=${p_value}`);
636
+ });
637
+ if (address.includes('?')) {
638
+ address += `&${urlParams.join('&')}`;
639
+ } else {
640
+ address += `?${urlParams.join('&')}`;
641
+ }
642
+ if (openMode === 'WINDOW') {
643
+ window.open(address);
644
+ return;
645
+ }
646
+ if (openMode === 'EJECT') {
647
+ this.modalShow = true;
648
+ this.modalData = Object.assign({}, data, {
649
+ address
650
+ });
651
+ return;
652
+ }
653
+ }
654
+ },
655
+ handleTemplateDetail(item) {
656
+ let content = this.getContent(item) || {};
657
+ let setting = content.customerSetting || {};
658
+ if (this.isServer) {
659
+ setting = content.serverSetting || {};
660
+ }
661
+ this.readSingleMsg(item);
662
+ this.handleTemplate(setting);
663
+ },
664
+ handleTemplateButton(btn) {
665
+ this.handleTemplate(btn);
666
+ },
667
+ // 消息撤回
668
+ handleRecall(item) {
669
+ let params = {
670
+ assemblyId: this.assemblyId,
671
+ sessionId: this.sessionId,
672
+ messageId: item.id,
673
+ messageType: item.content?.type,
674
+ userId: this.userInfo?.sysParams?.userId || ''
675
+ };
676
+
677
+ fetch.post('/chat/service/recallMessage', qs.stringify(params)).then(({ data }) => {
678
+ if (data.result === 'SUCCESS') {
679
+ this.dispatchEvent('msg_recallSuccess', {
680
+ message: { ...item },
681
+ ...params
682
+ });
683
+ this.$set(item, 'recallFlag', 1);
684
+ // 撤回成功提示
685
+ let title = this.getContent(item)?.title;
686
+ let text = title ? `已撤回[${title}]` : '已撤回';
687
+ this.$message.success(text);
688
+
689
+ if (!this.isLastMessage(item.id)) return;
690
+ this.setIsScrollListChange(true);
691
+ this.setListChangeItem({
692
+ opt: 1,
693
+ from: this.clientId,
694
+ sessionId: this.sessionId,
695
+ msgCount: 0,
696
+ lastContentRecallFlag: 1,
697
+ lastContent: vexutils.clone(item.content, true),
698
+ lastTime: new Date().getTime()
699
+ });
700
+ } else {
701
+ this.$message.error(data.resultMsg);
702
+ }
703
+ });
704
+ },
705
+ handleJumpUrl(contextMenuItem, item) {
706
+ const title = item.rightClickName;
707
+ const url = item.rightClickUrl.replace(/{(.*?)}/g, (match, p) => {
708
+ return eval(p);
709
+ });
710
+ this.dispatchEvent('open_jumpUrl', {
711
+ title: title,
712
+ url: url
713
+ });
714
+ },
715
+ // 右键菜单功能
716
+ handleRightClick(contextMenuItem, item) {
717
+ if (item.rightClickDo === 'rollBack') {
718
+ this.handleRecall(contextMenuItem);
719
+ } else if (item.rightClickDo === 'jumpUrl') {
720
+ this.handleJumpUrl(contextMenuItem, item);
721
+ } else if (item.rightClickDo === 'resend') {
722
+ this.resendMessage(contextMenuItem);
723
+ }
724
+ },
725
+ resendMessage(item) {
726
+ fetch({
727
+ method: 'POST',
728
+ url: '/chat/service/resendMessage',
729
+ data: qs.stringify({
730
+ assemblyId: this.assemblyId,
731
+ sessionId: this.sessionId,
732
+ messageId: item.id
733
+ })
734
+ });
735
+ },
736
+ // 重新编辑
737
+ reEditMessage(item) {
738
+ if (item.content?.type === 4) {
739
+ let content = this.getContent(item);
740
+ this.handleTemplate(content.serverSetting.reEditSetting, false);
741
+ return;
742
+ }
743
+ this.setFooterMessage(this.footerMessage + item.content.content.slice(5, -6));
744
+ },
745
+ observeMsg() {
746
+ if (this.enableReadRecord) {
747
+ if (!this._observer) {
748
+ this._observer = new ObserverScroll(this.$refs['message-wrapper'], this.readMsg);
749
+ this.$on('hook:beforeDestroy', () => {
750
+ this._observer.remove();
751
+ this._observer = null;
752
+ });
753
+ }
754
+ this._observer.disconnect();
755
+ if (this.msgList.length) {
756
+ this.$nextTick(() => {
757
+ const el = this.$refs['message-wrapper'];
758
+ const els = el?.querySelectorAll('.message-item.left');
759
+ els && this._observer.observe(Array.from(els).filter(item => item.getAttribute('data-rid')));
760
+ });
761
+ }
762
+ }
763
+ },
764
+ readMsg(ids, enableVaid = true, notify = true, post = true) {
765
+ const msgList = this.msgList;
766
+ const idKeys = msgList.reduce((obj, item, i) => {
767
+ const id = item?.id;
768
+ if (id) obj[id] = i;
769
+ return obj;
770
+ }, {});
771
+ const data = [];
772
+ const validFn = (item, type) => {
773
+ /**
774
+ * 针对文本、表情消息类型,只要在聊天区域内,视为已读,
775
+ * 图片、语音类型消息,需要点击查看后,才视为已读,
776
+ * 模板 类型消息,如果没有详情链接,只要在聊天区域内,视为已读,若有详情链接,需要点击查看后,才视为已读
777
+ */
778
+ const jumpType = `,6,1,`;
779
+ if (jumpType.includes(type)) return false;
780
+ if (type == 4 && !this.isDescribeMsg(item)) {
781
+ let content = this.getContent(item) || {};
782
+ let setting = (this.isServer ? content.serverSetting : content.customerSetting) || {};
783
+ return !setting?.address;
784
+ }
785
+ return true;
786
+ };
787
+ const value = ids.filter(id => {
788
+ const i = idKeys[id];
789
+ let item = msgList[i];
790
+ if (item) {
791
+ const type = item.content.type;
792
+ if (!enableVaid || validFn(item, type)) {
793
+ item.readStatus = 'Y';
794
+ data.push({ id, type });
795
+ return true;
796
+ }
797
+ return false;
798
+ }
799
+ });
800
+ if (!value.length) return;
801
+ notify &&
802
+ this.dispatchEvent('msg_readed', {
803
+ data,
804
+ assemblyId: this.assemblyId,
805
+ sessionId: this.sessionId
806
+ });
807
+ post && this.postReadMessage({ ids: value.join(',') });
808
+ },
809
+ postReadMessage(data) {
810
+ fetch.post(
811
+ `/chat/${this.isServer ? 'service' : 'access'}/readMessage`,
812
+ qs.stringify({
813
+ assemblyId: this.assemblyId,
814
+ orgId: this.orgId,
815
+ userId: this.userId,
816
+ sessionId: this.sessionId,
817
+ ...data
818
+ })
819
+ );
820
+ },
821
+ readSingleMsg(item) {
822
+ if (this.enableReadRecord && item.readStatus === 'N') {
823
+ const cls = this.getMessageItemClass(item);
824
+ if (!cls?.left) return;
825
+ this.readMsg([item.id], false);
826
+ }
827
+ },
828
+ closeReadRecord() {
829
+ this.readRecordVisible = false;
830
+ this.readRecordList = [];
831
+ },
832
+ openReadRecord(event, item) {
833
+ const readStatus = item.readStatus;
834
+ if (readStatus) {
835
+ const cls = this.getMessageItemClass(item);
836
+ if (!cls.right) return;
837
+ const rect = event.target.getBoundingClientRect();
838
+ const w = 440;
839
+ const h = 340;
840
+ const top = Math.max(0, Math.min(document.body.clientHeight - h, rect.top - h / 2));
841
+ const left = Math.max(0, Math.min(document.body.clientWidth - w, rect.left - w));
842
+ fetch({
843
+ url: `/chat/${this.isServer ? 'service' : 'access'}/getMessageMember`,
844
+ method: 'get',
845
+ params: {
846
+ assemblyId: this.assemblyId,
847
+ messageId: item.id,
848
+ orgId: this.isServer ? undefined : this.orgId
849
+ }
850
+ }).then(res => {
851
+ const list = res.data?.list || [];
852
+ this.readRecordStyle = `top:${top}px;left:${left}px;position:fixed;z-index:10`;
853
+ this.readRecordVisible = list.length > 0;
854
+ this.readRecordList = Object.freeze(list);
855
+ if (item.readStatus && list.length) {
856
+ const unread = list.filter(item => item.readStatus == 'N').length;
857
+ const single = list.length < 2;
858
+ const status = unread > 0 ? (single ? 'N' : `${unread}`) : single ? 'Y' : 'ALL';
859
+ // 检查是否更新人数
860
+ if (item.readStatus != status) {
861
+ item.readStatus = status;
862
+ }
863
+ }
864
+ });
865
+ }
866
+ },
867
+ isLastMessage(id) {
868
+ return this.msgList.findIndex(msg => msg.id === id) === this.msgList.length - 1;
869
+ },
870
+ isSystemMsg(item) {
871
+ return item.content.type == 4 && this.getContent(item).styleId == '2';
872
+ },
873
+ isDescribeMsg(item) {
874
+ return this.getContent(item).styleId == '3';
875
+ },
876
+ async handleOpenPortraitPanel(item) {
877
+ if (!this.showPanel || item.fromId === this.serviceId || !this.isServer || !this.isShowPortraitPanel) return;
878
+ const { portraitPanelParams, clientParams } = this;
879
+ const panelSetting = this.assemblySetting?.portraitPanelSetting;
880
+ this.dispatchEvent('open_portraitPanel', {
881
+ panelSetting,
882
+ clientParams,
883
+ panelParams: portraitPanelParams,
884
+ targetId: panelSetting?.targetId,
885
+ targetType: panelSetting?.targetType
886
+ });
887
+ },
888
+ handleContextmenu(e, item) {
889
+ // 系统消息,客户消息,待接入消息,历史消息不允许撤回
890
+ // 模板-描述消息禁用右键
891
+ if (item.content?.source === 1 || !this.sessionId || (this.sessionId && !this.onChating) || (item.content.type === 4 && this.isDescribeMsg(item))) return;
892
+ this.contextMenuItem = item;
893
+ if (this.rightClickSetting.length < 1) return;
894
+ e.preventDefault();
895
+ let left = e.pageX + 'px';
896
+ let top = e.pageY + 'px';
897
+ this.contextMenuStyle = Object.assign(this.contextMenuStyle, {
898
+ top,
899
+ left
900
+ });
901
+ this.contextMenuShow = true;
902
+ },
903
+ scrollEvent(e) {
904
+ console.log('e.target.scrollTop->', e.target.scrollTop);
905
+ this._scrollTop = e.target.scrollTop;
906
+ },
907
+ /* 事件绑定 */
908
+ attachEvent() {
909
+ this.scrollEvent = vexutils.debounce(this.scrollEvent, 800);
910
+ const handleClick = () => {
911
+ this.contextMenuShow = false;
912
+ };
913
+ const handleRasize = () => {
914
+ if (this.readRecordVisible) {
915
+ let style = this.readRecordStyle;
916
+ const top = style.match(topReg)?.[1];
917
+ const topReg = /top:([\d.]+)/;
918
+ const maxH = document.body.clientHeight - 360;
919
+ if (top && maxH < top) {
920
+ style = style.replace(topReg, `top:${maxH}`);
921
+ }
922
+ const leftReg = /left:([\d.]+)/;
923
+ const left = style.match(leftReg)?.[1];
924
+ const maxW = document.body.clientWidth - 440;
925
+ if (left && maxW < left) {
926
+ style = style.replace(leftReg, `left:${maxW}`);
927
+ }
928
+ this.readRecordStyle = style;
929
+ }
930
+ };
931
+ window.addEventListener('resize', handleRasize);
932
+ document.addEventListener('click', handleClick);
933
+ this.registerEvent('openPortraitPanel', this.handleOpenPortraitPanel);
934
+ const readMessage = data => {
935
+ this.readMsg(data.ids.split(','), false, false, false);
936
+ this.postReadMessage(data);
937
+ };
938
+ this.registerEvent('readMessage', readMessage);
939
+ this.$on('hook:beforeDestroy', () => {
940
+ window.removeEventListener('resize', handleRasize);
941
+ document.removeEventListener('click', handleClick);
942
+ this.unregisterEvent('openPortraitPanel', this.handleOpenPortraitPanel);
943
+ this.unregisterEvent('readMessage', readMessage);
944
+ });
945
+ },
946
+ goToBroadcastLink(item) {
947
+ if (!item.url) return;
948
+ window.open(item.url);
949
+ },
950
+ /**
951
+ * 客服切换
952
+ */
953
+ handleSessionIdChange(e) {
954
+ let [sessionId, serviceId] = e.target.value.split('-');
955
+ this.setSessionId(sessionId);
956
+ this.setServiceId(serviceId);
957
+ let isOnChating = this.sessionHistoryList.find(item => item.fromId === serviceId).onChating;
958
+ this.setOnChating(!!isOnChating);
959
+ this.setMsgList([]);
960
+ this.getEarlierMsg();
961
+ },
962
+ handleSendFail(item) {
963
+ this.sendMessage(Object.assign(item.content, { failItem: item }));
964
+ },
965
+ reCall(type) {
966
+ this.setShowAudio(true);
967
+ this.setVideoMode(type === 'voice' ? 1 : 2);
968
+ this.$nextTick(() => {
969
+ this.setVideoMembers([]);
970
+ });
971
+ },
972
+ playAudio(item) {
973
+ let { content = '' } = item?.content || {};
974
+ if (!content) return;
975
+ if (this.lastAudioItem && (item.id !== this.lastAudioItem.id || item.createdTime !== this.lastAudioItem.createdTime)) {
976
+ this.$set(this.lastAudioItem.content, 'isPlay', false);
977
+ }
978
+
979
+ this.readSingleMsg(item);
980
+ this.lastAudioItem = item;
981
+ this.$set(item.content, 'isPlay', !item.content.isPlay);
982
+ this.$nextTick(() => {
983
+ this.curAudioUrl = content;
984
+ let audioRef = this.$refs['audio'];
985
+ if (!audioRef) return;
986
+ audioRef.load();
987
+ setTimeout(() => {
988
+ if (item.content.isPlay) {
989
+ let playPromise = audioRef.play();
990
+ if (playPromise !== undefined) {
991
+ playPromise.then(() => {
992
+ audioRef.play();
993
+ });
994
+ }
995
+ } else {
996
+ audioRef.pause();
997
+ this.curAudioUrl = '';
998
+ }
999
+ });
1000
+ });
1001
+ },
1002
+ audioEnd() {
1003
+ if (!this.lastAudioItem) return;
1004
+ this.$set(this.lastAudioItem.content, 'isPlay', false);
1005
+ },
1006
+ getRecallText(item, flag = false) {
1007
+ return getRecallText(this, item, flag);
1008
+ }
1009
+ },
1010
+ directives: {
1011
+ InfiniteScroll
1012
+ },
1013
+ components: {
1014
+ AModal: Modal,
1015
+ [Layout.Content.name]: Layout.Content,
1016
+ [Spin.name]: Spin,
1017
+ [Icon.name]: Icon,
1018
+ [Popconfirm.name]: Popconfirm,
1019
+ [Radio.Button.name]: Radio.Button,
1020
+ [Radio.Group.name]: Radio.Group,
1021
+ [Carousel.name]: Carousel,
1022
+ SvgIcon,
1023
+ MsgPrescription,
1024
+ ReadStatus,
1025
+ ReadRecord,
1026
+ MsgPicture,
1027
+ MsgDescribe,
1028
+ chatHeader
1029
+ },
1030
+ watch: {
1031
+ msgList() {
1032
+ this.observeMsg();
1033
+ },
1034
+ isAppendMsg: {
1035
+ immediate: true,
1036
+ handler(isAppendMsg) {
1037
+ if (isAppendMsg) {
1038
+ let newArr = [];
1039
+ if (vexutils.isPlainObject(this.message)) {
1040
+ newArr = [...this.msgList, this.message];
1041
+ } else if (vexutils.isArray(this.message)) {
1042
+ newArr = [...this.msgList, ...this.message];
1043
+ }
1044
+ this.setMsgList(newArr);
1045
+ this.setIsAppendMsg(false);
1046
+ this.setScrollTo('bottom');
1047
+ }
1048
+ }
1049
+ },
1050
+ scrollTo: {
1051
+ immediate: true,
1052
+ handler(scrollTo) {
1053
+ if (scrollTo) {
1054
+ this.handleScrollTo(scrollTo);
1055
+ }
1056
+ }
1057
+ },
1058
+ activatedTime: {
1059
+ immediate: true,
1060
+ handler(value) {
1061
+ this.handleScrollTo(this._scrollTop);
1062
+ }
1063
+ },
1064
+ /**
1065
+ * 图片懒加载处理
1066
+ */
1067
+ appendList: {
1068
+ handler() {
1069
+ if (!this.scrollHeight) {
1070
+ let target = this.$refs['message-wrapper'];
1071
+ this.scrollHeight = target.scrollHeight;
1072
+ }
1073
+ if (this.appendList.length === this.msgList.length || this.appendList.length === 1) {
1074
+ this.setScrollTo('bottom');
1075
+ } else {
1076
+ this.setScrollTo('current');
1077
+ }
1078
+ }
1079
+ },
1080
+ isRecorderVoice: {
1081
+ immediate: true,
1082
+ handler(val) {
1083
+ if (!val) return;
1084
+ this.curAudioUrl = '';
1085
+ this.setIsRecorderVoice(false);
1086
+ if (!this.lastAudioItem) return;
1087
+ this.$set(this.lastAudioItem.content, 'isPlay', false);
1088
+ }
1089
+ }
1090
+ }
1091
+ };
1092
+ </script>
1093
+
1094
+ <style lang="less" scoped>
1095
+ @import '../style/emoji.css';
1096
+ @import '../style/message.mixin.less';
1097
+ .message-wrapper {
1098
+ .createMessageStyle(#ebebeb, @primary-color);
1099
+ flex: 1;
1100
+ height: 0;
1101
+ // position: relative;
1102
+ display: flex;
1103
+ flex-direction: column;
1104
+ overflow-x: hidden;
1105
+ .broadcast-wrap {
1106
+ height: 30px;
1107
+ text-align: center;
1108
+ font-size: 14px;
1109
+ background-color: #fffbe8;
1110
+ /deep/ .carousel-item {
1111
+ display: inline-flex !important;
1112
+ justify-content: center;
1113
+ align-items: center;
1114
+ width: 100%;
1115
+ height: 30px;
1116
+ text-align: center;
1117
+ &.has-link {
1118
+ color: #ed6a0c;
1119
+ cursor: pointer;
1120
+ }
1121
+ span {
1122
+ display: inline-block;
1123
+ max-width: calc(100% - 30px);
1124
+ margin-left: 4px;
1125
+ }
1126
+ }
1127
+ }
1128
+
1129
+ .loading-icon {
1130
+ position: absolute;
1131
+ top: 0;
1132
+ left: 50%;
1133
+ }
1134
+ }
1135
+ /deep/ .ant-layout-content {
1136
+ flex: 1;
1137
+ display: flex;
1138
+ flex-direction: column;
1139
+ position: relative;
1140
+ }
1141
+ .online-message {
1142
+ flex: 1;
1143
+ height: 100%;
1144
+ // height: 608px;
1145
+ overflow-y: auto;
1146
+ overflow-x: hidden;
1147
+ padding: 10px 22px;
1148
+ // margin: 10px 0;
1149
+ text-align: center;
1150
+ &::-webkit-scrollbar {
1151
+ width: 5px;
1152
+ }
1153
+ .message-time {
1154
+ display: inline-block;
1155
+ color: #666;
1156
+ font-size: 14px;
1157
+ border-radius: 4px;
1158
+ padding: 4px;
1159
+ margin: 0 auto;
1160
+ margin-bottom: 16px;
1161
+ }
1162
+ > div {
1163
+ margin-bottom: 16px;
1164
+ }
1165
+ .message-item {
1166
+ display: flex;
1167
+ /deep/ .chat-read-status-text {
1168
+ display: none;
1169
+ }
1170
+ &.right.read-status {
1171
+ padding-bottom: 24px;
1172
+ position: relative;
1173
+ /deep/ .chat-read-status-text {
1174
+ display: block;
1175
+ position: absolute;
1176
+ right: 50px;
1177
+ bottom: 0;
1178
+ }
1179
+ }
1180
+ .right-time {
1181
+ display: none;
1182
+ position: absolute;
1183
+ top: -16px;
1184
+ left: 10px;
1185
+ font-size: 12px;
1186
+ color: #b0b1b1;
1187
+ white-space: nowrap;
1188
+ }
1189
+
1190
+ .content-wrap {
1191
+ padding: 0 10px;
1192
+ text-align: left;
1193
+ position: relative;
1194
+ &:hover {
1195
+ .right-time {
1196
+ display: block;
1197
+ }
1198
+ }
1199
+
1200
+ .robot-item {
1201
+ text-align: left;
1202
+ a {
1203
+ text-decoration: underline;
1204
+ }
1205
+ }
1206
+ .intention-wrap {
1207
+ display: flex;
1208
+ flex-wrap: wrap;
1209
+ padding: 8px 0 4px 0;
1210
+ background-color: #fff;
1211
+ border-radius: 0 0 8px 8px;
1212
+ > div {
1213
+ display: inline-flex;
1214
+ flex-direction: column;
1215
+ align-items: center;
1216
+ width: 60px;
1217
+ height: 54px;
1218
+ cursor: pointer;
1219
+
1220
+ &:hover {
1221
+ color: #5585f5;
1222
+ span {
1223
+ color: #5585f5;
1224
+ }
1225
+ }
1226
+ }
1227
+ span {
1228
+ margin-top: 8px;
1229
+ max-width: 90%;
1230
+ text-overflow: ellipsis;
1231
+ overflow: hidden;
1232
+ white-space: nowrap;
1233
+ font-size: 12px;
1234
+ color: #6a6a6a;
1235
+ }
1236
+ }
1237
+ .dictionary-ul {
1238
+ padding-top: 8px;
1239
+ display: flex;
1240
+ flex-wrap: wrap;
1241
+ li {
1242
+ padding: 4px 16px;
1243
+ margin-right: 16px;
1244
+ font-size: 14px;
1245
+ color: #5585f5;
1246
+ background: #efefef;
1247
+ border-radius: 16px;
1248
+ cursor: pointer;
1249
+ }
1250
+ }
1251
+ .client-btn {
1252
+ display: inline-block;
1253
+ padding: 4px 8px;
1254
+ margin-top: 8px;
1255
+ color: #fff;
1256
+ font-size: 12px;
1257
+ border-radius: 20px;
1258
+ background: #5585f5;
1259
+ cursor: pointer;
1260
+ }
1261
+ .re-call {
1262
+ cursor: pointer;
1263
+ color: #5585f5;
1264
+ }
1265
+ .voice-bg {
1266
+ display: flex;
1267
+ align-items: center;
1268
+ cursor: pointer;
1269
+ img {
1270
+ mix-blend-mode: difference;
1271
+ display: inline-block;
1272
+ width: 14px;
1273
+ }
1274
+ .voice-text {
1275
+ display: inline-block;
1276
+ }
1277
+ span {
1278
+ margin-left: 8px;
1279
+ }
1280
+ }
1281
+ }
1282
+ .has-dictionary {
1283
+ padding: 0;
1284
+ text-align: left;
1285
+ background: unset;
1286
+ }
1287
+ .content {
1288
+ padding: 10px;
1289
+ background: #ebebeb;
1290
+ border-radius: 0px 8px 8px 8px;
1291
+ max-width: 500px;
1292
+ margin: 0px;
1293
+ line-height: 20px;
1294
+ font-size: 14px;
1295
+ color: #000;
1296
+ text-align: left;
1297
+ word-break: break-word;
1298
+ /deep/ p {
1299
+ margin: 0;
1300
+ }
1301
+ }
1302
+ .upload-image {
1303
+ margin-left: 8px;
1304
+ }
1305
+ &.right {
1306
+ flex-direction: row-reverse;
1307
+ .right-time {
1308
+ left: unset;
1309
+ right: 10px;
1310
+ }
1311
+ .content-wrap {
1312
+ text-align: right;
1313
+ .robot-item {
1314
+ text-align: right;
1315
+ }
1316
+ .voice-bg {
1317
+ flex-direction: row-reverse;
1318
+ align-self: flex-end;
1319
+ img {
1320
+ transform: rotateY(180deg);
1321
+ }
1322
+ span {
1323
+ margin-left: 0;
1324
+ margin-right: 8px;
1325
+ text-align: right;
1326
+ }
1327
+ }
1328
+ }
1329
+ .content-wrap .content {
1330
+ background-color: #e7f0ff;
1331
+ border-radius: 8px 0px 8px 8px;
1332
+ border: 1px solid #e7f0ff;
1333
+ box-sizing: border-box;
1334
+ }
1335
+ .upload-image {
1336
+ margin-right: 8px;
1337
+ }
1338
+ }
1339
+ }
1340
+ .bot-message {
1341
+ display: block;
1342
+ text-decoration: underline;
1343
+ color: #5585f5;
1344
+ cursor: pointer;
1345
+ }
1346
+ .session-end {
1347
+ display: flex;
1348
+ justify-content: center;
1349
+ margin-top: 15px;
1350
+ margin-bottom: 25px;
1351
+ .end {
1352
+ display: flex;
1353
+ justify-content: center;
1354
+ width: 30%;
1355
+ height: 36px;
1356
+ line-height: 36px;
1357
+ background-color: #e8e8e8;
1358
+ color: #939393;
1359
+ font-size: 14px;
1360
+ border-radius: 18px;
1361
+ }
1362
+ }
1363
+ .menu-tip {
1364
+ font-size: 20px;
1365
+ align-self: flex-end;
1366
+ margin-bottom: 8px;
1367
+ background: #f6f6f6;
1368
+ height: 25px;
1369
+ line-height: 25px;
1370
+ width: 30px;
1371
+ border-radius: 4px;
1372
+ }
1373
+ .menu-item {
1374
+ :hover {
1375
+ background: red;
1376
+ }
1377
+ }
1378
+ .menu-main {
1379
+ width: 100px;
1380
+ background-color: #101627;
1381
+ color: #fff;
1382
+ text-align: left;
1383
+ border-radius: 6px;
1384
+ padding: 10px 0;
1385
+ z-index: 3000;
1386
+ cursor: pointer;
1387
+ .menu-item {
1388
+ padding: 0 10px;
1389
+ }
1390
+ .menu-item:hover {
1391
+ background-color: #efefef;
1392
+ color: #000;
1393
+ }
1394
+ }
1395
+ .first-name {
1396
+ width: 40px;
1397
+ height: 40px;
1398
+ line-height: 40px;
1399
+ text-align: center;
1400
+ background: #5585f5;
1401
+ color: #fff;
1402
+ border-radius: 100%;
1403
+ font-size: 15px;
1404
+ }
1405
+ .msg-avatar {
1406
+ width: 40px;
1407
+ height: 40px;
1408
+ border-radius: 50%;
1409
+
1410
+ object-fit: cover;
1411
+ background: #fff;
1412
+ }
1413
+ /deep/ .ant-spin-spinning {
1414
+ display: flex;
1415
+ align-items: center;
1416
+ }
1417
+ .system-msg {
1418
+ margin: 10px 0;
1419
+ text-align: left;
1420
+ line-height: 20px;
1421
+ word-wrap: break-word;
1422
+ display: flex;
1423
+ justify-content: center;
1424
+ .system-icon {
1425
+ font-size: 18px;
1426
+ color: #ffc200;
1427
+ vertical-align: middle;
1428
+ margin-right: 10px;
1429
+ margin-top: 1px;
1430
+ }
1431
+ .system-btn {
1432
+ color: @primary-color;
1433
+ margin-left: 8px;
1434
+ cursor: pointer;
1435
+ text-decoration: underline;
1436
+ }
1437
+ }
1438
+ }
1439
+ /deep/ p {
1440
+ margin-bottom: 0;
1441
+ }
1442
+ </style>