Category.js
3.8 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
//帮助分类
var $ = require('jquery');
common = require('../../common/common');
var g = new common.grid({
el: '#help_list',
hash: false,
parms:function(){
return {
platform: common.util.__input("platform")
}
},
columns: [
{display: "编号", name: "id"},
{display: "分类名称", name: "categoryName"},
{
display: "显示平台", name: "platform", render: function (item) {
if (item.platform != null && item.platform.trim() != "") {
var platform = item.platform;
var temp = platform.replace("iphone", "IOS手机").replace("ipad", "IOS Pad")
.replace("android", "安卓手机").replace("androidpad", "安卓Pad")
.replace("h5", "手机网站").replace("web", "网站")
.replace("platform", "平台").replace(/\|/g, " ");
return temp;
}
}
},
{display: "时间", name: "createTime"},
{
display: "操作", name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-info btn-xs add2" data-index="' + item.__index + '">编辑</a>');
arr.push('<a class="btn btn-danger btn-xs delbtn" data-index="' + item.__index + '">删除</a>');
return arr.join('');
}
}
]
});
g.init("/operations/helpcategory/getAllHelpCategory");
// 筛选
$(document).on('click', "#filter-btn", function() {
g.reload(1);
});
var Bll = {
getLocalTime: function (nS) {
var date = new Date(parseInt(nS) * 1000);
var mm = date.getMonth() + 1;
var dd = date.getDate();
return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd);
},
onClick: function (url, item, hint) {
var e = new common.edit("#baseform");
common.dialog.confirm(hint,
common.util.__template($("#template").html(), item),
function () {
e.submit(url, function (option) {
option.success = function () {
common.util.__tip("帮助分类成功!", "success");
g.reload();
};
option.error = function () {
common.util.__tip(res.message);
}
});
});
e.init();
new common.dropDown({el: "#parentId", "ajax": "firstCategory"});
if (hint == "修改分类") {
common.util.__ajax({
url: '/operations/helpcategory/getCategoryListByPid',
data: {id: item.parentId}
}, function (res) {
for (var i = 0; i < res.data.length; i++) {
if (item.parentId == res.data[i].id) {
$("#select2-parentId-container").html(res.data[i].text);
break;
}
}
}, true);
}
}
};
$('#add-category').on('click', function () {
var item = {};
Bll.onClick("/operations/helpcategory/addCategory", item, "添加分类");
});
$(document).on('click', '.add2', function () {
var item = g.rows[$(this).data("index")];
Bll.onClick("/operations/helpcategory/updateHelpCategory", item, "修改分类");
});
$(document).on('click', '.delbtn', function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function () {
common.util.__ajax({
url: '/operations/helpcategory/deleteHelpCategory',
data: {
id: item.id,
parentId: item.parentId
}
}, function () {
g.reload();
});
});
});