44
44
<el-table-column label =" 模板编码" align =" center" prop =" code" />
45
45
<el-table-column label =" 模板名称" align =" center" prop =" name" />
46
46
<el-table-column label =" 模板标题" align =" center" prop =" title" />
47
+ <el-table-column label =" 模板内容" align =" center" prop =" content" :show-overflow-tooltip =" true" />
47
48
<el-table-column label =" 邮箱账号" align =" center" prop =" accountId" width =" 200" >
48
49
<template v-slot =" scope " >
49
50
{{ accountOptions.find(account => account.id === scope.row.accountId)?.mail }}
55
56
<dict-tag :type =" DICT_TYPE.COMMON_STATUS" :value =" scope.row.status" />
56
57
</template >
57
58
</el-table-column >
58
- <el-table-column label =" 备注" align =" center" prop =" remark" />
59
59
<el-table-column label =" 创建时间" align =" center" prop =" createTime" width =" 180" >
60
60
<template v-slot =" scope " >
61
61
<span >{{ parseTime(scope.row.createTime) }}</span >
62
62
</template >
63
63
</el-table-column >
64
- <el-table-column label =" 操作" align =" center" class-name =" small-padding fixed-width" >
64
+ <el-table-column label =" 操作" align =" center" class-name =" small-padding fixed-width" width = " 150 " >
65
65
<template v-slot =" scope " >
66
+ <el-button size =" mini" type =" text" icon =" el-icon-share" @click =" handleSend(scope.row)"
67
+ v-hasPermi =" ['system:mail-template:send-mail']" >测试</el-button >
66
68
<el-button size =" mini" type =" text" icon =" el-icon-edit" @click =" handleUpdate(scope.row)"
67
69
v-hasPermi =" ['system:mail-template:update']" >修改</el-button >
68
70
<el-button size =" mini" type =" text" icon =" el-icon-delete" @click =" handleDelete(scope.row)"
112
114
<el-button @click =" cancel" >取 消</el-button >
113
115
</div >
114
116
</el-dialog >
117
+
118
+ <!-- 对话框(发送邮件) -->
119
+ <el-dialog title =" 测试发送邮件" :visible.sync =" sendOpen" width =" 500px" append-to-body >
120
+ <el-form ref =" sendForm" :model =" sendForm" :rules =" sendRules" label-width =" 140px" >
121
+ <el-form-item label =" 模板内容" prop =" content" >
122
+ <el-input v-model =" sendForm.content" type =" textarea" placeholder =" 请输入模板内容" readonly />
123
+ </el-form-item >
124
+ <el-form-item label =" 收件邮箱" prop =" mail" >
125
+ <el-input v-model =" sendForm.mail" placeholder =" 请输入收件邮箱" />
126
+ </el-form-item >
127
+ <el-form-item v-for =" param in sendForm.params" :key =" param" :label =" '参数 {' + param + '}'" :prop =" 'templateParams.' + param" >
128
+ <el-input v-model =" sendForm.templateParams[param]" :placeholder =" '请输入 ' + param + ' 参数'" />
129
+ </el-form-item >
130
+ </el-form >
131
+ <div slot =" footer" class =" dialog-footer" >
132
+ <el-button type =" primary" @click =" submitSendForm" >确 定</el-button >
133
+ <el-button @click =" cancelSend" >取 消</el-button >
134
+ </div >
135
+ </el-dialog >
115
136
</div >
116
137
</template >
117
138
118
139
<script >
119
- import { createMailTemplate , updateMailTemplate , deleteMailTemplate , getMailTemplate , getMailTemplatePage } from " @/api/system/mail/template" ;
140
+ import { createMailTemplate , updateMailTemplate , deleteMailTemplate , getMailTemplate , getMailTemplatePage , sendMail } from " @/api/system/mail/template" ;
120
141
import Editor from ' @/components/Editor' ;
121
142
import { CommonStatusEnum } from " @/utils/constants" ;
122
143
import { getSimpleMailAccountList } from " @/api/system/mail/account" ;
@@ -130,8 +151,6 @@ export default {
130
151
return {
131
152
// 遮罩层
132
153
loading: true ,
133
- // 导出遮罩层
134
- exportLoading: false ,
135
154
// 显示搜索条件
136
155
showSearch: true ,
137
156
// 总条数
@@ -164,7 +183,18 @@ export default {
164
183
status: [{ required: true , message: " 开启状态不能为空" , trigger: " blur" }],
165
184
},
166
185
// 邮箱账号
167
- accountOptions: []
186
+ accountOptions: [],
187
+
188
+ // 发送邮箱
189
+ sendOpen: false ,
190
+ sendForm: {
191
+ params: [], // 模板的参数列表
192
+ },
193
+ sendRules: {
194
+ mail: [{ required: true , message: " 收件邮箱不能为空" , trigger: " blur" }],
195
+ templateCode: [{ required: true , message: " 模版编码不能为空" , trigger: " blur" }],
196
+ templateParams: { }
197
+ }
168
198
};
169
199
},
170
200
created () {
@@ -263,7 +293,56 @@ export default {
263
293
this .getList ();
264
294
this .$modal .msgSuccess (" 删除成功" );
265
295
}).catch (() => {});
266
- }
296
+ },
297
+ /** 发送短息按钮 */
298
+ handleSend (row ) {
299
+ this .resetSend (row);
300
+ // 设置参数
301
+ this .sendForm .content = row .content ;
302
+ this .sendForm .params = row .params ;
303
+ this .sendForm .templateCode = row .code ;
304
+ this .sendForm .templateParams = row .params .reduce (function (obj , item ) {
305
+ obj[item] = undefined ;
306
+ return obj;
307
+ }, {});
308
+ // 根据 row 重置 rules
309
+ this .sendRules .templateParams = row .params .reduce (function (obj , item ) {
310
+ obj[item] = { required: true , message: ' 参数 ' + item + " 不能为空" , trigger: " change" };
311
+ return obj;
312
+ }, {});
313
+ // 设置打开
314
+ this .sendOpen = true ;
315
+ },
316
+ /** 重置发送邮箱的表单 */
317
+ resetSend () {
318
+ // 根据 row 重置表单
319
+ this .sendForm = {
320
+ content: undefined ,
321
+ params: undefined ,
322
+ mobile: undefined ,
323
+ templateCode: undefined ,
324
+ templateParams: {}
325
+ };
326
+ this .resetForm (" sendForm" );
327
+ },
328
+ /** 取消发送邮箱 */
329
+ cancelSend () {
330
+ this .sendOpen = false ;
331
+ this .resetSend ();
332
+ },
333
+ /** 提交按钮 */
334
+ submitSendForm () {
335
+ this .$refs [" sendForm" ].validate (valid => {
336
+ if (! valid) {
337
+ return ;
338
+ }
339
+ // 添加的提交
340
+ sendMail (this .sendForm ).then (response => {
341
+ this .$modal .msgSuccess (" 提交发送成功!发送结果,见发送日志编号:" + response .data );
342
+ this .sendOpen = false ;
343
+ });
344
+ });
345
+ },
267
346
}
268
347
};
269
348
</script >
0 commit comments