match_cert.js
3.3 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
define(['jquery', 'bootstrap', 'backend', 'table', 'form','upload','clipboard'], function ($, undefined, Backend, Table, Form,Upload,ClipboardJS) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'match/match_cert/index' + location.search,
add_url: 'match/match_cert/add',
edit_url: 'match/match_cert/edit',
del_url: 'match/match_cert/del',
table: 'match_cert',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
searchFormVisible: false,
search:false,
clickToSelect: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{field: 'cert_name', title: __('证书名称'),operate: false},
{field: 'cert_url', title: __('证书Url'),operate: false,formatter:function (value,row,index){
return '<a href="javascript:;" data-clipboard-text="'+value+'" class="btn-copy" data-toggle="tooltip" data-original-title="点击复制">'+value+'</a>';
}},
]
]
});
var clipboard = new ClipboardJS('.btn-copy');
clipboard.on('success', function(e) {
Toastr.success('复制成功');
});
clipboard.on('error', function(e) {
Toastr.error('复制失败,请刷新后重试');
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
$("#cert_url_upload").data("upload-error", function(res,result){
if(result.code == 0) {
Toastr.error("上传失败!");
return false;
}
});
$("#cert_url_upload").data("upload-success", function (res) {
console.log(res);
var url = Backend.api.cdnurl(res.url);
$("#c-cert_url").val(url);
Toastr.success("上传成功!");
return false;
});
Controller.api.bindevent();
},
edit: function () {
$("#cert_url_upload").data("upload-error", function(res,result){
if(result.code == 0) {
Toastr.error("上传失败!");
return false;
}
});
$("#cert_url_upload").data("upload-success", function (res) {
console.log(res);
var url = Backend.api.cdnurl(res.url);
$("#c-cert_url").val(url);
Toastr.success("上传成功!");
return false;
});
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});