bhd-components 0.6.2 → 0.6.3

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 (39) hide show
  1. package/dist/{9eaa797e.esm.es5.development.js → a0cd97b9.esm.es5.development.js} +1 -1
  2. package/dist/{587f2764.esm.es5.production.js → e88a10a0.esm.es5.production.js} +1 -1
  3. package/dist/index.esm.es5.development.css +1711 -827
  4. package/dist/index.esm.es5.development.js +511 -383
  5. package/dist/index.esm.es5.production.css +1 -1
  6. package/dist/index.esm.es5.production.js +1 -1
  7. package/es2017/bhdSelect/index.d.ts +3 -0
  8. package/es2017/bhdSelect/index.js +18 -13
  9. package/es2017/bhdSelect/index.module.less +4 -1
  10. package/es2017/customerService/{contactsList/index.js → contactsList.js} +92 -76
  11. package/es2017/customerService/function.d.ts +1 -1
  12. package/es2017/customerService/function.js +10 -2
  13. package/es2017/customerService/{historyFun/index.d.ts → historyFun.d.ts} +0 -1
  14. package/es2017/customerService/{historyFun/index.js → historyFun.js} +62 -16
  15. package/es2017/customerService/index.d.ts +3 -3
  16. package/es2017/customerService/index.js +143 -82
  17. package/es2017/customerService/index.module.less +496 -6
  18. package/es2017/customerService/index2.module.less +1282 -0
  19. package/es2017/typings.d.ts +12 -0
  20. package/esm/bhdSelect/index.d.ts +3 -0
  21. package/esm/bhdSelect/index.js +18 -13
  22. package/esm/bhdSelect/index.module.less +4 -1
  23. package/esm/customerService/{contactsList/index.js → contactsList.js} +83 -65
  24. package/esm/customerService/function.d.ts +1 -1
  25. package/esm/customerService/function.js +10 -1
  26. package/esm/customerService/{historyFun/index.d.ts → historyFun.d.ts} +0 -1
  27. package/esm/customerService/{historyFun/index.js → historyFun.js} +63 -16
  28. package/esm/customerService/index.d.ts +3 -3
  29. package/esm/customerService/index.js +173 -112
  30. package/esm/customerService/index.module.less +496 -6
  31. package/esm/customerService/index2.module.less +1282 -0
  32. package/esm/typings.d.ts +12 -0
  33. package/package.json +1 -1
  34. package/es2017/customerService/contactsList/index.module.less +0 -208
  35. package/es2017/customerService/historyFun/index.module.less +0 -223
  36. package/esm/customerService/contactsList/index.module.less +0 -208
  37. package/esm/customerService/historyFun/index.module.less +0 -223
  38. /package/es2017/customerService/{contactsList/index.d.ts → contactsList.d.ts} +0 -0
  39. /package/esm/customerService/{contactsList/index.d.ts → contactsList.d.ts} +0 -0
@@ -22,6 +22,9 @@ interface BhdSelectProps extends SelectProps {
22
22
  useType?: string;
23
23
  listHeight?: number;
24
24
  popupMatchSelectWidth?: number;
25
+ dropdownStyle?: {
26
+ width: number;
27
+ };
25
28
  }
