Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
352ce1d5
authored
Nov 02, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
remove unused code
parent
9a75d867
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
760 deletions
components/chat-list-model.vue
components/chat-list.vue
components/chat-list-model.vue
deleted
100644 → 0
View file @
9a75d867
<
template
>
<div
class=
"chat-list-con"
>
<div
class=
"chat-list h-100"
>
<div
class=
"chat-list-scroll"
>
<el-scrollbar
ref=
"scrollbar"
class=
"list-scroll no-bottom-scrollbar"
>
<div
v-for=
"item in chatRooms"
:key=
"'room_' + item.id"
class=
"chat-item"
:class=
"
{ selected: item.chat_id == activeId }"
@click="goToChatRoom(item)"
>
<div
class=
"chat-info"
>
<div
class=
"checkbox-wrap"
@
click
.
stop
v-if=
"showItemCheckbox"
>
<el-checkbox
v-model=
"item.checked"
></el-checkbox>
</div>
<div
class=
"w-100"
>
<div
class=
"
chat-info-left
d-flex
justify-content-between
align-items-center
"
>
<div
class=
"
chat-name
flex-fill
text-dot-dot-dot
"
>
<span>
{{
item
.
title
}}
</span>
</div>
<div
v-if=
"item.last_msg_ts"
class=
"chat-time"
>
{{
formatTimestamp
(
item
.
last_msg_ts
)
}}
</div>
</div>
<div
class=
"chat-msg text-dot-dot-dot"
>
{{
userNames
[
item
.
last_msg_sender
]
?
userNames
[
item
.
last_msg_sender
]
+
": "
:
""
}}{{
parseMesage
(
item
)
}}
</div>
</div>
</div>
</div>
<div
class=
"empty"
v-if=
"chatRooms && chatRooms.length
<
=
0
"
>
无接待
</div>
</el-scrollbar>
<div
class=
"d-flex align-items-center justify-content-center"
>
<el-pagination
class=
"page-comp"
@
size-change=
"handleSizeChange"
:page-size=
"pageSize"
:total=
"total"
:current-page
.
sync=
"currentPage"
@
current-change=
"getList"
:page-sizes=
"[10, 20, 50]"
:pager-count=
"5"
layout=
"total, prev, pager, next"
></el-pagination>
</div>
<div
class=
"action-row"
>
<el-button
v-if=
"showItemCheckbox"
@
click=
"toggle"
>
全选
</el-button
>
<el-button
v-if=
"!showItemCheckbox"
@
click=
"showItemCheckbox = true"
>
批量接待
</el-button
>
<el-button
v-if=
"showItemCheckbox"
@
click=
"batchStartReception"
type=
"primary"
>
确定接待
</el-button
>
<el-button
v-if=
"showItemCheckbox"
@
click=
"unselectAll"
>
取消
</el-button
>
<i
title=
"刷新"
class=
"refresh-icon"
@
click=
"getList"
:class=
"
refreshing ? 'el-icon-loading' : 'el-icon-refresh'
"
></i>
</div>
</div>
</div>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Prop
,
Ref
,
Vue
}
from
"vue-property-decorator"
;
import
{
parserMessage
}
from
"./controller"
;
import
{
EVENTS
}
from
"@/EventConsts"
;
import
{
chatStore
,
ChatStore
}
from
"@/customer-service/store/model"
;
import
{
formatTime
,
parseString2TimeValue
,
TimeFormatRule
,
}
from
"@/customer-service/utils/time"
;
import
{
Chat
as
ChatType
}
from
"@/customer-service/xim/models/chat"
;
import
xim
from
"@/customer-service/xim"
;
interface
SelectChatType
extends
ChatType
{
checked
?:
boolean
;
}
@
Component
({
components
:
{}
})
export
default
class
ModelChatList
extends
Vue
{
@
chatStore
.
Action
(
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
)
private
readonly
_createChat
!
:
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
;
private
chatList
:
SelectChatType
[]
=
[];
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_SAVE_MYSELF_ID
)
private
readonly
saveMyId
!
:
ChatStore
.
MUTATION_SAVE_MYSELF_ID
;
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_SET_CHAT_SOURCE
)
private
readonly
setSource
!
:
ChatStore
.
MUTATION_SET_CHAT_SOURCE
;
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_USERNAME
)
private
readonly
userNames
!
:
ChatStore
.
STATE_CHAT_USERNAME
;
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_SAVE_USERNAME
)
private
readonly
updateUserName
!
:
ChatStore
.
MUTATION_SAVE_USERNAME
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_CLEAR_CURRENT_CHAT_DATA
)
private
readonly
clearChatId
!
:
ChatStore
.
ACTION_CLEAR_CURRENT_CHAT_DATA
;
@
Prop
({
type
:
Number
,
default
:
-
1
})
private
selected
!
:
number
;
@
Prop
({
type
:
String
})
private
modelName
!
:
string
;
@
Prop
({
type
:
String
})
private
listName
!
:
string
;
@
Ref
(
"scrollbar"
)
private
scrollbar
:
Vue
&
{
update
:
()
=>
void
};
private
activeId
=
""
;
private
pageSize
=
10
;
private
total
=
0
;
private
currentPage
=
1
;
private
sseTs
=
0
;
private
showItemCheckbox
=
false
;
private
refreshing
=
false
;
private
get
chatRooms
()
{
return
this
.
chatList
.
sort
(
(
x
,
y
)
=>
parseString2TimeValue
((
y
.
last_msg_ts
||
""
)
+
""
,
100
)
-
parseString2TimeValue
((
x
.
last_msg_ts
||
""
)
+
""
,
99
)
);
}
public
clearActiveId
()
{
this
.
clearChatId
();
}
private
async
getList
()
{
this
.
refreshing
=
true
;
let
result
=
await
this
.
sdk
.
model
(
this
.
modelName
)
.
list
(
this
.
listName
||
undefined
)
.
query
({
pageIndex
:
this
.
currentPage
,
item_size
:
this
.
pageSize
,
})
.
finally
(()
=>
(
this
.
refreshing
=
false
));
if
(
result
.
pageData
.
rows
.
length
===
0
&&
this
.
currentPage
!==
1
)
{
this
.
currentPage
=
1
;
if
(
result
.
pageData
.
record_count
>
0
)
{
result
=
await
this
.
sdk
.
model
(
this
.
modelName
)
.
list
(
this
.
listName
||
undefined
)
.
query
({
pageIndex
:
this
.
currentPage
,
item_size
:
this
.
pageSize
,
});
}
}
this
.
chatList
=
result
.
pageData
.
rows
.
map
((
it
)
=>
{
return
{
id
:
it
.
id
.
value
,
chat_id
:
it
.
ImChatId
.
value
,
model_name
:
it
.
ModelName
.
value
,
obj_id
:
it
.
ObjId
.
value
,
last_msg_sender
:
it
.
LastSpeakUid
.
value
,
last_msg_content
:
it
.
LastMsgContent
.
value
,
last_msg_ts
:
it
.
LastMsgTime
.
value
,
last_msg_type
:
it
.
LastMsgType
.
value
,
title
:
it
.
Title
.
value
||
`会话
${
it
.
id
.
value
}
`
,
checked
:
false
,
}
as
SelectChatType
;
});
this
.
total
=
result
.
pageData
.
record_count
;
this
.
$emit
(
"list-count-update"
,
this
.
total
);
}
async
created
()
{
await
this
.
getList
();
this
.
setSource
(
xim
.
getServiceType
());
this
.
scrollbar
&&
this
.
scrollbar
.
update
();
await
this
.
sdk
.
model
(
"UniplatChat"
)
.
registerOnChange
(
this
.
onTransportMessage
);
await
this
.
sdk
.
model
(
"general_order"
)
.
registerOnChange
(
this
.
onTransportMessage
);
if
(
this
.
listName
===
"group_receiving"
||
this
.
listName
===
"group_wait"
)
{
xim
.
$on
(
EVENTS
.
ChatUpdate
,
this
.
refreshListDebounce
);
}
}
onTransportMessage
(
e
:
any
)
{
const
index
=
e
.
dataUpdates
.
findIndex
(
(
it
)
=>
it
.
action
===
"startChat"
||
it
.
action
===
"createChat"
||
it
.
action
===
"csExitChat"
||
it
.
action
===
"finishChat"
||
(
it
.
action
===
"delete"
&&
it
.
model
===
"general_order"
)
||
(
it
.
action
===
"sendMsg"
&&
this
.
listName
===
"group_before_handle"
&&
this
.
chatList
.
findIndex
(
(
chat
)
=>
chat
.
id
===
it
.
selectedList
[
0
]
)
>
-
1
)
);
if
(
index
>
-
1
)
{
if
(
this
.
listName
===
"group_before_handle"
&&
e
.
dataUpdates
.
findIndex
((
it
)
=>
it
.
action
===
"sendMsg"
)
>
-
1
)
{
xim
.
$emit
(
EVENTS
.
ChatUpdate
);
}
this
.
refreshListDebounce
();
}
}
private
refreshListDebounce
()
{
if
(
this
.
sseTs
)
{
return
;
}
this
.
sseTs
=
new
Date
().
getTime
();
setTimeout
(()
=>
{
this
.
sseTs
=
0
;
this
.
getList
();
},
1000
);
}
mounted
()
{
this
.
saveMyId
();
}
private
handleSizeChange
(
newPageSize
)
{
this
.
pageSize
=
newPageSize
;
this
.
getList
();
}
private
async
goToChatRoom
(
data
:
ChatType
)
{
await
this
.
_createChat
({
modelName
:
data
.
model_name
,
selectedListId
:
data
.
obj_id
,
uids
:
[],
showByPage
:
true
,
});
this
.
activeId
=
data
.
chat_id
.
toString
();
}
private
raiseChatIdChanged
()
{
this
.
$emit
(
"change"
);
}
private
parseMesage
(
data
:
ChatType
)
{
if
(
data
.
last_msg_sender
&&
data
.
last_msg_sender
!==
"0"
)
{
if
(
this
.
userNames
[
data
.
last_msg_sender
]
===
undefined
)
{
this
.
updateUserName
({
id
:
data
.
last_msg_sender
,
name
:
""
});
this
.
sdk
.
model
(
"user"
)
.
detail
(
data
.
last_msg_sender
)
.
query
()
.
then
((
userInfo
)
=>
{
this
.
updateUserName
({
id
:
data
.
last_msg_sender
,
name
:
userInfo
.
row
.
first_name
.
display
as
string
,
});
});
}
}
if
(
data
.
last_msg_content
===
""
)
return
"[暂无消息]"
;
return
parserMessage
(
data
.
last_msg_type
,
data
.
last_msg_content
);
}
private
formatTimestamp
(
v
:
number
)
{
return
formatTime
(
v
,
{
short
:
true
,
rule
:
TimeFormatRule
.
Hour12
});
}
private
goToDetail
(
model_name
:
string
,
keyvalue
:
string
)
{
this
.
$router
.
push
(
`/
${
this
.
$route
.
params
.
project
}
/
${
this
.
$route
.
params
.
entrance
}
/detail/
${
model_name
}
/key/
${
keyvalue
}
`
);
}
private
batchStartReception
()
{
const
chats
=
this
.
chatRooms
.
filter
((
chat
)
=>
chat
.
checked
);
if
(
chats
.
length
===
0
)
{
return
this
.
$message
.
warning
(
"请先勾选要接待的会话"
);
}
const
length
=
chats
.
length
;
let
count
=
0
;
chats
.
forEach
((
chat
)
=>
{
this
.
sdk
.
model
(
chat
.
model_name
)
.
chat
(
chat
.
obj_id
,
this
.
global
.
org
.
id
.
toString
())
.
startChat
()
.
finally
(()
=>
{
count
++
;
if
(
count
>=
length
)
{
this
.
getList
();
this
.
$message
.
success
(
`批量接待完成`
);
}
});
chat
.
checked
=
false
;
});
this
.
showItemCheckbox
=
false
;
this
.
clearActiveId
();
}
private
toggle
()
{
for
(
const
item
of
this
.
chatList
)
{
item
.
checked
=
true
;
}
}
private
unselectAll
()
{
for
(
const
item
of
this
.
chatList
)
{
item
.
checked
=
false
;
}
this
.
showItemCheckbox
=
false
;
}
}
</
script
>
<
style
lang=
"less"
scoped
>
.w-100
{
width
:
100%
;
}
.chat-list-con
{
display
:
inline-block
;
position
:
relative
;
width
:
25%
;
box-sizing
:
border-box
;
height
:
100%
;
border-right
:
1px
solid
#ddd
;
.title
{
padding-left
:
20px
;
line-height
:
59px
;
font-size
:
18px
;
border-bottom
:
1px
solid
#e1e1e1
;
}
}
.chat-list
{
text-align
:
center
;
}
.chat-list-scroll
{
height
:
100%
;
.empty
{
padding-top
:
100%
;
}
.list-scroll
{
height
:
calc
(
100%
-
110px
);
}
}
.keyword-input
{
width
:
90%
;
margin
:
15px
;
/deep/
.el-input__inner
{
font-size
:
13px
;
height
:
30px
;
line-height
:
30px
;
border-radius
:
15px
;
padding-right
:
15px
;
}
/
deep
/
.el-icon-time
{
background
:
transparent
;
}
}
.chat-list
{
.chat-item
{
cursor
:
pointer
;
padding
:
4px
15px
10px
;
border-bottom
:
1px
solid
#eee
;
&:hover
{
background
:
#e4f0ff
;
}
&
.selected
{
background
:
#f0f0f0
;
}
.chat-avatar
{
display
:
inline-block
;
vertical-align
:
middle
;
width
:
0
;
height
:
0
;
margin-right
:
5px
;
}
.chat-info
{
display
:
flex
;
vertical-align
:
middle
;
width
:
calc
(
100%
-
10px
);
.chat-name
{
line-height
:
35px
;
min-height
:
35px
;
font-size
:
15px
;
}
.checkbox-wrap
{
padding-top
:
18px
;
padding-right
:
8px
;
}
}
.chat-info-left
{
text-align
:
start
;
font-size
:
14px
;
line-height
:
20px
;
color
:
#333333
;
margin-bottom
:
10px
;
.chat-time
{
text-align
:
end
;
flex
:
none
;
color
:
#999999
;
margin-left
:
10px
;
font-size
:
12px
;
line-height
:
1
;
}
}
.chat-msg
{
color
:
#888
;
text-align
:
start
;
font-size
:
12px
;
margin-top
:
-13px
;
min-height
:
16px
;
}
}
}
.chat-check-detail
{
margin-left
:
10px
;
}
.need-update-tip
{
background
:
#fff2e6
;
color
:
#e87005
;
font-size
:
14px
;
font-weight
:
400
;
line-height
:
14px
;
padding
:
8px
0
;
text-align
:
center
;
cursor
:
pointer
;
}
.page-comp
{
padding
:
15px
0
;
}
.action-row
{
position
:
relative
;
.el-button
{
padding
:
8px
14px
;
border-radius
:
15px
;
}
}
.refresh-icon
{
margin
:
0
5px
;
cursor
:
pointer
;
color
:
#409eff
;
position
:
absolute
;
right
:
10px
;
top
:
8px
;
}
</
style
>
components/chat-list.vue
deleted
100644 → 0
View file @
9a75d867
<
template
>
<div
class=
"chat-list-con"
>
<div
class=
"chat-list h-100"
>
<slot
/>
<div
class=
"chat-list-scroll"
>
<el-scrollbar
ref=
"scrollbar"
class=
"h-100 no-bottom-scrollbar"
>
<div
v-for=
"item in chatRooms"
:key=
"item.chat_id"
class=
"chat-item"
:class=
"
{ selected: isSelected(item) }"
@click="goToChatRoom(item)"
>
<div
class=
"red-dot"
v-if=
"item.unread_msg_count > 0"
>
{{
item
.
unread_msg_count
}}
</div>
<div
class=
"chat-info"
>
<div
class=
"
chat-info-left
d-flex
justify-content-between
align-items-center
"
>
<div
:title=
"item.customer_name"
class=
"chat-name flex-fill text-dot-dot-dot"
>
<span>
{{
item
.
title
||
item
.
chat_id
}}
</span>
</div>
<div
v-if=
"item.last_msg_ts"
class=
"chat-time"
>
{{
formatTimestamp
(
item
.
last_msg_ts
)
}}
</div>
</div>
<div
class=
"chat-msg text-dot-dot-dot"
>
{{
buildLastMessage
(
item
)
}}
</div>
</div>
</div>
<div
class=
"empty"
v-if=
"chatRooms && chatRooms.length
<
=
0
"
>
{{
searchKeyword
?
"无相关接待"
:
"无接待"
}}
</div>
</el-scrollbar>
</div>
</div>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Prop
,
Ref
,
Vue
}
from
"vue-property-decorator"
;
import
Controller
from
"./controller/chat-list"
;
import
{
EVENTS
}
from
"@/EventConsts"
;
import
avatar
from
"@/customer-service/components/avatar.vue"
;
import
{
Chat
as
ChatType
}
from
"@/customer-service/xim/models/chat"
;
import
{
ServiceType
}
from
"../model"
;
import
xim
from
"@/customer-service/xim"
;
@
Component
({
components
:
{
avatar
}
})
export
default
class
ChatList
extends
Controller
{
private
searchKeyword
=
""
;
@
Prop
({
type
:
Number
,
default
:
-
1
})
private
selected
!
:
number
;
@
Ref
(
"scrollbar"
)
private
readonly
scrollbar
!
:
Vue
&
{
update
:
()
=>
void
};
private
unReadMsgCount
=
0
;
private
get
chatRooms
()
{
if
(
this
.
chatList
)
{
const
list
=
this
.
chatList
.
list
.
filter
((
chat
)
=>
chat
.
title
.
indexOf
(
this
.
searchKeyword
)
>
-
1
)
.
sort
((
x
,
y
)
=>
y
.
last_msg_ts
-
x
.
last_msg_ts
);
let
unReadMsgCount
=
0
;
list
.
filter
((
chat
)
=>
chat
.
unread_msg_count
>
0
).
forEach
((
chat
)
=>
{
unReadMsgCount
+=
chat
.
unread_msg_count
;
});
this
.
unReadMsgCount
=
unReadMsgCount
;
this
.
$emit
(
"list-count-update"
,
this
.
unReadMsgCount
);
xim
.
$emit
(
EVENTS
.
NewMsg
,
this
.
unReadMsgCount
);
return
list
;
}
return
[];
}
private
isSelected
(
item
:
ChatType
)
{
if
(
this
.
chatId
)
{
return
item
.
chat_id
===
this
.
chatId
;
}
return
this
.
selected
===
item
.
chat_id
;
}
async
created
()
{
await
this
.
getMyChatList
();
this
.
setSource
(
ServiceType
.
Backend
);
this
.
scrollbar
.
update
();
}
mounted
()
{
this
.
saveMyId
();
}
public
async
search
(
searchKeyword
:
string
)
{
this
.
searchKeyword
=
searchKeyword
.
trim
();
}
private
async
goToChatRoom
(
data
:
ChatType
)
{
if
(
this
.
chatId
===
data
.
chat_id
)
{
this
.
showChat
();
return
;
}
await
this
.
saveChatId
(
data
.
chat_id
).
finally
(
this
.
raiseChatIdChanged
);
this
.
showChat
();
this
.
close
();
if
(
data
.
unread_msg_count
>
0
)
{
data
.
unread_msg_count
=
0
;
}
}
private
raiseChatIdChanged
()
{
this
.
$emit
(
"change"
);
}
private
close
()
{
this
.
$emit
(
"close"
);
}
private
goToDetail
(
model_name
:
string
,
keyvalue
:
string
)
{
this
.
$router
.
push
(
`/
${
this
.
$route
.
params
.
project
}
/
${
this
.
$route
.
params
.
entrance
}
/detail/
${
model_name
}
/key/
${
keyvalue
}
`
);
this
.
close
();
}
}
</
script
>
<
style
lang=
"less"
scoped
>
.chat-list-con
{
display
:
inline-block
;
width
:
25%
;
box-sizing
:
border-box
;
height
:
100%
;
border-right
:
1px
solid
#ddd
;
.title
{
padding-left
:
20px
;
line-height
:
59px
;
font-size
:
18px
;
border-bottom
:
1px
solid
#e1e1e1
;
}
}
.chat-list
{
text-align
:
center
;
}
.chat-list-scroll
{
height
:
100%
;
.empty
{
margin-top
:
100%
;
}
}
.keyword-input
{
width
:
90%
;
margin
:
15px
;
/deep/
.el-input__inner
{
font-size
:
13px
;
height
:
30px
;
line-height
:
30px
;
border-radius
:
15px
;
padding-right
:
15px
;
}
/
deep
/
.el-icon-time
{
background
:
transparent
;
}
/
deep
/
.el-input__icon
{
line-height
:
32px
;
}
}
.chat-list
{
.chat-item
{
position
:
relative
;
cursor
:
pointer
;
padding
:
4px
15px
10px
;
border-bottom
:
1px
solid
#eee
;
&:hover
{
background
:
#e4f0ff
;
}
&
.selected
{
background
:
#f0f0f0
;
}
.red-dot
{
position
:
absolute
;
min-width
:
14px
;
height
:
14px
;
line-height
:
14px
;
padding
:
0
2px
;
background
:
#e87005
;
border-radius
:
7px
;
z-index
:
1
;
right
:
10px
;
bottom
:
10px
;
font-size
:
12px
;
color
:
#fff
;
}
.chat-info
{
display
:
inline-block
;
vertical-align
:
middle
;
width
:
calc
(
100%
-
10px
);
.chat-name
{
line-height
:
35px
;
font-size
:
16px
;
}
}
.chat-info-left
{
text-align
:
start
;
font-size
:
14px
;
line-height
:
20px
;
color
:
#333333
;
margin-bottom
:
10px
;
.chat-time
{
text-align
:
end
;
flex
:
none
;
color
:
#999999
;
margin-left
:
10px
;
font-size
:
12px
;
line-height
:
1
;
}
}
.chat-msg
{
color
:
#888
;
text-align
:
start
;
font-size
:
12px
;
margin-top
:
-15px
;
}
}
}
.chat-check-detail
{
margin-left
:
10px
;
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment