mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +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'])) {
|
if (in_array($field['name'], $table['formFields'])) {
|
||||||
$this->formVueData['formFields'][] = $this->getFormField($field, $columnDict);
|
$this->formVueData['formFields'][] = $this->getFormField($field, $columnDict, $table['databaseConnection']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表格列
|
// 表格列
|
||||||
@ -653,8 +653,14 @@ class Crud extends Backend
|
|||||||
$columns[$relationField]['table']['show'] = 'false';
|
$columns[$relationField]['table']['show'] = 'false';
|
||||||
$columns[$relationField]['table']['operator'] = 'FIND_IN_SET';
|
$columns[$relationField]['table']['operator'] = 'FIND_IN_SET';
|
||||||
$columns[$relationField]['table']['comSearchRender'] = 'remoteSelect';
|
$columns[$relationField]['table']['comSearchRender'] = 'remoteSelect';
|
||||||
|
|
||||||
|
$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'] = [
|
$columns[$relationField]['table']['remote'] = [
|
||||||
'pk' => TableManager::tableName($field['form']['remote-table']) . '.' . ($field['form']['remote-pk'] ?? 'id'),
|
'pk' => $pk,
|
||||||
'field' => $field['form']['remote-field'] ?? 'name',
|
'field' => $field['form']['remote-field'] ?? 'name',
|
||||||
'remoteUrl' => $this->getRemoteSelectUrl($field),
|
'remoteUrl' => $this->getRemoteSelectUrl($field),
|
||||||
'multiple' => 'true',
|
'multiple' => 'true',
|
||||||
@ -753,7 +759,7 @@ class Crud extends Backend
|
|||||||
* 组装前台表单的数据
|
* 组装前台表单的数据
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
private function getFormField($field, $columnDict): array
|
private function getFormField($field, $columnDict, ?string $dbConnection = null): array
|
||||||
{
|
{
|
||||||
// 表单项属性
|
// 表单项属性
|
||||||
$formField = [
|
$formField = [
|
||||||
@ -771,7 +777,12 @@ class Crud extends Backend
|
|||||||
$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');
|
$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']['field'] = $field['form']['remote-field'] ?? 'name';
|
||||||
$formField[':input-attr']['remoteUrl'] = $this->getRemoteSelectUrl($field);
|
$formField[':input-attr']['remoteUrl'] = $this->getRemoteSelectUrl($field);
|
||||||
} elseif ($field['designType'] == 'number') {
|
} elseif ($field['designType'] == 'number') {
|
||||||
|
Loading…
Reference in New Issue
Block a user