nanjingliujinyu преди 4 месеца
родител
ревизия
635c4e179f
променени са 3 файла, в които са добавени 158 реда и са изтрити 67 реда
  1. 7 0
      ruoyi-ui/src/api/service/info.js
  2. 18 7
      ruoyi-ui/src/views/service/info/editModel.vue
  3. 133 60
      ruoyi-ui/src/views/service/info/index.vue

+ 7 - 0
ruoyi-ui/src/api/service/info.js

@@ -111,4 +111,11 @@ export function postReturnlist(data) {
     method: 'post',
     data:data
   });
+}
+export function testService(data) {
+  return request({
+    url: "/pt/service/testRun",
+    method: 'post',
+    data:data
+  });
 }

+ 18 - 7
ruoyi-ui/src/views/service/info/editModel.vue

@@ -231,6 +231,13 @@
                                         </div>
                                     </template>
                                 </el-table-column>
+                                <el-table-column prop="itemName" label="参数示例">
+                                      <template #default="scope">
+                                          <div style="width: 100%;">
+                                              <el-input placeholder="请填写参数示例" type="primary" class="noBor" v-model="scope.row.paramValue" size="mini" text style="margin-left: 0%;"></el-input>
+                                          </div>
+                                      </template>
+                                  </el-table-column>
                                 <el-table-column prop="itemName" label="参数说明" >
                                     <template #default="scope">
                                         <div style="width: 100%;">
@@ -541,14 +548,14 @@
                                 <el-table-column prop="itemName" label="参数字段">
                                     <template #default="scope">
                                         <div style="width: 100%;">
-                                            <el-input placeholder="请填写参数编码" type="primary" class="noBor" v-model="scope.row.parCode" size="mini" text style="margin-left: 0%;border: transparent;"></el-input>
+                                            <el-input placeholder="请填写参数编码" type="primary" class="noBor" v-model="scope.row.paramCode" size="mini" text style="margin-left: 0%;border: transparent;"></el-input>
                                         </div>
                                     </template>
                                 </el-table-column>
                                 <el-table-column prop="itemName" label="参数名称">
                                     <template #default="scope">
                                         <div style="width: 100%;">
-                                            <el-input placeholder="请填写参数名称" type="primary" class="noBor" v-model="scope.row.parName" size="mini" text style="margin-left: 0%;"></el-input>
+                                            <el-input placeholder="请填写参数名称" type="primary" class="noBor" v-model="scope.row.paramName" size="mini" text style="margin-left: 0%;"></el-input>
                                         </div>
                                     </template>
                                 </el-table-column>
@@ -581,7 +588,7 @@
                                 <el-table-column prop="itemName" label="参数说明" >
                                     <template #default="scope">
                                         <div style="width: 100%;">
-                                            <el-input type="primary" class="noBor" v-model="scope.row.parNote" size="mini" text style="margin-left: 0%;"></el-input>
+                                            <el-input type="primary" class="noBor" v-model="scope.row.paramNote" size="mini" text style="margin-left: 0%;"></el-input>
                                         </div>
                                     </template>
                                 </el-table-column>
@@ -605,7 +612,7 @@
                             </el-tab-pane>
                         </el-tabs>
                         <div style="overflow: auto;height: 20vh;margin-top: -1%;">
-                          <el-input placeholder="请输入示例" :rows="8" type="textarea" v-model="JsonAdd" size="mini" text style="margin-top: 0%;width: 98%;" ></el-input>
+                          <el-input placeholder="" :rows="8" type="textarea" v-model="JsonAdd" size="mini" text style="margin-top: 0%;width: 98%;" ></el-input>
                         </div>
                     </div>
                     <div style="margin-top: 2.5%;margin-left: 0%;padding-bottom: 1%;">
