<template> <div class="test-link"> <div class="title"> <div class="logo-text"> <img class="logo" src="../../assets/img/logo.png" /> <span>新疆互联网违法和不良信息举报中心</span> </div> <div class="subhead">—— 全平台链接测试工具</div> </div> <div class="main"> <div class="text">平台链接测试支持:抖音、快手、西瓜、微视等主流短视频平台,微博、 小红书、贴吧、b站、公众号</div> <div class="button-area"> <el-button type="primary" @click="test">链接测试</el-button> <el-upload :limit="1" :show-file-list="false" :http-request="uploadFile" :file-list="fileList" class="upload-btn" action="string" accept=".xls,.xlsx"> <el-button class="filter-item" style="margin: 0 10px;" type="primary" icon="el-icon-download">导入</el-button> </el-upload> <el-button type="primary" icon="el-icon-upload2">导出</el-button> </div> </div> <div class="table-area"> <el-table v-loading="tableLoading" :data="tableData" border stripe :show-overflow-tooltip="true" style="width: 100%" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55"></el-table-column> <el-table-column label="序号" width="55" align="center"> <template slot-scope="scope"> {{ (pageNum - 1) * pageSize + scope.$index + 1 }} </template> </el-table-column> <el-table-column align="center" v-for="item in tableHead" :key="item.id" :prop="item.id" :label="item.name" :width="item.width" ></el-table-column> </el-table> </div> <PageNum :pageSize="pageSize" :pageNum="pageNum" :total="total" @changePageSize="changePageSize" @changePageNum="changePageNum" /> <AddTestUrlDialog v-show="dialogFormVisible" ref="addTestUrlDialogRef" @watchChild="fetchData"/> </div> </template> <script> import PageNum from '../page/pageNum.vue'; import { getListPage, batchImport } from '@/api/testLink' import AddTestUrlDialog from './components/addTestUrlDialog.vue' export default { name: 'TestLink', components: { AddTestUrlDialog, PageNum }, data() { return { fileList: [], // 批量导入 tableData: [], //表格数据 tableHead: [ { id: 'testPlatform', name: '测试平台' }, { id: 'testUrl', name: '链接地址' }, { id: 'createTime', name: '测试时间', width: '140' }, { id: 'testTime', name: '测试耗时/ms' }, { id: 'testResult', name: '测试结果', width: '80' }, ], //表头 checkoutList: [], pageSize: 10, //一页多少条 pageNum: 1, //第几页 total: 50, //总条数 tableLoading: false, //表格loading tableHeight: document.body.clientHeight - 220, //表格固定高度 dialogFormVisible: false, // 是否显示编辑框 } }, mounted() { this.fetchData() }, methods: { //多选 handleSelectionChange(val) { this.checkoutList = val; console.log(this.checkoutList); }, changePageSize(val) { this.pageSize = val; this.fetchData() }, changePageNum(val) { this.pageNum = val; this.fetchData() }, // 获取数据 fetchData() { getListPage({limit: this.pageSize, offset: this.pageNum}).then(res => { if(res.code === 200) { this.tableData = res.data.rows this.total = res.data.total } }).catch(() => { this.$message.error('请求失败') }) }, // 批量导入 uploadFile(param) { // 判断文件大小是否符合要求 const _file = param.file const isLt5M = _file.size / 1024 / 1024 < 5 if (!isLt5M) { this.$message.error('请上传5M以下的excel文件') return false } // 全屏加载动画 const loading = this.$loading({ lock: true, text: '导入中,请稍后...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) // 批量导入上传请求 batchImport(_file).then(res => { loading.close() // 关闭加载动画 if (res.code === 200) { this.$message.success('导入成功') this.fileList = [] this.fetchData() } else { this.$message.error(res.message) } }).catch(err => { loading.close() this.$message.error(err.message) }) this.fileList = [] }, // 点击链接测试 test() { this.dialogFormVisible = true this.$refs.addTestUrlDialogRef.initDialog(this.dialogFormVisible) } } } </script> <style lang="scss" scoped> .test-link { width: 100%; height: 100%; padding-bottom: 20px; .title { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; height: 100px; background: url('../../assets/img/bg.png') no-repeat center; background-size: 100% 100%; padding: 0 20px; .logo-text { display: flex; justify-content: center; align-items: center; font-size: 32px; color: #fff; letter-spacing: 8px; font-weight: 600; .logo { height: 50px; height: 50px; margin-right: 20px; } } .subhead { width: 100%; text-align: right; font-size: 22px; color: #fff; margin-right: 80px; } } .main { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px 0 20px; .text { margin-right: 60px; text-align: left; font-size: 13px; } .button-area { display: flex; flex-wrap: nowrap; } } .table-area { padding: 10px 20px; } } </style> <style lang="scss"> .test-link { .el-button { background-color: #169bd5; } .el-table th.el-table__cell { background-color: rgba(0, 150, 224, .1); color: #444c59; font-weight: 600; } .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell { // background-color: rgba(0, 150, 224, .1); } .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner { background-color: #169bd5; border-color: #169bd5; } .el-table .cell { line-height: 16px; } } </style>