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
You need to sign in or sign up before continuing.
Commit
7a06251d
authored
Jul 15, 2021
by
panjiangyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加成员
parent
8b6b98f5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
31 deletions
chat.vue
create-chat.vue
store/index.ts
store/model.ts
chat.vue
View file @
7a06251d
...
@@ -17,11 +17,12 @@
...
@@ -17,11 +17,12 @@
<el-button
class=
"button"
@
click=
"terminate"
round
<el-button
class=
"button"
@
click=
"terminate"
round
>
结束会话
</el-button
>
结束会话
</el-button
>
>
<el-button
class=
"button"
@
click=
"
terminate
"
round
<el-button
class=
"button"
@
click=
"
showAddMember
"
round
>
添加成员
</el-button
>
添加成员
</el-button
>
>
</div>
</div>
</div>
</div>
<ChatCreator
v-show=
"visible"
@
submit=
"addMember"
@
hide=
"hideAddMember"
/>
</div>
</div>
<!--
</el-dialog>
-->
<!--
</el-dialog>
-->
</
template
>
</
template
>
...
@@ -33,9 +34,10 @@ import ChatRoom from "./chat-room.vue";
...
@@ -33,9 +34,10 @@ import ChatRoom from "./chat-room.vue";
import
MessageList
from
"./message-list.vue"
;
import
MessageList
from
"./message-list.vue"
;
import
buttonThrottle
from
"./utils/button-throttle"
;
import
buttonThrottle
from
"./utils/button-throttle"
;
import
ChatCreator
from
"@/customer-service/create-chat.vue"
;
import
{
ChatStore
,
chatStore
}
from
"@/customer-service/store/model"
;
import
{
ChatStore
,
chatStore
}
from
"@/customer-service/store/model"
;
@
Component
({
components
:
{
MessageList
,
ChatRoom
,
ChatList
}
})
@
Component
({
components
:
{
MessageList
,
ChatRoom
,
ChatList
,
ChatCreator
}
})
export
default
class
Chat
extends
Vue
{
export
default
class
Chat
extends
Vue
{
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
...
@@ -46,10 +48,27 @@ export default class Chat extends Vue {
...
@@ -46,10 +48,27 @@ export default class Chat extends Vue {
@
chatStore
.
Action
(
ChatStore
.
ACTION_TERINATE_CHAT
)
@
chatStore
.
Action
(
ChatStore
.
ACTION_TERINATE_CHAT
)
private
readonly
_terminate
!
:
ChatStore
.
ACTION_TERINATE_CHAT
;
private
readonly
_terminate
!
:
ChatStore
.
ACTION_TERINATE_CHAT
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_CHAT_ADD_MEMBERS
)
private
readonly
_addMember
!
:
ChatStore
.
ACTION_CHAT_ADD_MEMBERS
;
private
visible
=
false
;
@
buttonThrottle
()
@
buttonThrottle
()
private
terminate
()
{
private
terminate
()
{
this
.
_terminate
();
this
.
_terminate
();
}
}
private
showAddMember
()
{
this
.
visible
=
true
;
}
private
hideAddMember
()
{
this
.
visible
=
false
;
}
private
async
addMember
(
users
:
string
[],
done
:
()
=>
void
)
{
await
this
.
_addMember
(
users
);
done
();
}
}
}
</
script
>
</
script
>
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
...
...
create-chat.vue
View file @
7a06251d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<el-dialog
<el-dialog
class=
"create-chat"
class=
"create-chat"
title=
"创建会话"
title=
"创建会话"
:visible=
"
visibl
e"
:visible=
"
tru
e"
@
close=
"hide"
@
close=
"hide"
>
>
<div
class=
"search-bar"
>
<div
class=
"search-bar"
>
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
v-for=
"user in userList"
v-for=
"user in userList"
:key=
"user.id"
:key=
"user.id"
class=
"user-con"
class=
"user-con"
:class=
"
{ isChoosed:isChoosed(user.id) }"
:class=
"
{ isChoosed:
isChoosed(user.id) }"
@click="onClickUser(user.id)"
@click="onClickUser(user.id)"
>
>
<avatar
/>
<avatar
/>
...
@@ -60,9 +60,6 @@ export default class ChatCreator extends Vue {
...
@@ -60,9 +60,6 @@ export default class ChatCreator extends Vue {
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
)
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
)
private
readonly
visible
!
:
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
;
private
readonly
visible
!
:
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
;
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_HIDE_CHAT_CREATOR
)
private
readonly
hide
!
:
ChatStore
.
MUTATION_HIDE_CHAT_CREATOR
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
)
@
chatStore
.
Action
(
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
)
private
readonly
_createChat
!
:
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
;
private
readonly
_createChat
!
:
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
;
...
@@ -123,6 +120,10 @@ export default class ChatCreator extends Vue {
...
@@ -123,6 +120,10 @@ export default class ChatCreator extends Vue {
});
});
}
}
private
hide
()
{
this
.
$emit
(
"hide"
);
}
private
search
()
{
private
search
()
{
this
.
currentPage
=
1
;
this
.
currentPage
=
1
;
this
.
getUserList
(
this
.
searchText
);
this
.
getUserList
(
this
.
searchText
);
...
@@ -159,8 +160,12 @@ export default class ChatCreator extends Vue {
...
@@ -159,8 +160,12 @@ export default class ChatCreator extends Vue {
@
buttonThrottle
()
@
buttonThrottle
()
private
createChat
()
{
private
createChat
()
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
((
resolve
)
=>
{
this
.
$emit
(
"submit"
,
this
.
selectedUsers
.
map
(
id
=>
String
(
id
)),
resolve
);
this
.
$emit
(
"submit"
,
this
.
selectedUsers
.
map
((
id
)
=>
String
(
id
)),
resolve
);
});
});
}
}
}
}
...
@@ -179,7 +184,7 @@ export default class ChatCreator extends Vue {
...
@@ -179,7 +184,7 @@ export default class ChatCreator extends Vue {
margin-bottom
:
40px
;
margin-bottom
:
40px
;
cursor
:
pointer
;
cursor
:
pointer
;
&.isChoosed
{
&.isChoosed
{
outline
:
1px
solid
#3285FF
;
outline
:
1px
solid
#3285ff
;
}
}
}
}
.user-name
{
.user-name
{
...
...
store/index.ts
View file @
7a06251d
...
@@ -17,19 +17,19 @@ const sdk = Chat.getSdk;
...
@@ -17,19 +17,19 @@ const sdk = Chat.getSdk;
const
UniplatChatModelName
=
"UniplatChat"
;
const
UniplatChatModelName
=
"UniplatChat"
;
const
model
=
()
=>
sdk
().
model
(
UniplatChatModelName
);
const
model
=
()
=>
sdk
().
model
(
UniplatChatModelName
);
const
orgId
=
Chat
.
getOrgId
;
const
orgId
=
Chat
.
getOrgId
;
//
const getMyinfo = (function () {
const
getMyinfo
=
(
function
()
{
//
let data;
let
data
;
//
return async () => {
return
async
()
=>
{
//
if (data != null) return data;
if
(
data
!=
null
)
return
data
;
//
data = sdk().getUserInfo();
data
=
sdk
().
getUserInfo
();
//
return data;
return
data
;
//
};
};
//
})();
})();
function
uniqueMessages
(
function
uniqueMessages
(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
)
{
)
{
const
arr
=
[...
messages
];
const
arr
=
[...
messages
];
return
unique
(
arr
,
function
(
item
,
all
)
{
return
unique
(
arr
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
});
});
}
}
...
@@ -254,7 +254,7 @@ export default {
...
@@ -254,7 +254,7 @@ export default {
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
}
}
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
return
(
return
(
state
:
ChatStoreState
,
state
:
ChatStoreState
,
...
@@ -287,10 +287,9 @@ export default {
...
@@ -287,10 +287,9 @@ export default {
},
},
},
},
actions
:
{
actions
:
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
](
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
]({
{
commit
},
commit
,
// ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST>
})
/* ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST> */
{
)
{
const
{
pageData
}
=
await
model
().
list
().
query
({
const
{
pageData
}
=
await
model
().
list
().
query
({
pageIndex
:
1
,
pageIndex
:
1
,
item_size
:
50
,
item_size
:
50
,
...
@@ -340,7 +339,12 @@ export default {
...
@@ -340,7 +339,12 @@ export default {
)
{
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
if
(
chatId
==
null
)
return
;
const
data
=
await
xim
.
queryPrevPageMsg
(
chatType
,
chatId
,
msgId
,
10
);
const
data
=
await
xim
.
queryPrevPageMsg
(
chatType
,
chatId
,
msgId
,
10
);
commit
(
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
,
data
);
commit
(
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
,
data
);
return
data
;
return
data
;
},
},
...
@@ -350,7 +354,12 @@ export default {
...
@@ -350,7 +354,12 @@ export default {
)
{
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
if
(
chatId
==
null
)
return
;
const
data
=
await
xim
.
queryNextPageMsg
(
chatType
,
chatId
,
msgId
,
10
);
const
data
=
await
xim
.
queryNextPageMsg
(
chatType
,
chatId
,
msgId
,
10
);
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
);
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
);
return
data
;
return
data
;
},
},
...
@@ -405,7 +414,7 @@ export default {
...
@@ -405,7 +414,7 @@ export default {
{
state
,
commit
,
dispatch
},
{
state
,
commit
,
dispatch
},
params
:
Parameters
<
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
>
[
0
]
params
:
Parameters
<
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
>
[
0
]
)
{
)
{
const
myId
=
"1"
;
/* (await getMyinfo()).id */
const
myId
=
(
await
getMyinfo
()).
id
;
const
action
=
sdk
().
model
(
UniplatChatModelName
).
action
(
"insert"
);
const
action
=
sdk
().
model
(
UniplatChatModelName
).
action
(
"insert"
);
action
.
addInputs_parameter
({
action
.
addInputs_parameter
({
OrgId
:
orgId
(),
OrgId
:
orgId
(),
...
@@ -443,9 +452,7 @@ export default {
...
@@ -443,9 +452,7 @@ export default {
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
const
roomList
=
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
];
const
roomList
=
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
];
if
(
roomList
==
null
)
return
;
if
(
roomList
==
null
)
return
;
const
newChat
=
roomList
.
list
.
find
(
const
newChat
=
roomList
.
list
.
find
((
k
)
=>
k
.
uniplatId
===
id
);
(
k
)
=>
k
.
uniplatId
===
id
);
if
(
newChat
==
null
)
return
;
if
(
newChat
==
null
)
return
;
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
);
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
);
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
{
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
{
...
@@ -566,7 +573,7 @@ export default {
...
@@ -566,7 +573,7 @@ export default {
);
);
commit
(
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
unique
(
newChatMembers
,
function
(
item
,
all
)
{
unique
(
newChatMembers
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
})
})
);
);
...
@@ -589,6 +596,33 @@ export default {
...
@@ -589,6 +596,33 @@ export default {
.
execute
();
.
execute
();
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
},
},
async
[
ChatStore
.
ACTION_CHAT_ADD_MEMBERS
](
{
state
,
dispatch
},
uids
:
Parameters
<
ChatStore
.
ACTION_CHAT_ADD_MEMBERS
>
[
0
]
)
{
const
v
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
];
if
(
v
==
null
)
return
;
const
id
=
Number
(
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
);
const
action
=
sdk
().
model
(
UniplatChatModelName
).
action
(
"update"
);
action
.
updateInitialParams
({
selected_list
:
[{
v
,
id
}],
});
const
detailManager
=
await
action
.
getDetailParametersManagerByName
(
"UniplatChatMember"
);
uids
.
forEach
((
Uid
)
=>
{
detailManager
.
add
({
OrgId
:
orgId
(),
Uid
,
type
:
ChatMemberType
.
member
,
});
});
detailManager
.
done
();
await
action
.
execute
();
await
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MEMBERS
);
},
},
},
getters
:
{
getters
:
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
...
...
store/model.ts
View file @
7a06251d
...
@@ -261,6 +261,8 @@ export namespace ChatStore {
...
@@ -261,6 +261,8 @@ export namespace ChatStore {
})
=>
void
})
=>
void
export
const
ACTION_TERINATE_CHAT
=
"结束会话"
;
export
const
ACTION_TERINATE_CHAT
=
"结束会话"
;
export
type
ACTION_TERINATE_CHAT
=
()
=>
Promise
<
void
>
export
type
ACTION_TERINATE_CHAT
=
()
=>
Promise
<
void
>
export
const
ACTION_CHAT_ADD_MEMBERS
=
"添加成员"
;
export
type
ACTION_CHAT_ADD_MEMBERS
=
(
uids
:
string
[])
=>
Promise
<
void
>
}
}
export
interface
ChatStoreState
{
export
interface
ChatStoreState
{
...
...
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