bhd-components 0.6.1 → 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/{ab2a98d6.esm.es5.development.js → a0cd97b9.esm.es5.development.js} +1 -1
  2. package/dist/{b8edd934.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 +515 -384
  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 -77
  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 +144 -81
  17. package/es2017/customerService/index.module.less +496 -5
  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 -66
  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} +64 -17
  28. package/esm/customerService/index.d.ts +3 -3
  29. package/esm/customerService/index.js +176 -111
  30. package/esm/customerService/index.module.less +496 -5
  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 -206
  35. package/es2017/customerService/historyFun/index.module.less +0 -223
  36. package/esm/customerService/contactsList/index.module.less +0 -206
  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,37 +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 [firstLoading, setFirstLoading] = useState(true);
13
- // const [type,setType] = useState(0);
14
13
  let timer = useRef(null); //文本框输入时
15
14
  //获取聊天室列表
16
15
  useEffect(()=>{
17
16
  roomsListTimer();
18
- if (roomId != '') {
19
- setNewRoomId(roomId);
20
- }
21
17
  return ()=>{
22
18
  clearTimeout(timer.current);
23
19
  };
24
20
  }, []);
21
+ // //获取聊天室列表
22
+ // useEffect(() => {
23
+ // roomsListTimer();
24
+ // }, [contactsList]);
25
25
  useImperativeHandle(ref, ()=>({
26
26
  roomsListTimer: ()=>{
27
27
  return roomsListTimer();
28
28
  }
29
29
  }));
30
- // useEffect(()=>{
31
- // //重新调用接口
32
- // console.log(44444444,contactsList)
33
- // roomsListTimer();
34
- // },[type])
35
30
  const roomsListTimer = ()=>{
36
31
  if (timer != null) clearTimeout(timer.current);
37
32
  timer.current = setTimeout(()=>roomsListTimer(), 60000);
@@ -47,7 +42,6 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
47
42
  }).then((res)=>{
48
43
  if (res.data) {
49
44
  let list = res.data.contacts;
50
- // let newMessage = false;
51
45
  setContactsList((contactsList)=>{
52
46
  list = list.map((item, index)=>{
53
47
  let c_list = contactsList.filter((e)=>e.sender == item.sender);
@@ -60,42 +54,22 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
60
54
  return list;
61
55
  });
62
56
  getUserInfo(list);
63
- // if(firstLoading){
64
- // setFirstLoading(false);
65
- // let isRoom = false;
66
- // for (let index = 0; index < list.length; index++) {
67
- // let count = list[index].unreadCount;
68
- // if(count > 0 && list[index].roomId == roomId){
69
- // isRoom = true;
70
- // //在当前窗口
71
- // return null;
72
- // }else if(count > 0){
73
- // isRoom = true;
74
- // switchChatRoom(list[index].roomId, "");
75
- // setContactsList((contactsList)=>{
76
- // let new_list = contactsList;
77
- // new_list = new_list.map((item)=>{
78
- // if(item.roomId == list[index].roomId){
79
- // return {
80
- // ...item,
81
- // unreadCount:0,
82
- // }
83
- // }else{
84
- // return item;
85
- // }
86
- // })
87
- // return new_list;
88
- // })
89
- // return null;
90
- // }
91
- // }
92
- // }
93
57
  saveContactsList(list);
94
58
  }
95
59
  });
96
60
  };
97
61
  //删除聊天室
98
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
+ });
99
73
  http.delete(`${urllocation}/chat-service/public/v1.0/rooms/${roomId}`, {
100
74
  headers: {
101
75
  "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
@@ -103,22 +77,12 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
103
77
  }
104
78
  }).then((res)=>{
105
79
  roomsListTimer();
106
- // let contactsList;
107
- // setContactsList((list)=>{
108
- // contactsList = list.filter(e=>e.roomId != roomId);
109
- // //切换到AI聊天窗口
110
- // if(roomId == props.roomId){
111
- // switchChatRoom(contactsList[0].roomId, "");
112
- // }
113
- // return contactsList;
114
- // })
115
- // saveContactsList(contactsList);
116
80
  });
117
81
  };
118
82
  //获取老师的信息等
