From db5514d27f77a6d5f607552d1a80cc9f832d1231 Mon Sep 17 00:00:00 2001 From: 100011797 <2642441182@qq.com> Date: Fri, 10 Mar 2023 16:52:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E6=B5=8B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device/instance.ts | 2 +- src/components/NormalUpload/index.vue | 113 +++++++------- .../Instance/Detail/Diagnose/Status/index.tsx | 2 +- .../device/Instance/Detail/Info/index.vue | 6 +- .../Detail/Running/Property/Indicators.vue | 4 +- .../device/Instance/Detail/Running/index.vue | 12 +- src/views/device/Instance/Detail/index.vue | 47 +++--- src/views/device/Instance/Export/index.vue | 1 - src/views/device/Instance/Process/index.vue | 142 ++++++++++-------- src/views/device/Instance/Save/index.vue | 124 ++++++++------- src/views/device/Instance/index.vue | 4 + .../rule-engine/Scene/Save/Timer/index.vue | 13 +- .../Scene/Save/action/Modal/index.vue | 9 +- .../Scene/Save/action/Notify/NotifyWay.vue | 96 ++++++++++-- .../rule-engine/Scene/Save/action/index.vue | 13 +- .../Scene/Save/components/CardSelect.vue | 128 ++++++++++++++++ 16 files changed, 474 insertions(+), 242 deletions(-) create mode 100644 src/views/rule-engine/Scene/Save/components/CardSelect.vue diff --git a/src/api/device/instance.ts b/src/api/device/instance.ts index 8fcd6d96..25208fec 100644 --- a/src/api/device/instance.ts +++ b/src/api/device/instance.ts @@ -100,7 +100,7 @@ export const deviceImport = (productId: string, fileUrl: string, autoDeploy: boo * @param type 文件类型 * @returns */ -export const deviceExport = (productId: string, type: string) => `${BASE_API_PATH}/device-instance${!!productId ? '/' + productId : ''}/export.${type}` +export const deviceExport = (productId: string, type: string) => `${BASE_API_PATH}/device-instance${!!productId ? `/${productId}` : ''}/export.${type}` /** * 验证设备ID是否重复 diff --git a/src/components/NormalUpload/index.vue b/src/components/NormalUpload/index.vue index 2e3eac41..15c365c5 100644 --- a/src/components/NormalUpload/index.vue +++ b/src/components/NormalUpload/index.vue @@ -5,7 +5,7 @@ name="file" :action="FILE_UPLOAD" :headers="{ - 'X-Access-Token': LocalStore.get(TOKEN_KEY) + 'X-Access-Token': LocalStore.get(TOKEN_KEY), }" accept=".xlsx,.csv" :maxCount="1" @@ -26,19 +26,23 @@
- - 总数量:{{count}} -

{{errMessage}}

+ + 总数量:{{ count }} +

{{ errMessage }}

\ No newline at end of file diff --git a/src/views/device/Instance/Detail/Diagnose/Status/index.tsx b/src/views/device/Instance/Detail/Diagnose/Status/index.tsx index 514b5fd5..e22f2abc 100644 --- a/src/views/device/Instance/Detail/Diagnose/Status/index.tsx +++ b/src/views/device/Instance/Detail/Diagnose/Status/index.tsx @@ -1693,7 +1693,7 @@ const Status = defineComponent({ /> )} { - bindParentVisible && ( + bindParentVisible.value && ( { diff --git a/src/views/device/Instance/Detail/Info/index.vue b/src/views/device/Instance/Detail/Info/index.vue index 73cc6ca6..178dc38f 100644 --- a/src/views/device/Instance/Detail/Info/index.vue +++ b/src/views/device/Instance/Detail/Info/index.vue @@ -25,13 +25,13 @@ instanceStore.current.deviceType?.text }} {{ - instanceStore.current.firmwareInfo?.version + instanceStore.current?.firmwareInfo?.version }} {{ - instanceStore.current?.protocolName + instanceStore.current?.transport }} {{ - instanceStore.current.transport + instanceStore.current.protocolName }} {{ instanceStore.current.createTime diff --git a/src/views/device/Instance/Detail/Running/Property/Indicators.vue b/src/views/device/Instance/Detail/Running/Property/Indicators.vue index dd05bb7f..95b6f9e7 100644 --- a/src/views/device/Instance/Detail/Running/Property/Indicators.vue +++ b/src/views/device/Instance/Detail/Running/Property/Indicators.vue @@ -109,7 +109,9 @@ const loading = ref(false); const instanceStore = useInstanceStore(); const formRef = ref(); -const modelRef = reactive({ +const modelRef = reactive<{ + metrics: any[] +}>({ metrics: [], }); diff --git a/src/views/device/Instance/Detail/Running/index.vue b/src/views/device/Instance/Detail/Running/index.vue index 34662caa..1d685cbe 100644 --- a/src/views/device/Instance/Detail/Running/index.vue +++ b/src/views/device/Instance/Detail/Running/index.vue @@ -23,11 +23,12 @@ :tab="i.tab" /> - +
- + +
@@ -97,6 +98,13 @@ const onSearch = () => { } else { tabList.value = _.cloneDeep(arr) } + const dt = tabList.value?.[0] + if (dt) { + data.value = dt + type.value = dt.type; + } else { + type.value = '' + } }; const tabChange = (key: string) => { const dt = tabList.value.find((i) => i.key === key); diff --git a/src/views/device/Instance/Detail/index.vue b/src/views/device/Instance/Detail/index.vue index 616d2067..9d339dfe 100644 --- a/src/views/device/Instance/Detail/index.vue +++ b/src/views/device/Instance/Detail/index.vue @@ -9,7 +9,9 @@
-
{{ instanceStore.current.name }}
+
+ {{ instanceStore.current.name }} +
@@ -116,8 +118,8 @@ import Function from './Function/index.vue'; import Modbus from './Modbus/index.vue'; import OPCUA from './OPCUA/index.vue'; import EdgeMap from './EdgeMap/index.vue'; -import Parsing from './Parsing/index.vue' -import Log from './Log/index.vue' +import Parsing from './Parsing/index.vue'; +import Log from './Log/index.vue'; import { _deploy, _disconnect } from '@/api/device/instance'; import { message } from 'jetlinks-ui-components'; import { getImage } from '@/utils/comm'; @@ -149,17 +151,13 @@ const list = ref([ key: 'Metadata', tab: '物模型', }, - { - key: 'Log', - tab: '日志管理', - }, { key: 'Function', tab: '设备功能', }, { - key: 'ChildDevice', - tab: '子设备', + key: 'Log', + tab: '日志管理', }, ]); @@ -174,7 +172,7 @@ const tabs = { OPCUA, EdgeMap, Parsing, - Log + Log, }; const getStatus = (id: string) => { @@ -255,6 +253,17 @@ watchEffect(() => { tab: '设备诊断', }); } + if ( + instanceStore.current.features?.find( + (item: any) => item.id === 'transparentCodec', + ) && + !keys.includes('Parsing') + ) { + list.value.push({ + key: 'Parsing', + tab: '数据解析', + }); + } if ( instanceStore.current.protocol === 'modbus-tcp' && !keys.includes('Modbus') @@ -273,6 +282,13 @@ watchEffect(() => { tab: 'OPC UA', }); } + if (instanceStore.current.deviceType?.value === 'gateway') { + // 产品类型为网关的情况下才显示此模块 + list.value.push({ + key: 'ChildDevice', + tab: '子设备', + }); + } if ( instanceStore.current.accessProvider === 'edge-child-device' && instanceStore.current.parentId && @@ -283,15 +299,6 @@ watchEffect(() => { tab: '边缘端映射', }); } - if ( - instanceStore.current.features?.find((item: any) => item.id === 'transparentCodec') && - !keys.includes('Parsing') - ) { - list.value.push({ - key: 'Parsing', - tab: '数据解析', - }); - } }); onUnmounted(() => { diff --git a/src/views/device/Instance/Export/index.vue b/src/views/device/Instance/Export/index.vue index 1b422fde..1a14d9dd 100644 --- a/src/views/device/Instance/Export/index.vue +++ b/src/views/device/Instance/Export/index.vue @@ -51,7 +51,6 @@ import { queryNoPagingPost } from '@/api/device/product'; import { downloadFile } from '@/utils/utils'; import encodeQuery from '@/utils/encodeQuery'; -import { BASE_API_PATH } from '@/utils/variable'; import { deviceExport } from '@/api/device/instance'; const emit = defineEmits(['close']); diff --git a/src/views/device/Instance/Process/index.vue b/src/views/device/Instance/Process/index.vue index 05b405ac..784f6554 100644 --- a/src/views/device/Instance/Process/index.vue +++ b/src/views/device/Instance/Process/index.vue @@ -1,92 +1,106 @@ \ No newline at end of file diff --git a/src/views/device/Instance/Save/index.vue b/src/views/device/Instance/Save/index.vue index 76f5549e..f1ef6769 100644 --- a/src/views/device/Instance/Save/index.vue +++ b/src/views/device/Instance/Save/index.vue @@ -9,12 +9,7 @@ :confirmLoading="loading" >
- + @@ -22,14 +17,33 @@ - + @@ -39,7 +53,20 @@ :disabled="!!data?.id" /> - + - + @@ -68,10 +105,20 @@ v-for="item in productList" :key="item.id" :label="item.name" - >{{item.name}} + >{{ item.name }} - + , value: string) => { } }; -const rules = { - name: [ - { - required: true, - message: '请输入名称', - }, - { - max: 64, - message: '最多输入64个字符', - }, - ], - photoUrl: [ - { - required: true, - message: '请上传图标', - }, - ], - productId: [ - { - required: true, - message: '请选择所属产品', - }, - ], - id: [ - { - max: 64, - message: '最多输入64个字符', - }, - { - pattern: /^[j-zA-Z0-9_\-]+$/, - message: '请输入英文或者数字或者-或者_', - }, - { - validator: vailId, - trigger: 'blur', - }, - ], -}; - watch( () => props.data, (newValue) => { @@ -199,13 +207,13 @@ const handleSave = () => { .validate() .then(async (_data: any) => { loading.value = true; - const obj = {...toRaw(modelRef), ..._data} - if(!obj.id){ - delete obj.id + const obj = { ..._data }; + if (!obj.id) { + delete obj.id; } const resp = await update(obj).finally(() => { loading.value = false; - }) + }); if (resp.status === 200) { message.success('操作成功!'); emit('save'); diff --git a/src/views/device/Instance/index.vue b/src/views/device/Instance/index.vue index 5acf8604..f40fb78e 100644 --- a/src/views/device/Instance/index.vue +++ b/src/views/device/Instance/index.vue @@ -252,6 +252,7 @@ @close="operationVisible = false" :api="api" :type="type" + @save="onRefresh" /> new Promise((resolve) => { getProviders().then((resp: any) => { diff --git a/src/views/rule-engine/Scene/Save/Timer/index.vue b/src/views/rule-engine/Scene/Save/Timer/index.vue index 55646c35..de0a67d1 100644 --- a/src/views/rule-engine/Scene/Save/Timer/index.vue +++ b/src/views/rule-engine/Scene/Save/Timer/index.vue @@ -13,17 +13,16 @@ import { useSceneStore } from '@/store/scene'; import Action from '../action/index.vue'; import { storeToRefs } from 'pinia'; -import { ActionsType } from '@/components/Table'; +import { ActionsType } from '@/views/rule-engine/Scene/typings'; const sceneStore = useSceneStore(); const { data } = storeToRefs(sceneStore); -const onActionAdd = (_data: ActionsType) => { - console.log(_data) - // if (data?.branches && _data) { - // const newThen = [...data?.branches?.[0].then, data]; - // data.branches[0].then = newThen; - // } +const onActionAdd = (_data: any) => { + if (data.value?.branches && _data) { + data?.value.branches?.[0].then.push(_data) + console.log(data?.value.branches?.[0].then) + } }; const onActionUpdate = (_data: ActionsType, type: boolean) => { diff --git a/src/views/rule-engine/Scene/Save/action/Modal/index.vue b/src/views/rule-engine/Scene/Save/action/Modal/index.vue index 52b0aa4a..1b9da241 100644 --- a/src/views/rule-engine/Scene/Save/action/Modal/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Modal/index.vue @@ -18,13 +18,7 @@ }, ]" > - - + - - +
+
+
+ +
+
{{item.label}}
+
+
@@ -26,9 +34,13 @@ const props = defineProps({ type: String, default: '', }, + disabled: { + type: Boolean, + default: false, + }, }); -const emit = defineEmits(['update:value']) +const emit = defineEmits(['update:value']); const loading = ref(false); const notifyType = ref(''); @@ -37,17 +49,19 @@ const options = ref([]); watch( () => props.value, (newVal) => { - notifyType.value = newVal + notifyType.value = newVal; }, { deep: true, immediate: true }, ); -const onRadioChange = (e: any) => { - emit('update:value', e.target.value) -} +const onSelect = (val: string) => { + if (!props.disabled) { + emit('update:value', val); + } +}; onMounted(() => { - loading.value = true + loading.value = true; notice.queryMessageType().then((resp) => { if (resp.status === 200) { options.value = (resp.result as any[]).map((item) => { @@ -58,11 +72,65 @@ onMounted(() => { }; }); } - loading.value = false + loading.value = false; }); - notifyType.value = props.value + notifyType.value = props.value; }); \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/index.vue b/src/views/rule-engine/Scene/Save/action/index.vue index 0f2cf3e7..230fe39d 100644 --- a/src/views/rule-engine/Scene/Save/action/index.vue +++ b/src/views/rule-engine/Scene/Save/action/index.vue @@ -26,7 +26,7 @@ :actions=" serialArray.length ? serialArray[0].actions : [] " - @add="onAdd" + @add="(_item) => onAdd(_item, false)" @delete="onDelete" />
@@ -50,7 +50,7 @@ ? parallelArray[0].actions : [] " - @add="onAdd" + @add="(_item) => onAdd(_item, true)" @delete="onDelete" />
@@ -98,6 +98,8 @@ watch( parallelArray.value = newVal.filter((item) => item.parallel); serialArray.value = newVal.filter((item) => !item.parallel); + console.log(parallelArray.value, serialArray.value, '123') + const isSerialActions = serialArray.value.some((item) => { return !!item.actions.length; }); @@ -128,7 +130,7 @@ const onDelete = (_key: string) => { emit('update', serialArray[0], false); } }; -const onAdd = (actionItem: any) => { +const onAdd = (actionItem: any, _parallel: boolean) => { const newParallelArray = [...parallelArray.value]; if (newParallelArray.length) { const indexOf = newParallelArray[0].actions?.findIndex( @@ -140,12 +142,11 @@ const onAdd = (actionItem: any) => { newParallelArray[0].actions.push(actionItem); } parallelArray.value = [...newParallelArray]; - console.log(parallelArray.value); - emit('update', newParallelArray[0], true); + emit('update', newParallelArray[0], _parallel); } else { actionItem.key = randomString(); emit('add', { - parallel: true, + parallel: _parallel, key: randomString(), actions: [actionItem], }); diff --git a/src/views/rule-engine/Scene/Save/components/CardSelect.vue b/src/views/rule-engine/Scene/Save/components/CardSelect.vue new file mode 100644 index 00000000..17228c11 --- /dev/null +++ b/src/views/rule-engine/Scene/Save/components/CardSelect.vue @@ -0,0 +1,128 @@ + + + + + \ No newline at end of file