fix(CRUD):修复字段类型为char(1)时,生成的单选框无字典数据

This commit is contained in:
妙码生花 2022-07-18 16:16:05 +08:00
parent 08b1aa0eef
commit 16cba0daeb

View File

@ -1525,19 +1525,15 @@ class Crud extends Command
/**
* 列替换数据
*/
public function getColumnReplaceData(&$column, $fieldName, $inputType)
public function getColumnReplaceData($column, $fieldName, $inputType)
{
$columnData = [];
if (in_array($column['DATA_TYPE'], ['enum', 'set', 'tinyint'])) {
if (in_array($column['DATA_TYPE'], ['enum', 'set', 'tinyint', 'char'])) {
if ($column['DATA_TYPE'] !== 'tinyint') {
$columnData = substr($column['COLUMN_TYPE'], strlen($column['DATA_TYPE']) + 1, -1);
$columnData = explode(',', str_replace("'", '', $columnData));
}
$columnData = $this->getItemArray($columnData, $fieldName, $column['COLUMN_COMMENT']);
// 如果类型为tinyint且有使用备注数据
if ($columnData && $column['DATA_TYPE'] == 'tinyint') {
$column['DATA_TYPE'] = 'enum';
}
}
if (!$columnData && in_array($inputType, ['select', 'selects'])) {
$columnData = $this->getItemArray($columnData, $fieldName, $column['COLUMN_COMMENT']);