refactor(CRUD):生成的表单组件代码中的 FormItem 属性优化

This commit is contained in:
妙码生花 2024-06-26 23:05:25 +08:00
parent 4fd58be9bd
commit 1faa518ad8

View File

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