Commit 297603bc by chenyu

update: addDownload

parent 38d2a6bb
...@@ -205,3 +205,26 @@ export const postExcel = (url, params) => { ...@@ -205,3 +205,26 @@ export const postExcel = (url, params) => {
}) */ }) */
}); });
}; };
/**
* get excel
*/
export const getExcel = (url, params) => {
params.requestProject = 'haoban-manage-web';
return Vue.axios({
method: 'get',
url: `${local}${url}`,
data: {},
params: params,
responseType: 'blob',
headers: {
'content-type': 'application/x-www-form-urlencoded'
} //multipart/form-data{"token": token}
/* httpAgent: new http.Agent({
keepAlive: true
}),
httpsAgent: new https.Agent({
keepAlive: true
}) */
});
};
...@@ -34,14 +34,18 @@ ...@@ -34,14 +34,18 @@
<p class="search-items-label">表名:</p> <p class="search-items-label">表名:</p>
<el-input style="width:140px;" placeholder="请输入表名" v-model="searchParams.tableName" clearable> </el-input> <el-input style="width:140px;" placeholder="请输入表名" v-model="searchParams.tableName" clearable> </el-input>
</div> </div>
<el-button type="primary" @click="getTableList">筛选</el-button> <el-button type="primary" @click="getTableList" :disabled="loading">筛选</el-button>
</div> </div>
<el-button type="primary" @click="download">下载</el-button> <el-button type="primary" @click="download" :disabled="loading">下载</el-button>
</div> </div>
<div class="reviewed-body-content"> <div class="reviewed-body-content">
<el-table ref="multipleTable" v-loading="loading" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange"> <el-table ref="multipleTable" v-loading="loading" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
<el-table-column label="uuid" prop="uuid" show-overflow-tooltip></el-table-column> <el-table-column label="uuid" prop="uuid" show-overflow-tooltip></el-table-column>
<el-table-column label="时间" prop="updateTime" show-overflow-tooltip></el-table-column> <el-table-column label="时间" prop="updateTime" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.updateTime | formatTimeStamp }}
</template>
</el-table-column>
<el-table-column label="sql内容" prop="sqlContent" min-width="200"> <el-table-column label="sql内容" prop="sqlContent" min-width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip class="item" effect="dark" :content="scope.row.sqlContent" placement="top" <el-tooltip class="item" effect="dark" :content="scope.row.sqlContent" placement="top"
...@@ -86,7 +90,7 @@ ...@@ -86,7 +90,7 @@
<script> <script>
import errMsg from '@/common/js/error'; import errMsg from '@/common/js/error';
// import { _debounce } from '@/common/js/public'; // import { _debounce } from '@/common/js/public';
import { getRequest } from '@/api/api'; import { getRequest, getExcel } from '@/api/api';
export default { export default {
name: 'unreview', name: 'unreview',
data() { data() {
...@@ -131,16 +135,29 @@ export default { ...@@ -131,16 +135,29 @@ export default {
}, },
download() { download() {
const that = this; const that = this;
that.loading = true; const { tableName, dataSourceId, scame } = this.searchParams;
if (!tableName || !dataSourceId || !scame) {
that.$message.error({
duration: 3000,
message: '库地址、库名、表名为必填筛选项'
});
return;
}
let para = { ...this.searchParams }; let para = { ...this.searchParams };
getRequest('/redis-limiter-web/sql/sql-download', para) that.loading = true;
getExcel('/redis-limiter-web/sql/sql-download', para)
.then(res => { .then(res => {
let resData = res.data;
that.loading = false; that.loading = false;
if (resData.errorCode == 1) { if (res.data) {
return; let downloadA = document.createElement('a');
const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
// const href = URL.createObjectURL(blob);
// window.open(href);
downloadA.href = window.URL.createObjectURL(blob);
downloadA.download = `${dataSourceId}@${scame}@${tableName}`;
downloadA.click();
window.URL.revokeObjectURL(downloadA.href);
} }
errMsg.errorMsg(resData);
}) })
.catch(function(error) { .catch(function(error) {
that.$message.error({ that.$message.error({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment