2023-05-10 08:40:05 +08:00
|
|
|
<template>
|
2023-05-19 19:17:28 +08:00
|
|
|
<div class="log">
|
|
|
|
<a-card class="log-tree" :bordered="false">
|
|
|
|
<!-- 标题 -->
|
|
|
|
<template slot="title">
|
|
|
|
<div class="title">
|
|
|
|
<div class="title-text">LOG</div>
|
|
|
|
<div class="title-rect">
|
|
|
|
<span></span>
|
|
|
|
<span></span>
|
|
|
|
<span></span>
|
|
|
|
<span></span>
|
|
|
|
<span></span>
|
|
|
|
<span></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<!-- 标题结束 -->
|
|
|
|
<!-- 内容 -->
|
2023-05-26 20:06:17 +08:00
|
|
|
<a-spin :spinning="isGettingTreeData" style="margin-top: 80px; width: 100%; text-align: center;"> </a-spin>
|
|
|
|
<tree-with-line
|
|
|
|
v-if="treeData.length"
|
|
|
|
:treeData="treeData"
|
|
|
|
:selected-keys.sync="selectedKeys"
|
|
|
|
:expanded-keys.sync="expandedKeys"
|
|
|
|
@select="onSelect"
|
|
|
|
>
|
|
|
|
</tree-with-line>
|
2023-05-19 19:17:28 +08:00
|
|
|
<!-- 内容结束 -->
|
|
|
|
</a-card>
|
2023-05-25 19:42:39 +08:00
|
|
|
<!-- 日志列表 -->
|
2023-05-19 19:17:28 +08:00
|
|
|
<div class="log-list">
|
|
|
|
<custom-table
|
|
|
|
size="middle"
|
|
|
|
rowKey="id"
|
|
|
|
:columns="columns"
|
|
|
|
:list="dataSource"
|
|
|
|
:pagination="false"
|
2023-05-25 19:42:39 +08:00
|
|
|
:loading="isGettingTreeData || loading"
|
2023-05-19 19:17:28 +08:00
|
|
|
:can-select="false"
|
|
|
|
@change="handleTableChange"
|
2023-05-25 19:42:39 +08:00
|
|
|
:scroll="{ y: 'calc(100vh - 175px)' }"
|
2023-05-19 19:17:28 +08:00
|
|
|
>
|
|
|
|
<template slot="operate" slot-scope="{ record }">
|
|
|
|
<a-space :size="20">
|
|
|
|
<img src="@/assets/images/log/operate.png" alt="" style="cursor: pointer" @click.stop="onOperate(record)" />
|
|
|
|
<img
|
|
|
|
src="@/assets/images/log/download.png"
|
|
|
|
alt=""
|
|
|
|
style="cursor: pointer"
|
|
|
|
@click.stop="onDownload(record)"
|
|
|
|
/>
|
|
|
|
</a-space>
|
|
|
|
</template>
|
|
|
|
</custom-table>
|
|
|
|
</div>
|
2023-05-25 19:42:39 +08:00
|
|
|
<!-- 日志列表结束 -->
|
2023-07-06 14:05:43 +08:00
|
|
|
<custom-modal title="Log" :width="950" v-model="visible" :footer="null">
|
2023-05-26 20:06:17 +08:00
|
|
|
<a-spin class="log-detail" :spinning="isGettingDetail">
|
2023-05-26 15:07:08 +08:00
|
|
|
<div v-for="(logItem, index) in logInfo" :key="index">
|
|
|
|
{{ logItem }}
|
|
|
|
</div>
|
2023-05-25 19:42:39 +08:00
|
|
|
</a-spin>
|
2023-05-19 19:17:28 +08:00
|
|
|
</custom-modal>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
|
|
|
import TreeWithLine from '@/components/TreeWithLine/index.vue'
|
2023-05-25 19:42:39 +08:00
|
|
|
import { downloadFile, getAction, postAction } from '../../api/manage'
|
2023-05-19 19:17:28 +08:00
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
2023-05-25 19:42:39 +08:00
|
|
|
title: 'NAME',
|
2023-05-19 19:17:28 +08:00
|
|
|
align: 'center',
|
2023-05-25 19:42:39 +08:00
|
|
|
width: 320,
|
|
|
|
dataIndex: 'fileName'
|
2023-05-19 19:17:28 +08:00
|
|
|
},
|
|
|
|
{
|
2023-05-25 19:42:39 +08:00
|
|
|
title: 'DATE',
|
2023-05-19 19:17:28 +08:00
|
|
|
align: 'center',
|
2023-05-25 19:42:39 +08:00
|
|
|
width: 200,
|
|
|
|
dataIndex: 'fileDate'
|
2023-05-19 19:17:28 +08:00
|
|
|
},
|
|
|
|
{
|
2023-05-25 19:42:39 +08:00
|
|
|
title: 'SIZE',
|
2023-05-19 19:17:28 +08:00
|
|
|
align: 'center',
|
2023-05-25 19:42:39 +08:00
|
|
|
width: 220,
|
|
|
|
dataIndex: 'fileSize'
|
2023-05-19 19:17:28 +08:00
|
|
|
},
|
|
|
|
{
|
2023-05-25 19:42:39 +08:00
|
|
|
title: 'OPERATE',
|
2023-05-19 19:17:28 +08:00
|
|
|
align: 'center',
|
2023-05-25 19:42:39 +08:00
|
|
|
width: 200,
|
2023-05-19 19:17:28 +08:00
|
|
|
scopedSlots: {
|
|
|
|
customRender: 'operate'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
export default {
|
|
|
|
mixins: [JeecgListMixin],
|
|
|
|
components: {
|
|
|
|
TreeWithLine
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
this.columns = columns
|
|
|
|
return {
|
2023-05-22 15:20:34 +08:00
|
|
|
disableMixinCreated: true,
|
2023-05-19 19:17:28 +08:00
|
|
|
url: {
|
2023-05-25 19:42:39 +08:00
|
|
|
list: '/logManage/findFiles'
|
2023-05-19 19:17:28 +08:00
|
|
|
},
|
2023-05-22 15:20:34 +08:00
|
|
|
isGettingTreeData: false, // 正在获取左侧树信息
|
2023-05-23 16:30:09 +08:00
|
|
|
treeData: [],
|
|
|
|
selectedKeys: [],
|
|
|
|
expandedKeys: [],
|
2023-05-25 19:42:39 +08:00
|
|
|
dataSource: [],
|
|
|
|
|
|
|
|
visible: false,
|
|
|
|
isGettingDetail: false,
|
2023-05-26 15:07:08 +08:00
|
|
|
logInfo: []
|
2023-05-19 19:17:28 +08:00
|
|
|
}
|
|
|
|
},
|
2023-05-22 15:20:34 +08:00
|
|
|
created() {
|
|
|
|
this.getTreeData()
|
|
|
|
},
|
2023-05-19 19:17:28 +08:00
|
|
|
methods: {
|
2023-05-23 16:30:09 +08:00
|
|
|
async getTreeData() {
|
2023-05-22 15:20:34 +08:00
|
|
|
try {
|
|
|
|
this.isGettingTreeData = true
|
2023-05-25 19:42:39 +08:00
|
|
|
const res = await getAction('/logManage/findFtpFolders', { workPath: 'log' })
|
|
|
|
this.treeData = this.buildTreeData(res)
|
2023-05-23 16:30:09 +08:00
|
|
|
const firstNode = this.treeData[0]
|
|
|
|
this.selectedKeys = [firstNode.key]
|
|
|
|
this.expandedKeys = [firstNode.key]
|
2023-05-22 15:20:34 +08:00
|
|
|
this.onSelect()
|
2023-05-25 19:42:39 +08:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
this.$message.error('Get Tree Data Failed')
|
2023-05-22 15:20:34 +08:00
|
|
|
} finally {
|
|
|
|
this.isGettingTreeData = false
|
|
|
|
}
|
|
|
|
},
|
2023-05-23 16:30:09 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Array<any>} treeJson
|
|
|
|
*/
|
|
|
|
buildTreeData(treeJson) {
|
|
|
|
const tree = []
|
|
|
|
treeJson.forEach(item => {
|
|
|
|
const treeNode = {
|
|
|
|
title: item.name,
|
|
|
|
key: item.path,
|
|
|
|
children: []
|
|
|
|
}
|
|
|
|
if (item.children && item.children.length) {
|
|
|
|
treeNode.children.push(...this.buildTreeData(item.children))
|
|
|
|
}
|
|
|
|
tree.push(treeNode)
|
|
|
|
})
|
|
|
|
return tree
|
|
|
|
},
|
|
|
|
onSelect() {
|
2023-05-25 19:42:39 +08:00
|
|
|
this.queryParam.path = this.selectedKeys[0]
|
2023-05-22 15:20:34 +08:00
|
|
|
this.loadData()
|
|
|
|
},
|
2023-05-25 19:42:39 +08:00
|
|
|
|
|
|
|
loadData(arg) {
|
|
|
|
if (!this.url.list) {
|
|
|
|
this.$message.error('请设置url.list属性!')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
//加载数据 若传入参数1则加载第一页的内容
|
|
|
|
if (arg === 1) {
|
|
|
|
this.ipagination.current = 1
|
|
|
|
}
|
|
|
|
this.onClearSelected()
|
|
|
|
|
|
|
|
var params = this.getQueryParams() //查询条件
|
|
|
|
this.loading = true
|
|
|
|
getAction(this.url.list, params)
|
|
|
|
.then(res => {
|
|
|
|
this.dataSource = res
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
async onOperate({ fileName, filePath, fileSize }) {
|
|
|
|
if (parseFloat(fileSize) == 0) {
|
|
|
|
this.$message.warn('This Log Is Empty')
|
|
|
|
return
|
|
|
|
}
|
2023-05-19 19:17:28 +08:00
|
|
|
this.visible = true
|
2023-05-25 19:42:39 +08:00
|
|
|
const formData = new FormData()
|
|
|
|
formData.append('fileName', fileName)
|
|
|
|
formData.append('localPath', filePath)
|
|
|
|
try {
|
|
|
|
this.isGettingDetail = true
|
|
|
|
const res = await postAction('/logManage/downloadFile', formData)
|
2023-05-26 15:07:08 +08:00
|
|
|
this.logInfo = res.split('\r\n')
|
2023-05-25 19:42:39 +08:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
} finally {
|
|
|
|
this.isGettingDetail = false
|
|
|
|
}
|
2023-05-19 19:17:28 +08:00
|
|
|
},
|
2023-05-25 19:42:39 +08:00
|
|
|
onDownload({ fileName, filePath, fileSize }) {
|
|
|
|
if (parseFloat(fileSize) == 0) {
|
|
|
|
this.$message.warn('This Log Is Empty')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const formData = new FormData()
|
|
|
|
formData.append('fileName', fileName)
|
|
|
|
formData.append('localPath', filePath)
|
|
|
|
downloadFile('/logManage/downloadFile', fileName, formData, 'post')
|
2023-05-19 19:17:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
|
|
.log {
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
&-tree {
|
|
|
|
width: 290px;
|
|
|
|
height: 100%;
|
|
|
|
flex-shrink: 0;
|
|
|
|
margin-right: 20px;
|
|
|
|
background-color: #022024;
|
|
|
|
border: 1px solid #0c6a66;
|
|
|
|
::v-deep {
|
|
|
|
.ant-card {
|
|
|
|
&-head {
|
|
|
|
border-bottom: 4px solid rgba(12, 235, 201, 0.2);
|
|
|
|
height: auto;
|
|
|
|
&-title {
|
|
|
|
height: 45px;
|
|
|
|
line-height: 45px;
|
|
|
|
padding: 0;
|
|
|
|
padding-right: 20px;
|
|
|
|
font-family: MicrogrammaD-MediExte;
|
|
|
|
font-size: 18px;
|
|
|
|
font-weight: bold;
|
|
|
|
color: #0cebc9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&-body {
|
2023-05-26 20:06:17 +08:00
|
|
|
padding-left: 20px;
|
2023-05-19 19:17:28 +08:00
|
|
|
height: calc(100% - 50px);
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.title {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
&-text {
|
|
|
|
padding-left: 20px;
|
|
|
|
width: 100px;
|
|
|
|
background-color: rgba(12, 235, 201, 0.05);
|
|
|
|
}
|
|
|
|
|
|
|
|
&-rect {
|
|
|
|
span {
|
|
|
|
display: inline-block;
|
|
|
|
background-color: rgba(12, 235, 201, 0.2);
|
|
|
|
vertical-align: middle;
|
|
|
|
&:first-child {
|
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
|
|
|
}
|
|
|
|
&:nth-child(2) {
|
|
|
|
width: 6px;
|
|
|
|
height: 6px;
|
|
|
|
margin-right: 6px;
|
|
|
|
}
|
|
|
|
&:nth-child(3) {
|
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
|
|
|
margin-right: 9px;
|
|
|
|
}
|
|
|
|
&:nth-child(4) {
|
|
|
|
width: 1px;
|
|
|
|
height: 16px;
|
|
|
|
margin-right: 23px;
|
|
|
|
}
|
|
|
|
&:nth-child(5) {
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
|
|
|
margin-right: 24px;
|
|
|
|
}
|
|
|
|
&:nth-child(6) {
|
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-26 20:06:17 +08:00
|
|
|
}
|
2023-05-19 19:17:28 +08:00
|
|
|
|
2023-05-26 20:06:17 +08:00
|
|
|
.log-detail {
|
|
|
|
::v-deep {
|
|
|
|
.ant-spin-container {
|
|
|
|
min-height: 100px;
|
|
|
|
max-height: 520px;
|
|
|
|
overflow: auto;
|
|
|
|
padding: 10px;
|
|
|
|
}
|
2023-05-19 19:17:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|