|
|
|
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
|
|
|
|
var Controller = {
|
|
|
|
index: function () {
|
|
|
|
// 初始化表格参数配置
|
|
|
|
Table.api.init({
|
|
|
|
extend: {
|
|
|
|
index_url: 'content/index' + location.search,
|
|
|
|
add_url: 'content/add',
|
|
|
|
edit_url: 'content/edit',
|
|
|
|
del_url: 'content/del',
|
|
|
|
multi_url: 'content/multi',
|
|
|
|
import_url: 'content/import',
|
|
|
|
table: 'content',
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var table = $("#table");
|
|
|
|
|
|
|
|
// 初始化表格
|
|
|
|
table.bootstrapTable({
|
|
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
|
|
pk: 'id',
|
|
|
|
sortName: 'id',
|
|
|
|
fixedColumns: true,
|
|
|
|
fixedRightNumber: 1,
|
|
|
|
detailView: true,
|
|
|
|
columns: [
|
|
|
|
[
|
|
|
|
{checkbox: true},
|
|
|
|
{field: 'id', title: __('Id')},
|
|
|
|
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
// {field: 'tag', title: __('Tag'), formatter: Table.api.formatter.flag},
|
|
|
|
{field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'main_realname', title: __('Main_realname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'main_phone', title: __('Main_phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'main_cardno', title: __('Main_cardno'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'is_hot', title: __('是否热门'), operate: false, formatter: Controller.api.formatter.custom},
|
|
|
|
// {field: 'main_qq', title: __('Main_qq'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
// {field: 'main_wechat', title: __('Main_wechat'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'main_address', title: __('Main_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'main_jiguan', title: __('Main_jiguan'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
|
|
{field: 'status', title: '审核状态', searchList: {"0":'待审核',"1":'审核通过',"-1":'驳回'}, formatter: Table.api.formatter.status},
|
|
|
|
{field: 'updatetime', title: '审核时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
|
|
{field: 'content', title: __('Content'), formatter: Table.api.formatter.content},
|
|
|
|
// {field: 'video', title: __('Video')},
|
|
|
|
{field: 'main_company', title: __('Main_company'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'user_id', title: __('User_id')},
|
|
|
|
|
|
|
|
{
|
|
|
|
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
name: '审核',
|
|
|
|
title: "审核",
|
|
|
|
text: "审核",
|
|
|
|
classname: 'btn btn-xs btn-magic btn-dialog',
|
|
|
|
url: 'content/shenhe',
|
|
|
|
callback: function (data) {
|
|
|
|
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
|
|
|
|
console.log(123123)
|
|
|
|
// return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
],
|
|
|
|
formatter: Table.api.formatter.operate
|
|
|
|
},
|
|
|
|
|
|
|
|
]
|
|
|
|
],
|
|
|
|
onExpandRow: function (index, row, $detail) {
|
|
|
|
//点击左侧的加号 展开查看详情的时候调用(加载子菜单) 在这里做了递归调用自身再次构建一张表 这里的child-table-row.id是为了修改或者删除,刷新子表使用
|
|
|
|
createSubTable(index, row, $detail);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//加载子菜单列表
|
|
|
|
function createSubTable(index, row, $detail) {
|
|
|
|
var parentId = row.id;
|
|
|
|
var childTable = $detail.html('<table data-show-toolbar="false" widht="100%"></table>').find('table');
|
|
|
|
$(childTable).bootstrapTable({
|
|
|
|
classes: 'table table-hover table-striped',
|
|
|
|
sortable: false,
|
|
|
|
url: 'content.zhengren/index',
|
|
|
|
method: 'get',
|
|
|
|
queryParams: function(params) { // 设置查询参数
|
|
|
|
var queryParams = {
|
|
|
|
limit: params.limit, // 传递分页参数
|
|
|
|
offset: params.offset,
|
|
|
|
filter: '{"content_id":'+parentId+'}' // 添加额外的参数
|
|
|
|
};
|
|
|
|
return queryParams;
|
|
|
|
},
|
|
|
|
// queryParams: {content_id: parentId},
|
|
|
|
// ajaxOptions: {content_id: parentId},
|
|
|
|
search: false,
|
|
|
|
pagination: true, //开启分页
|
|
|
|
pageNumber: 1, //初始化加载第一页,默认第一页
|
|
|
|
queryParamsType: 'limit', //查询参数组织方式
|
|
|
|
pageSize: 10, //单页记录数
|
|
|
|
pageList: [5, 10, 20, 30], //分页步进值
|
|
|
|
toolbar: false,
|
|
|
|
singleSelect: false, //只选择一行
|
|
|
|
maintainSelected: true, //开启分页保持选择状态,就是用户点击下一页再次返回上一页
|
|
|
|
clickToSelect: true,
|
|
|
|
showSearch: false,
|
|
|
|
showRefresh: false,
|
|
|
|
showToggle: false,
|
|
|
|
showColumns: false,
|
|
|
|
detailView: false,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
checkbox: true
|
|
|
|
},
|
|
|
|
{ field: 'id', title: 'ID' },
|
|
|
|
{ field: 'realname', title: '姓名' },
|
|
|
|
{ field: 'phone', title: '手机号' },
|
|
|
|
{ field: 'cardno', title: '身份证号' },
|
|
|
|
{ field: 'address', title: '地址' },
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// 为表格绑定事件
|
|
|
|
Table.api.bindevent(table);
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
recyclebin: function () {
|
|
|
|
// 初始化表格参数配置
|
|
|
|
Table.api.init({
|
|
|
|
extend: {
|
|
|
|
'dragsort_url': ''
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var table = $("#table");
|
|
|
|
|
|
|
|
// 初始化表格
|
|
|
|
table.bootstrapTable({
|
|
|
|
url: 'content/recyclebin' + location.search,
|
|
|
|
pk: 'id',
|
|
|
|
sortName: 'id',
|
|
|
|
columns: [
|
|
|
|
[
|
|
|
|
{checkbox: true},
|
|
|
|
{field: 'id', title: __('Id')},
|
|
|
|
{field: 'title', title: __('Title'), align: 'left'},
|
|
|
|
{
|
|
|
|
field: 'deletetime',
|
|
|
|
title: __('Deletetime'),
|
|
|
|
operate: 'RANGE',
|
|
|
|
addclass: 'datetimerange',
|
|
|
|
formatter: Table.api.formatter.datetime
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'operate',
|
|
|
|
width: '140px',
|
|
|
|
title: __('Operate'),
|
|
|
|
table: table,
|
|
|
|
events: Table.api.events.operate,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
name: 'Restore',
|
|
|
|
text: __('Restore'),
|
|
|
|
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
|
|
|
|
icon: 'fa fa-rotate-left',
|
|
|
|
url: 'content/restore',
|
|
|
|
refresh: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Destroy',
|
|
|
|
text: __('Destroy'),
|
|
|
|
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
|
|
|
|
icon: 'fa fa-times',
|
|
|
|
url: 'content/destroy',
|
|
|
|
refresh: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
formatter: Table.api.formatter.operate
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
// 为表格绑定事件
|
|
|
|
Table.api.bindevent(table);
|
|
|
|
},
|
|
|
|
|
|
|
|
add: function () {
|
|
|
|
Controller.api.bindevent();
|
|
|
|
},
|
|
|
|
edit: function () {
|
|
|
|
Controller.api.bindevent();
|
|
|
|
},
|
|
|
|
shenhe: function () {
|
|
|
|
Controller.api.bindevent();
|
|
|
|
},
|
|
|
|
api: {
|
|
|
|
bindevent: function () {
|
|
|
|
Form.api.bindevent($("form[role=form]"));
|
|
|
|
},
|
|
|
|
formatter: {//渲染的方法
|
|
|
|
custom: function (value, row, index) {
|
|
|
|
//添加上btn-change可以自定义请求的URL进行数据处理
|
|
|
|
return '<a class="btn-change text-success" data-url="content/change" data-confirm="确认设为或者取消热门?" data-id="' + row.id + '"><i class="fa ' + (row.is_hot == 0 ? 'fa-toggle-on fa-flip-horizontal text-gray' : 'fa-toggle-on') + ' fa-2x"></i></a>';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return Controller;
|
|
|
|
});
|