From 4457fcfbb5af66a78cf9b1f44706fe79bddd4b62 Mon Sep 17 00:00:00 2001 From: PPPSCN <35696959@qq.com> Date: Sun, 8 Apr 2018 14:27:27 +0800 Subject: [PATCH] =?UTF-8?q?CRUD=E7=94=9F=E6=88=90=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 14 ++++++++------ .../admin/command/Crud/stubs/javascript.stub | 7 +++++++ public/assets/js/fast.js | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index ef365259..d4a5dd3a 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -696,6 +696,7 @@ class Crud extends Command //表注释 $tableComment = $modelTableInfo['Comment']; + $tableCNName = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) : $tableComment; $tableComment = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) . '管理' : $tableComment; $appNamespace = Config::get('app_namespace'); @@ -724,6 +725,7 @@ class Crud extends Command 'modelTableTypeName' => $modelTableTypeName, 'validateName' => $validateName, 'tableComment' => $tableComment, + 'tableCNName' => $tableCNName, 'iconName' => $iconName, 'pk' => $priKey, 'order' => $order, @@ -1166,11 +1168,11 @@ EOD; return << {$content} +
- {$previewcontainer} EOD; @@ -1207,7 +1209,7 @@ EOD; $html = str_repeat(" ", 24) . "{field: '{$field}{$extend}', title: __('{$lang}')"; //$formatter = $extend ? '' : $formatter; if ($extend) { - $html .= ", operate:false"; + $html .= ", operate: false"; if ($datatype == 'set') { $formatter = 'label'; } @@ -1218,21 +1220,21 @@ EOD; } unset($v); $searchList = json_encode($itemArr, JSON_FORCE_OBJECT); - $searchList = str_replace(['":"', '"}', ')","'], ['":', '}', '),"'], $searchList); + $searchList = str_replace(['":"', '"}', ')","'], ['": ', '}', '), "'], $searchList); if ($itemArr && !$extend) { $html .= ", searchList: " . $searchList; } if (in_array($datatype, ['date', 'datetime']) || $formatter === 'datetime') { - $html .= ", operate:'RANGE', addclass:'datetimerange'"; + $html .= ", operate: 'RANGE', addclass: 'datetimerange'"; } else if (in_array($datatype, ['float', 'double', 'decimal'])) { - $html .= ", operate:'BETWEEN'"; + $html .= ", operate: 'BETWEEN'"; } if ($formatter) $html .= ", formatter: Table.api.formatter." . $formatter . "}"; else $html .= "}"; if ($extend) { - $origin = str_repeat(" ", 24) . "{field: '{$field}', title: __('{$lang}'), visible:false"; + $origin = str_repeat(" ", 24) . "{field: '{$field}', title: __('{$lang}'), visible: false"; if ($searchList) { $origin .= ", searchList: " . $searchList; } diff --git a/application/admin/command/Crud/stubs/javascript.stub b/application/admin/command/Crud/stubs/javascript.stub index 1019d591..8c013cf8 100644 --- a/application/admin/command/Crud/stubs/javascript.stub +++ b/application/admin/command/Crud/stubs/javascript.stub @@ -18,6 +18,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin var table = $("#table"); var date = new Date(); + //在表格内容渲染完成后回调的事件 + table.on('post-body.bs.table', function (e, settings, json, xhr) { + $(".btn-add").data("area", ["1000px", "95%"]).data("title", '添加{%tableCNName%}'); + $(".btn-editone").data("area", ["1000px", "95%"]).data("title", '编辑{%tableCNName%}'); + $(".btn-edit").data("area", ["1000px", "95%"]).data("title", '编辑{%tableCNName%}'); + }); + // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, diff --git a/public/assets/js/fast.js b/public/assets/js/fast.js index 7c1602b4..387729d2 100644 --- a/public/assets/js/fast.js +++ b/public/assets/js/fast.js @@ -117,7 +117,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine title = options.title ? options.title : (title ? title : ""); url = Fast.api.fixurl(url); url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1"; - var area = [$(window).width() > 1000 ? '1000px' : '95%', $(window).height() > 750 ? '750px' : '95%']; + var area = [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%']; options = $.extend({ type: 2, title: title,