正在显示
67 个修改的文件
包含
4756 行增加
和
0 行删除
addons/example/Example.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace addons\example; | ||
4 | + | ||
5 | +use app\common\library\Menu; | ||
6 | +use think\Addons; | ||
7 | + | ||
8 | +/** | ||
9 | + * Example | ||
10 | + */ | ||
11 | +class Example extends Addons | ||
12 | +{ | ||
13 | + | ||
14 | + /** | ||
15 | + * 插件安装方法 | ||
16 | + * @return bool | ||
17 | + */ | ||
18 | + public function install() | ||
19 | + { | ||
20 | + $menu = [ | ||
21 | + [ | ||
22 | + 'name' => 'example', | ||
23 | + 'title' => '开发示例管理', | ||
24 | + 'icon' => 'fa fa-magic', | ||
25 | + 'sublist' => [ | ||
26 | + [ | ||
27 | + 'name' => 'example/bootstraptable', | ||
28 | + 'title' => '表格完整示例', | ||
29 | + 'icon' => 'fa fa-table', | ||
30 | + 'sublist' => [ | ||
31 | + ['name' => 'example/bootstraptable/index', 'title' => '查看'], | ||
32 | + ['name' => 'example/bootstraptable/detail', 'title' => '详情'], | ||
33 | + ['name' => 'example/bootstraptable/change', 'title' => '变更'], | ||
34 | + ['name' => 'example/bootstraptable/del', 'title' => '删除'], | ||
35 | + ['name' => 'example/bootstraptable/multi', 'title' => '批量更新'], | ||
36 | + ] | ||
37 | + ], | ||
38 | + [ | ||
39 | + 'name' => 'example/customsearch', | ||
40 | + 'title' => '自定义搜索', | ||
41 | + 'icon' => 'fa fa-table', | ||
42 | + 'sublist' => [ | ||
43 | + ['name' => 'example/customsearch/index', 'title' => '查看'], | ||
44 | + ['name' => 'example/customsearch/del', 'title' => '删除'], | ||
45 | + ['name' => 'example/customsearch/multi', 'title' => '批量更新'], | ||
46 | + ] | ||
47 | + ], | ||
48 | + [ | ||
49 | + 'name' => 'example/customform', | ||
50 | + 'title' => '自定义表单示例', | ||
51 | + 'icon' => 'fa fa-edit', | ||
52 | + 'sublist' => [ | ||
53 | + ['name' => 'example/customform/index', 'title' => '查看'], | ||
54 | + ] | ||
55 | + ], | ||
56 | + [ | ||
57 | + 'name' => 'example/tablelink', | ||
58 | + 'title' => '表格联动示例', | ||
59 | + 'icon' => 'fa fa-table', | ||
60 | + 'remark' => '点击左侧日志列表,右侧的表格数据会显示指定管理员的日志列表', | ||
61 | + 'sublist' => [ | ||
62 | + ['name' => 'example/tablelink/index', 'title' => '查看'], | ||
63 | + ] | ||
64 | + ], | ||
65 | + [ | ||
66 | + 'name' => 'example/colorbadge', | ||
67 | + 'title' => '彩色角标', | ||
68 | + 'icon' => 'fa fa-table', | ||
69 | + 'remark' => '左侧彩色的角标会根据当前数据量的大小进行更新', | ||
70 | + 'sublist' => [ | ||
71 | + ['name' => 'example/colorbadge/index', 'title' => '查看'], | ||
72 | + ['name' => 'example/colorbadge/del', 'title' => '删除'], | ||
73 | + ['name' => 'example/colorbadge/multi', 'title' => '批量更新'], | ||
74 | + ] | ||
75 | + ], | ||
76 | + [ | ||
77 | + 'name' => 'example/controllerjump', | ||
78 | + 'title' => '控制器间跳转', | ||
79 | + 'icon' => 'fa fa-table', | ||
80 | + 'remark' => '点击IP地址可以跳转到新的选项卡中查看指定IP的数据', | ||
81 | + 'sublist' => [ | ||
82 | + ['name' => 'example/controllerjump/index', 'title' => '查看'], | ||
83 | + ['name' => 'example/controllerjump/del', 'title' => '删除'], | ||
84 | + ['name' => 'example/controllerjump/multi', 'title' => '批量更新'], | ||
85 | + ] | ||
86 | + ], | ||
87 | + [ | ||
88 | + 'name' => 'example/cxselect', | ||
89 | + 'title' => '多级联动', | ||
90 | + 'icon' => 'fa fa-table', | ||
91 | + 'remark' => '基于jquery.cxselect实现的多级联动', | ||
92 | + 'sublist' => [ | ||
93 | + ['name' => 'example/cxselect/index', 'title' => '查看'], | ||
94 | + ['name' => 'example/cxselect/del', 'title' => '删除'], | ||
95 | + ['name' => 'example/cxselect/multi', 'title' => '批量更新'], | ||
96 | + ] | ||
97 | + ], | ||
98 | + [ | ||
99 | + 'name' => 'example/multitable', | ||
100 | + 'title' => '多表格示例', | ||
101 | + 'icon' => 'fa fa-table', | ||
102 | + 'remark' => '展示在一个页面显示多个Bootstrap-table表格', | ||
103 | + 'sublist' => [ | ||
104 | + ['name' => 'example/multitable/index', 'title' => '查看'], | ||
105 | + ['name' => 'example/multitable/del', 'title' => '删除'], | ||
106 | + ['name' => 'example/multitable/multi', 'title' => '批量更新'], | ||
107 | + ] | ||
108 | + ], | ||
109 | + [ | ||
110 | + 'name' => 'example/relationmodel', | ||
111 | + 'title' => '关联模型示例', | ||
112 | + 'icon' => 'fa fa-table', | ||
113 | + 'remark' => '列表中的头像、用户名和昵称字段均从关联表中取出', | ||
114 | + 'sublist' => [ | ||
115 | + ['name' => 'example/relationmodel/index', 'title' => '查看'], | ||
116 | + ['name' => 'example/relationmodel/del', 'title' => '删除'], | ||
117 | + ['name' => 'example/relationmodel/multi', 'title' => '批量更新'], | ||
118 | + ] | ||
119 | + ], | ||
120 | + [ | ||
121 | + 'name' => 'example/tabletemplate', | ||
122 | + 'title' => '表格模板示例', | ||
123 | + 'icon' => 'fa fa-table', | ||
124 | + 'remark' => '', | ||
125 | + 'sublist' => [ | ||
126 | + ['name' => 'example/tabletemplate/index', 'title' => '查看'], | ||
127 | + ['name' => 'example/tabletemplate/detail', 'title' => '详情'], | ||
128 | + ['name' => 'example/tabletemplate/del', 'title' => '删除'], | ||
129 | + ['name' => 'example/tabletemplate/multi', 'title' => '批量更新'], | ||
130 | + ] | ||
131 | + ], | ||
132 | + [ | ||
133 | + 'name' => 'example/baidumap', | ||
134 | + 'title' => '百度地图示例', | ||
135 | + 'icon' => 'fa fa-map-pin', | ||
136 | + 'sublist' => [ | ||
137 | + ['name' => 'example/baidumap/index', 'title' => '查看'], | ||
138 | + ['name' => 'example/baidumap/map', 'title' => '详情'], | ||
139 | + ['name' => 'example/baidumap/del', 'title' => '删除'], | ||
140 | + ] | ||
141 | + ], | ||
142 | + [ | ||
143 | + 'name' => 'example/echarts', | ||
144 | + 'title' => '统计图表示例', | ||
145 | + 'icon' => 'fa fa-bar-chart', | ||
146 | + 'sublist' => [ | ||
147 | + ['name' => 'example/echarts/index', 'title' => '查看'], | ||
148 | + ] | ||
149 | + ], | ||
150 | + ] | ||
151 | + ] | ||
152 | + ]; | ||
153 | + Menu::create($menu); | ||
154 | + return true; | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * 插件卸载方法 | ||
159 | + * @return bool | ||
160 | + */ | ||
161 | + public function uninstall() | ||
162 | + { | ||
163 | + Menu::delete('example'); | ||
164 | + return true; | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * 插件启用方法 | ||
169 | + */ | ||
170 | + public function enable() | ||
171 | + { | ||
172 | + Menu::enable('example'); | ||
173 | + } | ||
174 | + | ||
175 | + /** | ||
176 | + * 插件禁用方法 | ||
177 | + */ | ||
178 | + public function disable() | ||
179 | + { | ||
180 | + Menu::disable('example'); | ||
181 | + } | ||
182 | + | ||
183 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 百度地图 | ||
9 | + * | ||
10 | + * @icon fa fa-map | ||
11 | + * @remark 可以搜索百度位置,调用百度地图的相关API | ||
12 | + */ | ||
13 | +class Baidumap extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * 查找地图 | ||
25 | + */ | ||
26 | + public function map() | ||
27 | + { | ||
28 | + return $this->view->fetch(); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 搜索列表 | ||
33 | + */ | ||
34 | + public function selectpage() | ||
35 | + { | ||
36 | + $this->model = model('Area'); | ||
37 | + return parent::selectpage(); | ||
38 | + } | ||
39 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 表格完整示例 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark 在使用Bootstrap-table中的常用方式,更多使用方式可查看:http://bootstrap-table.wenzhixin.net.cn/zh-cn/ | ||
12 | + */ | ||
13 | +class Bootstraptable extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + /** | ||
17 | + * 无需鉴权的方法(需登录) | ||
18 | + * @var array | ||
19 | + */ | ||
20 | + protected $noNeedRight = ['start', 'pause', 'change', 'detail', 'cxselect', 'searchlist']; | ||
21 | + /** | ||
22 | + * 快捷搜索的字段 | ||
23 | + * @var string | ||
24 | + */ | ||
25 | + protected $searchFields = 'id,title,url'; | ||
26 | + | ||
27 | + public function _initialize() | ||
28 | + { | ||
29 | + parent::_initialize(); | ||
30 | + $this->model = model('AdminLog'); | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * 查看 | ||
35 | + */ | ||
36 | + public function index() | ||
37 | + { | ||
38 | + if ($this->request->isAjax()) { | ||
39 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(null); | ||
40 | + $total = $this->model | ||
41 | + ->where($where) | ||
42 | + ->order($sort, $order) | ||
43 | + ->count(); | ||
44 | + $list = $this->model | ||
45 | + ->where($where) | ||
46 | + ->order($sort, $order) | ||
47 | + ->limit($offset, $limit) | ||
48 | + ->select(); | ||
49 | + $result = array("total" => $total, "rows" => $list, "extend" => ['money' => mt_rand(100000, 999999), 'price' => 200]); | ||
50 | + | ||
51 | + return json($result); | ||
52 | + } | ||
53 | + return $this->view->fetch(); | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * 详情 | ||
58 | + */ | ||
59 | + public function detail($ids) | ||
60 | + { | ||
61 | + $row = $this->model->get(['id' => $ids]); | ||
62 | + if (!$row) { | ||
63 | + $this->error(__('No Results were found')); | ||
64 | + } | ||
65 | + if ($this->request->isAjax()) { | ||
66 | + $this->success("Ajax请求成功", null, ['id' => $ids]); | ||
67 | + } | ||
68 | + $this->view->assign("row", $row->toArray()); | ||
69 | + return $this->view->fetch(); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * 启用 | ||
74 | + */ | ||
75 | + public function start($ids = '') | ||
76 | + { | ||
77 | + $this->success("模拟启动成功"); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * 暂停 | ||
82 | + */ | ||
83 | + public function pause($ids = '') | ||
84 | + { | ||
85 | + $this->success("模拟暂停成功"); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * 切换 | ||
90 | + */ | ||
91 | + public function change($ids = '') | ||
92 | + { | ||
93 | + //你需要在此做具体的操作逻辑 | ||
94 | + | ||
95 | + $this->success("模拟切换成功"); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * 联动搜索 | ||
100 | + */ | ||
101 | + public function cxselect() | ||
102 | + { | ||
103 | + $type = $this->request->get('type'); | ||
104 | + $group_id = $this->request->get('group_id'); | ||
105 | + $list = null; | ||
106 | + if ($group_id !== '') { | ||
107 | + if ($type == 'group') { | ||
108 | + $groupIds = $this->auth->getChildrenGroupIds(true); | ||
109 | + $list = \app\admin\model\AuthGroup::where('id', 'in', $groupIds)->field('id as value, name')->select(); | ||
110 | + } else { | ||
111 | + $adminIds = \app\admin\model\AuthGroupAccess::where('group_id', 'in', $group_id)->column('uid'); | ||
112 | + $list = \app\admin\model\Admin::where('id', 'in', $adminIds)->field('id as value, username AS name')->select(); | ||
113 | + } | ||
114 | + } | ||
115 | + $this->success('', null, $list); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * 搜索下拉列表 | ||
120 | + */ | ||
121 | + public function searchlist() | ||
122 | + { | ||
123 | + $result = $this->model->limit(10)->select(); | ||
124 | + $searchlist = []; | ||
125 | + foreach ($result as $key => $value) { | ||
126 | + $searchlist[] = ['id' => $value['url'], 'name' => $value['url']]; | ||
127 | + } | ||
128 | + $data = ['searchlist' => $searchlist]; | ||
129 | + $this->success('', null, $data); | ||
130 | + } | ||
131 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 彩色角标 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark 在JS端控制角标的显示与隐藏,请注意左侧菜单栏角标的数值变化 | ||
12 | + */ | ||
13 | +class Colorbadge extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 控制器间跳转 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark FastAdmin支持在控制器间跳转,点击后将切换到另外一个TAB中,无需刷新当前页面 | ||
12 | + */ | ||
13 | +class Controllerjump extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 自定义表单示例 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark FastAdmin支持在控制器间跳转,点击后将切换到另外一个TAB中,无需刷新当前页面 | ||
12 | + */ | ||
13 | +class Customform extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | + | ||
23 | + public function index() | ||
24 | + { | ||
25 | + if ($this->request->isPost()) { | ||
26 | + $this->success("提交成功", null, ['data' => json_encode($this->request->post("row/a"), JSON_UNESCAPED_UNICODE)]); | ||
27 | + } | ||
28 | + return $this->view->fetch(); | ||
29 | + } | ||
30 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 自定义搜索 | ||
9 | + * | ||
10 | + * @icon fa fa-search | ||
11 | + * @remark 自定义列表的搜索 | ||
12 | + */ | ||
13 | +class Customsearch extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + $ipList = $this->model->whereTime('createtime', '-37 days')->group("ip")->column("ip,ip as aa"); | ||
22 | + $this->view->assign("ipList", $ipList); | ||
23 | + } | ||
24 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 多级联动 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark FastAdmin使用了jQuery-cxselect实现多级联动,更多文档请参考https://github.com/karsonzhang/cxSelect | ||
12 | + */ | ||
13 | +class Cxselect extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + } | ||
21 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 统计图表示例 | ||
9 | + * | ||
10 | + * @icon fa fa-charts | ||
11 | + * @remark 展示在FastAdmin中使用Echarts展示丰富多彩的统计图表 | ||
12 | + */ | ||
13 | +class Echarts extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * 查看 | ||
25 | + */ | ||
26 | + public function index() | ||
27 | + { | ||
28 | + | ||
29 | + return $this->view->fetch(); | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * 详情 | ||
34 | + */ | ||
35 | + public function detail($ids) | ||
36 | + { | ||
37 | + $row = $this->model->get(['id' => $ids]); | ||
38 | + if (!$row) { | ||
39 | + $this->error(__('No Results were found')); | ||
40 | + } | ||
41 | + $this->view->assign("row", $row->toArray()); | ||
42 | + return $this->view->fetch(); | ||
43 | + } | ||
44 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 多表格示例 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark 当一个页面上存在多个Bootstrap-table时该如何控制按钮和表格 | ||
12 | + */ | ||
13 | +class Multitable extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + protected $noNeedRight = ['table1', 'table2']; | ||
17 | + | ||
18 | + public function _initialize() | ||
19 | + { | ||
20 | + parent::_initialize(); | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * 查看 | ||
25 | + */ | ||
26 | + public function index() | ||
27 | + { | ||
28 | + $this->loadlang('general/attachment'); | ||
29 | + $this->loadlang('general/crontab'); | ||
30 | + return $this->view->fetch(); | ||
31 | + } | ||
32 | + | ||
33 | + public function table1() | ||
34 | + { | ||
35 | + $this->model = model('Attachment'); | ||
36 | + //设置过滤方法 | ||
37 | + $this->request->filter(['strip_tags']); | ||
38 | + if ($this->request->isAjax()) { | ||
39 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
40 | + if ($this->request->request('keyField')) { | ||
41 | + return $this->selectpage(); | ||
42 | + } | ||
43 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
44 | + $total = $this->model | ||
45 | + ->where($where) | ||
46 | + ->order($sort, $order) | ||
47 | + ->count(); | ||
48 | + | ||
49 | + $list = $this->model | ||
50 | + ->where($where) | ||
51 | + ->order($sort, $order) | ||
52 | + ->limit($offset, $limit) | ||
53 | + ->select(); | ||
54 | + | ||
55 | + $result = array("total" => $total, "rows" => $list); | ||
56 | + | ||
57 | + return json($result); | ||
58 | + } | ||
59 | + return $this->view->fetch('index'); | ||
60 | + } | ||
61 | + | ||
62 | + public function table2() | ||
63 | + { | ||
64 | + $this->model = model('AdminLog'); | ||
65 | + //设置过滤方法 | ||
66 | + $this->request->filter(['strip_tags']); | ||
67 | + if ($this->request->isAjax()) { | ||
68 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
69 | + if ($this->request->request('keyField')) { | ||
70 | + return $this->selectpage(); | ||
71 | + } | ||
72 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
73 | + $total = $this->model | ||
74 | + ->where($where) | ||
75 | + ->order($sort, $order) | ||
76 | + ->count(); | ||
77 | + | ||
78 | + $list = $this->model | ||
79 | + ->where($where) | ||
80 | + ->order($sort, $order) | ||
81 | + ->limit($offset, $limit) | ||
82 | + ->select(); | ||
83 | + | ||
84 | + $result = array("total" => $total, "rows" => $list); | ||
85 | + | ||
86 | + return json($result); | ||
87 | + } | ||
88 | + return $this->view->fetch('index'); | ||
89 | + } | ||
90 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 关联模型 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark 当使用到关联模型时需要重载index方法 | ||
12 | + */ | ||
13 | +class Relationmodel extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * 查看 | ||
25 | + */ | ||
26 | + public function index() | ||
27 | + { | ||
28 | + $this->relationSearch = true; | ||
29 | + $this->searchFields = "admin.username,id"; | ||
30 | + if ($this->request->isAjax()) { | ||
31 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
32 | + $total = $this->model | ||
33 | + ->with("admin") | ||
34 | + ->where($where) | ||
35 | + ->order($sort, $order) | ||
36 | + ->count(); | ||
37 | + $list = $this->model | ||
38 | + ->with("admin") | ||
39 | + ->where($where) | ||
40 | + ->order($sort, $order) | ||
41 | + ->limit($offset, $limit) | ||
42 | + ->select(); | ||
43 | + $result = array("total" => $total, "rows" => $list); | ||
44 | + | ||
45 | + return json($result); | ||
46 | + } | ||
47 | + return $this->view->fetch(); | ||
48 | + } | ||
49 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 表格联动 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + */ | ||
12 | +class Tablelink extends Backend | ||
13 | +{ | ||
14 | + protected $model = null; | ||
15 | + protected $noNeedRight = ['table1', 'table2']; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | + | ||
23 | + | ||
24 | + public function table1() | ||
25 | + { | ||
26 | + $this->model = model('Admin'); | ||
27 | + //设置过滤方法 | ||
28 | + $this->request->filter(['strip_tags']); | ||
29 | + if ($this->request->isAjax()) { | ||
30 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
31 | + if ($this->request->request('keyField')) { | ||
32 | + return $this->selectpage(); | ||
33 | + } | ||
34 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
35 | + $total = $this->model | ||
36 | + ->where($where) | ||
37 | + ->order($sort, $order) | ||
38 | + ->count(); | ||
39 | + | ||
40 | + $list = $this->model | ||
41 | + ->where($where) | ||
42 | + ->order($sort, $order) | ||
43 | + ->limit($offset, $limit) | ||
44 | + ->select(); | ||
45 | + | ||
46 | + $result = array("total" => $total, "rows" => $list); | ||
47 | + | ||
48 | + return json($result); | ||
49 | + } | ||
50 | + return $this->view->fetch('index'); | ||
51 | + } | ||
52 | + | ||
53 | + public function table2() | ||
54 | + { | ||
55 | + $this->model = model('AdminLog'); | ||
56 | + //设置过滤方法 | ||
57 | + $this->request->filter(['strip_tags']); | ||
58 | + if ($this->request->isAjax()) { | ||
59 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
60 | + if ($this->request->request('keyField')) { | ||
61 | + return $this->selectpage(); | ||
62 | + } | ||
63 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
64 | + $total = $this->model | ||
65 | + ->where($where) | ||
66 | + ->order($sort, $order) | ||
67 | + ->count(); | ||
68 | + | ||
69 | + $list = $this->model | ||
70 | + ->where($where) | ||
71 | + ->order($sort, $order) | ||
72 | + ->limit($offset, $limit) | ||
73 | + ->select(); | ||
74 | + | ||
75 | + $result = array("total" => $total, "rows" => $list); | ||
76 | + | ||
77 | + return json($result); | ||
78 | + } | ||
79 | + return $this->view->fetch('index'); | ||
80 | + } | ||
81 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller\example; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 表格模板示例 | ||
9 | + * | ||
10 | + * @icon fa fa-table | ||
11 | + * @remark 可以通过使用表格模板将表格中的行渲染成一样的展现方式,基于此功能可以任意定制自己想要的展示列表 | ||
12 | + */ | ||
13 | +class Tabletemplate extends Backend | ||
14 | +{ | ||
15 | + protected $model = null; | ||
16 | + | ||
17 | + public function _initialize() | ||
18 | + { | ||
19 | + parent::_initialize(); | ||
20 | + $this->model = model('AdminLog'); | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * 查看 | ||
25 | + */ | ||
26 | + public function index() | ||
27 | + { | ||
28 | + if ($this->request->isAjax()) { | ||
29 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(null); | ||
30 | + $total = $this->model | ||
31 | + ->where($where) | ||
32 | + ->order($sort, $order) | ||
33 | + ->count(); | ||
34 | + $list = $this->model | ||
35 | + ->where($where) | ||
36 | + ->order($sort, $order) | ||
37 | + ->limit($offset, $limit) | ||
38 | + ->select(); | ||
39 | + $result = array("total" => $total, "rows" => $list); | ||
40 | + | ||
41 | + return json($result); | ||
42 | + } | ||
43 | + return $this->view->fetch(); | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * 详情 | ||
48 | + */ | ||
49 | + public function detail($ids) | ||
50 | + { | ||
51 | + $row = $this->model->get(['id' => $ids]); | ||
52 | + if (!$row) { | ||
53 | + $this->error(__('No Results were found')); | ||
54 | + } | ||
55 | + $this->view->assign("row", $row->toArray()); | ||
56 | + return $this->view->fetch(); | ||
57 | + } | ||
58 | +} |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh,delete')} | ||
10 | + <a href="example/baidumap/map" class="btn btn-info btn-dialog" title="地图"><i class="fa fa-map-signs"></i> 地图</a> | ||
11 | + </div> | ||
12 | + <table id="table" class="table table-striped table-bordered table-hover" width="100%"> | ||
13 | + | ||
14 | + </table> | ||
15 | + | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | +</div> |
1 | +{__NOLAYOUT__} | ||
2 | +<!DOCTYPE html> | ||
3 | +<html lang="{$config.language}"> | ||
4 | + <head> | ||
5 | + {include file="common/meta" /} | ||
6 | + <style type="text/css"> | ||
7 | + body, html,#allmap{width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";} | ||
8 | + #search{position:absolute;top:20px;left:20px;} | ||
9 | + </style> | ||
10 | + </head> | ||
11 | + | ||
12 | + <body class="inside-header inside-aside {:defined('IS_DIALOG') && IS_DIALOG ? 'is-dialog' : ''}"> | ||
13 | + <div class="container-fluid" id="search"> | ||
14 | + <div class="row"> | ||
15 | + <div class="col-xs-12 col-sm-4"> | ||
16 | + <form role="form" action=""> | ||
17 | + <div class="input-group" style="width:300px;"> | ||
18 | + <input type="text" id="searchaddress" class="form-control selectpage" data-primary-key="name" data-source="example/baidumap/selectpage" /> | ||
19 | + <span class="input-group-btn"> | ||
20 | + <button class="btn btn-success btn-search" type="button">搜索</button> | ||
21 | + </span> | ||
22 | + </div> | ||
23 | + </form> | ||
24 | + </div> | ||
25 | + </div> | ||
26 | + </div> | ||
27 | + <div id='allmap'></div> | ||
28 | + {include file="common/script" /} | ||
29 | + </body> | ||
30 | +</html> |
1 | +<table class="table table-striped"> | ||
2 | + <thead> | ||
3 | + <tr> | ||
4 | + <th>{:__('Title')}</th> | ||
5 | + <th>{:__('Content')}</th> | ||
6 | + </tr> | ||
7 | + </thead> | ||
8 | + <tbody> | ||
9 | + {volist name="row" id="vo" } | ||
10 | + <tr> | ||
11 | + <td>{$key}</td> | ||
12 | + <td>{$vo}</td> | ||
13 | + </tr> | ||
14 | + {/volist} | ||
15 | + {if $Think.get.dialog} | ||
16 | + <tr> | ||
17 | + <td>回传数据</td> | ||
18 | + <td> | ||
19 | + <div class="input-group"> | ||
20 | + <input name="callback" class="form-control" value="test" /> | ||
21 | + <span class="input-group-btn"><a href="javascript:;" class="btn btn-success btn-callback" >回传数据</a></span> | ||
22 | + </div> | ||
23 | + </td> | ||
24 | + </tr> | ||
25 | + {/if} | ||
26 | + </tbody> | ||
27 | +</table> | ||
28 | +<div class="hide layer-footer"> | ||
29 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
30 | + <div class="col-xs-12 col-sm-8"> | ||
31 | + <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button> | ||
32 | + </div> | ||
33 | +</div> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh,delete')} | ||
10 | + <a class="btn btn-info btn-disabled disabled btn-selected" href="javascript:;"><i class="fa fa-leaf"></i> 获取选中项</a> | ||
11 | + <div class="dropdown btn-group"> | ||
12 | + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> <?= __('More') ?></a> | ||
13 | + <ul class="dropdown-menu text-left" role="menu"> | ||
14 | + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> | ||
15 | + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> | ||
16 | + </ul> | ||
17 | + </div> | ||
18 | + <a class="btn btn-success btn-singlesearch" href="javascript:;"><i class="fa fa-user"></i> 自定义搜索</a> | ||
19 | + <a class="btn btn-success btn-change btn-start" data-params="action=start" data-url="example/bootstraptable/start" href="javascript:;"><i class="fa fa-play"></i> 启动</a> | ||
20 | + <a class="btn btn-danger btn-change btn-pause" data-params="action=pause" data-url="example/bootstraptable/pause" href="javascript:;"><i class="fa fa-pause"></i> 暂停</a> | ||
21 | + <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;"> | ||
22 | + <i class="fa fa-dollar"></i> | ||
23 | + <span class="extend"> | ||
24 | + 金额:<span id="money">0</span> | ||
25 | + 单价:<span id="price">0</span> | ||
26 | + </span> | ||
27 | + </a> | ||
28 | + </div> | ||
29 | + <table id="table" class="table table-striped table-bordered table-hover" width="100%"> | ||
30 | + | ||
31 | + </table> | ||
32 | + | ||
33 | + </div> | ||
34 | + </div> | ||
35 | + | ||
36 | + </div> | ||
37 | + </div> | ||
38 | +</div> | ||
39 | +<script id="categorytpl" type="text/html"> | ||
40 | + <div class="row"> | ||
41 | + <div class="col-xs-12"> | ||
42 | + <div class="form-inline" data-toggle="cxselect" data-selects="group,admin"> | ||
43 | + <select class="group form-control" name="group" data-url="example/bootstraptable/cxselect?type=group"></select> | ||
44 | + <select class="admin form-control" name="admin_id" data-url="example/bootstraptable/cxselect?type=admin" data-query-name="group_id"></select> | ||
45 | + <input type="hidden" class="operate" data-name="admin_id" value="=" /> | ||
46 | + </div> | ||
47 | + </div> | ||
48 | + </div> | ||
49 | +</script> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh,delete')} | ||
10 | + </div> | ||
11 | + <table id="table" class="table table-striped table-bordered table-hover" width="100%"> | ||
12 | + | ||
13 | + </table> | ||
14 | + | ||
15 | + | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | +</div> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh,delete')} | ||
10 | + </div> | ||
11 | + <table id="table" class="table table-striped table-bordered table-hover" width="100%"> | ||
12 | + | ||
13 | + </table> | ||
14 | + | ||
15 | + | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | +</div> |
1 | +<div class="row"> | ||
2 | + <div class="col-md-6"> | ||
3 | + <div class="box box-success"> | ||
4 | + <div class="panel-heading"> | ||
5 | + {:__('自定义图片描述')} | ||
6 | + </div> | ||
7 | + <div class="panel-body"> | ||
8 | + <div class="alert alert-success-light"> | ||
9 | + <b>温馨提示</b><br> | ||
10 | + 默认我们的多图是没有图片描述的,如果我们需要自定义描述,可以使用以下的自定义功能<br> | ||
11 | + 特别注意的是图片的url和描述是分开储存的,也就是说图片一个字段,描述一个字段,你在前台使用时需要自己匹配映射关系<br> | ||
12 | + <b>下面的演示textarea为了便于调试,设置为可见的,实际使用中应该添加个hidden的class进行隐藏</b> | ||
13 | + </div> | ||
14 | + <form id="first-form" role="form" data-toggle="validator" method="POST" action=""> | ||
15 | + <div class="form-group row"> | ||
16 | + <label class="control-label col-xs-12 col-sm-2">{:__('一维数组示例')}:</label> | ||
17 | + <div class="col-xs-12 col-sm-8"> | ||
18 | + <div class="input-group"> | ||
19 | + <input id="c-files" data-rule="required" class="form-control" size="50" name="row[files]" type="text" value="https://cdn.fastadmin.net/uploads/addons/blog.png,https://cdn.fastadmin.net/uploads/addons/cms.png,https://cdn.fastadmin.net/uploads/addons/vote.png"> | ||
20 | + <div class="input-group-addon no-border no-padding"> | ||
21 | + <span><button type="button" id="plupload-files" class="btn btn-danger plupload" data-input-id="c-files" data-mimetype="*" data-multiple="true" data-preview-id="p-files"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> | ||
22 | + <span><button type="button" id="fachoose-files" class="btn btn-primary fachoose" data-input-id="c-files" data-mimetype="*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> | ||
23 | + </div> | ||
24 | + <span class="msg-box n-right" for="c-files"></span> | ||
25 | + </div> | ||
26 | + | ||
27 | + <!--ul需要添加 data-template和data-name属性,并一一对应且唯一 --> | ||
28 | + <ul class="row list-inline plupload-preview" id="p-files" data-template="introtpl" data-name="row[intro]"></ul> | ||
29 | + | ||
30 | + <!--请注意 ul和textarea间不能存在其它任何元素,实际开发中textarea应该添加个hidden进行隐藏--> | ||
31 | + <textarea name="row[intro]" class="form-control" style="margin-top:5px;">["简洁响应式博客","CMS内容管理系统","在线投票系统"]</textarea> | ||
32 | + | ||
33 | + <!--这里自定义图片预览的模板 开始--> | ||
34 | + <script type="text/html" id="introtpl"> | ||
35 | + <li class="col-xs-3"> | ||
36 | + <a href="<%=fullurl%>" data-url="<%=url%>" target="_blank" class="thumbnail"> | ||
37 | + <img src="<%=fullurl%>" class="img-responsive"> | ||
38 | + </a> | ||
39 | + <input type="text" name="row[intro][<%=index%>]" class="form-control" placeholder="请输入文件描述" value="<%=value?value:''%>"/> | ||
40 | + <a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="fa fa-trash"></i></a> | ||
41 | + </li> | ||
42 | + </script> | ||
43 | + <!--这里自定义图片预览的模板 结束--> | ||
44 | + </div> | ||
45 | + </div> | ||
46 | + <div class="form-group row"> | ||
47 | + <label class="control-label col-xs-12 col-sm-2">{:__('二维数组示例')}:</label> | ||
48 | + <div class="col-xs-12 col-sm-8"> | ||
49 | + <div class="input-group"> | ||
50 | + <input id="c-images" data-rule="required" class="form-control" size="50" name="row[images]" type="text" value="https://cdn.fastadmin.net/uploads/addons/example.png,https://cdn.fastadmin.net/uploads/addons/upyun.png,https://cdn.fastadmin.net/uploads/addons/alioss.png"> | ||
51 | + <div class="input-group-addon no-border no-padding"> | ||
52 | + <span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> | ||
53 | + <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> | ||
54 | + </div> | ||
55 | + <span class="msg-box n-right" for="c-images"></span> | ||
56 | + </div> | ||
57 | + | ||
58 | + <!--ul需要添加 data-template和data-name属性,并一一对应且唯一 --> | ||
59 | + <ul class="row list-inline plupload-preview" id="p-images" data-template="desctpl" data-name="row[desc]"></ul> | ||
60 | + | ||
61 | + <!--请注意 ul和textarea间不能存在其它任何元素,实际开发中textarea应该添加个hidden进行隐藏--> | ||
62 | + <textarea name="row[desc]" class="form-control" style="margin-top:5px;">[{"info":"开发者示例插件","size":"1M"},{"info":"又拍云储存整合","size":"2M"},{"info":"阿里OSS云储存","size":"1M"}]</textarea> | ||
63 | + | ||
64 | + <!--这里自定义图片预览的模板 开始--> | ||
65 | + <script type="text/html" id="desctpl"> | ||
66 | + <li class="col-xs-3"> | ||
67 | + <a href="<%=fullurl%>" data-url="<%=url%>" target="_blank" class="thumbnail"> | ||
68 | + <img src="<%=fullurl%>" class="img-responsive"> | ||
69 | + </a> | ||
70 | + <input type="text" name="row[desc][<%=index%>][info]" class="form-control" placeholder="请输入插件描述" value="<%=value?value['info']:''%>"/> | ||
71 | + <input type="text" name="row[desc][<%=index%>][size]" class="form-control" placeholder="请输入插件大小" value="<%=value?value['size']:''%>"/> | ||
72 | + <a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="fa fa-trash"></i></a> | ||
73 | + </li> | ||
74 | + </script> | ||
75 | + <!--这里自定义图片预览的模板 结束--> | ||
76 | + </div> | ||
77 | + </div> | ||
78 | + <div class="form-group row"> | ||
79 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
80 | + <div class="col-xs-12 col-sm-8"> | ||
81 | + <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button> | ||
82 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
83 | + </div> | ||
84 | + </div> | ||
85 | + | ||
86 | + </form> | ||
87 | + </div> | ||
88 | + </div> | ||
89 | + | ||
90 | + </div> | ||
91 | + <div class="col-md-6"> | ||
92 | + <div class="box box-info"> | ||
93 | + <div class="panel-heading"> | ||
94 | + {:__('自定义Fieldlist示例')} | ||
95 | + </div> | ||
96 | + <div class="panel-body"> | ||
97 | + <div class="alert alert-danger-light"> | ||
98 | + <b>温馨提示</b><br> | ||
99 | + 默认我们的fieldlist只有一维数组,为键值形式,如果需要二维数组,可使用下面的自定义模板来实现<br> | ||
100 | + 默认追加的元素是没有进行事件绑定的,我们需要监听btn-append这个按钮的fa.event.appendfieldlist事件<br> | ||
101 | + <b>下面的演示textarea为了便于调试,设置为可见的,实际使用中应该添加个hidden的class进行隐藏</b> | ||
102 | + </div> | ||
103 | + <form id="second-form" role="form" data-toggle="validator" method="POST" action=""> | ||
104 | + | ||
105 | + <div class="form-group row"> | ||
106 | + <label class="control-label col-xs-12 col-sm-2">{:__('Fieldlist示例')}:</label> | ||
107 | + <div class="col-xs-12 col-sm-8"> | ||
108 | + <dl class="fieldlist" data-template="basictpl" data-name="row[basic]"> | ||
109 | + <dd> | ||
110 | + <ins>{:__('标题')}</ins> | ||
111 | + <ins>{:__('介绍')}</ins> | ||
112 | + <ins>{:__('大小')}</ins> | ||
113 | + </dd> | ||
114 | + <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd> | ||
115 | + <!--请注意 dd和textarea间不能存在其它任何元素,实际开发中textarea应该添加个hidden进行隐藏--> | ||
116 | + <textarea name="row[basic]" class="form-control" cols="30" rows="5">[{"title":"开发者示例插件","intro":"开发者必备","size":"1M"},{"title":"又拍云储存整合","intro":"一款云储存","size":"2M"},{"title":"阿里OSS云储存","intro":"一款云储存","size":"1M"}]</textarea> | ||
117 | + </dl> | ||
118 | + <script id="basictpl" type="text/html"> | ||
119 | + <dd class="form-inline"> | ||
120 | + <ins><input type="text" name="<%=name%>[<%=index%>][title]" class="form-control" value="<%=row.title%>" placeholder="标题" size="10"/></ins> | ||
121 | + <ins><input type="text" name="<%=name%>[<%=index%>][intro]" class="form-control" value="<%=row.intro%>" placeholder="描述"/></ins> | ||
122 | + <ins><input type="text" name="<%=name%>[<%=index%>][size]" class="form-control" value="<%=row.size%>" placeholder="大小"/></ins> | ||
123 | + <!--下面的两个按钮务必保留--> | ||
124 | + <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> | ||
125 | + <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span> | ||
126 | + </dd> | ||
127 | + </script> | ||
128 | + </div> | ||
129 | + </div> | ||
130 | + <div class="form-group row"> | ||
131 | + <label class="control-label col-xs-12 col-sm-2">{:__('元素事件')}:</label> | ||
132 | + <div class="col-xs-12 col-sm-8"> | ||
133 | + <dl class="fieldlist" data-template="eventtpl" data-name="row[event]"> | ||
134 | + <dd> | ||
135 | + <ins>{:__('管理员')}</ins> | ||
136 | + <ins>{:__('名称')}</ins> | ||
137 | + <ins>{:__('登录时间')}</ins> | ||
138 | + </dd> | ||
139 | + <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd> | ||
140 | + <!--请注意 dd和textarea间不能存在其它任何元素,实际开发中textarea应该添加个hidden进行隐藏--> | ||
141 | + <textarea name="row[event]" class="form-control" cols="30" rows="5">[{"id":"1","name":"admin","time":"2019-06-28 12:05:03"}]</textarea> | ||
142 | + </dl> | ||
143 | + <script id="eventtpl" type="text/html"> | ||
144 | + <dd class="form-inline"> | ||
145 | + <ins><input type="text" name="<%=name%>[<%=index%>][id]" class="form-control selectpage" data-source="auth/admin/selectpage" data-field="username" value="<%=row.id%>" placeholder="管理员" size="10"/></ins> | ||
146 | + <ins><input type="text" name="<%=name%>[<%=index%>][name]" class="form-control" value="<%=row.name%>" placeholder="名称"/></ins> | ||
147 | + <ins><input type="text" name="<%=name%>[<%=index%>][time]" class="form-control datetimepicker" value="<%=row.time%>" placeholder="时间"/></ins> | ||
148 | + <!--下面的两个按钮务必保留--> | ||
149 | + <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> | ||
150 | + <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span> | ||
151 | + </dd> | ||
152 | + </script> | ||
153 | + </div> | ||
154 | + </div> | ||
155 | + <div class="form-group row"> | ||
156 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
157 | + <div class="col-xs-12 col-sm-8"> | ||
158 | + <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button> | ||
159 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
160 | + </div> | ||
161 | + </div> | ||
162 | + | ||
163 | + </form> | ||
164 | + </div> | ||
165 | + </div> | ||
166 | + | ||
167 | + </div> | ||
168 | +</div> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh')} | ||
10 | + </div> | ||
11 | + <table id="table" class="table table-striped table-bordered table-hover" width="100%"> | ||
12 | + | ||
13 | + </table> | ||
14 | + | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + | ||
18 | + </div> | ||
19 | + </div> | ||
20 | +</div> | ||
21 | + | ||
22 | +<script id="customformtpl" type="text/html"> | ||
23 | + <!--form表单必须添加form-commsearch这个类--> | ||
24 | + <form action="" class="form-commonsearch"> | ||
25 | + <div style="border-radius:2px;margin-bottom:10px;background:#f5f5f5;padding:15px 20px;"> | ||
26 | + <h4>自定义搜索表单</h4> | ||
27 | + <hr> | ||
28 | + <div class="row"> | ||
29 | + <div class="col-xs-12 col-sm-6 col-md-3"> | ||
30 | + <div class="form-group"> | ||
31 | + <label class="control-label">ID</label> | ||
32 | + <!--显式的operate操作符--> | ||
33 | + <div class="input-group"> | ||
34 | + <div class="input-group-btn"> | ||
35 | + <select class="form-control operate" data-name="id" style="width:60px;"> | ||
36 | + <option value="=" selected>等于</option> | ||
37 | + <option value=">">大于</option> | ||
38 | + <option value="<">小于</option> | ||
39 | + </select> | ||
40 | + </div> | ||
41 | + <input class="form-control" type="text" name="id" placeholder="" value=""/> | ||
42 | + </div> | ||
43 | + </div> | ||
44 | + </div> | ||
45 | + <div class="col-xs-12 col-sm-6 col-md-3"> | ||
46 | + <div class="form-group"> | ||
47 | + <label class="control-label">标题</label> | ||
48 | + <!--隐式的operate操作符,必须携带一个class为operate隐藏的文本框,且它的data-name="字段",值为操作符--> | ||
49 | + <input class="operate" type="hidden" data-name="title" value="="/> | ||
50 | + <div> | ||
51 | + <input class="form-control" type="text" name="title" placeholder="请输入查找的标题" value=""/> | ||
52 | + </div> | ||
53 | + </div> | ||
54 | + </div> | ||
55 | + <div class="col-xs-12 col-sm-6 col-md-3"> | ||
56 | + <div class="form-group"> | ||
57 | + <label class="control-label">管理员ID</label> | ||
58 | + <div class="row" data-toggle="cxselect" data-selects="group,admin"> | ||
59 | + <div class="col-xs-6"> | ||
60 | + <select class="group form-control" name="group" | ||
61 | + data-url="example/bootstraptable/cxselect?type=group"></select> | ||
62 | + </div> | ||
63 | + <div class="col-xs-6"> | ||
64 | + <select class="admin form-control" name="admin_id" | ||
65 | + data-url="example/bootstraptable/cxselect?type=admin" | ||
66 | + data-query-name="group_id"></select> | ||
67 | + </div> | ||
68 | + <input type="hidden" class="operate" data-name="admin_id" value="="/> | ||
69 | + </div> | ||
70 | + </div> | ||
71 | + </div> | ||
72 | + <div class="col-xs-12 col-sm-6 col-md-3"> | ||
73 | + <div class="form-group"> | ||
74 | + <label class="control-label">用户名</label> | ||
75 | + <input type="hidden" class="operate" data-name="username" value="="/> | ||
76 | + <div> | ||
77 | + <input id="c-category_id" data-source="auth/admin/index" data-primary-key="username" | ||
78 | + data-field="username" class="form-control selectpage" name="username" type="text" | ||
79 | + value="" style="display:block;"> | ||
80 | + </div> | ||
81 | + </div> | ||
82 | + </div> | ||
83 | + | ||
84 | + <div class="col-xs-12 col-sm-6 col-md-3" style="min-height:68px;"> | ||
85 | + <!--这里添加68px是为了避免刷新时出现元素错位闪屏--> | ||
86 | + <div class="form-group"> | ||
87 | + <label class="control-label">IP</label> | ||
88 | + <input type="hidden" class="operate" data-name="ip" value="in"/> | ||
89 | + <div> | ||
90 | + <!--给select一个固定的高度--> | ||
91 | + <select id="c-flag" class="form-control selectpicker" multiple name="ip" style="height:31px;"> | ||
92 | + {foreach name="ipList" item="vo"} | ||
93 | + <option value="{$key}" {in name="key" value="" }selected{ | ||
94 | + /in}>{$vo}</option> | ||
95 | + {/foreach} | ||
96 | + </select> | ||
97 | + </div> | ||
98 | + </div> | ||
99 | + </div> | ||
100 | + <div class="col-xs-12 col-sm-6 col-md-3"> | ||
101 | + <div class="form-group"> | ||
102 | + <label class="control-label">IP</label> | ||
103 | + <input type="hidden" class="operate" data-name="createtime" value="RANGE"/> | ||
104 | + <div> | ||
105 | + <input type="text" class="form-control datetimerange" name="createtime" value=""/> | ||
106 | + </div> | ||
107 | + </div> | ||
108 | + </div> | ||
109 | + <div class="col-xs-12 col-sm-6 col-md-3"> | ||
110 | + <div class="form-group"> | ||
111 | + <label class="control-label"></label> | ||
112 | + <div class="row"> | ||
113 | + <div class="col-xs-6"> | ||
114 | + <input type="submit" class="btn btn-success btn-block" value="提交"/> | ||
115 | + </div> | ||
116 | + <div class="col-xs-6"> | ||
117 | + <input type="reset" class="btn btn-primary btn-block" value="重置"/> | ||
118 | + </div> | ||
119 | + </div> | ||
120 | + </div> | ||
121 | + </div> | ||
122 | + </div> | ||
123 | + </div> | ||
124 | + </form> | ||
125 | +</script> |
1 | +<style>#cxselect-example textarea{margin:10px 0;}</style> | ||
2 | +<div class="panel panel-default panel-intro"> | ||
3 | + {:build_heading()} | ||
4 | + | ||
5 | + <div class="panel-body"> | ||
6 | + <div id="myTabContent" class="tab-content"> | ||
7 | + <div class="tab-pane fade active in" id="one"> | ||
8 | + <div class="widget-body no-padding" id="cxselect-example"> | ||
9 | + <form id="cxselectform" action=""> | ||
10 | + <div class="row"> | ||
11 | + <div class="col-md-6"> | ||
12 | + | ||
13 | + <div class="panel panel-default"> | ||
14 | + <div class="panel-heading"><b>省市区联动</b>(通过AJAX读取数据)</div> | ||
15 | + <div class="panel-body"> | ||
16 | + <div class="row"> | ||
17 | + <div class="col-xs-9"> | ||
18 | + <div class="form-inline" data-toggle="cxselect" data-selects="province,city,area"> | ||
19 | + <select class="province form-control" name="province" data-url="ajax/area"></select> | ||
20 | + <select class="city form-control" name="city" data-url="ajax/area"></select> | ||
21 | + <select class="area form-control" name="area" data-url="ajax/area"></select> | ||
22 | + </div> | ||
23 | + </div> | ||
24 | + <div class="col-xs-3 text-right"> | ||
25 | + <h6><label class="label label-primary"><i class="fa fa-pencil"></i> 增加</label></h6> | ||
26 | + </div> | ||
27 | + <div class="col-xs-12"> | ||
28 | + <textarea class="form-control" rows="8"> | ||
29 | + </textarea> | ||
30 | + </div> | ||
31 | + </div> | ||
32 | + <div class="row"> | ||
33 | + <div class="col-xs-9"> | ||
34 | + <div class="form-inline" data-toggle="cxselect" data-selects="province,city,area"> | ||
35 | + <select class="province form-control" name="province" data-url="ajax/area"> | ||
36 | + <option value="1964" selected>广东省</option> | ||
37 | + </select> | ||
38 | + <select class="city form-control" name="city" data-url="ajax/area"> | ||
39 | + <option value="1988" selected>深圳市</option> | ||
40 | + </select> | ||
41 | + <select class="area form-control" name="area" data-url="ajax/area"> | ||
42 | + <option value="1991" selected>南山区</option> | ||
43 | + </select> | ||
44 | + </div> | ||
45 | + </div> | ||
46 | + <div class="col-xs-3 text-right"> | ||
47 | + <h6><label class="label label-success"><i class="fa fa-edit"></i> 修改</label></h6> | ||
48 | + </div> | ||
49 | + <div class="col-xs-12"> | ||
50 | + <textarea class="form-control" rows="8"> | ||
51 | + </textarea> | ||
52 | + </div> | ||
53 | + </div> | ||
54 | + </div> | ||
55 | + | ||
56 | + </div> | ||
57 | + </div> | ||
58 | + <div class="col-md-6"> | ||
59 | + <div class="panel panel-default"> | ||
60 | + <div class="panel-heading"><b>类别联动</b>(Ajax读取数据)</div> | ||
61 | + <div class="panel-body"> | ||
62 | + <div class="row"> | ||
63 | + <div class="col-xs-9"> | ||
64 | + <div class="form-inline" data-toggle="cxselect" data-selects="first,second"> | ||
65 | + <select class="first form-control" name="first" data-url="ajax/category?type=page&pid=5"></select> | ||
66 | + <select class="second form-control" name="second" data-url="ajax/category" data-query-name="pid"></select> | ||
67 | + </div> | ||
68 | + </div> | ||
69 | + <div class="col-xs-3 text-right"> | ||
70 | + <h6><label class="label label-primary"><i class="fa fa-pencil"></i> 增加</label></h6> | ||
71 | + </div> | ||
72 | + <div class="col-xs-12"> | ||
73 | + <textarea class="form-control" rows="8"> | ||
74 | + </textarea> | ||
75 | + </div> | ||
76 | + </div> | ||
77 | + <div class="row"> | ||
78 | + <div class="col-xs-9"> | ||
79 | + <div class="form-inline" data-toggle="cxselect" data-selects="first,second"> | ||
80 | + <select class="first form-control" name="first" data-url="ajax/category?type=page&pid=5"> | ||
81 | + <option value="6" selected>网站建站</option> | ||
82 | + </select> | ||
83 | + <select class="second form-control" name="second" data-url="ajax/category" data-query-name="pid"> | ||
84 | + <option value="9" selected>移动端</option> | ||
85 | + </select> | ||
86 | + </div> | ||
87 | + </div> | ||
88 | + <div class="col-xs-3 text-right"> | ||
89 | + <h6><label class="label label-success"><i class="fa fa-edit"></i> 修改</label></h6> | ||
90 | + </div> | ||
91 | + <div class="col-xs-12"> | ||
92 | + <textarea class="form-control" rows="8"> | ||
93 | + </textarea> | ||
94 | + </div> | ||
95 | + </div> | ||
96 | + | ||
97 | + </div> | ||
98 | + </div> | ||
99 | + </div> | ||
100 | + <div class="col-md-6"> | ||
101 | + <div class="panel panel-default"> | ||
102 | + <div class="panel-heading"><b>省市区联动</b>(通过JSON渲染数据)</div> | ||
103 | + <div class="panel-body"> | ||
104 | + <div class="row"> | ||
105 | + <div class="col-xs-9"> | ||
106 | + <!--由于在初始化中修改了默认值,所以这里需要修改-jsonSpace/jsonValue/jsonName的值--> | ||
107 | + <div class="form-inline" data-toggle="cxselect" data-url="__CDN__/assets/libs/fastadmin-cxselect/js/cityData.min.json" | ||
108 | + data-selects="province,city,area" data-json-space="" data-json-name="n" data-json-value=""> | ||
109 | + <select class="province form-control" name="province"></select> | ||
110 | + <select class="city form-control" name="city"></select> | ||
111 | + <select class="area form-control" name="area"></select> | ||
112 | + </div> | ||
113 | + </div> | ||
114 | + <div class="col-xs-3 text-right"> | ||
115 | + <h6><label class="label label-primary"><i class="fa fa-pencil"></i> 增加</label></h6> | ||
116 | + </div> | ||
117 | + <div class="col-xs-12"> | ||
118 | + <textarea class="form-control" rows="8"> | ||
119 | + </textarea> | ||
120 | + </div> | ||
121 | + </div> | ||
122 | + <div class="row"> | ||
123 | + <div class="col-xs-9"> | ||
124 | + <!--由于在初始化中修改了默认值,所以这里需要修改-jsonSpace/jsonValue/jsonName的值--> | ||
125 | + <div class="form-inline" data-toggle="cxselect" data-url="__CDN__/assets/libs/fastadmin-cxselect/js/cityData.min.json" | ||
126 | + data-selects="province,city,area" data-json-space="" data-json-name="n" data-json-value=""> | ||
127 | + <select class="province form-control" data-first-title="选择省"> | ||
128 | + <option value="">请选择</option> | ||
129 | + <option value="浙江省" selected>浙江省</option> | ||
130 | + </select> | ||
131 | + <select class="city form-control" data-first-title="选择市"> | ||
132 | + <option value="">请选择</option> | ||
133 | + <option value="杭州市" selected>杭州市</option> | ||
134 | + </select> | ||
135 | + <select class="area form-control" data-first-title="选择地区"> | ||
136 | + <option value="">请选择</option> | ||
137 | + <option value="西湖区" selected>西湖区</option> | ||
138 | + </select> | ||
139 | + </div> | ||
140 | + </div> | ||
141 | + <div class="col-xs-3 text-right"> | ||
142 | + <h6><label class="label label-success"><i class="fa fa-edit"></i> 修改</label></h6> | ||
143 | + </div> | ||
144 | + <div class="col-xs-12"> | ||
145 | + <textarea class="form-control" rows="8"> | ||
146 | + </textarea> | ||
147 | + </div> | ||
148 | + </div> | ||
149 | + </div> | ||
150 | + | ||
151 | + </div> | ||
152 | + </div> | ||
153 | + </div> | ||
154 | + </form> | ||
155 | + </div> | ||
156 | + </div> | ||
157 | + | ||
158 | + </div> | ||
159 | + </div> | ||
160 | +</div> |
1 | +<style> | ||
2 | + .tab-content > .chart { | ||
3 | + padding: 10px; | ||
4 | + } | ||
5 | +</style> | ||
6 | +<div class="row"> | ||
7 | + <div class="col-lg-3 col-xs-6"> | ||
8 | + <!-- small box --> | ||
9 | + <div class="small-box bg-aqua"> | ||
10 | + <div class="inner"> | ||
11 | + <h3>150</h3> | ||
12 | + | ||
13 | + <p>今日订单</p> | ||
14 | + </div> | ||
15 | + <div class="icon"> | ||
16 | + <i class="fa fa-shopping-cart"></i> | ||
17 | + </div> | ||
18 | + <a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <!-- ./col --> | ||
22 | + <div class="col-lg-3 col-xs-6"> | ||
23 | + <!-- small box --> | ||
24 | + <div class="small-box bg-green"> | ||
25 | + <div class="inner"> | ||
26 | + <h3>53<sup style="font-size: 20px">%</sup></h3> | ||
27 | + | ||
28 | + <p>同比增长率</p> | ||
29 | + </div> | ||
30 | + <div class="icon"> | ||
31 | + <i class="fa fa-area-chart"></i> | ||
32 | + </div> | ||
33 | + <a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a> | ||
34 | + </div> | ||
35 | + </div> | ||
36 | + <!-- ./col --> | ||
37 | + <div class="col-lg-3 col-xs-6"> | ||
38 | + <!-- small box --> | ||
39 | + <div class="small-box bg-yellow"> | ||
40 | + <div class="inner"> | ||
41 | + <h3>44</h3> | ||
42 | + | ||
43 | + <p>今日注册用户数</p> | ||
44 | + </div> | ||
45 | + <div class="icon"> | ||
46 | + <i class="fa fa-users"></i> | ||
47 | + </div> | ||
48 | + <a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a> | ||
49 | + </div> | ||
50 | + </div> | ||
51 | + <!-- ./col --> | ||
52 | + <div class="col-lg-3 col-xs-6"> | ||
53 | + <!-- small box --> | ||
54 | + <div class="small-box bg-red"> | ||
55 | + <div class="inner"> | ||
56 | + <h3>65</h3> | ||
57 | + | ||
58 | + <p>唯一访客用户</p> | ||
59 | + </div> | ||
60 | + <div class="icon"> | ||
61 | + <i class="fa fa-user"></i> | ||
62 | + </div> | ||
63 | + <a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a> | ||
64 | + </div> | ||
65 | + </div> | ||
66 | + <!-- ./col --> | ||
67 | +</div> | ||
68 | +<!-- /.row --> | ||
69 | +<!-- Main row --> | ||
70 | +<div class="row" style="margin-bottom:5px;"> | ||
71 | + <!-- Left col --> | ||
72 | + <section class="col-lg-7 connectedSortable"> | ||
73 | + <!-- Custom tabs (Charts with tabs)--> | ||
74 | + <div class="nav-tabs-custom charts-custom"> | ||
75 | + <!-- Tabs within a box --> | ||
76 | + <ul class="nav nav-tabs pull-right"> | ||
77 | + <li class="active"><a href="#line-chart" data-toggle="tab">折线图</a></li> | ||
78 | + <li><a href="#area-chart" data-toggle="tab">区域图</a></li> | ||
79 | + <li class="pull-left header"><i class="fa fa-inbox"></i> 销售趋势</li> | ||
80 | + </ul> | ||
81 | + <div class="tab-content no-padding"> | ||
82 | + <!-- Morris chart - Sales --> | ||
83 | + <div class="chart tab-pane active" id="line-chart" style="position: relative; height: 300px;"></div> | ||
84 | + <div class="chart tab-pane" id="area-chart" style="position: relative; height: 300px;"></div> | ||
85 | + </div> | ||
86 | + </div> | ||
87 | + <div class="nav-tabs-custom charts-custom"> | ||
88 | + <!-- Tabs within a box --> | ||
89 | + <ul class="nav nav-tabs pull-right"> | ||
90 | + <li class="active"><a href="#pie-chart" data-toggle="tab">饼图</a></li> | ||
91 | + <li><a href="#bar-chart" data-toggle="tab">柱状图</a></li> | ||
92 | + <li class="pull-left header"><i class="fa fa-inbox"></i> 访问记录</li> | ||
93 | + </ul> | ||
94 | + <div class="tab-content no-padding"> | ||
95 | + <!-- Morris chart - Sales --> | ||
96 | + <div class="chart tab-pane active" id="pie-chart" style="position: relative; height: 300px;"></div> | ||
97 | + <div class="chart tab-pane" id="bar-chart" style="position: relative; height: 300px;"></div> | ||
98 | + </div> | ||
99 | + </div> | ||
100 | + <!-- /.nav-tabs-custom --> | ||
101 | + | ||
102 | + </section> | ||
103 | + <!-- /.Left col --> | ||
104 | + <section class="col-lg-5 connectedSortable"> | ||
105 | + | ||
106 | + <!-- Map box --> | ||
107 | + <div class="box box-solid bg-light-blue-gradient"> | ||
108 | + <div class="box-header"> | ||
109 | + <!-- tools box --> | ||
110 | + <div class="pull-right box-tools"> | ||
111 | + </div> | ||
112 | + <!-- /. tools --> | ||
113 | + | ||
114 | + <i class="fa fa-map-marker"></i> | ||
115 | + | ||
116 | + <h3 class="box-title"> | ||
117 | + 访客分布 | ||
118 | + </h3> | ||
119 | + </div> | ||
120 | + <div class="box-body"> | ||
121 | + <div id="simplebar-chart" style="height: 250px; width: 100%;"></div> | ||
122 | + </div> | ||
123 | + <!-- /.box-body--> | ||
124 | + <div class="box-footer no-border"> | ||
125 | + <div class="row"> | ||
126 | + <div class="col-xs-12 text-center"> | ||
127 | + <div class="knob-label">统计最近一周访客的记录</div> | ||
128 | + </div> | ||
129 | + <!-- ./col --> | ||
130 | + </div> | ||
131 | + <!-- /.row --> | ||
132 | + </div> | ||
133 | + </div> | ||
134 | + <!-- /.box --> | ||
135 | + | ||
136 | + <!-- solid sales graph --> | ||
137 | + <div class="box box-solid bg-teal-gradient"> | ||
138 | + <div class="box-header"> | ||
139 | + <i class="fa fa-th"></i> | ||
140 | + | ||
141 | + <h3 class="box-title">订单趋势</h3> | ||
142 | + | ||
143 | + <div class="box-tools pull-right"> | ||
144 | + </div> | ||
145 | + </div> | ||
146 | + <div class="box-body border-radius-none"> | ||
147 | + <div class="chart" id="smoothline-chart" style="height: 250px;"></div> | ||
148 | + </div> | ||
149 | + <!-- /.box-body--> | ||
150 | + <div class="box-footer no-border"> | ||
151 | + <div class="row"> | ||
152 | + <div class="col-xs-12 text-center"> | ||
153 | + <div class="knob-label">统计最近一周订单的趋势</div> | ||
154 | + </div> | ||
155 | + <!-- ./col --> | ||
156 | + </div> | ||
157 | + <!-- /.row --> | ||
158 | + </div> | ||
159 | + </div> | ||
160 | + <!-- /.box --> | ||
161 | + | ||
162 | + </section> | ||
163 | + <!-- right col --> | ||
164 | +</div> | ||
165 | +<!-- /.row (main row) --> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + <div class="panel-heading"> | ||
3 | + <div class="panel-lead"><em>多表格(Multitable)</em>用于展示在一个页面展示多个表格数据,并且每次切换时刷新</div> | ||
4 | + <ul class="nav nav-tabs"> | ||
5 | + <li class="active"><a href="#first" data-toggle="tab">表格1</a></li> | ||
6 | + <li><a href="#second" data-toggle="tab">表格2</a></li> | ||
7 | + </ul> | ||
8 | + </div> | ||
9 | + <div class="panel-body"> | ||
10 | + <div id="myTabContent" class="tab-content"> | ||
11 | + <div class="tab-pane fade active in" id="first"> | ||
12 | + <div id="toolbar1" class="toolbar"> | ||
13 | + {:build_toolbar('refresh')} | ||
14 | + </div> | ||
15 | + <table id="table1" class="table table-striped table-bordered table-hover" width="100%"> | ||
16 | + </table> | ||
17 | + </div> | ||
18 | + <div class="tab-pane fade" id="second"> | ||
19 | + <div id="toolbar2" class="toolbar"> | ||
20 | + {:build_toolbar('refresh')} | ||
21 | + </div> | ||
22 | + <table id="table2" class="table table-striped table-bordered table-hover" width="100%"> | ||
23 | + </table> | ||
24 | + </div> | ||
25 | + </div> | ||
26 | + </div> | ||
27 | +</div> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh,delete')} | ||
10 | + </div> | ||
11 | + <table id="table" class="table table-striped table-bordered table-hover" width="100%"> | ||
12 | + | ||
13 | + </table> | ||
14 | + | ||
15 | + | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | +</div> |
1 | +<div class="row"> | ||
2 | + <div class="col-xs-12 col-sm-6 col-md-5 col-lg-4"> | ||
3 | + <div class="panel panel-default panel-intro"> | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="1" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar1" class="toolbar"> | ||
9 | + {:build_toolbar('refresh')} | ||
10 | + </div> | ||
11 | + <table id="table1" class="table table-striped table-bordered table-hover" width="100%"> | ||
12 | + | ||
13 | + </table> | ||
14 | + | ||
15 | + | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + </div> | ||
22 | + </div> | ||
23 | + <div class="col-xs-12 col-sm-6 col-md-7 col-lg-8"> | ||
24 | + <div class="panel panel-default panel-intro"> | ||
25 | + <div class="panel-body"> | ||
26 | + <div id="myTabContent2" class="tab-content"> | ||
27 | + <div class="tab-pane fade active in" id="two"> | ||
28 | + <div class="widget-body no-padding"> | ||
29 | + <div id="toolbar2" class="toolbar"> | ||
30 | + {:build_toolbar('refresh')} | ||
31 | + </div> | ||
32 | + <table id="table2" class="table table-striped table-bordered table-hover" width="100%"> | ||
33 | + | ||
34 | + </table> | ||
35 | + | ||
36 | + | ||
37 | + </div> | ||
38 | + </div> | ||
39 | + | ||
40 | + </div> | ||
41 | + </div> | ||
42 | + </div> | ||
43 | + </div> | ||
44 | +</div> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + {:build_toolbar('refresh,delete')} | ||
10 | + <a class="btn btn-info btn-disabled disabled btn-selected" href="javascript:;"><i class="fa fa-leaf"></i> 获取选中项</a> | ||
11 | + <a class="btn btn-success btn-toggle-view" href="javascript:;"><i class="fa fa-leaf"></i> 切换视图</a> | ||
12 | + </div> | ||
13 | + <table id="table" class="table table-striped table-hover" width="100%"> | ||
14 | + | ||
15 | + </table> | ||
16 | + | ||
17 | + </div> | ||
18 | + </div> | ||
19 | + | ||
20 | + </div> | ||
21 | + </div> | ||
22 | +</div> | ||
23 | +<style type="text/css"> | ||
24 | + .example { | ||
25 | + height:100%;position: relative; | ||
26 | + } | ||
27 | + .example > span { | ||
28 | + position:absolute;left:15px;top:15px; | ||
29 | + } | ||
30 | +</style> | ||
31 | + | ||
32 | +<script id="itemtpl" type="text/html"> | ||
33 | + <!-- | ||
34 | + 如果启用了templateView,默认调用的是itemtpl这个模板,可以通过设置templateFormatter来修改 | ||
35 | + 在当前模板中可以使用三个变量(item:行数据,i:当前第几行,data:所有的行数据) | ||
36 | + 此模板引擎使用的是art-template的native,可参考官方文档 | ||
37 | + --> | ||
38 | + | ||
39 | + <div class="col-sm-4 col-md-3"> | ||
40 | + <!--下面四行是为了展示随机图片和标签,可移除--> | ||
41 | + <% var imagearr = ['https://cdn.fastadmin.net/uploads/addons/blog.png', 'https://cdn.fastadmin.net/uploads/addons/cms.png', 'https://cdn.fastadmin.net/uploads/addons/vote.png', 'https://cdn.fastadmin.net/uploads/addons/blog.png', 'https://cdn.fastadmin.net/uploads/addons/alisms.png']; %> | ||
42 | + <% var image = imagearr[item.id % 5]; %> | ||
43 | + <% var labelarr = ['primary', 'success', 'info', 'danger', 'warning']; %> | ||
44 | + <% var label = labelarr[item.id % 5]; %> | ||
45 | + <div class="thumbnail example"> | ||
46 | + <span class="btn btn-<%=label%>">ID:<%=item.id%></span> | ||
47 | + <img src="<%=image%>" style="width:100%;" alt="<%=item.title%>"> | ||
48 | + <div class="caption"> | ||
49 | + <h4><%=item.title?item.title:'无'%></h4> | ||
50 | + <p class="text-muted">操作者IP:<%=item.ip%></p> | ||
51 | + <p class="text-muted">操作时间:<%=Moment(item.createtime*1000).format("YYYY-MM-DD HH:mm:ss")%></p> | ||
52 | + <p> | ||
53 | + <!--详情的事件需要在JS中手动绑定--> | ||
54 | + <a href="#" class="btn btn-primary btn-success btn-detail" data-id="<%=item.id%>"><i class="fa fa-camera"></i> 详情</a> | ||
55 | + | ||
56 | + <!--如果需要响应编辑或删除事件,可以给元素添加 btn-edit或btn-del的类和data-id这个属性值--> | ||
57 | + <a href="#" class="btn btn-primary btn-edit" data-id="<%=item.id%>"><i class="fa fa-pencil"></i> 编辑</a> | ||
58 | + <a href="#" class="btn btn-danger btn-del" data-id="<%=item.id%>"><i class="fa fa-times"></i> 删除</a> | ||
59 | + <span class="pull-right" style="margin-top:10px;"> | ||
60 | + <!--如果需要多选操作,请确保有下面的checkbox元素存在,可移除--> | ||
61 | + <input name="checkbox" data-id="<%=item.id%>" type="checkbox" /> | ||
62 | + </span> | ||
63 | + </p> | ||
64 | + </div> | ||
65 | + </div> | ||
66 | + </div> | ||
67 | +</script> |
addons/example/assets/css/common.css
0 → 100644
1 | +/*! | ||
2 | + * Start Bootstrap - Modern Business (http://startbootstrap.com/) | ||
3 | + * Copyright 2013-2016 Start Bootstrap | ||
4 | + * Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap/blob/gh-pages/LICENSE) | ||
5 | + */ | ||
6 | + | ||
7 | +/* Global Styles */ | ||
8 | + | ||
9 | +html, | ||
10 | +body { | ||
11 | + height: 100%; | ||
12 | +} | ||
13 | + | ||
14 | +body { | ||
15 | + padding-top: 50px; /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */ | ||
16 | + -webkit-font-smoothing: antialiased; | ||
17 | + -moz-osx-font-smoothing: grayscale; | ||
18 | + font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||
19 | +} | ||
20 | + | ||
21 | +.img-addon { | ||
22 | + margin-bottom: 10px; | ||
23 | + width:100%; | ||
24 | +} | ||
25 | + | ||
26 | +.img-hover:hover { | ||
27 | + opacity: 0.8; | ||
28 | +} | ||
29 | + | ||
30 | +.display-1 { | ||
31 | + font-size:44px; | ||
32 | +} | ||
33 | +.display-4 { | ||
34 | + font-size:24px; | ||
35 | + line-height:32px; | ||
36 | +} | ||
37 | + | ||
38 | +/* Home Page Carousel */ | ||
39 | + | ||
40 | +header.carousel { | ||
41 | + height: 50%; | ||
42 | +} | ||
43 | + | ||
44 | +header.carousel .item, | ||
45 | +header.carousel .item.active, | ||
46 | +header.carousel .carousel-inner { | ||
47 | + height: 100%; | ||
48 | +} | ||
49 | + | ||
50 | +header.carousel .fill { | ||
51 | + width: 100%; | ||
52 | + height: 100%; | ||
53 | +} | ||
54 | + | ||
55 | +/* 404 Page Styles */ | ||
56 | + | ||
57 | +.error-404 { | ||
58 | + font-size: 100px; | ||
59 | +} | ||
60 | + | ||
61 | +/* Pricing Page Styles */ | ||
62 | + | ||
63 | +.price { | ||
64 | + display: block; | ||
65 | + font-size: 50px; | ||
66 | + line-height: 50px; | ||
67 | +} | ||
68 | + | ||
69 | +.price sup { | ||
70 | + top: -20px; | ||
71 | + left: 2px; | ||
72 | + font-size: 20px; | ||
73 | +} | ||
74 | + | ||
75 | +.period { | ||
76 | + display: block; | ||
77 | + font-style: italic; | ||
78 | +} | ||
79 | + | ||
80 | +/* Footer Styles */ | ||
81 | + | ||
82 | +footer { | ||
83 | + margin: 50px 0; | ||
84 | +} | ||
85 | + | ||
86 | +/* Responsive Styles */ | ||
87 | + | ||
88 | +@media(max-width:991px) { | ||
89 | + .customer-img, | ||
90 | + .img-related { | ||
91 | + margin-bottom: 30px; | ||
92 | + } | ||
93 | +} | ||
94 | + | ||
95 | +@media(max-width:767px) { | ||
96 | + .img-addon { | ||
97 | + margin-bottom: 15px; | ||
98 | + } | ||
99 | + | ||
100 | + header.carousel .carousel { | ||
101 | + height: 70%; | ||
102 | + } | ||
103 | +} | ||
104 | +.carousel-body { | ||
105 | + position:absolute; | ||
106 | + width: 100%; | ||
107 | + top:25%; | ||
108 | + text-align:center; | ||
109 | + color:#fff; | ||
110 | +} | ||
111 | + | ||
112 | +.addonlist a > p{ | ||
113 | + margin-bottom:15px; | ||
114 | +} |
addons/example/assets/js/async.js
0 → 100644
1 | +/** @license | ||
2 | + * RequireJS plugin for async dependency load like JSONP and Google Maps | ||
3 | + * Author: Miller Medeiros | ||
4 | + * Version: 0.1.2 (2014/02/24) | ||
5 | + * Released under the MIT license | ||
6 | + */ | ||
7 | +define(function(){ | ||
8 | + | ||
9 | + var DEFAULT_PARAM_NAME = 'callback', | ||
10 | + _uid = 0; | ||
11 | + | ||
12 | + function injectScript(src){ | ||
13 | + var s, t; | ||
14 | + s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = src; | ||
15 | + t = document.getElementsByTagName('script')[0]; t.parentNode.insertBefore(s,t); | ||
16 | + } | ||
17 | + | ||
18 | + function formatUrl(name, id){ | ||
19 | + var paramRegex = /!(.+)/, | ||
20 | + url = name.replace(paramRegex, ''), | ||
21 | + param = (paramRegex.test(name))? name.replace(/.+!/, '') : DEFAULT_PARAM_NAME; | ||
22 | + url += (url.indexOf('?') < 0)? '?' : '&'; | ||
23 | + return url + param +'='+ id; | ||
24 | + } | ||
25 | + | ||
26 | + function uid() { | ||
27 | + _uid += 1; | ||
28 | + return '__async_req_'+ _uid +'__'; | ||
29 | + } | ||
30 | + | ||
31 | + return{ | ||
32 | + load : function(name, req, onLoad, config){ | ||
33 | + if(config.isBuild){ | ||
34 | + onLoad(null); //avoid errors on the optimizer | ||
35 | + }else{ | ||
36 | + var id = uid(); | ||
37 | + //create a global variable that stores onLoad so callback | ||
38 | + //function can define new module after async load | ||
39 | + window[id] = onLoad; | ||
40 | + injectScript(formatUrl(req.toUrl(name), id)); | ||
41 | + } | ||
42 | + } | ||
43 | + }; | ||
44 | +}); |
addons/example/bootstrap.js
0 → 100644
addons/example/config.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +return [ | ||
4 | + [ | ||
5 | + 'name' => 'title', | ||
6 | + 'title' => '标题', | ||
7 | + 'type' => 'string', | ||
8 | + 'content' => [ | ||
9 | + ], | ||
10 | + 'value' => '示例标题', | ||
11 | + 'rule' => 'required', | ||
12 | + 'msg' => '', | ||
13 | + 'tip' => '', | ||
14 | + 'ok' => '', | ||
15 | + 'extend' => '' | ||
16 | + ], | ||
17 | + [ | ||
18 | + //配置唯一标识 | ||
19 | + 'name' => 'theme', | ||
20 | + //显示的标题 | ||
21 | + 'title' => '皮肤', | ||
22 | + //类型 | ||
23 | + 'type' => 'string', | ||
24 | + //数据字典 | ||
25 | + 'content' => [ | ||
26 | + ], | ||
27 | + //值 | ||
28 | + 'value' => 'default', | ||
29 | + //验证规则 | ||
30 | + 'rule' => 'required', | ||
31 | + //错误消息 | ||
32 | + 'msg' => '', | ||
33 | + //提示消息 | ||
34 | + 'tip' => '', | ||
35 | + //成功消息 | ||
36 | + 'ok' => '', | ||
37 | + //扩展信息 | ||
38 | + 'extend' => '' | ||
39 | + ], | ||
40 | + [ | ||
41 | + 'name' => 'domain', | ||
42 | + 'title' => '绑定二级域名前缀', | ||
43 | + 'type' => 'string', | ||
44 | + 'content' => [ | ||
45 | + ], | ||
46 | + 'value' => '', | ||
47 | + 'rule' => '', | ||
48 | + 'msg' => '', | ||
49 | + 'tip' => '', | ||
50 | + 'ok' => '', | ||
51 | + 'extend' => '' | ||
52 | + ], | ||
53 | + [ | ||
54 | + 'name' => 'rewrite', | ||
55 | + 'title' => '伪静态', | ||
56 | + 'type' => 'array', | ||
57 | + 'content' => [], | ||
58 | + 'value' => [ | ||
59 | + 'index/index' => '/example$', | ||
60 | + 'demo/index' => '/example/d/[:name]', | ||
61 | + 'demo/demo1' => '/example/d1/[:name]', | ||
62 | + 'demo/demo2' => '/example/d2/[:name]', | ||
63 | + ], | ||
64 | + 'rule' => 'required', | ||
65 | + 'msg' => '', | ||
66 | + 'tip' => '', | ||
67 | + 'ok' => '', | ||
68 | + 'extend' => '' | ||
69 | + ], | ||
70 | +]; |
addons/example/controller/Demo.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace addons\example\controller; | ||
4 | + | ||
5 | +use think\addons\Controller; | ||
6 | + | ||
7 | +/** | ||
8 | + * 测试控制器 | ||
9 | + */ | ||
10 | +class Demo extends Controller | ||
11 | +{ | ||
12 | + | ||
13 | + protected $layout = 'default'; | ||
14 | + protected $noNeedLogin = ['index', 'demo1']; | ||
15 | + protected $noNeedRight = ['*']; | ||
16 | + | ||
17 | + public function index() | ||
18 | + { | ||
19 | + return $this->view->fetch(); | ||
20 | + } | ||
21 | + | ||
22 | + public function demo1() | ||
23 | + { | ||
24 | + return $this->view->fetch(); | ||
25 | + } | ||
26 | + | ||
27 | + public function demo2() | ||
28 | + { | ||
29 | + return $this->view->fetch(); | ||
30 | + } | ||
31 | + | ||
32 | +} |
addons/example/controller/Index.php
0 → 100644
addons/example/info.ini
0 → 100644
addons/example/install.sql
0 → 100644
此 diff 太大无法显示。
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + var Controller = { | ||
3 | + index: function () { | ||
4 | + // | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/baidumap/index', | ||
9 | + add_url: 'example/baidumap/add', | ||
10 | + edit_url: 'example/baidumap/edit', | ||
11 | + del_url: 'example/baidumap/del', | ||
12 | + multi_url: 'example/baidumap/multi', | ||
13 | + table: '', | ||
14 | + } | ||
15 | + }); | ||
16 | + | ||
17 | + var table = $("#table"); | ||
18 | + | ||
19 | + // 初始化表格 | ||
20 | + table.bootstrapTable({ | ||
21 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
22 | + pk: 'id', | ||
23 | + sortName: 'id', | ||
24 | + columns: [ | ||
25 | + [ | ||
26 | + {checkbox: true}, | ||
27 | + {field: 'id', title: 'ID', operate: false}, | ||
28 | + {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, | ||
29 | + {field: 'username', title: __('Username'), formatter: Table.api.formatter.search}, | ||
30 | + {field: 'title', title: __('Title')}, | ||
31 | + {field: 'url', title: __('Url'), align: 'left'}, | ||
32 | + {field: 'ip', title: __('IP')}, | ||
33 | + {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
34 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
35 | + ] | ||
36 | + ] | ||
37 | + }); | ||
38 | + | ||
39 | + // 为表格绑定事件 | ||
40 | + Table.api.bindevent(table); | ||
41 | + }, | ||
42 | + add: function () { | ||
43 | + Controller.api.bindevent(); | ||
44 | + }, | ||
45 | + edit: function () { | ||
46 | + Controller.api.bindevent(); | ||
47 | + }, | ||
48 | + map: function () { | ||
49 | + Form.api.bindevent($("form[role=form]")); | ||
50 | + require(['async!BMap'], function () { | ||
51 | + // 更多文档可参考 http://lbsyun.baidu.com/jsdemo.htm | ||
52 | + // 百度地图API功能 | ||
53 | + var map = new BMap.Map("allmap"); | ||
54 | + var point = new BMap.Point(116.404, 39.915); | ||
55 | + | ||
56 | + map.centerAndZoom(point, 13); //设置中心坐标点和级别 | ||
57 | + var marker = new BMap.Marker(point); // 创建标注 | ||
58 | + map.addOverlay(marker); // 将标注添加到地图中 | ||
59 | + marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画 | ||
60 | + | ||
61 | + map.enableDragging(); //开启拖拽 | ||
62 | + //map.enableInertialDragging(); //开启惯性拖拽 | ||
63 | + map.enableScrollWheelZoom(true); //是否允许缩放 | ||
64 | + //map.centerAndZoom("上海",15); //根据城市名设定地图中心点 | ||
65 | + | ||
66 | + var geolocation = new BMap.Geolocation(); | ||
67 | + geolocation.getCurrentPosition(function (r) { | ||
68 | + if (this.getStatus() == BMAP_STATUS_SUCCESS) { | ||
69 | + var mk = new BMap.Marker(r.point); | ||
70 | + map.addOverlay(mk); | ||
71 | + map.panTo(r.point); | ||
72 | + //Layer.alert('您的位置:' + r.point.lng + ',' + r.point.lat); | ||
73 | + } else { | ||
74 | + Layer.alert('failed' + this.getStatus()); | ||
75 | + } | ||
76 | + }, {enableHighAccuracy: true}); | ||
77 | + | ||
78 | + // 点搜索按钮时解析地址坐标 | ||
79 | + $(document).on('click', '.btn-search', function () { | ||
80 | + // 创建地址解析器实例 | ||
81 | + var myGeo = new BMap.Geocoder(); | ||
82 | + // 将地址解析结果显示在地图上,并调整地图视野 | ||
83 | + myGeo.getPoint($("#searchaddress").val(), function (point) { | ||
84 | + if (point) { | ||
85 | + map.centerAndZoom(point, 16); | ||
86 | + map.addOverlay(new BMap.Marker(point)); | ||
87 | + } else { | ||
88 | + Layer.alert("您选择地址没有解析到结果!"); | ||
89 | + } | ||
90 | + }); | ||
91 | + }); | ||
92 | + | ||
93 | + }); | ||
94 | + }, | ||
95 | + api: { | ||
96 | + bindevent: function () { | ||
97 | + Form.api.bindevent($("form[role=form]")); | ||
98 | + } | ||
99 | + } | ||
100 | + }; | ||
101 | + return Controller; | ||
102 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/bootstraptable/index', | ||
9 | + add_url: '', | ||
10 | + edit_url: '', | ||
11 | + del_url: 'example/bootstraptable/del', | ||
12 | + multi_url: '', | ||
13 | + } | ||
14 | + }); | ||
15 | + | ||
16 | + var table = $("#table"); | ||
17 | + | ||
18 | + //在普通搜索提交搜索前 | ||
19 | + table.on('common-search.bs.table', function (event, table, query) { | ||
20 | + //这里可以获取到普通搜索表单中字段的查询条件 | ||
21 | + console.log(query); | ||
22 | + }); | ||
23 | + | ||
24 | + //在普通搜索渲染后 | ||
25 | + table.on('post-common-search.bs.table', function (event, table) { | ||
26 | + var form = $("form", table.$commonsearch); | ||
27 | + $("input[name='title']", form).addClass("selectpage").data("source", "auth/adminlog/selectpage").data("primaryKey", "title").data("field", "title").data("orderBy", "id desc"); | ||
28 | + $("input[name='username']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "username").data("field", "username").data("orderBy", "id desc"); | ||
29 | + Form.events.cxselect(form); | ||
30 | + Form.events.selectpage(form); | ||
31 | + }); | ||
32 | + | ||
33 | + //在表格内容渲染完成后回调的事件 | ||
34 | + table.on('post-body.bs.table', function (e, settings, json, xhr) { | ||
35 | + console.log(e, settings, json, xhr); | ||
36 | + }); | ||
37 | + | ||
38 | + //当表格数据加载完成时 | ||
39 | + table.on('load-success.bs.table', function (e, data) { | ||
40 | + //这里可以获取从服务端获取的JSON数据 | ||
41 | + console.log(data); | ||
42 | + //这里我们手动设置底部的值 | ||
43 | + $("#money").text(data.extend.money); | ||
44 | + $("#price").text(data.extend.price); | ||
45 | + }); | ||
46 | + | ||
47 | + // 初始化表格 | ||
48 | + // 这里使用的是Bootstrap-table插件渲染表格 | ||
49 | + // 相关文档:https://doc.fastadmin.net/doc/table.html | ||
50 | + table.bootstrapTable({ | ||
51 | + //表格参数可以参考:https://doc.fastadmin.net/doc/190.html | ||
52 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
53 | + columns: [ | ||
54 | + [ | ||
55 | + //更多列参数可以参考:https://doc.fastadmin.net/doc/191.html | ||
56 | + //该列为复选框字段,如果后台的返回state值将会默认选中 | ||
57 | + {field: 'state', checkbox: true,}, | ||
58 | + //sortable为是否排序,operate为搜索时的操作符,visible表示是否可见 | ||
59 | + {field: 'id', title: 'ID', sortable: true, operate: false}, | ||
60 | + //默认隐藏该列 | ||
61 | + {field: 'admin_id', title: __('管理员'), operate: false}, | ||
62 | + //直接响应搜索 | ||
63 | + {field: 'username', title: __('管理员'), formatter: Table.api.formatter.search}, | ||
64 | + //模糊搜索 | ||
65 | + {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'}, | ||
66 | + //通过Ajax渲染searchList,也可以使用JSON数据 | ||
67 | + { | ||
68 | + field: 'url', | ||
69 | + title: __('Url'), | ||
70 | + align: 'left', | ||
71 | + searchList: $.getJSON('example/bootstraptable/searchlist?search=a&field=row[user_id]'), | ||
72 | + formatter: Controller.api.formatter.url | ||
73 | + }, | ||
74 | + //点击IP时同时执行搜索此IP | ||
75 | + { | ||
76 | + field: 'ip', | ||
77 | + title: __('IP'), | ||
78 | + events: Controller.api.events.ip, | ||
79 | + formatter: Controller.api.formatter.ip | ||
80 | + }, | ||
81 | + //自定义栏位,custom是不存在的字段 | ||
82 | + {field: 'custom', title: __('切换'), operate: false, formatter: Controller.api.formatter.custom}, | ||
83 | + //browser是一个不存在的字段 | ||
84 | + //通过formatter来渲染数据,同时为它添加上事件 | ||
85 | + { | ||
86 | + field: 'browser', | ||
87 | + title: __('Browser'), | ||
88 | + operate: false, | ||
89 | + events: Controller.api.events.browser, | ||
90 | + formatter: Controller.api.formatter.browser | ||
91 | + }, | ||
92 | + { | ||
93 | + field: 'admin_id', title: __('联动搜索'), searchList: function (column) { | ||
94 | + return Template('categorytpl', {}); | ||
95 | + }, formatter: function (value, row, index) { | ||
96 | + return '无'; | ||
97 | + }, visible: false | ||
98 | + }, | ||
99 | + //启用时间段搜索 | ||
100 | + { | ||
101 | + field: 'createtime', | ||
102 | + title: __('Update time'), | ||
103 | + sortable: true, | ||
104 | + formatter: Table.api.formatter.datetime, | ||
105 | + operate: 'RANGE', | ||
106 | + addclass: 'datetimerange' | ||
107 | + }, | ||
108 | + //操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮 | ||
109 | + { | ||
110 | + field: 'operate', | ||
111 | + width: "150px", | ||
112 | + title: __('Operate'), | ||
113 | + table: table, | ||
114 | + events: Table.api.events.operate, | ||
115 | + buttons: [ | ||
116 | + { | ||
117 | + name: 'click', | ||
118 | + title: __('点击执行事件'), | ||
119 | + classname: 'btn btn-xs btn-info btn-click', | ||
120 | + icon: 'fa fa-leaf', | ||
121 | + // dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示 | ||
122 | + click: function (data) { | ||
123 | + Layer.alert("点击按钮执行的事件"); | ||
124 | + } | ||
125 | + }, | ||
126 | + { | ||
127 | + name: 'detail', | ||
128 | + title: __('弹出窗口打开'), | ||
129 | + classname: 'btn btn-xs btn-primary btn-dialog', | ||
130 | + icon: 'fa fa-list', | ||
131 | + url: 'example/bootstraptable/detail', | ||
132 | + callback: function (data) { | ||
133 | + Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); | ||
134 | + } | ||
135 | + }, | ||
136 | + { | ||
137 | + name: 'ajax', | ||
138 | + title: __('发送Ajax'), | ||
139 | + classname: 'btn btn-xs btn-success btn-magic btn-ajax', | ||
140 | + icon: 'fa fa-magic', | ||
141 | + confirm: '确认发送Ajax请求?', | ||
142 | + url: 'example/bootstraptable/detail', | ||
143 | + success: function (data, ret) { | ||
144 | + Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data)); | ||
145 | + //如果需要阻止成功提示,则必须使用return false; | ||
146 | + //return false; | ||
147 | + }, | ||
148 | + error: function (data, ret) { | ||
149 | + console.log(data, ret); | ||
150 | + Layer.alert(ret.msg); | ||
151 | + return false; | ||
152 | + } | ||
153 | + }, | ||
154 | + { | ||
155 | + name: 'addtabs', | ||
156 | + title: __('新选项卡中打开'), | ||
157 | + classname: 'btn btn-xs btn-warning btn-addtabs', | ||
158 | + icon: 'fa fa-folder-o', | ||
159 | + url: 'example/bootstraptable/detail' | ||
160 | + } | ||
161 | + ], | ||
162 | + formatter: Table.api.formatter.operate | ||
163 | + }, | ||
164 | + ], | ||
165 | + ], | ||
166 | + //更多配置参数可参考:https://doc.fastadmin.net/doc/190.html | ||
167 | + //亦可以参考require-table.js中defaults的配置 | ||
168 | + //快捷搜索,这里可在控制器定义快捷搜索的字段 | ||
169 | + search: true, | ||
170 | + //启用普通表单搜索 | ||
171 | + commonSearch: true, | ||
172 | + //显示导出按钮 | ||
173 | + showExport: true, | ||
174 | + //导出类型 | ||
175 | + exportDataType: "all", //共有basic, all, selected三种值 basic当前页 all全部 selected仅选中 | ||
176 | + //导出下拉列表选项 | ||
177 | + exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'], | ||
178 | + //可以控制是否默认显示搜索单表,false则隐藏,默认为false | ||
179 | + searchFormVisible: true, | ||
180 | + queryParams: function (params) { | ||
181 | + //这里可以追加搜索条件 | ||
182 | + var filter = JSON.parse(params.filter); | ||
183 | + var op = JSON.parse(params.op); | ||
184 | + //这里可以动态赋值,比如从URL中获取admin_id的值,filter.admin_id=Fast.api.query('admin_id'); | ||
185 | + filter.admin_id = 1; | ||
186 | + op.admin_id = "="; | ||
187 | + params.filter = JSON.stringify(filter); | ||
188 | + params.op = JSON.stringify(op); | ||
189 | + return params; | ||
190 | + }, | ||
191 | + }); | ||
192 | + | ||
193 | + // 为表格绑定事件 | ||
194 | + Table.api.bindevent(table); | ||
195 | + | ||
196 | + // 监听下拉列表改变的事件 | ||
197 | + $(document).on('change', 'select[name=admin]', function () { | ||
198 | + $("input[name='admin_id']").val($(this).val()); | ||
199 | + }); | ||
200 | + | ||
201 | + // 指定搜索条件 | ||
202 | + $(document).on("click", ".btn-singlesearch", function () { | ||
203 | + var options = table.bootstrapTable('getOptions'); | ||
204 | + var queryParams = options.queryParams; | ||
205 | + options.pageNumber = 1; | ||
206 | + options.queryParams = function (params) { | ||
207 | + //这一行必须要存在,否则在点击下一页时会丢失搜索栏数据 | ||
208 | + params = queryParams(params); | ||
209 | + | ||
210 | + //如果希望追加搜索条件,可使用 | ||
211 | + var filter = params.filter ? JSON.parse(params.filter) : {}; | ||
212 | + var op = params.op ? JSON.parse(params.op) : {}; | ||
213 | + filter.url = 'login'; | ||
214 | + op.url = 'like'; | ||
215 | + params.filter = JSON.stringify(filter); | ||
216 | + params.op = JSON.stringify(op); | ||
217 | + | ||
218 | + //如果希望忽略搜索栏搜索条件,可使用 | ||
219 | + //params.filter = JSON.stringify({url: 'login'}); | ||
220 | + //params.op = JSON.stringify({url: 'like'}); | ||
221 | + return params; | ||
222 | + }; | ||
223 | + table.bootstrapTable('refresh', {}); | ||
224 | + Toastr.info("当前执行的是自定义搜索,搜索URL中包含login的数据"); | ||
225 | + return false; | ||
226 | + }); | ||
227 | + | ||
228 | + // 获取选中项 | ||
229 | + $(document).on("click", ".btn-selected", function () { | ||
230 | + Layer.alert(JSON.stringify(table.bootstrapTable('getSelections'))); | ||
231 | + }); | ||
232 | + | ||
233 | + // 启动和暂停按钮 | ||
234 | + $(document).on("click", ".btn-start,.btn-pause", function () { | ||
235 | + //在table外不可以使用添加.btn-change的方法 | ||
236 | + //只能自己调用Table.api.multi实现 | ||
237 | + //如果操作全部则ids可以置为空 | ||
238 | + var ids = Table.api.selectedids(table); | ||
239 | + Table.api.multi("changestatus", ids.join(","), table, this); | ||
240 | + }); | ||
241 | + | ||
242 | + }, | ||
243 | + add: function () { | ||
244 | + Controller.api.bindevent(); | ||
245 | + }, | ||
246 | + edit: function () { | ||
247 | + Controller.api.bindevent(); | ||
248 | + }, | ||
249 | + detail: function () { | ||
250 | + $(document).on('click', '.btn-callback', function () { | ||
251 | + Fast.api.close($("input[name=callback]").val()); | ||
252 | + }); | ||
253 | + }, | ||
254 | + api: { | ||
255 | + bindevent: function () { | ||
256 | + Form.api.bindevent($("form[role=form]")); | ||
257 | + }, | ||
258 | + formatter: {//渲染的方法 | ||
259 | + url: function (value, row, index) { | ||
260 | + return '<div class="input-group input-group-sm" style="width:250px;"><input type="text" class="form-control input-sm" value="' + value + '"><span class="input-group-btn input-group-sm"><a href="' + value + '" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a></span></div>'; | ||
261 | + }, | ||
262 | + ip: function (value, row, index) { | ||
263 | + return '<a class="btn btn-xs btn-ip bg-success"><i class="fa fa-map-marker"></i> ' + value + '</a>'; | ||
264 | + }, | ||
265 | + browser: function (value, row, index) { | ||
266 | + //这里我们直接使用row的数据 | ||
267 | + return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>'; | ||
268 | + }, | ||
269 | + custom: function (value, row, index) { | ||
270 | + //添加上btn-change可以自定义请求的URL进行数据处理 | ||
271 | + return '<a class="btn-change text-success" data-url="example/bootstraptable/change" data-id="' + row.id + '"><i class="fa ' + (row.title == '' ? 'fa-toggle-on fa-flip-horizontal text-gray' : 'fa-toggle-on') + ' fa-2x"></i></a>'; | ||
272 | + }, | ||
273 | + }, | ||
274 | + events: {//绑定事件的方法 | ||
275 | + ip: { | ||
276 | + //格式为:方法名+空格+DOM元素 | ||
277 | + 'click .btn-ip': function (e, value, row, index) { | ||
278 | + e.stopPropagation(); | ||
279 | + var container = $("#table").data("bootstrap.table").$container; | ||
280 | + var options = $("#table").bootstrapTable('getOptions'); | ||
281 | + //这里我们手动将数据填充到表单然后提交 | ||
282 | + $("form.form-commonsearch [name='ip']", container).val(value); | ||
283 | + $("form.form-commonsearch", container).trigger('submit'); | ||
284 | + Toastr.info("执行了自定义搜索操作"); | ||
285 | + } | ||
286 | + }, | ||
287 | + browser: { | ||
288 | + 'click .btn-browser': function (e, value, row, index) { | ||
289 | + e.stopPropagation(); | ||
290 | + Layer.alert("该行数据为: <code>" + JSON.stringify(row) + "</code>"); | ||
291 | + } | ||
292 | + }, | ||
293 | + } | ||
294 | + } | ||
295 | + }; | ||
296 | + return Controller; | ||
297 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/colorbadge/index', | ||
9 | + add_url: '', | ||
10 | + edit_url: '', | ||
11 | + del_url: 'example/colorbadge/del', | ||
12 | + multi_url: '', | ||
13 | + } | ||
14 | + }); | ||
15 | + | ||
16 | + var table = $("#table"); | ||
17 | + | ||
18 | + // 初始化表格 | ||
19 | + table.bootstrapTable({ | ||
20 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
21 | + columns: [ | ||
22 | + [ | ||
23 | + {field: 'state', checkbox: true, }, | ||
24 | + {field: 'id', title: 'ID'}, | ||
25 | + {field: 'title', title: __('Title')}, | ||
26 | + {field: 'ip', title: __('IP')}, | ||
27 | + {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
28 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
29 | + ] | ||
30 | + ], | ||
31 | + onLoadSuccess: function (data) { | ||
32 | + // 在表格第次加载成功后,刷新左侧菜单栏彩色小角标,支持一次渲染多个 | ||
33 | + // 如果需要在进入后台即显示左侧的彩色小角标,请使用服务端渲染方式,详情修改application/admin/controller/Index.php | ||
34 | + Backend.api.sidebar({ | ||
35 | + 'example/colorbadge': data.total | ||
36 | + }); | ||
37 | + Toastr.info("左侧角标已经刷新成功"); | ||
38 | + } | ||
39 | + }); | ||
40 | + | ||
41 | + // 为表格绑定事件 | ||
42 | + Table.api.bindevent(table); | ||
43 | + }, | ||
44 | + add: function () { | ||
45 | + Form.api.bindevent($("form[role=form]")); | ||
46 | + }, | ||
47 | + edit: function () { | ||
48 | + Form.api.bindevent($("form[role=form]")); | ||
49 | + } | ||
50 | + }; | ||
51 | + return Controller; | ||
52 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/controllerjump/index', | ||
9 | + add_url: '', | ||
10 | + edit_url: '', | ||
11 | + del_url: 'example/controllerjump/del', | ||
12 | + multi_url: '', | ||
13 | + } | ||
14 | + }); | ||
15 | + | ||
16 | + var table = $("#table"); | ||
17 | + | ||
18 | + // 初始化表格 | ||
19 | + table.bootstrapTable({ | ||
20 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
21 | + columns: [ | ||
22 | + [ | ||
23 | + {field: 'state', checkbox: true, }, | ||
24 | + {field: 'id', title: 'ID'}, | ||
25 | + {field: 'admin_id', title: __('Admin_id')}, | ||
26 | + {field: 'title', title: __('Title')}, | ||
27 | + {field: 'ip', title: __('IP'), formatter: Controller.api.formatter.ip}, | ||
28 | + {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
29 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
30 | + ] | ||
31 | + ] | ||
32 | + }); | ||
33 | + | ||
34 | + // 为表格绑定事件 | ||
35 | + Table.api.bindevent(table); | ||
36 | + }, | ||
37 | + add: function () { | ||
38 | + Form.api.bindevent($("form[role=form]")); | ||
39 | + }, | ||
40 | + edit: function () { | ||
41 | + Form.api.bindevent($("form[role=form]")); | ||
42 | + }, | ||
43 | + api: { | ||
44 | + formatter: { | ||
45 | + ip: function (value, row, index) { | ||
46 | + //这里手动构造URL | ||
47 | + url = "example/bootstraptable?" + this.field + "=" + value; | ||
48 | + | ||
49 | + //方式一,直接返回class带有addtabsit的链接,这可以方便自定义显示内容 | ||
50 | + return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __('Search %s', value) + '</a>'; | ||
51 | + | ||
52 | + //方式二,直接调用Table.api.formatter.addtabs | ||
53 | + return Table.api.formatter.addtabs(value, row, index, url); | ||
54 | + } | ||
55 | + } | ||
56 | + } | ||
57 | + }; | ||
58 | + return Controller; | ||
59 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + //因为日期选择框不会触发change事件,导致无法刷新textarea,所以加上判断 | ||
6 | + $(document).on("dp.change", "#second-form .datetimepicker", function () { | ||
7 | + $(this).parent().prev().find("input").trigger("change"); | ||
8 | + }); | ||
9 | + $(document).on("fa.event.appendfieldlist", "#second-form .btn-append", function (e, obj) { | ||
10 | + Form.events.selectpage(obj); | ||
11 | + Form.events.datetimepicker(obj); | ||
12 | + }); | ||
13 | + Form.api.bindevent($("form[role=form]"), function (data, ret) { | ||
14 | + Layer.alert(data.data); | ||
15 | + }); | ||
16 | + }, | ||
17 | + }; | ||
18 | + return Controller; | ||
19 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + var Controller = { | ||
3 | + index: function () { | ||
4 | + // | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/customsearch/index', | ||
9 | + add_url: 'example/customsearch/add', | ||
10 | + edit_url: 'example/customsearch/edit', | ||
11 | + del_url: 'example/customsearch/del', | ||
12 | + multi_url: 'example/customsearch/multi', | ||
13 | + table: '', | ||
14 | + } | ||
15 | + }); | ||
16 | + | ||
17 | + var table = $("#table"); | ||
18 | + | ||
19 | + // 初始化表格 | ||
20 | + table.bootstrapTable({ | ||
21 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
22 | + pk: 'id', | ||
23 | + sortName: 'id', | ||
24 | + searchFormVisible: true, | ||
25 | + searchFormTemplate: 'customformtpl', | ||
26 | + columns: [ | ||
27 | + [ | ||
28 | + {checkbox: true}, | ||
29 | + {field: 'id', title: 'ID', operate: false}, | ||
30 | + {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, | ||
31 | + {field: 'username', title: __('Username'), formatter: Table.api.formatter.search}, | ||
32 | + {field: 'title', title: __('Title')}, | ||
33 | + {field: 'url', title: __('Url'), align: 'left'}, | ||
34 | + {field: 'ip', title: __('IP')}, | ||
35 | + {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
36 | + { | ||
37 | + field: 'operate', | ||
38 | + title: __('Operate'), | ||
39 | + table: table, | ||
40 | + events: Table.api.events.operate, | ||
41 | + formatter: Table.api.formatter.operate | ||
42 | + } | ||
43 | + ] | ||
44 | + ] | ||
45 | + }); | ||
46 | + | ||
47 | + // 为表格绑定事件 | ||
48 | + Table.api.bindevent(table); | ||
49 | + }, | ||
50 | + add: function () { | ||
51 | + Controller.api.bindevent(); | ||
52 | + }, | ||
53 | + edit: function () { | ||
54 | + Controller.api.bindevent(); | ||
55 | + }, | ||
56 | + api: { | ||
57 | + bindevent: function () { | ||
58 | + Form.api.bindevent($("form[role=form]")); | ||
59 | + } | ||
60 | + } | ||
61 | + }; | ||
62 | + return Controller; | ||
63 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + $("#cxselect-example .col-xs-12").each(function () { | ||
6 | + $("textarea", this).val($(this).prev().prev().html().replace(/[ ]{2}/g, '')); | ||
7 | + }); | ||
8 | + | ||
9 | + //这里需要手动为Form绑定上元素事件 | ||
10 | + Form.api.bindevent($("form#cxselectform")); | ||
11 | + } | ||
12 | + }; | ||
13 | + return Controller; | ||
14 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'echarts', 'echarts-theme'], function ($, undefined, Backend, Table, Form, Template, Echarts) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + console.log(Echarts.version); | ||
6 | + //这句话在多选项卡统计表时必须存在,否则会导致影响的图表宽度不正确 | ||
7 | + $(document).on("click", ".charts-custom a[data-toggle=\"tab\"]", function () { | ||
8 | + var that = this; | ||
9 | + setTimeout(function () { | ||
10 | + var id = $(that).attr("href"); | ||
11 | + var chart = Echarts.getInstanceByDom($(id)[0]); | ||
12 | + chart.resize(); | ||
13 | + }, 0); | ||
14 | + }); | ||
15 | + | ||
16 | + // 基于准备好的dom,初始化echarts实例 | ||
17 | + var lineChart = Echarts.init(document.getElementById('line-chart'), 'walden'); | ||
18 | + | ||
19 | + // 指定图表的配置项和数据 | ||
20 | + var option = { | ||
21 | + xAxis: { | ||
22 | + type: 'category', | ||
23 | + data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] | ||
24 | + }, | ||
25 | + yAxis: { | ||
26 | + type: 'value' | ||
27 | + }, | ||
28 | + series: [{ | ||
29 | + data: [49, 92, 61, 134, 90, 130, 120], | ||
30 | + type: 'line' | ||
31 | + }] | ||
32 | + }; | ||
33 | + | ||
34 | + // 使用刚指定的配置项和数据显示图表。 | ||
35 | + lineChart.setOption(option); | ||
36 | + // 基于准备好的dom,初始化echarts实例 | ||
37 | + var areaChart = Echarts.init(document.getElementById('area-chart'), 'walden'); | ||
38 | + | ||
39 | + // 指定图表的配置项和数据 | ||
40 | + var option = { | ||
41 | + xAxis: { | ||
42 | + type: 'category', | ||
43 | + boundaryGap: false, | ||
44 | + data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] | ||
45 | + }, | ||
46 | + yAxis: { | ||
47 | + type: 'value' | ||
48 | + }, | ||
49 | + series: [{ | ||
50 | + data: [820, 932, 901, 934, 1290, 1330, 1320], | ||
51 | + type: 'line', | ||
52 | + areaStyle: {} | ||
53 | + }] | ||
54 | + }; | ||
55 | + | ||
56 | + // 使用刚指定的配置项和数据显示图表。 | ||
57 | + areaChart.setOption(option); | ||
58 | + | ||
59 | + var pieChart = Echarts.init(document.getElementById('pie-chart'), 'walden'); | ||
60 | + var option = { | ||
61 | + tooltip: { | ||
62 | + trigger: 'item', | ||
63 | + formatter: '{a} <br/>{b}: {c} ({d}%)' | ||
64 | + }, | ||
65 | + legend: { | ||
66 | + orient: 'vertical', | ||
67 | + left: 10, | ||
68 | + data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'] | ||
69 | + }, | ||
70 | + series: [ | ||
71 | + { | ||
72 | + name: '访问来源', | ||
73 | + type: 'pie', | ||
74 | + radius: ['50%', '70%'], | ||
75 | + avoidLabelOverlap: false, | ||
76 | + label: { | ||
77 | + normal: { | ||
78 | + show: false, | ||
79 | + position: 'center' | ||
80 | + }, | ||
81 | + emphasis: { | ||
82 | + show: true, | ||
83 | + textStyle: { | ||
84 | + fontSize: '30', | ||
85 | + fontWeight: 'bold' | ||
86 | + } | ||
87 | + } | ||
88 | + }, | ||
89 | + labelLine: { | ||
90 | + normal: { | ||
91 | + show: false | ||
92 | + } | ||
93 | + }, | ||
94 | + data: [ | ||
95 | + {value: 335, name: '直接访问'}, | ||
96 | + {value: 310, name: '邮件营销'}, | ||
97 | + {value: 234, name: '联盟广告'}, | ||
98 | + {value: 135, name: '视频广告'}, | ||
99 | + {value: 1548, name: '搜索引擎'} | ||
100 | + ] | ||
101 | + } | ||
102 | + ] | ||
103 | + }; | ||
104 | + // 使用刚指定的配置项和数据显示图表。 | ||
105 | + pieChart.setOption(option); | ||
106 | + | ||
107 | + var barChart = Echarts.init(document.getElementById('bar-chart'), 'walden'); | ||
108 | + option = { | ||
109 | + legend: {}, | ||
110 | + tooltip: {}, | ||
111 | + dataset: { | ||
112 | + source: [ | ||
113 | + ['产品销售', '2015', '2016', '2017'], | ||
114 | + ['风扇', 43.3, 85.8, 93.7], | ||
115 | + ['电视机', 83.1, 73.4, 55.1], | ||
116 | + ['空调', 86.4, 65.2, 82.5], | ||
117 | + ['冰箱', 72.4, 53.9, 39.1] | ||
118 | + ] | ||
119 | + }, | ||
120 | + xAxis: {type: 'category'}, | ||
121 | + yAxis: {}, | ||
122 | + // Declare several bar series, each will be mapped | ||
123 | + // to a column of dataset.source by default. | ||
124 | + series: [ | ||
125 | + {type: 'bar'}, | ||
126 | + {type: 'bar'}, | ||
127 | + {type: 'bar'} | ||
128 | + ] | ||
129 | + }; | ||
130 | + // 使用刚指定的配置项和数据显示图表。 | ||
131 | + barChart.setOption(option); | ||
132 | + | ||
133 | + | ||
134 | + var barChart = Echarts.init(document.getElementById('simplebar-chart')); | ||
135 | + option = { | ||
136 | + xAxis: { | ||
137 | + type: 'category', | ||
138 | + axisLine: { | ||
139 | + lineStyle: { | ||
140 | + color: "#fff" | ||
141 | + } | ||
142 | + }, | ||
143 | + data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] | ||
144 | + }, | ||
145 | + yAxis: { | ||
146 | + type: 'value', | ||
147 | + axisLine: { | ||
148 | + lineStyle: { | ||
149 | + color: "#fff" | ||
150 | + } | ||
151 | + } | ||
152 | + }, | ||
153 | + series: [{ | ||
154 | + data: [120, 200, 150, 80, 70, 110, 130], | ||
155 | + type: 'bar', | ||
156 | + itemStyle: { | ||
157 | + color: "#fff", | ||
158 | + opacity: 0.6 | ||
159 | + } | ||
160 | + }] | ||
161 | + }; | ||
162 | + // 使用刚指定的配置项和数据显示图表。 | ||
163 | + barChart.setOption(option); | ||
164 | + | ||
165 | + var barChart = Echarts.init(document.getElementById('smoothline-chart')); | ||
166 | + option = { | ||
167 | + textStyle: { | ||
168 | + color: "#fff" | ||
169 | + }, | ||
170 | + color: ['#fff'], | ||
171 | + xAxis: { | ||
172 | + type: 'category', | ||
173 | + boundaryGap: false, | ||
174 | + data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], | ||
175 | + axisLine: { | ||
176 | + lineStyle: { | ||
177 | + color: "#fff" | ||
178 | + } | ||
179 | + } | ||
180 | + }, | ||
181 | + yAxis: { | ||
182 | + type: 'value', | ||
183 | + splitLine: { | ||
184 | + show: false | ||
185 | + }, | ||
186 | + axisLine: { | ||
187 | + lineStyle: { | ||
188 | + color: "#fff" | ||
189 | + } | ||
190 | + } | ||
191 | + }, | ||
192 | + series: [{ | ||
193 | + data: [820, 932, 901, 934, 1290, 1330, 1320], | ||
194 | + type: 'line', | ||
195 | + smooth: true, | ||
196 | + areaStyle: { | ||
197 | + opacity: 0.4 | ||
198 | + } | ||
199 | + | ||
200 | + }] | ||
201 | + }; | ||
202 | + // 使用刚指定的配置项和数据显示图表。 | ||
203 | + barChart.setOption(option); | ||
204 | + } | ||
205 | + }; | ||
206 | + return Controller; | ||
207 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init(); | ||
7 | + | ||
8 | + //绑定事件 | ||
9 | + $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { | ||
10 | + var panel = $($(this).attr("href")); | ||
11 | + if (panel.size() > 0) { | ||
12 | + Controller.table[panel.attr("id")].call(this); | ||
13 | + $(this).on('click', function (e) { | ||
14 | + $($(this).attr("href")).find(".btn-refresh").trigger("click"); | ||
15 | + }); | ||
16 | + } | ||
17 | + //移除绑定的事件 | ||
18 | + $(this).unbind('shown.bs.tab'); | ||
19 | + }); | ||
20 | + | ||
21 | + //必须默认触发shown.bs.tab事件 | ||
22 | + $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab"); | ||
23 | + }, | ||
24 | + table: { | ||
25 | + first: function () { | ||
26 | + // 表格1 | ||
27 | + var table1 = $("#table1"); | ||
28 | + table1.bootstrapTable({ | ||
29 | + url: 'example/multitable/table1', | ||
30 | + toolbar: '#toolbar1', | ||
31 | + sortName: 'id', | ||
32 | + search: false, | ||
33 | + columns: [ | ||
34 | + [ | ||
35 | + {field: 'state', checkbox: true, }, | ||
36 | + {field: 'id', title: 'ID'}, | ||
37 | + {field: 'url', title: __('Url'), formatter: Table.api.formatter.url}, | ||
38 | + {field: 'imagewidth', title: __('Imagewidth')}, | ||
39 | + {field: 'imageheight', title: __('Imageheight')}, | ||
40 | + {field: 'mimetype', title: __('Mimetype')}, | ||
41 | + {field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
42 | + ] | ||
43 | + ] | ||
44 | + }); | ||
45 | + | ||
46 | + // 为表格1绑定事件 | ||
47 | + Table.api.bindevent(table1); | ||
48 | + }, | ||
49 | + second: function () { | ||
50 | + // 表格2 | ||
51 | + var table2 = $("#table2"); | ||
52 | + table2.bootstrapTable({ | ||
53 | + url: 'example/multitable/table2', | ||
54 | + extend: { | ||
55 | + index_url: '', | ||
56 | + add_url: '', | ||
57 | + edit_url: '', | ||
58 | + del_url: '', | ||
59 | + multi_url: '', | ||
60 | + table: '', | ||
61 | + }, | ||
62 | + toolbar: '#toolbar2', | ||
63 | + sortName: 'id', | ||
64 | + search: false, | ||
65 | + columns: [ | ||
66 | + [ | ||
67 | + {field: 'id', title: 'ID'}, | ||
68 | + {field: 'title', title: __('Title')}, | ||
69 | + {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url}, | ||
70 | + {field: 'ip', title: __('ip')}, | ||
71 | + {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
72 | + ] | ||
73 | + ] | ||
74 | + }); | ||
75 | + | ||
76 | + // 为表格2绑定事件 | ||
77 | + Table.api.bindevent(table2); | ||
78 | + } | ||
79 | + }, | ||
80 | + add: function () { | ||
81 | + Controller.api.bindevent(); | ||
82 | + }, | ||
83 | + edit: function () { | ||
84 | + Controller.api.bindevent(); | ||
85 | + }, | ||
86 | + api: { | ||
87 | + bindevent: function () { | ||
88 | + Form.api.bindevent($("form[role=form]")); | ||
89 | + }, | ||
90 | + } | ||
91 | + }; | ||
92 | + return Controller; | ||
93 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/relationmodel/index', | ||
9 | + add_url: '', | ||
10 | + edit_url: '', | ||
11 | + del_url: 'example/relationmodel/del', | ||
12 | + multi_url: '', | ||
13 | + } | ||
14 | + }); | ||
15 | + | ||
16 | + var table = $("#table"); | ||
17 | + | ||
18 | + // 初始化表格 | ||
19 | + table.bootstrapTable({ | ||
20 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
21 | + columns: [ | ||
22 | + [ | ||
23 | + {field: 'state', checkbox: true, }, | ||
24 | + {field: 'id', title: 'ID', operate: '='}, | ||
25 | + {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'}, | ||
26 | + {field: 'admin.avatar', title: __('Avatar'), operate: false, formatter: Table.api.formatter.image}, | ||
27 | + {field: 'admin.username', title: __('Username'), operate: '='}, | ||
28 | + {field: 'admin.nickname', title: __('Nickname'), operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'}, | ||
29 | + {field: 'ip', title: __('IP'), operate: '='}, | ||
30 | + {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
31 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
32 | + ] | ||
33 | + ], | ||
34 | + }); | ||
35 | + | ||
36 | + // 为表格绑定事件 | ||
37 | + Table.api.bindevent(table); | ||
38 | + }, | ||
39 | + add: function () { | ||
40 | + Form.api.bindevent($("form[role=form]")); | ||
41 | + }, | ||
42 | + edit: function () { | ||
43 | + Form.api.bindevent($("form[role=form]")); | ||
44 | + }, | ||
45 | + }; | ||
46 | + return Controller; | ||
47 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init(); | ||
7 | + this.table.first(); | ||
8 | + this.table.second(); | ||
9 | + }, | ||
10 | + table: { | ||
11 | + first: function () { | ||
12 | + // 表格1 | ||
13 | + var table1 = $("#table1"); | ||
14 | + table1.bootstrapTable({ | ||
15 | + url: 'example/tablelink/table1', | ||
16 | + toolbar: '#toolbar1', | ||
17 | + sortName: 'id', | ||
18 | + search: false, | ||
19 | + columns: [ | ||
20 | + [ | ||
21 | + {field: 'state', checkbox: true,}, | ||
22 | + {field: 'id', title: 'ID'}, | ||
23 | + {field: 'username', title: __('Nickname')}, | ||
24 | + { | ||
25 | + field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, buttons: [ | ||
26 | + { | ||
27 | + name: 'log', | ||
28 | + title: '日志列表', | ||
29 | + text: '日志列表', | ||
30 | + icon: 'fa fa-list', | ||
31 | + classname: 'btn btn-primary btn-xs btn-click', | ||
32 | + click: function (e, data) { | ||
33 | + $("#myTabContent2 .form-commonsearch input[name='username']").val(data.username); | ||
34 | + $("#myTabContent2 .btn-refresh").trigger("click"); | ||
35 | + } | ||
36 | + } | ||
37 | + ], formatter: Table.api.formatter.operate | ||
38 | + } | ||
39 | + ] | ||
40 | + ] | ||
41 | + }); | ||
42 | + | ||
43 | + // 为表格1绑定事件 | ||
44 | + Table.api.bindevent(table1); | ||
45 | + }, | ||
46 | + second: function () { | ||
47 | + // 表格2 | ||
48 | + var table2 = $("#table2"); | ||
49 | + table2.bootstrapTable({ | ||
50 | + url: 'example/tablelink/table2', | ||
51 | + extend: { | ||
52 | + index_url: '', | ||
53 | + add_url: '', | ||
54 | + edit_url: '', | ||
55 | + del_url: '', | ||
56 | + multi_url: '', | ||
57 | + table: '', | ||
58 | + }, | ||
59 | + toolbar: '#toolbar2', | ||
60 | + sortName: 'id', | ||
61 | + search: false, | ||
62 | + columns: [ | ||
63 | + [ | ||
64 | + {field: 'state', checkbox: true,}, | ||
65 | + {field: 'id', title: 'ID'}, | ||
66 | + {field: 'username', title: __('Nickname')}, | ||
67 | + {field: 'title', title: __('Title')}, | ||
68 | + {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url}, | ||
69 | + {field: 'ip', title: __('ip')}, | ||
70 | + {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
71 | + ] | ||
72 | + ] | ||
73 | + }); | ||
74 | + | ||
75 | + // 为表格2绑定事件 | ||
76 | + Table.api.bindevent(table2); | ||
77 | + } | ||
78 | + }, | ||
79 | + }; | ||
80 | + return Controller; | ||
81 | +}); |
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'example/tabletemplate/index', | ||
9 | + add_url: '', | ||
10 | + edit_url: '', | ||
11 | + del_url: 'example/tabletemplate/del', | ||
12 | + multi_url: '', | ||
13 | + } | ||
14 | + }); | ||
15 | + | ||
16 | + var table = $("#table"); | ||
17 | + | ||
18 | + Template.helper("Moment", Moment); | ||
19 | + | ||
20 | + // 初始化表格 | ||
21 | + table.bootstrapTable({ | ||
22 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
23 | + templateView: true, | ||
24 | + columns: [ | ||
25 | + [ | ||
26 | + {field: 'state', checkbox: true, }, | ||
27 | + {field: 'id', title: 'ID', operate: false}, | ||
28 | + //直接响应搜索 | ||
29 | + {field: 'username', title: __('Username'), formatter: Table.api.formatter.search}, | ||
30 | + //模糊搜索 | ||
31 | + {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符', style: 'width:200px'}, | ||
32 | + //通过Ajax渲染searchList | ||
33 | + {field: 'url', title: __('Url'), align: 'left', formatter: Controller.api.formatter.url}, | ||
34 | + //点击IP时同时执行搜索此IP,同时普通搜索使用下拉列表的形式 | ||
35 | + {field: 'ip', title: __('IP'), searchList: ['127.0.0.1', '127.0.0.2'], events: Controller.api.events.ip, formatter: Controller.api.formatter.ip}, | ||
36 | + //browser是一个不存在的字段 | ||
37 | + //通过formatter来渲染数据,同时为它添加上事件 | ||
38 | + {field: 'browser', title: __('Browser'), operate: false, events: Controller.api.events.browser, formatter: Controller.api.formatter.browser}, | ||
39 | + //启用时间段搜索 | ||
40 | + {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
41 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
42 | + ], | ||
43 | + ], | ||
44 | + //禁用默认搜索 | ||
45 | + search: false, | ||
46 | + //启用普通表单搜索 | ||
47 | + commonSearch: false, | ||
48 | + //可以控制是否默认显示搜索单表,false则隐藏,默认为false | ||
49 | + searchFormVisible: false, | ||
50 | + //分页大小 | ||
51 | + pageSize: 12 | ||
52 | + }); | ||
53 | + | ||
54 | + // 为表格绑定事件 | ||
55 | + Table.api.bindevent(table); | ||
56 | + | ||
57 | + //指定搜索条件 | ||
58 | + $(document).on("click", ".btn-toggle-view", function () { | ||
59 | + var options = table.bootstrapTable('getOptions'); | ||
60 | + table.bootstrapTable('refreshOptions', {templateView: !options.templateView}); | ||
61 | + }); | ||
62 | + | ||
63 | + //点击详情 | ||
64 | + $(document).on("click", ".btn-detail[data-id]", function () { | ||
65 | + Backend.api.open('example/bootstraptable/detail/ids/' + $(this).data('id'), __('Detail')); | ||
66 | + }); | ||
67 | + | ||
68 | + //获取选中项 | ||
69 | + $(document).on("click", ".btn-selected", function () { | ||
70 | + //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取 | ||
71 | + Layer.alert(JSON.stringify(Table.api.selectedids(table))); | ||
72 | + }); | ||
73 | + }, | ||
74 | + add: function () { | ||
75 | + Controller.api.bindevent(); | ||
76 | + }, | ||
77 | + edit: function () { | ||
78 | + Controller.api.bindevent(); | ||
79 | + }, | ||
80 | + api: { | ||
81 | + bindevent: function () { | ||
82 | + Form.api.bindevent($("form[role=form]")); | ||
83 | + }, | ||
84 | + formatter: { | ||
85 | + url: function (value, row, index) { | ||
86 | + return '<div class="input-group input-group-sm" style="width:250px;"><input type="text" class="form-control input-sm" value="' + value + '"><span class="input-group-btn input-group-sm"><a href="' + value + '" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a></span></div>'; | ||
87 | + }, | ||
88 | + ip: function (value, row, index) { | ||
89 | + return '<a class="btn btn-xs btn-ip bg-success"><i class="fa fa-map-marker"></i> ' + value + '</a>'; | ||
90 | + }, | ||
91 | + browser: function (value, row, index) { | ||
92 | + //这里我们直接使用row的数据 | ||
93 | + return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>'; | ||
94 | + } | ||
95 | + }, | ||
96 | + events: { | ||
97 | + ip: { | ||
98 | + 'click .btn-ip': function (e, value, row, index) { | ||
99 | + var options = $("#table").bootstrapTable('getOptions'); | ||
100 | + //这里我们手动将数据填充到表单然后提交 | ||
101 | + $("#commonSearchContent_" + options.idTable + " form [name='ip']").val(value); | ||
102 | + $("#commonSearchContent_" + options.idTable + " form").trigger('submit'); | ||
103 | + Toastr.info("执行了自定义搜索操作"); | ||
104 | + } | ||
105 | + }, | ||
106 | + browser: { | ||
107 | + 'click .btn-browser': function (e, value, row, index) { | ||
108 | + Layer.alert("该行数据为: <code>" + JSON.stringify(row) + "</code>"); | ||
109 | + } | ||
110 | + } | ||
111 | + } | ||
112 | + } | ||
113 | + }; | ||
114 | + return Controller; | ||
115 | +}); |
addons/example/view/demo/demo1.html
0 → 100644
1 | +<!-- Page Content --> | ||
2 | + <div class="container"> | ||
3 | + | ||
4 | + <!-- Page Heading/Breadcrumbs --> | ||
5 | + <div class="row"> | ||
6 | + <div class="col-lg-12"> | ||
7 | + <h1 class="page-header">无需登录页面 | ||
8 | + <small>开发者示例</small> | ||
9 | + </h1> | ||
10 | + <ol class="breadcrumb"> | ||
11 | + <li><a href="{:addon_url('example/index/index')}">插件首页</a> | ||
12 | + </li> | ||
13 | + <li class="active">无需登录页面</li> | ||
14 | + </ol> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + <!-- /.row --> | ||
18 | + | ||
19 | + <!-- Content Row --> | ||
20 | + <div class="row"> | ||
21 | + <div class="col-lg-12"> | ||
22 | + <p class="well">当前登录页面无需登录即可查看,当前请求的name值为:{$Request.param.name}</p> | ||
23 | + {if $user} | ||
24 | + <p class="well text-danger">但是如果你登录后可以浏览到这段隐藏的信息</p> | ||
25 | + {/if} | ||
26 | + </div> | ||
27 | + </div> | ||
28 | + <!-- /.row --> | ||
29 | + | ||
30 | + <hr> | ||
31 | + | ||
32 | + </div> | ||
33 | + <!-- /.container --> |
addons/example/view/demo/demo2.html
0 → 100644
1 | +<!-- Page Content --> | ||
2 | +<div class="container"> | ||
3 | + | ||
4 | + <!-- Page Heading/Breadcrumbs --> | ||
5 | + <div class="row"> | ||
6 | + <div class="col-lg-12"> | ||
7 | + <h1 class="page-header">需登录页面 | ||
8 | + <small>开发者示例</small> | ||
9 | + </h1> | ||
10 | + <ol class="breadcrumb"> | ||
11 | + <li><a href="{:addon_url('example/index/index')}">插件首页</a> | ||
12 | + </li> | ||
13 | + <li class="active">需登录页面</li> | ||
14 | + </ol> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + <!-- /.row --> | ||
18 | + | ||
19 | + <!-- Content Row --> | ||
20 | + <div class="row"> | ||
21 | + <div class="col-lg-12"> | ||
22 | + <p class="well">当前登录页面需要登录后才可以查看,你可以退出后再访问此页面,会提醒登录,当前请求的name值为:{$Request.param.name}</p> | ||
23 | + <p class="well">你好!{$user.nickname},<a href="{:url('index/user/logout')}">注销登录</a></p> | ||
24 | + </div> | ||
25 | + </div> | ||
26 | + <!-- /.row --> | ||
27 | + | ||
28 | + <hr> | ||
29 | + | ||
30 | +</div> | ||
31 | +<!-- /.container --> |
addons/example/view/demo/index.html
0 → 100644
1 | +<!-- Page Content --> | ||
2 | + <div class="container"> | ||
3 | + | ||
4 | + <!-- Page Heading/Breadcrumbs --> | ||
5 | + <div class="row"> | ||
6 | + <div class="col-lg-12"> | ||
7 | + <h1 class="page-header">使用模板标签和变量 | ||
8 | + <small>开发者示例</small> | ||
9 | + </h1> | ||
10 | + <ol class="breadcrumb"> | ||
11 | + <li><a href="{:addon_url('example/index/index')}">插件首页</a> | ||
12 | + </li> | ||
13 | + <li class="active">使用模板标签和变量</li> | ||
14 | + </ol> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + <!-- /.row --> | ||
18 | + | ||
19 | + <!-- Content Row --> | ||
20 | + <div class="row"> | ||
21 | + <div class="col-lg-12"> | ||
22 | + <p class="well">当前请求的name值为:{$Request.param.name}</p> | ||
23 | + {literal} | ||
24 | + <pre> | ||
25 | +在插件视图中可以使用所有ThinkPHP5内支持的模板标签和变量,如 | ||
26 | + | ||
27 | +{$Think.server.script_name} // 输出$_SERVER['SCRIPT_NAME']变量 | ||
28 | +{$Think.session.user_id} // 输出$_SESSION['user_id']变量 | ||
29 | +{$Think.get.pageNumber} // 输出$_GET['pageNumber']变量 | ||
30 | +{$Think.cookie.name} // 输出$_COOKIE['name']变量 | ||
31 | + | ||
32 | +// 调用Request对象的get方法 传入参数为id | ||
33 | +{$Request.get.id} | ||
34 | +// 调用Request对象的param方法 传入参数为name | ||
35 | +{$Request.param.name} | ||
36 | +// 调用Request对象的param方法 传入参数为user.nickname | ||
37 | +{$Request.param.user.nickname} | ||
38 | +// 调用Request对象的root方法 | ||
39 | +{$Request.root} | ||
40 | +// 调用Request对象的root方法,并且传入参数true | ||
41 | +{$Request.root.true} | ||
42 | +// 调用Request对象的path方法 | ||
43 | +{$Request.path} | ||
44 | +// 调用Request对象的module方法 | ||
45 | +{$Request.module} | ||
46 | +// 调用Request对象的controller方法 | ||
47 | +{$Request.controller} | ||
48 | +// 调用Request对象的action方法 | ||
49 | +{$Request.action} | ||
50 | +// 调用Request对象的ext方法 | ||
51 | +{$Request.ext} | ||
52 | +// 调用Request对象的host方法 | ||
53 | +{$Request.host} | ||
54 | +// 调用Request对象的ip方法 | ||
55 | +{$Request.ip} | ||
56 | +// 调用Request对象的header方法 | ||
57 | +{$Request.header.accept-encoding} | ||
58 | + </pre> | ||
59 | + {/literal} | ||
60 | + </div> | ||
61 | + </div> | ||
62 | + <!-- /.row --> | ||
63 | + | ||
64 | + <hr> | ||
65 | + | ||
66 | + </div> | ||
67 | + <!-- /.container --> |
addons/example/view/index/index.html
0 → 100644
1 | +<!-- Header Carousel --> | ||
2 | +<header id="myCarousel" class="carousel slide"> | ||
3 | + <!-- Indicators --> | ||
4 | + <ol class="carousel-indicators"> | ||
5 | + <li data-target="#myCarousel" data-slide-to="0" class="active"></li> | ||
6 | + <li data-target="#myCarousel" data-slide-to="1"></li> | ||
7 | + <li data-target="#myCarousel" data-slide-to="2"></li> | ||
8 | + <li data-target="#myCarousel" data-slide-to="3"></li> | ||
9 | + </ol> | ||
10 | + | ||
11 | + <!-- Wrapper for slides --> | ||
12 | + <div class="carousel-inner"> | ||
13 | + <div class="item active"> | ||
14 | + <a href="https://www.fastadmin.net/store/cms.html" target="_blank"> | ||
15 | + <div class="fill" style="background-image:url('https://bg.fastadmin.net?text=random&color=3498db');"></div> | ||
16 | + <div class="carousel-body"> | ||
17 | + <div class="container"> | ||
18 | + <h1 class="display-1 text-white">CMS内容管理模块</h1> | ||
19 | + <h2 class="display-4 text-white">简单强大的内容管理系统,可自定义内容模型、标签、伪静态、全文搜索、百度推送等功能<br>包含完整的小程序CMS客户端,拥有完善的资讯模块、产品模块、评论模块、会员模块</h2> | ||
20 | + </div> | ||
21 | + </div> | ||
22 | + </a> | ||
23 | + </div> | ||
24 | + <div class="item"> | ||
25 | + <a href="https://www.fastadmin.net/store/blog.html" target="_blank"> | ||
26 | + <div class="fill" style="background-image:url('https://bg.fastadmin.net?text=random&color=2ecc71');"></div> | ||
27 | + <div class="carousel-body"> | ||
28 | + <div class="container"> | ||
29 | + <h1 class="display-1 text-white">简单博客模块</h1> | ||
30 | + <h2 class="display-4 text-white">响应式博客插件,包含日志、评论、分类、归档、全文搜索、百度推送等功能<br/>包含完整的小程序博客客户端,拥有博客日志列表、日志详情、评论等功能</h2> | ||
31 | + </div> | ||
32 | + </div> | ||
33 | + </a> | ||
34 | + </div> | ||
35 | + <div class="item"> | ||
36 | + <a href="https://www.fastadmin.net/store/vote.html" target="_blank"> | ||
37 | + <div class="fill" style="background-image:url('https://bg.fastadmin.net?text=random&color=0082ff');"></div> | ||
38 | + <div class="carousel-body"> | ||
39 | + <div class="container"> | ||
40 | + <h1 class="display-1 text-white">在线投票系统</h1> | ||
41 | + <h2 class="display-4 text-white">基于FastAdmin+ThinkPHP开发的响应式在线投票系统,支持微信公众号投票和PC端投票<br/>具有高防刷票机制和实时排行榜等诸多特性,提供全部前后台无加密源代码</h2> | ||
42 | + </div> | ||
43 | + </div> | ||
44 | + </a> | ||
45 | + </div> | ||
46 | + <div class="item"> | ||
47 | + <a href="https://www.fastadmin.net/store/docs.html" target="_blank"> | ||
48 | + <div class="fill" style="background-image:url('https://bg.fastadmin.net?text=random&color=9c88ff');"></div> | ||
49 | + <div class="carousel-body"> | ||
50 | + <div class="container"> | ||
51 | + <h1 class="display-1 text-white">Markdown文档生成</h1> | ||
52 | + <h2 class="display-4 text-white">将Github或本地Git环境中的Markdown文件解析并生成HTML,可在线浏览或导出为HTML离线浏览</h2> | ||
53 | + </div> | ||
54 | + </div> | ||
55 | + </a> | ||
56 | + </div> | ||
57 | + </div> | ||
58 | +</header> | ||
59 | + | ||
60 | +<!-- Page Content --> | ||
61 | +<div class="container"> | ||
62 | + | ||
63 | + <!-- Marketing Icons Section --> | ||
64 | + <div class="row"> | ||
65 | + <div class="col-lg-12"> | ||
66 | + <h2 class="page-header"> | ||
67 | + 基础模块 | ||
68 | + </h2> | ||
69 | + </div> | ||
70 | + <div class="col-md-4"> | ||
71 | + <div class="panel panel-default"> | ||
72 | + <div class="panel-heading"> | ||
73 | + <h4><i class="fa fa-fw fa-user"></i> 前台模块</h4> | ||
74 | + </div> | ||
75 | + <div class="panel-body"> | ||
76 | + <p>FastAdmin有基础的前台模块,可快速的进行二次开发,前台模块中包含基础的会员模块,前台模块中的会员账号和API模块中的会员账号是同一账号体系</p> | ||
77 | + <a href="{:url('index/index/index')}" target="_blank" class="btn btn-primary">立即访问</a> | ||
78 | + <a href="{:url('index/user/index')}" target="_blank" class="btn btn-default">会员中心</a> | ||
79 | + </div> | ||
80 | + </div> | ||
81 | + </div> | ||
82 | + <div class="col-md-4"> | ||
83 | + <div class="panel panel-default"> | ||
84 | + <div class="panel-heading"> | ||
85 | + <h4><i class="fa fa-fw fa-gift"></i> API模块</h4> | ||
86 | + </div> | ||
87 | + <div class="panel-body"> | ||
88 | + <p>FastAdmin有基础的API模块,可快速的进行二次开发,API模块中包含基础的会员模块,初始化模块、短信发送模块、验证模块</p> | ||
89 | + <a href="{:url('api/index/index')}" target="_blank" class="btn btn-primary">立即访问</a> | ||
90 | + <a href="{:url('api/common/init')}?version=1.0.0" target="_blank" class="btn btn-default">初始化接口</a> | ||
91 | + </div> | ||
92 | + </div> | ||
93 | + </div> | ||
94 | + <div class="col-md-4"> | ||
95 | + <div class="panel panel-default"> | ||
96 | + <div class="panel-heading"> | ||
97 | + <h4><i class="fa fa-fw fa-compass"></i> API文档</h4> | ||
98 | + </div> | ||
99 | + <div class="panel-body"> | ||
100 | + <p>我们提供了一键生成API文档的功能,当写完API接口以后,可通过执行php think api一键生成我们所需要的API文档,并且可以直接在线测试</p> | ||
101 | + <a href="{:url('/')}api.html" target="_blank" class="btn btn-primary">立即访问</a> | ||
102 | + <a href="https://doc.fastadmin.net/docs/command.html#一键生成API文档" target="_blank" class="btn btn-default">一键生成文档</a> | ||
103 | + </div> | ||
104 | + </div> | ||
105 | + </div> | ||
106 | + </div> | ||
107 | + <div class="row"> | ||
108 | + <div class="col-lg-12"> | ||
109 | + <h2 class="page-header"> | ||
110 | + 功能示例 | ||
111 | + </h2> | ||
112 | + </div> | ||
113 | + <div class="col-md-4"> | ||
114 | + <div class="panel panel-default"> | ||
115 | + <div class="panel-heading"> | ||
116 | + <h4><i class="fa fa-fw fa-check"></i> 使用模板标签和变量</h4> | ||
117 | + </div> | ||
118 | + <div class="panel-body"> | ||
119 | + <p>在FastAdmin插件的视图中我们可以像前后台开发一样,向视图中渲染我们的自定义变量,然后在视图中进行访问。同时FastAdmin的插件视图中支持所有ThinkPHP5官方的系统模板标签和变量。轻轻松松的开发我们的插件</p> | ||
120 | + <a href="{:addon_url('example/demo/index',[':name'=>'s1'])}" class="btn btn-success">查看示例</a> | ||
121 | + </div> | ||
122 | + </div> | ||
123 | + </div> | ||
124 | + <div class="col-md-4"> | ||
125 | + <div class="panel panel-default"> | ||
126 | + <div class="panel-heading"> | ||
127 | + <h4><i class="fa fa-fw fa-gift"></i> 访问不需要登录的页面</h4> | ||
128 | + </div> | ||
129 | + <div class="panel-body"> | ||
130 | + <p>在开发的过程有许多页面是不需要会员登录就可以访问的页面,比如新闻列表、新闻详情、评论列表、产品列表、产品展示、关于我们等等页面。在FastAdmin中可以使用noNeedLogin很方便的控制我们请求方法的访问权限</p> | ||
131 | + <a href="{:addon_url('example/demo/demo1',[':name'=>'s2'])}" class="btn btn-success">立即访问</a> | ||
132 | + </div> | ||
133 | + </div> | ||
134 | + </div> | ||
135 | + <div class="col-md-4"> | ||
136 | + <div class="panel panel-default"> | ||
137 | + <div class="panel-heading"> | ||
138 | + <h4><i class="fa fa-fw fa-compass"></i> 访问需要登录的页面</h4> | ||
139 | + </div> | ||
140 | + <div class="panel-body"> | ||
141 | + <p>通常我们在开发中,如果页面与会员信息相关联,则通常需要控制页面在会员登录后才可以访问,FastAdmin中前台的权限控制可以很快捷的在插件中使用。我们可以直接重新定义noNeedLogin排除我们不需要登录的方法即可。</p> | ||
142 | + <a href="{:addon_url('example/demo/demo2',[':name'=>'s3'])}" class="btn btn-success">立即访问</a> | ||
143 | + </div> | ||
144 | + </div> | ||
145 | + </div> | ||
146 | + </div> | ||
147 | + <!-- /.row --> | ||
148 | + | ||
149 | + <div class="row addonlist"> | ||
150 | + <div class="col-lg-12"> | ||
151 | + <h2 class="page-header"> | ||
152 | + 模块&插件 | ||
153 | + <span class="pull-right small" style="margin-top:5px;"> | ||
154 | + <small> | ||
155 | + <a href="https://www.fastadmin.net/store.html" target="_blank">更多</a> | ||
156 | + </small> | ||
157 | + </span> | ||
158 | + </h2> | ||
159 | + </div> | ||
160 | + <div class="col-md-4 col-sm-6"> | ||
161 | + <a href="https://www.fastadmin.net/store/cms.html" target="_blank"> | ||
162 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/cms.png" alt=""> | ||
163 | + <p>CMS内容管理模块</p> | ||
164 | + </a> | ||
165 | + </div> | ||
166 | + <div class="col-md-4 col-sm-6"> | ||
167 | + <a href="https://www.fastadmin.net/store/blog.html" target="_blank"> | ||
168 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/blog.png" alt=""> | ||
169 | + <p>简洁博客模块</p> | ||
170 | + </a> | ||
171 | + </div> | ||
172 | + <div class="col-md-4 col-sm-6"> | ||
173 | + <a href="https://www.fastadmin.net/store/ask.html" target="_blank"> | ||
174 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/ask.png" alt=""> | ||
175 | + <p>付费问答社区</p> | ||
176 | + </a> | ||
177 | + </div> | ||
178 | + <div class="col-md-4 col-sm-6"> | ||
179 | + <a href="https://www.fastadmin.net/store/docs.html" target="_blank"> | ||
180 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/docs.png" alt=""> | ||
181 | + <p>文档生成模块</p> | ||
182 | + </a> | ||
183 | + </div> | ||
184 | + <div class="col-md-4 col-sm-6"> | ||
185 | + <a href="https://www.fastadmin.net/store/vote.html" target="_blank"> | ||
186 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/vote.png" alt=""> | ||
187 | + <p>在线投票系统</p> | ||
188 | + </a> | ||
189 | + </div> | ||
190 | + <div class="col-md-4 col-sm-6"> | ||
191 | + <a href="https://www.fastadmin.net/store/qiniu.html" target="_blank"> | ||
192 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/qiniu.png" alt=""> | ||
193 | + <p>七牛上传插件</p> | ||
194 | + </a> | ||
195 | + </div> | ||
196 | + <div class="col-md-4 col-sm-6"> | ||
197 | + <a href="https://www.fastadmin.net/store/alioss.html" target="_blank"> | ||
198 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/alioss.png" alt=""> | ||
199 | + <p>阿里云储存</p> | ||
200 | + </a> | ||
201 | + </div> | ||
202 | + <div class="col-md-4 col-sm-6"> | ||
203 | + <a href="https://www.fastadmin.net/store/alisms.html" target="_blank"> | ||
204 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/alisms.png" alt=""> | ||
205 | + <p>阿里云短信</p> | ||
206 | + </a> | ||
207 | + </div> | ||
208 | + <div class="col-md-4 col-sm-6"> | ||
209 | + <a href="https://www.fastadmin.net/store/nkeditor.html" target="_blank"> | ||
210 | + <img class="img-responsive img-addon img-hover" src="https://cdn.fastadmin.net/uploads/addons/nkeditor.png" alt=""> | ||
211 | + <p>富文本编辑器</p> | ||
212 | + </a> | ||
213 | + </div> | ||
214 | + <div class="col-xs-12 text-center"> | ||
215 | + <a href="https://www.fastadmin.net/store.html" class="btn btn-primary" target="_blank">前往插件市场</a> | ||
216 | + </div> | ||
217 | + </div> | ||
218 | + <!-- /.row --> | ||
219 | + | ||
220 | + <hr> | ||
221 | + | ||
222 | + <!-- Call to Action Section --> | ||
223 | + <div class="well"> | ||
224 | + <div class="row"> | ||
225 | + <div class="col-md-8"> | ||
226 | + <p>感谢你对FastAdmin的支持!如果你在使用FastAdmin开发插件的过程中有任何疑问或需要寻求帮助,请前往FastAdmin问答社区与小伙伴们一起交流。</p> | ||
227 | + </div> | ||
228 | + <div class="col-md-4"> | ||
229 | + <a class="btn btn-lg btn-default btn-block" href="https://ask.fastadmin.net" target="_blank">前往问答社区</a> | ||
230 | + </div> | ||
231 | + </div> | ||
232 | + </div> | ||
233 | + | ||
234 | + <hr> | ||
235 | + | ||
236 | +</div> |
addons/example/view/layout/default.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html lang="en"> | ||
3 | + | ||
4 | + <head> | ||
5 | + | ||
6 | + <meta charset="utf-8"> | ||
7 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
8 | + <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
9 | + <meta name="description" content=""> | ||
10 | + <meta name="author" content=""> | ||
11 | + | ||
12 | + <title>开发者示例 - FastAdmin</title> | ||
13 | + | ||
14 | + <!-- Bootstrap Core CSS --> | ||
15 | + <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> | ||
16 | + | ||
17 | + <!-- Custom CSS --> | ||
18 | + <link href="__ADDON__/css/common.css" rel="stylesheet"> | ||
19 | + | ||
20 | + <!-- Custom Fonts --> | ||
21 | + <link href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"> | ||
22 | + | ||
23 | + <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> | ||
24 | + <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | ||
25 | + <!--[if lt IE 9]> | ||
26 | + <script src="https://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script> | ||
27 | + <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> | ||
28 | + <![endif]--> | ||
29 | + | ||
30 | + </head> | ||
31 | + | ||
32 | + <body> | ||
33 | + | ||
34 | + <!-- Navigation --> | ||
35 | + <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> | ||
36 | + <div class="container"> | ||
37 | + <!-- Brand and toggle get grouped for better mobile display --> | ||
38 | + <div class="navbar-header"> | ||
39 | + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> | ||
40 | + <span class="sr-only">Toggle navigation</span> | ||
41 | + <span class="icon-bar"></span> | ||
42 | + <span class="icon-bar"></span> | ||
43 | + <span class="icon-bar"></span> | ||
44 | + </button> | ||
45 | + <a class="navbar-brand" href="{:addon_url('example/index/index')}">FastAdmin</a> | ||
46 | + </div> | ||
47 | + <!-- Collect the nav links, forms, and other content for toggling --> | ||
48 | + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> | ||
49 | + <ul class="nav navbar-nav navbar-right"> | ||
50 | + <li> | ||
51 | + <a href="{:addon_url('example/index/index')}">插件首页</a> | ||
52 | + </li> | ||
53 | + <li> | ||
54 | + <a href="{:addon_url('example/demo/demo1', [':name'=>'s1'])}">无需登录页面</a> | ||
55 | + </li> | ||
56 | + <li> | ||
57 | + <a href="{:addon_url('example/demo/demo2', [':name'=>'s2'])}">需登录页面</a> | ||
58 | + </li> | ||
59 | + {if $user} | ||
60 | + <li class="dropdown"> | ||
61 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown">欢迎你! {$user.nickname}<b class="caret"></b></a> | ||
62 | + <ul class="dropdown-menu"> | ||
63 | + <li> | ||
64 | + <a href="{:url('index/user/index')}">会员中心</a> | ||
65 | + </li> | ||
66 | + <li> | ||
67 | + <a href="{:url('index/user/profile')}">个人资料</a> | ||
68 | + </li> | ||
69 | + <li> | ||
70 | + <a href="{:url('index/user/logout')}">退出登录</a> | ||
71 | + </li> | ||
72 | + </ul> | ||
73 | + </li> | ||
74 | + {else /} | ||
75 | + <li class="dropdown"> | ||
76 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown">会员中心 <b class="caret"></b></a> | ||
77 | + <ul class="dropdown-menu"> | ||
78 | + <li> | ||
79 | + <a href="{:url('index/user/login')}">登录</a> | ||
80 | + </li> | ||
81 | + <li> | ||
82 | + <a href="{:url('index/user/register')}">注册</a> | ||
83 | + </li> | ||
84 | + </ul> | ||
85 | + </li> | ||
86 | + {/if} | ||
87 | + </ul> | ||
88 | + </div> | ||
89 | + <!-- /.navbar-collapse --> | ||
90 | + </div> | ||
91 | + <!-- /.container --> | ||
92 | + </nav> | ||
93 | + | ||
94 | + {__CONTENT__} | ||
95 | + | ||
96 | + <div class="container"> | ||
97 | + <!-- Footer --> | ||
98 | + <footer> | ||
99 | + <div class="row"> | ||
100 | + <div class="col-lg-12"> | ||
101 | + <p>Copyright © <a href="https://www.fastadmin.net">FastAdmin</a> 2020</p> | ||
102 | + </div> | ||
103 | + </div> | ||
104 | + </footer> | ||
105 | + | ||
106 | + </div> | ||
107 | + <!-- /.container --> | ||
108 | + | ||
109 | + <!-- jQuery --> | ||
110 | + <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> | ||
111 | + | ||
112 | + <!-- Bootstrap Core JavaScript --> | ||
113 | + <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | ||
114 | + | ||
115 | + <!-- Script to Activate the Carousel --> | ||
116 | + <script> | ||
117 | + $('.carousel').carousel({ | ||
118 | + interval: 5000 //changes the speed | ||
119 | + }) | ||
120 | + </script> | ||
121 | + | ||
122 | + </body> | ||
123 | + | ||
124 | +</html> |
addons/litestore/Litestore.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace addons\litestore; | ||
4 | + | ||
5 | +use app\common\library\Menu; | ||
6 | +use think\Addons; | ||
7 | + | ||
8 | +/** | ||
9 | + * 插件 | ||
10 | + */ | ||
11 | +class Litestore extends Addons | ||
12 | +{ | ||
13 | + | ||
14 | + /** | ||
15 | + * 插件安装方法 | ||
16 | + * @return bool | ||
17 | + */ | ||
18 | + public function install() | ||
19 | + { | ||
20 | + $menu = [ | ||
21 | + [ | ||
22 | + 'name' => 'litestore', | ||
23 | + 'title' => '移动端商城', | ||
24 | + 'icon' => 'fa fa-shopping-basket', | ||
25 | + 'sublist' => [ | ||
26 | + [ | ||
27 | + 'name' => 'litestorenews', | ||
28 | + 'title' => '首页banner', | ||
29 | + 'icon' => 'fa fa-image', | ||
30 | + 'sublist' => [ | ||
31 | + ['name' => 'litestorenews/index', 'title' => '查看'], | ||
32 | + ['name' => 'litestorenews/add', 'title' => '添加'], | ||
33 | + ['name' => 'litestorenews/edit', 'title' => '修改'], | ||
34 | + ['name' => 'litestorenews/del', 'title' => '删除'], | ||
35 | + ['name' => 'litestorenews/multi', 'title' => '批量更新'], | ||
36 | + ] | ||
37 | + ], | ||
38 | + [ | ||
39 | + 'name' => 'litestoregoods', | ||
40 | + 'title' => '商品设置', | ||
41 | + 'icon' => 'fa fa-gift', | ||
42 | + 'sublist' => [ | ||
43 | + ['name' => 'litestoregoods/index', 'title' => '查看'], | ||
44 | + ['name' => 'litestoregoods/add', 'title' => '添加'], | ||
45 | + ['name' => 'litestoregoods/edit', 'title' => '修改'], | ||
46 | + ['name' => 'litestoregoods/del', 'title' => '删除'], | ||
47 | + ['name' => 'litestoregoods/multi', 'title' => '批量更新'], | ||
48 | + ['name' => 'litestoregoods/addSpec', 'title' => '增加规格'], | ||
49 | + ['name' => 'litestoregoods/addSpecValue', 'title' => '增加规格值'], | ||
50 | + ] | ||
51 | + ], | ||
52 | + [ | ||
53 | + 'name' => 'litestorecategory', | ||
54 | + 'title' => '商品分类', | ||
55 | + 'icon' => 'fa fa-th', | ||
56 | + 'sublist' => [ | ||
57 | + ['name' => 'litestorecategory/index', 'title' => '查看'], | ||
58 | + ['name' => 'litestorecategory/add', 'title' => '添加'], | ||
59 | + ['name' => 'litestorecategory/edit', 'title' => '修改'], | ||
60 | + ['name' => 'litestorecategory/del', 'title' => '删除'], | ||
61 | + ['name' => 'litestorecategory/multi', 'title' => '批量更新'], | ||
62 | + ] | ||
63 | + ], | ||
64 | + [ | ||
65 | + 'name' => 'litestorefreight', | ||
66 | + 'title' => '运费模板设置', | ||
67 | + 'icon' => 'fa fa-train', | ||
68 | + 'sublist' => [ | ||
69 | + ['name' => 'litestorefreight/index', 'title' => '查看'], | ||
70 | + ['name' => 'litestorefreight/add', 'title' => '添加'], | ||
71 | + ['name' => 'litestorefreight/edit', 'title' => '修改'], | ||
72 | + ['name' => 'litestorefreight/del', 'title' => '删除'], | ||
73 | + ['name' => 'litestorefreight/multi', 'title' => '批量更新'], | ||
74 | + ] | ||
75 | + ], | ||
76 | + [ | ||
77 | + 'name' => 'litestoreorder', | ||
78 | + 'title' => '订单管理', | ||
79 | + 'icon' => 'fa fa-tasks', | ||
80 | + 'sublist' => [ | ||
81 | + ['name' => 'litestoreorder/index', 'title' => '查看'], | ||
82 | + ['name' => 'litestoreorder/add', 'title' => '添加'], | ||
83 | + ['name' => 'litestoreorder/edit', 'title' => '修改'], | ||
84 | + ['name' => 'litestoreorder/del', 'title' => '删除'], | ||
85 | + ['name' => 'litestoreorder/multi', 'title' => '批量更新'], | ||
86 | + ['name' => 'litestoreorder/detail', 'title' => '订单详情'], | ||
87 | + ] | ||
88 | + ], | ||
89 | + ] | ||
90 | + ] | ||
91 | + ]; | ||
92 | + Menu::create($menu); | ||
93 | + return true; | ||
94 | + } | ||
95 | + | ||
96 | + /** | ||
97 | + * 插件卸载方法 | ||
98 | + * @return bool | ||
99 | + */ | ||
100 | + public function uninstall() | ||
101 | + { | ||
102 | + Menu::delete('litestore'); | ||
103 | + return true; | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
107 | + * 插件启用方法 | ||
108 | + * @return bool | ||
109 | + */ | ||
110 | + public function enable() | ||
111 | + { | ||
112 | + Menu::enable('litestore'); | ||
113 | + return true; | ||
114 | + } | ||
115 | + | ||
116 | + /** | ||
117 | + * 插件禁用方法 | ||
118 | + * @return bool | ||
119 | + */ | ||
120 | + public function disable() | ||
121 | + { | ||
122 | + Menu::disable('litestore'); | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + public function GetCfg(){ | ||
127 | + return $this->getConfig(); | ||
128 | + } | ||
129 | + | ||
130 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | +use fast\Tree; | ||
7 | +/** | ||
8 | + * 商品分类 | ||
9 | + * | ||
10 | + * @icon fa fa-circle-o | ||
11 | + */ | ||
12 | +class Litestorecategory extends Backend | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * Litestorecategory模型对象 | ||
17 | + * @var \app\admin\model\Litestorecategory | ||
18 | + */ | ||
19 | + protected $model = null; | ||
20 | + protected $categorylist = []; | ||
21 | + | ||
22 | + public function _initialize() | ||
23 | + { | ||
24 | + parent::_initialize(); | ||
25 | + $this->model = new \app\admin\model\Litestorecategory; | ||
26 | + | ||
27 | + $tree = Tree::instance(); | ||
28 | + $tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid'); | ||
29 | + $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name'); | ||
30 | + $categorydata = [0 => ['type' => 'all', 'name' => __('None')]]; | ||
31 | + foreach ($this->categorylist as $k => $v) | ||
32 | + { | ||
33 | + $categorydata[$v['id']] = $v; | ||
34 | + } | ||
35 | + $this->view->assign("parentList", $categorydata); | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
40 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
41 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
42 | + */ | ||
43 | + public function index() | ||
44 | + { | ||
45 | + if ($this->request->isAjax()) | ||
46 | + { | ||
47 | + $search = $this->request->request("search"); | ||
48 | + $type = "all"; | ||
49 | + | ||
50 | + //构造父类select列表选项数据 | ||
51 | + $list = []; | ||
52 | + | ||
53 | + foreach ($this->categorylist as $k => $v) | ||
54 | + { | ||
55 | + if ($search) { | ||
56 | + if (stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) | ||
57 | + { | ||
58 | + if($type == "all" || $type == null) { | ||
59 | + $list = $this->categorylist; | ||
60 | + } else { | ||
61 | + $list[] = $v; | ||
62 | + } | ||
63 | + } | ||
64 | + } else { | ||
65 | + if($type == "all" || $type == null) { | ||
66 | + $list = $this->categorylist; | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
70 | + } | ||
71 | + | ||
72 | + $total = count($list); | ||
73 | + $result = array("total" => $total, "rows" => $list); | ||
74 | + | ||
75 | + return json($result); | ||
76 | + } | ||
77 | + return $this->view->fetch(); | ||
78 | + } | ||
79 | + | ||
80 | + public function selectpage() | ||
81 | + { | ||
82 | + return parent::selectpage(); | ||
83 | + } | ||
84 | + | ||
85 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * | ||
9 | + * | ||
10 | + * @icon fa fa-circle-o | ||
11 | + */ | ||
12 | +class Litestorefreight extends Backend | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * Litestore_freight模型对象 | ||
17 | + * @var \app\admin\model\Litestorefreight | ||
18 | + */ | ||
19 | + protected $model = null; | ||
20 | + | ||
21 | + public function _initialize() | ||
22 | + { | ||
23 | + parent::_initialize(); | ||
24 | + $this->model = new \app\admin\model\Litestorefreight; | ||
25 | + $this->view->assign("methodList", $this->model->getMethodList()); | ||
26 | + | ||
27 | + $AreaData = new \app\admin\model\Litestorearea; | ||
28 | + $this->view->assign("regionData", json_encode($AreaData->getCacheTree())); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
33 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
34 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
35 | + */ | ||
36 | + /** | ||
37 | + * 添加 | ||
38 | + */ | ||
39 | + public function add() | ||
40 | + { | ||
41 | + if ($this->request->isPost()) { | ||
42 | + $params = $this->request->post("row/a"); | ||
43 | + | ||
44 | + if ($params) { | ||
45 | + $ruleparams = $this->request->post("delivery/a"); | ||
46 | + //这里判断是否存在 地区信息 | ||
47 | + if(!isset($ruleparams['rule']) || empty($ruleparams['rule'])){ | ||
48 | + $this->error('请选择可配送区域'); | ||
49 | + } | ||
50 | + $ruleparams = $ruleparams['rule']; | ||
51 | + | ||
52 | + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | ||
53 | + $params[$this->dataLimitField] = $this->auth->id; | ||
54 | + } | ||
55 | + try { | ||
56 | + //是否采用模型验证 | ||
57 | + if ($this->modelValidate) { | ||
58 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
59 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; | ||
60 | + $this->model->validate($validate); | ||
61 | + } | ||
62 | + $result = $this->model->allowField(true)->save($params); | ||
63 | + if ($result !== false) { | ||
64 | + //当插入完成后 插入规则 | ||
65 | + $this->model->createDeliveryRule($ruleparams); | ||
66 | + | ||
67 | + $this->success(); | ||
68 | + } else { | ||
69 | + $this->error($this->model->getError()); | ||
70 | + } | ||
71 | + } catch (\think\exception\PDOException $e) { | ||
72 | + $this->error($e->getMessage()); | ||
73 | + } catch (\think\Exception $e) { | ||
74 | + $this->error($e->getMessage()); | ||
75 | + } | ||
76 | + } | ||
77 | + $this->error(__('Parameter %s can not be empty', '')); | ||
78 | + } | ||
79 | + return $this->view->fetch(); | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * 编辑 | ||
84 | + */ | ||
85 | + public function edit($ids = NULL) | ||
86 | + { | ||
87 | + $row = $this->model->detail($ids); | ||
88 | + if (!$row) | ||
89 | + $this->error(__('No Results were found')); | ||
90 | + $adminIds = $this->getDataLimitAdminIds(); | ||
91 | + if (is_array($adminIds)) { | ||
92 | + if (!in_array($row[$this->dataLimitField], $adminIds)) { | ||
93 | + $this->error(__('You have no permission')); | ||
94 | + } | ||
95 | + } | ||
96 | + if ($this->request->isPost()) { | ||
97 | + $params = $this->request->post("row/a"); | ||
98 | + if ($params) { | ||
99 | + $ruleparams = $this->request->post("delivery/a"); | ||
100 | + //这里判断是否存在 地区信息 | ||
101 | + if(!isset($ruleparams['rule']) || empty($ruleparams['rule'])){ | ||
102 | + $this->error('请选择可配送区域'); | ||
103 | + } | ||
104 | + $ruleparams = $ruleparams['rule']; | ||
105 | + | ||
106 | + try { | ||
107 | + //是否采用模型验证 | ||
108 | + if ($this->modelValidate) { | ||
109 | + $name = basename(str_replace('\\', '/', get_class($this->model))); | ||
110 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; | ||
111 | + $row->validate($validate); | ||
112 | + } | ||
113 | + $result = $row->allowField(true)->save($params); | ||
114 | + if ($result !== false) { | ||
115 | + //当更新完成后 插入规则 | ||
116 | + $row->createDeliveryRule($ruleparams); | ||
117 | + $this->success(); | ||
118 | + } else { | ||
119 | + $this->error($row->getError()); | ||
120 | + } | ||
121 | + } catch (\think\exception\PDOException $e) { | ||
122 | + $this->error($e->getMessage()); | ||
123 | + } catch (\think\Exception $e) { | ||
124 | + $this->error($e->getMessage()); | ||
125 | + } | ||
126 | + } | ||
127 | + $this->error(__('Parameter %s can not be empty', '')); | ||
128 | + } | ||
129 | + $this->view->assign("row", $row); | ||
130 | + return $this->view->fetch(); | ||
131 | + } | ||
132 | + /** | ||
133 | + * 删除 | ||
134 | + */ | ||
135 | + public function del($ids = "") | ||
136 | + { | ||
137 | + if ($ids) { | ||
138 | + $pk = $this->model->getPk(); | ||
139 | + $adminIds = $this->getDataLimitAdminIds(); | ||
140 | + if (is_array($adminIds)) { | ||
141 | + $count = $this->model->where($this->dataLimitField, 'in', $adminIds); | ||
142 | + } | ||
143 | + $list = $this->model->where($pk, 'in', $ids)->select(); | ||
144 | + $count = 0; | ||
145 | + foreach ($list as $k => $v) { | ||
146 | + $count += $v->delete(); | ||
147 | + $v->rule()->delete(); | ||
148 | + } | ||
149 | + if ($count) { | ||
150 | + $this->success(); | ||
151 | + } else { | ||
152 | + $this->error(__('No rows were deleted')); | ||
153 | + } | ||
154 | + } | ||
155 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
156 | + } | ||
157 | + | ||
158 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | +use app\admin\model\Litestorespec as SpecModel; | ||
7 | +use app\admin\model\Litestorespecvalue as SpecValueModel; | ||
8 | +/** | ||
9 | + * | ||
10 | + * | ||
11 | + * @icon fa fa-circle-o | ||
12 | + */ | ||
13 | +class Litestoregoods extends Backend | ||
14 | +{ | ||
15 | + private $SpecModel; | ||
16 | + private $SpecValueModel; | ||
17 | + /** | ||
18 | + * Litestoregoods模型对象 | ||
19 | + * @var \app\admin\model\Litestoregoods | ||
20 | + */ | ||
21 | + protected $model = null; | ||
22 | + | ||
23 | + public function _initialize() | ||
24 | + { | ||
25 | + parent::_initialize(); | ||
26 | + $this->SpecModel = new SpecModel; | ||
27 | + $this->SpecValueModel = new SpecValueModel; | ||
28 | + | ||
29 | + $this->model = new \app\admin\model\Litestoregoods; | ||
30 | + $this->view->assign("specTypeList", $this->model->getSpecTypeList()); | ||
31 | + $this->view->assign("deductStockTypeList", $this->model->getDeductStockTypeList()); | ||
32 | + $this->view->assign("goodsStatusList", $this->model->getGoodsStatusList()); | ||
33 | + $this->view->assign("isDeleteList", $this->model->getIsDeleteList()); | ||
34 | + | ||
35 | + $this->view->assign("spec_attr", ''); | ||
36 | + $this->view->assign("spec_list", ''); | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
41 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
42 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
43 | + */ | ||
44 | + | ||
45 | + | ||
46 | + /** | ||
47 | + * 查看 | ||
48 | + */ | ||
49 | + public function index() | ||
50 | + { | ||
51 | + //当前是否为关联查询 | ||
52 | + $this->relationSearch = true; | ||
53 | + //设置过滤方法 | ||
54 | + $this->request->filter(['strip_tags']); | ||
55 | + if ($this->request->isAjax()) | ||
56 | + { | ||
57 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
58 | + if ($this->request->request('keyField')) | ||
59 | + { | ||
60 | + return $this->selectpage(); | ||
61 | + } | ||
62 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
63 | + $total = $this->model | ||
64 | + ->with(['category','freight']) | ||
65 | + ->where($where) | ||
66 | + ->order($sort, $order) | ||
67 | + ->count(); | ||
68 | + | ||
69 | + $list = $this->model | ||
70 | + ->with(['category','freight']) | ||
71 | + ->where($where) | ||
72 | + ->order($sort, $order) | ||
73 | + ->limit($offset, $limit) | ||
74 | + ->select(); | ||
75 | + | ||
76 | + foreach ($list as $row) { | ||
77 | + | ||
78 | + $row->getRelation('category')->visible(['name']); | ||
79 | + $row->getRelation('freight')->visible(['name']); | ||
80 | + } | ||
81 | + $list = collection($list)->toArray(); | ||
82 | + $result = array("total" => $total, "rows" => $list); | ||
83 | + | ||
84 | + return json($result); | ||
85 | + } | ||
86 | + return $this->view->fetch(); | ||
87 | + } | ||
88 | + | ||
89 | + public function addSpec($spec_name, $spec_value){ | ||
90 | + // 判断规格组是否存在 | ||
91 | + if (!$specId = $this->SpecModel->getSpecIdByName($spec_name)) { | ||
92 | + // 新增规格组and规则值 | ||
93 | + if ($this->SpecModel->add($spec_name) | ||
94 | + && $this->SpecValueModel->add($this->SpecModel['id'], $spec_value)) | ||
95 | + return $this->success('', '', [ | ||
96 | + 'spec_id' => (int)$this->SpecModel['id'], | ||
97 | + 'spec_value_id' => (int)$this->SpecValueModel['id'], | ||
98 | + ]); | ||
99 | + return $this->error(); | ||
100 | + } | ||
101 | + //return ; | ||
102 | + // 判断规格值是否存在 | ||
103 | + if ($specValueId = $this->SpecValueModel->getSpecValueIdByName($specId, $spec_value)) { | ||
104 | + return $this->success('', '', [ | ||
105 | + 'spec_id' => (int)$specId, | ||
106 | + 'spec_value_id' => (int)$specValueId, | ||
107 | + ]); | ||
108 | + } | ||
109 | + // 添加规则值 | ||
110 | + if ($this->SpecValueModel->add($specId, $spec_value)) | ||
111 | + return $this->success('', '', [ | ||
112 | + 'spec_id' => (int)$specId, | ||
113 | + 'spec_value_id' => (int)$this->SpecValueModel['id'], | ||
114 | + ]); | ||
115 | + return $this->error(); | ||
116 | + } | ||
117 | + | ||
118 | + | ||
119 | + /** | ||
120 | + * 添加规格值 | ||
121 | + */ | ||
122 | + public function addSpecValue($spec_id, $spec_value) | ||
123 | + { | ||
124 | + // 判断规格值是否存在 | ||
125 | + if ($specValueId = $this->SpecValueModel->getSpecValueIdByName($spec_id, $spec_value)) { | ||
126 | + return $this->success('', '', [ | ||
127 | + 'spec_value_id' => (int)$specValueId, | ||
128 | + ]); | ||
129 | + } | ||
130 | + // 添加规则值 | ||
131 | + if ($this->SpecValueModel->add($spec_id, $spec_value)) | ||
132 | + return $this->success('', '', [ | ||
133 | + 'spec_value_id' => (int)$this->SpecValueModel['id'], | ||
134 | + ]); | ||
135 | + return $this->error(); | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
139 | + * 添加 | ||
140 | + */ | ||
141 | + public function add() | ||
142 | + { | ||
143 | + if ($this->request->isPost()) { | ||
144 | + $params = $this->request->post("row/a"); | ||
145 | + if ($params) { | ||
146 | + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | ||
147 | + $params[$this->dataLimitField] = $this->auth->id; | ||
148 | + } | ||
149 | + try { | ||
150 | + //是否采用模型验证 | ||
151 | + if ($this->modelValidate) { | ||
152 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
153 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; | ||
154 | + $this->model->validate($validate); | ||
155 | + } | ||
156 | + $result = $this->model->allowField(true)->save($params); | ||
157 | + //\think\Log::write('hawk-1 result'.json_encode($result), \think\Log::NOTICE); | ||
158 | + if ($result !== false) { | ||
159 | + //成功之后 存储商品规格 | ||
160 | + $spec_many_params = $this->request->post("spec_many/a"); | ||
161 | + //\think\Log::write('hawk0 spec_many_params'.json_encode($spec_many_params), \think\Log::NOTICE); | ||
162 | + $this->model->addGoodsSpec($params,$spec_many_params,$this->request->post("spec/a")); | ||
163 | + $this->success(); | ||
164 | + } else { | ||
165 | + $this->error($this->model->getError()); | ||
166 | + } | ||
167 | + } catch (\think\exception\PDOException $e) { | ||
168 | + $this->error($e->getMessage()); | ||
169 | + } catch (\think\Exception $e) { | ||
170 | + $this->error($e->getMessage()); | ||
171 | + } | ||
172 | + } | ||
173 | + $this->error(__('Parameter %s can not be empty', '')); | ||
174 | + } | ||
175 | + return $this->view->fetch(); | ||
176 | + } | ||
177 | + | ||
178 | + /** | ||
179 | + * 删除 | ||
180 | + */ | ||
181 | + public function del($ids = "") | ||
182 | + { | ||
183 | + if ($ids) { | ||
184 | + $pk = $this->model->getPk(); | ||
185 | + $adminIds = $this->getDataLimitAdminIds(); | ||
186 | + if (is_array($adminIds)) { | ||
187 | + $count = $this->model->where($this->dataLimitField, 'in', $adminIds); | ||
188 | + } | ||
189 | + $list = $this->model->where($pk, 'in', $ids)->select(); | ||
190 | + $count = 0; | ||
191 | + foreach ($list as $k => $v) { | ||
192 | + // 删除商品sku | ||
193 | + $v->removesku(); | ||
194 | + | ||
195 | + $count += $v->delete(); | ||
196 | + } | ||
197 | + if ($count) { | ||
198 | + $this->success(); | ||
199 | + } else { | ||
200 | + $this->error(__('No rows were deleted')); | ||
201 | + } | ||
202 | + } | ||
203 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
204 | + } | ||
205 | + | ||
206 | + /** | ||
207 | + * 编辑 | ||
208 | + */ | ||
209 | + public function edit($ids = NULL) | ||
210 | + { | ||
211 | + $row = $this->model->get($ids, ['specRel', 'spec', 'spec_rel.spec']); | ||
212 | + if (!$row) | ||
213 | + $this->error(__('No Results were found')); | ||
214 | + $adminIds = $this->getDataLimitAdminIds(); | ||
215 | + if (is_array($adminIds)) { | ||
216 | + if (!in_array($row[$this->dataLimitField], $adminIds)) { | ||
217 | + $this->error(__('You have no permission')); | ||
218 | + } | ||
219 | + } | ||
220 | + if ($this->request->isPost()) { | ||
221 | + $params = $this->request->post("row/a"); | ||
222 | + if ($params) { | ||
223 | + try { | ||
224 | + //是否采用模型验证 | ||
225 | + if ($this->modelValidate) { | ||
226 | + $name = basename(str_replace('\\', '/', get_class($this->model))); | ||
227 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; | ||
228 | + $row->validate($validate); | ||
229 | + } | ||
230 | + $result = $row->allowField(true)->save($params); | ||
231 | + if ($result !== false) { | ||
232 | + //成功之后 存储商品规格 | ||
233 | + $spec_many_params = $this->request->post("spec_many/a"); | ||
234 | + $row->addGoodsSpec($params,$spec_many_params,$this->request->post("spec/a"), true); | ||
235 | + $this->success(); | ||
236 | + } else { | ||
237 | + $this->error($row->getError()); | ||
238 | + } | ||
239 | + } catch (\think\exception\PDOException $e) { | ||
240 | + $this->error($e->getMessage()); | ||
241 | + } catch (\think\Exception $e) { | ||
242 | + $this->error($e->getMessage()); | ||
243 | + } | ||
244 | + } | ||
245 | + $this->error(__('Parameter %s can not be empty', '')); | ||
246 | + } | ||
247 | + // 多规格信息 | ||
248 | + $specData = 'null'; | ||
249 | + if ($row['spec_type'] === '20'){ | ||
250 | + $specData = json_encode($this->model->getManySpecData($row['spec_rel'], $row['spec'])); | ||
251 | + } | ||
252 | + $row['specData'] = $specData; | ||
253 | + $this->view->assign("row", $row); | ||
254 | + return $this->view->fetch(); | ||
255 | + } | ||
256 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 首页banner | ||
9 | + * | ||
10 | + * @icon fa fa-circle-o | ||
11 | + */ | ||
12 | +class Litestorenews extends Backend | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * Litestorenews模型对象 | ||
17 | + * @var \app\admin\model\Litestorenews | ||
18 | + */ | ||
19 | + protected $model = null; | ||
20 | + | ||
21 | + public function _initialize() | ||
22 | + { | ||
23 | + parent::_initialize(); | ||
24 | + $this->model = new \app\admin\model\Litestorenews; | ||
25 | + $this->view->assign("statusList", $this->model->getStatusList()); | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
30 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
31 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
32 | + */ | ||
33 | + | ||
34 | + | ||
35 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * | ||
9 | + * | ||
10 | + * @icon fa fa-circle-o | ||
11 | + */ | ||
12 | +class Litestoreorder extends Backend | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * Litestoreorder模型对象 | ||
17 | + * @var \app\admin\model\Litestoreorder | ||
18 | + */ | ||
19 | + protected $model = null; | ||
20 | + | ||
21 | + public function _initialize() | ||
22 | + { | ||
23 | + parent::_initialize(); | ||
24 | + $this->model = new \app\admin\model\Litestoreorder; | ||
25 | + $this->view->assign("payStatusList", $this->model->getPayStatusList()); | ||
26 | + $this->view->assign("freightStatusList", $this->model->getFreightStatusList()); | ||
27 | + $this->view->assign("receiptStatusList", $this->model->getReceiptStatusList()); | ||
28 | + $this->view->assign("orderStatusList", $this->model->getOrderStatusList()); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
33 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
34 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
35 | + */ | ||
36 | + | ||
37 | + | ||
38 | + /** | ||
39 | + * 查看 | ||
40 | + */ | ||
41 | + public function index() | ||
42 | + { | ||
43 | + //当前是否为关联查询 | ||
44 | + $this->relationSearch = true; | ||
45 | + //设置过滤方法 | ||
46 | + $this->request->filter(['strip_tags']); | ||
47 | + if ($this->request->isAjax()) | ||
48 | + { | ||
49 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
50 | + if ($this->request->request('keyField')) | ||
51 | + { | ||
52 | + return $this->selectpage(); | ||
53 | + } | ||
54 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
55 | + $total = $this->model | ||
56 | + ->with(['address']) | ||
57 | + ->where($where) | ||
58 | + ->order($sort, $order) | ||
59 | + ->count(); | ||
60 | + | ||
61 | + $list = $this->model | ||
62 | + ->with(['address']) | ||
63 | + ->where($where) | ||
64 | + ->order($sort, $order) | ||
65 | + ->limit($offset, $limit) | ||
66 | + ->select(); | ||
67 | + | ||
68 | + foreach ($list as $row) { | ||
69 | + $row->visible(['id','order_no','total_price','pay_price','pay_time','express_price','freight_time','receipt_time','order_status','updatetime']); | ||
70 | + $row->visible(['address']); | ||
71 | + $row->getRelation('address')->visible(['name']); | ||
72 | + } | ||
73 | + $list = collection($list)->toArray(); | ||
74 | + $result = array("total" => $total, "rows" => $list); | ||
75 | + | ||
76 | + return json($result); | ||
77 | + } | ||
78 | + return $this->view->fetch(); | ||
79 | + } | ||
80 | + | ||
81 | + public function detail(){ | ||
82 | + if($this->request->isPost()) | ||
83 | + { | ||
84 | + $id = input('post.ids'); | ||
85 | + $row = $this->model->get($id); | ||
86 | + $row['freight_status'] = "20"; | ||
87 | + $row['freight_time'] = time(); | ||
88 | + $row['express_company'] = input('post.virtual_name'); | ||
89 | + $row['express_no'] = input('post.virtual_sn'); | ||
90 | + $row->save(); | ||
91 | + $this->success(); | ||
92 | + } | ||
93 | + | ||
94 | + $param = $this->request->param(); | ||
95 | + $row = $this->model->get($param['ids']); | ||
96 | + $this->view->assign('vo', $row); | ||
97 | + return $this->view->fetch(); | ||
98 | + } | ||
99 | +} |
1 | +<?php | ||
2 | + | ||
3 | +return [ | ||
4 | + 'Goods_id' => 'ID', | ||
5 | + 'Goods_name' => '商品名称', | ||
6 | + 'Category_id' => '商品类别', | ||
7 | + 'Images' => '商品图片', | ||
8 | + 'Spec_type' => '商品规格', | ||
9 | + 'Spec_type 10' => '单规格', | ||
10 | + 'Spec_type 20' => '多规格', | ||
11 | + 'Deduct_stock_type' => '库存计算方式', | ||
12 | + 'Deduct_stock_type 10' => '下单减库存', | ||
13 | + 'Deduct_stock_type 20' => '付款减库存', | ||
14 | + 'Content' => '描述详情', | ||
15 | + 'Sales_initial' => '初始销量', | ||
16 | + 'Sales_actual' => '实际销量', | ||
17 | + 'Goods_sort' => '权重', | ||
18 | + 'Delivery_id' => '运费模板ID', | ||
19 | + 'Goods_status' => '商品状态', | ||
20 | + 'Goods_status 10' => '上架', | ||
21 | + 'Goods_status 20' => '下架', | ||
22 | + 'Is_delete' => '是否删除', | ||
23 | + 'Is_delete 0' => '未删除', | ||
24 | + 'Is_delete 1' => '已删除', | ||
25 | + 'Createtime' => '创建时间', | ||
26 | + 'Updatetime' => '更新时间', | ||
27 | + 'Category.name' => '分类名称', | ||
28 | + 'Freight.name' => '运费模版名称' | ||
29 | +]; |
1 | +<?php | ||
2 | + | ||
3 | +return [ | ||
4 | + 'Id' => '订单ID', | ||
5 | + 'Order_no' => '订单编号', | ||
6 | + 'Total_price' => '商品金额', | ||
7 | + 'Pay_price' => '总金额(含邮费)', | ||
8 | + 'Pay_status' => '支付状态', | ||
9 | + 'Pay_status 10' => '未支付', | ||
10 | + 'Pay_status 20' => '已支付', | ||
11 | + 'Pay_time' => '支付时间', | ||
12 | + 'Express_price' => '邮费', | ||
13 | + 'Express_company' => '快递公司', | ||
14 | + 'Express_no' => '快递单号', | ||
15 | + 'Freight_status' => '发货状态', | ||
16 | + 'Freight_status 10' => '未发货', | ||
17 | + 'Freight_status 20' => '已发货', | ||
18 | + 'Freight_time' => '发货时间', | ||
19 | + 'Receipt_status' => '收货状态', | ||
20 | + 'Receipt_status 10' => '未收货', | ||
21 | + 'Receipt_status 20' => '已收货', | ||
22 | + 'Receipt_time' => '收货时间', | ||
23 | + 'Order_status' => '订单状态', | ||
24 | + 'Order_status 10' => '进行中', | ||
25 | + 'Order_status 20' => '取消', | ||
26 | + 'Order_status 30' => '已完成', | ||
27 | + 'Transaction_id' => '微信支付ID', | ||
28 | + 'User_id' => '用户ID', | ||
29 | + 'Createtime' => '生成时间', | ||
30 | + 'Updatetime' => '更新时间', | ||
31 | + 'Address.name' => '联系人', | ||
32 | + | ||
33 | + 'order detail info' => '订单信息', | ||
34 | + 'consignee user info' => '收货人信息', | ||
35 | + 'province / Region' => '省 / 市 / 区', | ||
36 | + 'AddressDetail' => '具体地址', | ||
37 | + 'mobile' => '联系电话', | ||
38 | +]; |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\model; | ||
4 | +use think\Model; | ||
5 | +use think\Cache; | ||
6 | + | ||
7 | +class Litestorearea extends Model | ||
8 | +{ | ||
9 | + // 表名 | ||
10 | + protected $name = 'area'; | ||
11 | + | ||
12 | + // 开启自动写入时间戳字段 | ||
13 | + protected $autoWriteTimestamp = false; | ||
14 | + // 定义时间戳字段名 | ||
15 | + protected $createTime = false; | ||
16 | + protected $updateTime = false; | ||
17 | + | ||
18 | + public static function getNameById($id) | ||
19 | + { | ||
20 | + $area = self::getCacheAll(); | ||
21 | + return $area[$id]['name']; | ||
22 | + } | ||
23 | + | ||
24 | + public static function getIdByName($name, $level = 0, $pid = 0) | ||
25 | + { | ||
26 | + return static::useGlobalScope(false)->where(compact('name', 'level', 'pid')) | ||
27 | + ->value('id') ?: static::add($name, $level, $pid); | ||
28 | + } | ||
29 | + | ||
30 | + private static function add($name, $level = 0, $pid = 0) | ||
31 | + { | ||
32 | + $model = new static; | ||
33 | + $model->save(compact('name', 'level', 'pid')); | ||
34 | + Cache::rm('area'); | ||
35 | + return $model->getLastInsID(); | ||
36 | + } | ||
37 | + | ||
38 | + public static function getCacheTree() | ||
39 | + { | ||
40 | + return self::areaCache()['tree']; | ||
41 | + } | ||
42 | + | ||
43 | + public static function getCacheAll() | ||
44 | + { | ||
45 | + return self::areaCache()['all']; | ||
46 | + } | ||
47 | + | ||
48 | + private static function areaCache() | ||
49 | + { | ||
50 | + if (!Cache::get('area')) { | ||
51 | + // 所有地区 | ||
52 | + $all = $allData = self::useGlobalScope(false)->column('id, pid, name, level', 'id'); | ||
53 | + // 格式化 | ||
54 | + $tree = []; | ||
55 | + foreach ($allData as $pKey => $province) { | ||
56 | + if ($province['level'] === 1) { // 省份 | ||
57 | + $tree[$province['id']] = $province; | ||
58 | + unset($allData[$pKey]); | ||
59 | + foreach ($allData as $cKey => $city) { | ||
60 | + if ($city['level'] === 2 && $city['pid'] === $province['id']) { // 城市 | ||
61 | + $tree[$province['id']]['city'][$city['id']] = $city; | ||
62 | + unset($allData[$cKey]); | ||
63 | + foreach ($allData as $rKey => $area) { | ||
64 | + if ($area['level'] === 3 && $area['pid'] === $city['id']) { // 地区 | ||
65 | + $tree[$province['id']]['city'][$city['id']]['area'][$area['id']] = $area; | ||
66 | + unset($allData[$rKey]); | ||
67 | + } | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + } | ||
72 | + } | ||
73 | + Cache::set('area', compact('all', 'tree')); | ||
74 | + } | ||
75 | + return Cache::get('area'); | ||
76 | + } | ||
77 | + | ||
78 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | + | ||
7 | +class Litestorecategory extends Model | ||
8 | +{ | ||
9 | + // 表名 | ||
10 | + protected $name = 'litestore_category'; | ||
11 | + | ||
12 | + // 自动写入时间戳字段 | ||
13 | + protected $autoWriteTimestamp = 'int'; | ||
14 | + | ||
15 | + // 定义时间戳字段名 | ||
16 | + protected $createTime = 'createtime'; | ||
17 | + protected $updateTime = 'updatetime'; | ||
18 | + | ||
19 | + // 追加属性 | ||
20 | + protected $append = [ | ||
21 | + | ||
22 | + ]; | ||
23 | + | ||
24 | + | ||
25 | + protected static function init() | ||
26 | + { | ||
27 | + self::afterInsert(function ($row) { | ||
28 | + $pk = $row->getPk(); | ||
29 | + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); | ||
30 | + }); | ||
31 | + } | ||
32 | + | ||
33 | + | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | + | ||
40 | + | ||
41 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | +use addons\litestore\litestore as litestore_add; | ||
7 | + | ||
8 | +class Litestorefreight extends Model | ||
9 | +{ | ||
10 | + // 表名 | ||
11 | + protected $name = 'litestore_freight'; | ||
12 | + | ||
13 | + // 自动写入时间戳字段 | ||
14 | + protected $autoWriteTimestamp = 'int'; | ||
15 | + | ||
16 | + // 定义时间戳字段名 | ||
17 | + protected $createTime = 'createtime'; | ||
18 | + protected $updateTime = 'updatetime'; | ||
19 | + | ||
20 | + // 追加属性 | ||
21 | + protected $append = [ | ||
22 | + 'method_text' | ||
23 | + ]; | ||
24 | + | ||
25 | + | ||
26 | + protected static function init() | ||
27 | + { | ||
28 | + self::afterInsert(function ($row) { | ||
29 | + $pk = $row->getPk(); | ||
30 | + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); | ||
31 | + }); | ||
32 | + } | ||
33 | + | ||
34 | + | ||
35 | + public function getMethodList() | ||
36 | + { | ||
37 | + return ['10' => __('Method 10'),'20' => __('Method 20')]; | ||
38 | + } | ||
39 | + | ||
40 | + | ||
41 | + public function getMethodTextAttr($value, $data) | ||
42 | + { | ||
43 | + $value = $value ? $value : (isset($data['method']) ? $data['method'] : ''); | ||
44 | + $list = $this->getMethodList(); | ||
45 | + return isset($list[$value]) ? $list[$value] : ''; | ||
46 | + } | ||
47 | + | ||
48 | + public function rule() | ||
49 | + { | ||
50 | + return $this->hasMany('Litestorefreightrule'); | ||
51 | + } | ||
52 | + | ||
53 | + public function createDeliveryRule($data) | ||
54 | + { | ||
55 | + $save = []; | ||
56 | + $connt = count($data['region']); | ||
57 | + for ($i = 0; $i < $connt; $i++) { | ||
58 | + $save[] = [ | ||
59 | + 'region' => $data['region'][$i], | ||
60 | + 'first' => $data['first'][$i], | ||
61 | + 'first_fee' => $data['first_fee'][$i], | ||
62 | + 'additional' => $data['additional'][$i], | ||
63 | + 'additional_fee' => $data['additional_fee'][$i], | ||
64 | + ]; | ||
65 | + } | ||
66 | + $this->rule()->delete(); | ||
67 | + return $this->rule()->saveAll($save); | ||
68 | + } | ||
69 | + | ||
70 | + public function detail($delivery_id) | ||
71 | + { | ||
72 | + return self::get($delivery_id, ['rule']); | ||
73 | + } | ||
74 | + | ||
75 | +} |
-
请 注册 或 登录 后发表评论