"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _conf=_interopRequireDefault(require("../../conf")),_xeUtils=_interopRequireDefault(require("xe-utils/methods/xe-utils"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default={name:"PlxExportPanel",props:{defaultOptions:Object,storeData:Object},data:function(){return{isAll:!1,isIndeterminate:!1,modeList:[{value:"all",label:"plx.toolbar.expAll"},{value:"selected",label:"plx.toolbar.expSelected"}]}},computed:{vSize:function(){return this.size||this.$parent.size||this.$parent.vSize},showSheet:function(){return-1<["html","xml","xlsx"].indexOf(this.defaultOptions.type)}},render:function(l){var o=this,e=this._e,t=this.isAll,a=this.isIndeterminate,i=this.showSheet,n=this.defaultOptions,s=this.storeData,r=this.modeList;return l("plx-modal",{res:"modal",model:{value:s.visible,callback:function(e){s.visible=e}},props:{title:_conf.default.i18n("plx.toolbar.expTitle"),width:660,mask:!0,lockView:!0,showFooter:!1,escClosable:!0,maskClosable:!0},on:{show:this.showEvent}},[l("div",{class:"plx-export--panel"},[l("table",{attrs:{cellspacing:0,cellpadding:0,border:0}},[l("tr",[l("td",_conf.default.i18n("plx.toolbar.expName")),l("td",[l("input",{ref:"filename",attrs:{type:"text",placeholder:_conf.default.i18n("plx.toolbar.expNamePlaceholder")},domProps:{value:n.filename},on:{input:function(e){n.filename=e.target.value}}})])]),l("tr",[l("td",_conf.default.i18n("plx.toolbar.expType")),l("td",[l("select",{on:{change:function(e){n.type=e.target.value}}},n.types.map(function(e){return l("option",{attrs:{value:e.value},domProps:{selected:n.type===e.value}},_conf.default.i18n(e.label))}))])]),i?l("tr",[l("td",_conf.default.i18n("plx.toolbar.expSheetName")),l("td",[l("input",{attrs:{type:"text",placeholder:_conf.default.i18n("plx.toolbar.expSheetNamePlaceholder")},domProps:{value:n.sheetName},on:{input:function(e){n.sheetName=e.target.value}}})])]):e(),l("tr",[l("td",_conf.default.i18n("plx.toolbar.expMode")),l("td",[l("select",{on:{change:function(e){s.mode=e.target.value}}},r.map(function(e){return l("option",{attrs:{value:e.value},domProps:{selected:s.mode===e.value}},_conf.default.i18n(e.label))}))])]),l("tr",[l("td",[_conf.default.i18n("plx.toolbar.expColumn")]),l("td",[l("div",{class:"plx-export--panel-column"},[l("ul",{class:"plx-export--panel-column-header"},[l("li",{class:["plx-export--panel-column-option",{"is--checked":t,"is--indeterminate":a}],attrs:{title:_conf.default.i18n("plx.table.allTitle")},on:{click:this.allColumnEvent}},_conf.default.i18n("plx.toolbar.expAllColumn"))]),l("ul",{class:"plx-export--panel-column-body"},s.columns.map(function(e){var t=e.getTitle();return l("li",{class:["plx-export--panel-column-option",{"is--checked":e.checked,"is--disabled":e.disabled}],attrs:{title:t},on:{click:function(){e.disabled||(e.checked=!e.checked,o.checkStatus())}}},t)}))])])]),l("tr",[l("td",_conf.default.i18n("plx.toolbar.expOpts")),l("td",[l("plx-checkbox",{props:{title:_conf.default.i18n("plx.toolbar.expHeaderTitle")},model:{value:n.isHeader,callback:function(e){n.isHeader=e}}},_conf.default.i18n("plx.toolbar.expOptHeader")),l("plx-checkbox",{props:{disabled:!s.hasFooter,title:_conf.default.i18n("plx.toolbar.expFooterTitle")},model:{value:n.isFooter,callback:function(e){n.isFooter=e}}},_conf.default.i18n("plx.toolbar.expOptFooter")),l("plx-checkbox",{props:{title:_conf.default.i18n("plx.toolbar.expOriginalTitle")},model:{value:n.original,callback:function(e){n.original=e}}},_conf.default.i18n("plx.toolbar.expOptOriginal"))])])]),l("div",{class:"plx-export--panel-btns"},[l("plx-button",{on:{click:this.printEvent}},_conf.default.i18n("plx.toolbar.expPrint")),l("plx-button",{props:{type:"primary"},on:{click:this.exportEvent}},_conf.default.i18n("plx.toolbar.expConfirm"))])])])},methods:{checkStatus:function(){var e=this.storeData.columns;this.isAll=this.storeData.columns.every(function(e){return e.disabled||e.checked}),this.isIndeterminate=!this.isAll&&e.some(function(e){return!e.disabled&&e.checked})},allColumnEvent:function(){var t=!this.isAll;this.storeData.columns.forEach(function(e){e.disabled||(e.checked=t)}),this.isAll=t,this.checkStatus()},showEvent:function(){var e=this;this.$nextTick(function(){e.$refs.filename.focus()}),this.checkStatus()},getExportOption:function(){var e=this.storeData,t=this.defaultOptions,l=this.$parent,o=l.$grid,a=l.$table,i=o||a,n=e.selectRecords,s=Object.assign({columns:e.columns.filter(function(e){return e.checked})},t);return"selected"===e.mode&&(-1<["html","pdf"].indexOf(t.type)&&i.treeConfig?s.data=_xeUtils.default.searchTree(i.getTableData().fullData,function(e){return-1<n.indexOf(e)},i.getTreeStatus().config):s.data=n),s},printEvent:function(){this.storeData.visible=!1,this.$emit("print",this.getExportOption())},exportEvent:function(){this.storeData.visible=!1,this.$emit("export",this.getExportOption())}}};exports.default=_default;