|
@@ -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) => {
|