bhd-components 0.6.5 → 0.6.6

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 (29) hide show
  1. package/dist/{d4259367.esm.es5.development.js → 869a16fb.esm.es5.development.js} +1402 -1140
  2. package/dist/{8bda9e2e.esm.es5.production.js → c220442c.esm.es5.production.js} +1 -1
  3. package/dist/index.esm.es5.development.css +864 -732
  4. package/dist/index.esm.es5.development.js +757 -671
  5. package/dist/index.esm.es5.production.css +1 -1
  6. package/dist/index.esm.es5.production.js +1 -1
  7. package/es2017/customerService/contactsList.d.ts +1 -1
  8. package/es2017/customerService/contactsList.js +11 -145
  9. package/es2017/customerService/function.js +1 -1
  10. package/es2017/customerService/historyFun.js +325 -154
  11. package/es2017/customerService/index.js +412 -341
  12. package/es2017/customerService/index.module.less +169 -65
  13. package/es2017/customerService/index2.module.less +170 -65
  14. package/es2017/icons/components/custom-expand.d.ts +4 -0
  15. package/es2017/icons/components/custom-expand.js +22 -0
  16. package/es2017/icons/components/index.d.ts +1 -0
  17. package/es2017/icons/components/index.js +1 -0
  18. package/esm/customerService/contactsList.d.ts +1 -1
  19. package/esm/customerService/contactsList.js +11 -158
  20. package/esm/customerService/function.js +1 -1
  21. package/esm/customerService/historyFun.js +329 -167
  22. package/esm/customerService/index.js +397 -348
  23. package/esm/customerService/index.module.less +169 -65
  24. package/esm/customerService/index2.module.less +170 -65
  25. package/esm/icons/components/custom-expand.d.ts +4 -0
  26. package/esm/icons/components/custom-expand.js +24 -0
  27. package/esm/icons/components/index.d.ts +1 -0
  28. package/esm/icons/components/index.js +1 -0
  29. package/package.json +1 -1
