index.js
5.34 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* Created by jiangmin on 2016/5/9.
* 反馈管理
*/
var $ = require('jquery');
common = require('../common/common');
datepicker = require('../util/datepicker');
/**
* 下拉框
*/
new common.dropDown({
el: "#status-filter"
});
/**
* 日期插件
*/
$('.hasDatepicker').fdatepicker({
format: 'yyyy-mm-dd'
});
/**
* 列表
* @type {common.grid}
*/
var g = new common.grid({
el: '#content-list',
parms: function () {
return {
brandName: common.util.__input('brandName-filter'),
status: common.util.__input('status-filter')
};
},
columns: [
{
display: "ID",
name: "id"
}, {
display: "品牌名称",
name: "brandName"
}, {
display: "状态",
name: 'status',
render: function (item) {
if (item.status == 1) {
return "可用"
}
return "不可用"
}
}, {
display: '排序',
name: "orderBy"
}, {
display: '添加人',
name: "creatorName"
}, {
display: '添加时间',
name: "createTime",
render: function (item) {
return "<p>" + Bll.__time(item.createTime) + "</p>";
}
}, {
display: '修改人',
name: "modifyName"
}, {
display: '修改时间',
name: "modifyTime",
render: function (item) {
return "<p>" + Bll.__time(item.modifyTime) + "</p>";
}
}, {
display: '操作',
render: function (item) {
var HtmArr = [];
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-info btn-xs update">修改</a>');
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs delete">删除</a>');
return HtmArr.join('');
}
}]
});
g.init('/hotSearchBrand/queryHotBrandList');
var edit = new common.edit2(".modal-body");
var Bll = {
module: null,
__time:function(time){
var t = new Date(time * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return formatted;
},
__render: function (selecter, templater, data) {
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
},
//弹框
toast: function (url, module, hint) {
Bll.module = module;
var d = new common.dialog({
title: hint,
content: common.util.__template2($("#template").html(), Bll.module),
width: '30%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
common.util.__ajax({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
});
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
Bll.__editRender();
},
renderDialog: function (templater) {
Bll.__render(".modal-body", templater, Bll.module);
Bll.__editRender();
},
__editRender: function () {
edit.init();
}
};
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
});
/**
* 添加--点击事件
*/
$('#addHotBrand').on('click', function () {
var item = {
"brandName": "",
"orderBy": 1,
"status": 0
};
item._state="add";
Bll.toast("/hotSearchBrand/addHotBrand", item, "添加");
});
/**
* 编辑--点击事件
*/
$(document).on('click', '.update', function () {
var item = g.rows[$(this).data("index")];
item._state="update";
item.createTime= Bll.__time(item.createTime);
item.modifyTime= Bll.__time(item.modifyTime);
Bll.toast('/hotSearchBrand/updateHotBrand', item, "修改");
});
/**
* 删除--点击事件
*/
$(document).on('click', '.delete', function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function () {
common.util.__ajax({
url: '/hotSearchBrand/delHotBrand',
data: {
id: item.id
}
}, function () {
g.reload();
});
});
});
/**
* 查询按钮--点击事件
*/
$(document).on('click', '#filter-btn', function () {
g.reload(1);
});