From d0373fc87072809fa683ea929a016acd2dfa4fce Mon Sep 17 00:00:00 2001 From: PPPSCN <35696959@qq.com> Date: Tue, 17 Apr 2018 23:19:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E5=8C=96crud=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 10 ++++++---- .../admin/command/Crud/stubs/html/radio.stub | 2 +- .../admin/command/Crud/stubs/html/select.stub | 2 +- application/admin/command/Crud/stubs/index.stub | 5 +---- .../admin/command/Crud/stubs/javascript.stub | 16 ++++++++-------- .../admin/command/Crud/stubs/mixins/radio.stub | 2 +- .../admin/command/Crud/stubs/mixins/select.stub | 2 +- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index db41cedc..bcd63f5f 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -703,14 +703,16 @@ class Crud extends Command $addList = implode("\n", array_filter($addList)); $editList = implode("\n", array_filter($editList)); $javascriptList = implode(",\n", array_filter($javascriptList)); + $langList = implode(",\n", array_filter($langList)); //数组等号对齐 + $langList = array_filter(explode(",\n", $langList . ",\n")); foreach ($langList as &$line) { if (preg_match("/^\s+'([^']+)'\s*=>\s*'([^']+)'\s*/is", $line, $matches)) { $line = " '{$matches[1]}'" . str_pad('=>', ($this->fieldMaxLen - strlen($matches[1]) + 3), ' ', STR_PAD_LEFT) . " '{$matches[2]}'"; } } unset($line); - $langList = implode(",\n", array_filter($langList)) . ','; + $langList = implode(",\n", array_filter($langList)). ","; //表注释 $tableComment = $modelTableInfo['Comment']; @@ -761,7 +763,7 @@ class Crud extends Command 'relationMethodList' => '', 'controllerIndex' => '', 'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(explode(',', $fields))) . "']);" : '', - 'appendAttrList' => implode(",\n", $appendAttrList), + 'appendAttrList' => implode(",\n", $appendAttrList) . ',', 'getEnumList' => implode("\n\n", $getEnumArr), 'getAttrList' => implode("\n\n", $getAttrArr), 'setAttrList' => implode("\n\n", $setAttrArr), @@ -868,7 +870,7 @@ class Crud extends Command public function {$methodName}() { return [{$itemString}]; - } + } EOD; $controllerAssignList[] = <<view->assign("{$fieldList}", \$this->model->{$methodName}()); @@ -1047,7 +1049,7 @@ EOD; } $stringArr[] = "'" . $k . "' => " . ($is_var ? $v : "'{$v}'"); } - return implode(",", $stringArr); + return implode(", ", $stringArr); } protected function getItemArray($item, $field, $comment) diff --git a/application/admin/command/Crud/stubs/html/radio.stub b/application/admin/command/Crud/stubs/html/radio.stub index 605cc9d6..6056544a 100644 --- a/application/admin/command/Crud/stubs/html/radio.stub +++ b/application/admin/command/Crud/stubs/html/radio.stub @@ -1,4 +1,4 @@ -
+
{foreach name="{%fieldList%}" item="vo"} {/foreach} diff --git a/application/admin/command/Crud/stubs/html/select.stub b/application/admin/command/Crud/stubs/html/select.stub index f3e4552c..4ea3932d 100644 --- a/application/admin/command/Crud/stubs/html/select.stub +++ b/application/admin/command/Crud/stubs/html/select.stub @@ -1,4 +1,4 @@ - {foreach name="{%fieldList%}" item="vo"} {/foreach} diff --git a/application/admin/command/Crud/stubs/index.stub b/application/admin/command/Crud/stubs/index.stub index 288affb3..b1dd9b21 100644 --- a/application/admin/command/Crud/stubs/index.stub +++ b/application/admin/command/Crud/stubs/index.stub @@ -1,6 +1,5 @@
{:build_heading()} -
@@ -11,7 +10,6 @@ {:__('Edit')} {:__('Delete')} -
-
-
+
\ No newline at end of file diff --git a/application/admin/command/Crud/stubs/javascript.stub b/application/admin/command/Crud/stubs/javascript.stub index 0e420a20..a4de5300 100644 --- a/application/admin/command/Crud/stubs/javascript.stub +++ b/application/admin/command/Crud/stubs/javascript.stub @@ -40,14 +40,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {%javascriptList%} ] ], - //禁用默认搜索 - search: false, - //启用普通表单搜索 - commonSearch: true, - //可以控制是否默认显示搜索单表,false则隐藏,默认为false - searchFormVisible: false, - showColumns: false, - showToggle: false, + //禁用默认搜索 + search: false, + //启用普通表单搜索 + commonSearch: true, + //可以控制是否默认显示搜索单表,false则隐藏,默认为false + searchFormVisible: false, + showColumns: false, + showToggle: false, }); // 为表格绑定事件 diff --git a/application/admin/command/Crud/stubs/mixins/radio.stub b/application/admin/command/Crud/stubs/mixins/radio.stub index f5fa6e0d..027b6e20 100644 --- a/application/admin/command/Crud/stubs/mixins/radio.stub +++ b/application/admin/command/Crud/stubs/mixins/radio.stub @@ -1,6 +1,6 @@ public function {%methodName%}($value, $data) - { + { $value = $value ? $value : $data['{%field%}']; $list = $this->{%listMethodName%}(); return isset($list[$value]) ? $list[$value] : ''; diff --git a/application/admin/command/Crud/stubs/mixins/select.stub b/application/admin/command/Crud/stubs/mixins/select.stub index f5fa6e0d..027b6e20 100644 --- a/application/admin/command/Crud/stubs/mixins/select.stub +++ b/application/admin/command/Crud/stubs/mixins/select.stub @@ -1,6 +1,6 @@ public function {%methodName%}($value, $data) - { + { $value = $value ? $value : $data['{%field%}']; $list = $this->{%listMethodName%}(); return isset($list[$value]) ? $list[$value] : '';