数据库导出新窗口使用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

@@ -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 => {