record.vue
6.44 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
<template>
<div>
<el-form :model="query" ref="queryForm" :inline="true" label-position="left" class="top-search" label-width="70px">
<el-form-item label="群发内容" prop="content">
<el-input v-model="query.content" placeholder="请输入群发内容" clearable @keyup.enter.native="getList(1)" />
</el-form-item>
<el-form-item label="群发类型" prop="chatType">
<el-select v-model="query.chatType" placeholder="请选择群发类型">
<el-option v-for="(value, key, index) in pushType" :label="value" :value="key" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="发送类型" prop="isTask">
<el-select v-model="query.isTask" placeholder="请选择发送类型">
<el-option v-for="(value, key, index) in timedTask" :label="value" :value="key" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label-width="0">
<el-button type="primary" @click="getList(1)">查询</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<div class="g-card">
<div class="mid-action">
<el-button type="primary" @click="goRoute('', '', '', 'add')">新建群发</el-button>
</div>
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table-column label="群发内容" align="center" prop="content" />
<el-table-column label="群发类型" align="center">
<template slot-scope="scope">
{{ pushType[scope.row.chatType] }}
</template>
</el-table-column>
<el-table-column label="发送类型" align="center">
<template slot-scope="scope">
{{ timedTask[scope.row.isTask] }}
</template>
</el-table-column>
<el-table-column label="发送时间" align="center" prop="sendTime" width="180"></el-table-column>
<el-table-column label="最近更新时间" align="center" prop="createTime" width="180"></el-table-column>
<el-table-column label="操作" align="center" width="180">
<template slot-scope="scope">
<!-- v-hasPermi="['enterpriseWechat:view']" -->
<el-button type="text" @click="goRoute(scope.row.id, scope.row.isTask, scope.row.status, 'detail')">
详情
</el-button>
<el-button
v-if="scope.row.isTask === 1 && scope.row.status === 0"
type="text"
@click="cancelSend(scope.row)">
取消发送
</el-button>
<!-- <el-button v-hasPermi="['enterpriseWechat:edit']" type="text" disabled=""
@click="goRoute(scope.row, 1)">编辑</el-button>
<el-button v-hasPermi="['enterpriseWechat:edit']" type="text"
@click="syncMsg(scope.row)">同步</el-button> -->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
@pagination="getList()" />
</div>
</div>
</template>
<script>
import { getList, syncMsg, cancelSend } from '@/api/groupMessage'
export default {
name: 'Operlog',
data() {
return {
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 总条数
total: 0,
// 表格数据
list: [],
// 日期范围
dateRange: [],
// 查询参数
query: {
pageNum: 1,
pageSize: 10,
content: undefined,
chatType: undefined,
isTask: undefined,
orderByColumn: 'create_time',
isAsc: 'desc',
},
pushType: {
1: '发给客户',
2: '发给客户群',
},
timedTask: {
0: '立即发送',
1: '定时发送',
},
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now() // 选当前时间之前的时间
},
},
}
},
created() {
this.getList()
},
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
getList(this.query)
.then(({ rows, total }) => {
this.list = rows
this.total = Number(total)
this.loading = false
this.ids = []
})
.catch(() => {
this.loading = false
})
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.$refs['queryForm'].resetFields()
this.getList(1)
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id)
},
/** 删除按钮操作 */
handleDelete(row) {
const operIds = row.operId || this.ids
this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(function () {})
.then(() => {
this.getList()
this.msgSuccess('删除成功')
})
.catch(function () {})
},
goRoute(id, isTask, status, path) {
const query = {}
if (id) {
query.id = id
}
if (isTask) {
query.isTask = isTask
}
if (status) {
query.status = status
}
this.$router.push({
path: './' + path,
query,
})
},
syncMsg(data) {
let { msgid, messageId } = data
syncMsg(this, {
msgids: [msgid],
messageId,
})
.then(({ data }) => {
this.msgSuccess('同步成功')
this.getList()
// this.list = rows
// this.total = +total
// this.loading = false
// this.ids = []
})
.catch(() => {
// this.loading = false
})
},
cancelSend(data) {
cancelSend(data.id).then((res) => {
if (res.code == 200) {
this.getList()
this.msgSuccess('操作成功')
} else {
this.msgError(res.msg || '操作失败')
}
})
},
},
}
</script>
<style lang="scss" scoped>
.my-divider {
display: block;
height: 1px;
width: 100%;
background-color: #dcdfe6;
}
</style>