Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c70cee04
authored
Nov 08, 2022
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增群机器人功能
1 parent
720c8ae4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
497 additions
and
2 deletions
linkwe-pc/src/api/internalCollaborate/groupRobot.js
linkwe-pc/src/views/internalCollaborate/appManage/list.vue
linkwe-pc/src/views/internalCollaborate/groupRobot/HistoryMsg.vue
linkwe-pc/src/views/internalCollaborate/groupRobot/list.vue
linkwe-pc/src/api/internalCollaborate/groupRobot.js
0 → 100644
View file @
c70cee0
import
request
from
'@/utils/request'
const
service
=
window
.
CONFIG
.
services
.
system
+
window
.
CONFIG
.
services
.
wecom
+
'/agent'
const
serviceMsg
=
service
+
'/msg'
// 应用管理
/**
* 列表
* @param {*} params
*/
export
function
getList
()
{
return
request
({
url
:
service
+
'/list'
,
})
}
/**
* 同步应用信息
* @param {*} params
*/
export
function
sync
(
id
)
{
return
request
({
url
:
service
+
`/pull/
${
id
}
`
,
method
:
'get'
,
})
}
/**
* 删除
* @param {*} params
*/
export
function
remove
(
id
)
{
return
request
({
url
:
service
+
`/delete/
${
id
}
`
,
method
:
'delete'
,
})
}
/**
* 添加应用
* @param {*} data
{
"agentId": "应用ID",
"secret": "应用密钥"
}
* @returns
*/
export
function
add
(
data
)
{
return
request
({
url
:
service
+
'/add'
,
method
:
'post'
,
data
,
})
}
/**
* 编辑应用信息
* @param {*} data
{
description:'', // string 企业应用详情
homeUrl:'', // string 应用主页url
logoUrl:'', // string 企业应用头像
name:'', // string 企业应用名称
redirectDomain:'', // string 企业应用可信域名
}
* @returns
*/
export
function
update
(
data
)
{
return
request
({
url
:
service
+
`/update/
${
data
.
id
}
`
,
method
:
'PUT'
,
data
,
})
}
// 应用消息
export
const
appMsg
=
{
/**
* 获取历史消息列表
* @param {*} params
{
endTime:'', // string date-time 发送结束时间
startTime:'', // string date-time 发送开始时间
status:'',// integer int32状态
title:'', // string 标题
}
*/
getList
(
params
)
{
return
request
({
url
:
serviceMsg
+
'/list'
,
params
,
})
},
/**
* 应用消息详情
* @param {*} id
*/
getDetail
(
id
)
{
return
request
({
url
:
serviceMsg
+
`/get/
${
id
}
`
,
})
},
/**
* 撤销应用消息
* @param {*} id
*/
revoke
(
id
)
{
return
request
({
url
:
serviceMsg
+
`/revoke/
${
id
}
`
,
})
},
/**
* 新增应用消息
* @param {*} data
{
agentId:'', // integer int32 应用ID
planSendTime: '', // string date-time 计划时间
scopeType:'', // integer int32 范围类型 1-全部 2-自定义
sendTime: '', // string date-time 发送时间
sendType:'', // integer int32 发送方式 1-立即发送 2-定时发送
title: '', // string 消息标题
toParty: '', // string 示例值 接收消息的部门
toTag: '', // string 示例值 接收消息的标签
toUser: '', // string 示例值 接收消息的成员
WeMessageTemplate:{
appId: '', // string 小程序appid(可以在微信公众平台上查询),必须是关联到企业的小程序应用
content: '', // string 文本内容(文本消息必传)
description: '', // string 消息的描述(视频、文本卡片、图文 必传)
linkUrl: '', // string 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https) (文本卡片、图文 必传)
mediaId: '', // string 素材id(语音、视频、文件 必传)
msgType: '', // string 消息类型 文本:text, 图片:image, 语音:voice, 视频:video, 文件:file, 文本卡片:textcard, 图文:news, 图文消息:link, 小程序:miniprogram
picUrl: '', // string 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150。(文本卡片、图文 必传)
title: '', // string 消息的标题(视频、文本卡片、图文 必传)
}
}
*/
add
(
data
)
{
return
request
({
url
:
serviceMsg
+
'/add'
,
method
:
'post'
,
data
,
})
},
// 保存应用消息 data同上
save
(
data
)
{
return
request
({
url
:
serviceMsg
+
'/save'
,
method
:
'post'
,
data
,
})
},
// 修改应用消息 data同上
update
(
data
)
{
return
request
({
url
:
serviceMsg
+
`/update/
${
data
.
id
}
`
,
method
:
'PUT'
,
data
,
})
},
/**
* 删除
* @param {*} id
*/
remove
(
id
)
{
return
request
({
url
:
serviceMsg
+
`/delete/
${
id
}
`
,
method
:
'delete'
,
})
},
}
linkwe-pc/src/views/internalCollaborate/appManage/list.vue
View file @
c70cee0
<
script
>
<
script
>
import
{
getList
,
update
,
add
,
remove
,
sync
}
from
'@/api/internalCollaborate/appManage'
import
{
getList
,
update
,
add
,
remove
,
sync
}
from
'@/api/internalCollaborate/appManage'
// import clipboard from "clipboard";
// import clipboard from "clipboard";
// import HistoryMsg from './HistoryMsg'
export
default
{
export
default
{
components
:
{
HistoryMsg
:
()
=>
import
(
'./HistoryMsg'
)
},
components
:
{
HistoryMsg
:
()
=>
import
(
'./HistoryMsg'
)
},
...
@@ -256,7 +255,7 @@ export default {
...
@@ -256,7 +255,7 @@ export default {
<!-- 历史消息 弹窗 -->
<!-- 历史消息 弹窗 -->
<el-dialog
title=
"历史消息"
:visible
.
sync=
"dialogVisibleHistoryMsg"
:close-on-click-modal=
"false"
>
<el-dialog
title=
"历史消息"
:visible
.
sync=
"dialogVisibleHistoryMsg"
:close-on-click-modal=
"false"
>
<HistoryMsg
:id=
"id"
v-if=
"dialogVisibleHistoryMsg"
ref=
"historyMsg"
/>
<HistoryMsg
:id=
"id"
v-if=
"dialogVisibleHistoryMsg"
/>
</el-dialog>
</el-dialog>
<!-- 选择素材弹窗 -->
<!-- 选择素材弹窗 -->
...
...
linkwe-pc/src/views/internalCollaborate/groupRobot/HistoryMsg.vue
0 → 100644
View file @
c70cee0
<
script
>
import
{
appMsg
}
from
'@/api/internalCollaborate/groupRobot'
export
default
{
name
:
''
,
components
:
{},
props
:
{
id
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
query
:
{
pageNum
:
1
,
pageSize
:
10
,
id
:
this
.
id
,
},
total
:
0
,
list
:
[],
loading
:
false
,
dialogVisibleHistoryMsg
:
false
,
type
:
[
'图片'
,
'语音'
,
'视频'
,
'文件'
,
'文本'
,
'海报'
,
'活码'
,
'人群'
,
'旅程'
,
'图文'
,
'链接'
,
'小程序'
,
'文章'
,
'企业话术'
,
'客服话术'
,
],
}
},
computed
:
{},
watch
:
{},
created
()
{
this
.
getList
()
},
mounted
()
{},
methods
:
{
getList
(
page
)
{
// if (this.dateRange) {
// this.query.beginTime = this.dateRange[0]
// this.query.endTime = this.dateRange[1]
// } else {
// this.query.beginTime = ''
// this.query.endTime = ''
// }
page
&&
(
this
.
query
.
pageNum
=
page
)
this
.
loading
=
true
appMsg
.
getList
(
this
.
query
)
.
then
(({
data
,
total
})
=>
{
this
.
list
=
data
this
.
total
=
+
total
})
.
finally
(()
=>
{
this
.
loading
=
false
})
},
edit
(
data
,
type
)
{
this
.
form
=
Object
.
assign
({},
data
||
{})
this
.
dialogVisible
=
true
type
||
!
data
?
(
this
.
disabled
=
false
)
:
(
this
.
disabled
=
true
)
},
removke
(
id
,
action
,
tip
)
{
// const operIds = id || this.ids + ''
this
.
$confirm
(
'是否确认'
+
tip
+
'?该操作不可撤销,请谨慎操作。'
,
{
title
:
'警告'
,
type
:
'warning'
,
})
.
then
(
function
()
{
return
appMsg
[
action
](
id
)
})
.
then
(()
=>
{
this
.
getList
()
this
.
msgSuccess
(
'删除成功'
)
})
},
},
}
</
script
>
<
template
>
<div>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table-column
label=
"消息标题"
align=
"center"
prop=
"title"
/>
<el-table-column
prop=
"type"
label=
"类型"
align=
"center"
>
<template
slot-scope=
"
{ row }">
{{
type
[
row
.
type
]
}}
</
template
>
</el-table-column>
<el-table-column
label=
"发送时间"
align=
"center"
prop=
"groupName"
/>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<
template
slot-scope=
"{ row }"
>
<!--
<el-button
type=
"text"
@
click=
"edit(row, 'detail')"
>
详情
</el-button>
<el-button
v-if=
"[0, 1].includes(row.status)"
type=
"text"
@
click=
"edit(row, 'edit')"
>
编辑
</el-button>
-->
<el-button
v-if=
"row.status == 2"
type=
"text"
@
click=
"removke(row.id, 'revoke', '撤回')"
>
撤回
</el-button>
<el-button
v-else
@
click=
"removke(row.id, 'remove', '删除')"
type=
"text"
>
删除
</el-button>
<!-- v-hasPermi="['customerManage:tag:remove']" -->
</
template
>
</el-table-column>
</el-table>
<pagination
v-show=
"total > 0"
:total=
"total"
layout=
"prev, pager, next"
:page
.
sync=
"query.pageNum"
:limit
.
sync=
"query.pageSize"
@
pagination=
"getList()"
/>
</div>
</template>
<
style
lang=
"less"
scoped
></
style
>
linkwe-pc/src/views/internalCollaborate/groupRobot/list.vue
0 → 100644
View file @
c70cee0
<
script
>
import
{
getList
,
update
,
add
,
remove
,
sync
}
from
'@/api/internalCollaborate/groupRobot'
export
default
{
components
:
{
HistoryMsg
:
()
=>
import
(
'./HistoryMsg'
)
},
props
:
{},
data
()
{
return
{
form
:
{},
list
:
[],
dialogVisible
:
false
,
disabled
:
false
,
loading
:
false
,
rules
:
Object
.
freeze
({
name
:
[{
required
:
true
,
message
:
'必填项'
,
trigger
:
'blur'
}],
WebHook
:
[{
required
:
true
,
message
:
'必填项'
,
trigger
:
'blur'
}],
}),
id
:
''
,
dialogVisibleHistoryMsg
:
false
,
// dialogVisibleSelectMaterial: false,
}
},
watch
:
{},
computed
:
{},
created
()
{
this
.
getList
()
this
.
$store
.
dispatch
(
'app/setBusininessDesc'
,
`<div>企业微信自建应用管理,支持通过应用发送应用消息</div> `
)
},
mounted
()
{},
methods
:
{
getList
(
page
)
{
this
.
loading
=
true
getList
()
.
then
(({
data
,
total
})
=>
{
data
.
forEach
((
element
)
=>
{
element
.
allowPartyName
=
(
element
.
allowPartyName
||
''
).
split
(
','
)
element
.
allowUserinfoName
=
(
element
.
allowUserinfoName
||
''
).
split
(
','
)
})
this
.
list
=
data
})
.
finally
(()
=>
{
this
.
loading
=
false
})
},
sync
(
item
)
{
sync
(
item
.
id
).
then
(({
data
})
=>
{
Object
.
assign
(
item
,
data
)
this
.
msgSuccess
(
'操作成功'
)
})
},
edit
(
data
,
type
)
{
this
.
form
=
Object
.
assign
({},
data
||
{})
this
.
dialogVisible
=
true
type
||
!
data
?
(
this
.
disabled
=
false
)
:
(
this
.
disabled
=
true
)
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'form'
].
clearValidate
()
})
},
submit
()
{
this
.
$refs
[
'form'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
;(
this
.
form
.
id
?
update
:
add
)(
this
.
form
)
.
then
(()
=>
{
this
.
msgSuccess
(
'操作成功'
)
this
.
dialogVisible
=
false
this
.
getList
()
// this.getList(!this.form.id && 1)
})
.
catch
(()
=>
{
this
.
dialogVisible
=
false
})
}
})
},
remove
(
id
)
{
// const operIds = id || this.ids + ''
this
.
$confirm
(
'是否确认删除?该操作不可撤销,请谨慎操作。'
,
{
title
:
'警告'
,
type
:
'warning'
,
})
.
then
(
function
()
{
return
remove
(
id
)
})
.
then
(()
=>
{
this
.
getList
()
this
.
msgSuccess
(
'删除成功'
)
})
},
// goRoute(id, path) {
// this.$router.push({
// path: 'taskAev',
// query: { id },
// })
// },
// 选择素材确认按钮
// submitSelectMaterial(text, image, file) {
// this.form.logoMediaid = image.id
// this.form.squareLogoUrl = image.materialUrl
// this.dialogVisibleSelectMaterial = false
// },
},
}
</
script
>
<
template
>
<div>
<ul
v-loading=
"loading"
class=
"list-wrap"
>
<li
v-for=
"(item, index) of list"
:key=
"index"
class=
"list"
>
<div
class=
"title blod toe"
>
{{
item
.
name
}}
</div>
<div
class=
"desc mt10"
>
{{
item
.
description
}}
</div>
<!--
<el-button
size=
"mini"
type=
"primary"
plain
@
click=
"sync(item)"
>
同步
</el-button>
-->
<div
class=
"list-action fxbw"
>
<!--
<el-button
type=
"text"
>
发送消息
</el-button>
-->
<el-button
type=
"text"
@
click=
"
id = item.id
dialogVisibleHistoryMsg = true
"
>
历史消息
</el-button>
<el-button
type=
"text"
@
click=
"edit(item)"
>
编辑
</el-button>
<el-button
type=
"text"
@
click=
"remove(item.id)"
>
删除
</el-button>
</div>
</li>
<li
class=
"list flex aic cp"
style=
"justify-content: center"
@
click=
"edit()"
>
<div
class=
"ac theme"
>
<i
class=
"el-icon-plus"
></i>
添加机器人
</div>
</li>
</ul>
<!-- 编辑,添加弹窗 -->
<el-dialog
:title=
"form.id ? '编辑' : '添加'"
:visible
.
sync=
"dialogVisible"
:close-on-click-modal=
"false"
width=
"580px"
>
<el-form
ref=
"form"
label-position=
"right"
:model=
"form"
:rules=
"rules"
label-width=
"80px"
>
<el-form-item
label=
"群名称"
prop=
"name"
>
<el-input
v-model=
"form.name"
placeholder=
"请输入群名称"
></el-input>
<div
class=
"dialog-tip"
>
如何获取:企微后台->应用管理->自建应用详情->AgentId
</div>
</el-form-item>
<el-form-item
label=
"WebHook"
prop=
"secret"
>
<el-input
v-model=
"form.secret"
placeholder=
"请输入WebHook URL"
></el-input>
<div
class=
"dialog-tip"
>
如何获取:企业微信内部群 -> 开启群机器人 -> 复制地址
</div>
</el-form-item>
</el-form>
<div
slot=
"footer"
>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"submit"
>
确 定
</el-button>
</div>
</el-dialog>
<!-- 历史消息 弹窗 -->
<el-dialog
title=
"历史消息"
:visible
.
sync=
"dialogVisibleHistoryMsg"
:close-on-click-modal=
"false"
>
<HistoryMsg
:id=
"id"
v-if=
"dialogVisibleHistoryMsg"
ref=
"historyMsg"
/>
</el-dialog>
</div>
</
template
>
<
style
lang=
"scss"
scoped
>
.theme
{
color
:
$
blue
;
}
.list-wrap
{
display
:
flex
;
flex-wrap
:
wrap
;
line-height
:
20px
;
.list
{
width
:
33%
;
height
:
218px
;
padding
:
20px
20px
10px
;
border
:
1px
solid
#eee
;
margin
:
0
20px
20px
0
;
background
:
#fff
;
border-radius
:
6px
;
.title
{
font-size
:
16px
;
}
.desc
{
color
:
#ddd
;
word-break
:
break-all
;
}
}
}
.dialog-tip
{
color
:
#888
;
font-size
:
12px
;
}
</
style
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment