소스 검색

datasources

Alsmile 1 년 전
부모
커밋
da40dcbf25
1개의 변경된 파일19개의 추가작업 그리고 7개의 파일을 삭제
  1. 19 7
      src/views/components/Network.vue

+ 19 - 7
src/views/components/Network.vue

@@ -123,7 +123,7 @@
 
 <script lang="ts" setup>
 import { onBeforeMount, ref } from 'vue';
-
+import axios from 'axios';
 import { debounce } from '@/services/debouce';
 
 const { modelValue, mode } = defineProps<{
@@ -167,12 +167,19 @@ const httpMethodChange = (method: string) => {
   }
 };
 
-const onSave = () => {
+const onSave = async () => {
   emit('update:modelValue', modelValue);
   emit('change', modelValue);
 
+  const id = modelValue._id || modelValue.id;
+
   // 保存到我的数据源
-  // todo
+  if (id) {
+    modelValue._id = id;
+    await axios.post(`/api/data/datasources/update`, modelValue);
+  } else {
+    await axios.post(`/api/data/datasources/add`, modelValue);
+  }
 };
 
 const onInput = (text: string) => {
@@ -181,10 +188,15 @@ const onInput = (text: string) => {
 
 // 请求我的数据源接口
 const getNetworks = async () => {
-  // const ret: any = await axios.get(`/api/xxx`);
-  // if (ret) {
-  //   dataDialog.networkList = ret.list
-  // }
+  const ret: any = await axios.post(`/api/data/datasources/list`, {
+    q: {
+      name: modelValue.name,
+    },
+    projection: { updatedAt: 0 },
+  });
+  if (ret) {
+    networkList.value = ret.list;
+  }
 };
 
 const onSelect = (item: any) => {