email.js
3.95 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
define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
var Controller = {
index : function () {
// 初始化表格参数配置
Table.api.init({
extend : {
index_url : 'antis/general/email/index',
add_url : 'antis/general/email/add',
edit_url : 'antis/general/email/edit',
del_url : 'antis/general/email/del',
table : 'email'
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url : $.fn.bootstrapTable.defaults.extend.index_url,
sortName : 'id',
pageSize:1000,
columns : [
[
{field : 'name', title : __('名称'), width : 200},
{field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: false},
{field: 'updatetime', title: __('更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
],
pageList:['ALL'],
//启用普通表单搜索
commonSearch : false,
searchFormVisible : false,
onLoadSuccess:function(){
// 这里就是数据渲染结束后的回调函数
$('.btn-editone').html('编辑');
$('.fa-pencil').remove();
$('.btn-delone').html('删除');
$('.fa-trash').remove();
$('.btn-editone').removeClass('btn-success')
$('.btn-editone').removeClass('btn')
$('.btn-delone').removeClass('btn')
$('.btn-delone').removeClass('btn-danger')
}
});
// 为表格绑定事件
Table.api.bindevent(table);
$('.search').hide();
$('.btn-import').hide();
},
batch_send_email : function () {
$(document).on('change','#c-template_id',function (){
var templater_id=$(this).val();
var url=location.pathname + location.search;
var content=$("#c-content").val();
if (content){
Layer.confirm(
__('邮件已经存在内容,确定要覆盖吗?'),
{icon: 3, title: __('Warning'), shadeClose: true},
function (index) {
location=url+"&templater_id="+templater_id
layer.close(index);
return;
}
);
}else{
location=url+"&templater_id="+templater_id;
return;
}
});
Controller.api.bindevent();
},
send_email : function () {
$(document).on('change','#c-template_id',function (){
var templater_id=$(this).val();
var url=location.pathname + location.search;
var content=$("#c-content").val();
if (content){
Layer.confirm(
__('邮件已经存在内容,确定要覆盖吗?'),
{icon: 3, title: __('Warning'), shadeClose: true},
function (index) {
location=url+"&templater_id="+templater_id
layer.close(index);
return;
}
);
}else{
location=url+"&templater_id="+templater_id;
return;
}
});
Controller.api.bindevent();
},
add : function () {
$(document).on('click','.variable_name',function (){
var c_content=$('#c-content');
var html=c_content.val();
c_content.val(html+$(this).data('value'));
});
Controller.api.bindevent();
},
edit : function () {
$(document).on('click','.variable_name',function (){
var c_content=$('#c-content');
var html=c_content.val();
c_content.val(html+$(this).data('value'));
});
Controller.api.bindevent();
},
api : {
bindevent : function () {
Form.api.bindevent($("form[role=form]"));
},
formatter : {
thumb : function (value, row, index) {
var style = row.storage == 'upyun' ? '!/fwfh/120x90' : '';
return '<img src="' + row.image + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
},
}
}
};
return Controller;
});