From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/iot/rule/data/sink/config/HttpConfigForm.vue | 86 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/src/views/iot/rule/data/sink/config/HttpConfigForm.vue b/src/views/iot/rule/data/sink/config/HttpConfigForm.vue
new file mode 100644
index 0000000..5fa759b
--- /dev/null
+++ b/src/views/iot/rule/data/sink/config/HttpConfigForm.vue
@@ -0,0 +1,86 @@
+<template>
+ <el-form-item label="璇锋眰鍦板潃" prop="config.url">
+ <el-input v-model="urlPath" placeholder="璇疯緭鍏ヨ姹傚湴鍧�">
+ <template #prepend>
+ <el-select v-model="urlPrefix" placeholder="Select" style="width: 115px">
+ <!--suppress HttpUrlsUsage -->
+ <el-option label="http://" value="http://" />
+ <el-option label="https://" value="https://" />
+ </el-select>
+ </template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="璇锋眰鏂规硶" prop="config.method">
+ <el-select v-model="config.method" placeholder="璇烽�夋嫨璇锋眰鏂规硶">
+ <el-option label="GET" value="GET" />
+ <el-option label="POST" value="POST" />
+ <el-option label="PUT" value="PUT" />
+ <el-option label="DELETE" value="DELETE" />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="璇锋眰澶�" prop="config.headers">
+ <key-value-editor v-model="config.headers" add-button-text="娣诲姞璇锋眰澶�" />
+ </el-form-item>
+ <el-form-item label="璇锋眰鍙傛暟" prop="config.query">
+ <key-value-editor v-model="config.query" add-button-text="娣诲姞鍙傛暟" />
+ </el-form-item>
+ <el-form-item label="璇锋眰浣�" prop="config.body">
+ <el-input v-model="config.body" placeholder="璇疯緭鍏ュ唴瀹�" type="textarea" />
+ </el-form-item>
+</template>
+
+<script lang="ts" setup>
+import { HttpConfig, IotDataSinkTypeEnum } from '@/api/iot/rule/data/sink'
+import { useVModel } from '@vueuse/core'
+import { isEmpty } from '@/utils/is'
+import KeyValueEditor from './components/KeyValueEditor.vue'
+
+defineOptions({ name: 'HttpConfigForm' })
+
+const props = defineProps<{
+ modelValue: any
+}>()
+const emit = defineEmits(['update:modelValue'])
+const config = useVModel(props, 'modelValue', emit) as Ref<HttpConfig>
+
+// noinspection HttpUrlsUsage
+/** URL澶勭悊 */
+const urlPrefix = ref('http://')
+const urlPath = ref('')
+const fullUrl = computed(() => {
+ return urlPath.value ? urlPrefix.value + urlPath.value : ''
+})
+
+/** 鐩戝惉 URL 鍙樺寲 */
+watch([urlPrefix, urlPath], () => {
+ config.value.url = fullUrl.value
+})
+
+/** 缁勪欢鍒濆鍖� */
+onMounted(() => {
+ if (!isEmpty(config.value)) {
+ // 鍒濆鍖� URL
+ if (config.value.url) {
+ if (config.value.url.startsWith('https://')) {
+ urlPrefix.value = 'https://'
+ urlPath.value = config.value.url.substring(8)
+ } else if (config.value.url.startsWith('http://')) {
+ urlPrefix.value = 'http://'
+ urlPath.value = config.value.url.substring(7)
+ } else {
+ urlPath.value = config.value.url
+ }
+ }
+ return
+ }
+
+ config.value = {
+ type: IotDataSinkTypeEnum.HTTP + '', // 搴忓垪鍖栨垚瀵瑰簲绫诲瀷鏃朵娇鐢�
+ url: '',
+ method: 'POST',
+ headers: {},
+ query: {},
+ body: ''
+ }
+})
+</script>
--
Gitblit v1.8.0