Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/plugins/datasource/src/DataSourceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ export default {
}
getDataSourceName().validate(async (valid) => {
if (valid) {
const remoteConfig =
state.dataSource.data.type === 'remote' ? settingRef.value?.getRemoteConfig?.() || {} : {}

const columns = state.dataSource.data.columns.map(({ name, title, type, format, field }) => {
return {
name,
Expand All @@ -244,15 +247,15 @@ export default {
name: state.dataSource.name,
data: Object.assign(state.dataSource.data, {
columns,
...dataSourceState.remoteConfig,
...remoteConfig,
data: record ? record.requestData.data.data : state.dataSource.data.data
})
}
const addRequestData = {
columns,
data: record ? record.requestData.data.data : [],
type: state.dataSource.data.type ? state.dataSource.data.type : 'remote',
...dataSourceState.remoteConfig
...remoteConfig
}
if (props.editable) {
requestUpdateDataSource(state.dataSource.id, editRequestData).then(() => {
Expand Down
16 changes: 15 additions & 1 deletion packages/plugins/datasource/src/DataSourceSettingRemote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
})
}
},
emits: ['confirm'],
emits: ['confirm', 'update:modelValue'],
setup(props, { emit }) {
const dataSourceRemoteAdapteRef = ref(null)

Expand Down Expand Up @@ -141,10 +141,24 @@ export default {
})
}

const getRemoteConfig = () => {
const options = { ...state.remoteData.options }

if (options.params) {
options.params = string2Obj(options.params)
}

return {
options,
...dataSourceRemoteAdapteRef.value.getEditorValue()
}
}

return {
state,
dataSourceRemoteAdapteRef,
sendRequest,
getRemoteConfig,
closePanel: close
}
}
Expand Down
10 changes: 9 additions & 1 deletion packages/plugins/datasource/src/DataSourceSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<div>
<data-source-setting-remote
v-model="state.dataSource.data"
ref="remoteRef"
:editable="editable"
@renderRemoteData="renderRemoteData"
></data-source-setting-remote>
Expand Down Expand Up @@ -75,6 +76,7 @@ export default {
setup(props, { emit }) {
const { dataSourceState } = useDataSource()
const recordRef = ref(null)
const remoteRef = ref(null)

const state = reactive({
dataSource: {},
Expand All @@ -88,6 +90,10 @@ export default {
return recordRef.value.saveRecordList()
}

const getRemoteConfig = () => {
return remoteRef.value?.getRemoteConfig?.() || {}
}

const changeRecord = () => {
state.currentData = state.dataSource
closeRemoteResult()
Expand Down Expand Up @@ -145,12 +151,14 @@ export default {
return {
state,
recordRef,
remoteRef,
showRemote,
tabClick,
renderRemoteData,
refresh,
changeTab,
saveRecord
saveRecord,
getRemoteConfig
}
}
}
Expand Down
Loading