diff --git a/src/api/device/instance.ts b/src/api/device/instance.ts index 11b27733..a4f189fd 100644 --- a/src/api/device/instance.ts +++ b/src/api/device/instance.ts @@ -4,6 +4,13 @@ import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable' import { DeviceInstance } from '@/views/device/Instance/typings' import { DeviceMetadata, UnitType } from '@/views/device/Product/typings'; +/** + * 重置设备继承产品的物模型规则 + * @param deviceId 设备ID + * @param productId 产品ID + */ +export const resetRule = (productId:string,deviceId:string,data:any) => server.remove(`/virtual/property/product/${productId}/${deviceId}/_batch`,{},{data}) + /** * 删除设备物模型 * @param deviceId 设备ID diff --git a/src/views/DataCollect/Dashboard/components/Card.vue b/src/views/DataCollect/Dashboard/components/Card.vue index 630c53db..fa5679e1 100644 --- a/src/views/DataCollect/Dashboard/components/Card.vue +++ b/src/views/DataCollect/Dashboard/components/Card.vue @@ -61,22 +61,21 @@ const data: any = ref({ const pickerTimeChange = () => { data.value.time.type = undefined; - console.log(1); }; const getEcharts = async (val: any) => { loading.value = true; const resp: any = await dashboard(pointParams(val)); - if (resp.success) { - const x = resp.result + if (resp.success && resp?.result?.length) { + const x = resp.result .map((item: any) => item.data.timeString) .reverse(); const y = resp.result.map((item: any) => item.data.value).reverse(); handleOptions(x, y); } - setTimeout(() => { + setTimeout(()=>{ loading.value = false; - }, 300); + },300) }; const handleOptions = (x = [], y = []) => { diff --git a/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue b/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue index c4ed9b2c..2f7f7adf 100644 --- a/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue +++ b/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue @@ -33,6 +33,10 @@ const props = defineProps({ id: { type: String, default: undefined + }, + pluginId:{ + type:String, + default: undefined } }) @@ -46,7 +50,7 @@ const handleOk = async () => { loading.value = true const res = await savePluginData( 'device', - props.accessId!, + props.pluginId!, route.params.id as string, checkKey.value ).catch(() => ({ success: false })) diff --git a/src/views/device/Instance/Detail/Info/index.vue b/src/views/device/Instance/Detail/Info/index.vue index fa621df7..9fdfc157 100644 --- a/src/views/device/Instance/Detail/Info/index.vue +++ b/src/views/device/Instance/Detail/Info/index.vue @@ -103,6 +103,7 @@ v-if='inkingVisible' :id='inklingDeviceId' :accessId='instanceStore.current.accessId' + :pluginId="channelId" @cancel="inkingVisible = false" @submit='saveInkling' /> @@ -150,7 +151,7 @@ const queryInkling = () => { queryPluginAccessDetail(instanceStore.current?.accessId).then(async res => { if (res.success) { channelId.value = res.result.channelId - const pluginRes = await getPluginData('device',instanceStore.current?.accessId, instanceStore.current?.id) + const pluginRes = await getPluginData('device',channelId.value, instanceStore.current?.id) if (pluginRes.success) { inklingDeviceId.value = pluginRes.result?.externalId } diff --git a/src/views/device/components/Metadata/Base/columns.tsx b/src/views/device/components/Metadata/Base/columns.tsx index 56a25c31..595431c2 100644 --- a/src/views/device/components/Metadata/Base/columns.tsx +++ b/src/views/device/components/Metadata/Base/columns.tsx @@ -425,6 +425,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n props: { noEdit: noEdit?.value?.source || [], target: target, + productNoEdit: productNoEdit?.value } }, doubleClick(record){ diff --git a/src/views/device/components/Metadata/Base/components/Source.vue b/src/views/device/components/Metadata/Base/components/Source.vue index 1ebfd788..a1379450 100644 --- a/src/views/device/components/Metadata/Base/components/Source.vue +++ b/src/views/device/components/Metadata/Base/components/Source.vue @@ -10,7 +10,7 @@ > - + @@ -96,10 +96,9 @@ import VirtualRule from './VirtualRule/index.vue'; import { Form } from 'jetlinks-ui-components'; import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable' import { useInstanceStore } from '@/store/instance'; -import { - queryProductVirtualProperty -} from '@/api/device/product'; +import { resetRule } from '@/api/device/instance'; import { updata } from '@/api/rule-engine/configuration'; +import { onlyMessage } from '@/utils/comm'; const instanceStore = useInstanceStore(); const PropertySource: { label: string; value: string }[] = isNoCommunity ? [ @@ -134,7 +133,7 @@ type Emit = { }; const fullRef = inject(FULL_CODE); - +const showReset = ref(false); const props = defineProps({ value: { type: Object, @@ -152,6 +151,10 @@ const props = defineProps({ type: String, default: undefined, }, + productNoEdit:{ + type:Array, + default: [] + } }); const emit = defineEmits(); @@ -211,17 +214,23 @@ const confirm = async () => { }); }; //重置规则 +// const resetRules = async() =>{ +// let res:any = await queryProductVirtualProperty(instanceStore.current?.productId,props.value.id) +// if(res && res.status === 200 && res.result.rule){ +// const data:any = {} +// data.virtualRule = res.result.rule +// data.virtualRule.triggerProperties = res.result.triggerProperties +// data.type = type.value +// updateValue({ +// source:myValue.value, +// ...data +// }) +// } +// } const resetRules = async() =>{ - let res:any = await queryProductVirtualProperty(instanceStore.current?.productId,props.value.id) - if(res && res.status === 200 && res.result.rule){ - const data:any = {} - data.virtualRule = res.result.rule - data.virtualRule.triggerProperties = res.result.triggerProperties - data.type = type.value - updateValue({ - source:myValue.value, - ...data - }) + let res:any = await resetRule(instanceStore.current?.productId,instanceStore.current?.id,props.value?.id) + if(res.status === 200){ + onlyMessage('操作成功!') } } const cancel = () => { @@ -245,6 +254,13 @@ watch( }, { immediate: true }, ); +onMounted(()=>{ + if(props.target === 'device'){ + props.productNoEdit?.id?.forEach((item:any)=>{ + item === props.value?.id ? showReset.value = true : '' + }) + } +}) diff --git a/src/views/system/Department/components/LeftTree.vue b/src/views/system/Department/components/LeftTree.vue index 909d408c..daa6d35e 100644 --- a/src/views/system/Department/components/LeftTree.vue +++ b/src/views/system/Department/components/LeftTree.vue @@ -130,12 +130,12 @@ function getTree(cb?: Function) { treeMap.clear() getTreeData_api(params) .then((resp: any) => { - selectedKeys.value = [resp.result[0]?.id]; sourceTree.value = resp.result.sort((a: any, b: any) => a.sortIndex === b.sortIndex ? b.createTime - a.createTime : a.sortIndex - b.sortIndex, ); // 报存源数据 + selectedKeys.value = [resp.result[0]?.id]; handleTreeMap(resp.result); // 将树形结构转换为map结构 treeData.value = resp.result; // 第一次不用进行过滤 cb && cb(); @@ -275,7 +275,7 @@ init(); .tree { overflow-y: auto; overflow-x: auto; - + flex: 1 1 auto; .department-tree-item-content { display: flex; align-items: center; diff --git a/src/views/system/Department/user/components/AddBindUserDialog.vue b/src/views/system/Department/user/components/AddBindUserDialog.vue index 08074786..244ef5e5 100644 --- a/src/views/system/Department/user/components/AddBindUserDialog.vue +++ b/src/views/system/Department/user/components/AddBindUserDialog.vue @@ -14,6 +14,7 @@ :columns="columns" target="category" @search="(params:any)=>queryParams = {...params}" + style="margin-bottom: 0;" />