Merge branch 'dev' into dev-dictionary

This commit is contained in:
XieYongHong 2023-09-14 10:09:51 +08:00
commit 0bfe7efc43
11 changed files with 96 additions and 53 deletions

View File

@ -316,7 +316,7 @@ const handleSearch = async (_array: any[]) => {
const differ = array.every((i:any)=>{
return item.metadataId !== i.metadataId
})
if(!differ){
if(differ){
array.push(item)
}
})

View File

@ -67,10 +67,31 @@
"
>******</span
>
<span v-else-if="item.type.type === 'enum'">
<Ellipsis>{{
item.type.elements?.filter((i)=>
i.value === instanceStore.current?.configuration?.[
item.property
]
)[0].text
}}</Ellipsis>
<j-tooltip
v-if="isExit(item.property)"
:title="`有效值:${
instanceStore.current?.configuration?.[
item.property
]
}`"
><AIcon type="QuestionCircleOutlined"
/></j-tooltip>
</span>
<span v-else>
<Ellipsis>{{
instanceStore.current?.configuration?.[item.property] ||
''
item.type.elements?.filter((i)=>
i.value === instanceStore.current?.configuration?.[
item.property
]
)[0].text
}}</Ellipsis>
<j-tooltip
v-if="isExit(item.property)"

View File

@ -82,17 +82,18 @@ const rightList = ref<any[]>([]);
const dataSource = ref<any[]>([]);
const loading = ref<boolean>(false);
const handleData = (data: any[], type: string) => {
const handleData = (data: any[], type: string,provider?:string) => {
data.forEach((item) => {
item.key = item.id;
item.title = item.name;
item.checkable = type === 'collectors';
provider ? item.provider = provider : ''
if (
item.collectors &&
Array.isArray(item.collectors) &&
item.collectors.length
) {
item.children = handleData(item.collectors, 'collectors');
item.children = handleData(item.collectors, 'collectors',item.provider);
}
if (item.points && Array.isArray(item.points) && item.points.length) {
item.children = handleData(item.points, 'points');
@ -134,6 +135,7 @@ const _delete = (_key: string) => {
};
const handleClick = async () => {
if (!rightList.value.length) {
onlyMessage('请选择采集器', 'warning');
} else {
@ -146,10 +148,11 @@ const handleClick = async () => {
metadataType: 'property',
metadataId: (_props.metaData as any[]).find((i: any) => i.name === element.name)
?.metadataId,
provider: _props.type
provider: item.provider
}));
params.push(...array);
});
const filterParms = params.filter((item) => !!item.metadataId);
if (filterParms && filterParms.length !== 0) {
const res = await saveMapping(_props.deviceId, _props.type, filterParms);

View File

@ -247,6 +247,7 @@ import type {
ProductItem,
} from '@/views/device/Product/typings';
import type { PropType } from 'vue';
import { TOKEN_KEY } from '@/utils/variable'
import {useRouter, onBeforeRouteUpdate} from 'vue-router'
import { useMetadata, useOperateLimits } from './hooks';
import {TypeStringMap, useColumns} from './columns';
@ -259,7 +260,7 @@ import { useProductStore } from '@/store/product';
import { asyncUpdateMetadata, updateMetadata } from '../metadata';
import { useMetadataStore } from '@/store/metadata';
import { DeviceInstance } from '@/views/device/Instance/typings';
import { onlyMessage } from '@/utils/comm';
import { onlyMessage , LocalStore} from '@/utils/comm';
import {omit} from "lodash-es";
import { PropertiesModal, FunctionModal, EventModal, TagsModal } from './DetailModal'
import { Modal } from 'jetlinks-ui-components'
@ -510,7 +511,7 @@ const handleSaveClick = async (next?: Function) => {
const tabsChange = inject('tabsChange')
const parentTabsChange = (next?: Function) => {
if (editStatus.value && permissionStore.hasPermission(`${props.permission}:update`)) {
if (editStatus.value && permissionStore.hasPermission(`${props.permission}:update`) && LocalStore.get(TOKEN_KEY)) {
const modal = Modal.confirm({
content: '页面改动数据未保存',
okText: '保存',

View File

@ -85,8 +85,9 @@ export const handleTypeValue = (type:string, value: any = {}) => {
obj.format = value
break;
case 'string':
obj.maxLength = JSON.stringify(value) === '{}' ? undefined : value
case 'password':
obj.maxLength = value
obj.maxLength = JSON.stringify(value) === '{}' ? undefined : value
break;
default:
obj = value

View File

@ -236,7 +236,7 @@ const confirm = async () => {
// }
// }
const resetRules = async() =>{
let res:any = await resetRule(instanceStore.current?.productId,instanceStore.current?.id,props.value?.id)
let res:any = await resetRule(instanceStore.current?.productId,instanceStore.current?.id,[props.value?.id])
if(res.status === 200){
onlyMessage('操作成功!')
}

View File

@ -101,7 +101,7 @@
:key="i"
>
<PermissionButton
:disabled="o.disabled || item.state !== 'online'"
:disabled="o.disabled || slotProps.state.value !== 'online'"
:popConfirm="o.popConfirm"
:tooltip="{
...o.tooltip,

View File

@ -100,6 +100,7 @@
type="primary"
@click="addProcotol"
hasPermission="link/Protocol:add"
:disabled="id !== ':id'"
>
<template #icon><AIcon type="PlusOutlined" /></template>
新增

View File

@ -426,20 +426,24 @@ const handleSubmit = () => {
formRef.value
?.validate()
.then(async () => {
const resq:any = await DeviceApi.validateId(id)
if(resq.status === 200 && resq?.result?.passed){
btnLoading.value = true;
const res = !route.query.id
? await DeviceApi.save(params)
: await DeviceApi.update(params);
let res;
if(!route.query.id){
const resp:any = await DeviceApi.validateId(id)
if(resp.status === 200 && resp?.result?.passed){
res = await DeviceApi.save(params)
}else{
notification.error({ key: 'error', message: '设备ID已重复'})
}
}else{
res = await DeviceApi.update(params);
}
if (res?.success) {
onlyMessage('保存成功');
history.back();
}
}else{
notification.error({ key: 'error', message: '设备ID已重复'})
}
})
)
.catch((err: any) => {
console.log('err: ', err);
})

View File

@ -9,6 +9,7 @@
style="margin-bottom: 24px"
/>
<!-- 使用v-if用于解决异步加载数据后不展开的问题 -->
<div class="tree">
<j-tree
v-if="leftData.treeData.length > 0"
defaultExpandAll
@ -45,6 +46,7 @@
</template>
</j-tree>
</div>
</div>
<div class="right">
<div class="btns">
<j-button type="primary" @click="clickSave">保存</j-button>
@ -507,8 +509,11 @@ const checkName = (_: any, value: any) =>
box-sizing: border-box;
width:300px;
height:100%;
.tree{
max-height: 680px;
overflow-y: auto;
}
}
.right {
width: calc(100% - 280px);
box-sizing: border-box;

View File

@ -73,6 +73,13 @@ onMounted(() => {
emit('update:value', options.value?.[0]?.value);
emit('update:name', options.value?.[0]?.label);
emit('change', {label: options.value?.[0]?.label, value: options.value?.[0]?.value});
}else{
options.value.find((item:any)=>{
if(item.value === props.value){
emit('update:name',item.label)
return true
}
})
}
}
loading.value = false;