operations.icon.Index.js
3.78 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
webpackJsonp([114],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/7/5.
* app图标管理
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var channelArr = ["通用","男生","女生","潮童","创意生活"];
var module = {};
var edit = new common.edit2("#base-form");
new common.dropDown({el: "#status-filter"});
new common.dropDown({el: "#type-filter"});
var Bll = {
toast: function (item, prefix, url) {
var dialog = common.dialog.confirm(prefix + "图标信息",
common.util.__template2($("#toast-template").html(), item),
function () {
if(edit.validate()) {
common.util.__ajax({
url: url,
data: module
}, function () {
dialog.close();
g.reload();
});
}
//console.log(item);
return false;
});
edit.init();
new common.dropDown({el: "#type"});
new common.dropDown({el: "#ico_key"});
}
};
var g = new common.grid({
el: "#content-list",
parms: function() {
return {
type: common.util.__input("type-filter"),
status: common.util.__input("status-filter"),
icoName:common.util.__input("icoName-filter")
}
},
columns: [
{display: "ID", name: 'id'},
{display: "名称", name: 'icoName'},
{display: "默认图片名称", name: 'defaultIco'},
{display: "高亮图片名称", name: 'ico'},
{display: "频道", render: function (item) {
return channelArr[item.type];
}},
{display: "key", name: 'icoKey'},
{display: "状态", render: function (item) {
if(item.status == 1) {
return "已开启";
} else {
return "已关闭";
}
}},
{display: "操作",
render: function(items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" class="btn btn-info btn-xs edit">编辑</a>');
if(items.status == 1) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs closeStatus">关闭入口</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-success btn-xs publishStatus">开启入口</a>');
}
return HtmArr.join('');
}
}
]
});
g.init("/icon/getList");
//筛选
$(document).on("click", "#filter-btn", function () {
g.reload(1);
});
//关闭图标入口
$(document).on("click", ".closeStatus", function () {
common.util.__ajax({
url: "/icon/closeIcon",
data: {id: $(this).data("id")}
}, function () {
g.reload();
});
});
//开启图标入口
$(document).on("click", ".publishStatus", function () {
common.util.__ajax({
url: "/icon/publishIcon",
data: {id: $(this).data("id")}
}, function () {
g.reload();
});
});
//添加信息
$(document).on("click", "#addInfo", function () {
module = {};
Bll.toast(module, "添加", "/icon/addIcon");
});
//编辑
$(document).on("click", ".edit", function () {
module = g.rows[$(this).data("index")];
Bll.toast(module, "编辑", "/icon/updateIcon");
});
//监听数据变化
$(document).on("change", ".observe", function () {
module[$(this).data("field")] = $(this).val();
});
$(document).on("click", "#chooseFile", function () {
$("#uploadBox").click();
});
/***/ }
]);