mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 14:41:29 +00:00
fix(CRUD):修复在多数据库场景中远程下拉组件的 pk 属性可能错误的问题
This commit is contained in:
parent
b8ce675ae8
commit
3783cd1d2f
@ -196,7 +196,7 @@ class Crud extends Backend
|
||||
|
||||
// 表单项
|
||||
if (in_array($field['name'], $table['formFields'])) {
|
||||
$this->formVueData['formFields'][] = $this->getFormField($field, $columnDict);
|
||||
$this->formVueData['formFields'][] = $this->getFormField($field, $columnDict, $table['databaseConnection']);
|
||||
}
|
||||
|
||||
// 表格列
|
||||
@ -653,13 +653,19 @@ class Crud extends Backend
|
||||
$columns[$relationField]['table']['show'] = 'false';
|
||||
$columns[$relationField]['table']['operator'] = 'FIND_IN_SET';
|
||||
$columns[$relationField]['table']['comSearchRender'] = 'remoteSelect';
|
||||
$columns[$relationField]['table']['remote'] = [
|
||||
'pk' => TableManager::tableName($field['form']['remote-table']) . '.' . ($field['form']['remote-pk'] ?? 'id'),
|
||||
|
||||
$pk = $field['form']['remote-pk'] ?? 'id';
|
||||
if (!str_contains($pk, '.')) {
|
||||
$pk = TableManager::tableName($field['form']['remote-table'], true, $table['databaseConnection']) . '.' . $pk;
|
||||
}
|
||||
|
||||
$columns[$relationField]['table']['remote'] = [
|
||||
'pk' => $pk,
|
||||
'field' => $field['form']['remote-field'] ?? 'name',
|
||||
'remoteUrl' => $this->getRemoteSelectUrl($field),
|
||||
'multiple' => 'true',
|
||||
];
|
||||
$this->indexVueData['tableColumn'][] = $this->getTableColumn($columns[$relationField], $columnDict, '', $relationFieldLangPrefix);
|
||||
$this->indexVueData['tableColumn'][] = $this->getTableColumn($columns[$relationField], $columnDict, '', $relationFieldLangPrefix);
|
||||
} else {
|
||||
$columns[$relationField]['table']['operator'] = 'LIKE';
|
||||
$this->indexVueData['tableColumn'][] = $this->getTableColumn($columns[$relationField], $columnDict, $relationFieldPrefix, $relationFieldLangPrefix);
|
||||
@ -753,7 +759,7 @@ class Crud extends Backend
|
||||
* 组装前台表单的数据
|
||||
* @throws Throwable
|
||||
*/
|
||||
private function getFormField($field, $columnDict): array
|
||||
private function getFormField($field, $columnDict, ?string $dbConnection = null): array
|
||||
{
|
||||
// 表单项属性
|
||||
$formField = [
|
||||
@ -771,7 +777,12 @@ class Crud extends Backend
|
||||
$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');
|
||||
$pk = $field['form']['remote-pk'] ?? 'id';
|
||||
if (!str_contains($pk, '.')) {
|
||||
$pk = TableManager::tableName($field['form']['remote-table'], true, $dbConnection) . '.' . $pk;
|
||||
}
|
||||
|
||||
$formField[':input-attr']['pk'] = $pk;
|
||||
$formField[':input-attr']['field'] = $field['form']['remote-field'] ?? 'name';
|
||||
$formField[':input-attr']['remoteUrl'] = $this->getRemoteSelectUrl($field);
|
||||
} elseif ($field['designType'] == 'number') {
|
||||
|
Loading…
Reference in New Issue
Block a user