fix
This commit is contained in:
@@ -23,6 +23,12 @@
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<a-button class="ele-btn-icon" @click="handleExport">
|
||||
<template #icon>
|
||||
<DownloadOutlined />
|
||||
</template>
|
||||
<span>导出设备</span>
|
||||
</a-button>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="40" />
|
||||
@@ -119,7 +125,10 @@
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import {
|
||||
DownloadOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
@@ -129,14 +138,23 @@
|
||||
import Search from './components/search.vue';
|
||||
import EquipmentEdit from './components/equipment-edit.vue';
|
||||
import { pageEquipment, removeBatchEquipment } from '@/api/apps/equipment';
|
||||
import type { Equipment, EquipmentParam } from '@/api/apps/equipment/model';
|
||||
import { Equipment } from '@/api/apps/equipment/model';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
import { Accessory } from '@/api/tower/accessory/model';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
// import { Category } from '@/api/goods/category/model';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection2?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
@@ -227,7 +245,7 @@
|
||||
dataIndex: 'leaseStatus',
|
||||
//sorter: true,
|
||||
key: 'leaseStatus',
|
||||
hideInTable:true
|
||||
hideInTable: true
|
||||
},
|
||||
{
|
||||
title: '电池状态',
|
||||
@@ -297,6 +315,64 @@
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = () => {
|
||||
if (!selection.value?.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'二维码',
|
||||
'设备编号',
|
||||
'所属商户',
|
||||
'在租用户',
|
||||
'设备名称',
|
||||
'激活状态',
|
||||
'电池型号',
|
||||
'绑定状态'
|
||||
]
|
||||
];
|
||||
|
||||
selection.value?.forEach((d: Equipment) => {
|
||||
const bangding = d.userId > 0 ? '已绑定' : '未绑定';
|
||||
var username = '';
|
||||
if (d.user != null) {
|
||||
username = d.user.mobile ? d.user.mobile : d.user.nickname;
|
||||
}
|
||||
|
||||
array.push([
|
||||
`${d.qrcode}`,
|
||||
`${d.equipmentCode}`,
|
||||
`${d.merchantName}`,
|
||||
`${username}`,
|
||||
`${d.equipmentName}`,
|
||||
`${d.isCtive}`,
|
||||
`${d.batteryModel}`,
|
||||
`${bangding}`,
|
||||
`${d.comments}`
|
||||
]);
|
||||
});
|
||||
const sheetName = '设备列表';
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 40 },
|
||||
{ wch: 10 }
|
||||
];
|
||||
writeFile(workbook, '导出设备管理表.xlsx');
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
@@ -346,7 +422,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection.value.filter(item=>item.userId!==0).length>0){
|
||||
if (selection.value.filter((item) => item.userId !== 0).length > 0) {
|
||||
message.error('不能删除绑定的设备,请重新选择');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user