@@ -46,21 +46,22 @@ const CustomerService = (props)=>{
46
46
  const [firstLoad, setFirstLoad] = useState(false); //第一次切换全屏时滚动到页面底部
47
47
  const [buttomHei, setButtomHei] = useState(45); //底部输入框的高度
48
48
  const [showHistory, setShowHistory] = useState(false); //是否显示历史记录
49
- const [showContacts, setShowContacts] = useState(false); //是否显示关联老师
49
+ const [showContacts, setShowContacts] = useState(false); //是否显示老师列表
50
50
  const [showType, setShowType] = useState(-1); //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
51
51
  const [answerMode, setAnswerMode] = useState(-1); //设置回答模式。1,召唤老师回答
52
52
  const [teacherList, setTeacherList] = useState([]); //老师列表
53
53
  const [problem, setProblem] = useState({}); //召唤老师回答的问题
54
- const [roomList, setRoomList] = useState([]); //聊天列表
54
+ // const [roomList,setRoomList] = useState([]);//聊天列表
55
+ const [contactsList, setContactsList] = useState([]); //老师列表
55
56
  const [chatObj, setChatObj] = useState([]); //聊天记录id保存,用来在实验报告中记录
56
57
  const timer = useRef(null); //文本框输入时
57
58
  let receiveMessageTimer = useRef(null); //接收ai发回的消息
58
59
  let voiceCountdownTimer = useRef(null); //语音录制倒计时
59
60
  let listTimer = useRef(null); // 请求列表倒计时
60
61
  let roomMessage = useRef(null); //循环当前页面的新消息
62
+ let chatRoomList = useRef(null); //获取聊天室列表
61
63
  const ctrl = useRef(); //停止生成ai回答时使用
62
64
  let childRef = useRef(null); //获取子组件方法
63
- // const [mid, setmid] = useState(props.userData.mid); //当前用户id
64
65
  const mid = props.userData.mid;
65
66
  const remarkable = new Remarkable({
66
67
  highlight: function(str, lang) {
@@ -82,6 +83,7 @@ const CustomerService = (props)=>{
82
83
  clearTimeout(listTimer.current);
83
84
  clearTimeout(timer.current);
84
85
  clearTimeout(roomMessage.current);
86
+ clearTimeout(chatRoomList.current);
85
87
  };
86
88
  }, []);
87
89
  useEffect(()=>{
@@ -94,12 +96,11 @@ const CustomerService = (props)=>{
94
96
  function handleScroll() {
95
97
  const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
96
98
  const scrollTop = container.scrollTop;
97
- // const scrollBottom = container.scroll;
98
99
  const clientHeight = container.clientHeight;
99
100
  const scrollHeight = container.scrollHeight;
100
101
  // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
101
102
  if (clientHeight + scrollTop + 0.5 >= scrollHeight) {
102
- console.log('到底部了22222');
103
+ console.log("到底部了22222");
103
104
  // console.log(11111111,pageNumHistory)
104
105
  if (pageNumHistory > 1) {
105
106
  // console.log(pageNumHistory,'pageNumpageNumpageNum')
@@ -108,15 +109,14 @@ const CustomerService = (props)=>{
108
109
  clearTimeout(listTimer.current);
109
110
  setBottomLoading(true);
110
111
  listTimer.current = setTimeout(()=>{
111
- // console.log("加载下一页", number);
112
112
  getHistoryMessage(number, 4);
113
113
  }, 1000);
114
114
  } else {
115
- setLastId('');
115
+ setLastId("");
116
116
  }
117
117
  }
118
118
  if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
119
- console.log('到顶了', pageNum);
119
+ console.log("到顶了", pageNum);
120
120
  // if(pageNum == 1){
121
121
  // setFirstpage(true);//代表是否存在第一页
122
122
  // }
@@ -166,15 +166,13 @@ const CustomerService = (props)=>{
166
166
  // console.log(props,'lsdkcmsdlcksd')
167
167
  getQuestiionsList("", 1);
168
168
  scrollToBottom();
169
- // less.modifyVars({ "@color-border-Tr": "#f4523b" });
170
169
  setShowType(initShowType);
171
170
  }, [
172
171
  initShowType
173
172
  ]);
174
173
  useEffect(()=>{
175
- // console.log(roomId,1111111)
176
- if (roomId != '') {
177
- if (lastId == '') {
174
+ if (roomId != "") {
175
+ if (lastId == "") {
178
176
  getHistoryMessage(pageNum, 2);
179
177
  } else {
180
178
  //查看历史记录,需要定位到当前记录
@@ -184,30 +182,28 @@ const CustomerService = (props)=>{
184
182
  }, [
185
183
  roomId
186
184
  ]);
185
+ //创建聊天室并获取聊天室列表
187
186
  useEffect(()=>{
188
- if (roomList.length == 0) {
189
- createRooms("AI").then((res)=>{
190
- setRoomId(res.data.id);
191
- setRoomList([
192
- {
193
- roomId: res.data.id,
194
- unreadCount: 0,
195
- uid: mid,
196
- sender: 'AI'
197
- }
198
- ]);
199
- });
200
- } else {
201
- setRoomList(roomList);
202
- }
203
- // recordRef.current.roomList=JSON.parse(JSON.stringify(roomList))
204
- }, [
205
- roomList
206
- ]);
187
+ createRooms("AI").then((res)=>{
188
+ setRoomId(res.data.id);
189
+ });
190
+ roomsListTimer();
191
+ return ()=>{
192
+ clearTimeout(chatRoomList.current);
193
+ };
194
+ }, []);
207
195
  //进入页面,发送打招呼信息
208
196
  useEffect(()=>{
209
- // console.log(historyMessageList, "dkjvndfkjvd33333f");
210
197
  //老师的聊天窗口不发送打招呼信息
198
+ let roomList = contactsList;
199
+ // console.log(roomList,'dkfvdfkjvndfkjvdfv')
200
+ let count = 0;
201
+ roomList.map((item)=>{
202
+ count += item.unreadCount;
203
+ });
204
+ if (count > 0) {
205
+ setShowContacts(true);
206
+ }
211
207
  if (!(roomList.length > 0 && roomList[0].roomId != roomId)) {
212
208
  //是否发送打招呼信息
213
209
  if (greetingMessage && historyMessageList.length == 0) {
@@ -242,7 +238,7 @@ const CustomerService = (props)=>{
242
238
  }, [
243
239
  bese64String
244
240
  ]);
245
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
241
+ //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
246
242
  const sendGreetingMessage = (type)=>{
247
243
  let questionsList = [];
248
244
  let obj = {};
@@ -345,12 +341,7 @@ const CustomerService = (props)=>{
345
341
  setKeyWord("");
346
342
  setQuestionsList([]);
347
343
  setCitationContent({});
348
- http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj, {
349
- headers: {
350
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
351
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
352
- }
353
- }).then((res)=>{
344
+ http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj).then((res)=>{
354
345
  if (res.data.id) {
355
346
  setHistoryMessageList((historyMessageList)=>{
356
347
  let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
@@ -385,8 +376,8 @@ const CustomerService = (props)=>{
385
376
  };
386
377
  setProblem({});
387
378
  } else if (type == 2) {
388
- let list = roomList.filter((item)=>item.roomId == roomId);
389
- let recevier = '';
379
+ let list = contactsList.filter((item)=>item.roomId == roomId);
380
+ let recevier = "";
390
381
  if (list.length > 0) {
391
382
  recevier = list[0].sender;
392
383
  }
@@ -398,14 +389,9 @@ const CustomerService = (props)=>{
398
389
  quotedMessage: citationContent.content || ""
399
390
  };
400
391
  }
401
- http.post(`${urllocation}/chat-service/public/v1.0/chat-with-user/messages`, obj, {
402
- headers: {
403
- "x-module-id": userData.modules.find((ele)=>ele.short == "TeacherAnswer").id,
404
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
405
- }
406
- }).then((res)=>{
392
+ http.post(`${urllocation}/chat-service/public/v1.0/chat-with-user/messages`, obj).then((res)=>{
407
393
  if (res.data.id) {
408
- console.log(pageNum, pageNumHistory, lastId, 'dlskskdsd4444');
394
+ // console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
409
395
  if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
410
396
  setHistoryMessageList((historyMessageList)=>{
411
397
  let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
@@ -426,8 +412,8 @@ const CustomerService = (props)=>{
426
412
  if (type == 1) {
427
413
  let roomList = [
428
414
  {
429
- 'roomId': roomId,
430
- 'id': res.data.id
415
+ roomId: roomId,
416
+ id: res.data.id
431
417
  }
432
418
  ];
433
419
  setChatObj((list)=>{
@@ -517,12 +503,7 @@ const CustomerService = (props)=>{
517
503
  return newHistoryMessageList;
518
504
  });
519
505
  scrollToBottom();
520
- http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj, {
521
- headers: {
522
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
523
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
524
- }
525
- }).then((res)=>{
506
+ http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj).then((res)=>{
526
507
  if (res.data.id) {
527
508
  //更新聊天记录id
528
509
  setHistoryMessageList((historyMessageList)=>{
@@ -552,34 +533,18 @@ const CustomerService = (props)=>{
552
533
  }
553
534
  ]
554
535
  };
555
- sendingExistingIssues(2, dataObj, '');
556
- testLabQuestion(obj.message, questions.answer, '');
536
+ sendingExistingIssues(2, dataObj, "");
537
+ testLabQuestion(obj.message, questions.answer, "");
557
538
  }
558
- }).then((res)=>{
559
- console.log(res);
560
539
  });
561
540
  };
562
541
  //向AI发送问题 type == 1 发送点赞或踩消息,type == 2 发送重新生成消息,type == 3 正常发送消息
563
- let content = ''; //用于实验报告的问题记录
542
+ let content = ""; //用于实验报告的问题记录
564
543
  const aiSendQuestions = (type, obj, id)=>{
565
- content = '';
566
- // if (type == 3) {
567
- // try {
568
- // if (ctrl && ctrl.current) {
569
- // ctrl.current.abort();
570
- // }
571
- // } catch (error) {}
572
- // clearTimeout(receiveMessageTimer.current);
573
- // setHistoryMessageList((historyMessageList) => {
574
- // return historyMessageList.filter((item) => item.id != "123456");
575
- // });
576
- // setFinished(true);
577
- // return;
578
- // }
544
+ content = "";
579
545
  ctrl.current = new AbortController();
580
546
  clearTimeout(receiveMessageTimer.current);
581
547
  receiveMessageTimer.current = setTimeout(()=>{
582
- // console.log('超时终止1111')
583
548
  setHistoryMessageList((historyMessageList)=>{
584
549
  return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
585
550
  });
@@ -656,7 +621,7 @@ const CustomerService = (props)=>{
656
621
  Accept: "text/event-stream,application/json",
657
622
  "X-Auth-Jwt": window.localStorage.getItem("usertoken") || "",
658
623
  "Auth-Token": userData.token,
659
- "X-Module-Id": userData.modules.find((ele)=>ele.short == "AIservice").id
624
+ "X-Module-Id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id
660
625
  },
661
626
  body: data,
662
627
  signal: ctrl.current.signal,
@@ -747,7 +712,7 @@ const CustomerService = (props)=>{
747
712
  }
748
713
  if (msg.finished) {
749
714
  setFinished(true); //发送结束
750
- testLabQuestion(JSON.parse(data).message, content, '');
715
+ testLabQuestion(JSON.parse(data).message, content, "");
751
716
  }
752
717
  },
753
718
  onclose () {
@@ -812,27 +777,22 @@ const CustomerService = (props)=>{
812
777
  return newHistoryMessageList2;
813
778
  }
814
779
  });
815
- setTimeout(()=>{
816
- scrollToBottom();
817
- }, 10);
780
+ // setTimeout(() => {
781
+ scrollToBottom();
782
+ // }, 10);
818
783
  };
819
784
  //问题记录到实验报告中
820
785
  const testLabQuestion = (title, content, teachId)=>{
821
786
  // console.log(title,content,'记录到实验报告中')
822
- if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
787
+ if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
823
788
  http.post(`${urllocation}/sandboxes/public/v1.0/labquestion`, {
824
789
  title: title,
825
790
  content: content,
826
791
  teachId: teachId != undefined ? teachId : chatWith.uid | mid,
827
792
  stepId: stepId,
828
793
  stepIds: stepIds
829
- }, {
830
- headers: {
831
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
832
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
833
- }
834
794
  }).then(()=>{
835
- console.log(roomId, chatObj, 'roomIdroomIdroomIdroomId');
795
+ console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
836
796
  setChatObj((list1)=>{
837
797
  let list = list1.filter((e)=>e.roomId != roomId);
838
798
  return list;
@@ -844,11 +804,6 @@ const CustomerService = (props)=>{
844
804
  const speechToText = ()=>{
845
805
  http.post(`${urllocation}/chat-service/public/v1.0/speech:recognize`, {
846
806
  audio: bese64String
847
- }, {
848
- headers: {
849
- "x-module-id": userData.modules.find((ele)=>ele.short == "AIservice").id,
850
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
851
- }
852
807
  }).then((res)=>{
853
808
  setVoiceRecordingStatus(3);
854
809
  if (res.data) {
@@ -864,17 +819,12 @@ const CustomerService = (props)=>{
864
819
  const createRooms = (uid)=>{
865
820
  return http.post(`${urllocation}/chat-service/public/v1.0/rooms`, {
866
821
  chatWith: uid
867
- }, {
868
- headers: {
869
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
870
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
871
- }
872
822
  });
873
823
  };
874
824
  //获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
875
825
  const getHistoryMessage = (pageNum, flag, id = "1")=>{
876
826
  clearTimeout(roomMessage.current);
877
- console.log(pageNum, flag, 'dkfjvndfjvndfkvdf');
827
+ // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
878
828
  // flag == 1 时已经设置好了位置标记
879
829
  let last_id = "";
880
830
  if (flag == 2 && historyMessageList.length > 0) {
@@ -895,18 +845,10 @@ const CustomerService = (props)=>{
895
845
  page: pageNum ? pageNum : 1,
896
846
  maxPageSize: 30,
897
847
  direction: "desc"
898
- },
899
- headers: {
900
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
901
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
902
848
  }
903
849
  }).then((res)=>{
904
850
  let totalNumber = 0;
905
- let roomList = [];
906
- setRoomList((list)=>{
907
- roomList = list;
908
- return list;
909
- });
851
+ let roomList = contactsList;
910
852
  if (res.data.messages.length > 0) {
911
853
  clearTimeout(listTimer.current);
912
854
  let total = res.data.total;
@@ -941,7 +883,7 @@ const CustomerService = (props)=>{
941
883
  });
942
884
  //如果在跟老师的聊天窗口,用于找到与老师的最新的聊天,并不在与老师对话的窗口中,并聊天窗口相同
943
885
  try {
944
- if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
886
+ if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
945
887
  fildChatRecords(newHistoryMessageList);
946
888
  }
947
889
  } catch (error) {}
@@ -973,8 +915,9 @@ const CustomerService = (props)=>{
973
915
  // console.log(roomList,rid,roomId,555555);
974
916
  //不是ai窗口循环查询消息
975
917
  let chatWindow = roomList.filter((item)=>item.roomId == rid);
976
- let isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == 'AI' ? true : false;
918
+ let isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
977
919
  if (!isAiChatWindow && roomList.length > 0 && (pageNum == 1 || pageNumHistory == 0)) {
920
+ //&& pageNum == 1
978
921
  getRoomidHistoryMessage(totalNumber, rid);
979
922
  }
980
923
  }).catch((res)=>{
@@ -987,18 +930,14 @@ const CustomerService = (props)=>{
987
930
  roomMessage.current = setTimeout(()=>{
988
931
  getRoomidHistoryMessage(totalNumber, rid);
989
932
  }, 5000);
990
- if (rid == '') return;
933
+ if (rid == "") return;
991
934
  // console.log(roomList,2222222);
992
935
  return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
993
936
  params: {
994
937
  roomId: rid,
995
938
  page: 1,
996
- maxPageSize: totalNumber,
939
+ maxPageSize: totalNumber == 0 ? 30 : totalNumber,
997
940
  direction: "desc"
998
- },
999
- headers: {
1000
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
1001
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1002
941
  }
1003
942
  }).then((res)=>{
1004
943
  let newHistoryMessageList = [];
@@ -1015,7 +954,7 @@ const CustomerService = (props)=>{
1015
954
  newList = newHistoryMessageList.length;
1016
955
  return newHistoryMessageList;
1017
956
  });
1018
- console.log(dataList.length, originList, lastId, 'dfkvdnfkvdfj44444');
957
+ // console.log(dataList.length , originList,lastId,'dfkvdnfkvdfj44444');
1019
958
  if (!lastId && originList != newList) {
1020
959
  setTimeout(()=>{
1021
960
  scrollToBottom();
@@ -1023,7 +962,7 @@ const CustomerService = (props)=>{
1023
962
  }
1024
963
  }
1025
964
  try {
1026
- if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
965
+ if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
1027
966
  fildChatRecords(newHistoryMessageList);
1028
967
  }
1029
968
  } catch (error) {}
@@ -1046,7 +985,7 @@ const CustomerService = (props)=>{
1046
985
  if (room.length > 0) {
1047
986
  // console.log(room,'dfvdfvdfvdfv')
1048
987
  let chatID = room[0].id;
1049
- console.log(chatID, 'chatIDchatIDchatID');
988
+ console.log(chatID, "chatIDchatIDchatID");
1050
989
  let index = -1;
1051
990
  newHistoryMessageList.forEach((item, i)=>{
1052
991
  // console.log(item,item.id,'lskdcmsldksdcsdc')
@@ -1058,11 +997,10 @@ const CustomerService = (props)=>{
1058
997
  //有新的消息
1059
998
  if (index != -1) {
1060
999
  let newMessage = newHistoryMessageList.slice(index);
1061
- console.log(newMessage, 'newMessagenewMessage');
1000
+ console.log(newMessage, "newMessagenewMessage");
1062
1001
  let result = [];
1063
1002
  newMessage.forEach((item, index)=>{
1064
- let isQuestion = item.receiver !== mid //是否为问题
1065
- ;
1003
+ let isQuestion = item.receiver !== mid; //是否为问题
1066
1004
  if (isQuestion) {
1067
1005
  //问题
1068
1006
  if (newMessage[index + 1] && newMessage[index + 1].receiver === mid) {
@@ -1075,7 +1013,7 @@ const CustomerService = (props)=>{
1075
1013
  }
1076
1014
  }
1077
1015
  });
1078
- console.log(result, '存储的消息');
1016
+ console.log(result, "存储的消息");
1079
1017
  result.map((item)=>{
1080
1018
  testLabQuestion(item.question, item.answer, String(item.id));
1081
1019
  });
@@ -1094,11 +1032,6 @@ const CustomerService = (props)=>{
1094
1032
  }
1095
1033
  http.post(url, {
1096
1034
  messageId: id
1097
- }, {
1098
- headers: {
1099
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
1100
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1101
- }
1102
1035
  }).then((res)=>{
1103
1036
  setHistoryMessageList((historyMessageList)=>{
1104
1037
  let list = historyMessageList;
@@ -1123,11 +1056,6 @@ const CustomerService = (props)=>{
1123
1056
  }
1124
1057
  http.post(url, {
1125
1058
  messageId: id
1126
- }, {
1127
- headers: {
1128
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
1129
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1130
- }
1131
1059
  }).then((res)=>{
1132
1060
  setHistoryMessageList((historyMessageList)=>{
1133
1061
  let list = historyMessageList;
@@ -1157,11 +1085,7 @@ const CustomerService = (props)=>{
1157
1085
  };
1158
1086
  }
1159
1087
  http.get(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions`, {
1160
- params: data,
1161
- headers: {
1162
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
1163
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1164
- }
1088
+ params: data
1165
1089
  }).then((res)=>{
1166
1090
  if (res.data.questions) {
1167
1091
  if (flag == 1) {
@@ -1177,10 +1101,6 @@ const CustomerService = (props)=>{
1177
1101
  http.get(`${urllocation}/chat-service/public/v1.0/teachers`, {
1178
1102
  params: {
1179
1103
  name: keyWord
1180
- },
1181
- headers: {
1182
- "x-module-id": userData.modules.find((ele)=>ele.short == "TeacherAnswer").id,
1183
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1184
1104
  }
1185
1105
  }).then((res)=>{
1186
1106
  console.log(res);
@@ -1189,6 +1109,82 @@ const CustomerService = (props)=>{
1189
1109
  }
1190
1110
  });
1191
1111
  };
1112
+ //获取聊天室列表
1113
+ const roomsListTimer = ()=>{
1114
+ if (chatRoomList != null) clearTimeout(chatRoomList.current);
1115
+ chatRoomList.current = setTimeout(()=>roomsListTimer(), 60000);
1116
+ http.get(`${urllocation}/chat-service/public/v1.0/rooms`, {
1117
+ params: {
1118
+ page: 1,
1119
+ maxPageSize: 100002
1120
+ }
1121
+ }).then((res)=>{
1122
+ if (res.data) {
1123
+ let list = res.data.contacts;
1124
+ setContactsList((list1)=>{
1125
+ list = list.map((item, index)=>{
1126
+ let c_list = list1.filter((e)=>e.sender == item.sender);
1127
+ let obj = {};
1128
+ if (c_list.length > 0) {
1129
+ obj = c_list[0];
1130
+ }
1131
+ return _object_spread({}, obj, item);
1132
+ });
1133
+ return list;
1134
+ });
1135
+ getUserInfo(list);
1136
+ }
1137
+ });
1138
+ };
1139
+ //获取老师的信息等
1140
+ const getUserInfo = (list)=>{
1141
+ let getUserid = [];
1142
+ //查找需要用户名和头像的
1143
+ list.map((item, i)=>{
1144
+ if (!item.name && !item.headImg && item.sender != "AI") {
1145
+ getUserid.push(item.sender);
1146
+ }
1147
+ });
1148
+ if (getUserid.length > 0) {
1149
+ getUserName(getUserid.join(",")).then((res)=>{
1150
+ if (res.data) {
1151
+ let nameList = res.data;
1152
+ // console.log(nameList,contactsList,'kdsjnvjdkvdfj')
1153
+ setContactsList((contactsList)=>{
1154
+ list = list.map((item, index)=>{
1155
+ let name = nameList.filter((v)=>v.uid == item.sender);
1156
+ if (name.length > 0) {
1157
+ return _object_spread({}, item, name[0]);
1158
+ } else {
1159
+ return item;
1160
+ }
1161
+ });
1162
+ return list;
1163
+ });
1164
+ }
1165
+ });
1166
+ } else {
1167
+ setContactsList((contactsList)=>{
1168
+ list = list.map((item, index)=>{
1169
+ let c_list = contactsList.filter((e)=>e.sender == item.sender);
1170
+ let obj = {};
1171
+ if (c_list.length > 0) {
1172
+ obj = c_list[0];
1173
+ }
1174
+ return _object_spread({}, obj, item);
1175
+ });
1176
+ return list;
1177
+ });
1178
+ }
1179
+ };
1180
+ //获取老师用户名
1181
+ const getUserName = (uid)=>{
1182
+ return http.get(`${urllocation}/chat-service/public/v1.0/userinfo`, {
1183
+ params: {
1184
+ uid: uid
1185
+ }
1186
+ });
1187
+ };
1192
1188
  //设置滚动条滚动到底部
1193
1189
  const scrollToBottom = ()=>{
1194
1190
  const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
@@ -1203,11 +1199,18 @@ const CustomerService = (props)=>{
1203
1199
  container.scrollTop = 60;
1204
1200
  try {
1205
1201
  setTimeout(()=>{
1206
- let top = showType == 1 || showType == 3 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1202
+ // let top2 =
1203
+ // showType == 1 || showType == 3
1204
+ // ? $("#li_flag").offset().top - 20
1205
+ // : $("#chat_content_modal #li_flag").offset().top -
1206
+ // $("#chat_content_modal").offset().top +
1207
+ // 24;
1208
+ let top = showType == 1 || showType == 3 ? $("#li_flag").offset().top : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top;
1209
+ // console.log(top2,top,444444444444)
1207
1210
  $(`#${showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"}`).animate({
1208
1211
  scrollTop: top
1209
1212
  }, 0);
1210
- }, 10);
1213
+ }, 100);
1211
1214
  } catch (error) {}
1212
1215
  setLoading(false);
1213
1216
  }
@@ -1227,17 +1230,32 @@ const CustomerService = (props)=>{
1227
1230
  });
1228
1231
  });
1229
1232
  };
1230
- //渲染头部
1231
- const renderHeader = ()=>{
1232
- let list = roomList.filter((e)=>e.roomId == roomId);
1233
- let title = '智能问答';
1234
- if (list.length > 0 && list[0].name) {
1235
- title = list[0].name;
1236
- }
1233
+ //显示未读消息
1234
+ const showUnreadMessage = ()=>{
1237
1235
  let count = 0;
1238
- roomList.map((item)=>{
1236
+ contactsList.map((item)=>{
1239
1237
  count = count + item.unreadCount;
1240
1238
  });
1239
+ if (count > 0) {
1240
+ return /*#__PURE__*/ _jsx("span", {
1241
+ className: styles.count,
1242
+ children: count > 99 ? "99+" : count
1243
+ });
1244
+ } else {
1245
+ return "";
1246
+ }
1247
+ };
1248
+ //显示聊天室名字
1249
+ const showChatRoomName = ()=>{
1250
+ let title = "AI助手";
1251
+ let list = contactsList.filter((e)=>e.roomId == roomId);
1252
+ if (list.length > 0 && list[0].name) {
1253
+ title = list[0].name;
1254
+ }
1255
+ return title;
1256
+ };
1257
+ //渲染头部
1258
+ const renderHeader = ()=>{
1241
1259
  if (showType == 4) {
1242
1260
  return /*#__PURE__*/ _jsxs("div", {
1243
1261
  className: styles.top,
@@ -1245,7 +1263,7 @@ const CustomerService = (props)=>{
1245
1263
  /*#__PURE__*/ _jsx("div", {
1246
1264
  className: styles.user,
1247
1265
  children: /*#__PURE__*/ _jsx("p", {
1248
- children: title
1266
+ children: showChatRoomName()
1249
1267
  })
1250
1268
  }),
1251
1269
  /*#__PURE__*/ _jsxs("div", {
@@ -1296,13 +1314,10 @@ const CustomerService = (props)=>{
1296
1314
  },
1297
1315
  children: [
1298
1316
  /*#__PURE__*/ _jsx(CustomContacts, {}),
1299
- count > 0 ? /*#__PURE__*/ _jsx("span", {
1300
- className: styles.count,
1301
- children: count > 99 ? '99+' : count
1302
- }) : ''
1317
+ showUnreadMessage()
1303
1318
  ]
1304
1319
  }),
1305
- title
1320
+ showChatRoomName()
1306
1321
  ]
1307
1322
  })
1308
1323
  }),
@@ -1325,7 +1340,13 @@ const CustomerService = (props)=>{
1325
1340
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
1326
1341
  // switchDialogBox(3, true);
1327
1342
  setShowType(2);
1328
- childRef.current.roomsListTimer();
1343
+ setTimeout(()=>{
1344
+ setKeyWord(" ");
1345
+ }, 100);
1346
+ setTimeout(()=>{
1347
+ setKeyWord("");
1348
+ }, 300);
1349
+ // childRef.current.roomsListTimer();
1329
1350
  },
1330
1351
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
1331
1352
  }) : /*#__PURE__*/ _jsx("i", {
@@ -1350,7 +1371,7 @@ const CustomerService = (props)=>{
1350
1371
  const resettingBottomHei = ()=>{
1351
1372
  setTimeout(()=>{
1352
1373
  if (showType == 1 || showType == 3) {
1353
- if (document.getElementById("Drawer_buttom_modal")) {
1374
+ if (document.getElementById("Drawer_buttom")) {
1354
1375
  let hei = document.getElementById("Drawer_buttom").offsetHeight;
1355
1376
  setButtomHei(hei);
1356
1377
  }
@@ -1364,28 +1385,48 @@ const CustomerService = (props)=>{
1364
1385
  };
1365
1386
  //切换聊天室 type == renew ,存在新消息
1366
1387
  const switchChatRoom = (id, type)=>{
1367
- setLastId("");
1368
- setPageNum(1);
1369
- setPageCount(0);
1370
- setRoomId(id);
1371
- //
1372
- // if (type == "renew") {
1373
- // getHistoryMessage(1, 3,id);
1374
- // }else{
1375
- // setRoomId(id);
1376
- // }
1377
- readMessage(id, urllocation, userData, http);
1378
- };
1379
- const saveContactsList = (list)=>{
1380
- if (list != undefined) {
1381
- setRoomList(list);
1388
+ if (type != "1") {
1389
+ readMessage(id, urllocation, userData, http);
1390
+ setLastId("");
1391
+ setPageNum(1);
1392
+ setPageCount(0);
1393
+ setRoomId(id);
1394
+ try {
1395
+ if (ctrl && ctrl.current) {
1396
+ ctrl.current.abort();
1397
+ }
1398
+ setFinished(true);
1399
+ } catch (error) {}
1400
+ setTimeout(()=>{
1401
+ roomsListTimer();
1402
+ }, 500);
1382
1403
  }
1404
+ //删除聊天室
1405
+ if (type == "1") {
1406
+ if (id == roomId) {
1407
+ // console.log(contactsList,888888);
1408
+ switchChatRoom(contactsList[0].roomId, '');
1409
+ }
1410
+ setContactsList((list)=>{
1411
+ let newList = list;
1412
+ newList = newList.filter((v)=>v.roomId != id);
1413
+ return newList;
1414
+ });
1415
+ }
1416
+ // if (type == "renew") {
1417
+ // getHistoryMessage(1, 3,id);
1418
+ // }else{
1419
+ // setRoomId(id);
1420
+ // }
1383
1421
  };
1422
+ // const saveContactsList = (list: any)=>{
1423
+ // console.log(list,44444444)
1424
+ // // if(list != undefined){
1425
+ // // setRoomList(list);
1426
+ // // }
1427
+ // }
1384
1428
  //渲染问答
1385
1429
  const renderQuestion = ()=>{
1386
- // 2023-12-01T14:34:07
1387
- // console.log(lastId,'lastIdlastIdlastId')
1388
- // console.log(mid, historyMessageList, "ddkfdscksdcs");
1389
1430
  if (historyMessageList.length > 0) {
1390
1431
  return /*#__PURE__*/ _jsx("ul", {
1391
1432
  className: styles.message_con,
@@ -1434,56 +1475,61 @@ const CustomerService = (props)=>{
1434
1475
  children: /*#__PURE__*/ _jsxs("div", {
1435
1476
  className: styles.main_content,
1436
1477
  children: [
1437
- /*#__PURE__*/ _jsx("div", {
1438
- className: styles.operate_modal,
1439
- children: /*#__PURE__*/ _jsxs("p", {
1440
- className: styles.operate,
1441
- children: [
1442
- /*#__PURE__*/ _jsx("i", {
1443
- className: "yinyong_quote1",
1444
- onClick: ()=>{
1445
- setCitationContent({
1446
- content: item.message,
1447
- id: item.id
1448
- });
1449
- resettingBottomHei();
1450
- onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1451
- },
1452
- children: /*#__PURE__*/ _jsx(CustomQuote, {})
1453
- }),
1454
- copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1455
- className: `tongyong-xuanzhongdui`,
1456
- children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1457
- }) : /*#__PURE__*/ _jsx("i", {
1458
- className: "fuzhi21",
1459
- onClick: ()=>{
1460
- let bol = copyText(item.message);
1461
- if (bol) {
1462
- let obj = copyTextOBJ;
1463
- obj = obj.filter((list)=>list != item.id);
1464
- obj.push(item.id);
1465
- setCopyTextObj(obj);
1466
- }
1467
- setTimeout(()=>{
1468
- let obj = copyTextOBJ;
1469
- obj = obj.filter((list)=>list != item.id);
1470
- setCopyTextObj(obj);
1471
- }, 3000);
1472
- onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1478
+ /*#__PURE__*/ _jsxs("div", {
1479
+ className: styles.main_content_flag,
1480
+ children: [
1481
+ /*#__PURE__*/ _jsx("div", {
1482
+ className: styles.operate_modal,
1483
+ children: /*#__PURE__*/ _jsxs("p", {
1484
+ className: styles.operate,
1485
+ children: [
1486
+ /*#__PURE__*/ _jsx("i", {
1487
+ className: "yinyong_quote1",
1488
+ onClick: ()=>{
1489
+ setCitationContent({
1490
+ content: item.message,
1491
+ id: item.id
1492
+ });
1493
+ resettingBottomHei();
1494
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1495
+ },
1496
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1497
+ }),
1498
+ copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1499
+ className: `tongyong-xuanzhongdui`,
1500
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1501
+ }) : /*#__PURE__*/ _jsx("i", {
1502
+ className: "fuzhi21",
1503
+ onClick: ()=>{
1504
+ let bol = copyText(item.message);
1505
+ if (bol) {
1506
+ let obj = copyTextOBJ;
1507
+ obj = obj.filter((list)=>list != item.id);
1508
+ obj.push(item.id);
1509
+ setCopyTextObj(obj);
1510
+ }
1511
+ setTimeout(()=>{
1512
+ let obj = copyTextOBJ;
1513
+ obj = obj.filter((list)=>list != item.id);
1514
+ setCopyTextObj(obj);
1515
+ }, 3000);
1516
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1517
+ },
1518
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1519
+ })
1520
+ ]
1521
+ })
1522
+ }),
1523
+ /*#__PURE__*/ _jsx("div", {
1524
+ className: styles.content,
1525
+ children: /*#__PURE__*/ _jsx("p", {
1526
+ dangerouslySetInnerHTML: {
1527
+ __html: remarkable.render(message)
1473
1528
  },
1474
- children: /*#__PURE__*/ _jsx(CustomCopy, {})
1529
+ className: styles.content_child
1475
1530
  })
1476
- ]
1477
- })
1478
- }),
1479
- /*#__PURE__*/ _jsx("div", {
1480
- className: styles.content,
1481
- children: /*#__PURE__*/ _jsx("p", {
1482
- dangerouslySetInnerHTML: {
1483
- __html: remarkable.render(message)
1484
- },
1485
- className: styles.content_child
1486
- })
1531
+ })
1532
+ ]
1487
1533
  }),
1488
1534
  //引用消息
1489
1535
  item.quotedMessage && /*#__PURE__*/ _jsx("div", {
@@ -1521,13 +1567,16 @@ const CustomerService = (props)=>{
1521
1567
  });
1522
1568
  } else {
1523
1569
  //获取用户头像
1524
- let headImg = '';
1525
- let chatWindow = roomList.filter((item)=>item.roomId == roomId);
1526
- if (chatWindow.length > 0 && chatWindow[0].headImg != '') {
1570
+ let headImg = "";
1571
+ let chatWindow = [];
1572
+ let isAiChatWindow;
1573
+ chatWindow = contactsList.filter((item)=>item.roomId == roomId);
1574
+ if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
1527
1575
  headImg = chatWindow[0].headImg;
1528
1576
  }
1577
+ // console.log(chatWindow,'chatWindowchatWindow')
1529
1578
  //是否在智能客服窗口
1530
- let isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == 'AI' ? true : false;
1579
+ isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
1531
1580
  let header = 2; //代表是ai头像
1532
1581
  if (isAiChatWindow && item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
1533
1582
  //使用AI头像
@@ -1559,34 +1608,39 @@ const CustomerService = (props)=>{
1559
1608
  children: /*#__PURE__*/ _jsxs("div", {
1560
1609
  className: styles.main_content,
1561
1610
  children: [
1562
- /*#__PURE__*/ _jsx("div", {
1563
- className: styles.operate_modal,
1564
- children: // 不是最后一行,
1565
- historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
1566
- }),
1567
1611
  /*#__PURE__*/ _jsxs("div", {
1568
- className: styles.content,
1612
+ className: styles.main_content_flag,
1569
1613
  children: [
1570
- /*#__PURE__*/ _jsx("p", {
1571
- dangerouslySetInnerHTML: {
1572
- __html: remarkable.render(message)
1573
- },
1574
- className: styles.content_child
1614
+ /*#__PURE__*/ _jsx("div", {
1615
+ className: styles.operate_modal,
1616
+ children: // 不是最后一行,
1617
+ historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
1575
1618
  }),
1576
- item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsx("ul", {
1577
- className: styles.association_problem,
1578
- children: JSON.parse(item.extraInfo).map((list, index)=>{
1579
- return /*#__PURE__*/ _jsxs("li", {
1580
- onClick: ()=>{
1581
- sendMessage(list, 1);
1619
+ /*#__PURE__*/ _jsxs("div", {
1620
+ className: styles.content,
1621
+ children: [
1622
+ /*#__PURE__*/ _jsx("p", {
1623
+ dangerouslySetInnerHTML: {
1624
+ __html: remarkable.render(message)
1582
1625
  },
1583
- children: [
1584
- index + 1,
1585
- ".",
1586
- list.question
1587
- ]
1588
- }, i + "_" + index + "_" + list.value);
1589
- })
1626
+ className: styles.content_child
1627
+ }),
1628
+ item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsx("ul", {
1629
+ className: styles.association_problem,
1630
+ children: JSON.parse(item.extraInfo).map((list, index)=>{
1631
+ return /*#__PURE__*/ _jsxs("li", {
1632
+ onClick: ()=>{
1633
+ sendMessage(list, 1);
1634
+ },
1635
+ children: [
1636
+ index + 1,
1637
+ ".",
1638
+ list.question
1639
+ ]
1640
+ }, i + "_" + index + "_" + list.value);
1641
+ })
1642
+ })
1643
+ ]
1590
1644
  })
1591
1645
  ]
1592
1646
  }),
@@ -1612,7 +1666,7 @@ const CustomerService = (props)=>{
1612
1666
  !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && renderLastOperateBtn(item, isAiChatWindow, i),
1613
1667
  //召唤老师回答按钮
1614
1668
  isAiChatWindow && item.findTeacher && userData.modules.some((item)=>item.short == "TeacherAnswer") ? /*#__PURE__*/ _jsx("div", {
1615
- className: `${styles.operate_modal_bottom}`,
1669
+ className: `${styles.operate_modal_bottom} `,
1616
1670
  children: /*#__PURE__*/ _jsx("p", {
1617
1671
  className: styles.stop_findTeacher,
1618
1672
  children: /*#__PURE__*/ _jsx("span", {
@@ -1626,7 +1680,7 @@ const CustomerService = (props)=>{
1626
1680
  children: "停止召唤老师"
1627
1681
  })
1628
1682
  })
1629
- }) : ''
1683
+ }) : ""
1630
1684
  ]
1631
1685
  })
1632
1686
  })
@@ -1647,8 +1701,8 @@ const CustomerService = (props)=>{
1647
1701
  //问候语及点赞下面不需要展示相关按钮
1648
1702
  let extraInfo = item.extraInfo;
1649
1703
  //JSON.parse(extraInfo)[0].key == 'questionId' 是联想问题
1650
- if (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'messageSource' || extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'isVoteMessage') {
1651
- return '';
1704
+ if (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "messageSource" || extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "isVoteMessage") {
1705
+ return "";
1652
1706
  }
1653
1707
  return /*#__PURE__*/ _jsxs("p", {
1654
1708
  className: styles.operate,
@@ -1777,30 +1831,34 @@ const CustomerService = (props)=>{
1777
1831
  };
1778
1832
  //渲染最后一条的操作按钮
1779
1833
  const renderLastOperateBtn = (item, isAiChatWindow, i)=>{
1780
- {}
1834
+ {
1835
+ /* 停止生成按钮 最后一次生成答案的支持点击 */ }
1781
1836
  //问候语及点赞下面不需要展示相关按钮
1782
1837
  let extraInfo = item.extraInfo;
1783
1838
  //JSON.parse(extraInfo)[0].key == 'questionId' 是联想问题
1784
- if (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'messageSource' || extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'isVoteMessage') {
1785
- return '';
1839
+ if (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "messageSource" || extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "isVoteMessage") {
1840
+ return "";
1786
1841
  }
1787
1842
  //1、是否显示停止生成按钮 finished 是否生产完成
1788
1843
  let showStopBtn = false;
1789
- if (!finished && item.sender == 'AI' && item.extraInfo == null) {
1844
+ if (!finished && item.sender == "AI" && item.extraInfo == null) {
1790
1845
  showStopBtn = true;
1791
1846
  }
1792
1847
  //2、是否展示重新生成按钮
1793
1848
  let regenerationBtn = false;
1794
- if (finished && item.sender == 'AI' && item.extraInfo == null) {
1849
+ if (finished && item.sender == "AI" && item.extraInfo == null) {
1795
1850
  regenerationBtn = true;
1796
1851
  }
1797
1852
  //3、是否显示召唤老师回答按钮
1798
1853
  let findTeacherBtn = false;
1799
- if (!showStopBtn && isAiChatWindow && (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'questionId' || extraInfo == null)) {
1854
+ if (!showStopBtn && isAiChatWindow && (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "questionId" || extraInfo == null)) {
1800
1855
  findTeacherBtn = true;
1801
1856
  }
1802
1857
  return /*#__PURE__*/ _jsxs("div", {
1803
1858
  className: `${styles.operate_modal_bottom}`,
1859
+ style: {
1860
+ position: showStopBtn ? 'sticky' : 'relative'
1861
+ },
1804
1862
  children: [
1805
1863
  /*#__PURE__*/ _jsxs("p", {
1806
1864
  className: styles.stop_generate,
@@ -1851,8 +1909,6 @@ const CustomerService = (props)=>{
1851
1909
  question: historyMessageList[i - 1].message,
1852
1910
  user: problem.user
1853
1911
  });
1854
- console.log(item, '88888999999');
1855
- // if(item.extraInfo == null){
1856
1912
  setHistoryMessageList((historyMessageList)=>{
1857
1913
  let newHistoryMessageList = historyMessageList.concat({
1858
1914
  id: -1,
@@ -1871,30 +1927,6 @@ const CustomerService = (props)=>{
1871
1927
  });
1872
1928
  return newHistoryMessageList;
1873
1929
  });
1874
- // }else{
1875
- // setHistoryMessageList(
1876
- // (historyMessageList) => {
1877
- // let newHistoryMessageList =
1878
- // historyMessageList.concat({
1879
- // id: -1,
1880
- // roomId: roomId,
1881
- // sender: "AI",
1882
- // recevier: mid,
1883
- // message:
1884
- // "请告诉我您要召唤的老师名字",
1885
- // createdAt: getDataTime(-1),
1886
- // findTeacher:true,
1887
- // extraInfo: JSON.stringify([
1888
- // {
1889
- // key: "questionId",
1890
- // value: "questionId",
1891
- // },
1892
- // ])
1893
- // });
1894
- // return newHistoryMessageList;
1895
- // }
1896
- // );
1897
- // }
1898
1930
  setTimeout(()=>{
1899
1931
  scrollToBottom();
1900
1932
  }, 200);
@@ -2057,6 +2089,7 @@ const CustomerService = (props)=>{
2057
2089
  if (answerMode == 1) {
2058
2090
  getTeacherList(String(e.target.value));
2059
2091
  } else {
2092
+ let roomList = contactsList;
2060
2093
  if (roomList.length > 0 && roomList[0].roomId != roomId) return;
2061
2094
  getQuestiionsList(String(e.target.value), 2);
2062
2095
  }
@@ -2070,13 +2103,27 @@ const CustomerService = (props)=>{
2070
2103
  e.stopPropagation();
2071
2104
  e.preventDefault();
2072
2105
  clearTimeout(timer.current);
2073
- setKeyWord('');
2106
+ setKeyWord("");
2074
2107
  setCitationContent({});
2108
+ //查找是否是召唤老师回答并有相应的老师名称
2109
+ if (answerMode == 1 && teacherList.length > 0) {
2110
+ let list = teacherList.filter((v)=>v.name == keyWord.trim());
2111
+ if (list.length > 0) {
2112
+ //直接进入召唤老师回答模式
2113
+ enterTeacherChat(list[0]);
2114
+ setButtomHei(45);
2115
+ return;
2116
+ }
2117
+ } else {}
2075
2118
  //跟老师对话
2119
+ let roomList = contactsList;
2076
2120
  if (roomList.length > 0 && roomList[0].roomId != roomId) {
2077
2121
  sendToTeacher(2);
2078
2122
  } else {
2079
- sendMessage('', 0);
2123
+ setAnswerMode(-1);
2124
+ setQuestionsList([]);
2125
+ setTeacherList([]);
2126
+ sendMessage("", 0);
2080
2127
  }
2081
2128
  setButtomHei(45);
2082
2129
  } else {
@@ -2115,7 +2162,7 @@ const CustomerService = (props)=>{
2115
2162
  className: styles.voice,
2116
2163
  children: [
2117
2164
  voiceRecordingStatus == 1 || voiceRecordingStatus == 3 ? /*#__PURE__*/ _jsx("i", {
2118
- className: `${!disabled ? styles.disabled : ''}`,
2165
+ className: `${!disabled ? styles.disabled : ""}`,
2119
2166
  onClick: ()=>{
2120
2167
  //开始录音
2121
2168
  if (!disabled) return;
@@ -2150,18 +2197,29 @@ const CustomerService = (props)=>{
2150
2197
  /*#__PURE__*/ _jsx("p", {
2151
2198
  className: `${styles.sending}`,
2152
2199
  children: /*#__PURE__*/ _jsx("i", {
2153
- className: `${!disabled || keyWord.trim() == '' ? styles.disabled : ''}`,
2200
+ className: `${!disabled || keyWord.trim() == "" ? styles.disabled : ""}`,
2154
2201
  onClick: ()=>{
2155
2202
  if (!disabled) return;
2156
2203
  setCitationContent({});
2157
2204
  setButtomHei(45);
2158
2205
  if (keyWord.trim() != "") {
2159
- setKeyWord('');
2206
+ //查找是否是召唤老师回答并有相应的老师名称
2207
+ if (answerMode == 1 && teacherList.length > 0) {
2208
+ let list = teacherList.filter((v)=>v.name == keyWord.trim());
2209
+ if (list.length > 0) {
2210
+ //直接进入召唤老师回答模式
2211
+ enterTeacherChat(list[0]);
2212
+ setButtomHei(45);
2213
+ return;
2214
+ }
2215
+ }
2216
+ setKeyWord("");
2160
2217
  //跟老师对话
2218
+ let roomList = contactsList;
2161
2219
  if (roomList.length > 0 && roomList[0].roomId != roomId) {
2162
2220
  sendToTeacher(2);
2163
2221
  } else {
2164
- sendMessage('', 0);
2222
+ sendMessage("", 0);
2165
2223
  }
2166
2224
  onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
2167
2225
  }
@@ -2172,6 +2230,32 @@ const CustomerService = (props)=>{
2172
2230
  ]
2173
2231
  });
2174
2232
  };
2233
+ //进入与老师的聊天
2234
+ const enterTeacherChat = (item)=>{
2235
+ setTeacherList([]);
2236
+ //提问的问题
2237
+ setProblem({
2238
+ question: problem.question,
2239
+ user: item.uid
2240
+ });
2241
+ setKeyWord("");
2242
+ //setUpdateRecords(true);
2243
+ setAnswerMode(-1);
2244
+ setChatWith(item);
2245
+ let roomList = contactsList;
2246
+ let list = roomList.filter((e)=>e.sender == item.uid);
2247
+ setShowContacts(true);
2248
+ if (list.length > 0) {
2249
+ setRoomId(list[0].roomId); //已有聊天室
2250
+ } else {
2251
+ createRooms(item.uid).then((res)=>{
2252
+ // childRef.current.roomsListTimer();
2253
+ roomsListTimer();
2254
+ let id = res.data.id;
2255
+ setRoomId(id); //新的聊天室id
2256
+ });
2257
+ }
2258
+ };
2175
2259
  //渲染联想问题及联想的老师名称
2176
2260
  const renderAssociationProblem = ()=>{
2177
2261
  if (answerMode == 1) {
@@ -2181,33 +2265,14 @@ const CustomerService = (props)=>{
2181
2265
  bottom: `${buttomHei + 14}px`
2182
2266
  },
2183
2267
  children: teacherList.map((item)=>{
2184
- let span = item.name.replaceAll(keyWord, ()=>{
2185
- return `<span class=${styles.sign}>${keyWord}</span>`;
2268
+ let span = item.name.replaceAll(new RegExp(keyWord, "ig"), (i)=>{
2269
+ return `<span class=${styles.sign}>${i}</span>`;
2186
2270
  });
2187
2271
  return /*#__PURE__*/ _jsx("p", {
2188
2272
  className: styles.item,
2189
2273
  children: /*#__PURE__*/ _jsx("span", {
2190
2274
  onClick: ()=>{
2191
- setTeacherList([]);
2192
- //提问的问题
2193
- setProblem({
2194
- question: problem.question,
2195
- user: item.uid
2196
- });
2197
- setKeyWord("");
2198
- //setUpdateRecords(true);
2199
- setAnswerMode(-1);
2200
- setChatWith(item);
2201
- let list = roomList.filter((e)=>e.sender == item.uid);
2202
- if (list.length > 0) {
2203
- setRoomId(list[0].roomId); //已有聊天室
2204
- } else {
2205
- createRooms(item.uid).then((res)=>{
2206
- childRef.current.roomsListTimer();
2207
- let id = res.data.id;
2208
- setRoomId(id); //新的聊天室id
2209
- });
2210
- }
2275
+ enterTeacherChat(item);
2211
2276
  },
2212
2277
  dangerouslySetInnerHTML: {
2213
2278
  __html: span
@@ -2223,8 +2288,8 @@ const CustomerService = (props)=>{
2223
2288
  bottom: `${buttomHei + 6}px`
2224
2289
  },
2225
2290
  children: questionsList.map((item)=>{
2226
- let span = item.question.replaceAll(keyWord, ()=>{
2227
- return `<span class=${styles.sign}>${keyWord}</span>`;
2291
+ let span = item.question.replaceAll(new RegExp(keyWord, "ig"), (i)=>{
2292
+ return `<span class=${styles.sign}>${i}</span>`;
2228
2293
  });
2229
2294
  return /*#__PURE__*/ _jsx("p", {
2230
2295
  className: styles.item,
@@ -2255,20 +2320,22 @@ const CustomerService = (props)=>{
2255
2320
  getHistoryMessage(page, 1);
2256
2321
  } else {
2257
2322
  setRoomId(renewRoomId);
2258
- if (childRef.current) {
2259
- if (receiver != mid) {
2260
- createRooms(receiver);
2261
- }
2262
- setTimeout(()=>{
2263
- childRef.current.roomsListTimer();
2264
- }, 500);
2323
+ // if (childRef.current) {
2324
+ if (receiver != mid) {
2325
+ createRooms(receiver);
2265
2326
  }
2327
+ setTimeout(()=>{
2328
+ // childRef.current.roomsListTimer();
2329
+ roomsListTimer();
2330
+ }, 500);
2331
+ // }
2266
2332
  }
2333
+ setShowContacts(true);
2267
2334
  };
2268
2335
  return /*#__PURE__*/ _jsxs(_Fragment, {
2269
2336
  children: [
2270
2337
  /*#__PURE__*/ _jsxs(Drawer, {
2271
- title: "智能问答",
2338
+ title: "AI助手",
2272
2339
  width: 560,
2273
2340
  onClose: ()=>{
2274
2341
  onCancel();
@@ -2293,9 +2360,9 @@ const CustomerService = (props)=>{
2293
2360
  onClose: ()=>{
2294
2361
  setShowContacts(false);
2295
2362
  },
2296
- // roomIdAi={roomIdAi}
2297
2363
  switchChatRoom: switchChatRoom,
2298
- saveContactsList: saveContactsList,
2364
+ // saveContactsList={saveContactsList}
2365
+ contactsList: contactsList,
2299
2366
  ref: childRef
2300
2367
  })
2301
2368
  }),
@@ -2352,7 +2419,7 @@ const CustomerService = (props)=>{
2352
2419
  ]
2353
2420
  }),
2354
2421
  /*#__PURE__*/ _jsxs(Modal, {
2355
- title: "智能问答",
2422
+ title: "AI助手",
2356
2423
  open: showType == 2 ? true : false,
2357
2424
  onCancel: ()=>{
2358
2425
  onCancel();
@@ -2391,7 +2458,8 @@ const CustomerService = (props)=>{
2391
2458
  setShowContacts(false);
2392
2459
  },
2393
2460
  switchChatRoom: switchChatRoom,
2394
- saveContactsList: saveContactsList,
2461
+ contactsList: contactsList,
2462
+ // saveContactsList={saveContactsList}
2395
2463
  ref: childRef
2396
2464
  }),
2397
2465
  /*#__PURE__*/ _jsxs("div", {
@@ -2447,7 +2515,7 @@ const CustomerService = (props)=>{
2447
2515
  /*#__PURE__*/ _jsx("div", {
2448
2516
  className: styles.user,
2449
2517
  children: /*#__PURE__*/ _jsx("p", {
2450
- children: roomList.filter((e)=>e.roomId == roomId).length > 0 && roomList.filter((e)=>e.roomId == roomId)[0].name != undefined ? roomList.filter((e)=>e.roomId == roomId)[0].name : '智能问答'
2518
+ children: showChatRoomName()
2451
2519
  })
2452
2520
  }),
2453
2521
  /*#__PURE__*/ _jsxs("div", {
@@ -2468,7 +2536,7 @@ const CustomerService = (props)=>{
2468
2536
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2469
2537
  setFirstLoad(false);
2470
2538
  setShowType(4);
2471
- childRef.current.roomsListTimer();
2539
+ // childRef.current.roomsListTimer();
2472
2540
  },
2473
2541
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
2474
2542
  }),
@@ -2536,17 +2604,18 @@ const CustomerService = (props)=>{
2536
2604
  onClose: ()=>{
2537
2605
  setShowContacts(false);
2538
2606
  },
2607
+ contactsList: contactsList,
2539
2608
  switchChatRoom: switchChatRoom,
2540
- saveContactsList: saveContactsList,
2609
+ // saveContactsList={saveContactsList}
2541
2610
  ref: childRef
2542
2611
  })
2543
2612
  })
2544
2613
  ]
2545
- }) : '',
2614
+ }) : "",
2546
2615
  showType == 4 && /*#__PURE__*/ _jsxs(_Fragment, {
2547
2616
  children: [
2548
2617
  /*#__PURE__*/ _jsxs(Modal, {
2549
- title: "智能问答",
2618
+ title: "AI助手",
2550
2619
  open: true,
2551
2620
  onCancel: ()=>{
2552
2621
  onCancel();
@@ -2584,8 +2653,9 @@ const CustomerService = (props)=>{
2584
2653
  onClose: ()=>{
2585
2654
  setShowContacts(false);
2586
2655
  },
2656
+ contactsList: contactsList,
2587
2657
  switchChatRoom: switchChatRoom,
2588
- saveContactsList: saveContactsList,
2658
+ // saveContactsList={saveContactsList}
2589
2659
  ref: childRef
2590
2660
  }),
2591
2661
  /*#__PURE__*/ _jsxs("div", {
@@ -2641,7 +2711,7 @@ const CustomerService = (props)=>{
2641
2711
  /*#__PURE__*/ _jsx("div", {
2642
2712
  className: styles.user,
2643
2713
  children: /*#__PURE__*/ _jsx("p", {
2644
- children: roomList.filter((e)=>e.roomId == roomId).length > 0 && !roomList.filter((e)=>e.roomId == roomId)[0].name ? roomList.filter((e)=>e.roomId == roomId)[0].name : '智能问答'
2714
+ children: showChatRoomName()
2645
2715
  })
2646
2716
  }),
2647
2717
  /*#__PURE__*/ _jsxs("div", {
@@ -2660,7 +2730,7 @@ const CustomerService = (props)=>{
2660
2730
  onClick: ()=>{
2661
2731
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2662
2732
  setShowType(4);
2663
- childRef.current.roomsListTimer();
2733
+ // childRef.current.roomsListTimer();
2664
2734
  },
2665
2735
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
2666
2736
  }),
@@ -2717,8 +2787,9 @@ const CustomerService = (props)=>{
2717
2787
  onClose: ()=>{
2718
2788
  setShowContacts(false);
2719
2789
  },
2790
+ contactsList: contactsList,
2720
2791
  switchChatRoom: switchChatRoom,
2721
- saveContactsList: saveContactsList,
2792
+ // saveContactsList={saveContactsList}
2722
2793
  ref: childRef
2723
2794
  })
2724
2795
  })