@@ -1010,6 +1017,7 @@ function addChildNode(treeData, parentId, newNode) {
 function addSiblingNode(treeData, siblingId, newNode) {
   // 1. 首先找到目标兄弟节点
   const siblingNode = findNode(treeData, siblingId, 'id');
+  console.log(siblingNode)
   if (!siblingNode) {
     console.warn(`未找到ID为 ${siblingId} 的兄弟节点`);
     return false;
@@ -1017,9 +1025,11 @@ function addSiblingNode(treeData, siblingId, newNode) {
   
   // 2. 找到兄弟节点的父节点(通过parentId查找)
   const parentNode = findNode(treeData, siblingNode.parentId, 'id');
-  if (!parentNode) {
-    console.warn(`未找到ID为 ${siblingNode.parentId} 的父节点(兄弟节点的父节点)`);
-    return false;
+  console.log(parentNode)
+  if (!parentNode&&siblingNode) {
+    newNode.id = Math.random()
+    treeData.push(newNode);
+    return true;
   }
   
   // 3. 将新节点添加到父节点的children数组中
@@ -1320,6 +1330,7 @@ async function handleNodeClick(node,data,event){
   console.log(JSON.parse(dataJsonXiang.value))
   getServiceReturn(par).then(res=>{
     const fullTree = buildTree1(res.data)
+    console.log(fullTree)
     fullTree.forEach((item,index) => {
       if(item.children && item.children.length > 0){
         item = dfsRecursive(item)

+ 133 - 60
ruoyi-ui/src/views/service/info/index.vue

@@ -111,7 +111,7 @@
         </el-table>
       </div>
       
-        <el-dialog @close="clearAdd" v-model="dialogVisible" title="" width="50%" destroy-on-close :key="tableKey">
+        <el-dialog @close="clearAdd" v-model="dialogVisible" title="" width="60%" destroy-on-close :key="tableKey">
           <div style="display: flex;align-items: center;">
             <div v-if="detailJson.rqtype==='GET'">
               <el-tag class="ml-2" type="warning">GET</el-tag>
@@ -126,6 +126,38 @@
               {{ detailJson.url }}
             </div>
           </div>
+          <el-descriptions style="margin-top: 1%;" :column="3" border>
+            <el-descriptions-item label="接口类型">{{ detailJson.type }}</el-descriptions-item>
+            <el-descriptions-item label="请求方式">{{ detailJson.rqtype }}</el-descriptions-item>
+            <el-descriptions-item label="响应类型">{{ detailJson.rptype }}</el-descriptions-item>
+            <el-descriptions-item label="服务分类">{{ detailJson.cateCode }}</el-descriptions-item>
+          </el-descriptions>
+          <div style="margin-top:4%;font-size: 18px;">
+            请求参数
+          </div>
+           <el-table 
+            style="margin-top: 1%;width: 98%;"
+            :data="tableDataCan" 
+            :cell-style="{ textAlign: 'center',padding:'2px 0' }"
+            :header-cell-style="{ textAlign: 'center'}"
+            :row-style="{ height: heightAll*0.01+'px',fontSize: '16px',textAlign:'center'  }"
+            border >
+                <el-table-column prop="paramCode" label="参数字段">
+                </el-table-column>
+                <el-table-column prop="paramName" label="参数名称">
+                </el-table-column>
+                <el-table-column prop="paramType" label="参数类型" width="200">
+                </el-table-column>
+                <el-table-column prop="paramValue" label="参数示例">
+                  
+                </el-table-column>
+                <el-table-column prop="paramNote" label="参数说明" show-overflow-tooltip>
+                </el-table-column>
+            </el-table>
+            <div style="margin-top:4%;font-size: 18px;">
+              返回参数
+            </div>
+            <el-input readonly  placeholder="" :rows="8" type="textarea" v-model="dataJsonXiang" size="mini" text style="margin-top: 1%;width: 98%;" ></el-input>
           <template #footer>
             <span class="dialog-footer">
               <el-button size="mini" @click="dialogVisible = false">取消</el-button>
@@ -135,6 +167,57 @@
             </span>
           </template>
         </el-dialog>
+        <el-dialog @close="clearAdd" v-model="dialogVisibleTest" title="" width="60%" destroy-on-close :key="tableKey">
+          <div style="display: flex;align-items: center;width: 98%;">
+            <div v-if="detailJson.rqtype==='GET'">
+              <el-tag class="ml-2" type="warning">GET</el-tag>
+            </div>
+            <div v-if="detailJson.rqtype==='POST'">
+              <el-tag class="ml-2" type="warning">POST</el-tag>
+            </div>
+            <div style="margin-left: 1%;">
+              {{ detailJson.name }}:
+            </div>
+            <div style="margin-left: 1%;">
+              {{ detailJson.url }}
+            </div>
+            <svg-icon @click="test" icon-class="startTest" style="margin-left: 1%;width: 50px;height: 25px;cursor: pointer;"/>
+          </div>
+          <div style="margin-top:2%;font-size: 18px;">
+            请求参数
+          </div>
+           <el-table 
+            style="margin-top: 1%;width: 98%;"
+            :data="tableDataCan" 
+            :cell-style="{ textAlign: 'center',padding:'2px 0' }"
+            :header-cell-style="{ textAlign: 'center'}"
+            :row-style="{ height: heightAll*0.01+'px',fontSize: '16px',textAlign:'center'  }"
+            border >
+                <el-table-column prop="paramCode" label="参数字段">
+                </el-table-column>
+                <el-table-column prop="paramName" label="参数名称">
+                </el-table-column>
+                <el-table-column prop="paramType" label="参数类型" width="200">
+                </el-table-column>
+                <el-table-column prop="paramValue" label="测试值">
+                  <template #default="scope">
+                      <div style="width: 100%;">
+                          <el-input placeholder="请填写" type="primary" class="noBor" v-model="scope.row.paramValue" size="mini" text style="margin-left: 0%;"></el-input>
+                      </div>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="paramNote" label="参数说明" show-overflow-tooltip>
+                </el-table-column>
+            </el-table>
+            <div style="margin-top:4%;font-size: 18px;">
+              返回参数
+            </div>
+            <el-input  placeholder="" :rows="8" type="textarea" v-model="dataReturn" size="mini" text style="margin-top: 1%;width: 98%;" ></el-input>
+          <template #footer>
+            <span class="dialog-footer">
+            </span>
+          </template>
+        </el-dialog>
         <el-dialog @close="clearFromLev" title="添加目录" v-model="dialogVisibleLevel" width="30%" destroy-on-close :key="tableKey">
           <el-form size="mini" :key="tableKey" style="margin-top: 1%;width: 90%;"  :model="formLev" label-position="right" ref="formRefLev" label-width="120px" :rules="rulesLev">
             <el-form-item label="名称:" prop="itemName" style="">
@@ -166,7 +249,7 @@
 import {getCatalog} from "@/api/service/catalog";
 import { Plus,Search,Filter,Promotion,Check  } from '@element-plus/icons-vue'
 import { reactive } from 'vue'
-import { modelTreeSelect,getSerDe,addService,addParam,editService,editParam,addServiceParam,delService,getTreeDe,addTree,deTree,getServiceInfo } from "@/api/service/info";
+import { modelTreeSelect,getSerDe,addService,addParam,editService,editParam,addServiceParam,delService,getTreeDe,addTree,deTree,getServiceInfo,testService } from "@/api/service/info";
 import { ref, onMounted, onUnmounted, nextTick,onBeforeMount } from 'vue';
 import JsonViewer from 'vue-json-viewer'
 import 'vue-json-viewer/style.css' 
@@ -186,7 +269,7 @@ const detail = ref({
 const show1Lev = ref(true)
 const inputNode =ref('')
 const isEdit = ref(true)
-const dataReturn = ref({})
+const dataReturn = ref('')
 const optionsCan = ref([
   {
     label:"string",
@@ -242,6 +325,7 @@ const tableDataCan = ref([
       paramNote:''
     }
 ])
+const dialogVisibleTest = ref(false)
 const optionsMdid = ref([])
 const optionsRqtype = ref([
     {label:'GET',
@@ -373,24 +457,36 @@ const filterNode = (value, data) => {
 
 const copied = ref(false);
 
+function test(){
+  var par = detailJson.value
+  par.params = tableDataCan.value
+  testService(par).then(res=>{
+    console.log(res)
+    dataReturn.value = res.msg
+  })
+}
+function testSer(row){
+  getSerDe(row.srvId).then(res=>{
+    if(res.code===200){
+      detailJson.value = res.data.ptService
+      console.log(detailJson.value)
+      dialogVisibleTest.value = true
+      tableDataCan.value = res.data.list
+    }
+  })
+}
 function showDe(row){
   getSerDe(row.srvId).then(res=>{
     if(res.code===200){
       detailJson.value = res.data.ptService
       dialogVisible.value = true
+      detailJson.value.cateCode = row.cateCode
+      detailJson.value.rptype = row.rptype
+      tableDataCan.value = res.data.list
+      dataJsonXiang.value = res.data.ptService.rpcontent
     }
   })
 }
-async function copyUrl(){
-  try {
-    await navigator.clipboard.writeText(detail.value.url);
-    copied.value = true;
-    console.log(detail.url.value,copied.value)
-    setTimeout(() => (copied.value = false), 2000); // 2秒后提示消失
-  } catch (err) {
-    console.error("复制失败", err);
-  }
-};
 function filterModelNodes(nodes) {
   if (!Array.isArray(nodes)) return [];
   
@@ -414,27 +510,9 @@ function filterModelNodes(nodes) {
   return result;
 }
 function clearAdd(){
-  formAdd.value = {
-    name:'',
-    cateCode:'',
-    type:'',
-    url:'',
-    rqtype:'',
-    rptype:'',
-    intro:'',
-    mdid:''
-  }
-  tableDataCanAdd.value = [
-    {
-      itemName:'',
-      itemCode:'',
-      paramType:'',
-      paramNote:''
-    }
+  tableDataCan.value = [
   ]
-  JsonAdd.value = ''
-  dialogVisible.value = false
-  exampleAdd.value = ''
+  dataJsonXiang.value = ''
 }
 function extractModelNodesDFSIterative(root) {
   const result = [];
@@ -519,33 +597,6 @@ async function delSer(){
     proxy.$modal.msgSuccess("删除成功");
   }).catch(() => {});
 }
-async function saveEditService(){
-  console.log(JsonAdd.value)
-  var valid
-  await formRefJi.value.validate((valid1) => {
-    valid = valid1
-  });
-  console.log(valid)
-  if(valid){
-    var par = formJi.value
-    par.example = example.value
-    par.rpcontent = dataJsonXiang.value
-    par.cateCode = par.cateCode[0]
-    console.log(par)
-    await editService(par).then(res=>{
-      if(res.code===200){
-        var parCan = tableDataCan.value
-        // parCan.srvId = parId.value.srvId
-        addServiceParam(parCan).then(res1=>{
-          if(res1.code===200){
-            proxy.$modal.msgSuccess("修改成功");
-            getTreeLeft()
-          }
-        })
-      }
-    })
-  }
-}
 async function addSer(){
   console.log(JsonAdd.value)
   var valid
@@ -605,6 +656,7 @@ async function handleNodeClick(node,data,event){
   await getServiceInfo(par).then(res=>{
     if(res.data){
       tableData.value = res.data.serviceList
+      
     }
   })
   parOptions.value.forEach(option => {
@@ -620,6 +672,27 @@ async function handleNodeClick(node,data,event){
       }
     }
   }
+  var par = [
+    {
+      value:'1',
+      label:'JSON'
+    },
+    {
+      value:'2',
+      label:'XML'
+    },
+    {
+      value:'3',
+      label:'HTML'
+    }
+  ]
+  for(var i = 0; i < par.length; i++){
+    for(var i1 = 0; i1 < tableData.value.length; i1++){
+      if(par[i].value === tableData.value[i1].rptype){
+         tableData.value[i1].rptype = par[i].label
+      }
+    }
+  }
 }
 async function getTreeLeft(){
   var par = {