119
83
  const getUserInfo = (list)=>{
120
84
  list.map((item, i)=>{
121
- if (!item.name && !item.headImg && item.sender != 'AI') {
85
+ if (!item.name && !item.headImg && item.sender != "AI") {
122
86
  getUserName(item.sender).then((res)=>{
123
87
  if (res.data) {
124
88
  let list;
@@ -151,16 +115,15 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
151
115
  };
152
116
  return type == 2 || type == 4 ? //联系人展开
153
117
  /*#__PURE__*/ _jsxs("div", {
154
- className: styles.teacher_layout_modal,
118
+ className: `${styles.teacher_layout_modal} ${type == 4 ? styles.teacher_layout_modal_newlabo : ""}`,
155
119
  children: [
156
120
  /*#__PURE__*/ _jsx("div", {
157
121
  className: styles.top,
158
122
  children: /*#__PURE__*/ _jsxs("div", {
159
- 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 : ""}`,
160
124
  onClick: ()=>{
161
- setNewRoomId(contactsList[0].roomId);
162
125
  switchChatRoom(contactsList[0].roomId, "");
163
- roomsListTimer();
126
+ // roomsListTimer();
164
127
  },
165
128
  children: [
166
129
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -173,7 +136,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
173
136
  "AI助手",
174
137
  /*#__PURE__*/ _jsx("span", {
175
138
  className: styles.time,
176
- children: contactsList.length > 0 && getDataTime(contactsList[0].createdAt)
139
+ children: contactsList.length > 0 && contactsList[0].createdAt != undefined && getDataTime(contactsList[0].createdAt)
177
140
  })
178
141
  ]
179
142
  }),
@@ -190,12 +153,37 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
190
153
  className: styles.bottom,
191
154
  children: contactsList.map((item, index)=>{
192
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
+ }
193
164
  return /*#__PURE__*/ _jsxs("div", {
194
- 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 : ""}`,
195
166
  onClick: ()=>{
196
- setNewRoomId(item.roomId);
197
167
  switchChatRoom(item.roomId, "");
198
- 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);
199
187
  },
200
188
  children: [
201
189
  /*#__PURE__*/ _jsx("img", {
@@ -207,10 +195,15 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
207
195
  /*#__PURE__*/ _jsxs("p", {
208
196
  className: styles.message,
209
197
  children: [
210
- item.name,
211
- 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", {
212
205
  className: styles.num,
213
- children: item.unreadCount > 99 ? '99+' : item.unreadCount
206
+ children: item.unreadCount > 99 ? "99+" : item.unreadCount
214
207
  }),
215
208
  /*#__PURE__*/ _jsx("span", {
216
209
  className: styles.time,
@@ -230,7 +223,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
230
223
  return null;
231
224
  }
232
225
  })
233
- }) : ''
226
+ }) : ""
234
227
  ]
235
228
  }) : /*#__PURE__*/ _jsxs("div", {
236
229
  className: `${styles.teacher_layout} ${type == 3 ? styles.teacher_layout_newlabo : ""}`,
@@ -250,18 +243,17 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
250
243
  /*#__PURE__*/ _jsx(CustomRetract, {}),
251
244
  /*#__PURE__*/ _jsx("p", {
252
245
  style: {
253
- marginTop: '8px'
246
+ marginTop: "8px"
254
247
  },
255
248
  children: "收起"
256
249
  })
257
250
  ]
258
251
  }),
259
252
  /*#__PURE__*/ _jsxs("div", {
260
- 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 : ""}`,
261
254
  onClick: ()=>{
262
- setNewRoomId(contactsList[0].roomId);
263
255
  switchChatRoom(contactsList[0].roomId, "");
264
- roomsListTimer();
256
+ // roomsListTimer();
265
257
  },
266
258
  children: [
267
259
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -277,22 +269,45 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
277
269
  children: contactsList.map((item, index)=>{
278
270
  if (index != 0) {
279
271
  return /*#__PURE__*/ _jsxs("div", {
280
- 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 : ""}`,
281
273
  onClick: ()=>{
282
- setNewRoomId(item.roomId);
283
274
  switchChatRoom(item.roomId, "");
284
- 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);
285
295
  },
286
296
  children: [
287
297
  /*#__PURE__*/ _jsx("img", {
288
298
  src: item.headImg
289
299
  }),
290
300
  /*#__PURE__*/ _jsx("p", {
291
- 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
292
307
  }),
293
- 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", {
294
309
  className: styles.num,
295
- children: item.unreadCount > 99 ? '99+' : item.unreadCount
310
+ children: item.unreadCount > 99 ? "99+" : item.unreadCount
296
311
  }),
297
312
  // 没有消息时,可点击删除
298
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,47 +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
- const [userNameObj, setUserNameObj] = useState([]); //根据用户id,存储一些用户名
16
15
  const [showLoadingState, setShowLoadingState] = useState(1); //1,初始状态,2、无数据 ,3、不显示图片
16
+ const [pageNum, setPageNum] = useState(1);
17
+ const [pageCount, setPageCount] = useState(0);
17
18
  const [load, setLoad] = useState(false);
18
19
  const timer = useRef(null); //文本框输入时
19
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]);
20
49
  useEffect(()=>{
21
50
  setKeyHistoryMessageList((list)=>{
22
- console.log(objName, 4444455555);
23
51
  let newList = list.map((item)=>{
24
52
  let name = '';
25
53
  let nameList = objName.current.filter((a)=>a.id == item.receiver);
26
54
  if (nameList.length > 0) {
27
55
  name = nameList[0].name;
28
56
  }
29
- console.log(name, 77777);
30
57
  return _object_spread_props(_object_spread({}, item), {
31
58
  name: name
32
59
  });
33
60
  });
34
- console.log(newList, 4444444444);
35
61
  return newList;
36
62
  });
37
63
  }, [
38
64
  load
39
65
  ]);
40
66
  //获取搜索中的历史消息记录
41
- const getKeyHistoryMessage = (keyWordProblem)=>{
67
+ const getKeyHistoryMessage = (keyWordProblem, page = 1)=>{
42
68
  if (roomId == "") return;
69
+ setLoad(false);
70
+ setKeyHistoryMessageList([]);
43
71
  return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
44
72
  params: {
45
73
  roomId: "",
46
74
  message: keyWordProblem,
47
- page: 1,
48
- maxPageSize: 300,
75
+ page: page,
76
+ maxPageSize: 1000,
49
77
  direction: "desc"
50
78
  },
51
79
  headers: {
@@ -53,11 +81,16 @@ const HistoryFun = (props)=>{
53
81
  "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
54
82
  }
55
83
  }).then((res)=>{
56
- console.log(res.data, 3434378);
57
84
  if (res.data.messages.length > 0) {
85
+ let total = res.data.total;
86
+ let maxPageSize = 20;
87
+ setPageCount(Math.ceil(total / maxPageSize));
58
88
  setShowLoadingState(3);
59
89
  let dataList = res.data.messages;
60
- setKeyHistoryMessageList(dataList);
90
+ setKeyHistoryMessageList((list)=>{
91
+ let newList = list.concat(dataList);
92
+ return newList;
93
+ });
61
94
  getUserName(dataList);
62
95
  } else {
63
96
  // setKeyHistoryMessageList([]);
@@ -88,7 +121,7 @@ const HistoryFun = (props)=>{
88
121
  return pageNumber;
89
122
  };
90
123
  //根据index,计算历史数据在第几页
91
- const calculationData = (roomId, index, id, sender)=>{
124
+ const calculationData = (roomId, id, receiver)=>{
92
125
  allData(roomId).then((res)=>{
93
126
  // console.log(res.data.messages,'11111111')
94
127
  if (res.data) {
@@ -102,7 +135,10 @@ const HistoryFun = (props)=>{
102
135
  }
103
136
  });
104
137
  const pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
105
- console.log(roomId, pageNumber, id, "第几页第几页第几页第几页第几页第几页");
138
+ // console.log(
139
+ // roomId, pageNumber, id,
140
+ // "第几页第几页第几页第几页第几页第几页"
141
+ // );
106
142
  loadSpecifiedData(roomId, pageNumber, id, receiver);
107
143
  onClose();
108
144
  setKeyWordProblem("");
@@ -202,6 +238,7 @@ const HistoryFun = (props)=>{
202
238
  }),
203
239
  /*#__PURE__*/ _jsxs("div", {
204
240
  className: styles.main_list,
241
+ id: "history_list",
205
242
  children: [
206
243
  showLoadingState == 1 && /*#__PURE__*/ _jsxs("div", {
207
244
  className: styles.no_data,
@@ -240,10 +277,19 @@ const HistoryFun = (props)=>{
240
277
  } else {
241
278
  name = item.name;
242
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
+ }
243
288
  return /*#__PURE__*/ _jsxs("div", {
244
289
  className: styles.list,
245
290
  onClick: ()=>{
246
- calculationData(item.roomId, item.messageIdWithinRoom, item.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;