Skip to content

Commit f931769

Browse files
author
liux
committed
feat: 表格列默认值处理
1 parent 959db47 commit f931769

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

app/command/Md2c.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ protected function field2col($field, $index, $entity)
180180
'value_type' => 'text',
181181
'title' => $field['defName'],
182182
'tip' => $field['comment'],
183+
'default_value' => trim($field['defaultValue'], "'"),
183184
'hide_in_table' => $field['hideInGraph'] ? 1 : 0,
184185
'hide_in_form' => ($field['hideInGraph'] || $field['primaryKey']) ? 1 : 0,
185186
'sort' => $index

app/controller/admin/Table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public function read($name)
144144
return $this->success($table->visible([
145145
'code', 'name', 'props', 'options', 'status', 'create_time',
146146
'cols' => ['data_index', 'value_type', 'value_enum_dict_key', 'title', 'tip',
147+
'required', 'default_value', 'validator',
147148
'ellipsis', 'copyable', 'filters', 'col_size',
148149
'hide_in_search', 'hide_in_table', 'hide_in_form', 'hide_in_descriptions']
149150
])->toArray());

app/model/Col.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public function getFormilySchemaAttr($value, $data)
8888
'x-component' => $mapComponent[$data['value_type']] ?? 'Input',
8989
];
9090
!empty($data['required']) && $schema['required'] = true;
91+
$data['default_value'] != '' && $schema['default'] = is_numeric($data['default_value']) ? $data['default_value'] + 0 : $data['default_value'];
9192
!empty($data['value_enum_dict_key']) && $schema['enum'] = array_map(
9293
fn($key, $value) => ['value' => $key, 'label' => $value],
9394
array_keys(system_dict($data['value_enum_dict_key'])),

0 commit comments

Comments
 (0)