Index.js
3.33 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
/**
* Created by ty on 2016/3/23.
* 平台管理
*/
var $ = require('jquery'),
common = require('../../../common/common'),
util = require('../../../common/util');
var g = new common.grid({
el: "#content-list",
hash: false,
columns: [
{display: "平台ID", name: "platformId"},
{display: "平台名称", name: "platformName"},
{display: "平台标志", name: "platformFlag"},
{display: "状态", name: "", render: function(item) {
if(item.status == 0) {
return "关闭";
} else if(item.status == 1) {
return "开启";
}
}},
{display: "添加时间", name: "", render: function(item) {
return Bll.getLocalTime(item.createTime);
}},
{
display: "操作",name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-xs btn-primary add2" data-index="' + item.__index + '">编辑</a>');
arr.push('<a class="btn btn-xs btn-danger delbtn" data-index="' + item.__index + '">删除</a>');
return arr.join("");
}
}
]
});
g.init("/resources/findResPlatforms");
var Bll = {
getLocalTime:function(nS) {
var date = new Date(parseInt(nS) * 1000);
var mm = date.getMonth() + 1;
var dd = date.getDate();
var h = date.getHours();
var min = date.getMinutes();
var second = date.getSeconds();
return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd) + " " + (h < 10 ? "0" + h : h) + ":"
+ (min < 10 ? "0" + min : min) + ":" + (second < 10 ? "0" + second : second);
},
toast:function(url, item, hint) {
var e = new common.edit("#base-form");
e.on('validate', function() {
if(!$("#status").val()) {
return "请填写状态";
}
});
var dialog=common.dialog.confirm(hint,
common.util.__template2($("#platform-template").html(), item),
function() {
e.submit(url,function(option){
//option.data;
//console.log(option.data);
option.success=function(res){
dialog.close();
util.__tip(res.message, 'success');
g.reload();
};
option.error=function(res){
dialog.close();
util.__tip(res.message);
}
});
return false;
});
e.init();
}
};
$(document).on('click', '#add-platform', function() {
var item = {};
Bll.toast("/resources/addResPlatform", item, "添加平台");
});
$(document).on('click', '.add2', function() {
var item = g.rows[$(this).data("index")];
Bll.toast("/resources/updateResPlatform", item, "修改平台");
});
$(document).on('click', '.delbtn', function() {
var item=g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function() {
common.util.__ajax({
url:'/resources/deleteResPlatform',
data:{platformId:item.platformId}
},function() {
g.reload();
});
});
});