0.11.2 下载当前检索结果

This commit is contained in:
gotoeasy 2023-09-13 22:02:04 +08:00
parent c829b3913d
commit 6e0f883bc4
3 changed files with 31 additions and 3 deletions

View File

@ -1,3 +1,3 @@
package onstart
const VERSION = "glogcenter 0.11.1"
const VERSION = "glogcenter 0.11.2"

View 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

View File

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