mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
0.11.2 下载当前检索结果
This commit is contained in:
parent
c829b3913d
commit
6e0f883bc4
@ -1,3 +1,3 @@
|
||||
package onstart
|
||||
|
||||
const VERSION = "glogcenter 0.11.1"
|
||||
const VERSION = "glogcenter 0.11.2"
|
||||
|
||||
1
glc/www/web/src/assets/icons/download.svg
Normal file
1
glc/www/web/src/assets/icons/download.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64zm384-253.696 236.288-236.352 45.248 45.248L508.8 704 192 387.2l45.248-45.248L480 584.704V128h64v450.304z"></path></svg>
|
||||
|
After Width: | Height: | Size: 263 B |
@ -40,6 +40,11 @@
|
||||
<SvgIcon name="zoom" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="下载当前检索结果" placement="top">
|
||||
<el-button circle @click="fnDownload">
|
||||
<SvgIcon name="download" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<GxPageTableConfig :tid="tid" :page-config="pageSettingStore" />
|
||||
</template>
|
||||
</GxToolbar>
|
||||
@ -208,7 +213,7 @@ function search() {
|
||||
console.log(rs)
|
||||
if (rs.success) {
|
||||
const resultData = rs.result.data || [];
|
||||
const pagesize = rs.result.pagesize - 0;
|
||||
const pagesize = rs.result.pagesize - 0;
|
||||
tableData.value.splice(0, tableData.value.length); // 删除原全部元素,nextTick时再插入新查询结果
|
||||
document.querySelector('.c-glc-table .el-scrollbar__wrap').scrollTop = 0; // 滚动到顶部
|
||||
|
||||
@ -256,7 +261,7 @@ function searchMore() {
|
||||
console.log(rs)
|
||||
if (rs.success) {
|
||||
const resultData = rs.result.data || [];
|
||||
const pagesize = rs.result.pagesize - 0;
|
||||
const pagesize = rs.result.pagesize - 0;
|
||||
tableData.value.push(...resultData)
|
||||
|
||||
if (resultData.length < pagesize) {
|
||||
@ -276,6 +281,28 @@ function searchMore() {
|
||||
})
|
||||
}
|
||||
|
||||
// 下载当前检索结果
|
||||
function fnDownload() {
|
||||
let fileContent = '';
|
||||
const tableConfigStore = $emitter.emit('$table:config', { id: tid.value })
|
||||
tableData.value.forEach(item => {
|
||||
let flg = false;
|
||||
tableConfigStore.columns.forEach(oCol => {
|
||||
if (!oCol.hidden && !oCol.editType.startsWith('$')) {
|
||||
flg && (fileContent += ', ');
|
||||
oCol.field == 'text' ? (fileContent += item.detail) : (fileContent += item[oCol.field]);
|
||||
flg = true;
|
||||
}
|
||||
})
|
||||
fileContent += '\r\n';
|
||||
})
|
||||
|
||||
const blob = new Blob([fileContent], { type: 'text/plain' }); // 创建Blob对象
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.href = URL.createObjectURL(blob);
|
||||
downloadLink.download = 'example.txt'; // 文件名
|
||||
downloadLink.click(); // 模拟点击下载链接
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user