fix: 修改设备网关的样式

This commit is contained in:
100011797 2023-03-31 10:42:33 +08:00
parent ef6c66600f
commit 74c0b9fc0a
4 changed files with 108 additions and 57 deletions

View File

@ -16,14 +16,10 @@ export const useInstanceStore = defineStore({
this.detail = current this.detail = current
}, },
async refresh(id: string) { async refresh(id: string) {
const resp: any = await detail(id).catch((err) => { const resp: any = await detail(id)
onlyMessage(err.response.data.message, 'error')
})
if(resp.status === 200){ if(resp.status === 200){
this.current = resp.result this.current = resp.result
this.detail = resp.result this.detail = resp.result
} else {
onlyMessage(resp?.message, 'error')
} }
}, },
setTabActiveKey(key: string) { setTabActiveKey(key: string) {

View File

@ -151,6 +151,8 @@ const errorHandler = (error: any) => {
path: LoginPath path: LoginPath
}) })
}, 0) }, 0)
} else if (status === 404) {
showNotification(error?.code, error?.response?.data?.message, '404')
} }
} else if (error.response === undefined) { } else if (error.response === undefined) {
showNotification(error.message, (error.stack + '').substr(0, 90), undefined) showNotification(error.message, (error.stack + '').substr(0, 90), undefined)

View File

@ -53,7 +53,8 @@
<img <img
:width="88" :width="88"
:height="88" :height="88"
:src="slotProps?.photoUrl || :src="
slotProps?.photoUrl ||
getImage('/device/instance/device-card.png') getImage('/device/instance/device-card.png')
" "
/> />
@ -85,8 +86,42 @@
</j-row> </j-row>
</template> </template>
<template #actions="item"> <template #actions="item">
<j-dropdown
placement="bottomRight"
v-if="item.key === 'others'"
>
<j-button>
<AIcon :type="item.icon" />
<span>{{ item.text }}</span>
</j-button>
<template #overlay>
<j-menu>
<j-menu-item
v-for="(o, i) in item.children"
:key="i"
>
<PermissionButton
:disabled="o.disabled"
:popConfirm="o.popConfirm"
:tooltip="{
...o.tooltip,
}"
@click="o.onClick"
:hasPermission="
'edge/Device:' + o.key
"
type="link"
>
<AIcon :type="o.icon" />
<span>{{ o?.text }}</span>
</PermissionButton>
</j-menu-item>
</j-menu>
</template>
</j-dropdown>
<PermissionButton <PermissionButton
:disabled="item.disabled" :disabled="item.disabled"
v-else
:popConfirm="item.popConfirm" :popConfirm="item.popConfirm"
:tooltip="{ :tooltip="{
...item.tooltip, ...item.tooltip,
@ -383,36 +418,6 @@ const getActions = (
current.value = data; current.value = data;
}, },
}, },
{
key: 'setting',
text: '远程控制',
tooltip: {
title: '远程控制',
},
icon: 'ControlOutlined',
onClick: () => {
menuStory.jumpPage('edge/Device/Remote', { id: data.id });
},
},
{
key: 'password',
text: '重置密码',
tooltip: {
title: '重置密码',
},
icon: 'RedoOutlined',
popConfirm: {
title: '确认重置密码为P@ssw0rd',
onConfirm: async () => {
restPassword(data.id).then((resp: any) => {
if (resp.status === 200) {
message.success('操作成功!');
edgeDeviceRef.value?.reload();
}
});
},
},
},
{ {
key: 'action', key: 'action',
text: data.state?.value !== 'notActive' ? '禁用' : '启用', text: data.state?.value !== 'notActive' ? '禁用' : '启用',
@ -443,34 +448,82 @@ const getActions = (
}, },
}, },
}, },
];
const others = [
{ {
key: 'delete', key: 'setting',
text: '删除', text: '远程控制',
disabled: data.state?.value !== 'notActive',
tooltip: { tooltip: {
title: title: '远程控制',
data.state.value !== 'notActive'
? '已启用的设备不能删除'
: '删除',
}, },
icon: 'ControlOutlined',
onClick: () => {
menuStory.jumpPage('edge/Device/Remote', {
id: data.id,
});
},
},
{
key: 'password',
text: '重置密码',
tooltip: {
title: '重置密码',
},
icon: 'RedoOutlined',
popConfirm: { popConfirm: {
title: '确认删除?', title: '确认重置密码为P@ssw0rd',
onConfirm: async () => { onConfirm: async () => {
const resp = await _delete(data.id); restPassword(data.id).then((resp: any) => {
if (resp.status === 200) { if (resp.status === 200) {
message.success('操作成功!'); message.success('操作成功!');
edgeDeviceRef.value?.reload(); edgeDeviceRef.value?.reload();
} else { }
message.error('操作失败!'); });
}
}, },
}, },
icon: 'DeleteOutlined',
}, },
]; ];
if (type === 'card')
return actions.filter((i: ActionsType) => i.key !== 'view'); const deleteItem = {
return actions; key: 'delete',
text: '删除',
disabled: data.state?.value !== 'notActive',
tooltip: {
title:
data.state.value !== 'notActive'
? '已启用的设备不能删除'
: '删除',
},
popConfirm: {
title: '确认删除?',
onConfirm: async () => {
const resp = await _delete(data.id);
if (resp.status === 200) {
message.success('操作成功!');
edgeDeviceRef.value?.reload();
} else {
message.error('操作失败!');
}
},
},
icon: 'DeleteOutlined',
};
if (type === 'card') {
const arr = actions.filter((i: ActionsType) => i.key !== 'view');
return [
...arr,
{
key: 'others',
text: '其他',
icon: 'EllipsisOutlined',
children: [...others],
},
deleteItem,
];
} else {
return [...actions, ...others, deleteItem];
}
}; };
const handleSearch = (_params: any) => { const handleSearch = (_params: any) => {

View File

@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3:
jetlinks-ui-components@^1.0.5: jetlinks-ui-components@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#1cd2b4b99afdda515bffd05f7fc9dd61a3cff16d" resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#c71ecae61776bff738f43efe46aac7264f092736"
integrity sha512-cIB/6wOiU+GHDKI3dUnGLa27VrHXuEOoOsqKI30GcKRHbdamBfApchOcvAON+SHpv19n5i3inKw8pNXaHOeKZw== integrity sha512-+1a/4nA5RCiInRFyyaVCMEWSBzNU8lzxOYTTpY0GiNhuJuhGE5AbBsVp9CXXF0lFECK2iqaAElY+QN4Wjms1Dw==
dependencies: dependencies:
"@vueuse/core" "^9.12.0" "@vueuse/core" "^9.12.0"
ant-design-vue "^3.2.15" ant-design-vue "^3.2.15"