Skip to content

Commit 98cb7e0

Browse files
committed
fix: 在仅需修改数据源“请求参数JSON”配置或“请求处理”相关配置时,点右上角保存有效
1 parent 59e8548 commit 98cb7e0

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

packages/plugins/datasource/src/DataSourceForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ export default {
221221
}
222222
getDataSourceName().validate(async (valid) => {
223223
if (valid) {
224+
const remoteConfig =
225+
state.dataSource.data.type === 'remote' ? settingRef.value?.getRemoteConfig?.() || {} : {}
226+
224227
const columns = state.dataSource.data.columns.map(({ name, title, type, format, field }) => {
225228
return {
226229
name,
@@ -244,15 +247,15 @@ export default {
244247
name: state.dataSource.name,
245248
data: Object.assign(state.dataSource.data, {
246249
columns,
247-
...dataSourceState.remoteConfig,
250+
...remoteConfig,
248251
data: record ? record.requestData.data.data : state.dataSource.data.data
249252
})
250253
}
251254
const addRequestData = {
252255
columns,
253256
data: record ? record.requestData.data.data : [],
254257
type: state.dataSource.data.type ? state.dataSource.data.type : 'remote',
255-
...dataSourceState.remoteConfig
258+
...remoteConfig
256259
}
257260
if (props.editable) {
258261
requestUpdateDataSource(state.dataSource.id, editRequestData).then(() => {

packages/plugins/datasource/src/DataSourceSettingRemote.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default {
6262
})
6363
}
6464
},
65-
emits: ['confirm'],
65+
emits: ['confirm', 'update:modelValue'],
6666
setup(props, { emit }) {
6767
const dataSourceRemoteAdapteRef = ref(null)
6868
@@ -141,10 +141,24 @@ export default {
141141
})
142142
}
143143
144+
const getRemoteConfig = () => {
145+
const options = { ...state.remoteData.options }
146+
147+
if (options.params) {
148+
options.params = string2Obj(options.params)
149+
}
150+
151+
return {
152+
options,
153+
...dataSourceRemoteAdapteRef.value.getEditorValue()
154+
}
155+
}
156+
144157
return {
145158
state,
146159
dataSourceRemoteAdapteRef,
147160
sendRequest,
161+
getRemoteConfig,
148162
closePanel: close
149163
}
150164
}

packages/plugins/datasource/src/DataSourceSettings.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<div>
66
<data-source-setting-remote
77
v-model="state.dataSource.data"
8+
ref="remoteRef"
89
:editable="editable"
910
@renderRemoteData="renderRemoteData"
1011
></data-source-setting-remote>
@@ -75,6 +76,7 @@ export default {
7576
setup(props, { emit }) {
7677
const { dataSourceState } = useDataSource()
7778
const recordRef = ref(null)
79+
const remoteRef = ref(null)
7880
7981
const state = reactive({
8082
dataSource: {},
@@ -88,6 +90,10 @@ export default {
8890
return recordRef.value.saveRecordList()
8991
}
9092
93+
const getRemoteConfig = () => {
94+
return remoteRef.value?.getRemoteConfig?.() || {}
95+
}
96+
9197
const changeRecord = () => {
9298
state.currentData = state.dataSource
9399
closeRemoteResult()
@@ -145,12 +151,14 @@ export default {
145151
return {
146152
state,
147153
recordRef,
154+
remoteRef,
148155
showRemote,
149156
tabClick,
150157
renderRemoteData,
151158
refresh,
152159
changeTab,
153-
saveRecord
160+
saveRecord,
161+
getRemoteConfig
154162
}
155163
}
156164
}

0 commit comments

Comments
 (0)