|
|
@ -17,7 +17,7 @@ |
|
|
|
<el-table-column prop="createTime" label="导入时间" align="center"></el-table-column> |
|
|
|
<el-table-column prop="createTime" label="导入时间" align="center"></el-table-column> |
|
|
|
<el-table-column prop="fileSize" label="文件大小" width="120" align="center"> |
|
|
|
<el-table-column prop="fileSize" label="文件大小" width="120" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
{{ (scope.row.fileSize / 1024 / 1024).toFixed(2) }}MB |
|
|
|
{{ (scope.row.fileSize / 1024 / 1024).toFixed(3) }}MB |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="fileFormat" label="格式" width="100" align="center"></el-table-column> |
|
|
|
<el-table-column prop="fileFormat" label="格式" width="100" align="center"></el-table-column> |
|
|
@ -66,13 +66,13 @@ |
|
|
|
:props="{ |
|
|
|
:props="{ |
|
|
|
label: 'categoryName' |
|
|
|
label: 'categoryName' |
|
|
|
}" |
|
|
|
}" |
|
|
|
@node-click="getTable" |
|
|
|
@node-click="typeClick" |
|
|
|
> |
|
|
|
> |
|
|
|
</el-tree> |
|
|
|
</el-tree> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-main style="padding-top: 0;padding-bottom: 0;"> |
|
|
|
<el-main style="padding-top: 0;padding-bottom: 0;"> |
|
|
|
<el-card shadow="hover"> |
|
|
|
<el-card shadow="hover"> |
|
|
|
<el-input style="width: 250px;margin-bottom: 15px;" placeholder="请输入表名称" v-model="keyword" suffix-icon="el-icon-search" clearable size="small"></el-input> |
|
|
|
<el-input style="width: 250px;margin-bottom: 15px;" placeholder="请输入表名称" v-model="keywordTable" suffix-icon="el-icon-search" clearable size="small"></el-input> |
|
|
|
<el-table :data="tables" class="cus-table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> |
|
|
|
<el-table :data="tables" class="cus-table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> |
|
|
|
<el-table-column width="40" align="center"> |
|
|
|
<el-table-column width="40" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<template slot-scope="scope"> |
|
|
@ -108,15 +108,22 @@ |
|
|
|
</el-container> |
|
|
|
</el-container> |
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<el-button @click="importVisible = false">取 消</el-button> |
|
|
|
<el-button @click="importVisible = false">取 消</el-button> |
|
|
|
<el-button type="primary" :loading="submited" @click="confirmImport">确 定</el-button> |
|
|
|
<el-button class="cus-btn" type="primary" :loading="submited" @click="confirmImport">确 定</el-button> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
</el-dialog> |
|
|
|
<el-dialog title="预览" :visible.sync="previewVisible" width="60%" center :close-on-click-modal="false"> |
|
|
|
<el-dialog title="预览" :visible.sync="previewVisible" width="60%" center :close-on-click-modal="false"> |
|
|
|
<el-table :data="previewData" class="table" stripe header-align="center" row-key="id"> |
|
|
|
<el-table :data="previewData" class="cus-table" stripe header-align="center" row-key="id"> |
|
|
|
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> |
|
|
|
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> |
|
|
|
<el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.comment" align="center"></el-table-column> |
|
|
|
<el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.comment" align="center"></el-table-column> |
|
|
|
</el-table> |
|
|
|
</el-table> |
|
|
|
</el-dialog> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 购买弹框 --> |
|
|
|
|
|
|
|
<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=""> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -160,18 +167,25 @@ export default { |
|
|
|
previewVisible: false, |
|
|
|
previewVisible: false, |
|
|
|
previewHead: [], |
|
|
|
previewHead: [], |
|
|
|
previewData: [], |
|
|
|
previewData: [], |
|
|
|
|
|
|
|
buyVisible: false |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
components: { |
|
|
|
components: { |
|
|
|
breadcrumb |
|
|
|
breadcrumb |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
|
keyword: function(val) { |
|
|
|
keyword: function(val) { |
|
|
|
clearTimeout(this.searchTimer) |
|
|
|
clearTimeout(this.searchTimer) |
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
this.initData() |
|
|
|
this.initData() |
|
|
|
},500) |
|
|
|
},500) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
keywordTable: function(val) { |
|
|
|
|
|
|
|
clearTimeout(this.searchTimer) |
|
|
|
|
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
|
|
|
|
this.initTable() |
|
|
|
|
|
|
|
},500) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
created() { |
|
|
|
created() { |
|
|
|
this.loading = true |
|
|
|
this.loading = true |
|
|
@ -282,17 +296,27 @@ export default { |
|
|
|
this.curTable = '' |
|
|
|
this.curTable = '' |
|
|
|
this.tables = [] |
|
|
|
this.tables = [] |
|
|
|
this.importLoading = true |
|
|
|
this.importLoading = true |
|
|
|
this.importVisible = true |
|
|
|
|
|
|
|
this.$post(this.api.getDataProductBoughtByOurSchool).then(({ data }) => { |
|
|
|
this.$post(this.api.getDataProductBoughtByOurSchool).then(({ data }) => { |
|
|
|
this.importTypeList = data |
|
|
|
this.importTypeList = data |
|
|
|
this.importLoading = false |
|
|
|
this.importLoading = false |
|
|
|
|
|
|
|
if (data.length) { |
|
|
|
|
|
|
|
this.importVisible = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.buyVisible = true |
|
|
|
|
|
|
|
// this.$message.error('当前院校暂未购买该数据库,请购买后再尝试') |
|
|
|
|
|
|
|
} |
|
|
|
}).catch(res => { |
|
|
|
}).catch(res => { |
|
|
|
this.importLoading = false |
|
|
|
this.importLoading = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 分类点击回调 |
|
|
|
|
|
|
|
typeClick() { |
|
|
|
|
|
|
|
this.keywordTable = '' |
|
|
|
|
|
|
|
this.getTable() |
|
|
|
|
|
|
|
}, |
|
|
|
// 查询分类下的表 |
|
|
|
// 查询分类下的表 |
|
|
|
getTable(){ |
|
|
|
getTable(){ |
|
|
|
this.$post(`${this.api.getPurchasedTableByCategory}?categoryId=${this.$refs.typeTree.getCurrentKey()}&pageNum=${this.pageTable}&pageSize=${this.pageSizeTable}`).then(({ data }) => { |
|
|
|
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 |
|
|
|
const list = data.records |
|
|
|
list.map(e => { |
|
|
|
list.map(e => { |
|
|
|
// 开始结束日期不用显示时间,所以只需要截取日期 |
|
|
|
// 开始结束日期不用显示时间,所以只需要截取日期 |
|
|
@ -310,42 +334,39 @@ export default { |
|
|
|
this.totalTable = data.total |
|
|
|
this.totalTable = data.total |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 重置表分页 |
|
|
|
|
|
|
|
initTable() { |
|
|
|
|
|
|
|
this.pageTable = 1 |
|
|
|
|
|
|
|
this.getTable() |
|
|
|
|
|
|
|
}, |
|
|
|
handleCurrentChangeTable(val) { |
|
|
|
handleCurrentChangeTable(val) { |
|
|
|
this.pageTable = val |
|
|
|
this.pageTable = val |
|
|
|
this.getTable() |
|
|
|
this.getTable() |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 预览 |
|
|
|
// 预览 |
|
|
|
preview(row){ |
|
|
|
preview(row){ |
|
|
|
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => { |
|
|
|
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(({ comment, data }) => { |
|
|
|
let comment = res.comment |
|
|
|
let previewHead = [] |
|
|
|
let previewHead = [] |
|
|
|
comment.map(n => { |
|
|
|
this.curComment = comment // 用来修改表头的,先保存完整的表头,修改表头的时候需要传给后端 |
|
|
|
// 表格上不用展示id和操作时间 |
|
|
|
comment.map(n => { |
|
|
|
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n) |
|
|
|
// 表格上不用展示id和操作时间 |
|
|
|
}) |
|
|
|
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n) |
|
|
|
this.previewHead = previewHead |
|
|
|
}) |
|
|
|
data.map(n => { |
|
|
|
this.previewHead = previewHead |
|
|
|
for(let i in n){ |
|
|
|
|
|
|
|
// 如果是以+0000结尾的,就表明这个是时间,则转化为正常的时间格式 |
|
|
|
let data = res.data |
|
|
|
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) |
|
|
|
// 如果是自定义表头,则在数据最前面加个custom的行,用来修改表头 |
|
|
|
} |
|
|
|
isEdit && data.unshift({ |
|
|
|
}) |
|
|
|
custom: true |
|
|
|
this.previewData = data |
|
|
|
}) |
|
|
|
this.previewVisible = true |
|
|
|
data.map(n => { |
|
|
|
}).catch(res => {}) |
|
|
|
for(let i in n){ |
|
|
|
|
|
|
|
// 如果是以+0000结尾的,就表明这个是时间,则转化为正常的时间格式 |
|
|
|
|
|
|
|
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 => {}) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 上传到python数据列表 |
|
|
|
// 上传到python数据列表 |
|
|
|
importData(file) { |
|
|
|
importData(file, row) { |
|
|
|
this.$post(this.api.importData, { |
|
|
|
this.$post(this.api.importData, { |
|
|
|
fileFormat: file.fileType || file.fileFormat, |
|
|
|
fileFormat: file.fileType || file.fileFormat, |
|
|
|
fileName: file.originalFileName || file.fileName, |
|
|
|
fileName: row.tableComment || file.fileName, |
|
|
|
filePath: file.fileUrl || file.filePath, |
|
|
|
filePath: file.fileUrl || file.filePath, |
|
|
|
fileSize: file.fileSize, |
|
|
|
fileSize: file.fileSize, |
|
|
|
ossFileName: file.ossFileName |
|
|
|
ossFileName: file.ossFileName |
|
|
@ -371,7 +392,7 @@ export default { |
|
|
|
const { name } = row |
|
|
|
const { name } = row |
|
|
|
this.submited = true |
|
|
|
this.submited = true |
|
|
|
// 查询某表的Excel文件是否存在 |
|
|
|
// 查询某表的Excel文件是否存在 |
|
|
|
this.$post(`${this.api.lookupTableFile}?tableName=${name}`).then(({ data }) => { |
|
|
|
this.$post(`${this.api.lookupTableFile}?tableName=${row.tableComment}`).then(({ data }) => { |
|
|
|
// 如果不存在,则下载该表并上传到阿里云 |
|
|
|
// 如果不存在,则下载该表并上传到阿里云 |
|
|
|
if (!data) { |
|
|
|
if (!data) { |
|
|
|
// 通过预览接口获取字段 |
|
|
|
// 通过预览接口获取字段 |
|
|
@ -387,7 +408,7 @@ export default { |
|
|
|
// 把该表上传到阿里云 |
|
|
|
// 把该表上传到阿里云 |
|
|
|
const form = new FormData() |
|
|
|
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', name) |
|
|
|
form.append('tableName', row.name.replace(/(\r|\n)+/, '')) |
|
|
|
form.append('token', this.token) |
|
|
|
form.append('token', this.token) |
|
|
|
axios({ |
|
|
|
axios({ |
|
|
|
method: 'post', |
|
|
|
method: 'post', |
|
|
@ -398,7 +419,7 @@ export default { |
|
|
|
'Content-Type': 'multipart/form-data' |
|
|
|
'Content-Type': 'multipart/form-data' |
|
|
|
}, |
|
|
|
}, |
|
|
|
}).then(({ data }) => { |
|
|
|
}).then(({ data }) => { |
|
|
|
this.importData(data.filesResult) |
|
|
|
this.importData(data.filesResult, row) |
|
|
|
}).catch(res => { |
|
|
|
}).catch(res => { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
|
}) |
|
|
|
}) |
|
|
@ -410,7 +431,7 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 如果数据库里已经有这个表,则直接调导入数据的接口 |
|
|
|
// 如果数据库里已经有这个表,则直接调导入数据的接口 |
|
|
|
this.importData(data) |
|
|
|
this.importData(data, {}) |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(res => { |
|
|
|
}).catch(res => { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
@ -456,9 +477,12 @@ export default { |
|
|
|
display: inline-flex; |
|
|
|
display: inline-flex; |
|
|
|
justify-content: center; |
|
|
|
justify-content: center; |
|
|
|
align-items: center; |
|
|
|
align-items: center; |
|
|
|
height: 100px; |
|
|
|
height: 80px; |
|
|
|
border: 1px solid #ccc; |
|
|
|
font-size: 16px; |
|
|
|
|
|
|
|
color: #333; |
|
|
|
border-radius: 8px; |
|
|
|
border-radius: 8px; |
|
|
|
|
|
|
|
background-color: #F6F8FA; |
|
|
|
|
|
|
|
border: 1px solid transparent; |
|
|
|
cursor: pointer; |
|
|
|
cursor: pointer; |
|
|
|
img { |
|
|
|
img { |
|
|
|
width: 90%; |
|
|
|
width: 90%; |
|
|
@ -477,9 +501,29 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.buy { |
|
|
|
|
|
|
|
text-align: center; |
|
|
|
|
|
|
|
.tips { |
|
|
|
|
|
|
|
margin-bottom: 10px; |
|
|
|
|
|
|
|
font-size: 14px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
img { |
|
|
|
|
|
|
|
width: 85%; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/deep/.check-table { |
|
|
|
/deep/.check-table { |
|
|
|
.el-radio__label { |
|
|
|
.el-radio__label { |
|
|
|
display: none; |
|
|
|
display: none; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/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 { |
|
|
|
|
|
|
|
border-color: #007eff; |
|
|
|
|
|
|
|
background: #007eff; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/deep/.el-radio__inner:hover { |
|
|
|
|
|
|
|
border-color: #007eff; |
|
|
|
|
|
|
|
} |
|
|
|
</style> |
|
|
|
</style> |