26
29
  declare const BhdSelect: {
27
30
  (props: BhdSelectProps): React.JSX.Element;
@@ -26,7 +26,7 @@ const BhdSelect = (props)=>{
26
26
  const [optionHei, setOptionHei] = useState(0); //option的宽度
27
27
  const [filterValue, setFilterValue] = useState(""); //下拉搜索的内容
28
28
  const [filterChildren, setfilterChildren] = useState([]);
29
- // const [selectWidth,setSelectWidth] = useState(0);//下拉框的宽度
29
+ const [selectWidth, setSelectWidth] = useState(0); //下拉框的宽度
30
30
  const renderSuffixIcon = ()=>{
31
31
  switch(arrowType){
32
32
  case "table":
@@ -197,11 +197,11 @@ const BhdSelect = (props)=>{
197
197
  };
198
198
  useEffect(()=>{
199
199
  // console.log(34343434,props);
200
- // if(props.popupMatchSelectWidth){
201
- // setSelectWidth(props.popupMatchSelectWidth);
202
- // }else{
203
- // // console.log(bhdSelectRef.current.getBoundingClientRect(),555555555);
204
- // }
200
+ if (props.popupMatchSelectWidth) {
201
+ setSelectWidth(props.popupMatchSelectWidth);
202
+ } else {
203
+ // console.log(bhdSelectRef.current.getBoundingClientRect(),555555555);
204
+ }
205
205
  filterOption();
206
206
  window.addEventListener("resize", initHeight);
207
207
  return ()=>{
@@ -217,7 +217,11 @@ const BhdSelect = (props)=>{
217
217
  let config = _object_spread_props(_object_spread({}, props), {
218
218
  listHeight: optionHei,
219
219
  popupClassName: `${styles.bhdSelect_option} ${popupClassName || ""} `,
220
- suffixIcon: suffixIcon ? suffixIcon : renderSuffixIcon()
220
+ suffixIcon: suffixIcon ? suffixIcon : renderSuffixIcon(),
221
+ popupMatchSelectWidth: selectWidth,
222
+ dropdownStyle: _object_spread_props(_object_spread({}, props.dropdownStyle), {
223
+ width: selectWidth
224
+ })
221
225
  });
222
226
  delete config.mask;
223
227
  delete config.className;
@@ -262,12 +266,13 @@ const BhdSelect = (props)=>{
262
266
  }
263
267
  //表格中使用下拉列表,定义下拉列表宽度
264
268
  // console.log(props.dropdownStyle,'sdsddfdfdf');
265
- // if(props.dropdownStyle != undefined && props.dropdownStyle.width != undefined){
266
- // setSelectWidth(props.dropdownStyle.width)
267
- // }else if( (props.dropdownStyle == undefined || props.dropdownStyle.width == undefined) && useType === 'table'){
268
- // console.log(bhdSelectRef.current.parentNode.getBoundingClientRect().width-4,33333);
269
- // setSelectWidth(bhdSelectRef.current.parentNode.getBoundingClientRect().width-4)
270
- // }
269
+ if (props.dropdownStyle != undefined && props.dropdownStyle.width != undefined) {
270
+ setSelectWidth(props.dropdownStyle.width);
271
+ } else if ((props.dropdownStyle == undefined || props.dropdownStyle.width == undefined) && useType === 'table') {
272
+ try {
273
+ setSelectWidth(bhdSelectRef.current.parentNode.getBoundingClientRect().width + 14);
274
+ } catch (error) {}
275
+ }
271
276
  props.onMouseEnter && props.onMouseEnter(e);
272
277
  },
273
278
  children: filterChildren
@@ -105,10 +105,13 @@
105
105
  width: 14px;
106
106
  .bhd-btn {
107
107
  border: none;
108
- height: 10px;
108
+ height: 16px;
109
109
  line-height: 16px;
110
110
  width: 14px;
111
111
  }
112
+ .bhd-btn-default{
113
+ box-shadow: none !important;
114
+ }
112
115
  }
113
116
 
114
117
  }
@@ -1,36 +1,32 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
2
3
  import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
3
4
  import React, { useEffect, useState, useRef, useImperativeHandle, forwardRef } from "react";
4
5
  import styles from "./index.module.less";
5
- import { CustomAiIcon, CustomRetract } from "../../icons/index";
6
+ import { Tooltip } from "antd";
7
+ import { CustomAiIcon, CustomRetract } from "../icons/index";
6
8
  import { CloseOutlined } from "@ant-design/icons";
7
- import { getDataTime } from "../function"; //录音使用文件
9
+ import { getDataTime, getByteLen } from "./function"; //录音使用文件
8
10
  const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
9
11
  let { type , roomId , userData , http , urllocation , onClose , switchChatRoom , saveContactsList } = props;
10
12
  const [contactsList, setContactsList] = useState([]); //老师列表
11
- const [newRoomId, setNewRoomId] = useState("");
12
- // const [type,setType] = useState(0);
13
13
  let timer = useRef(null); //文本框输入时
14
14
  //获取聊天室列表
15
15
  useEffect(()=>{
16
16
  roomsListTimer();
17
- if (roomId != '') {
18
- setNewRoomId(roomId);
19
- }
20
17
  return ()=>{
21
18
  clearTimeout(timer.current);
22
19
  };
23
20
  }, []);
21
+ // //获取聊天室列表
22
+ // useEffect(() => {
23
+ // roomsListTimer();
24
+ // }, [contactsList]);
24
25
  useImperativeHandle(ref, ()=>({
25
26
  roomsListTimer: ()=>{
26
27
  return roomsListTimer();
27
28
  }
28
29
  }));
29
- // useEffect(()=>{
30
- // //重新调用接口
31
- // console.log(44444444,contactsList)
32
- // roomsListTimer();
33
- // },[type])
34
30
  const roomsListTimer = ()=>{
35
31
  if (timer != null) clearTimeout(timer.current);
36
32
  timer.current = setTimeout(()=>roomsListTimer(), 60000);
@@ -46,7 +42,6 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
46
42
  }).then((res)=>{
47
43
  if (res.data) {
48
44
  let list = res.data.contacts;
49
- // let newMessage = false;
50
45
  setContactsList((contactsList)=>{
51
46
  list = list.map((item, index)=>{
52
47
  let c_list = contactsList.filter((e)=>e.sender == item.sender);
@@ -59,42 +54,22 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
59
54
  return list;
60
55
  });
61
56
  getUserInfo(list);
62
- // if(firstLoading){
63
- // setFirstLoading(false);
64
- // let isRoom = false;
65
- // for (let index = 0; index < list.length; index++) {
66
- // let count = list[index].unreadCount;
67
- // if(count > 0 && list[index].roomId == roomId){
68
- // isRoom = true;
69
- // //在当前窗口
70
- // return null;
71
- // }else if(count > 0){
72
- // isRoom = true;
73
- // switchChatRoom(list[index].roomId, "");
74
- // setContactsList((contactsList)=>{
75
- // let new_list = contactsList;
76
- // new_list = new_list.map((item)=>{
77
- // if(item.roomId == list[index].roomId){
78
- // return {
79
- // ...item,
80
- // unreadCount:0,
81
- // }
82
- // }else{
83
- // return item;
84
- // }
85
- // })
86
- // return new_list;
87
- // })
88
- // return null;
89
- // }
90
- // }
91
- // }
92
57
  saveContactsList(list);
93
58
  }
94
59
  });
95
60
  };
96
61
  //删除聊天室
97
62
  const deleteRoom = (roomId)=>{
63
+ let contactsList;
64
+ setContactsList((list)=>{
65
+ contactsList = list.filter((e)=>e.roomId != roomId);
66
+ //切换到AI聊天窗口
67
+ if (roomId == props.roomId) {
68
+ switchChatRoom(contactsList[0].roomId, "");
69
+ }
70
+ saveContactsList(contactsList);
71
+ return contactsList;
72
+ });
98
73
  http.delete(`${urllocation}/chat-service/public/v1.0/rooms/${roomId}`, {
99
74
  headers: {
100
75
  "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
@@ -102,22 +77,12 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
102
77
  }
103
78
  }).then((res)=>{
104
79
  roomsListTimer();
105
- // let contactsList;
106
- // setContactsList((list)=>{
107
- // contactsList = list.filter(e=>e.roomId != roomId);
108
- // //切换到AI聊天窗口
109
- // if(roomId == props.roomId){
110
- // switchChatRoom(contactsList[0].roomId, "");
111
- // }
112
- // return contactsList;
113
- // })
114
- // saveContactsList(contactsList);
115
80
  });
116
81
  };
117
82
  //获取老师的信息等
118
83
  const getUserInfo = (list)=>{
119
84
  list.map((item, i)=>{
120
- if (!item.name && !item.headImg && item.sender != 'AI') {
85
+ if (!item.name && !item.headImg && item.sender != "AI") {
121
86
  getUserName(item.sender).then((res)=>{
122
87
  if (res.data) {
123
88
  let list;
@@ -150,16 +115,15 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
150
115
  };
151
116
  return type == 2 || type == 4 ? //联系人展开
152
117
  /*#__PURE__*/ _jsxs("div", {
153
- className: styles.teacher_layout_modal,
118
+ className: `${styles.teacher_layout_modal} ${type == 4 ? styles.teacher_layout_modal_newlabo : ""}`,
154
119
  children: [
155
120
  /*#__PURE__*/ _jsx("div", {
156
121
  className: styles.top,
157
122
  children: /*#__PURE__*/ _jsxs("div", {
158
- className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != '' && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
123
+ className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
159
124
  onClick: ()=>{
160
- setNewRoomId(contactsList[0].roomId);
161
125
  switchChatRoom(contactsList[0].roomId, "");
162
- roomsListTimer();
126
+ // roomsListTimer();
163
127
  },
164
128
  children: [
165
129
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -172,7 +136,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
172
136
  "AI助手",
173
137
  /*#__PURE__*/ _jsx("span", {
174
138
  className: styles.time,
175
- children: contactsList.length > 0 && getDataTime(contactsList[0].createdAt)
139
+ children: contactsList.length > 0 && contactsList[0].createdAt != undefined && getDataTime(contactsList[0].createdAt)
176
140
  })
177
141
  ]
178
142
  }),
@@ -189,12 +153,37 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
189
153
  className: styles.bottom,
190
154
  children: contactsList.map((item, index)=>{
191
155
  if (index != 0) {
156
+ let time = '';
157
+ let currentTime = getDataTime(-1, 1); //当前时间
158
+ let updatedAt = getDataTime(item.createdAt, 1);
159
+ if (currentTime == updatedAt) {
160
+ time = getDataTime(item.createdAt, 2);
161
+ } else {
162
+ time = getDataTime(item.createdAt);
163
+ }
192
164
  return /*#__PURE__*/ _jsxs("div", {
193
- className: `${styles.ai} ${item.roomId != undefined && roomId != '' && item.roomId == roomId ? styles.active : ""}`,
165
+ className: `${styles.ai} ${item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""}`,
194
166
  onClick: ()=>{
195
- setNewRoomId(item.roomId);
196
167
  switchChatRoom(item.roomId, "");
197
- roomsListTimer();
168
+ // roomsListTimer();
169
+ let newList = [];
170
+ setContactsList((list)=>{
171
+ newList = list;
172
+ newList = newList.map((v)=>{
173
+ if (v.roomId == item.roomId) {
174
+ return _object_spread_props(_object_spread({}, v), {
175
+ unreadCount: 0
176
+ });
177
+ } else {
178
+ return v;
179
+ }
180
+ });
181
+ return newList;
182
+ });
183
+ // console.log(newList,9999999999)
184
+ setTimeout(()=>{
185
+ saveContactsList(newList);
186
+ }, 100);
198
187
  },
199
188
  children: [
200
189
  /*#__PURE__*/ _jsx("img", {
@@ -206,10 +195,15 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
206
195
  /*#__PURE__*/ _jsxs("p", {
207
196
  className: styles.message,
208
197
  children: [
209
- item.name,
210
- item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != '' && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
198
+ item.name != undefined && getByteLen(item.name) >= 20 ? /*#__PURE__*/ _jsx(Tooltip, {
199
+ overlayClassName: `${styles.popover_main_content_name}`,
200
+ title: item.name,
201
+ placement: "top",
202
+ children: item.name
203
+ }) : item.name,
204
+ item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != "" && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
211
205
  className: styles.num,
212
- children: item.unreadCount > 99 ? '99+' : item.unreadCount
206
+ children: item.unreadCount > 99 ? "99+" : item.unreadCount
213
207
  }),
214
208
  /*#__PURE__*/ _jsx("span", {
215
209
  className: styles.time,
@@ -229,7 +223,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
229
223
  return null;
230
224
  }
231
225
  })
232
- }) : ''
226
+ }) : ""
233
227
  ]
234
228
  }) : /*#__PURE__*/ _jsxs("div", {
235
229
  className: `${styles.teacher_layout} ${type == 3 ? styles.teacher_layout_newlabo : ""}`,
@@ -249,18 +243,17 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
249
243
  /*#__PURE__*/ _jsx(CustomRetract, {}),
250
244
  /*#__PURE__*/ _jsx("p", {
251
245
  style: {
252
- marginTop: '8px'
246
+ marginTop: "8px"
253
247
  },
254
248
  children: "收起"
255
249
  })
256
250
  ]
257
251
  }),
258
252
  /*#__PURE__*/ _jsxs("div", {
259
- className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != '' && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
253
+ className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
260
254
  onClick: ()=>{
261
- setNewRoomId(contactsList[0].roomId);
262
255
  switchChatRoom(contactsList[0].roomId, "");
263
- roomsListTimer();
256
+ // roomsListTimer();
264
257
  },
265
258
  children: [
266
259
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -276,22 +269,45 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
276
269
  children: contactsList.map((item, index)=>{
277
270
  if (index != 0) {
278
271
  return /*#__PURE__*/ _jsxs("div", {
279
- className: `${styles.ai} ${item.roomId != undefined && roomId != '' && item.roomId == roomId ? styles.active : ""}`,
272
+ className: `${styles.ai} ${item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""}`,
280
273
  onClick: ()=>{
281
- setNewRoomId(item.roomId);
282
274
  switchChatRoom(item.roomId, "");
283
- roomsListTimer();
275
+ // roomsListTimer();
276
+ //消息更改为已读
277
+ let newList = [];
278
+ setContactsList((list)=>{
279
+ newList = list;
280
+ newList = newList.map((v)=>{
281
+ if (v.roomId == item.roomId) {
282
+ return _object_spread_props(_object_spread({}, v), {
283
+ unreadCount: 0
284
+ });
285
+ } else {
286
+ return v;
287
+ }
288
+ });
289
+ return newList;
290
+ });
291
+ // console.log(newList,9999999999)
292
+ setTimeout(()=>{
293
+ saveContactsList(newList);
294
+ }, 100);
284
295
  },
285
296
  children: [
286
297
  /*#__PURE__*/ _jsx("img", {
287
298
  src: item.headImg
288
299
  }),
289
300
  /*#__PURE__*/ _jsx("p", {
290
- children: item.name
301
+ children: item.name != undefined && getByteLen(item.name) >= 10 ? /*#__PURE__*/ _jsx(Tooltip, {
302
+ overlayClassName: styles.popover_main_content_name,
303
+ title: item.name,
304
+ placement: "top",
305
+ children: item.name
306
+ }) : item.name
291
307
  }),
292
- item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != '' && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
308
+ item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != "" && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
293
309
  className: styles.num,
294
- children: item.unreadCount > 99 ? '99+' : item.unreadCount
310
+ children: item.unreadCount > 99 ? "99+" : item.unreadCount
295
311
  }),
296
312
  // 没有消息时,可点击删除
297
313
  !item.unreadCount && /*#__PURE__*/ _jsx("span", {
@@ -13,5 +13,5 @@ declare const readMessage: (roomId: number | string, urllocation: any, userData:
13
13
  declare const getByteLen: (val: string) => number;
14
14
  declare const serverUrl: () => string;
15
15
  declare const copyText: (text: string) => boolean;
16
- declare const getDataTime: (time: string | number | Date) => string;
16
+ declare const getDataTime: (time: string | number | Date, type?: number) => string;
17
17
  export { readMessage, getByteLen, serverUrl, copyText, getDataTime };
@@ -48,7 +48,9 @@ const copyText = (text)=>{
48
48
  return true;
49
49
  };
50
50
  //获取当前时间
51
- const getDataTime = (time)=>{
51
+ const getDataTime = (time, type = -1)=>{
52
+ //type = 1 ,获取当前年月日
53
+ //type = 2 ,只显示十 分
52
54
  try {
53
55
  let now;
54
56
  if (time != undefined && time != -1) {
@@ -64,7 +66,13 @@ const getDataTime = (time)=>{
64
66
  const minutes = String(now.getMinutes()).padStart(2, "0");
65
67
  const seconds = String(now.getSeconds()).padStart(2, "0");
66
68
  const currentDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
67
- return currentDateTime;
69
+ if (type == 1) {
70
+ return `${year}-${month}-${day}`;
71
+ } else if (type == 2) {
72
+ return `${hours}:${minutes}`;
73
+ } else {
74
+ return currentDateTime;
75
+ }
68
76
  } catch (error) {
69
77
  return '';
70
78
  }
@@ -8,7 +8,6 @@ interface data {
8
8
  urllocation: String;
9
9
  onClose: any;
10
10
  loadSpecifiedData: any;
11
- roomList: any;
12
11
  }
13
12
  declare const HistoryFun: (props: data) => JSX.Element;
14
13
  export default HistoryFun;
@@ -5,46 +5,75 @@ import React, { useEffect, useState, useRef } from "react";
5
5
  import styles from "./index.module.less";
6
6
  import "highlight.js/styles/default.css";
7
7
  import { Input } from "antd";
8
- import { CustomClose } from "../../icons/index";
8
+ import { CustomClose } from "../icons/index";
9
9
  import { SearchOutlined } from "@ant-design/icons";
10
- import { getDataTime } from "../function"; //录音使用文件
10
+ import { getDataTime } from "./function"; //录音使用文件
11
11
  const HistoryFun = (props)=>{
12
- let { type , roomId , userData , http , urllocation , onClose , loadSpecifiedData , roomList } = props;
12
+ let { type , roomId , userData , http , urllocation , onClose , loadSpecifiedData } = props;
13
13
  const [keyWordProblem, setKeyWordProblem] = useState(""); //搜索内容
14
14
  const [keyHistoryMessageList, setKeyHistoryMessageList] = useState([]); //搜索的历史记录
15
15
  const [showLoadingState, setShowLoadingState] = useState(1); //1,初始状态,2、无数据 ,3、不显示图片
16
+ const [pageNum, setPageNum] = useState(1);
17
+ const [pageCount, setPageCount] = useState(0);
16
18
  const [load, setLoad] = useState(false);
17
19
  const timer = useRef(null); //文本框输入时
18
20
  const objName = useRef([]);
21
+ // useEffect(() => {
22
+ // function handleScroll() {
23
+ // const container = document.getElementById('history_list');
24
+ // const scrollTop = container.scrollTop;
25
+ // const clientHeight = container.clientHeight;
26
+ // const scrollHeight = container.scrollHeight;
27
+ // // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
28
+ // // if((clientHeight + scrollTop + 10) >= scrollHeight && pageCount > pageNum && pageCount > 0){
29
+ // // // console.log(11111111,pageNumHistory)
30
+ // // let number = pageNum + 1;
31
+ // // console.log('到底部了22222',number)
32
+ // // setPageNum((pageNum) => {
33
+ // // return pageNum + 1;
34
+ // // });
35
+ // // getKeyHistoryMessage(keyWordProblem,number);
36
+ // // }
37
+ // }
38
+ // const content = document.getElementById('history_list');
39
+ // if (content) {
40
+ // content.addEventListener("scroll", handleScroll);
41
+ // }
42
+ // return () => {
43
+ // const content = document.getElementById('history_list');
44
+ // if (content) {
45
+ // content.removeEventListener("scroll", handleScroll);
46
+ // }
47
+ // };
48
+ // }, [keyHistoryMessageList]);
19
49
  useEffect(()=>{
20
50
  setKeyHistoryMessageList((list)=>{
21
- console.log(objName, 4444455555);
22
51
  let newList = list.map((item)=>{
23
52
  let name = '';
24
53
  let nameList = objName.current.filter((a)=>a.id == item.receiver);
25
54
  if (nameList.length > 0) {
26
55
  name = nameList[0].name;
27
56
  }
28
- console.log(name, 77777);
29
57
  return _object_spread_props(_object_spread({}, item), {
30
58
  name: name
31
59
  });
32
60
  });
33
- console.log(newList, 4444444444);
34
61
  return newList;
35
62
  });
36
63
  }, [
37
64
  load
38
65
  ]);
39
66
  //获取搜索中的历史消息记录
40
- const getKeyHistoryMessage = (keyWordProblem)=>{
67
+ const getKeyHistoryMessage = (keyWordProblem, page = 1)=>{
41
68
  if (roomId == "") return;
69
+ setLoad(false);
70
+ setKeyHistoryMessageList([]);
42
71
  return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
43
72
  params: {
44
73
  roomId: "",
45
74
  message: keyWordProblem,
46
- page: 1,
47
- maxPageSize: 300,
75
+ page: page,
76
+ maxPageSize: 1000,
48
77
  direction: "desc"
49
78
  },
50
79
  headers: {
@@ -52,11 +81,16 @@ const HistoryFun = (props)=>{
52
81
  "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
53
82
  }
54
83
  }).then((res)=>{
55
- console.log(res.data, 3434378);
56
84
  if (res.data.messages.length > 0) {
85
+ let total = res.data.total;
86
+ let maxPageSize = 20;
87
+ setPageCount(Math.ceil(total / maxPageSize));
57
88
  setShowLoadingState(3);
58
89
  let dataList = res.data.messages;
59
- setKeyHistoryMessageList(dataList);
90
+ setKeyHistoryMessageList((list)=>{
91
+ let newList = list.concat(dataList);
92
+ return newList;
93
+ });
60
94
  getUserName(dataList);
61
95
  } else {
62
96
  // setKeyHistoryMessageList([]);
@@ -87,7 +121,7 @@ const HistoryFun = (props)=>{
87
121
  return pageNumber;
88
122
  };
89
123
  //根据index,计算历史数据在第几页
90
- const calculationData = (roomId, index, id, receiver)=>{
124
+ const calculationData = (roomId, id, receiver)=>{
91
125
  allData(roomId).then((res)=>{
92
126
  // console.log(res.data.messages,'11111111')
93
127
  if (res.data) {
@@ -101,7 +135,10 @@ const HistoryFun = (props)=>{
101
135
  }
102
136
  });
103
137
  const pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
104
- console.log(roomId, pageNumber, id, "第几页第几页第几页第几页第几页第几页");
138
+ // console.log(
139
+ // roomId, pageNumber, id,
140
+ // "第几页第几页第几页第几页第几页第几页"
141
+ // );
105
142
  loadSpecifiedData(roomId, pageNumber, id, receiver);
106
143
  onClose();
107
144
  setKeyWordProblem("");
@@ -201,6 +238,7 @@ const HistoryFun = (props)=>{
201
238
  }),
202
239
  /*#__PURE__*/ _jsxs("div", {
203
240
  className: styles.main_list,
241
+ id: "history_list",
204
242
  children: [
205
243
  showLoadingState == 1 && /*#__PURE__*/ _jsxs("div", {
206
244
  className: styles.no_data,
@@ -239,11 +277,19 @@ const HistoryFun = (props)=>{
239
277
  } else {
240
278
  name = item.name;
241
279
  }
280
+ let time = '';
281
+ let currentTime = getDataTime(-1, 1); //当前时间
282
+ let updatedAt = getDataTime(item.updatedAt, 1);
283
+ if (currentTime == updatedAt) {
284
+ time = getDataTime(item.updatedAt, 2);
285
+ } else {
286
+ time = getDataTime(item.updatedAt);
287
+ }
242
288
  return /*#__PURE__*/ _jsxs("div", {
243
289
  className: styles.list,
244
290
  onClick: ()=>{
245
- let id = item.receiver == userData.mid ? item.sender : item.receiver;
246
- calculationData(item.roomId, item.messageIdWithinRoom, id, item.receiver);
291
+ let id = item.receiver; // == userData.mid ? item.sender : item.receiver
292
+ calculationData(item.roomId, item.id, id);
247
293
  },
248
294
  children: [
249
295
  /*#__PURE__*/ _jsxs("div", {
@@ -254,7 +300,7 @@ const HistoryFun = (props)=>{
254
300
  }),
255
301
  /*#__PURE__*/ _jsx("span", {
256
302
  className: styles.time,
257
- children: getDataTime(item.updatedAt)
303
+ children: time
258
304
  })
259
305
  ]
260
306
  }),
@@ -7,9 +7,9 @@ interface Service {
7
7
  onCancel?: () => {};
8
8
  serverName?: string;
9
9
  fetchEventSource?: any;
10
- initShowType?: string | number;
11
- stepIds: string;
12
- stepId: string | number;
10
+ initShowType?: number;
11
+ stepIds?: string;
12
+ stepId?: string | number;
13
13
  onEvent: (a: string, b: string, c: string) => {};
14
14
  }
15
15
  declare const CustomerService: (props: Service) => JSX.Element;