Browse Source

外部服务

CzRger 5 months ago
parent
commit
fc23a64880
2 changed files with 57 additions and 25 deletions
  1. 5 0
      src/api/modules/manage/service.ts
  2. 52 25
      src/views/manage/service/detail.vue

+ 5 - 0
src/api/modules/manage/service.ts

@@ -30,3 +30,8 @@ export const outsideServiceStatusUpdate = (params: any) => handle({
   method: 'post',
   params
 })
+// 详情
+export const outsideServiceFindById = (id: any) => handle({
+  url: `/${suffix}/api/outsideService/findById/${id}`,
+  method: 'get',
+})

+ 52 - 25
src/views/manage/service/detail.vue

@@ -528,7 +528,7 @@ import {useDictionaryStore} from "@/stores";
 import {ElMessage, ElMessageBox} from "element-plus";
 import complexRequestParams from './complex-params.vue'
 import formatRuleDict from './format-rule-dict.vue'
-import {outsideServiceSaveOrUpdate} from "@/api/modules/manage/service";
+import {outsideServiceFindById, outsideServiceSaveOrUpdate} from "@/api/modules/manage/service";
 
 const emit = defineEmits(['update:show', 'refresh'])
 const {proxy} = getCurrentInstance()
@@ -753,13 +753,41 @@ const onSubmit = () => {
 }
 const initDetail = () => {
   state.loading = true
-  // sysThemeFind(props.transfer.id).then(res => {
-  //   state.form = res.data
-  //   if (state.form.themeType == '2') {
-  //     state.form.themeParam = state.form.themeParam.split(',')
-  //   }
-  //   state.loading = false
-  // })
+  outsideServiceFindById(props.transfer.id).then(res => {
+    state.form = res.data
+    if (state.form.requestParams) {
+      try {
+        const p = JSON.parse(state.form.requestParams)
+        state.params.requestParams.data = p || []
+      } catch (e) {}
+    }
+    if (state.form.requestHeaders) {
+      try {
+        const p = JSON.parse(state.form.requestHeaders)
+        state.params.requestHeaders.data = p || []
+      } catch (e) {}
+    }
+    if (state.form.requestBody) {
+      try {
+        const p = JSON.parse(state.form.requestBody)
+        state.params.requestBody.type = p.type
+        state.params.requestBody.str = p.str
+        state.params.requestBody.data = p.data || []
+      } catch (e) {}
+    }
+    if (state.form.responseBody) {
+      try {
+        const p = JSON.parse(state.form.responseBody)
+        state.params.responseBody.type = p.type
+        state.params.responseBody.json.pathForm = p.json.pathForm
+        state.params.responseBody.json.data = p.json.data || []
+        state.params.responseBody.text.data = p.text.data || []
+        state.params.responseBody.other.plug = p.other.plug
+        state.params.responseBody.other.data = p.other.data || []
+      } catch (e) {}
+    }
+    state.loading = false
+  })
 }
 const onChangeGsPlug = (val) => {
   state.form.pluginType = DictionaryStore.gsPlugObjMap.get(val)?.type
@@ -859,23 +887,22 @@ watch(() => props.show, (n) => {
   if (n) {
     state.loading = false
     initDictionary()
-    if (props.transfer.mode === 'add') {
-      state.form = {
-        requestType: 'GET'
-      }
-      state.params.tab = 1
-      state.params.requestParams.data = []
-      state.params.requestHeaders.data = []
-      state.params.requestBody.type = 'NONE'
-      state.params.requestBody.str = 'NONE'
-      state.params.requestBody.data = []
-      state.params.responseBody.type = '1'
-      state.params.responseBody.json.pathForm = {}
-      state.params.responseBody.json.data = []
-      state.params.responseBody.text.data = [{label: '', key: '', formatType: '1', formatRule: ''}]
-      state.params.responseBody.other.plug = ''
-      state.params.responseBody.other.data = []
-    } else {
+    state.params.tab = 1
+    state.form = {
+      requestType: 'GET'
+    }
+    state.params.requestParams.data = []
+    state.params.requestHeaders.data = []
+    state.params.requestBody.type = 'NONE'
+    state.params.requestBody.str = 'NONE'
+    state.params.requestBody.data = []
+    state.params.responseBody.type = '1'
+    state.params.responseBody.json.pathForm = {}
+    state.params.responseBody.json.data = []
+    state.params.responseBody.text.data = [{label: '', key: '', formatType: '1', formatRule: ''}]
+    state.params.responseBody.other.plug = ''
+    state.params.responseBody.other.data = []
+    if (props.transfer.mode !== 'add') {
       initDetail()
     }
     nextTick(() => {