正在显示
2 个修改的文件
包含
17 行增加
和
15 行删除
@@ -201,7 +201,8 @@ class Crud extends Command | @@ -201,7 +201,8 @@ class Crud extends Command | ||
201 | $prefix = Config::get('database.prefix'); | 201 | $prefix = Config::get('database.prefix'); |
202 | 202 | ||
203 | //检查主表 | 203 | //检查主表 |
204 | - $tableName = $table; | 204 | + $table = stripos($table, $prefix) === 0 ? substr($table, strlen($prefix)) : $table; |
205 | + $modelTableName = $tableName = $table; | ||
205 | $modelTableType = 'table'; | 206 | $modelTableType = 'table'; |
206 | $tableInfo = Db::query("SHOW TABLE STATUS LIKE '{$tableName}'", [], TRUE); | 207 | $tableInfo = Db::query("SHOW TABLE STATUS LIKE '{$tableName}'", [], TRUE); |
207 | if (!$tableInfo) | 208 | if (!$tableInfo) |
@@ -214,21 +215,19 @@ class Crud extends Command | @@ -214,21 +215,19 @@ class Crud extends Command | ||
214 | throw new Exception("table not found"); | 215 | throw new Exception("table not found"); |
215 | } | 216 | } |
216 | } | 217 | } |
217 | - else | ||
218 | - { | ||
219 | - $table = stripos($table, $prefix) === 0 ? substr($table, strlen($prefix)) : $table; | ||
220 | - } | ||
221 | $tableInfo = $tableInfo[0]; | 218 | $tableInfo = $tableInfo[0]; |
222 | 219 | ||
220 | + $relationModelTableName = $relationTableName = $relation; | ||
223 | $relationModelTableType = 'table'; | 221 | $relationModelTableType = 'table'; |
224 | //检查关联表 | 222 | //检查关联表 |
225 | if ($relation) | 223 | if ($relation) |
226 | { | 224 | { |
227 | - $relationTableName = $prefix . $relation; | 225 | + $relation = stripos($relation, $prefix) === 0 ? substr($relation, strlen($prefix)) : $relation; |
226 | + $relationModelTableName = $relationTableName = $relation; | ||
228 | $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], TRUE); | 227 | $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], TRUE); |
229 | if (!$relationTableInfo) | 228 | if (!$relationTableInfo) |
230 | { | 229 | { |
231 | - $relationTableName = $relation; | 230 | + $relationTableName = $prefix . $relation; |
232 | $relationModelTableType = 'name'; | 231 | $relationModelTableType = 'name'; |
233 | $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], TRUE); | 232 | $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], TRUE); |
234 | if (!$relationTableInfo) | 233 | if (!$relationTableInfo) |
@@ -236,10 +235,6 @@ class Crud extends Command | @@ -236,10 +235,6 @@ class Crud extends Command | ||
236 | throw new Exception("relation table not found"); | 235 | throw new Exception("relation table not found"); |
237 | } | 236 | } |
238 | } | 237 | } |
239 | - else | ||
240 | - { | ||
241 | - $relation = stripos($relation, $prefix) === 0 ? substr($relation, strlen($prefix)) : $relation; | ||
242 | - } | ||
243 | } | 238 | } |
244 | 239 | ||
245 | //根据表名匹配对应的Fontawesome图标 | 240 | //根据表名匹配对应的Fontawesome图标 |
@@ -247,6 +242,7 @@ class Crud extends Command | @@ -247,6 +242,7 @@ class Crud extends Command | ||
247 | $iconName = is_file($iconPath) && stripos(file_get_contents($iconPath), '@fa-var-' . $table . ':') ? $table : 'fa fa-circle-o'; | 242 | $iconName = is_file($iconPath) && stripos(file_get_contents($iconPath), '@fa-var-' . $table . ':') ? $table : 'fa fa-circle-o'; |
248 | 243 | ||
249 | //控制器默认以表名进行处理,以下划线进行分隔,如果需要自定义则需要传入controller,格式为目录层级 | 244 | //控制器默认以表名进行处理,以下划线进行分隔,如果需要自定义则需要传入controller,格式为目录层级 |
245 | + $controller = str_replace('_', '', $controller); | ||
250 | $controllerArr = !$controller ? explode('_', strtolower($table)) : explode('/', strtolower($controller)); | 246 | $controllerArr = !$controller ? explode('_', strtolower($table)) : explode('/', strtolower($controller)); |
251 | $controllerUrl = implode('/', $controllerArr); | 247 | $controllerUrl = implode('/', $controllerArr); |
252 | $controllerName = ucfirst(array_pop($controllerArr)); | 248 | $controllerName = ucfirst(array_pop($controllerArr)); |
@@ -670,7 +666,6 @@ class Crud extends Command | @@ -670,7 +666,6 @@ class Crud extends Command | ||
670 | } | 666 | } |
671 | } | 667 | } |
672 | 668 | ||
673 | - | ||
674 | //JS最后一列加上操作列 | 669 | //JS最后一列加上操作列 |
675 | $javascriptList[] = str_repeat(" ", 24) . "{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}"; | 670 | $javascriptList[] = str_repeat(" ", 24) . "{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}"; |
676 | $addList = implode("\n", array_filter($addList)); | 671 | $addList = implode("\n", array_filter($addList)); |
@@ -718,9 +713,9 @@ class Crud extends Command | @@ -718,9 +713,9 @@ class Crud extends Command | ||
718 | 'modelAutoWriteTimestamp' => in_array('createtime', $fieldArr) || in_array('updatetime', $fieldArr) ? "'int'" : 'false', | 713 | 'modelAutoWriteTimestamp' => in_array('createtime', $fieldArr) || in_array('updatetime', $fieldArr) ? "'int'" : 'false', |
719 | 'createTime' => in_array('createtime', $fieldArr) ? "'createtime'" : 'false', | 714 | 'createTime' => in_array('createtime', $fieldArr) ? "'createtime'" : 'false', |
720 | 'updateTime' => in_array('updatetime', $fieldArr) ? "'updatetime'" : 'false', | 715 | 'updateTime' => in_array('updatetime', $fieldArr) ? "'updatetime'" : 'false', |
721 | - 'modelTableName' => $table, | 716 | + 'modelTableName' => $modelTableName, |
722 | 'modelTableType' => $modelTableType, | 717 | 'modelTableType' => $modelTableType, |
723 | - 'relationModelTableName' => $relation, | 718 | + 'relationModelTableName' => $relationModelTableName, |
724 | 'relationModelTableType' => $relationModelTableType, | 719 | 'relationModelTableType' => $relationModelTableType, |
725 | 'relationModelName' => $relationModelName, | 720 | 'relationModelName' => $relationModelName, |
726 | 'relationWith' => '', | 721 | 'relationWith' => '', |
@@ -13,13 +13,20 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi | @@ -13,13 +13,20 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi | ||
13 | }); | 13 | }); |
14 | e.stopPropagation(); | 14 | e.stopPropagation(); |
15 | }); | 15 | }); |
16 | - | 16 | + |
17 | //快捷搜索 | 17 | //快捷搜索 |
18 | $(".menuresult").width($("form.sidebar-form > .input-group").width()); | 18 | $(".menuresult").width($("form.sidebar-form > .input-group").width()); |
19 | + var isAndroid = /(android)/i.test(navigator.userAgent); | ||
19 | var searchResult = $(".menuresult"); | 20 | var searchResult = $(".menuresult"); |
20 | $("form.sidebar-form").on("blur", "input[name=q]", function () { | 21 | $("form.sidebar-form").on("blur", "input[name=q]", function () { |
21 | searchResult.addClass("hide"); | 22 | searchResult.addClass("hide"); |
23 | + if (isAndroid) { | ||
24 | + $.AdminLTE.options.sidebarSlimScroll = true; | ||
25 | + } | ||
22 | }).on("focus", "input[name=q]", function () { | 26 | }).on("focus", "input[name=q]", function () { |
27 | + if (isAndroid) { | ||
28 | + $.AdminLTE.options.sidebarSlimScroll = false; | ||
29 | + } | ||
23 | if ($("a", searchResult).size() > 0) { | 30 | if ($("a", searchResult).size() > 0) { |
24 | searchResult.removeClass("hide"); | 31 | searchResult.removeClass("hide"); |
25 | } | 32 | } |
-
请 注册 或 登录 后发表评论