From 20dea7cb5bc5a4736058adaab33733478dfa91f4 Mon Sep 17 00:00:00 2001 From: Karson Date: Tue, 20 Jun 2023 10:10:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96CRUD=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit a40420b8cd122a79f597462797de30859950a3d8) --- application/admin/command/Crud.php | 10 ++++++++-- .../admin/command/Crud/stubs/html/multiple-html.stub | 8 ++++++++ application/admin/command/Crud/stubs/index.stub | 8 +------- application/admin/lang/zh-cn.php | 2 ++ 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 application/admin/command/Crud/stubs/html/multiple-html.stub diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index d66f3229..3845fa4c 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -712,6 +712,7 @@ class Crud extends Command $headingHtml = '{:build_heading()}'; $controllerImport = ''; $importHtml = ''; + $multipleHtml = ''; $recyclebinHtml = ''; if ($import) { @@ -996,6 +997,7 @@ class Crud extends Command } if ($this->headingFilterField && $this->headingFilterField == $field && $itemArr) { $headingHtml = $this->getReplacedStub('html/heading-html', ['field' => $field, 'fieldName' => Loader::parseName($field, 1, false)]); + $multipleHtml = $this->getReplacedStub('html/multiple-html', ['field' => $field, 'fieldName' => Loader::parseName($field, 1, false), 'controllerUrl' => $controllerUrl]); } //排序方式,如果有指定排序字段,否则按主键排序 $order = $field == $this->sortField ? $this->sortField : $order; @@ -1119,6 +1121,7 @@ class Crud extends Command 'controllerIndex' => '', 'recyclebinJs' => '', 'headingHtml' => $headingHtml, + 'multipleHtml' => $multipleHtml, 'importHtml' => $importHtml, 'recyclebinHtml' => $recyclebinHtml, 'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(in_array($priKey, explode(',', $fields)) ? explode(',', $fields) : explode(',', $priKey . ',' . $fields))) . "']);" : '', @@ -1466,7 +1469,7 @@ EOD; if ($content || !Lang::has($field)) { $this->fieldMaxLen = strlen($field) > $this->fieldMaxLen ? strlen($field) : $this->fieldMaxLen; $content = str_replace(',', ',', $content); - if (stripos($content, ':') !== false && stripos($content, ',') && stripos($content, '=') !== false) { + if (stripos($content, ':') !== false && stripos($content, '=') !== false) { list($fieldLang, $item) = explode(':', $content); $itemArr = [$field => $fieldLang]; foreach (explode(',', $item) as $k => $v) { @@ -1474,6 +1477,9 @@ EOD; if (count($valArr) == 2) { list($key, $value) = $valArr; $itemArr[$field . ' ' . $key] = $value; + if ($this->headingFilterField == $field) { + $itemArr['Set ' . $field . ' to ' . $key] = '设为' . $value; + } $this->fieldMaxLen = strlen($field . ' ' . $key) > $this->fieldMaxLen ? strlen($field . ' ' . $key) : $this->fieldMaxLen; } } @@ -1549,7 +1555,7 @@ EOD; return $itemArr; } - protected function getFieldType(& $v) + protected function getFieldType(&$v) { $inputType = 'text'; switch ($v['DATA_TYPE']) { diff --git a/application/admin/command/Crud/stubs/html/multiple-html.stub b/application/admin/command/Crud/stubs/html/multiple-html.stub new file mode 100644 index 00000000..0bdbba70 --- /dev/null +++ b/application/admin/command/Crud/stubs/html/multiple-html.stub @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/application/admin/command/Crud/stubs/index.stub b/application/admin/command/Crud/stubs/index.stub index 7fea21f5..cbde67ed 100644 --- a/application/admin/command/Crud/stubs/index.stub +++ b/application/admin/command/Crud/stubs/index.stub @@ -12,13 +12,7 @@ {:__('Delete')} {%importHtml%} - + {%multipleHtml%} {%recyclebinHtml%} diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index 03389e27..f2a7efd9 100755 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -124,6 +124,8 @@ return [ '%d year%s after' => '%d年后', 'Set to normal' => '设为正常', 'Set to hidden' => '设为隐藏', + 'Set status to normal' => '设为正常', + 'Set status to hidden' => '设为隐藏', 'Recycle bin' => '回收站', 'Restore' => '还原', 'Restore all' => '还原全部',