dataColSetting-f2372139.js 8.6 KB

1
  1. var y=(C,S,h)=>new Promise((T,P)=>{var I=o=>{try{D(h.next(o))}catch(f){P(f)}},v=o=>{try{D(h.throw(o))}catch(f){P(f)}},D=o=>o.done?T(o.value):Promise.resolve(o.value).then(I,v);D((h=h.apply(C,S)).next())});import{f as U,b7 as E,ao as oe,_ as le}from"./index.js";import{c as se,m as ie,g as re,f as de}from"./jointApi-2ea41cbf.js";import{u as J,_ as O,a as ue}from"./useTable-3abd6d70.js";import{B as K,O as Q,U as j,Q as Y,R as ce}from"./antd-ecb53b14.js";import{d as ge,f as m,B as fe,x as pe,Y as b,Z as k,_ as u,l as i,a7 as s,E as c,u as n,$ as g,F as N,a9 as R,a6 as me,a1 as ve,a2 as ye}from"./vue-8fccce23.js";import"./useForm-19fca69f.js";import"./FormItem.vue_vue_type_script_lang-35d3ca4d.js";import"./useFormItem-d8cab136.js";import"./index-8cbf1e33.js";import"./useWindowSizeFn-8ad2dbf2.js";import"./uuid-31b8b5a4.js";import"./useSortable-987ef813.js";import"./download-c6c2acd3.js";import"./index-22d6b33a.js";import"./copyTextToClipboard-ab85e052.js";import"./index-3eef3423.js";import"./index-b614de6b.js";import"./TextEditor-284232fa.js";import"./onMountedOrActivated-cb072c10.js";import"./componentMap-16efd70f.js";import"./sortable.esm-4ae27e0b.js";const Ce=[{title:"序号",align:"center",width:50,dataIndex:"currentIndex"},{title:"字段名称",width:150,align:"center",dataIndex:"name"},{title:"类型",align:"center",width:120,dataIndex:"type"},{title:"注释",width:150,align:"center",dataIndex:"comment"},{title:"是否为空",align:"center",width:80,dataIndex:"isnull"},{title:"是否主键",align:"center",width:80,dataIndex:"ifPrimaryKey"}],he=[{title:"序号",align:"center",width:50,dataIndex:"currentIndex"},{title:"字段名称",align:"center",width:150,dataIndex:"name"},{title:"类型",align:"center",width:120,dataIndex:"type"},{title:"注释",align:"center",width:150,dataIndex:"comment"},{title:"默认值",align:"center",width:150,edit:!0,editable:!0,dataIndex:"defaultValue",editComponent:"Input",editComponentProps:{placeholder:"请输入字段默认值"}},{title:"是否为空",align:"center",width:80,dataIndex:"isnull"},{title:"是否主键",align:"center",width:80,dataIndex:"ifPrimaryKey"}],Z=C=>(ve("data-v-29639e86"),C=C(),ye(),C),xe={class:"steps-inner"},Ie={class:"steps-action"},_e=Z(()=>u("div",null,null,-1)),we=Z(()=>u("div",{style:{height:"50px"}},null,-1)),be={style:{display:"flex","justify-content":"space-between"}},Se={style:{height:"50px","line-height":"50px"}},De=ge({__name:"dataColSetting",props:{dataId:{type:String}},emits:["success","close","previousStep"],setup(C,{emit:S}){const h=C,{createMessage:T}=oe(),P=[{title:"映射",align:"center",width:80,dataIndex:"auxiliary"}],I=m([]),v=m(!1),D=m(""),o=m({mapping:{source:[],target:[]}}),f=m([]),p=m([]),V=m(),F=m(),L=m([]);fe(()=>y(this,null,function*(){yield W(h.dataId),(yield se()).forEach(a=>{L.value.push({label:a.datasourceName,value:a.id})})}));const[q]=J({rowKey:"id",columns:Ce,dataSource:f,showIndexColumn:!1,useSearchForm:!1,showTableSetting:!1,pagination:!1,bordered:!1}),[z]=J({dataSource:p,rowKey:"id",columns:he,showIndexColumn:!1,useSearchForm:!1,showTableSetting:!1,pagination:!1,bordered:!1,customRow:te,actionColumn:{width:80,align:"center",title:"操作",dataIndex:"action"}}),[H]=J({dataSource:I,columns:P,showIndexColumn:!1,useSearchForm:!1,showTableSetting:!1,pagination:!1,bordered:!1});function W(l){return y(this,null,function*(){yield pe();const a=yield ie(l);if(o.value=a,D.value=a.id,a&&a.mapping&&a.mapping.source){const e=a.mapping.source;f.value=yield G(e);for(let t=0;t<f.value.length;t++)I.value.push({auxiliary:"➤➤➤"})}else yield B("source");a&&a.mapping&&a.mapping.target?(p.value=a.mapping.target,p.value.forEach(e=>{e.sourceCode=e.currentIndex,e.targetCode=e.currentIndex})):yield B("destination")})}function B(l){return y(this,null,function*(){var a,e,t,d,r,_;if(l==="source"){if(o.value.sourceConfig){const w={datasourceId:(a=o.value.sourceConfig)==null?void 0:a.datasourceId,tableName:(e=o.value.sourceConfig)==null?void 0:e.table,tableSchema:(t=o.value.sourceConfig)==null?void 0:t.scheme};A(w,"source")}}else if(o.value.targetConfig){const w={datasourceId:(d=o.value.targetConfig)==null?void 0:d.datasourceId,tableName:(r=o.value.targetConfig)==null?void 0:r.table,tableSchema:(_=o.value.targetConfig)==null?void 0:_.scheme};A(w,"destination")}})}function A(l,a){return y(this,null,function*(){const e=yield re(l);if(a=="source"){const t=e;f.value=yield G(t)}else e.forEach(t=>{t.sourceCode=t.currentIndex,t.targetCode=t.currentIndex}),p.value=e;I.value=[];for(let t=0;t<e.length;t++)I.value.push({auxiliary:"➤➤➤"})})}function X(){return y(this,null,function*(){try{v.value=!0,o.value.mapping={source:f.value,target:p.value};const l=yield de(o.value);T.success("数据字段映射配置成功!"),S("success",l)}finally{v.value=!1}})}function ee(){S("previousStep",h.dataId)}function te(l,a){return{props:{},style:{cursor:"move"},onMouseenter:e=>{const t=e||window.event;t.target.draggable=!0},onDragstart:e=>{(e||window.event).stopPropagation(),V.value=l.sourceCode},onDragover:e=>{(e||window.event).preventDefault()},onDragenter:e=>{(e||window.event).preventDefault();const d=document.getElementsByClassName("ant-table-row"),r=document.getElementsByClassName("target");r.length&&r[0].classList.remove("target"),d[a].classList.add("target")},onDrop:e=>{(e||window.event).stopPropagation(),F.value=l.targetCode;const d=document.getElementsByClassName("target");if(d.length&&d[0].classList.remove("target"),V.value!=F.value){const r=p.value.slice(),_=r.findIndex(x=>x.sourceCode===V.value),w=r[_];r.splice(_,1);const M=r.findIndex(x=>x.targetCode===F.value);_===M?r.splice(M+1,0,w):r.splice(M,0,w),r.forEach((x,$)=>{x.currentIndex=$+1,x.sourceIndex=$+1,x.targetIndex=$+1}),p.value=r}}}}function ae(l){p.value.forEach((a,e)=>{if(a.targetCode==l.targetCode){const t={comment:void 0,ifPrimaryKey:void 0,isnull:void 0,name:void 0,defaultValue:void 0,targetCode:l.targetCode,sourceCode:l.sourceCode,type:void 0,currentIndex:a.currentIndex};p.value[e]=t}})}function ne(){return y(this,null,function*(){yield B("destination"),yield B("source")})}function G(l){return y(this,null,function*(){return l.sort((a,e)=>a.currentIndex>e.currentIndex?1:a.currentIndex<e.currentIndex?-1:0)})}return(l,a)=>(b(),k("div",xe,[u("div",Ie,[_e,u("div",null,[i(n(K),{loading:v.value,type:"primary",onClick:ee},{default:s(()=>[c("上一步")]),_:1},8,["loading"]),i(n(K),{loading:v.value,type:"primary",style:{"margin-left":"8px"},onClick:X},{default:s(()=>[c("下一步")]),_:1},8,["loading"]),i(n(K),{loading:v.value,danger:"",style:{"margin-left":"8px"},onClick:a[0]||(a[0]=e=>S("close"))},{default:s(()=>[c("关闭")]),_:1},8,["loading"])])]),u("div",null,[i(n(ce),null,{default:s(()=>[i(n(Q),{span:9},{default:s(()=>[i(n(j),null,{title:s(()=>{var e,t,d;return[i(n(Y),{color:"#2db7f5"},{default:s(()=>[c("来源")]),_:1}),c(g(n(U)(L.value,(e=o.value.sourceConfig)==null?void 0:e.datasourceId,"label"))+": "+g((t=o.value.sourceConfig)==null?void 0:t.scheme)+" ",1),u("div",null,"数据表:"+g((d=o.value.sourceConfig)==null?void 0:d.table),1)]}),default:s(()=>[u("div",null,[i(n(O),{onRegister:n(q)},{bodyCell:s(({column:e,record:t})=>[e.key=="isnull"?(b(),k(N,{key:0},[c(g(t.isnull!=null?n(E)(t.isnull,0):""),1)],64)):R("",!0),e.key=="ifPrimaryKey"?(b(),k(N,{key:1},[c(g(t.ifPrimaryKey!=null?n(E)(t.ifPrimaryKey,0):""),1)],64)):R("",!0)]),_:1},8,["onRegister"])])]),_:1})]),_:1}),i(n(Q),{span:2},{default:s(()=>[i(n(j),null,{title:s(()=>[we]),default:s(()=>[u("div",null,[i(n(O),{onRegister:n(H)},null,8,["onRegister"])])]),_:1})]),_:1}),i(n(Q),{span:13},{default:s(()=>[i(n(j),null,{title:s(()=>{var e,t,d;return[u("div",be,[u("div",null,[i(n(Y),{color:"#f50"},{default:s(()=>[c("去向")]),_:1}),c(g(n(U)(L.value,(e=o.value.targetConfig)==null?void 0:e.datasourceId,"label"))+": "+g((t=o.value.targetConfig)==null?void 0:t.scheme)+" ",1),u("div",null," 数据表:"+g((d=o.value.targetConfig)==null?void 0:d.table),1)]),u("div",Se,[i(n(K),{loading:v.value,type:"primary",onClick:ne,tooltip:"梯式"},{default:s(()=>[c("重置")]),_:1},8,["loading"])])])]}),default:s(()=>[u("div",null,[i(n(O),{onRegister:n(z)},{bodyCell:s(({column:e,record:t})=>[e.key=="isnull"?(b(),k(N,{key:0},[c(g(t.isnull!=null?n(E)(t.isnull,0):""),1)],64)):R("",!0),e.key=="ifPrimaryKey"?(b(),k(N,{key:1},[c(g(t.ifPrimaryKey!=null?n(E)(t.ifPrimaryKey,0):""),1)],64)):R("",!0),e.key=="action"?(b(),me(n(ue),{key:2,actions:[{ifShow:t.name!="",icon:"icon-xt-details_delete_default|iconfont",tooltip:"删除",popConfirm:{title:"是否确认删除",placement:"left",confirm:ae.bind(null,t)}}]},null,8,["actions"])):R("",!0)]),_:1},8,["onRegister"])])]),_:1})]),_:1})]),_:1})])]))}});const qe=le(De,[["__scopeId","data-v-29639e86"]]);export{qe as default};