Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev

This commit is contained in:
jackhoo_98 2023-03-31 12:40:02 +08:00
commit 0998f4bc79
9 changed files with 129 additions and 72 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

@ -208,7 +208,7 @@ watch(
*/ */
const onTreeSelect = (keys: any) => { const onTreeSelect = (keys: any) => {
deptId.value = keys[0]; deptId.value = keys[0];
pageSize.value = 5; pageSize.value = 10;
current.value = 1; current.value = 1;
}; };

View File

@ -43,14 +43,14 @@
</j-form-item> </j-form-item>
<j-form-item <j-form-item
v-else v-else
name="selectorValues" name="upperKey"
label="变量" label="变量"
:rules="[{ required: true, message: '请选择' }]" :rules="[{ required: true, message: '请选择' }]"
> >
<j-tree-select <j-tree-select
style="width: 100%; height: 100%" style="width: 100%; height: 100%"
:tree-data="builtInList" :tree-data="builtInList"
v-model:value="modelRef.selectorValues" v-model:value="modelRef.upperKey"
placeholder="请选择参数" placeholder="请选择参数"
@select="onVariableChange" @select="onVariableChange"
:fieldNames="{ label: 'name', value: 'id' }" :fieldNames="{ label: 'name', value: 'id' }"
@ -302,7 +302,7 @@ const onVariableChange = (val: any, node: any) => {
modelRef.deviceId = val; modelRef.deviceId = val;
modelRef.source = 'upper'; modelRef.source = 'upper';
modelRef.upperKey = val; modelRef.upperKey = val;
modelRef.selectorValues = [{ value: val, name: node.description }] as any; modelRef.selectorValues = undefined // [{ value: val, name: node.description }] as any;
emits('save', unref(modelRef), { name: node.description }); emits('save', unref(modelRef), { name: node.description });
}; };
@ -366,7 +366,7 @@ const onFormSave = () => {
}); });
} }
} else { } else {
resolve(_data); resolve({..._data});
} }
}) })
.catch((err: any) => { .catch((err: any) => {

View File

@ -136,11 +136,9 @@ const onSave = (_data: any) => {
source: DeviceModel.source, source: DeviceModel.source,
selectorValues: DeviceModel.selectorValues, selectorValues: DeviceModel.selectorValues,
productId: DeviceModel.productId, productId: DeviceModel.productId,
upperKey: DeviceModel.upperKey,
message: _data.message, message: _data.message,
}; };
if (DeviceModel.selector === 'variable') {
item.selector = 'fixed';
}
if (DeviceModel.selector === 'relation') { if (DeviceModel.selector === 'relation') {
item.upperKey = 'scene.deviceId'; item.upperKey = 'scene.deviceId';
} }
@ -167,6 +165,7 @@ const onSave = (_data: any) => {
? JSON.stringify(_options?.propertiesValue) ? JSON.stringify(_options?.propertiesValue)
: _options?.propertiesValue) : _options?.propertiesValue)
} }
console.log(item)
emit('save', item, JSON.parse(JSON.stringify(_options))); emit('save', item, JSON.parse(JSON.stringify(_options)));
}; };
@ -181,7 +180,6 @@ const onProductChange = (_val: any, bol: boolean) => {
JSON.parse(_val.metadata || '{}'), JSON.parse(_val.metadata || '{}'),
DeviceModel?.message, DeviceModel?.message,
); );
console.log(flag)
if (!flag) { if (!flag) {
DeviceModel.message = { DeviceModel.message = {
messageType: 'INVOKE_FUNCTION', messageType: 'INVOKE_FUNCTION',

View File

@ -242,7 +242,7 @@
v-else-if="data?.executor === 'device'" v-else-if="data?.executor === 'device'"
@click="onType('device')" @click="onType('device')"
> >
<template v-if="data?.device?.selector === 'fixed'"> <template v-if="['fixed', 'context'].includes(data?.device?.selector)">
<div style='display: flex; align-items: center;'> <div style='display: flex; align-items: center;'>
<AIcon <AIcon
:type=" :type="

View File

@ -28,6 +28,14 @@
onSelect: changeSelect, onSelect: changeSelect,
}" }"
@cancelSelect="selectedRowKeys = []" @cancelSelect="selectedRowKeys = []"
:defaultParams="{
pageSize: 10,
}"
:pagination="{
pageSizeOptions: ['10', '20', '50', '100'],
showSizeChanger: true,
hideOnSinglePage: false,
}"
> >
</j-pro-table> </j-pro-table>
</j-modal> </j-modal>
@ -101,11 +109,11 @@ const confirm = () => {
}; };
const changeSelect = (item: any, state: boolean) => { const changeSelect = (item: any, state: boolean) => {
const arr = new Set(selectedRowKeys.value); const arr = new Set(selectedRowKeys.value);
console.log(item,state); console.log(item, state);
if(state){ if (state) {
arr.add(item.id) arr.add(item.id);
}else{ } else {
arr.delete(item.id) arr.delete(item.id);
} }
selectedRowKeys.value = [...arr.values()]; selectedRowKeys.value = [...arr.values()];
}; };

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"