refactor(CRUD):多数据库支持兼容旧记录时默认值将显示为空

This commit is contained in:
妙码生花 2024-03-06 10:08:16 +08:00
parent 16c2185f67
commit b033c06d26
2 changed files with 3 additions and 5 deletions

View File

@ -307,12 +307,9 @@ class Crud extends Backend
if (!$info) {
$this->error(__('Record not found'));
}
// 需要兼容旧纪录
if(!isset($info['table']['databaseConnection'])) {
$info['table']['databaseConnection'] = config('database.default');
}
// 数据表是否有数据
$connection = TableManager::getConnection($info['table']['databaseConnection']);
$connection = TableManager::getConnection($info['table']['databaseConnection'] ?? '');
$tableName = TableManager::tableName($info['table']['name'], false, $connection);
$adapter = TableManager::phinxAdapter(true, $connection);
if ($adapter->hasTable($tableName)) {

View File

@ -1136,6 +1136,7 @@ const loadData = () => {
state.table.rebuild = 'Yes'
}
state.table.isCommonModel = parseInt(res.data.table.isCommonModel)
state.table.databaseConnection = res.data.table.databaseConnection ? res.data.table.databaseConnection : ''
const fields = res.data.fields
for (const key in fields) {
const field = handleFieldAttr(cloneDeep(fields[key]))