智能安全帽 添加 在线时长管理 页面

This commit is contained in:
jiayu 2024-09-27 09:35:39 +08:00
parent 5c89b35132
commit 8550d97ac4
2 changed files with 169 additions and 0 deletions

View File

@ -698,6 +698,15 @@ const routes2 = [{
"@/views/projectFront/smartSafeHat/deviceCentral/deviceCentral.vue"
),
},
// 智能安全帽--在线时长管理
{
path: "/project/smartSafeHat/onlineTime",
name: "智能安全帽_设备中台",
component: () =>
import (
"@/views/projectFront/smartSafeHat/onlineTime/onlineTime.vue"
),
},
// 智能安全带--数据台账
{
path: "/project/smartSeatBelts/dataPay",

View File

@ -0,0 +1,160 @@
<template>
<div class="fullHeight">
<div class="searchBox whiteBlock">
<el-form :inline="true" ref="searchForm" :model="searchForm" size="medium">
<el-form-item>
<el-date-picker
v-model="dateTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
<el-button type="primary" style="margin-left: 24px" @click="downloadFn">导出</el-button>
</el-form-item>
</el-form>
</div>
<div class="table_wrap whiteBlock">
<vue-scroll style="height: 100%">
<el-table class="tables" :data="tableData" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column prop="workerName" align="center" label="人员名称" width="280"></el-table-column>
<el-table-column prop="devSn" align="center" label="设备序号"></el-table-column>
<el-table-column prop="fenceName" label="围栏名称" align="center">
<template slot-scope="scope">{{ scope.row.fenceName || '-' }}</template>
</el-table-column>
</el-table>
</vue-scroll>
</div>
</div>
</template>
<script>
import { getSafeHatEquipmentCentralPageApi } from '@/assets/js/api/smartSafeHat/smartSafeHat.js'
export default {
mounted() {},
created() {
this.getPage()
},
computed: {
headers() {
return { Authorization: this.$store.state.userInfo.token }
}
},
data() {
return {
pagInfo: {
pageNo: 1, //
pageSize: 10, //
total: 0 //
},
dialogShow: false,
dateTime: [],
multipleSelection: [],
tableData: [],
searchForm: {},
messageList: []
}
},
methods: {
//
downloadFn() {
if (!this.multipleSelection.length) {
return this.$message.error('请选择要导出的数据')
}
if (!this.dateTime.length) {
return this.$message.error('请选择时间范围')
}
const ids = this.multipleSelection.map(item => item.extUserId).filter(i=>i && i.trim()).join(',')
if (!ids) {
return this.$message.error('导出失败,用户信息有误')
}
let data = {
projectSn: this.$store.state.projectSn,
stime: this.dateTime[0],
etime: this.dateTime[1],
userId: ids
}
let api = this.$http.defaults.baseURL + 'xmgl/safetyHatData/exportUseHistory?'
//url
const entries = Object.entries(data)
entries.map(([key, value], index) => {
api += `${key}=${value}${index + 1 < entries.length ? '&' : ''}`
})
console.log('api', api)
fetch(api, {
method: 'get',
headers: {
Authorization: this.$store.state.userInfo.token,
'Content-Type': 'application/json' // JSON
}
})
.then(response => {
//
if (!response.ok) {
throw new Error('下载失败')
}
return response.blob()
})
.then(blob => {
// X
const url = window.URL.createObjectURL(blob)
// <a>
const link = document.createElement('a')
link.href = url
link.download = '在线统计时长.xlsx' //
//
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
// URL
window.URL.revokeObjectURL(url)
//
// 使blob
console.log('下载', link, url)
})
.catch(error => {
//
console.error(error)
})
},
async getPage() {
await getSafeHatEquipmentCentralPageApi({
pageNo: 1,
pageSize: 9999,
projectSn: this.$store.state.projectSn,
devSn: this.searchForm.devSn,
type: this.type
}).then(result => {
if (result.success) {
this.tableData = result.result.records
}
})
},
handleSelectionChange(val) {
console.info(val)
this.multipleSelection = val
}
}
}
</script>
<style lang="less" scoped>
.tables {
// min-height: 0;
}
.tables2 {
min-height: auto;
}
.textStyle {
width: 140px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tableBtns {
display: flex;
justify-content: center;
align-item: center;
}
</style>