(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0efd67"],{"9a8a":function(e,t,n){"use strict";n.r(t);var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-container"},[n("el-backtop"),e._v(" "),e.loading?n("div",[e._v("生成中...")]):n("div",[n("el-container",[n("el-aside",[n("el-button",{attrs:{icon:"el-icon-download",type:"text"},on:{click:e.downloadAll}},[e._v("下载全部")]),e._v(" "),n("el-input",{directives:[{name:"show",rawName:"v-show",value:e.treeData.length>0,expression:"treeData.length > 0"}],staticStyle:{"margin-bottom":"10px"},attrs:{"prefix-icon":"el-icon-search",placeholder:"搜索",size:"mini",clearable:""},model:{value:e.filterText,callback:function(t){e.filterText=t},expression:"filterText"}}),e._v(" "),n("el-tree",{ref:"tree",attrs:{data:e.treeData,props:e.defaultProps,"filter-node-method":e.filterNode,"node-key":"id","default-expand-all":"","highlight-current":""},on:{"current-change":e.onTreeSelect}})],1),e._v(" "),n("el-main",{directives:[{name:"show",rawName:"v-show",value:e.fileInfo.content.length>0,expression:"fileInfo.content.length > 0"}]},[n("el-button",{staticClass:"copyBtn",attrs:{type:"text",icon:"el-icon-document-copy","data-clipboard-text":e.fileInfo.content}},[e._v("复制代码")]),e._v(" "),n("el-button",{attrs:{icon:"el-icon-download",type:"text"},on:{click:function(t){return e.downloadText(e.fileInfo.fileName,e.fileInfo.content)}}},[e._v("下载当前文件")]),e._v(" "),n("codemirror",{attrs:{options:e.cmOptions},model:{value:e.fileInfo.content,callback:function(t){e.$set(e.fileInfo,"content",t)},expression:"fileInfo.content"}})],1)],1)],1)],1)},i=[],o=(n("ac6a"),n("c4e3")),l=n.n(o),r=n("21a6"),c=n("8f94");n("bbca");n("f9d4"),n("4ba6"),n("74bb"),n("d69f"),n("d5e0");var s={js:"text/javascript",java:"text/x-java",cs:"text/x-csharp",jsp:"application/x-jsp",html:"text/html",vue:"application/x-ejs",aspx:"application/x-aspx",xml:"application/xml"},f={components:{codemirror:c["codemirror"]},data:function(){return{loading:!0,clientParam:{datasourceConfigId:"",tableNames:[],templateConfigIdList:[],packageName:""},treeData:[],filterText:"",defaultProps:{children:"children",label:"fileName"},content:"",fileInfo:{content:"",fileName:""},cmOptions:{value:"",mode:"text/x-java",theme:"neat",readOnly:!0}}},watch:{filterText:function(e){this.$refs.tree.filter(e)}},created:function(){var e=this.$route.params.config||"";e&&(this.clientParam=JSON.parse(e),this.onGenerate()),this.initCopy()},destroyed:function(){this.cleanCopy()},methods:{onGenerate:function(){var e=this;0!==this.clientParam.tableNames.length?0!==this.clientParam.templateConfigIdList.length?this.post("/generate/code",this.clientParam,(function(t){e.loading=!1;var n=t.data;e.treeData=e.buildTreeData(n)})):this.tip("请勾选模板","error"):this.tip("请勾选表","error")},filterNode:function(e,t){return!e||-1!==t.fileName.toLowerCase().indexOf(e.toLowerCase())},buildTreeData:function(e){for(var t=[],n={},a=0,i=e.length;a<i;a++){var o=e[a],l=o.folder,r=n[l];r||(r=[],n[l]=r),r.push(o)}for(var c in n){var s=n[c],f={fileName:c,children:this.buildChildren(s)};t.push(f)}return t},buildChildren:function(e){for(var t=[],n=0,a=e.length;n<a;n++){var i=e[n],o={fileName:i.fileName,content:i.content};t.push(o)}return t},onTreeSelect:function(e){e.children&&e.children.length>0||(this.fileInfo=e,this.changeMod(e.fileName))},changeMod:function(e){var t=this.getSuffix(e);this.cmOptions.mode=s[t]||"text/javascript"},getSuffix:function(e){var t=e.lastIndexOf(".");return-1===t?"js":e.substring(t+1,e.length)},downloadAll:function(){var e=this.treeData,t=new l.a;e.forEach((function(e){var n=e.children,a=n.length>0;if(a){var i=e.fileName.replaceAll(".","/"),o=t.folder(i);n.forEach((function(e){o.file(e.fileName,e.content)}))}})),t.generateAsync({type:"blob"}).then((function(e){Object(r["saveAs"])(e,"code-".concat((new Date).getTime(),".zip"))}))}}},d=f,h=n("2877"),p=Object(h["a"])(d,a,i,!1,null,null,null);t["default"]=p.exports}}]);