##引入核心模板##
var main = require('../..../main');
module.exports = function(Router) {
Router = new main(Router, options);
return Router;
};
##options配置##
- router --- 路由
设置了路由之后会默认生成三个路由,在router后添加后缀
- _json
- _jsonp
- _excel
{
router : '/xxx/xxx' || '/xxx'
}
同一路由可以查询多个表
{
modelName : ['xxx', 'xxx']
}
- dataName --- 查询数据后对应的数据名称
默认值
- first --- 查询第一个表之后数据对应的名称
- second --- 查询第二个表之后数据对应的名称
- third --- 查询第三个表之后数据对应的名称
- fourth --- 查询第四个表之后数据对应的名称
{
dataName : ['first', 'second', 'third', 'fourth']
}
默认值
- params --- 第一个表添加参数
- secondParams --- 第二个表添加参数
- thirdParams --- 第三个表添加参数
- fourthParams --- 第四个表添加参数
{
paramsName : ['params', 'secondParams', 'thirdParams', 'fourthParams']
}
//使用方法实在options里边设置对应值
{
params : {} || function(query, params, data){}
}
{
pixedName : fucntion(req, query, cb) {}
}
- procedure --- 查库流程
默认情况下分三种情况
{
//不分页的情况
procedure : [{
find : 'params',
order : ['xx', 'xx'],
run : ''
}]
//分页且不需要对某些值求和
procedure : [
[
{
find : 'params',
offset : 'offset',
limit : 'limit',
order : ['xxx', 'xxx'],
run : ''
},
{
count : ''
}
]
]
//分页且需要对某些值求和
procedure : [
[
{
find : 'params',
offset : 'offset',
limit : 'limit',
order : ['xxx', 'xxx'],
run : ''
},
{
aggregate : 'params',
sum : ['xxx', 'xxx'],
get : ''
},
{
count : ''
}
]
]
}
- sql --- 支持sql查询
默认值
{
sql : ['firstSql', 'secondSql', 'thirdSql', 'fourthSql']
}
//不分页时 支持sql查询
{
firstSql : function(query, params) {}
}
//分页时 支持sql查询 true 查询数据 false 查询总条数
{
firstSql : function(query, params, true || false){}
}
- paging 对应表是否分页
{
paging : [true, false]
}
- page --- 分页时每页条数
{
page : 20
}
- sum --- 需要求和字段
{
sum : ['xx', 'xxx']
}
- order --- 排序字段
{
order : ['xx', 'xxx']
}
- selectFilter --- 前端模块需查表完成
{
selectFilter : function(req, cb) {}
}
- rows --- 行,用于下载
{
rows : [
[
'xx', 'xx'
]
]
}
- cols --- 列,用于下载
{
cols : [
[
caption : '列名',
type : '类型',
help : '帮助信息'
]
]
}
- platform --- 是否显示平台
默认值
{
platform : true
}
- channel --- 是否显示渠道
默认值
{
channel : false
}
- version --- 是否显示版本
默认值
{
version : false
}
- coupon --- 是否显示优惠券类型
默认值
{
coupon : false
}
- excel_export --- 是否有导出路径
默认值
{
excel_export : false
}
- flexible_btn --- 按钮设置
{
flexible_btn : [{
content: '导出',
preMethods: ['excel_export']
}]
}
- date_picker --- 是否显示时间
默认值
{
date_picker : true
}
- date_picker_data --- 初始时间
默认值
{
//可以选择多天 7 只能选择单天 1
date_picker_data : 7
}
- level_select --- 联动菜单是否显示
默认值
{
level_select : false
}
- level_select_url --- 联动菜单地址
{
level_select_url : '/xxx/xxx'
}
- level_select_name --- 查询字段名称
{
level_select_name : 'xxxx'
}
- filter_select --- 单选
{
filter_select : [{
title: '标题',
filter_key : '参数名',
groups: [{
key: '参数值',
value: '参数显示名称'
}]
}]
}
- filter --- 数据过滤
{
filter : function(data, query, dates, type) {}
}
- search --- 搜索框
默认值
{
search : {
show : false
}
}
- control_table_col --- 表格字段选择框
默认值
{
control_table_col : false
}
- global_platform --- 全局模块
默认值
{
golbal_platform : {
show : false,
key : '参数名',
list : [{
key : '参数值',
name : '名称'
}]
}
}