提交 | 用户 | age
|
5dfa4a
|
1 |
<template> |
J |
2 |
<div class="app-container"> |
|
3 |
<!-- 返回按钮和标题 --> |
|
4 |
<!-- <el-page-header class="mb20" content="xx" @back="$router.go(-1)" /> --> |
|
5 |
|
|
6 |
<!-- 搜索区 ↓↓↓↓↓↓↓↓↓↓ --> |
|
7 |
<el-form v-show="showSearch" ref="searchForm" :inline="true"> |
|
8 |
<el-form-item label="批次名称"> |
|
9 |
<el-input |
|
10 |
v-model="batchName" |
|
11 |
placeholder="搜索批次名称" |
|
12 |
clearable |
|
13 |
size="small" |
|
14 |
style="width: 240px" |
|
15 |
maxlength="50" |
|
16 |
@keyup.enter.native="reGetList" |
|
17 |
/> |
|
18 |
</el-form-item> |
|
19 |
<el-form-item label="批次编号"> |
|
20 |
<el-input |
|
21 |
v-model="batchCode" |
|
22 |
placeholder="搜索批次编号" |
|
23 |
clearable |
|
24 |
size="small" |
|
25 |
style="width: 240px" |
|
26 |
maxlength="50" |
|
27 |
@keyup.enter.native="reGetList" |
|
28 |
/> |
|
29 |
</el-form-item> |
|
30 |
<el-form-item> |
|
31 |
<el-button type="cyan" icon="el-icon-search" size="mini" @click="reGetList">搜索</el-button> |
|
32 |
<el-button icon="el-icon-refresh" size="mini" @click="resetHandle">重置</el-button> |
f2a2b4
|
33 |
<el-button type="primary" icon="el-icon-download" size="mini" @click="exportList">下载发送模板</el-button> |
5dfa4a
|
34 |
</el-form-item> |
J |
35 |
</el-form> |
|
36 |
<!-- 搜索区 ↑↑↑↑↑↑↑↑↑↑ --> |
|
37 |
|
|
38 |
<!-- 操作区 ↓↓↓↓↓↓↓↓↓↓ --> |
|
39 |
<el-row :gutter="10" class="mb8"> |
|
40 |
<el-col :span="1.5"> |
|
41 |
<!-- 权限判断 v-if="getAuthValueFN('xxx_add')" --> |
|
42 |
<el-button |
|
43 |
type="primary" |
|
44 |
icon="el-icon-plus" |
|
45 |
size="mini" |
|
46 |
@click="showAddDialog" |
|
47 |
>临时发送</el-button> |
|
48 |
</el-col> |
|
49 |
<right-toolbar :show-search.sync="showSearch" @queryTable="getList" /> |
|
50 |
</el-row> |
|
51 |
<!-- 操作区 ↑↑↑↑↑↑↑↑↑↑ --> |
|
52 |
|
|
53 |
<!-- |
|
54 |
table参数设置: |
|
55 |
stripe 是否为斑马纹 |
|
56 |
border 是否带有纵向边框 |
|
57 |
max-height 最大高度 |
|
58 |
--> |
|
59 |
<el-table :data="list" stripe> |
|
60 |
<el-table-column type="index" label="序号" align="center" width="60" /> |
|
61 |
<el-table-column label="创建时间" prop="createTime" align="center" min-width="160" /> |
|
62 |
<el-table-column label="批次名称" prop="batchName" align="center" /> |
|
63 |
<el-table-column label="批次编号" prop="batchCode" align="center" /> |
|
64 |
<el-table-column label="期望发送时间" prop="timingTime" align="center" min-width="160" /> |
|
65 |
<el-table-column label="发送短信时间" prop="executionTime" align="center" min-width="160" /> |
|
66 |
<el-table-column label="发送成功总数" prop="sendSuccess" align="center" /> |
|
67 |
<el-table-column label="发送失败总数" prop="sendFail" align="center" /> |
|
68 |
<el-table-column label="发送总数" prop="sendTotal" align="center" /> |
|
69 |
<el-table-column label="状态" prop="status" align="center"> |
|
70 |
<template slot-scope="scope"> |
f2a2b4
|
71 |
<span v-if="scope.row.status == 0">待执行</span> |
J |
72 |
<span v-if="scope.row.status == 1">执行中</span> |
|
73 |
<span v-if="scope.row.status == 2">完成</span> |
|
74 |
<span v-if="scope.row.status == 3">取消</span> |
|
75 |
<span v-if="scope.row.status == 4">失败</span> |
5dfa4a
|
76 |
</template> |
J |
77 |
</el-table-column> |
|
78 |
<el-table-column label="短信模内容" prop="smsTemplate" align="center" min-width="160"> |
|
79 |
<template slot-scope="scope"> |
|
80 |
<el-popover |
|
81 |
placement="top-start" |
|
82 |
width="400" |
|
83 |
popper-class="el-popover_tableFilter" |
|
84 |
trigger="hover" |
|
85 |
:popper-options="{ removeOnDestroy: true }" |
|
86 |
> |
|
87 |
<div style="max-height: 500px;overflow-y: auto;">{{ scope.row.smsTemplate }}</div> |
|
88 |
<div slot="reference" class="line-clamp-2" style="line-height: 1.2">{{ scope.row.smsTemplate }}</div> |
|
89 |
</el-popover> |
|
90 |
</template> |
|
91 |
</el-table-column> |
|
92 |
<!-- <el-table-column label="是否上架" prop="isUp" align="center" min-width="100"> |
|
93 |
<template slot-scope="scope"> |
|
94 |
<el-switch |
|
95 |
v-model="scope.row.isUp" |
|
96 |
:active-value="1" |
|
97 |
:inactive-value="0" |
|
98 |
@change="handleUpChange(scope.row)" |
|
99 |
/> |
|
100 |
</template> |
|
101 |
</el-table-column> --> |
f2a2b4
|
102 |
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120"> |
5dfa4a
|
103 |
<template slot-scope="scope"> |
f2a2b4
|
104 |
<!-- <el-button |
5dfa4a
|
105 |
size="mini" |
J |
106 |
type="text" |
|
107 |
icon="el-icon-edit" |
|
108 |
@click="showEditDialog(scope.row)" |
f2a2b4
|
109 |
>编辑</el-button> --> |
5dfa4a
|
110 |
<el-button |
J |
111 |
size="mini" |
|
112 |
type="text warn" |
|
113 |
icon="el-icon-delete" |
|
114 |
@click="handleDelete(scope.row)" |
f2a2b4
|
115 |
>取消批次</el-button> |
5dfa4a
|
116 |
</template> |
f2a2b4
|
117 |
</el-table-column> |
5dfa4a
|
118 |
</el-table> |
J |
119 |
|
|
120 |
<!-- 新增&编辑 --> |
|
121 |
<el-dialog v-el-drag-dialog :title="'临时发送短信'" width="800px" :visible.sync="dialogVisible" append-to-body :before-close="hideDialog" :close-on-click-modal="false"> |
|
122 |
<el-form ref="refDialog" :model="dialogData" label-width="110px" :rules="rules" size="small"> |
|
123 |
<el-form-item label="批次名称" prop="batchName"> |
|
124 |
<el-input v-model="dialogData.batchName" placeholder="请输入批次名称" maxlength="255" /> |
|
125 |
</el-form-item> |
|
126 |
<el-form-item label="批次编号" prop="batchCode"> |
|
127 |
<el-input v-model="dialogData.batchCode" placeholder="请输入批次编号" maxlength="255" /> |
|
128 |
</el-form-item> |
|
129 |
<el-form-item label="上传文件" prop="uploadFiles"> |
|
130 |
<div class="upload_single_file"> |
|
131 |
<!-- 上传文件组件(单) --> |
|
132 |
<el-upload |
|
133 |
ref="refUploadFile" |
|
134 |
:auto-upload="false" |
|
135 |
action="#" |
|
136 |
:limit="1" |
|
137 |
:file-list="uploadFiles" |
|
138 |
:on-change="addUploadFile" |
|
139 |
:on-remove="delUploadFile" |
|
140 |
:http-request="uploadFileReq" |
|
141 |
:before-upload="beforeUploadFile" |
|
142 |
size="mini" |
|
143 |
> |
|
144 |
<el-button style="display: block" :disabled="uploadFiles&&uploadFiles.length>0" class="mb8" type="primary" size="small" icon="el-icon-plus">上传文件</el-button> |
|
145 |
</el-upload> |
|
146 |
</div> |
|
147 |
</el-form-item> |
|
148 |
<el-form-item label="短信模内容" prop="smsTemplate"> |
|
149 |
<el-input v-model="dialogData.smsTemplate" type="textarea" placeholder="请输入短信模版内容" maxlength="500" rows="5" /> |
|
150 |
</el-form-item> |
|
151 |
<!-- <el-form-item label="短信模内容" prop="smsTemplate"> |
|
152 |
<WangEnduit :catchdata="catchData" :content="dialogData.smsTemplate" :rangenum="rangenum" /> |
|
153 |
</el-form-item> --> |
|
154 |
</el-form> |
|
155 |
<div slot="footer" class="dialog-footer"> |
|
156 |
<el-button @click="hideDialog">取消</el-button> |
|
157 |
<el-button type="primary" @click="submitHandle">确定</el-button> |
|
158 |
</div> |
|
159 |
</el-dialog> |
|
160 |
|
|
161 |
<pagination |
|
162 |
v-show="total>0" |
|
163 |
:total="total" |
|
164 |
:page.sync="pageNum" |
|
165 |
:limit.sync="pageSize" |
|
166 |
@pagination="getList" |
|
167 |
/> |
|
168 |
|
|
169 |
<back-to-top :visibility-height="300" :back-position="50" transition-name="fade" /> |
|
170 |
</div> |
|
171 |
</template> |
|
172 |
|
|
173 |
<script> |
|
174 |
import BackToTop from '@/components/BackToTop' |
f2a2b4
|
175 |
import { getToken } from '@/utils/auth' // get token from session |
5dfa4a
|
176 |
// import WangEnduit from '@/components/WangEnduit' // 富文本 |
J |
177 |
export default { |
|
178 |
name: 'Index', |
|
179 |
components: { |
|
180 |
BackToTop |
|
181 |
// WangEnduit |
|
182 |
}, |
|
183 |
data() { |
|
184 |
return { |
|
185 |
showSearch: true, // 是否显示搜索区 |
|
186 |
// keyWord: '', // 搜索区字段,可自行扩展其余字段 |
|
187 |
batchName: '', |
|
188 |
batchCode: '', |
|
189 |
|
|
190 |
objectName: '短信', // 对象名称,用于删除提示、启用提示、弹窗标题等 |
|
191 |
|
|
192 |
// 数据列表 |
|
193 |
list: [], |
|
194 |
userList: [], // 用户列表 |
|
195 |
|
|
196 |
uploadFiles: [], // 上传文件 |
|
197 |
|
|
198 |
// 弹窗数据 |
|
199 |
dialogVisible: false, |
|
200 |
dialogData: {}, |
|
201 |
|
|
202 |
// 富文本编辑器 |
|
203 |
// rangenum: null, |
|
204 |
|
|
205 |
// 分页 ↓↓↓↓↓↓↓↓↓↓ |
|
206 |
total: 0, |
|
207 |
pageNum: 1, |
|
208 |
pageSize: 20, |
|
209 |
// 分页 ↑↑↑↑↑↑↑↑↑↑ |
|
210 |
|
|
211 |
// 表单校验 |
|
212 |
rules: { |
|
213 |
batchName: [ |
|
214 |
{ required: true, message: '批次名称不能为空', trigger: 'change' } |
|
215 |
], |
|
216 |
batchCode: [ |
|
217 |
{ required: true, message: '批次编号不能为空', trigger: 'change' } |
|
218 |
], |
|
219 |
smsTemplate: [ |
|
220 |
{ required: true, message: '短信模内容不能为空', trigger: 'change' } |
|
221 |
] |
|
222 |
// isUp: [ |
|
223 |
// { required: true, message: '是否上架不能为空', trigger: 'change' } |
|
224 |
// ] |
|
225 |
} |
|
226 |
} |
|
227 |
}, |
|
228 |
mounted() { |
|
229 |
this.init() |
|
230 |
}, |
|
231 |
methods: { |
|
232 |
// 初始化 |
|
233 |
init() { |
|
234 |
this.getList() |
|
235 |
}, |
|
236 |
|
|
237 |
// ========== 富文本相关 |
|
238 |
// 富文本编辑器的内容赋值 |
|
239 |
// catchData(content) { |
|
240 |
// if (content === '<p><br></p>') content = '' |
|
241 |
// try { |
|
242 |
// const currentRange = window.getSelection().getRangeAt(0) |
|
243 |
// this.rangenum = currentRange |
|
244 |
// } catch (e) { |
|
245 |
// console.log(e) |
|
246 |
// } |
|
247 |
// this.$set(this.dialogData, 'smsTemplate', content) |
|
248 |
// this.$refs['refDialog'].validateField('smsTemplate') |
|
249 |
// }, |
|
250 |
// ========== 富文本相关 |
|
251 |
|
|
252 |
// 获取列表 |
|
253 |
getList() { |
|
254 |
var { pageNum, pageSize, batchName, batchCode } = this |
|
255 |
this.postFN({ |
|
256 |
url: 'send-general/list', |
|
257 |
header: { 'Content-Type': 'application/json;charset=UTF-8' }, |
|
258 |
params: { |
|
259 |
pageNum: pageNum, |
|
260 |
pageSize: pageSize, |
|
261 |
|
|
262 |
batchName: batchName, |
|
263 |
batchCode: batchCode |
|
264 |
}, |
|
265 |
mockData: { |
|
266 |
code: 100, |
|
267 |
msg: '', |
|
268 |
data: { |
|
269 |
list: [{ |
|
270 |
id: 'xxx', |
|
271 |
index: 1, |
|
272 |
name: '超级管理员', |
|
273 |
createTime: '2020-08-09 10:10:10' |
|
274 |
}], |
|
275 |
total: 100 |
|
276 |
} |
|
277 |
} |
|
278 |
}, (inf) => { |
|
279 |
this.list = inf.list || [] |
|
280 |
this.userList = inf.userList || [] |
|
281 |
this.total = inf.total |
|
282 |
}) |
|
283 |
}, |
|
284 |
// 重新获取列表 |
|
285 |
reGetList() { |
|
286 |
this.pageNum = 1 |
|
287 |
this.getList() |
|
288 |
}, |
|
289 |
// 重置 |
|
290 |
resetHandle() { |
|
291 |
this.batchCode = '' |
|
292 |
this.batchName = '' |
|
293 |
this.reGetList() |
|
294 |
}, |
|
295 |
// 删除 |
|
296 |
handleDelete(item) { |
|
297 |
// 打开二次确认弹窗 |
f2a2b4
|
298 |
this.$confirm('是否确认取消该短信批次?', '提示', { |
5dfa4a
|
299 |
confirmButtonText: '确定', |
J |
300 |
cancelButtonText: '取消', |
|
301 |
type: 'warning' |
|
302 |
}).then(() => { |
|
303 |
// 确定回调 |
|
304 |
this.postFN({ |
f2a2b4
|
305 |
url: 'send-general/cancel', |
J |
306 |
header: { 'Content-Type': 'application/json;charset=UTF-8' }, |
5dfa4a
|
307 |
params: { |
J |
308 |
id: item.id |
|
309 |
}, |
|
310 |
mockData: { |
|
311 |
code: 100, |
|
312 |
msg: '', |
|
313 |
data: {} |
|
314 |
} |
|
315 |
}, () => { |
|
316 |
this.getList() |
f2a2b4
|
317 |
this.$messageSuc('取消成功') |
5dfa4a
|
318 |
}) |
J |
319 |
}).catch(() => {}) |
|
320 |
}, |
|
321 |
// 修改是否上架 |
|
322 |
handleUpChange(item) { |
|
323 |
const text = item.isUp === 1 ? '上架' : '下架' |
|
324 |
this.$confirm('确认要' + text + '该' + this.objectName + '吗?', '提示', { |
|
325 |
confirmButtonText: '确定', |
|
326 |
cancelButtonText: '取消', |
|
327 |
type: 'warning' |
|
328 |
}).then(() => { |
|
329 |
// TODO url |
|
330 |
this.postFN({ |
|
331 |
url: 'xxx', |
|
332 |
params: { |
|
333 |
id: item.id, |
|
334 |
isUp: item.isUp |
|
335 |
}, |
|
336 |
mockData: { |
|
337 |
code: 100, |
|
338 |
msg: '', |
|
339 |
data: {} |
|
340 |
} |
|
341 |
}, () => { |
|
342 |
this.$messageSuc(text + '成功') |
|
343 |
}, (res) => { |
|
344 |
item.isUp = item.isUp === 1 ? 0 : 1 |
|
345 |
this.$messageError(res.msg) |
|
346 |
}) |
|
347 |
}).catch(() => { |
|
348 |
item.isUp = item.isUp === 1 ? 0 : 1 |
|
349 |
}) |
|
350 |
}, |
|
351 |
|
|
352 |
// 打开新增弹窗 |
|
353 |
showAddDialog() { |
|
354 |
var dialogData = { |
|
355 |
batchCode: '', |
|
356 |
batchName: '', |
|
357 |
smsTemplate: '' |
|
358 |
} |
|
359 |
this.uploadFiles = [] |
|
360 |
this.dialogVisible = true |
|
361 |
this.$nextTick(() => { |
|
362 |
this.dialogData = dialogData |
|
363 |
this.$refs['refDialog'].resetFields() |
|
364 |
}) |
|
365 |
}, |
|
366 |
// 打开编辑弹框 |
|
367 |
showEditDialog(item) { |
|
368 |
var dialogData = { |
|
369 |
type: 'edit', |
|
370 |
...item |
|
371 |
} |
|
372 |
console.log('dialogData', dialogData) |
|
373 |
this.dialogVisible = true |
|
374 |
this.$nextTick(() => { |
|
375 |
this.dialogData = dialogData |
|
376 |
this.$refs['refDialog'].resetFields() |
|
377 |
}) |
|
378 |
}, |
|
379 |
// 关闭编辑弹窗 |
|
380 |
hideDialog() { |
|
381 |
this.dialogData = { |
|
382 |
|
|
383 |
} |
|
384 |
this.dialogVisible = false |
|
385 |
// 清空富文本 |
|
386 |
// this.rangenum = null |
|
387 |
}, |
|
388 |
// 提交新增&编辑 |
|
389 |
submitHandle() { |
|
390 |
this.$refs['refDialog'].validate(valid => { |
|
391 |
if (valid) { |
|
392 |
this.uploadFileReq() |
|
393 |
// this.submitReq() |
|
394 |
} |
|
395 |
}) |
|
396 |
}, |
|
397 |
// 提交接口 |
|
398 |
submitReq() { |
|
399 |
var { dialogData } = this |
|
400 |
var params = { |
|
401 |
name: dialogData.name, |
|
402 |
isUp: dialogData.isUp |
|
403 |
// TODO 参数 |
|
404 |
} |
|
405 |
|
|
406 |
if (dialogData.password) params.password = dialogData.password |
|
407 |
|
|
408 |
var isAdd = dialogData.type === 'add' |
|
409 |
// TODO url |
|
410 |
var url = isAdd ? 'xxx/add' : 'xxx/edit' |
|
411 |
|
|
412 |
!isAdd && (params.id = dialogData.id) |
|
413 |
|
|
414 |
this.postFN({ |
|
415 |
url: url, |
|
416 |
params: params, |
|
417 |
mockData: { |
|
418 |
code: 100, |
|
419 |
msg: '', |
|
420 |
data: {} |
|
421 |
} |
|
422 |
}, () => { |
|
423 |
this.$messageSuc('保存成功') |
|
424 |
this.hideDialog() |
|
425 |
isAdd ? this.reGetList() : this.getList() |
|
426 |
}) |
|
427 |
}, |
|
428 |
// 上传文件 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ |
|
429 |
// 上传前确认格式 |
|
430 |
beforeUploadFile(file) { |
|
431 |
const isTooLarge = file.size / 1024 / 1024 > 50 |
|
432 |
let flag = true |
|
433 |
if (isTooLarge) { |
|
434 |
this.$message.error('请勿上传大于50MB的文件') |
|
435 |
flag = false |
|
436 |
} |
|
437 |
return flag |
|
438 |
}, |
|
439 |
// 增加文件 |
|
440 |
addUploadFile(file, fileList) { |
|
441 |
this.uploadFiles = fileList |
|
442 |
}, |
|
443 |
// 删除文件 |
|
444 |
delUploadFile(file, fileList) { |
|
445 |
this.uploadFiles = fileList |
|
446 |
}, |
|
447 |
// 执行上传商品图 |
|
448 |
runUploadFile(suc_cb) { |
|
449 |
if (this.checkNeedUpload(this.uploadFiles)) { |
|
450 |
this.callback = suc_cb |
|
451 |
this.$refs.refUploadFile.submit() |
|
452 |
} else { |
|
453 |
suc_cb && suc_cb() |
|
454 |
} |
|
455 |
}, |
|
456 |
// 上传文件 |
|
457 |
uploadFileReq() { |
|
458 |
var { dialogData, uploadFiles } = this |
|
459 |
var file |
|
460 |
uploadFiles[0] && (file = uploadFiles[0].raw) |
|
461 |
const formData = new FormData() |
|
462 |
for (const key in dialogData) { |
|
463 |
formData.append(key, dialogData[key]) |
|
464 |
} |
|
465 |
formData.append('file', file) |
|
466 |
if (!file) { |
|
467 |
this.$message.error('请上传文件') |
|
468 |
return |
|
469 |
} |
|
470 |
console.log('/*******************提交数据formData/', dialogData, file) |
|
471 |
this.postFN({ |
|
472 |
url: 'send-general/temporary-send', |
|
473 |
header: { 'Content-Type': 'multipart/form-data' }, |
|
474 |
params: formData, |
|
475 |
mockData: { |
|
476 |
code: 100, |
|
477 |
msg: '', |
|
478 |
data: { |
|
479 |
imgUrl: '上传文件成功' |
|
480 |
} |
|
481 |
} |
|
482 |
}, (inf) => { |
|
483 |
console.log('上传文件成功且结束', inf) |
|
484 |
|
|
485 |
this.reGetList() |
|
486 |
|
|
487 |
this.hideDialog() |
|
488 |
|
|
489 |
// 提交 |
|
490 |
// this.$set(this.dialogData, 'imgUrl', inf.imgUrl) |
|
491 |
// this.callback && this.callback(inf.imgUrl) |
|
492 |
}) |
|
493 |
}, |
|
494 |
// 获取文件后缀名 |
|
495 |
extname(filename) { |
|
496 |
if (!filename || typeof filename !== 'string') { |
|
497 |
return '' |
|
498 |
} |
|
499 |
const a = filename.split('').reverse().join('') |
|
500 |
const b = a.substring(0, a.search(/\./)).split('').reverse().join('') |
|
501 |
return b |
f2a2b4
|
502 |
}, |
5dfa4a
|
503 |
// 上传文件 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |
f2a2b4
|
504 |
// 导出列表 |
J |
505 |
exportList() { |
|
506 |
var adminToken = getToken() |
|
507 |
const path = `${window.location.protocol}//${window.location.host}/sms/send-general/get/temp?adminToken=${adminToken}` |
|
508 |
console.log('path', path) |
|
509 |
window.location.href = path |
|
510 |
} |
5dfa4a
|
511 |
} |
J |
512 |
} |
|
513 |
</script> |
|
514 |
|
|
515 |
<style lang="scss" scoped> |
|
516 |
.upload_single_file .el-upload-list__item-name{ |
|
517 |
padding: 5px!important; |
|
518 |
} |
|
519 |
</style> |