feat:采集点类型/数据实时监控/历史记录查询添加导出按钮

main
黄伟杰 1 week ago
parent 8fd545671c
commit 4f877d350d

@ -121,6 +121,10 @@ export const DeviceApi = {
return await request.download({ url: `/iot/device/export-excel`, params })
},
exportLineDevice: async (params) => {
return await request.download({ url: `/iot/device/export-line-device`, params })
},
getLineDevicePage: async (params: LineDevicePageParams) => {
return await request.get({ url: `/iot/device/lineDevicePage`, params })
},

@ -228,11 +228,13 @@ const handleBatchDelete = async () => {
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await DeviceAttributeTypeApi.exportDeviceAttributeType(queryParams)
const params: any = {
...queryParams,
ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined,
}
const data = await DeviceAttributeTypeApi.exportDeviceAttributeType(params)
download.excel(data, '采集点分类.xls')
} catch {
} finally {

@ -50,6 +50,9 @@
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" /> 重置
</el-button>
<el-button type="success" plain @click="handleExport" :loading="exportLoading">
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
@ -61,7 +64,9 @@
:stripe="true"
:show-overflow-tooltip="true"
row-key="id"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" reserve-selection />
<el-table-column label="产线编码" align="left" prop="lineNode" min-width="140px" />
<el-table-column label="产线名称" align="left" prop="lineName" min-width="160px" />
<el-table-column label="设备编码" align="left" prop="deviceCode" min-width="140px" />
@ -98,14 +103,18 @@
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { DeviceApi, LineDeviceVO, LineDevicePageParams } from '@/api/iot/device'
import HistorySingleDeviceDialog from './HistorySingleDeviceDialog.vue'
defineOptions({ name: 'HistoryData' })
const message = useMessage()
const loading = ref(true)
const list = ref<LineDeviceVO[]>([])
const total = ref(0)
const exportLoading = ref(false)
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -119,6 +128,14 @@ const queryParams = reactive({
const queryFormRef = ref()
const selectedIds = ref<(string | number)[]>([])
const handleSelectionChange = (rows: LineDeviceVO[]) => {
selectedIds.value =
rows?.map((row) => ((row as any)?.id ?? (row as any)?.deviceId) as string | number).filter(
(id) => id !== undefined && id !== null && id !== ''
) ?? []
}
const singleDialogVisible = ref(false)
const singleDeviceId = ref<string | number>()
const singleDeviceName = ref<string>('')
@ -188,4 +205,20 @@ onActivated(() => {
}
getList()
})
const handleExport = async () => {
try {
await message.exportConfirm()
exportLoading.value = true
const params: any = {
...buildQueryParams(),
ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined
}
const data = await DeviceApi.exportLineDevice(params)
download.excel(data, '历史数据设备.xls')
} catch {
} finally {
exportLoading.value = false
}
}
</script>

@ -28,12 +28,23 @@ v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable @
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" /> 重置
</el-button>
<el-button type="success" plain @click="handleExport" :loading="exportLoading">
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
row-key="id"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" reserve-selection />
<el-table-column label="产线编码" align="left" prop="lineNode" min-width="140px" />
<el-table-column label="产线名称" align="left" prop="lineName" min-width="160px" />
<el-table-column label="设备编码" align="left" prop="deviceCode" min-width="140px" />
@ -66,6 +77,7 @@ v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable @
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { DeviceApi, LineDeviceVO } from '@/api/iot/device'
import SingleDeviceMonitorDialog from './SingleDeviceMonitorDialog.vue'
@ -76,6 +88,7 @@ const message = useMessage()
const loading = ref(true)
const list = ref<LineDeviceVO[]>([])
const total = ref(0)
const exportLoading = ref(false)
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -87,7 +100,15 @@ const queryParams = reactive({
status: undefined,
collectionTime: undefined
})
const queryFormRef = ref() //
const queryFormRef = ref()
const selectedIds = ref<(string | number)[]>([])
const handleSelectionChange = (rows: LineDeviceVO[]) => {
selectedIds.value =
rows?.map((row) => ((row as any)?.id ?? (row as any)?.deviceId) as string | number).filter(
(id) => id !== undefined && id !== null && id !== ''
) ?? []
}
const monitorDialogVisible = ref(false)
const monitorDeviceId = ref<string | number>()
@ -143,6 +164,22 @@ const handleSingleMonitor = (row: LineDeviceVO) => {
monitorDialogVisible.value = true
}
const handleExport = async () => {
try {
await message.exportConfirm()
exportLoading.value = true
const params: any = {
...buildQueryParams(),
ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined
}
const data = await DeviceApi.exportLineDevice(params)
download.excel(data, '实时监控设备.xls')
} catch {
} finally {
exportLoading.value = false
}
}
onMounted(() => {
getList()
})

Loading…
Cancel
Save