diff --git a/.gitignore b/.gitignore index fb8818a5a07beb5be1c6b17181bd4d5cea077f94..194f5db9988e6c8a027cbe9c3bad64171d44f96a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ composer.lock *.css.map !.gitkeep .env +/.svn .vscode diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index db3b2ce223df62d815e0155f4db8cdc2f1ffc87c..67adbbce3261f75f639085bae2a5d3e791ce128b 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -115,6 +115,11 @@ class Crud extends Command */ protected $editorClass = 'editor'; + /** + * langList的key最长字节数 + */ + protected $fieldMaxLen = 0; + protected function configure() { $this @@ -324,8 +329,8 @@ class Crud extends Command $controllerUrl = strtolower(implode('/', $controllerArr)); $controllerBaseName = strtolower(implode(DS, $controllerArr)); - //视图文件 - $viewDir = $adminPath . 'view' . DS . $controllerBaseName . DS; + //视图文件 -- 如果控制器名字为驼峰形式,目录名需要转为下划线 + $viewDir = $adminPath . 'view' . DS . strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', implode(DS, $controllerArr))) . DS; //最终将生成的文件路径 $javascriptFile = ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'backend' . DS . $controllerBaseName . '.js'; @@ -482,6 +487,7 @@ class Crud extends Command //循环所有字段,开始构造视图的HTML和JS信息 foreach ($columnList as $k => $v) { $field = $v['COLUMN_NAME']; + $langField = mb_ucfirst($field); $itemArr = []; // 这里构建Enum和Set类型的列表数据 if (in_array($v['DATA_TYPE'], ['enum', 'set', 'tinyint'])) { @@ -539,6 +545,7 @@ class Crud extends Command $formEditElement = $this->getReplacedStub('html/select', ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => "\$row.{$field}"]); } else if ($inputType == 'datetime') { $cssClassArr[] = 'datetimepicker'; + $attrArr['placeholder'] = "{:__('Please select')}{:__('{$langField}')}"; $attrArr['class'] = implode(' ', $cssClassArr); $format = "YYYY-MM-DD HH:mm:ss"; $phpFormat = "Y-m-d H:i:s"; @@ -594,6 +601,7 @@ class Crud extends Command $formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => "\$row.{$field}"]); } else if ($inputType == 'textarea') { $cssClassArr[] = $this->isMatchSuffix($field, $this->editorSuffix) ? $this->editorClass : ''; + $attrArr['placeholder'] = "{:__('Please input')}{:__('{$langField}')}"; $attrArr['class'] = implode(' ', $cssClassArr); $attrArr['rows'] = 5; $formAddElement = Form::textarea($fieldName, $defaultValue, $attrArr); @@ -614,17 +622,20 @@ class Crud extends Command $formAddElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => $defaultValue, 'fieldSwitchClass' => $defaultValue == $no ? $stateNoClass : '']); $formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => "{\$row.{$field}}", 'fieldSwitchClass' => "{eq name=\"\$row.{$field}\" value=\"{$no}\"}fa-flip-horizontal text-gray{/eq}"]); } else if ($inputType == 'citypicker') { + $attrArr['placeholder'] = "{:__('Please select')}{:__('{$langField}')}"; $attrArr['class'] = implode(' ', $cssClassArr); $attrArr['data-toggle'] = "city-picker"; $formAddElement = sprintf("