Skip to content

Commit

Permalink
refactor(CRUD):生成的表单组件代码中的 FormItem 属性优化
Browse files Browse the repository at this point in the history
  • Loading branch information
build-admin committed Jun 26, 2024
1 parent 4fd58be commit 1faa518
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/admin/controller/crud/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,17 +765,15 @@ private function getFormField($field, $columnDict): array

// 不同输入框的属性处理
if ($columnDict || in_array($field['designType'], ['radio', 'checkbox', 'select', 'selects'])) {
$formField[':data'] = [
'content' => $columnDict,
];
$formField[':input-attr']['content'] = $columnDict;
} elseif ($field['designType'] == 'textarea') {
$formField[':input-attr']['rows'] = (int)($field['form']['rows'] ?? 3);
$formField['@keyup.enter.stop'] = '';
$formField['@keyup.ctrl.enter'] = 'baTable.onSubmit(formRef)';
} elseif ($field['designType'] == 'remoteSelect' || $field['designType'] == 'remoteSelects') {
$formField[':input-attr']['pk'] = TableManager::tableName($field['form']['remote-table']) . '.' . ($field['form']['remote-pk'] ?? 'id');
$formField[':input-attr']['field'] = $field['form']['remote-field'] ?? 'name';
$formField[':input-attr']['remote-url'] = $this->getRemoteSelectUrl($field);
$formField[':input-attr']['pk'] = TableManager::tableName($field['form']['remote-table']) . '.' . ($field['form']['remote-pk'] ?? 'id');
$formField[':input-attr']['field'] = $field['form']['remote-field'] ?? 'name';
$formField[':input-attr']['remoteUrl'] = $this->getRemoteSelectUrl($field);
} elseif ($field['designType'] == 'number') {
$formField[':input-attr']['step'] = (int)($field['form']['step'] ?? 1);
$formField['v-model.number'] = $formField['v-model'];
Expand Down

0 comments on commit 1faa518

Please sign in to comment.