list.vue
6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<script>
import { getList, update, add, remove, appMsg } from '@/api/internalCollaborate/groupRobot'
export default {
components: { HistoryMsg: () => import('./HistoryMsg'), MsgForm: () => import('../components/MsgForm') },
props: {},
data() {
return {
form: {},
list: [],
dialogVisible: false,
disabled: false,
loading: false,
rules: Object.freeze({
groupName: [{ required: true, message: '必填项', trigger: 'blur' }],
webHookUrl: [{ required: true, message: '必填项', trigger: 'blur' }],
}),
formMsg: {},
dialogVisibleHistoryMsg: false,
dialogVisibleSendMsg: false,
}
},
watch: {},
computed: {},
created() {
this.getList()
this.$store.dispatch('app/setBusininessDesc', `<div>通过群机器人给内部群发送消息,通知员工</div> `)
},
mounted() {},
methods: {
getList(page) {
this.loading = true
getList()
.then(({ rows, total }) => {
this.list = rows
})
.finally(() => {
this.loading = false
})
},
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('删除成功')
})
},
// 发送消息确认按钮
submitSendMsg(form) {
if (form) {
;(form.id ? appMsg.update : appMsg.add)(form)
.then(() => {
this.msgSuccess('操作成功')
this.dialogVisibleSendMsg = false
})
.catch(() => {
this.dialogVisibleSendMsg = false
})
} else {
this.dialogVisibleSendMsg = false
}
},
// 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="list-item">
<div class="title blod toe">{{ item.groupName }}</div>
<div class="desc mt10">
{{ item.webHookUrl }}
</div>
<!-- <el-button size="mini" type="primary" plain @click="sync(item)">同步</el-button> -->
<div class="list-action fxbw">
<el-button
type="text"
@click="
formMsg = { robotId: item.id }
disabledMsg = false
dialogVisibleSendMsg = true
">
发送消息
</el-button>
<el-button
type="text"
@click="
formMsg = { robotId: 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>
</div>
</li>
<li class="list" @click="edit()">
<div class="ac flex aic cp theme list-item" style="justify-content: center">
<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="90px">
<el-form-item label="群名称" prop="groupName">
<el-input v-model="form.groupName" placeholder="请输入群名称"></el-input>
<div class="dialog-tip">如何获取:企微后台->应用管理->自建应用详情->AgentId</div>
</el-form-item>
<el-form-item label="WebHook" prop="webHookUrl">
<el-input v-model="form.webHookUrl" 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="formMsg.robotId"
v-if="dialogVisibleHistoryMsg"
ref="historyMsg"
@edit="
(data, type) => {
dialogVisibleSendMsg = true
disabledMsg = true
formMsg = data
}
" />
</el-dialog>
<!-- 编辑/详情发送消息 弹窗 -->
<el-dialog title="发送消息" :visible.sync="dialogVisibleSendMsg" :close-on-click-modal="false">
<MsgForm v-if="dialogVisibleSendMsg" :data="formMsg" :disabled="disabledMsg" @submit="submitSendMsg" />
</el-dialog>
</div>
</template>
<style lang="scss" scoped>
.theme {
color: var(--color);
}
.list-wrap {
display: flex;
flex-wrap: wrap;
line-height: 20px;
.list {
width: 33.3%;
overflow: hidden;
}
.list-item {
height: 128px;
padding: 20px 20px 0;
border: 1px solid #eee;
margin: 0 20px 20px 0;
background: #fff;
border-radius: 6px;
.title {
font-size: 16px;
}
.desc {
color: #ddd;
height: 40px;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
}
}
}
.dialog-tip {
color: #888;
font-size: 12px;
}
</style>