fix:【iot 物联网】linter 报错
This commit is contained in:
@@ -14,8 +14,8 @@ import {
|
||||
import { getDataSinkSimpleList } from '#/api/iot/rule/data/sink';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useRuleFormSchema } from './data';
|
||||
import SourceConfigForm from './components/SourceConfigForm.vue';
|
||||
import { useRuleFormSchema } from './data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<any>();
|
||||
@@ -49,7 +49,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
|
||||
// 校验数据源配置
|
||||
await sourceConfigRef.value?.validate();
|
||||
|
||||
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as any;
|
||||
@@ -73,7 +73,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<any>();
|
||||
|
||||
|
||||
// 加载数据目的列表
|
||||
const sinkList = await getDataSinkSimpleList();
|
||||
formApi.updateSchema([
|
||||
@@ -110,7 +110,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
<Modal class="w-4/5" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
<div class="mx-4 mt-4">
|
||||
<div class="text-sm font-medium mb-2">数据源配置</div>
|
||||
<div class="mb-2 text-sm font-medium">数据源配置</div>
|
||||
<SourceConfigForm ref="sourceConfigRef" />
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
|
||||
import { Table, Select, Button, Form, FormItem } from 'ant-design-vue';
|
||||
import { Button, Form, FormItem, Select, Table } from 'ant-design-vue';
|
||||
|
||||
import { getSimpleProductList } from '#/api/iot/product/product';
|
||||
import { getSimpleDeviceList } from '#/api/iot/device/device';
|
||||
import { getSimpleProductList } from '#/api/iot/product/product';
|
||||
import { getThingModelListByProductId } from '#/api/iot/thingmodel';
|
||||
import {
|
||||
IotDeviceMessageMethodEnum,
|
||||
@@ -25,13 +25,17 @@ const formRef = ref(); // 表单 Ref
|
||||
|
||||
// 获取上行消息方法列表
|
||||
const upstreamMethods = computed(() => {
|
||||
return Object.values(IotDeviceMessageMethodEnum).filter((item) => item.upstream);
|
||||
return Object.values(IotDeviceMessageMethodEnum).filter(
|
||||
(item) => item.upstream,
|
||||
);
|
||||
});
|
||||
|
||||
/** 根据产品 ID 过滤设备 */
|
||||
const getFilteredDevices = (productId: number) => {
|
||||
if (!productId) return [];
|
||||
return deviceList.value.filter((device: any) => device.productId === productId);
|
||||
return deviceList.value.filter(
|
||||
(device: any) => device.productId === productId,
|
||||
);
|
||||
};
|
||||
|
||||
/** 判断是否需要显示标识符选择器 */
|
||||
|
||||
@@ -145,4 +145,3 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
} from '#/api/iot/rule/data';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useSinkFormSchema } from './data';
|
||||
import {
|
||||
HttpConfigForm,
|
||||
KafkaMQConfigForm,
|
||||
@@ -22,6 +21,9 @@ import {
|
||||
RedisStreamConfigForm,
|
||||
RocketMQConfigForm,
|
||||
} from './config';
|
||||
import { useSinkFormSchema } from './data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
const IotDataSinkTypeEnum = {
|
||||
HTTP: 1,
|
||||
@@ -32,7 +34,6 @@ const IotDataSinkTypeEnum = {
|
||||
REDIS_STREAM: 6,
|
||||
} as const;
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<any>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
@@ -118,7 +119,7 @@ watch(
|
||||
<Modal class="w-3/5" :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
<div v-if="formData" class="mx-4 mt-4">
|
||||
<div class="text-sm font-medium mb-2">配置信息</div>
|
||||
<div class="mb-2 text-sm font-medium">配置信息</div>
|
||||
<HttpConfigForm
|
||||
v-if="IotDataSinkTypeEnum.HTTP === formData.type"
|
||||
v-model="formData.config"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { Input, Select, FormItem } from 'ant-design-vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { FormItem, Input, Select } from 'ant-design-vue';
|
||||
|
||||
import KeyValueEditor from './components/KeyValueEditor.vue';
|
||||
|
||||
defineOptions({ name: 'HttpConfigForm' });
|
||||
@@ -33,10 +34,10 @@ onMounted(() => {
|
||||
if (config.value.url) {
|
||||
if (config.value.url.startsWith('https://')) {
|
||||
urlPrefix.value = 'https://';
|
||||
urlPath.value = config.value.url.substring(8);
|
||||
urlPath.value = config.value.url.slice(8);
|
||||
} else if (config.value.url.startsWith('http://')) {
|
||||
urlPrefix.value = 'http://';
|
||||
urlPath.value = config.value.url.substring(7);
|
||||
urlPath.value = config.value.url.slice(7);
|
||||
} else {
|
||||
urlPath.value = config.value.url;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { Input, Switch, FormItem } from 'ant-design-vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { FormItem, Input, Switch } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'KafkaMQConfigForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { Input, FormItem } from 'ant-design-vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { FormItem, Input } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'MqttConfigForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { Input, InputNumber, FormItem } from 'ant-design-vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { FormItem, Input, InputNumber } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'RabbitMQConfigForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { Input, InputNumber, FormItem } from 'ant-design-vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { FormItem, Input, InputNumber } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'RedisStreamConfigForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { Input, FormItem } from 'ant-design-vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { FormItem, Input } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'RocketMQConfigForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -1,5 +1,66 @@
|
||||
<script lang="ts" setup>
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { Delete, Plus } from '@element-plus/icons-vue';
|
||||
|
||||
defineOptions({ name: 'KeyValueEditor' });
|
||||
|
||||
const props = defineProps<{
|
||||
addButtonText: string;
|
||||
modelValue: Record<string, string>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
interface KeyValueItem {
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
const items = ref<KeyValueItem[]>([]); // 内部 key-value 项列表
|
||||
|
||||
/** 添加项目 */
|
||||
const addItem = () => {
|
||||
items.value.push({ key: '', value: '' });
|
||||
updateModelValue();
|
||||
};
|
||||
|
||||
/** 移除项目 */
|
||||
const removeItem = (index: number) => {
|
||||
items.value.splice(index, 1);
|
||||
updateModelValue();
|
||||
};
|
||||
|
||||
/** 更新 modelValue */
|
||||
const updateModelValue = () => {
|
||||
const result: Record<string, string> = {};
|
||||
items.value.forEach((item) => {
|
||||
if (item.key) {
|
||||
result[item.key] = item.value;
|
||||
}
|
||||
});
|
||||
emit('update:modelValue', result);
|
||||
};
|
||||
|
||||
/** 监听项目变化 */
|
||||
watch(items, updateModelValue, { deep: true });
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
// 列表有值后以列表中的值为准
|
||||
if (isEmpty(val) || !isEmpty(items.value)) {
|
||||
return;
|
||||
}
|
||||
items.value = Object.entries(props.modelValue).map(([key, value]) => ({
|
||||
key,
|
||||
value,
|
||||
}));
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-for="(item, index) in items" :key="index" class="flex mb-2 w-full">
|
||||
<div v-for="(item, index) in items" :key="index" class="mb-2 flex w-full">
|
||||
<el-input v-model="item.key" class="mr-2" placeholder="键" />
|
||||
<el-input v-model="item.value" placeholder="值" />
|
||||
<el-button class="ml-2" text type="danger" @click="removeItem(index)">
|
||||
@@ -16,58 +77,3 @@
|
||||
{{ addButtonText }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { Delete, Plus } from '@element-plus/icons-vue'
|
||||
import { isEmpty } from '@vben/utils'
|
||||
|
||||
defineOptions({ name: 'KeyValueEditor' })
|
||||
|
||||
interface KeyValueItem {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: Record<string, string>
|
||||
addButtonText: string
|
||||
}>()
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
const items = ref<KeyValueItem[]>([]) // 内部 key-value 项列表
|
||||
|
||||
/** 添加项目 */
|
||||
const addItem = () => {
|
||||
items.value.push({ key: '', value: '' })
|
||||
updateModelValue()
|
||||
}
|
||||
|
||||
/** 移除项目 */
|
||||
const removeItem = (index: number) => {
|
||||
items.value.splice(index, 1)
|
||||
updateModelValue()
|
||||
}
|
||||
|
||||
/** 更新 modelValue */
|
||||
const updateModelValue = () => {
|
||||
const result: Record<string, string> = {}
|
||||
items.value.forEach((item) => {
|
||||
if (item.key) {
|
||||
result[item.key] = item.value
|
||||
}
|
||||
})
|
||||
emit('update:modelValue', result)
|
||||
}
|
||||
|
||||
/** 监听项目变化 */
|
||||
watch(items, updateModelValue, { deep: true })
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
// 列表有值后以列表中的值为准
|
||||
if (isEmpty(val) || !isEmpty(items.value)) {
|
||||
return
|
||||
}
|
||||
items.value = Object.entries(props.modelValue).map(([key, value]) => ({ key, value }))
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import HttpConfigForm from './HttpConfigForm.vue'
|
||||
import MqttConfigForm from './MqttConfigForm.vue'
|
||||
import RocketMQConfigForm from './RocketMQConfigForm.vue'
|
||||
import KafkaMQConfigForm from './KafkaMQConfigForm.vue'
|
||||
import RabbitMQConfigForm from './RabbitMQConfigForm.vue'
|
||||
import RedisStreamConfigForm from './RedisStreamConfigForm.vue'
|
||||
|
||||
export {
|
||||
HttpConfigForm,
|
||||
MqttConfigForm,
|
||||
RocketMQConfigForm,
|
||||
KafkaMQConfigForm,
|
||||
RabbitMQConfigForm,
|
||||
RedisStreamConfigForm
|
||||
}
|
||||
export { default as HttpConfigForm } from './HttpConfigForm.vue';
|
||||
export { default as KafkaMQConfigForm } from './KafkaMQConfigForm.vue';
|
||||
export { default as MqttConfigForm } from './MqttConfigForm.vue';
|
||||
export { default as RabbitMQConfigForm } from './RabbitMQConfigForm.vue';
|
||||
export { default as RedisStreamConfigForm } from './RedisStreamConfigForm.vue';
|
||||
export { default as RocketMQConfigForm } from './RocketMQConfigForm.vue';
|
||||
|
||||
@@ -150,4 +150,3 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user