Authored by 姜敏

热搜品牌初步

/**
* 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);
});
... ...
/**
* Created by jiangmin on 16/5/11.
* 热门品牌搜索词
*/
//接口主域
//exports.domain = require('../config/common.js').domain;
exports.domain = "http://172.16.6.214:8088/platform";
//路由配置
exports.res = [
{
//搜索词页面渲染
route: '/hotSearchBrand/queryHotBrandList',
method: 'GET',
view: 'pages/hotBrands/index',
src: '/hotBrands/index'
},
//搜索词列表
{
route: '/hotSearchBrand/queryHotBrandList1',
method: 'POST',
url: '/hotSearchBrand/queryHotBrandList',
params: [
{name: 'page', type: 'Number', def: '1'},
{name: 'size', type: 'Number', def: '10'},
{name: 'brandName', type: 'String'},
{name: 'status', type: 'Number'}
]
},
{
//添加搜索词
route: '/hotSearchBrand/addHotBrand',
method: 'POST',
url: '/hotSearchBrand/addHotBrand',
params: [
{name: 'brandName', type: 'String'},
{name: 'orderBy', type: 'Number'},
{name: 'status', type: 'Number'}
]
},
{
//搜索词修改
route: '/hotSearchBrand/updateHotBrand',
method: 'POST',
url: '/hotSearchBrand/updateHotBrand',
params: [
{name: 'id', type: 'Number'},
{name: 'brandName', type: 'String'},
{name: 'orderBy', type: 'Number'},
{name: 'status', type: 'Number'}
]
},
{
//删除
route: '/hotSearchBrand/delHotBrand',
method: 'POST',
url: '/hotSearchBrand/delHotBrand',
params: [
{name: 'id', type: 'Number'}
]
},
{
//查询单个
route: '/hotSearchBrand/queryHotBrand',
method: 'POST',
url: '/hotSearchBrand/queryHotBrand',
params: [
{name: 'id', type: 'Number'}
]
}
];
... ...
<!--反馈管理界面-->
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">搜索词管理</a></li>
<li>品牌热搜词管理</li>
</ul>
<div>
<div style="width: 30%;float: left;">
<h4>品牌热搜词列表</h4>
</div>
</div>
</div>
</div>
</div>
<div class="contentpanel">
<div class="panel panel-default" style="...">
<div class="panel-heading">
<a id="addHotBrand" class="btn btn-primary">添加</a>
</div>
<div class="panel-body">
<div class="row">
<div class="panel-col2">
<input type="text" value="" id="brandName-filter" placeholder="品牌"
class="form-control">
</div>
<div class="panel-col">
<select id="status-filter" class="form-control">
<option value="-1">选择状态</option>
<option value="0">不可用</option>
<option value="1">可用</option>
</select>
</div>
<div class="panel-col">
<a id="filter-btn" href="javascript:;" class="btn btn-info">查询</a>
<a id="filter-all" href="/hotSearchBrand/queryHotBrandList" class="btn btn-info">全部</a>
</div>
</div>
</div>
</div>
<div id="content-list"></div>
</div>
<!--内容-->
<script type="text/template" id="template">
<div id="content">
<div class="form-group">
<label for="brandName" class="col-sm-2 control-label"><i class="red">*</i> 品牌名</label>
<div class="col-sm-10">
<input type="text" name="" value="[[brandName]]" id="brandName" class="form-control observe" required="required"
data-field="brandName" placeholder="品牌名">
</div>
</div>
<div class="form-group">
<label for="orderBy" class="col-sm-2 control-label"><i class="red">*</i> 排序</label>
<div class="col-sm-10">
<input type="number" name="" value="[[orderBy]]" id="orderBy" data-field="orderBy" class="form-control observe" required="required"
placeholder="排序">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span class="red">*</span> 状态</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="status" class="observe" data-field="status" value="1" >可用
</label>
<label class="radio-inline">
<input type="radio" name="status" class="observe" data-field="status" value="0">不可用
</label>
</div>
<input type="hidden" id="status" value="[[status]]" for="radio" required="required"
class="observe" data-field="status" placeholder="状态">
</div>
</div>
</script>
... ...