<template>
|
<div class="home-container">
|
<div style="height: 100%">
|
<div class="homeCard">
|
<div class="main-card">
|
<el-row class="cardTop">
|
<el-col :span="12" class="mainCardBtn">
|
<el-button type="primary" icon="Plus" size="default" @click="openDialog('add',{})">新增</el-button>
|
</el-col>
|
</el-row>
|
<el-table :data="reportData" style="width: 100%" height="calc(100% - 48px)" :header-cell-style="{ background: '#fafafa' }">
|
<el-table-column prop="id" label="id" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="no" label="编号" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="name" label="设备名称" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="cateName" label="分类" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="model" label="型号" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="productionTime" label="出厂时间" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="isSpecial" label="是否特种设备" show-overflow-tooltip>
|
<template #default="scope">
|
{{scope.row.isSpecial == 0?'是':scope.row.isSpecial == 1?'否':''}}
|
</template>
|
</el-table-column>
|
<el-table-column prop="isRegister" label="是否注册登记" show-overflow-tooltip>
|
<template #default="scope">
|
{{scope.row.isSpecial == 0?'是':scope.row.isSpecial == 1?'否':''}}
|
</template>
|
</el-table-column>
|
<el-table-column prop="registerNo" label="注册登记编号" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="status" label="设备状况" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="files" label="附件" show-overflow-tooltip>
|
<template #default="scope">
|
<el-button v-if="scope.row.files !== ''" size="small" text type="primary" @click="openFile(scope.row.files)">查看</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column prop="registerTable" label="注册等级表" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="checkStatus" label="检验状态" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="designUseYears" label="设备使用年限" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="firstUseDate" label="首次使用日期" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="nextCheckTime" label="下次检验时间" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="lastCheckTime" label="上次校验时间" show-overflow-tooltip></el-table-column>
|
<el-table-column label="操作" width="140">
|
<template #default="scope">
|
<el-button size="small" text type="primary" @click="openDialog('update',scope.row)">重新上报</el-button>
|
<el-button style="color: red" size="small" text type="primary" @click="onRowDel(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div class="pageBtn">
|
<el-pagination @size-change="onHandleSizeChange" small="false" @current-change="onHandleCurrentChange" class="page-position" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="listQuery.pageIndex" background v-model:page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>
|
</div>
|
</div>
|
</div>
|
</div>
|
<add-report ref="reportRef" @refresh="getData"></add-report>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue'
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
import { Plus } from '@element-plus/icons-vue'
|
import addReport from "./components/addReport.vue"
|
import {judgeReportApi} from "/@/api/dataUpload/saftyBaseInfo/judgeReport";
|
import axios from "axios";
|
import Cookies from "js-cookie";
|
interface TableDataState {
|
reportData: [],
|
listQuery: {
|
searchParams: {}
|
pageIndex: number
|
pageSize: number
|
}
|
total: null | number
|
}
|
|
export default defineComponent({
|
name: 'equipInfo',
|
components: {addReport },
|
setup() {
|
const reportRef= ref();
|
const state = reactive<TableDataState>({
|
reportData: [],
|
listQuery: {
|
searchParams: {},
|
pageIndex: 1,
|
pageSize: 10
|
},
|
total: null
|
});
|
|
// 页面加载时
|
onMounted(() => {
|
getData()
|
});
|
|
const getData = async ()=>{
|
const res = await judgeReportApi().getEquipList(state.listQuery)
|
if(res.data.code == 200){
|
state.reportData = res.data.data
|
state.total = res.data.total
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
})
|
}
|
}
|
|
const openDialog=(type:string,data:object)=>{
|
reportRef.value.open(type,data)
|
}
|
|
// 删除用户
|
const onRowDel = (row: Object) => {
|
ElMessageBox.confirm(`此操作将永久删除:“${row.name}”,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
const res = await judgeReportApi().delEquip({ids: [row.id]})
|
if(res.data.code == 200){
|
ElMessage({
|
type: 'success',
|
message: '删除成功'
|
})
|
await getData()
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
})
|
}
|
})
|
.catch(() => {});
|
};
|
// 分页改变
|
const onHandleSizeChange = (val: number) => {
|
state.listQuery.pageSize = val;
|
getData()
|
};
|
// 分页改变
|
const onHandleCurrentChange = (val: number) => {
|
state.listQuery.pageIndex = val;
|
getData()
|
};
|
|
const openFile=(file: string)=>{
|
// axios.get(import.meta.env.VITE_API_URL + file,{headers:{'Content-Type': 'application/json','Authorization': `${Cookies.get('token')}`,'uid':`${Cookies.get('uid')}`},responseType: 'blob'}).then(res=>{
|
// if (res) {
|
// const link = document.createElement('a')
|
// let blob = new Blob([res.data],{type: 'application/pdf'})
|
// link.style.display = "none";
|
// link.href = URL.createObjectURL(blob); // 创建URL
|
// window.open(link.href)
|
// } else {
|
// ElMessage({
|
// type: 'warning',
|
// message: '文件读取失败'
|
// });
|
// }
|
// })
|
window.open(file)
|
}
|
|
return {
|
reportRef,
|
openDialog,
|
getData,
|
onRowDel,
|
onHandleSizeChange,
|
onHandleCurrentChange,
|
openFile,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|
<style lang="scss" scoped>
|
.home-container {
|
height: calc(100vh - 144px);
|
box-sizing: border-box;
|
overflow: hidden;
|
.demo-tabs {
|
width: 100%;
|
height: 100%;
|
|
&::v-deep(.el-tabs__content) {
|
height: calc(100% - 60px);
|
}
|
|
.el-tab-pane {
|
height: 100%;
|
}
|
}
|
.homeCard {
|
width: 100%;
|
padding: 20px;
|
box-sizing: border-box;
|
background: #fff;
|
border-radius: 4px;
|
|
.main-card {
|
width: 100%;
|
height: 100%;
|
.cardTop {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 20px;
|
.mainCardBtn {
|
margin: 0;
|
}
|
}
|
.pageBtn {
|
height: 60px;
|
display: flex;
|
align-items: center;
|
justify-content: right;
|
|
.demo-pagination-block + .demo-pagination-block {
|
margin-top: 10px;
|
}
|
.demo-pagination-block .demonstration {
|
margin-bottom: 16px;
|
}
|
}
|
}
|
&:last-of-type {
|
height: calc(100% - 100px);
|
}
|
}
|
.el-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 20px;
|
&:last-child {
|
margin-bottom: 0;
|
}
|
.grid-content {
|
align-items: center;
|
min-height: 36px;
|
}
|
|
.topInfo {
|
display: flex;
|
align-items: center;
|
font-size: 16px;
|
font-weight: bold;
|
|
& > div {
|
white-space: nowrap;
|
margin-right: 20px;
|
}
|
}
|
}
|
.el-card {
|
border: 0;
|
}
|
}
|
</style>
|