|
|
|
<template>
|
|
|
|
<div class="logMainClass">
|
|
|
|
<h3>日志列表
|
|
|
|
|
|
|
|
<el-select v-model="logValue" placeholder="请选择" @change="logTypeChange">
|
|
|
|
<el-option
|
|
|
|
v-for="item in LogOptions"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value">
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</h3>
|
|
|
|
<div class="boxLogTable">
|
|
|
|
<el-table
|
|
|
|
v-loading="logLoading"
|
|
|
|
:data="tableData"
|
|
|
|
border
|
|
|
|
stripe
|
|
|
|
style="width: 100%"
|
|
|
|
height="100%"
|
|
|
|
>
|
|
|
|
<el-table-column type="index" width="50" label="序号">
|
|
|
|
</el-table-column>
|
|
|
|
<!-- <el-table-column prop="id" label="Id" width="80"> </el-table-column> -->
|
|
|
|
<el-table-column prop="lineName" label="线路"> </el-table-column>
|
|
|
|
<el-table-column prop="cmdid" label="装置编号" width="160"> </el-table-column>
|
|
|
|
<el-table-column label="规约" width="140">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
{{ protocolMap[scope.row.protocol] }}
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column prop="fileName" label="文件名">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<!-- <a :href="'http://61.169.135.146:40085/dl/' + scope.row.path" class="buttonText"></a> -->
|
|
|
|
<el-button type="text" @click="downFile(scope.row)" class="buttonText">{{
|
|
|
|
scope.row.fileName
|
|
|
|
}}</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="文件大小" width="100">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
{{ scope.row.fileSize | changeType }}
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column prop="createTime" label="上传时间" width="160"> </el-table-column>
|
|
|
|
<el-table-column label="操作" class-name="editClass" >
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-link
|
|
|
|
type="danger"
|
|
|
|
@click="handleDeleteClick(scope.row)"
|
|
|
|
size="small"
|
|
|
|
icon="el-icon-delete"
|
|
|
|
>删除</el-link
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { logListApi,logDeleteApi} from "@/utils/api/index";
|
|
|
|
export default {
|
|
|
|
name: "log",
|
|
|
|
components: {},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
logValue:0,
|
|
|
|
LogOptions:[{
|
|
|
|
value: 0,
|
|
|
|
label: '日志'
|
|
|
|
}, {
|
|
|
|
value: 1,
|
|
|
|
label: '其它'
|
|
|
|
}],
|
|
|
|
tableData: [],
|
|
|
|
logLoading: false,
|
|
|
|
protocolMap: {
|
|
|
|
65280: "国网I1",
|
|
|
|
65296: "陕西",
|
|
|
|
65281: "安徽",
|
|
|
|
65282: "江苏",
|
|
|
|
65283: "湖南",
|
|
|
|
65284: "浙江",
|
|
|
|
65285: "河南全景",
|
|
|
|
65286: "河南郑州",
|
|
|
|
65290: "河南统一视频v2020",
|
|
|
|
65298:"宁夏",
|
|
|
|
2:"南网"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
filters: {
|
|
|
|
changeType(val) {
|
|
|
|
if (val == "0") return "0B";
|
|
|
|
var k = 1024;
|
|
|
|
var sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
|
|
|
|
|
|
let i = Math.floor(Math.log(val) / Math.log(k)); //得出该数字的单位应该是kB?MB
|
|
|
|
return (val / Math.pow(k, i)).toPrecision(3) + "" + sizes[i];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {},
|
|
|
|
created() {},
|
|
|
|
mounted() {
|
|
|
|
this.getLogList(0);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
logTypeChange(val){
|
|
|
|
this.getLogList(val)
|
|
|
|
},
|
|
|
|
getLogList(val) {
|
|
|
|
this.logLoading = true;
|
|
|
|
logListApi({type:val})
|
|
|
|
.then((res) => {
|
|
|
|
this.tableData = res.data;
|
|
|
|
this.logLoading = false;
|
|
|
|
})
|
|
|
|
.catch((err) => {});
|
|
|
|
},
|
|
|
|
handleDeleteClick(row) {
|
|
|
|
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
type: "warning",
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
logDeleteApi({
|
|
|
|
id: row.id,
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
console.log(res);
|
|
|
|
this.$message({
|
|
|
|
duration: 1500,
|
|
|
|
showClose: true,
|
|
|
|
message: "文件删除成功",
|
|
|
|
type: "success",
|
|
|
|
});
|
|
|
|
this.getLogList();
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
},
|
|
|
|
//下载日志文件
|
|
|
|
downFile(row){
|
|
|
|
|
|
|
|
// 创建一个新的a标签元素
|
|
|
|
const a = document.createElement('a');
|
|
|
|
// 设置a标签的href属性为文件的URL
|
|
|
|
a.href = '/dl/'+row.path;
|
|
|
|
console.log(a.href)
|
|
|
|
// 设置文件名(可选,取决于服务器配置)
|
|
|
|
a.download = row.fileName; // 你希望保存的文件名
|
|
|
|
|
|
|
|
// 触发点击事件
|
|
|
|
document.body.appendChild(a);
|
|
|
|
a.click();
|
|
|
|
|
|
|
|
// 然后移除a标签
|
|
|
|
document.body.removeChild(a);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="less">
|
|
|
|
.logMainClass {
|
|
|
|
height: calc(100% - 24px);
|
|
|
|
width: calc(100% - 24px);
|
|
|
|
padding: 12px;
|
|
|
|
h3 {
|
|
|
|
margin-bottom: 12px;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 24px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.boxLogTable {
|
|
|
|
height: calc(100% - 36px);
|
|
|
|
background: #fcc;
|
|
|
|
.el-table__cell {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
.el-table thead {
|
|
|
|
th.el-table__cell {
|
|
|
|
background: #fafafa;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.buttonText {
|
|
|
|
cursor: pointer;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
&:hover {
|
|
|
|
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|