数据库导出新窗口使用post方式提交,更加优雅

This commit is contained in:
暮光:城中城
2020-09-06 16:26:39 +08:00
parent f602ccf2a4
commit 08bdaabcf5
6 changed files with 27 additions and 11 deletions

View File

@@ -250,7 +250,7 @@ public class DatabaseDocController {
return DocDbResponseJson.ok();
}
@GetMapping(value = "/exportDatabase")
@PostMapping(value = "/exportDatabase")
public ResponseJson exportDatabase(HttpServletResponse response, Long sourceId, String dbName, String tableNames, Integer exportType) {
this.judgeAuth(sourceId, DbAuthType.VIEW.getName(), "没有查看该库表信息的权限");
if (StringUtils.isBlank(tableNames)) {

View File

@@ -94,6 +94,7 @@ public class PoiUtil {
document.createParagraph().createRun().setText("数据库名:" + dbName);
document.createParagraph().createRun().setText("导出时间:" + DateTime.now().toString());
document.createParagraph().createRun().setText("导出说明本文档使用zyplayer-doc生成并导出");
document.createParagraph().createRun().setText("所有库表:");
List<List<String>> baseDataList = new LinkedList<>();
baseDataList.add(Arrays.asList("表名", "说明"));
for (TableColumnVo.TableInfoVo dto : tableList) {

View File

@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/app.9aaf8b21.css rel=preload as=style><link href=css/chunk-vendors.7be40bfc.css rel=preload as=style><link href=js/app.ff5f6236.js rel=preload as=script><link href=js/chunk-vendors.8274a50c.js rel=preload as=script><link href=css/chunk-vendors.7be40bfc.css rel=stylesheet><link href=css/app.9aaf8b21.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.8274a50c.js></script><script src=js/app.ff5f6236.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/app.9aaf8b21.css rel=preload as=style><link href=css/chunk-vendors.7be40bfc.css rel=preload as=style><link href=js/app.c76c831f.js rel=preload as=script><link href=js/chunk-vendors.8274a50c.js rel=preload as=script><link href=css/chunk-vendors.7be40bfc.css rel=stylesheet><link href=css/app.9aaf8b21.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.8274a50c.js></script><script src=js/app.c76c831f.js></script></body></html>

View File

@@ -2,8 +2,8 @@
ENV = 'development'
# base api
# VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
VUE_APP_BASE_API = 'http://doc.zyplayer.com/zyplayer-doc-manage'
VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
# VUE_APP_BASE_API = 'http://doc.zyplayer.com/zyplayer-doc-manage'
VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@@ -25,6 +25,9 @@
<el-table-column prop="tableComment" label="表注释"></el-table-column>
</el-table>
</el-card>
<form method="post" ref="downloadForm" :action="downloadFormParam.url" target="_blank">
<input type="hidden" :name="key" :value="val" v-for="(val,key) in downloadFormParam.param">
</form>
</div>
</template>
@@ -47,6 +50,10 @@
databaseList: [],
tableList: [],
selectTables: [],
downloadFormParam: {
url: 'zyplayer-doc-db/doc-db/exportDatabase',
param: {}
},
}
},
mounted: function () {
@@ -66,17 +73,25 @@
app.$message.info("请选择需要导出的表");
return;
}
var tableNames = "";
for (var i = 0; i < this.selectTables.length; i++) {
let tableNames = "";
for (let i = 0; i < this.selectTables.length; i++) {
if (tableNames !== "") {
tableNames += ",";
}
tableNames += this.selectTables[i].tableName;
}
window.open("zyplayer-doc-db/doc-db/exportDatabase?sourceId=" + this.choiceDatasourceId
+ "&exportType=" + this.exportType
+ "&dbName=" + this.choiceDatabase
+ "&tableNames=" + tableNames);
// window.open("zyplayer-doc-db/doc-db/exportDatabase?sourceId=" + this.choiceDatasourceId
// + "&exportType=" + this.exportType
// + "&dbName=" + this.choiceDatabase
// + "&tableNames=" + tableNames);
// 改为post方式提交下载
this.downloadFormParam.param = {
sourceId: this.choiceDatasourceId,
exportType: this.exportType,
dbName: this.choiceDatabase,
tableNames: tableNames,
};
setTimeout(() => this.$refs.downloadForm.submit(), 0);
},
loadGetTableList() {
datasourceApi.tableList({sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase}).then(json => {