"use strict";(self["webpackChunkmodel"]=self["webpackChunkmodel"]||[]).push([[233],{4032:function(e,t,l){l.r(t),l.d(t,{default:function(){return X}});var o=l(9003);const a=e=>((0,o.dD)("data-v-26dcd95d"),e=e(),(0,o.Cn)(),e),i={class:"XMLTemplateEditor"},d={class:"left-title"},n=a((()=>(0,o._)("span",{class:"title"},"XML模板",-1))),r={class:"right-btns"},s={class:"content-module"},c={class:"dialog-footer"};function m(e,t,l,a,m,h){const p=(0,o.up)("el-button"),u=(0,o.up)("el-col"),f=(0,o.up)("el-row"),g=(0,o.up)("XMLFileTree"),w=(0,o.up)("el-scrollbar"),y=(0,o.up)("pane"),D=(0,o.up)("DAOTree"),b=(0,o.up)("XMLCodeMirror"),C=(0,o.up)("splitpanes"),v=(0,o.up)("el-input"),T=(0,o.up)("el-form-item"),k=(0,o.up)("el-option"),I=(0,o.up)("el-select"),x=(0,o.up)("el-form"),L=(0,o.up)("el-dialog");return(0,o.wg)(),(0,o.iD)("div",i,[(0,o.Wm)(f,{class:"header-module"},{default:(0,o.w5)((()=>[(0,o.Wm)(u,{span:4},{default:(0,o.w5)((()=>[(0,o._)("div",d,[n,(0,o.Wm)(p,{type:"primary",disabled:e.createBtn,onClick:e.createHandle},{default:(0,o.w5)((()=>[(0,o.Uk)("新建")])),_:1},8,["disabled","onClick"])])])),_:1}),(0,o.Wm)(u,{span:18},{default:(0,o.w5)((()=>[(0,o._)("div",r,[(0,o.Wm)(p,{type:"primary",disabled:e.disabeldBtn||e.saveBtn,onClick:e.saveHandle},{default:(0,o.w5)((()=>[(0,o.Uk)("保存")])),_:1},8,["disabled","onClick"]),(0,o.Wm)(p,{type:"primary",disabled:e.disabeldBtn||e.exportBtn,onClick:e.exportHandle},{default:(0,o.w5)((()=>[(0,o.Uk)("导出")])),_:1},8,["disabled","onClick"])])])),_:1})])),_:1}),(0,o._)("div",s,[(0,o.Wm)(C,null,{default:(0,o.w5)((()=>[(0,o.Wm)(y,{size:15},{default:(0,o.w5)((()=>[(0,o.Wm)(w,null,{default:(0,o.w5)((()=>[(0,o.Wm)(g,{ref:"xmlTree",fileList:e.fileList,xmlFileItem:e.xmlFileItem,showDescription:e.showDescription,onDeleteHandle:e.onDelete,onGetChildrenData:e.getProjectHandle,onSaveHandle:e.saveHandle},null,8,["fileList","xmlFileItem","showDescription","onDeleteHandle","onGetChildrenData","onSaveHandle"])])),_:1})])),_:1}),(0,o.Wm)(y,{class:"model-attribute",size:80},{default:(0,o.w5)((()=>[(0,o.Wm)(C,null,{default:(0,o.w5)((()=>[(0,o.Wm)(y,{size:25},{default:(0,o.w5)((()=>[(0,o.Wm)(w,null,{default:(0,o.w5)((()=>[(0,o.Wm)(D,{datamodelChildData:e.datamodelChildData},null,8,["datamodelChildData"])])),_:1})])),_:1}),(0,o.Wm)(y,{class:"model-attribute",size:75},{default:(0,o.w5)((()=>[(0,o.Wm)(w,null,{default:(0,o.w5)((()=>[(0,o.Wm)(b,{ref:"XMLCodeMirror",showDescription:e.showDescription,xmlFileItem:e.xmlFileItem,keywordsList:e.keywordsList[0].children},null,8,["showDescription","xmlFileItem","keywordsList"])])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})]),(0,o.Wm)(L,{modelValue:e.dialogFormVisible,"onUpdate:modelValue":t[3]||(t[3]=t=>e.dialogFormVisible=t),title:"新建XML模板文件",onClose:e.createdCloseHandle},{footer:(0,o.w5)((()=>[(0,o._)("span",c,[(0,o.Wm)(p,{onClick:e.createdCloseHandle},{default:(0,o.w5)((()=>[(0,o.Uk)("取消")])),_:1},8,["onClick"]),(0,o.Wm)(p,{type:"primary",onClick:e.createSubmitHandle},{default:(0,o.w5)((()=>[(0,o.Uk)(" 确认 ")])),_:1},8,["onClick"])])])),default:(0,o.w5)((()=>[(0,o.Wm)(x,{model:e.form},{default:(0,o.w5)((()=>[(0,o.Wm)(T,{label:"文件名","label-width":"140px"},{default:(0,o.w5)((()=>[(0,o.Wm)(v,{class:"size",modelValue:e.form.name,"onUpdate:modelValue":t[0]||(t[0]=t=>e.form.name=t),autocomplete:"off"},null,8,["modelValue"])])),_:1}),(0,o.Wm)(T,{label:"关联项目","label-width":"140px"},{default:(0,o.w5)((()=>[(0,o.Wm)(I,{modelValue:e.form.project,"onUpdate:modelValue":t[1]||(t[1]=t=>e.form.project=t),placeholder:"请选择关联项目",onChange:e.findDataModel},{default:(0,o.w5)((()=>[((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(e.projectList,(e=>((0,o.wg)(),(0,o.j4)(k,{key:e.id,label:e.name,value:e.id},null,8,["label","value"])))),128))])),_:1},8,["modelValue","onChange"])])),_:1}),(0,o.Wm)(T,{label:"关联模型","label-width":"140px"},{default:(0,o.w5)((()=>[(0,o.Wm)(I,{modelValue:e.form.model,"onUpdate:modelValue":t[2]||(t[2]=t=>e.form.model=t),placeholder:"请选择关联模型"},{default:(0,o.w5)((()=>[((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(e.modelList,(e=>((0,o.wg)(),(0,o.j4)(k,{key:e.id,label:e.name,value:e.id},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1})])),_:1},8,["model"])])),_:1},8,["modelValue","onClose"])])}l(7658);var h=l(7627),p=l(4704),u=l(5321),f=l(7178),g=l(6e3);const w=e=>((0,o.dD)("data-v-6a8404c0"),e=e(),(0,o.Cn)(),e),y=["onDblclick"],D=w((()=>(0,o._)("span",{class:"iconfont icon-fuzhi"},null,-1))),b=w((()=>(0,o._)("div",{class:"desc-title"},"基本信息",-1)));function C(e,t,l,a,i,d){const n=(0,o.up)("el-badge"),r=(0,o.up)("el-tree"),s=(0,o.up)("pane"),c=(0,o.up)("el-descriptions-item"),m=(0,o.up)("el-descriptions"),h=(0,o.up)("el-scrollbar"),p=(0,o.up)("splitpanes");return(0,o.wg)(),(0,o.j4)(p,{horizontal:""},{default:(0,o.w5)((()=>[(0,o.Wm)(s,null,{default:(0,o.w5)((()=>[(0,o.Wm)(r,{ref:"fileList",data:e.fileList,props:e.defaultProps,"node-key":"id","highlight-current":"",onNodeContextmenu:e.contextHandle},{default:(0,o.w5)((({data:t})=>[(0,o._)("div",{class:(0,o.C_)(["custom-tree-node",{"dbclick-item":e.hasOpenedItem.id==t.id}]),onDblclick:l=>e.beforeLeaveSaveHandle(t)},[D,(0,o.Wm)(n,{type:"success"},{default:(0,o.w5)((()=>[(0,o.Uk)((0,o.zw)(t.name),1)])),_:2},1024)],42,y)])),_:1},8,["data","props","onNodeContextmenu"])])),_:1}),(0,o.wy)((0,o.Wm)(s,{class:"model-attribute base-attr",size:25},{default:(0,o.w5)((()=>[b,(0,o.Wm)(h,{height:"100%"},{default:(0,o.w5)((()=>[(0,o.Wm)(m,{column:1,size:"small",border:""},{default:(0,o.w5)((()=>[((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(e.descList,(e=>((0,o.wg)(),(0,o.j4)(c,{key:e.id,label:e.label},{default:(0,o.w5)((()=>[(0,o.Uk)((0,o.zw)(e.value),1)])),_:2},1032,["label"])))),128))])),_:1})])),_:1})])),_:1},512),[[o.F8,e.showDescription]])])),_:1})}var v=l(7198),T=(0,o.aZ)({name:"XMLFileTree",data(){return{defaultProps:{children:"children",label:"name"},hasOpenedItem:{},descList:[]}},props:{fileList:{type:Array,default:[]},xmlFileItem:{type:Object,default:{}},showDescription:{type:Boolean,default:!1}},emits:["deleteHandle","getChildrenData","saveHandle"],components:{Splitpanes:u.F,Pane:u.X},setup(){},methods:{beforeLeaveSaveHandle(e){this.hasOpenedItem?.id?g.T.confirm(`是否需要保存文件:"${this.hasOpenedItem.name}"?`,"Warning",{confirmButtonText:"保存",cancelButtonText:"取消",type:"warning"}).then((()=>{this.$emit("saveHandle"),this.hasOpenedItem=e,this.onOpen(e)})).catch((()=>{this.hasOpenedItem=e,this.onOpen(e)})):(this.hasOpenedItem=e,this.onOpen(e))},contextHandle(e,t,l){(0,v.x)(e.clientX,e.clientY,{props:{data:t,commands:[{key:0,label:"打开",command:this.beforeLeaveSaveHandle,icon:"icon-jijianfasong-xianxing",disabled:this.hasOpenedItem.id===t.id},{key:1,label:"删除",command:this.onDelete,icon:"icon-delete-fill"}]}})},onOpen(e){this.$emit("getChildrenData",e),this.$nextTick((()=>{this.$refs.fileList.setCurrentKey(e.id)}))},onDelete(e){console.log("this.currentFileItem.id === param.id",this.hasOpenedItem.id,e.id),this.hasOpenedItem.id===e.id&&(this.hasOpenedItem={}),this.$emit("deleteHandle",e)}},watch:{xmlFileItem:{deep:!0,handler(e){this.descList=[{id:e.id,label:"项目名称",value:e.projectName},{id:e.id,label:"模型名称",value:e.modelName},{id:e.id,label:"创建时间",value:e.createTime}]}}}}),k=l(89);const I=(0,k.Z)(T,[["render",C],["__scopeId","data-v-6a8404c0"]]);var x=I;function L(e,t,l,a,i,d){const n=(0,o.up)("el-tree");return(0,o.wg)(),(0,o.j4)(n,{data:e.datamodelChildData,props:e.defaultProps,"node-key":"id",draggable:"","default-expand-all":"","expand-on-click-node":!1,"allow-drop":e.allowDrop,"allow-drag":e.allowDrag,onNodeDragStart:e.handleDragStart,onNodeDragEnd:e.handleDragEnd,onNodeDrop:e.handleDrop},null,8,["data","props","allow-drop","allow-drag","onNodeDragStart","onNodeDragEnd","onNodeDrop"])}var _=l(65),W=(0,o.aZ)({name:"DAOTree",data(){return{data:[],defaultProps:{children:"children",label:"label"}}},props:{datamodelChildData:{type:Array,default:[]}},components:{},setup(){const e=(0,_.oR)(),t=(t,l)=>{if(console.log("node: Node, ev",t,l),l.target&&l.dataTransfer&&l.target["children"]){const o=l.target["children"][0]["children"][1];l.dataTransfer.setDragImage(o,o.offsetWidth/2,o.offsetHeight+5),e.commit("setKeyWordItem",t.data)}},l=(e,t,l,o)=>{console.log("tree drag end:",t&&t.label,l)},o=(e,t,l,o)=>{console.log("tree drop:",t.label,l)},a=(e,t,l)=>"prev"!==l&&"next"!==l&&"inner"!==l,i=e=>["",2,3].includes(e.data.classType);return{handleDragStart:t,handleDragEnd:l,handleDrop:o,allowDrop:a,allowDrag:i}},methods:{}});const F=(0,k.Z)(W,[["render",L],["__scopeId","data-v-56f20082"]]);var H=F;const O={class:"XMLCodeMirror"};function M(e,t,l,a,i,d){const n=(0,o.up)("Codemirror");return(0,o.wy)(((0,o.wg)(),(0,o.iD)("div",O,[(0,o.Wm)(n,{ref:"cmRef",value:e.code,"onUpdate:value":t[0]||(t[0]=t=>e.code=t),options:e.cmOptions,border:"",height:"100%",width:"100%",onDrop:e.onDrop,onBlur:e.getCursorPosition},null,8,["value","options","onDrop","onBlur"])],512)),[[o.F8,e.showDescription]])}l(1804);var P=l(6609),j=(l(6881),(0,o.aZ)({name:"XMLCodeMirror",data(){return{cursorPos:{}}},props:{showDescription:{type:Boolean},xmlFileItem:{type:Object,default:{}},keywordsList:{type:Array,default:[]}},components:{Codemirror:P.ZP},setup(){const e=(0,o.iH)(""),t=(0,o.iH)(),l={mode:"application/xml",tabSize:2,styleActiveLine:!0,lineNumbers:!0,line:!0,lineWrapping:!0,matchBrackets:!0,foldGutter:!0,autofocus:!0,autoRefresh:!0,showCursorWhenSelecting:!0,highlightselectionMatches:{minChars:2,trim:!0,style:"matchhighlight",showToken:!1}},a=(0,_.oR)();return(0,o.bv)((()=>{})),(0,o.SK)((()=>{t.value?.destroy()})),{code:e,cmRef:t,cmOptions:l,getKeyWordItem:(0,o.Fl)((()=>a.state.dragAndDropItem))}},mounted(){this.listenCursorPos()},methods:{onDrop(e,t){t.stopPropagation();const l=this.$refs.cmRef.cminstance;let o="";if(this.getKeyWordItem&&"keyword"==this.getKeyWordItem.type){const e=this.keywordsList&&this.keywordsList?.find((e=>e.label===this.getKeyWordItem.label));o=e.code}else if(console.log("this.getKeyWordItem",this.getKeyWordItem),o=this.getKeyWordItem.label,2==this.getKeyWordItem.classType){if(this.cursorPos.line>=0){const e=l.getLine(this.cursorPos.line).slice(this.cursorPos.ch-5,this.cursorPos.ch);console.log("curLineText",e);const t=e.indexOf("DAO=");console.log("hasDAO",t),-1===t&&(o=`DAO="${o}"`)}}else 3==this.getKeyWordItem.classType&&(o=`VAL-${o}`);l.replaceRange(o,this.cursorPos)},getCursorPosition(e){this.cursorPos=e.getCursor()},listenCursorPos(){this.cmRef.cminstance.on("cursorActivity",(e=>{const t={getCursor:{line:e.doc.getCursor().line,ch:e.doc.getCursor().ch}};this.cursorPos=t.getCursor}))}},watch:{xmlFileItem:{deep:!0,handler(e){console.log("val",e),this.code=e.content}}}}));const z=(0,k.Z)(j,[["render",M],["__scopeId","data-v-5f0f6e90"]]);var B=z,A=(0,o.aZ)({name:"XMLTemplateEditor",data(){return{fileList:[],showDescription:!1,dialogFormVisible:!1,form:{name:"",project:"",model:""},projectList:[],modelList:[],datamodelChildData:[],xmlFileItem:{},currentFileItem:{},keywordsList:[{label:"关键字",children:[{classType:"",dataType:"",fkType:"",id:null,isPk:"",label:"FrontNode",name:"FrontNode",type:"keyword",code:'FrontNode=""'},{classType:"",dataType:"",fkType:"",id:null,isPk:"",label:"Relation",name:"Relation",type:"keyword",code:'Relation=""'},{classType:"",dataType:"",fkType:"",id:null,isPk:"",label:"ConditionDAO",name:"ConditionDAO",type:"keyword",code:''},{classType:"",dataType:"",fkType:"",id:null,isPk:"",label:"ConditionValue",name:"ConditionValue",type:"keyword",code:''},{classType:"",dataType:"",fkType:"",id:null,isPk:"",label:"Count",name:"Count",type:"keyword",code:'Count=""'}]}],createBtn:!1,saveBtn:!1,exportBtn:!1}},components:{Splitpanes:u.F,Pane:u.X,XMLFileTree:x,DAOTree:H,XMLCodeMirror:B},computed:{disabeldBtn(){return!this.currentFileItem?.id}},mounted(){h.Z.commit("setCurrentModule","XMLTemplateEditor"),this.QTRegister("XmlEditEventModule"),p.Z.$emit("change-title","XML模版编辑器"),this.getAllXmlData()},methods:{getAllXmlData(){this.QTSend("get-all-xml").then((({error:e,data:t})=>{console.log("getAllXmlData --data",e,t),e?f.z8.error(e):this.fileList=t||[]}))},getAllProject(){this.QTSend("get-all-project").then((({error:e,data:t})=>{e?f.z8.error(e):(console.log("data",t),this.projectList=t)}))},findDataModel(e,t){this.QTSend("get-project-datamodel",{id:e}).then((({error:e,data:l})=>{e?f.z8.error(e):t||(this.modelList=l,this.form.model="")}))},createHandle(){this.createBtn=!0,this.getAllProject(),this.dialogFormVisible=!0},createSubmitHandle(){if(!this.form.name||!this.form.project||!this.form.model)return void f.z8.error("请填写完整模板信息");const e=this.fileList.findIndex((e=>e.name==this.form.name));-1===e?this.QTSend("new-xml-file",{id:-1,name:this.form.name,projectId:this.form.project,datamodelId:this.form.model}).then((({error:e,data:t})=>{e?f.z8.error(e):(console.log("data",t),this.fileList.push(t),this.createdCloseHandle())})):f.z8.error("当前文件名已存在")},loopForDel(e,t){console.log("item.id === id",t,e),t&&t.forEach(((l,o)=>{l.id===e?t.splice(o,1):this.loopForDel(e,t["children"])}))},onDelete(e){console.log("param删除",e),this.QTSend("del-xml-file",{id:e.id}).then((({error:t,data:l})=>{t?f.z8.error(t):(this.loopForDel(e.id,this.fileList),this.currentFileItem.id===e.id&&(this.datamodelChildData=[]),f.z8.success("删除成功"))}))},async getProjectHandle(e){await this.findDataModel(e.projectId,1),await this.getCurrentXml(e)},loopDataHandleField(e){e&&e.forEach((e=>{2!==e.classType&&3!==e.classType||(e.label=2===e.classType?e.tableName:e.field),this.loopDataHandleField(e["children"])}))},getCurrentXml(e){this.QTSend("get-current-xml",{id:e.id}).then((({error:e,data:t})=>{e?f.z8.error(e):(console.log("get-current-xml",t),this.xmlFileItem=t,this.getDatamodelChild(t))}))},getDatamodelChild(e){this.QTSend("get-datamodel-child",{id:e.datamodelId}).then((({error:t,data:l})=>{if(console.log("getDatamodelChilderror, data",t,l),t)return void f.z8.error(t);let o=[{label:e.modelName,children:l}];o=o.concat(this.keywordsList),this.loopDataChangeField(o),this.datamodelChildData=o,this.loopDataHandleField(this.datamodelChildData[0].children),this.showDescription=!0})),this.currentFileItem=e},loopDataChangeField(e){e&&e.forEach((e=>{for(const t in e)Array.isArray(e[t])&&("attributes"==t&&(e["children"]=e.attributes,delete e.attributes),2==e.classType&&e.children.unshift({field:"_ID",classType:3,id:e.id+"_0"}),this.loopDataChangeField(e["children"]))}))},saveHandle(){this.saveBtn=!0,console.log("currentFileItem",this.currentFileItem),this.QTSend("save-xml-file",{id:this.currentFileItem.id,content:this.$refs.XMLCodeMirror.code}).then((({error:e,data:t})=>{e?f.z8.error(e):(console.log("data",t),t&&f.z8.success("保存成功"),this.saveBtn=!1)}))},exportHandle(){this.exportBtn=!0,this.QTSend("export-xml-file",{name:this.currentFileItem.name,content:this.$refs.XMLCodeMirror.code}).then((({error:e,data:t})=>{if(e)return f.z8.error(e),void(this.exportBtn=!1);console.log("data",t),t.status&&(f.z8.success("导出成功"),g.T.confirm("是否需要查看导出文件?",{confirmButtonText:"是",cancelButtonText:"否"}).then((async()=>{this.QTSend("open-xml-dir",{name:this.currentFileItem.name}).then((({error:e,data:t})=>{e&&f.z8.error(e)}))})).catch((()=>{}))),this.exportBtn=!1}))},createdCloseHandle(){this.dialogFormVisible=!1,this.createBtn=!1,this.form.name="",this.form.project="",this.form.model="",this.modelList=[]}},beforeRouteLeave(e,t,l){console.log("to, from, next",e,t,l);const o=this.$refs.xmlTree.hasOpenedItem;console.log("this.hasOpenedItem",o),o&&o?.id?g.T.confirm(`是否需要保存文件:${o.name}?`,"Warning",{confirmButtonText:"保存",cancelButtonText:"取消",type:"warning"}).then((async()=>{await this.saveHandle(),l()})).catch((()=>{l()})):l()}});const S=(0,k.Z)(A,[["render",m],["__scopeId","data-v-26dcd95d"]]);var X=S}}]);
//# sourceMappingURL=233.ad4b770e.js.map