|
|
/**
|
|
|
* 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) {
|
|
|
var t = new Date(item.createTime * 1000);
|
|
|
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
|
|
|
return "<p>" + formatted + "</p>";
|
|
|
}
|
|
|
}, {
|
|
|
display: '修改人',
|
|
|
name: "modifyName"
|
|
|
}, {
|
|
|
display: '修改时间',
|
|
|
name: "modifyTime",
|
|
|
render: function (item) {
|
|
|
var t = new Date(item.modifyTime * 1000);
|
|
|
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
|
|
|
return "<p>" + formatted + "</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/queryHotBrandList1');
|
|
|
var edit = new common.edit2(".modal-body");
|
|
|
var Bll = {
|
|
|
contentDatas: [],
|
|
|
module: null,
|
|
|
__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
|
|
|
};
|
|
|
Bll.toast("/hotSearchBrand/addHotBrand", item, "添加");
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 编辑--点击事件
|
|
|
*/
|
|
|
$(document).on('click', '.update', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var item1 = {
|
|
|
id: item.id,
|
|
|
brandName: item.brandName,
|
|
|
status: item.status,
|
|
|
orderBy: item.orderBy
|
|
|
};
|
|
|
Bll.toast('/hotSearchBrand/updateHotBrand', item1, "修改");
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 删除--点击事件
|
|
|
*/
|
|
|
$(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);
|
|
|
}); |
...
|
...
|
|