正在显示
10 个修改的文件
包含
260 行增加
和
17 行删除
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 SizeTemplate extends Backend | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * StyleTemplate模型对象 | ||
17 | + * @var \app\admin\model\StyleTemplate | ||
18 | + */ | ||
19 | + protected $model = null; | ||
20 | + | ||
21 | + public function _initialize() | ||
22 | + { | ||
23 | + parent::_initialize(); | ||
24 | + $this->model = new \app\admin\model\StyleTemplate; | ||
25 | + $this->view->assign("typeList", $this->model->getTypeList()); | ||
26 | + $this->assignconfig('typeList', $this->model->getTypeList()); | ||
27 | + } | ||
28 | + | ||
29 | + public function import() | ||
30 | + { | ||
31 | + parent::import(); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
36 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
37 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
38 | + */ | ||
39 | + | ||
40 | + /** | ||
41 | + * 查看 | ||
42 | + */ | ||
43 | + public function index() | ||
44 | + { | ||
45 | + //设置过滤方法 | ||
46 | + $this->request->filter(['strip_tags']); | ||
47 | + if ($this->request->isAjax()) { | ||
48 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
49 | + if ($this->request->request('keyField')) | ||
50 | + { | ||
51 | + return $this->selectpage(); | ||
52 | + } | ||
53 | + $list = $this->model | ||
54 | + ->where('type','size') | ||
55 | + ->select(); | ||
56 | + foreach ($list as $row) { | ||
57 | + $row->visible(['id','name','type','updatetime']); | ||
58 | + } | ||
59 | + $list = collection($list)->toArray(); | ||
60 | + $result = array("total" => count($list), "rows" => $list); | ||
61 | + | ||
62 | + return json($result); | ||
63 | + } | ||
64 | + return $this->view->fetch(); | ||
65 | + } | ||
66 | +} |
@@ -50,17 +50,8 @@ class StyleTemplate extends Backend | @@ -50,17 +50,8 @@ class StyleTemplate extends Backend | ||
50 | { | 50 | { |
51 | return $this->selectpage(); | 51 | return $this->selectpage(); |
52 | } | 52 | } |
53 | - $search = $this->request->request("search"); | ||
54 | - $type = $this->request->request("type"); | ||
55 | - $where = []; | ||
56 | - if(!empty($search)){ | ||
57 | - $where['name'] = ['like','%'.$search.'%']; | ||
58 | - } | ||
59 | - if(!empty($type) && $type != 'all'){ | ||
60 | - $where['type'] = $type; | ||
61 | - } | ||
62 | $list = $this->model | 53 | $list = $this->model |
63 | - ->where($where) | 54 | + ->where('type','style') |
64 | ->select(); | 55 | ->select(); |
65 | foreach ($list as $row) { | 56 | foreach ($list as $row) { |
66 | $row->visible(['id','name','type','updatetime']); | 57 | $row->visible(['id','name','type','updatetime']); |
1 | +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + <!-- <div class="form-group"> | ||
3 | + <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label> | ||
4 | + <div class="col-xs-12 col-sm-8"> | ||
5 | + | ||
6 | + <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]"> | ||
7 | + {foreach name="typeList" item="vo"} | ||
8 | + <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option> | ||
9 | + {/foreach} | ||
10 | + </select> | ||
11 | + | ||
12 | + </div> | ||
13 | + </div> --> | ||
14 | + <input id="c-type" name="row[type]" type="hidden" value="size"> | ||
15 | + <div class="form-group"> | ||
16 | + <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | ||
17 | + <div class="col-xs-12 col-sm-8"> | ||
18 | + <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value=""> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group layer-footer"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
25 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | +</form> |
1 | +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + <!-- <div class="form-group"> | ||
3 | + <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label> | ||
4 | + <div class="col-xs-12 col-sm-8"> | ||
5 | + | ||
6 | + <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]"> | ||
7 | + {foreach name="typeList" item="vo"} | ||
8 | + <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option> | ||
9 | + {/foreach} | ||
10 | + </select> | ||
11 | + | ||
12 | + </div> | ||
13 | + </div> --> | ||
14 | + <input id="c-type" name="row[type]" type="hidden" value="size"> | ||
15 | + <div class="form-group"> | ||
16 | + <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | ||
17 | + <div class="col-xs-12 col-sm-8"> | ||
18 | + <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}"> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group layer-footer"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
25 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | +</form> |
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + <!-- <div class="panel-heading"> | ||
4 | + <ul class="nav nav-tabs"> | ||
5 | + <li class="active"><a href="#all" data-toggle="tab">{:__('All')}</a></li> | ||
6 | + {foreach name="typeList" item="vo"} | ||
7 | + <li><a href="#{$key}" data-toggle="tab">{$vo}</a></li> | ||
8 | + {/foreach} | ||
9 | + </ul> | ||
10 | + </div> --> | ||
11 | + <div class="panel-body"> | ||
12 | + <div id="myTabContent" class="tab-content"> | ||
13 | + <div class="tab-pane fade active in" id="one"> | ||
14 | + <div class="widget-body no-padding"> | ||
15 | + <div id="toolbar" class="toolbar"> | ||
16 | + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> | ||
17 | + <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('style_template/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> | ||
18 | + | ||
19 | + | ||
20 | + </div> | ||
21 | + <table id="table" class="table table-striped table-bordered table-hover table-nowrap" | ||
22 | + data-operate-edit="{:$auth->check('style_template/edit')}" | ||
23 | + data-operate-del="{:$auth->check('style_template/del')}" | ||
24 | + width="100%"> | ||
25 | + </table> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | + | ||
29 | + </div> | ||
30 | + </div> | ||
31 | +</div> |
1 | <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | 1 | <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
2 | - <div class="form-group"> | 2 | + <!-- <div class="form-group"> |
3 | <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label> | 3 | <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label> |
4 | <div class="col-xs-12 col-sm-8"> | 4 | <div class="col-xs-12 col-sm-8"> |
5 | 5 | ||
@@ -10,7 +10,8 @@ | @@ -10,7 +10,8 @@ | ||
10 | </select> | 10 | </select> |
11 | 11 | ||
12 | </div> | 12 | </div> |
13 | - </div> | 13 | + </div> --> |
14 | + <input id="c-type" name="row[type]" type="hidden" value="style"> | ||
14 | <div class="form-group"> | 15 | <div class="form-group"> |
15 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | 16 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> |
16 | <div class="col-xs-12 col-sm-8"> | 17 | <div class="col-xs-12 col-sm-8"> |
1 | <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | 1 | <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
2 | - <div class="form-group"> | 2 | + <!-- <div class="form-group"> |
3 | <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label> | 3 | <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label> |
4 | <div class="col-xs-12 col-sm-8"> | 4 | <div class="col-xs-12 col-sm-8"> |
5 | 5 | ||
@@ -10,7 +10,8 @@ | @@ -10,7 +10,8 @@ | ||
10 | </select> | 10 | </select> |
11 | 11 | ||
12 | </div> | 12 | </div> |
13 | - </div> | 13 | + </div> --> |
14 | + <input id="c-type" name="row[type]" type="hidden" value="style"> | ||
14 | <div class="form-group"> | 15 | <div class="form-group"> |
15 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | 16 | <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> |
16 | <div class="col-xs-12 col-sm-8"> | 17 | <div class="col-xs-12 col-sm-8"> |
1 | <div class="panel panel-default panel-intro"> | 1 | <div class="panel panel-default panel-intro"> |
2 | {:build_heading()} | 2 | {:build_heading()} |
3 | - <div class="panel-heading"> | 3 | + <!-- <div class="panel-heading"> |
4 | <ul class="nav nav-tabs"> | 4 | <ul class="nav nav-tabs"> |
5 | <li class="active"><a href="#all" data-toggle="tab">{:__('All')}</a></li> | 5 | <li class="active"><a href="#all" data-toggle="tab">{:__('All')}</a></li> |
6 | {foreach name="typeList" item="vo"} | 6 | {foreach name="typeList" item="vo"} |
7 | <li><a href="#{$key}" data-toggle="tab">{$vo}</a></li> | 7 | <li><a href="#{$key}" data-toggle="tab">{$vo}</a></li> |
8 | {/foreach} | 8 | {/foreach} |
9 | </ul> | 9 | </ul> |
10 | - </div> | 10 | + </div> --> |
11 | <div class="panel-body"> | 11 | <div class="panel-body"> |
12 | <div id="myTabContent" class="tab-content"> | 12 | <div id="myTabContent" class="tab-content"> |
13 | <div class="tab-pane fade active in" id="one"> | 13 | <div class="tab-pane fade active in" id="one"> |
public/assets/js/backend/size_template.js
0 → 100644
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: 'size_template/index' + location.search, | ||
9 | + add_url: 'size_template/add', | ||
10 | + edit_url: 'size_template/edit', | ||
11 | + del_url: 'size_template/del', | ||
12 | + multi_url: 'size_template/multi', | ||
13 | + import_url: 'size_template/import', | ||
14 | + table: 'style_template', | ||
15 | + } | ||
16 | + }); | ||
17 | + | ||
18 | + var table = $("#table"); | ||
19 | + | ||
20 | + // 初始化表格 | ||
21 | + table.bootstrapTable({ | ||
22 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
23 | + pk: 'id', | ||
24 | + sortName: 'id', | ||
25 | + pagination: false, | ||
26 | + commonSearch: false, | ||
27 | + search: false, | ||
28 | + columns: [ | ||
29 | + [ | ||
30 | + {checkbox: true}, | ||
31 | + {field: 'id', title: __('Id')}, | ||
32 | + {field: 'type', title: __('模板类型'), operate: false, searchList: Config.typeList, formatter: Table.api.formatter.label}, | ||
33 | + {field: 'name', title: __('Name')}, | ||
34 | + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | ||
35 | + //操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮 | ||
36 | + { | ||
37 | + field: 'operate', | ||
38 | + width: "150px", | ||
39 | + title: __('Operate'), | ||
40 | + table: table, | ||
41 | + events: Table.api.events.operate, | ||
42 | + buttons: [ | ||
43 | + { | ||
44 | + name: 'addtabs', | ||
45 | + title: __('规格列表'), | ||
46 | + classname: 'btn btn-xs btn-warning btn-addtabs', | ||
47 | + icon: 'fa fa-list', | ||
48 | + url: 'style/index?style_template_id={id}' | ||
49 | + } | ||
50 | + ], | ||
51 | + formatter: function (value, row, index) { | ||
52 | + var that = $.extend({}, this); | ||
53 | + var table = $(that.table).clone(true); | ||
54 | + if(row.type == 'size'){ | ||
55 | + $(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del | ||
56 | + } | ||
57 | + that.table = table; | ||
58 | + return Table.api.formatter.operate.call(that, value, row, index); | ||
59 | + } | ||
60 | + }, | ||
61 | + ] | ||
62 | + ] | ||
63 | + }); | ||
64 | + | ||
65 | + // 为表格绑定事件 | ||
66 | + Table.api.bindevent(table); | ||
67 | + | ||
68 | + //绑定TAB事件 | ||
69 | + $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { | ||
70 | + // var options = table.bootstrapTable(tableOptions); | ||
71 | + var typeStr = $(this).attr("href").replace('#', ''); | ||
72 | + var options = table.bootstrapTable('getOptions'); | ||
73 | + options.pageNumber = 1; | ||
74 | + options.queryParams = function (params) { | ||
75 | + // params.filter = JSON.stringify({type: typeStr}); | ||
76 | + params.type = typeStr; | ||
77 | + console.log(params); | ||
78 | + return params; | ||
79 | + }; | ||
80 | + table.bootstrapTable('refresh', {}); | ||
81 | + return false; | ||
82 | + }); | ||
83 | + }, | ||
84 | + add: function () { | ||
85 | + Controller.api.bindevent(); | ||
86 | + }, | ||
87 | + edit: function () { | ||
88 | + Controller.api.bindevent(); | ||
89 | + }, | ||
90 | + api: { | ||
91 | + bindevent: function () { | ||
92 | + Form.api.bindevent($("form[role=form]")); | ||
93 | + } | ||
94 | + } | ||
95 | + }; | ||
96 | + return Controller; | ||
97 | +}); |
@@ -42,7 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -42,7 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
42 | buttons: [ | 42 | buttons: [ |
43 | { | 43 | { |
44 | name: 'addtabs', | 44 | name: 'addtabs', |
45 | - title: __('规格列表'), | 45 | + title: __('风格列表'), |
46 | classname: 'btn btn-xs btn-warning btn-addtabs', | 46 | classname: 'btn btn-xs btn-warning btn-addtabs', |
47 | icon: 'fa fa-list', | 47 | icon: 'fa fa-list', |
48 | url: 'style/index?style_template_id={id}' | 48 | url: 'style/index?style_template_id={id}' |
-
请 注册 或 登录 后发表评论