diff --git a/ApiServer/Backend/Service/System/AutocodeService.php b/ApiServer/Backend/Service/System/AutocodeService.php index e85c4a429b56ec0295f35c1ae50524d2229db74e..5a95ab74f1152d06334a8f1703b4e366cc178d8d 100644 --- a/ApiServer/Backend/Service/System/AutocodeService.php +++ b/ApiServer/Backend/Service/System/AutocodeService.php @@ -284,7 +284,7 @@ class AutocodeService extends AbstractService foreach ($columns as $k => $column) { $row = $info; $row['key'] = $column['COLUMN_NAME']; - $row['name'] = $column['COLUMN_COMMENT'] ?: $row['key']; + $row['name'] = $this->getCommentName($column['COLUMN_COMMENT']) ?: $row['key']; $row['table'] = (bool)$this->getTableType($column); $row['table_type'] = $this->getTableType($column); $row['save'] = (bool)$this->getSaveType($column); @@ -404,7 +404,9 @@ class AutocodeService extends AbstractService protected function getSaveOption($v) { $type = $this->getSaveType($v); - if ($type == 'radio') { + if (str_contains($v['COLUMN_COMMENT'], ':') && str_contains($v['COLUMN_COMMENT'], '=')) { + return $this->getCommentJson($v['COLUMN_COMMENT']); + } elseif ($type == 'radio') { if (str_contains($v['COLUMN_TYPE'], 'enum(')) { $enum = str_replace(["enum(", ")", '"', "'"], '', $v['COLUMN_TYPE']); $enum = explode(',', $enum); @@ -492,4 +494,37 @@ class AutocodeService extends AbstractService include $path . $template . '.tpl'; return ob_get_clean(); } + + protected function getCommentName($comment = '') + { + if ($comment) { + if (str_contains($comment, ':') && str_contains($comment, '=')) { + list($commentName, $item) = explode(':', $comment); + } else { + return $comment; + } + return $commentName; + } + return false; + } + + protected function getCommentJson($comment) + { + list($commentName, $item) = explode(':', $comment); + $item = str_replace(",", ',', $item); + $arr = explode(',', $item); + $new = json_decode('{}'); + foreach ($arr as $val) { + $data = explode('=', $val); + if (sizeof($data) == 1) { + $k = $v = $data[0]; + } else { + $k = $data[0]; + $v = $data[1]; + } + $s = strval($k); + $new->$s = $v; + } + return json_encode($new, JSON_UNESCAPED_UNICODE); + } }