平台对接
@@ -114,46 +173,72 @@
{{ slotProps.cardType.text }}
- 绑定设备
+
+ 绑定设备
+
{{ slotProps.deviceName }}
-
- {{ slotProps.totalFlow }}
-
-
- M 使用流量
-
-
-
-
- {{
- (slotProps.usedFlow / slotProps.totalFlow * 100).toFixed(2)
- }}
- %
-
-
- 总共 {{ slotProps.totalFlow }} M
-
+
+ {{ slotProps.totalFlow }}
+
+
+ M 使用流量
+
+
+
+
+ {{
+ (
+ (slotProps.usedFlow /
+ slotProps.totalFlow) *
+ 100
+ ).toFixed(2)
+ }}
+ %
+
+
+ 总共 {{ slotProps.totalFlow }} M
+
+
+
-
-
-
-
+
+
{{ item?.text }}
-
-
+
-
+
-
+
@@ -304,11 +417,13 @@ import BindDevice from './BindDevice.vue';
import Import from './Import.vue';
import Export from './Export.vue';
import Save from './Save.vue';
-import { useMenuStore } from 'store/menu'
+import { useMenuStore } from 'store/menu';
import BadgeStatus from '@/components/BadgeStatus/index.vue';
+import BatchDropdown from '@/components/BatchDropdown/index.vue';
+import { BatchActionsType } from '@/components/BatchDropdown/types';
const router = useRouter();
-const menuStory = useMenuStore()
+const menuStory = useMenuStore();
const cardManageRef = ref
>({});
const params = ref>({});
const _selectedRowKeys = ref([]);
@@ -320,6 +435,7 @@ const importVisible = ref(false);
const cardId = ref();
const current = ref>({});
const saveType = ref('');
+const isCheck = ref(false);
const columns = [
{
@@ -472,21 +588,7 @@ const getActions = (
type: 'card' | 'table',
): ActionsType[] => {
if (!data) return [];
- return [
- {
- key: 'view',
- text: '查看',
- tooltip: {
- title: '查看',
- },
- icon: 'EyeOutlined',
- onClick: () => {
- // router.push({
- // path: `/iot-card/CardManagement/detail/${data.id}`,
- // });
- menuStory.jumpPage('iot-card/CardManagement/Detail', { id: data.id })
- },
- },
+ const arr = [
{
key: 'update',
text: '编辑',
@@ -509,18 +611,18 @@ const getActions = (
icon: data.deviceId ? 'DisconnectOutlined' : 'LinkOutlined',
popConfirm: data.deviceId
? {
- title: '确认解绑设备?',
- okText: '确定',
- cancelText: '取消',
- onConfirm: async () => {
- unbind(data.id).then((resp: any) => {
- if (resp.status === 200) {
- message.success('操作成功')
- cardManageRef.value?.reload();
- }
- });
- },
- }
+ title: '确认解绑设备?',
+ okText: '确定',
+ cancelText: '取消',
+ onConfirm: async () => {
+ unbind(data.id).then((resp: any) => {
+ if (resp.status === 200) {
+ message.success('操作成功');
+ cardManageRef.value?.reload();
+ }
+ });
+ },
+ }
: undefined,
onClick: () => {
if (!data.deviceId) {
@@ -530,55 +632,58 @@ const getActions = (
},
},
{
- key: data.cardStateType?.value === 'toBeActivated' ? 'active' : 'action',
+ key:
+ data.cardStateType?.value === 'toBeActivated'
+ ? 'active'
+ : 'action',
text:
data.cardStateType?.value === 'toBeActivated'
? '激活'
: data.cardStateType?.value === 'deactivate'
- ? '复机'
- : '停用',
+ ? '复机'
+ : '停用',
tooltip: {
title:
data.cardStateType?.value === 'toBeActivated'
? '激活'
: data.cardStateType?.value === 'deactivate'
- ? '复机'
- : '停用',
+ ? '复机'
+ : '停用',
},
icon:
data.cardStateType?.value === 'toBeActivated'
? 'CheckCircleOutlined'
: data.cardStateType?.value === 'deactivate'
- ? 'PoweroffOutlined'
- : 'StopOutlined',
+ ? 'PoweroffOutlined'
+ : 'StopOutlined',
popConfirm: {
title:
data.cardStateType?.value === 'toBeActivated'
? '确认激活?'
: data.cardStateType?.value === 'deactivate'
- ? '确认复机?'
- : '确认停用?',
+ ? '确认复机?'
+ : '确认停用?',
okText: '确定',
cancelText: '取消',
onConfirm: async () => {
if (data.cardStateType?.value === 'toBeActivated') {
changeDeploy(data.id).then((resp) => {
if (resp.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
cardManageRef.value?.reload();
}
});
} else if (data.cardStateType?.value === 'deactivate') {
resumption(data.id).then((resp) => {
if (resp.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
cardManageRef.value?.reload();
}
});
} else {
unDeploy(data.id).then((resp) => {
if (resp.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
cardManageRef.value?.reload();
}
});
@@ -599,7 +704,7 @@ const getActions = (
onConfirm: async () => {
const resp: any = await del(data.id);
if (resp.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
cardManageRef.value?.reload();
} else {
message.error('操作失败!');
@@ -609,6 +714,26 @@ const getActions = (
icon: 'DeleteOutlined',
},
];
+ if (type === 'card') {
+ return arr;
+ } else {
+ return [
+ {
+ key: 'view',
+ text: '查看',
+ tooltip: {
+ title: '查看',
+ },
+ icon: 'EyeOutlined',
+ onClick: () => {
+ menuStory.jumpPage('iot-card/CardManagement/Detail', {
+ id: data.id,
+ });
+ },
+ },
+ ...arr,
+ ];
+ }
};
const handleSearch = (e: any) => {
@@ -625,14 +750,24 @@ const cancelSelect = () => {
};
const handleClick = (dt: any) => {
- if (_selectedRowKeys.value.includes(dt.id)) {
- const _index = _selectedRowKeys.value.findIndex((i) => i === dt.id);
- _selectedRowKeys.value.splice(_index, 1);
+ if (isCheck.value) {
+ if (_selectedRowKeys.value.includes(dt.id)) {
+ const _index = _selectedRowKeys.value.findIndex((i) => i === dt.id);
+ _selectedRowKeys.value.splice(_index, 1);
+ } else {
+ _selectedRowKeys.value = [..._selectedRowKeys.value, dt.id];
+ }
} else {
- _selectedRowKeys.value = [..._selectedRowKeys.value, dt.id];
+ menuStory.jumpPage('iot-card/CardManagement/Detail', {
+ id: dt.id,
+ });
}
};
+const onCheckChange = () => {
+ _selectedRowKeys.value = [];
+};
+
/**
* 新增
*/
@@ -694,7 +829,7 @@ const handleStop = () => {
) {
unDeployBatch(_selectedRowKeys.value).then((res: any) => {
if (res.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
}
});
} else {
@@ -712,7 +847,7 @@ const handleResumption = () => {
) {
resumptionBatch(_selectedRowKeys.value).then((res: any) => {
if (res.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
}
});
} else {
@@ -736,20 +871,106 @@ const handleSync = () => {
* 批量删除
*/
const handelRemove = async () => {
+ if (!_selectedRow.value.length) {
+ message.error('请选择数据');
+ return;
+ }
const resp = await removeCards(_selectedRow.value);
if (resp.status === 200) {
- message.success('操作成功')
+ message.success('操作成功');
_selectedRowKeys.value = [];
_selectedRow.value = [];
cardManageRef.value?.reload();
}
};
+const batchActions: BatchActionsType[] = [
+ {
+ key: 'export',
+ text: '批量导出',
+ permission: 'iot-card/CardManagement:export',
+ icon: 'ExportOutlined',
+ onClick: () => {
+ exportVisible.value = true;
+ },
+ },
+ {
+ key: 'import',
+ text: '批量导入',
+ permission: 'iot-card/CardManagement:import',
+ icon: 'ImportOutlined',
+ onClick: () => {
+ importVisible.value = true;
+ },
+ },
+ // {
+ // key: 'active',
+ // text: '批量激活',
+ // permission: 'iot-card/CardManagement:active',
+ // icon: 'CheckCircleOutlined',
+ // selected: {
+ // popConfirm: {
+ // title: '确认激活吗?',
+ // onConfirm: handleActive,
+ // },
+ // },
+ // },
+ {
+ key: 'stop',
+ text: '批量停用',
+ permission: 'iot-card/CardManagement:action',
+ icon: 'StopOutlined',
+ selected: {
+ popConfirm: {
+ title: '确认停用吗?',
+ onConfirm: handleStop,
+ },
+ },
+ },
+ {
+ key: 'resumption',
+ text: '批量复机',
+ ghost: true,
+ type: 'primary',
+ permission: 'iot-card/CardManagement:action',
+ icon: 'PoweroffOutlined',
+ selected: {
+ popConfirm: {
+ title: '确认复机吗?',
+ onConfirm: handleResumption,
+ },
+ },
+ },
+ {
+ key: 'sync',
+ text: '同步状态',
+ ghost: true,
+ type: 'primary',
+ permission: 'iot-card/CardManagement:sync',
+ icon: 'SwapOutlined',
+ popConfirm: {
+ title: '确认同步状态吗?',
+ onConfirm: handleSync,
+ },
+ },
+ {
+ key: 'delete',
+ text: '批量删除',
+ danger: true,
+ permission: 'iot-card/CardManagement:delete',
+ icon: 'StopOutlined',
+ selected: {
+ popConfirm: {
+ title: '确认删除吗?',
+ onConfirm: handelRemove,
+ },
+ },
+ },
+];