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
7a06251d
authored
Jul 15, 2021
by
panjiangyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加成员
parent
8b6b98f5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
34 deletions
chat.vue
create-chat.vue
store/index.ts
store/model.ts
chat.vue
View file @
7a06251d
...
...
@@ -17,11 +17,12 @@
<el-button
class=
"button"
@
click=
"terminate"
round
>
结束会话
</el-button
>
<el-button
class=
"button"
@
click=
"
terminate
"
round
<el-button
class=
"button"
@
click=
"
showAddMember
"
round
>
添加成员
</el-button
>
</div>
</div>
<ChatCreator
v-show=
"visible"
@
submit=
"addMember"
@
hide=
"hideAddMember"
/>
</div>
<!--
</el-dialog>
-->
</
template
>
...
...
@@ -33,9 +34,10 @@ import ChatRoom from "./chat-room.vue";
import
MessageList
from
"./message-list.vue"
;
import
buttonThrottle
from
"./utils/button-throttle"
;
import
ChatCreator
from
"@/customer-service/create-chat.vue"
;
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
{
@
chatStore
.
State
(
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 {
@
chatStore
.
Action
(
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
()
private
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
>
<
style
lang=
"less"
scoped
>
...
...
create-chat.vue
View file @
7a06251d
...
...
@@ -2,7 +2,7 @@
<el-dialog
class=
"create-chat"
title=
"创建会话"
:visible=
"
visibl
e"
:visible=
"
tru
e"
@
close=
"hide"
>
<div
class=
"search-bar"
>
...
...
@@ -21,7 +21,7 @@
v-for=
"user in userList"
:key=
"user.id"
class=
"user-con"
:class=
"
{ isChoosed:isChoosed(user.id) }"
:class=
"
{ isChoosed:
isChoosed(user.id) }"
@click="onClickUser(user.id)"
>
<avatar
/>
...
...
@@ -60,9 +60,6 @@ export default class ChatCreator extends Vue {
@
chatStore
.
State
(
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
)
private
readonly
_createChat
!
:
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
;
...
...
@@ -73,9 +70,9 @@ export default class ChatCreator extends Vue {
@
Watch
(
"visible"
)
private
onvisibleChange
()
{
if
(
this
.
visible
)
{
this
.
selectedUsers
=
[];
}
if
(
this
.
visible
)
{
this
.
selectedUsers
=
[];
}
}
private
searchText
=
""
;
...
...
@@ -123,6 +120,10 @@ export default class ChatCreator extends Vue {
});
}
private
hide
()
{
this
.
$emit
(
"hide"
);
}
private
search
()
{
this
.
currentPage
=
1
;
this
.
getUserList
(
this
.
searchText
);
...
...
@@ -159,8 +160,12 @@ export default class ChatCreator extends Vue {
@
buttonThrottle
()
private
createChat
()
{
return
new
Promise
(
resolve
=>
{
this
.
$emit
(
"submit"
,
this
.
selectedUsers
.
map
(
id
=>
String
(
id
)),
resolve
);
return
new
Promise
((
resolve
)
=>
{
this
.
$emit
(
"submit"
,
this
.
selectedUsers
.
map
((
id
)
=>
String
(
id
)),
resolve
);
});
}
}
...
...
@@ -179,7 +184,7 @@ export default class ChatCreator extends Vue {
margin-bottom
:
40px
;
cursor
:
pointer
;
&.isChoosed
{
outline
:
1px
solid
#3285FF
;
outline
:
1px
solid
#3285ff
;
}
}
.user-name
{
...
...
store/index.ts
View file @
7a06251d
...
...
@@ -17,19 +17,19 @@ const sdk = Chat.getSdk;
const
UniplatChatModelName
=
"UniplatChat"
;
const
model
=
()
=>
sdk
().
model
(
UniplatChatModelName
);
const
orgId
=
Chat
.
getOrgId
;
//
const getMyinfo = (function () {
//
let data;
//
return async () => {
//
if (data != null) return data;
//
data = sdk().getUserInfo();
//
return data;
//
};
//
})();
const
getMyinfo
=
(
function
()
{
let
data
;
return
async
()
=>
{
if
(
data
!=
null
)
return
data
;
data
=
sdk
().
getUserInfo
();
return
data
;
};
})();
function
uniqueMessages
(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
)
{
const
arr
=
[...
messages
];
return
unique
(
arr
,
function
(
item
,
all
)
{
return
unique
(
arr
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
});
}
...
...
@@ -254,7 +254,7 @@ export default {
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
}
=
{};
return
(
state
:
ChatStoreState
,
...
...
@@ -287,10 +287,9 @@ export default {
},
},
actions
:
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
](
{
commit
},
// ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST>
)
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
]({
commit
,
})
/* ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST> */
{
const
{
pageData
}
=
await
model
().
list
().
query
({
pageIndex
:
1
,
item_size
:
50
,
...
...
@@ -340,7 +339,12 @@ export default {
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
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
);
return
data
;
},
...
...
@@ -350,7 +354,12 @@ export default {
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
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
);
return
data
;
},
...
...
@@ -405,7 +414,7 @@ export default {
{
state
,
commit
,
dispatch
},
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"
);
action
.
addInputs_parameter
({
OrgId
:
orgId
(),
...
...
@@ -443,9 +452,7 @@ export default {
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
const
roomList
=
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
];
if
(
roomList
==
null
)
return
;
const
newChat
=
roomList
.
list
.
find
(
(
k
)
=>
k
.
uniplatId
===
id
);
const
newChat
=
roomList
.
list
.
find
((
k
)
=>
k
.
uniplatId
===
id
);
if
(
newChat
==
null
)
return
;
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
);
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
{
...
...
@@ -566,7 +573,7 @@ export default {
);
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
unique
(
newChatMembers
,
function
(
item
,
all
)
{
unique
(
newChatMembers
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
})
);
...
...
@@ -589,6 +596,33 @@ export default {
.
execute
();
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
:
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
...
...
store/model.ts
View file @
7a06251d
...
...
@@ -261,6 +261,8 @@ export namespace ChatStore {
})
=>
void
export
const
ACTION_TERINATE_CHAT
=
"结束会话"
;
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
{
...
...
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