|
|
@@ -9,7 +9,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import ModelObjectSelector from './components/ModelObjectSelector.vue'
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
import { getApiById } from '@/api/paas/apiApi'
|
|
|
-import { deleteAtuById, getAtuByList } from '@/api/paas/apiTransUnitApi'
|
|
|
+import { deleteAtuById, generateParamsByCode, getAtuByList } from '@/api/paas/apiTransUnitApi'
|
|
|
import { createX, deleteX, getX, patchX, updateX } from '@/api/paas/apiGatewayApi'
|
|
|
|
|
|
const settingsStore = useSettingsStore()
|
|
|
@@ -79,29 +79,34 @@ const onDelete = (data: { apiId: number; atuId: number; objectTitle: string }) =
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const onGenerateParams = () => {
|
|
|
- state.result = '生成参数'
|
|
|
+const onGenerateParams = async () => {
|
|
|
+ const { data } = await generateParamsByCode(state.apiCode)
|
|
|
+ state.data = JSON.stringify(data)
|
|
|
}
|
|
|
|
|
|
const onExecute = async () => {
|
|
|
- const apiType = state.apiType
|
|
|
- const apiCode = state.apiCode
|
|
|
- const params = {}
|
|
|
-
|
|
|
- if (apiType === 1) {
|
|
|
- await getX(apiCode, params)
|
|
|
- }
|
|
|
- else if (apiType === 2) {
|
|
|
- await createX(apiCode, params)
|
|
|
- }
|
|
|
- else if (apiType === 3) {
|
|
|
- await updateX(apiCode, params)
|
|
|
- }
|
|
|
- else if (apiType === 4) {
|
|
|
- await patchX(apiCode, params)
|
|
|
+ try {
|
|
|
+ const apiType = state.apiType
|
|
|
+ const apiCode = state.apiCode
|
|
|
+ const params = JSON.parse(state.data)
|
|
|
+ if (apiType === 1) {
|
|
|
+ await getX(apiCode, params)
|
|
|
+ }
|
|
|
+ else if (apiType === 2) {
|
|
|
+ await createX(apiCode, params)
|
|
|
+ }
|
|
|
+ else if (apiType === 3) {
|
|
|
+ await updateX(apiCode, params)
|
|
|
+ }
|
|
|
+ else if (apiType === 4) {
|
|
|
+ await patchX(apiCode, params)
|
|
|
+ }
|
|
|
+ else if (apiType === 5) {
|
|
|
+ await deleteX(apiCode, params)
|
|
|
+ }
|
|
|
}
|
|
|
- else if (apiType === 5) {
|
|
|
- await deleteX(apiCode, params)
|
|
|
+ catch (err) {
|
|
|
+ ElMessage.error('提交失败')
|
|
|
}
|
|
|
}
|
|
|
// 选择对象模型回调
|