{"size": 25218, "ext": "js", "max_stars_repo_path": "lib/export/src/hook.min.js", "max_stars_repo_name": "ZHONG007/vxe-table", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/export/src/hook.min.js", "max_issues_repo_name": "ZHONG007/vxe-table", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/export/src/hook.min.js", "max_forks_repo_name": "ZHONG007/vxe-table", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25218.0, "max_line_length": 25218, "alphanum_fraction": 0.6957332064}
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var htmlCellElem,_vue=require("vue"),_xeUtils=_interopRequireDefault(require("xe-utils")),_conf=_interopRequireDefault(require("../../v-x-e-table/src/conf")),_vXETable=require("../../v-x-e-table"),_util=require("../../table/src/util"),_utils=require("../../tools/utils"),_util2=require("./util");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var csvBOM="\ufeff",enterSymbol="\r\n";function defaultFilterExportColumn(e){return e.property||-1<["seq","checkbox","radio"].indexOf(e.type)}var getConvertColumns=function t(e){var r=[];return e.forEach(function(e){e.childNodes&&e.childNodes.length?(r.push(e),r.push.apply(r,t(e.childNodes))):r.push(e)}),r},convertToRows=function(e){var o=1;e.forEach(function(e){e._level=1,function t(r,e){if(e&&(r._level=e._level+1,o<r._level&&(o=r._level)),r.childNodes&&r.childNodes.length){var n=0;r.childNodes.forEach(function(e){t(e,r),n+=e._colSpan}),r._colSpan=n}else r._colSpan=1}(e)});for(var t=[],r=0;r<o;r++)t.push([]);return getConvertColumns(e).forEach(function(e){e.childNodes&&e.childNodes.length?e._rowSpan=1:e._rowSpan=o-e._level+1,t[e._level-1].push(e)}),t};function toTableBorder(e){return!0===e?"full":e||"default"}function getBooleanValue(e){return"TRUE"===e||"true"===e||!0===e}function getHeaderTitle(e,t){return(e.original?t.property:t.getTitle())||""}function getFooterData(e,t){var r=e.footerFilterMethod;return r?t.filter(function(e,t){return r({items:e,$rowIndex:t})}):t}function getCsvCellTypeLabel(e,t){if(t)switch(e.cellType){case"string":if(!isNaN(t))return"\t"+t;break;case"number":break;default:if(12<=t.length&&!isNaN(t))return"\t"+t}return t}function toTxtCellLabel(e){return/[",\s\n]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e}function getElementsByTagName(e,t){return e.getElementsByTagName(t)}function getTxtCellKey(e){return"#"+e+"@"+_xeUtils.default.uniqueId()}function replaceTxtCell(e,t){return e.replace(/#\d+@\d+/g,function(e){return _xeUtils.default.hasOwnProp(t,e)?t[e]:e})}function getTxtCellValue(e,t){return replaceTxtCell(e,t).replace(/^"+$/g,function(e){return'"'.repeat(Math.ceil(e.length/2))})}function parseCsvAndTxt(e,t,n){var r=t.split(enterSymbol),o=[],l=[];if(r.length){var i={},a=Date.now();r.forEach(function(e){if(e){var r={},t=(e=e.replace(/("")|(\n)/g,function(e,t){var r=getTxtCellKey(a);return i[r]=t?'"':"\n",r}).replace(/"(.*?)"/g,function(e,t){var r=getTxtCellKey(a);return i[r]=replaceTxtCell(t,i),r})).split(n);l.length?(t.forEach(function(e,t){t<l.length&&(r[l[t]]=getTxtCellValue(e.trim(),i))}),o.push(r)):l=t.map(function(e){return getTxtCellValue(e.trim(),i)})}})}return{fields:l,rows:o}}function parseCsv(e,t){return parseCsvAndTxt(e,t,",")}function parseTxt(e,t){return parseCsvAndTxt(e,t,"\t")}function parseHTML(e,t){var r=getElementsByTagName((new DOMParser).parseFromString(t,"text/html"),"body"),n=[],o=[];if(r.length){var l=getElementsByTagName(r[0],"table");if(l.length){var i=getElementsByTagName(l[0],"thead");if(i.length){_xeUtils.default.arrayEach(getElementsByTagName(i[0],"tr"),function(e){_xeUtils.default.arrayEach(getElementsByTagName(e,"th"),function(e){o.push(e.textContent)})});var a=getElementsByTagName(l[0],"tbody");a.length&&_xeUtils.default.arrayEach(getElementsByTagName(a[0],"tr"),function(e){var r={};_xeUtils.default.arrayEach(getElementsByTagName(e,"td"),function(e,t){o[t]&&(r[o[t]]=e.textContent||"")}),n.push(r)})}}}return{fields:o,rows:n}}function parseXML(e,t){var r=getElementsByTagName((new DOMParser).parseFromString(t,"application/xml"),"Worksheet"),o=[],l=[];if(r.length){var n=getElementsByTagName(r[0],"Table");if(n.length){var i=getElementsByTagName(n[0],"Row");i.length&&(_xeUtils.default.arrayEach(getElementsByTagName(i[0],"Cell"),function(e){l.push(e.textContent)}),_xeUtils.default.arrayEach(i,function(e,t){if(t){var r={},n=getElementsByTagName(e,"Cell");_xeUtils.default.arrayEach(n,function(e,t){l[t]&&(r[l[t]]=e.textContent)}),o.push(r)}}))}}return{fields:l,rows:o}}function clearColumnConvert(e){_xeUtils.default.eachTree(e,function(e){delete e._level,delete e._colSpan,delete e._rowSpan,delete e._children,delete e.childNodes},{children:"children"})}function checkImportData(e,t){var r=[];return e.forEach(function(e){var t=e.property;t&&r.push(t)}),t.some(function(e){return-1<r.indexOf(e)})}var tableExportMethodKeys=["exportData","importByFile","importData","saveFile","readFile","print","openImport","openExport","openPrint"],tableExportHook={setupTable:function(F){var N=F.props,M=F.reactData,O=F.internalData,e=F.getComputeMaps(),L=e.computeTreeOpts,n=e.computePrintOpts,R=e.computeExportOpts,d=e.computeImportOpts,C=e.computeCustomOpts,i=e.computeSeqOpts,o=e.computeRadioOpts,l=e.computeCheckboxOpts,S=(0,_vue.inject)("$xegrid",null),g=function(e,t,r,n){var o=i.value,l=o.seqMethod||r.seqMethod;return l?l({row:e,rowIndex:t,column:r,columnIndex:n}):o.startIndex+t+1},b=function(e){return _xeUtils.default.isBoolean(e)?e?"TRUE":"FALSE":e},p=function(p,f,e){var h=p.isAllExpand,t=N.treeConfig,m=o.value,v=l.value,r=L.value;if(htmlCellElem||(htmlCellElem=document.createElement("div")),t){var x=[];return _xeUtils.default.eachTree(e,function(e,a,t,r,n,o){var l,i,s=e._row||e,c=n&&n._row?n._row:n;if(h||!c||F.isTreeExpandByRow(c)){var u=(l=s,i=L.value,l[i.children]&&l[i.children].length),d={_row:s,_level:o.length-1,_hasChild:u,_expand:u&&F.isTreeExpandByRow(s)};f.forEach(function(e,t){var r="",n=e.editRender||e.cellRender,o=e.exportMethod;if(!o&&n&&n.name){var l=_vXETable.VXETable.renderer.get(n.name);l&&(o=l.exportMethod)}if(o)r=o({$table:F,row:s,column:e,options:p});else switch(e.type){case"seq":r=g(s,a,e,t);break;case"checkbox":r=b(F.isCheckedByCheckboxRow(s)),d._checkboxLabel=v.labelField?_xeUtils.default.get(s,v.labelField):"",d._checkboxDisabled=v.checkMethod&&!v.checkMethod({row:s});break;case"radio":r=b(F.isCheckedByRadioRow(s)),d._radioLabel=m.labelField?_xeUtils.default.get(s,m.labelField):"",d._radioDisabled=m.checkMethod&&!m.checkMethod({row:s});break;default:if(p.original)r=(0,_util.getCellValue)(s,e);else if(r=F.getCellLabel(s,e),"html"===e.type)htmlCellElem.innerHTML=r,r=htmlCellElem.innerText.trim();else{var i=F.getCell(s,e);i&&(r=i.innerText.trim())}}d[e.id]=_xeUtils.default.toValueString(r)}),x.push(Object.assign(d,s))}},r),x}return e.map(function(a,s){var c={_row:a};return f.forEach(function(e,t){var r="",n=e.editRender||e.cellRender,o=e.exportMethod;if(!o&&n&&n.name){var l=_vXETable.VXETable.renderer.get(n.name);l&&(o=l.exportMethod)}if(o)r=o({$table:F,row:a,column:e,options:p});else switch(e.type){case"seq":r=g(a,s,e,t);break;case"checkbox":r=b(F.isCheckedByCheckboxRow(a)),c._checkboxLabel=v.labelField?_xeUtils.default.get(a,v.labelField):"",c._checkboxDisabled=v.checkMethod&&!v.checkMethod({row:a});break;case"radio":r=b(F.isCheckedByRadioRow(a)),c._radioLabel=m.labelField?_xeUtils.default.get(a,m.labelField):"",c._radioDisabled=m.checkMethod&&!m.checkMethod({row:a});break;default:if(p.original)r=(0,_util.getCellValue)(a,e);else if(r=F.getCellLabel(a,e),"html"===e.type)htmlCellElem.innerHTML=r,r=htmlCellElem.innerText.trim();else{var i=F.getCell(a,e);i&&(r=i.innerText.trim())}}c[e.id]=_xeUtils.default.toValueString(r)}),c})},j=function(e,t,r){var n=r.editRender||r.cellRender,o=r.footerExportMethod;if(!o&&n&&n.name){var l=_vXETable.VXETable.renderer.get(n.name);l&&(o=l.footerExportMethod)}var i=F.getVTColumnIndex(r);return o?o({$table:F,items:t,itemIndex:i,_columnIndex:i,column:r,options:e}):_xeUtils.default.toValueString(t[i])},D=function(e,t,r){var n=e[t],o=_xeUtils.default.isUndefined(n)||_xeUtils.default.isNull(n)?r:n,l="title"===o||(!0===o||"tooltip"===o)||"ellipsis"===o,i=M.scrollXLoad,a=M.scrollYLoad;return!i&&!a||l||(l=!0),l},f=function(e,t,r){if(t.length)switch(e.type){case"csv":return function(r,e,t){var n=csvBOM;if(r.isHeader&&(n+=e.map(function(e){return toTxtCellLabel(getHeaderTitle(r,e))}).join(",")+enterSymbol),t.forEach(function(t){n+=e.map(function(e){return toTxtCellLabel(getCsvCellTypeLabel(e,t[e.id]))}).join(",")+enterSymbol}),r.isFooter){var o=M.footerTableData;getFooterData(r,o).forEach(function(t){n+=e.map(function(e){return toTxtCellLabel(j(r,t,e))}).join(",")+enterSymbol})}return n}(e,t,r);case"txt":return function(r,e,t){var n="";if(r.isHeader&&(n+=e.map(function(e){return toTxtCellLabel(getHeaderTitle(r,e))}).join("\t")+enterSymbol),t.forEach(function(t){n+=e.map(function(e){return toTxtCellLabel(t[e.id])}).join("\t")+enterSymbol}),r.isFooter){var o=M.footerTableData;getFooterData(r,o).forEach(function(t){n+=e.map(function(e){return toTxtCellLabel(j(r,t,e))}).join(",")+enterSymbol})}return n}(e,t,r);case"html":return function(a,e,t){var p=N.id,r=N.border,n=N.treeConfig,s=N.headerAlign,f=N.align,l=N.footerAlign,h=N.showOverflow,c=N.showHeaderOverflow,u=M.isAllSelected,o=M.isIndeterminate,m=M.mergeList,i=L.value,v=a.print,d=a.isHeader,x=a.isFooter,g=a.isColgroup,b=a.isMerge,_=a.colgroups,y=a.original,T="check-all",w=['<table class="'+["vxe-table","border--"+toTableBorder(r),v?"is--print":"",d?"is--header":""].filter(function(e){return e}).join(" ")+'" border="0" cellspacing="0" cellpadding="0">',"<colgroup>"+e.map(function(e){return'<col style="width:'+e.renderWidth+'px">'}).join("")+"</colgroup>"];if(d&&(w.push("<thead>"),g&&!y?_.forEach(function(e){w.push("<tr>"+e.map(function(t){var e=t.headerAlign||t.align||s||f,r=D(t,"showHeaderOverflow",c)?["col--ellipsis"]:[],n=getHeaderTitle(a,t),o=0,l=0;_xeUtils.default.eachTree([t],function(e){e.childNodes&&t.childNodes.length||l++,o+=e.renderWidth},{children:"childNodes"});var i=o-l;return e&&r.push("col--"+e),"checkbox"===t.type?'<th class="'+r.join(" ")+'" colspan="'+t._colSpan+'" rowspan="'+t._rowSpan+'"><div '+(v?"":'style="width: '+i+'px"')+'><input type="checkbox" class="'+T+'" '+(u?"checked":"")+"><span>"+n+"</span></div></th>":'<th class="'+r.join(" ")+'" colspan="'+t._colSpan+'" rowspan="'+t._rowSpan+'" title="'+n+'"><div '+(v?"":'style="width: '+i+'px"')+"><span>"+(0,_utils.formatText)(n,!0)+"</span></div></th>"}).join("")+"</tr>")}):w.push("<tr>"+e.map(function(e){var t=e.headerAlign||e.align||s||f,r=D(e,"showHeaderOverflow",c)?["col--ellipsis"]:[],n=getHeaderTitle(a,e);return t&&r.push("col--"+t),"checkbox"===e.type?'<th class="'+r.join(" ")+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><input type="checkbox" class="'+T+'" '+(u?"checked":"")+"><span>"+n+"</span></div></th>":'<th class="'+r.join(" ")+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+"><span>"+(0,_utils.formatText)(n,!0)+"</span></div></th>"}).join("")+"</tr>"),w.push("</thead>")),t.length&&(w.push("<tbody>"),n?t.forEach(function(l){w.push("<tr>"+e.map(function(e){var t=e.align||f,r=D(e,"showOverflow",h)?["col--ellipsis"]:[],n=l[e.id];if(t&&r.push("col--"+t),e.treeNode){var o="";return l._hasChild&&(o='<i class="'+(l._expand?"vxe-table--tree-fold-icon":"vxe-table--tree-unfold-icon")+'"></i>'),r.push("vxe-table--tree-node"),"radio"===e.type?'<td class="'+r.join(" ")+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><div class="vxe-table--tree-node-wrapper" style="padding-left: '+l._level*i.indent+'px"><div class="vxe-table--tree-icon-wrapper">'+o+'</div><div class="vxe-table--tree-cell"><input type="radio" name="radio_'+p+'" '+(l._radioDisabled?"disabled ":"")+(getBooleanValue(n)?"checked":"")+"><span>"+l._radioLabel+"</span></div></div></div></td>":"checkbox"===e.type?'<td class="'+r.join(" ")+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><div class="vxe-table--tree-node-wrapper" style="padding-left: '+l._level*i.indent+'px"><div class="vxe-table--tree-icon-wrapper">'+o+'</div><div class="vxe-table--tree-cell"><input type="checkbox" '+(l._checkboxDisabled?"disabled ":"")+(getBooleanValue(n)?"checked":"")+"><span>"+l._checkboxLabel+"</span></div></div></div></td>":'<td class="'+r.join(" ")+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><div class="vxe-table--tree-node-wrapper" style="padding-left: '+l._level*i.indent+'px"><div class="vxe-table--tree-icon-wrapper">'+o+'</div><div class="vxe-table--tree-cell">'+n+"</div></div></div></td>"}return"radio"===e.type?'<td class="'+r.join(" ")+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><input type="radio" name="radio_'+p+'" '+(l._radioDisabled?"disabled ":"")+(getBooleanValue(n)?"checked":"")+"><span>"+l._radioLabel+"</span></div></td>":"checkbox"===e.type?'<td class="'+r.join(" ")+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><input type="checkbox" '+(l._checkboxDisabled?"disabled ":"")+(getBooleanValue(n)?"checked":"")+"><span>"+l._checkboxLabel+"</span></div></td>":'<td class="'+r.join(" ")+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+">"+(0,_utils.formatText)(n,!0)+"</div></td>"}).join("")+"</tr>")}):t.forEach(function(d){w.push("<tr>"+e.map(function(e){var t=e.align||f,r=D(e,"showOverflow",h)?["col--ellipsis"]:[],n=d[e.id],o=1,l=1;if(b&&m.length){var i=F.getVTRowIndex(d._row),a=F.getVTColumnIndex(e),s=(0,_util.mergeBodyMethod)(m,i,a);if(s){var c=s.rowspan,u=s.colspan;if(!c||!u)return"";1<c&&(o=c),1<u&&(l=u)}}return t&&r.push("col--"+t),"radio"===e.type?'<td class="'+r.join(" ")+'" rowspan="'+o+'" colspan="'+l+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><input type="radio" name="radio_'+p+'" '+(d._radioDisabled?"disabled ":"")+(getBooleanValue(n)?"checked":"")+"><span>"+d._radioLabel+"</span></div></td>":"checkbox"===e.type?'<td class="'+r.join(" ")+'" rowspan="'+o+'" colspan="'+l+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+'><input type="checkbox" '+(d._checkboxDisabled?"disabled ":"")+(getBooleanValue(n)?"checked":"")+"><span>"+d._checkboxLabel+"</span></div></td>":'<td class="'+r.join(" ")+'" rowspan="'+o+'" colspan="'+l+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+">"+(0,_utils.formatText)(n,!0)+"</div></td>"}).join("")+"</tr>")}),w.push("</tbody>")),x){var E=M.footerTableData,C=getFooterData(a,E);C.length&&(w.push("<tfoot>"),C.forEach(function(o){w.push("<tr>"+e.map(function(e){var t=e.footerAlign||e.align||l||f,r=D(e,"showOverflow",h)?["col--ellipsis"]:[],n=j(a,o,e);return t&&r.push("col--"+t),'<td class="'+r.join(" ")+'" title="'+n+'"><div '+(v?"":'style="width: '+e.renderWidth+'px"')+">"+(0,_utils.formatText)(n,!0)+"</div></td>"}).join("")+"</tr>")}),w.push("</tfoot>"))}var k=!u&&o?'<script>(function(){var a=document.querySelector(".'+T+'");if(a){a.indeterminate=true}})()<\/script>':"";return w.push("</table>",k),v?w.join(""):(0,_util2.createHtmlPage)(a,w.join(""))}(e,t,r);case"xml":return function(r,e,t){var n=['<?xml version="1.0"?>','<?mso-application progid="Excel.Sheet"?>','<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">','<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">',"<Version>16.00</Version>","</DocumentProperties>",'<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">',"<WindowHeight>7920</WindowHeight>","<WindowWidth>21570</WindowWidth>","<WindowTopX>32767</WindowTopX>","<WindowTopY>32767</WindowTopY>","<ProtectStructure>False</ProtectStructure>","<ProtectWindows>False</ProtectWindows>","</ExcelWorkbook>",'<Worksheet ss:Name="'+r.sheetName+'">',"<Table>",e.map(function(e){return'<Column ss:Width="'+e.renderWidth+'"/>'}).join("")].join("");if(r.isHeader&&(n+="<Row>"+e.map(function(e){return'<Cell><Data ss:Type="String">'+getHeaderTitle(r,e)+"</Data></Cell>"}).join("")+"</Row>"),t.forEach(function(t){n+="<Row>"+e.map(function(e){return'<Cell><Data ss:Type="String">'+t[e.id]+"</Data></Cell>"}).join("")+"</Row>"}),r.isFooter){var o=M.footerTableData;getFooterData(r,o).forEach(function(t){n+="<Row>"+e.map(function(e){return'<Cell><Data ss:Type="String">'+j(r,t,e)+"</Data></Cell>"}).join("")+"</Row>"})}return n+"</Table></Worksheet></Workbook>"}(e,t,r)}return""},B=function(a){var s=a.remote,c=a.columns,u=a.colgroups,d=a.exportMethod,t=a.afterExportMethod;return new Promise(function(e){if(s){var t={options:a,$table:F,$grid:S};e(d?d(t):t)}else{var r=(o=(n=a).columns,l=n.dataFilterMethod,i=n.data,l&&(i=i.filter(function(e,t){return l({row:e,$rowIndex:t})})),p(n,o,i));e(F.preventEvent(null,"event.export",{options:a,columns:c,colgroups:u,datas:r},function(){return function(e,t){var r=e.filename,n=e.type;if(!e.download){var o=(0,_util2.getExportBlobByContent)(t,e);return Promise.resolve({type:n,content:t,blob:o})}(0,_util2.saveLocalFile)({filename:r,type:n,content:t}).then(function(){!1!==e.message&&_vXETable.VXETable.modal.message({content:_conf.default.i18n("vxe.table.expSuccess"),status:"success"})})}(a,f(a,c,r))}))}var n,o,l,i}).then(function(e){return clearColumnConvert(c),a.print||t&&t({status:!0,options:a,$table:F,$grid:S}),Object.assign({status:!0},e)}).catch(function(){clearColumnConvert(c),a.print||t&&t({status:!1,options:a,$table:F,$grid:S});return Promise.reject({status:!1})})},a=function(i,a){var s=a.importMethod,t=a.afterImportMethod,e=(0,_utils.parseFile)(i),c=e.type,u=e.filename;if(s||_xeUtils.default.includes(_vXETable.VXETable.config.importTypes,c))return new Promise(function(t,r){var e=function(e){t(e),O._importResolve=null,O._importReject=null},n=function(e){r(e),O._importResolve=null,O._importReject=null};if(O._importResolve=e,O._importReject=n,window.FileReader){var o=Object.assign({mode:"insert"},a,{type:c,filename:u});if(o.remote)s?Promise.resolve(s({file:i,options:o,$table:F})).then(function(){e({status:!0})}).catch(function(){e({status:!0})}):e({status:!0});else{var l=O.tableFullColumn;F.preventEvent(null,"event.import",{file:i,options:o,columns:l},function(){var e=new FileReader;e.onerror=function(){(0,_utils.errLog)("vxe.error.notType",[c]),n({status:!1})},e.onload=function(e){!function(e,r){var t=O.tableFullColumn,n=O._importResolve,o=O._importReject,l={fields:[],rows:[]};switch(r.type){case"csv":l=parseCsv(t,e);break;case"txt":l=parseTxt(t,e);break;case"html":l=parseHTML(t,e);break;case"xml":l=parseXML(t,e)}var i=l.fields,a=l.rows;checkImportData(t,i)?F.createData(a).then(function(e){var t;return t="insert"===r.mode?F.insert(e):F.reloadData(e),!1!==r.message&&_vXETable.VXETable.modal.message({content:_conf.default.i18n("vxe.table.impSuccess",[a.length]),status:"success"}),t.then(function(){n&&n({status:!0})})}):!1!==r.message&&(_vXETable.VXETable.modal.message({content:_conf.default.i18n("vxe.error.impFields"),status:"error"}),o&&o({status:!1}))}(e.target.result,o)},e.readAsText(i,"UTF-8")})}}else"development"===process.env.NODE_ENV&&(0,_utils.errLog)("vxe.error.notExp"),e({status:!0})}).then(function(){t&&t({status:!0,options:a,$table:F})}).catch(function(e){return t&&t({status:!1,options:a,$table:F}),Promise.reject(e)});!1!==a.message&&_vXETable.VXETable.modal.message({content:_conf.default.i18n("vxe.error.notType",[c]),status:"error"});return Promise.reject({status:!1})},r=function(e,t){var r=N.treeConfig,n=N.showHeader,o=N.showFooter,l=M.initStore,i=M.mergeList,a=M.isGroup,s=M.footerTableData,c=M.exportStore,u=M.exportParams,d=O.collectColumn,p=r,f=C.value,h=F.getCheckboxRecords(),m=!!s.length,v=!p&&i.length,x=Object.assign({message:!0,isHeader:n,isFooter:o},e),g=x.types||_vXETable.VXETable.config.exportTypes,b=x.modes,_=f.checkMethod,y=d.slice(0),T=x.columns,w=g.map(function(e){return{value:e,label:"vxe.export.types."+e}}),E=b.map(function(e){return{value:e,label:"vxe.export.modes."+e}});return _xeUtils.default.eachTree(y,function(o,e,t,r,n){(o.children&&o.children.length||defaultFilterExportColumn(o))&&(o.checked=T?T.some(function(e){if((0,_util.isColumnInfo)(e))return o===e;if(_xeUtils.default.isString(e))return o.field===e;var t=e.id||e.colId,r=e.type,n=e.property||e.field;return t?o.id===t:n&&r?o.property===n&&o.type===r:n?o.property===n:r?o.type===r:void 0}):o.visible,o.halfChecked=!1,o.disabled=n&&n.disabled||!!_&&!_({column:o}))}),Object.assign(c,{columns:y,typeList:w,modeList:E,hasFooter:m,hasMerge:v,hasTree:p,isPrint:t,hasColgroup:a,visible:!0}),l.export||Object.assign(u,{mode:h.length?"selected":"current"},x),-1===b.indexOf(u.mode)&&(u.mode=b[0]),-1===g.indexOf(u.type)&&(u.type=g[0]),l.export=!0,(0,_vue.nextTick)()},s={exportData:function(e){var t=N.treeConfig,r=M.isGroup,n=M.tableGroupColumn,l=O.tableFullColumn,o=O.afterFullData,i=R.value,a=L.value,s=Object.assign({isHeader:!0,isFooter:!0,isColgroup:!0,download:!0,type:"csv",mode:"current"},i,{print:!1},e),c=s.type,u=s.mode,d=s.columns,p=s.original,f=s.beforeExportMethod,h=[],m=d&&d.length?d:null,v=s.columnFilterMethod;m||v||(v=p?function(e){return e.column.property}:function(e){return defaultFilterExportColumn(e.column)}),h=m?_xeUtils.default.searchTree(_xeUtils.default.mapTree(m,function(e){var t;if(e){if((0,_util.isColumnInfo)(e))t=e;else if(_xeUtils.default.isString(e))t=F.getColumnByField(e);else{var r=e.id||e.colId,n=e.type,o=e.property||e.field;r?t=F.getColumnById(r):o&&n?t=l.find(function(e){return e.property===o&&e.type===n}):o?t=F.getColumnByField(o):n&&(t=l.find(function(e){return e.type===n}))}return t||{}}},{children:"childNodes",mapChildren:"_children"}),function(e,t){return(0,_util.isColumnInfo)(e)&&(!v||v({column:e,$columnIndex:t}))},{children:"_children",mapChildren:"childNodes",original:!0}):_xeUtils.default.searchTree(r?n:l,function(e,t){return e.visible&&(!v||v({column:e,$columnIndex:t}))},{children:"children",mapChildren:"childNodes",original:!0});var x=[];if(_xeUtils.default.eachTree(h,function(e){e.children&&e.children.length||x.push(e)},{children:"childNodes"}),s.columns=x,s.colgroups=convertToRows(h),s.filename||(s.filename=_conf.default.i18n(s.original?"vxe.table.expOriginFilename":"vxe.table.expFilename",[_xeUtils.default.toDateString(Date.now(),"yyyyMMddHHmmss")])),s.sheetName||(s.sheetName=document.title),!s.exportMethod&&!_xeUtils.default.includes(_vXETable.VXETable.config.exportTypes,c)){"development"===process.env.NODE_ENV&&(0,_utils.errLog)("vxe.error.notType",[c]);return Promise.reject({status:!1})}if(s.print||f&&f({options:s,$table:F,$grid:S}),!s.data)if(s.data=o,"selected"===u){var g=F.getCheckboxRecords();-1<["html","pdf"].indexOf(c)&&t?s.data=_xeUtils.default.searchTree(F.getTableData().fullData,function(e){return-1<F.findRowIndexOf(g,e)},Object.assign({},a,{data:"_row"})):s.data=g}else if("all"===u&&("development"===process.env.NODE_ENV&&(S||(0,_utils.warnLog)("vxe.error.errProp",["all","mode=current,selected"])),S&&!s.remote)){var b=S.reactData,_=S.getComputeMaps().computeProxyOpts.value,y=_.beforeQueryAll,T=_.afterQueryAll,w=_.ajax,E=void 0===w?{}:w,C=_.props,k=void 0===C?{}:C,j=E.queryAll;if("development"===process.env.NODE_ENV&&(j||(0,_utils.warnLog)("vxe.error.notFunc",["proxy-config.ajax.queryAll"])),j){var D={$table:F,$grid:S,sort:b.sortData,filters:b.filterData,form:b.formData,target:j,options:s};return Promise.resolve((y||j)(D)).catch(function(e){return e}).then(function(e){return s.data=(k.list?_xeUtils.default.get(e,k.list):e)||[],T&&T(D),B(s)})}}return B(s)},importByFile:function(e,t){var r=Object.assign({},t),n=r.beforeImportMethod;return n&&n({options:r,$table:F}),a(e,r)},importData:function(e){var t=d.value,r=Object.assign({types:_vXETable.VXETable.config.importTypes},t,e),n=r.beforeImportMethod,o=r.afterImportMethod;return n&&n({options:r,$table:F}),(0,_util2.readLocalFile)(r).catch(function(e){return o&&o({status:!1,options:r,$table:F}),Promise.reject(e)}).then(function(e){var t=e.file;return a(t,r)})},saveFile:function(e){return(0,_util2.saveLocalFile)(e)},readFile:function(e){return(0,_util2.readLocalFile)(e)},print:function(e){var t=n.value,r=Object.assign({original:!1},t,e,{type:"html",download:!1,remote:!1,print:!0});return r.sheetName||(r.sheetName=document.title),new Promise(function(e){r.content?e((0,_util2.handlePrint)(F,r,r.content)):e(s.exportData(r).then(function(e){var t=e.content;return(0,_util2.handlePrint)(F,r,t)}))})},openImport:function(e){var t=N.treeConfig,r=N.importConfig,n=M.initStore,o=M.importStore,l=M.importParams,i=d.value,a=Object.assign({mode:"insert",message:!0,types:_vXETable.VXETable.config.importTypes},e,i),s=a.types;if(!!t)a.message&&_vXETable.VXETable.modal.message({content:_conf.default.i18n("vxe.error.treeNotImp"),status:"error"});else{r||(0,_utils.errLog)("vxe.error.reqProp",["import-config"]);var c=s.map(function(e){return{value:e,label:"vxe.export.types."+e}}),u=a.modes.map(function(e){return{value:e,label:"vxe.import.modes."+e}});Object.assign(o,{file:null,type:"",filename:"",modeList:u,typeList:c,visible:!0}),Object.assign(l,a),n.import=!0}},openExport:function(e){var t=R.value;"development"===process.env.NODE_ENV&&(N.exportConfig||(0,_utils.errLog)("vxe.error.reqProp",["export-config"])),r(Object.assign({},t,e))},openPrint:function(e){var t=n.value;"development"===process.env.NODE_ENV&&(N.printConfig||(0,_utils.errLog)("vxe.error.reqProp",["print-config"])),r(Object.assign({},t,e),!0)}};return s},setupGrid:function(e){return e.extendTableMethods(tableExportMethodKeys)}},_default=tableExportHook;exports.default=_default;