@ -1,59 +1,124 @@
< template >
< div class = "wrap" v-loading ="loading" >
< div class = "wrap"
v - loading = "loading" >
< breadcrumb data = "返回实验/我的数据" > < / breadcrumb >
< div class = "inner" >
< div class = "tool" >
< el -input style = "width: 250px" placeholder = "请输入文件名称" v-model ="keyword" suffix-icon="el-icon-search" clearable size="small" > < / el -input >
< el -input style = "width: 250px"
placeholder = "请输入文件名称"
v - model = "keyword"
suffix - icon = "el-icon-search"
clearable
size = "small" > < / e l - i n p u t >
< div class = "action" >
< el -button class = "cus-btn" type = "primary" size = "small" @ click = "sourceVisible = true" > 导入数据 < / e l - b u t t o n >
< el -button class = "cus-btn" style = "margin-left: 10px;" type = "primary" size = "small" @click ="delAll" > 批量删除 < / el -button >
< el -button class = "cus-btn"
type = "primary"
size = "small"
@ click = "sourceVisible = true" > 导入数据 < / e l - b u t t o n >
< el -button class = "cus-btn"
style = "margin-left: 10px;"
type = "primary"
size = "small"
@ click = "delAll" > 批量删除 < / e l - b u t t o n >
< / div >
< / div >
< el -table :data ="list" class = "cus-table" ref = "table" stripe header -align = " center " empty -text = " 暂无数据 , 支持导入xlsx 、 csv 、 txt等格式的文件 " @selection-change ="handleSelectionChange" >
< el -table -column type = "selection" width = "80" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column type = "index" label = "序号" width = "55" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "fileName" label = "文件名称" align = "center" show -overflow -tooltip > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "createTime" label = "导入时间" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "fileSize" label = "文件大小" width = "120" align = "center" >
< el -table :data ="list"
class = "cus-table"
ref = "table"
stripe
header - align = "center"
empty - text = "暂无数据,支持导入xlsx 、csv 、txt等格式的文件"
@ selection - change = "handleSelectionChange" >
< el -table -column type = "selection"
width = "80"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column type = "index"
label = "序号"
width = "55"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "fileName"
label = "文件名称"
align = "center"
show - overflow - tooltip > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "createTime"
label = "导入时间"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "fileSize"
label = "文件大小"
width = "120"
align = "center" >
< template slot -scope = " scope " >
{ { ( scope . row . fileSize / 1024 / 1024 ) . toFixed ( 3 ) } } MB
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column prop = "fileFormat" label = "格式" width = "100" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column label = "文件路径" align = "center" >
< el -table -column prop = "fileFormat"
label = "格式"
width = "100"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column label = "文件路径"
align = "center" >
< template slot -scope = " scope " >
{ { scope . row . ossFileName } }
< i class = "el-icon-document-copy copy" @ click = "copy($event, scope.row)" > < / i >
< i class = "el-icon-document-copy copy"
@ click = "copy($event, scope.row)" > < / i >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column width = "300" label = "操作" align = "center" >
< el -table -column width = "300"
label = "操作"
align = "center" >
< template slot -scope = " scope " >
< el -button type = "text" @click ="show(scope.row)" > 查看 < / el -button >
< el -button type = "text" @click ="download(scope.row)" > 下载 < / el -button >
< el -button type = "text" @click ="del(scope.row)" > 删除 < / el -button >
< el -button type = "text"
@ click = "show(scope.row)" > 查看 < / e l - b u t t o n >
< el -button type = "text"
@ click = "download(scope.row)" > 下载 < / e l - b u t t o n >
< el -button type = "text"
@ click = "del(scope.row)" > 删除 < / e l - b u t t o n >
< / template >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< div class = "pagination" >
< el -pagination background layout = "total,prev, pager, next" :current-page ="page" @current-change ="handleCurrentChange" :total ="total" > < / e l - p a g i n a t i o n >
< el -pagination background
layout = "total,prev, pager, next"
: current - page = "page"
@ current - change = "handleCurrentChange"
: total = "total" > < / e l - p a g i n a t i o n >
< / div >
< el -dialog title = "请选择数据源" :visible.sync ="sourceVisible" width = "400px" :close-on-click-modal ="false" >
< el -dialog title = "请选择数据源"
: visible . sync = "sourceVisible"
width = "400px"
: close - on - click - modal = "false" >
< ul class = "source-list" >
< li style = "width: 48%" @click ="showData" >
< img src = "@/assets/images/dataforward.png" alt = "" >
< li style = "width: 48%"
@ click = "showData" >
< img src = "@/assets/images/dataforward.png"
alt = "" >
< / li >
< el -upload class = "upload" :headers ="{token}" :action ="api.fileUpload" name = "file" :limit ="1000" :show-file-list ="false" :before-upload ="beforeImport" :on-success ="successImport" >
< el -upload class = "upload"
drag
: headers = "{token}"
: action = "api.fileUpload"
name = "file"
: limit = "1000"
: show - file - list = "false"
: before - upload = "beforeImport"
: on - success = "successImport" >
< li style = "width: 100%;" > 本地上传 < / li >
< / e l - u p l o a d >
< / ul >
< / e l - d i a l o g >
<!-- 导入数据 -- >
< el -dialog title = "导入" :visible.sync ="importVisible" width = "80%" center class = "dialog" :close-on-click-modal ="false" >
< el -dialog title = "导入"
: visible . sync = "importVisible"
width = "80%"
center
class = "dialog"
: close - on - click - modal = "false" >
< el -container style = "padding: 20px 0 20px 20px;background-color: #f0f0f0;" >
< div style = "overflow:auto;height: 558px;width:330px;padding:15px;background:#fff" ref = "typeTreeWrap" >
< div style = "overflow:auto;height: 558px;width:330px;padding:15px;background:#fff"
ref = "typeTreeWrap" >
< el -tree v -loading = " importLoading "
ref = "typeTree"
: data = "importTypeList"
@ -66,62 +131,123 @@
: props = " {
label : 'categoryName'
} "
@ node - click = "typeClick"
>
@ node - click = "typeClick" >
< / e l - t r e e >
< / div >
< el -main style = "padding-top: 0;padding-bottom: 0;" >
< el -card shadow = "hover" >
< el -input style = "width: 250px;margin-bottom: 15px;" placeholder = "请输入表名称" v-model ="keywordTable" suffix-icon="el-icon-search" clearable size="small" > < / el -input >
< el -table v-loading ="tableLoading" :data="tables" class="cus-table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange" >
< el -table -column width = "40" align = "center" >
< el -input style = "width: 250px;margin-bottom: 15px;"
placeholder = "请输入表名称"
v - model = "keywordTable"
suffix - icon = "el-icon-search"
clearable
size = "small" > < / e l - i n p u t >
< el -table v -loading = " tableLoading "
: data = "tables"
class = "cus-table"
ref = "table"
stripe
header - align = "center"
@ selection - change = "handleSelectionChange" >
< el -table -column width = "40"
align = "center" >
< template slot -scope = " scope " >
< el -radio class = "check-table" v-model ="curTable" :label="scope.row.id" > < / el -radio >
< el -radio class = "check-table"
v - model = "curTable"
: label = "scope.row.id" > < / e l - r a d i o >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column type = "index" width = "50" label = "序号" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "tableComment" label = "数据表名称" align = "center" >
< el -table -column type = "index"
width = "50"
label = "序号"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "tableComment"
label = "数据表名称"
align = "center" >
< template slot -scope = " scope " >
{ { scope . row . tableComment ? scope . row . tableComment : scope . row . showName } }
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column prop = "dataTotal" label = "数据总量" width = "80" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "timeRange" label = "起止日期" width = "200" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "dataSize" label = "数据大小" width = "80" align = "center" >
< el -table -column prop = "dataTotal"
label = "数据总量"
width = "80"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "timeRange"
label = "起止日期"
width = "200"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column prop = "dataSize"
label = "数据大小"
width = "80"
align = "center" >
< template slot -scope = " scope " >
{ { scope . row . dataSize } } M
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column prop = "updateTime" label = "更新时间" width = "160" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column label = "操作" width = "80" align = "center" >
< el -table -column prop = "updateTime"
label = "更新时间"
width = "160"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column label = "操作"
width = "80"
align = "center" >
< template slot -scope = " scope " >
< el -button type = "text" @click ="preview(scope.row)" > 预览 < / el -button >
< el -button type = "text"
@ click = "preview(scope.row)" > 预览 < / e l - b u t t o n >
< / template >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< div class = "pagination" >
< el -pagination background layout = "total, prev, pager, next" :current-page ="pageTable" @current-change ="handleCurrentChangeTable" :total ="totalTable" >
< el -pagination background
layout = "total, prev, pager, next"
: current - page = "pageTable"
@ current - change = "handleCurrentChangeTable"
: total = "totalTable" >
< / e l - p a g i n a t i o n >
< / div >
< / e l - c a r d >
< / e l - m a i n >
< / e l - c o n t a i n e r >
< span slot = "footer" class = "dialog-footer" >
< span slot = "footer"
class = "dialog-footer" >
< el -button @ click = "importVisible = false" > 取 消 < / e l - b u t t o n >
< el -button class = "cus-btn" type = "primary" :loading ="submited" @click ="confirmImport" > 确 定 < / el -button >
< el -button class = "cus-btn"
type = "primary"
: loading = "submited"
@ click = "confirmImport" > 确 定 < / e l - b u t t o n >
< / span >
< / e l - d i a l o g >
< el -dialog title = "预览" :visible.sync ="previewVisible" width = "60%" center :close-on-click-modal ="false" >
< el -table :data ="previewData" class = "cus-table" stripe header -align = " center " row -key = " id " >
< el -table -column type = "index" width = "100" label = "序号" align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column v-for ="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.comment" align="center" > < / el -table -column >
< el -dialog title = "预览"
: visible . sync = "previewVisible"
width = "60%"
center
: close - on - click - modal = "false" >
< el -table :data ="previewData"
class = "cus-table"
stripe
header - align = "center"
row - key = "id" >
< el -table -column type = "index"
width = "100"
label = "序号"
align = "center" > < / e l - t a b l e - c o l u m n >
< el -table -column v -for = " ( item , index ) in previewHead "
: prop = "item.field"
: key = "index"
: label = "item.comment"
align = "center" > < / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< / e l - d i a l o g >
<!-- 购买弹框 -- >
< el -dialog title = "温馨提示" :visible.sync ="buyVisible" width = "400px" center :close-on-click-modal ="false" >
< el -dialog title = "温馨提示"
: visible . sync = "buyVisible"
width = "400px"
center
: close - on - click - modal = "false" >
< div class = "buy" >
< p class = "tips" > 当前院校暂未购买该数据库 , 请扫码咨询购买 < / p >
< img src = "@/assets/images/wechat-code.jpeg" alt = "" >
< img src = "@/assets/images/wechat-code.jpeg"
alt = "" >
< / div >
< / e l - d i a l o g >
< / div >
@ -134,7 +260,7 @@ import clipboard from '@/util/clipboard'
import breadcrumb from '@/components/breadcrumb'
import axios from 'axios'
export default {
data ( ) {
data ( ) {
return {
token : Cookie . get ( 'admin-token' ) ,
loading : false ,
@ -176,28 +302,28 @@ export default {
breadcrumb
} ,
watch : {
keyword : function ( val ) {
keyword : function ( val ) {
clearTimeout ( this . searchTimer )
this . searchTimer = setTimeout ( ( ) => {
this . initData ( )
} , 500 )
} , 500 )
} ,
keywordTable : function ( val ) {
keywordTable : function ( val ) {
clearTimeout ( this . searchTimer )
this . searchTimer = setTimeout ( ( ) => {
this . initTable ( )
} , 500 )
} , 500 )
}
} ,
created ( ) {
created ( ) {
this . loading = true
} ,
mounted ( ) {
mounted ( ) {
this . getData ( )
} ,
methods : {
/ / 获 取 列 表
getData ( ) {
getData ( ) {
this . $post ( ` ${ this . api . myData } ?fileName= ${ this . keyword } &pageNum= ${ this . page } &pageSize= ${ this . pageSize } ` ) . then ( res => {
const { data } = res
this . list = data . records
@ -208,12 +334,12 @@ export default {
} )
} ,
/ / 初 始 化 列 表
initData ( ) {
initData ( ) {
this . page = 1
this . getData ( )
} ,
/ / 导 入 前 的 钩 子
beforeImport ( file ) {
beforeImport ( file ) {
const { size , name } = file
if ( util . isVideo ( name . substring ( name . lastIndexOf ( '.' ) + 1 ) ) ) {
this . $message . error ( '不支持上传视频,请选择其他文件!' )
@ -225,7 +351,7 @@ export default {
}
} ,
/ / 导 入 数 据 成 功
successImport ( res ) {
successImport ( res ) {
const file = res . filesResult
const name = file . originalFileName
this . $post ( this . api . importData , {
@ -238,11 +364,11 @@ export default {
this . $message . success ( '导入成功' )
this . sourceVisible = false
this . getData ( )
} ) . catch ( res => { } )
} ) . catch ( res => { } )
} ,
/ / 批 量 删 除
delAll ( ) {
if ( this . multipleSelection . length ) {
delAll ( ) {
if ( this . multipleSelection . length ) {
const newArr = this . multipleSelection
const delList = newArr . map ( item => {
return ` ids= ${ item . id } `
@ -254,47 +380,47 @@ export default {
this . $refs . table . clearSelection ( )
this . $message . success ( '删除成功' )
this . getData ( )
} ) . catch ( res => { } )
} ) . catch ( ( ) => { } )
} else {
} ) . catch ( res => { } )
} ) . catch ( ( ) => { } )
} else {
this . $message . error ( '请先选择数据 !' )
}
} ,
/ / 复 制
copy ( e , row ) {
copy ( e , row ) {
clipboard ( row . filePath , e , '文件路径已复制!' )
} ,
/ / 查 看
show ( row ) {
show ( row ) {
const format = row . fileFormat
window . open ( ( util . isDoc ( format ) ? 'https://view.officeapps.live.com/op/view.aspx?src=' : '' ) + row . filePath )
} ,
/ / 下 载
download ( row ) {
download ( row ) {
util . downloadFile ( row . fileName + '.' + row . fileFormat , row . filePath )
} ,
/ / 删 除
del ( row ) {
del ( row ) {
this . $confirm ( '此删除操作不可逆,是否确认删除选中项?' , '提示' , {
type : 'warning'
} ) . then ( ( ) => {
this . $post ( ` ${ this . api . batchDeletion } ?ids= ${ row . id } ` ) . then ( res => {
this . $message . success ( '删除成功' )
this . getData ( )
} ) . catch ( res => { } )
} ) . catch ( ( ) => { } )
} ) . catch ( res => { } )
} ) . catch ( ( ) => { } )
} ,
handleCurrentChange ( val ) {
handleCurrentChange ( val ) {
this . page = val
this . getData ( )
} ,
handleSelectionChange ( val ) {
handleSelectionChange ( val ) {
this . multipleSelection = val
} ,
/ / 导 入 数 据
showData ( ) {
showData ( ) {
this . curTable = ''
this . tables = [ ]
this . importLoading = true
@ -318,7 +444,7 @@ export default {
} )
} ,
/ / 查 找 第 一 个 分 类 下 最 深 层 级 的 i d
getDeepestId ( data ) {
getDeepestId ( data ) {
for ( const e of data ) {
if ( e . children . length ) {
this . getDeepestId ( e . children )
@ -329,13 +455,13 @@ export default {
}
} ,
/ / 分 类 点 击 回 调
typeClick ( ) {
typeClick ( ) {
this . keywordTable = ''
this . tableLoading = true
this . getTable ( )
} ,
/ / 查 询 分 类 下 的 表
getTable ( ) {
getTable ( ) {
this . $post ( ` ${ this . api . getPurchasedTableByCategory } ?categoryId= ${ this . $refs . typeTree . getCurrentKey ( ) } &pageNum= ${ this . pageTable } &pageSize= ${ this . pageSizeTable } &name= ${ this . keywordTable } ` ) . then ( ( { data } ) => {
const list = data . records
list . map ( e => {
@ -358,16 +484,16 @@ export default {
} )
} ,
/ / 重 置 表 分 页
initTable ( ) {
initTable ( ) {
this . pageTable = 1
this . getTable ( )
} ,
handleCurrentChangeTable ( val ) {
handleCurrentChangeTable ( val ) {
this . pageTable = val
this . getTable ( )
} ,
/ / 预 览
preview ( row ) {
preview ( row ) {
this . $get ( ` ${ this . api . previewData } ?tableName= ${ row . name } &tableId= ${ row . id } ` ) . then ( ( { comment , data } ) => {
let previewHead = [ ]
comment . map ( n => {
@ -376,17 +502,17 @@ export default {
} )
this . previewHead = previewHead
data . map ( n => {
for ( let i in n ) {
for ( let i in n ) {
/ / 如 果 是 以 + 0 0 0 0 结 尾 的 , 就 表 明 这 个 是 时 间 , 则 转 化 为 正 常 的 时 间 格 式
if ( typeof n [ i ] == 'string' && n [ i ] . endsWith ( '+0000' ) ) n [ i ] = this . formatDate ( 'yyyy-MM-dd hh:mm:ss' , new Date ( n [ i ] ) )
if ( typeof n [ i ] == 'string' && n [ i ] . endsWith ( '+0000' ) ) n [ i ] = this . formatDate ( 'yyyy-MM-dd hh:mm:ss' , new Date ( n [ i ] ) )
}
} )
this . previewData = data
this . previewVisible = true
} ) . catch ( res => { } )
} ) . catch ( res => { } )
} ,
/ / 上 传 到 p y t h o n 数 据 列 表
importData ( file , row ) {
importData ( file , row ) {
this . $post ( this . api . importData , {
fileFormat : file . fileType || file . fileFormat ,
fileName : row . tableComment || file . fileName ,
@ -406,11 +532,11 @@ export default {
} )
} ,
/ / 导 入 表
confirmImport ( ) {
if ( this . submited ) return false / / 导 入 防 抖 标 识
confirmImport ( ) {
if ( this . submited ) return false / / 导 入 防 抖 标 识
const id = this . curTable / / 勾 选 的 数 据
/ / 如 果 没 有 选 择 任 何 数 据
if ( ! id ) return this . $message . warning ( '请选择数据' )
if ( ! id ) return this . $message . warning ( '请选择数据' )
const row = this . tables . find ( e => e . id === id )
const { name } = row
this . submited = true
@ -430,7 +556,7 @@ export default {
/ / i f ( r e s . d a t a . t y p e ! = ' m u l t i p a r t / f o r m - d a t a ' ) r e t u r n u t i l . w a r n i n g M s g ( ' 数 据 总 数 为 零 ! ' )
/ / 把 该 表 上 传 到 阿 里 云
const form = new FormData ( )
form . append ( 'file' , new Blob ( [ res . data ] , { type : 'application/vnd.ms-excel' } ) )
form . append ( 'file' , new Blob ( [ res . data ] , { type : 'application/vnd.ms-excel' } ) )
form . append ( 'tableName' , row . name . replace ( /(\r|\n)+/ , '' ) )
form . append ( 'token' , this . token )
axios ( {
@ -504,7 +630,7 @@ export default {
font - size : 16 px ;
color : # 333 ;
border - radius : 8 px ;
background - color : # F6F8FA ;
background - color : # f6f8fa ;
border : 1 px solid transparent ;
cursor : pointer ;
img {
@ -521,6 +647,11 @@ export default {
& : focus {
color : # 007 eff ;
}
. el - upload - dragger {
width : auto ;
height : auto ;
border : 0 ;
}
}
}
}
@ -539,7 +670,9 @@ export default {
display : none ;
}
}
/deep/ . el - tree -- highlight - current . el - tree - node . is - current > . el - tree - node _ _content {
/deep/ . el - tree -- highlight - current
. el - tree - node . is - current
> . el - tree - node _ _content {
background - color : # e8f0ff ;
}
/deep/ . el - radio _ _input . is - checked . el - radio _ _inner {