vue3-gantt-customized
Version:
vue3甘特图 借鉴了原有作者ZRX
6 lines (4 loc) • 26.7 kB
JavaScript
(function(t,J){typeof exports=="object"&&typeof module<"u"?module.exports=J(require("vue")):typeof define=="function"&&define.amd?define(["vue"],J):(t=typeof globalThis<"u"?globalThis:t||self,t.vue3GanttCustomized=J(t.Vue))})(this,function(t){"use strict";const J={style:{display:"none"}},rt=t.defineComponent({__name:"types",setup(a){return(s,e)=>(t.openBlock(),t.createElementBlock("div",J))}}),ot=t.defineComponent({__name:"index",props:{isOpen:{type:Boolean,default:!1},color:{type:String,default:"#000000"}},setup(a){const s=t.ref(null),e=a;return t.onMounted(()=>{s.value&&s.value.style.setProperty("--bg-color",e.color)}),(d,h)=>(t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",{ref_key:"arrowRef",ref:s,class:t.normalizeClass([e.isOpen?"arrow_open":"","main-arrow"])},null,2)]))}}),st={class:"ganttOverview-box"},at={class:"ganttOverview-arrrow"},it={class:"ganttOverview-head"},lt={class:"ganttOverview-body"},dt={style:{flex:"1",overflow:"hidden"}},ct=["title"],ht={key:0,class:"ganttOverview-body-cell-open"},gt={key:0,class:"quan"},mt=t.defineComponent({__name:"Table",props:{head:{},list:{},headWidth:{},headBodyPaddingY:{},headBodyPaddingX:{},scrollBarHeight:{},open:{type:Boolean},openStatus:{type:Boolean}},emits:["onChange"],setup(a,{emit:s}){const e=a,d=s,h=()=>{d("onChange")};return t.onMounted(()=>{}),(l,k)=>(t.openBlock(),t.createElementBlock("div",st,[e.open?(t.openBlock(),t.createElementBlock("div",{key:0,class:"ganttOverview-arrrow-box",onClick:h},[t.createElementVNode("div",at,[t.createVNode(ot,{isOpen:!e.openStatus,color:"#696B6C"},null,8,["isOpen"])])])):t.createCommentVNode("",!0),t.createElementVNode("div",{style:t.normalizeStyle({width:e.headWidth}),class:t.normalizeClass(e.openStatus?"ganttOverview":"ganttOverview-close")},[t.createElementVNode("div",{style:t.normalizeStyle({width:e.headWidth}),class:"ganttOverview-head-box"},[t.createElementVNode("div",it,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.head,(g,y)=>(t.openBlock(),t.createElementBlock("div",{key:y,class:"ganttOverview-head-item",style:t.normalizeStyle({textAlign:g.align?g.align:"center",width:g.width?g.width:"auto",maxWidth:g.width?g.width:"auto",minWidth:g.width?g.width:"auto"})},t.toDisplayString(g.title),5))),128))]),t.createElementVNode("div",lt,[t.createElementVNode("div",dt,[t.createElementVNode("div",{class:"ganttOverview-body-height",style:t.normalizeStyle({paddingLeft:l.headBodyPaddingX+"px",paddingRight:l.headBodyPaddingX+"px",paddingTop:l.headBodyPaddingY+"px",paddingBottom:l.headBodyPaddingY+"px"})},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.list,(g,y)=>(t.openBlock(),t.createElementBlock("div",{key:y,class:"ganttOverview-body-cell"},[(t.openBlock(),t.createElementBlock("div",{key:y,class:"ganttOverview-body-cell-filed"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.head,(u,w)=>(t.openBlock(),t.createElementBlock("div",{key:w,style:t.normalizeStyle({textAlign:u.align?u.align:"center",width:u.width?u.width:"auto",maxWidth:u.width?u.width:"auto",minWidth:u.width?u.width:"auto"}),class:"ganttOverview-body-cell-item",title:u.key?g[u.key]:""},t.toDisplayString(u.key?g[u.key]:""),13,ct))),128))])),g.children?(t.openBlock(),t.createElementBlock("div",ht,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(g.children,(u,w)=>(t.openBlock(),t.createElementBlock("div",{key:w,class:"ganttOverview-body-cell-open-cell"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.head,(m,V)=>(t.openBlock(),t.createElementBlock("div",{key:V,class:t.normalizeClass(["ganttOverview-body-cell-open-cell-item",V===0?"ganttOverview-body-cell-open-cell-item-first":""])},[V===0?(t.openBlock(),t.createElementBlock("div",gt)):t.createCommentVNode("",!0),t.createElementVNode("div",{style:t.normalizeStyle({width:m.width?m.width:"auto",maxWidth:m.width?m.width:"auto",minWidth:m.width?m.width:"auto"})},t.toDisplayString(m.key?u[m.key]:""),5)],2))),128))]))),128))])):t.createCommentVNode("",!0)]))),128))],4)]),t.createElementVNode("div",{style:t.normalizeStyle({height:e.scrollBarHeight+"px"})},null,4)])],4)],6)]))}});var pt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ft(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var et={exports:{}};(function(a,s){(function(e,d){a.exports=d()})(pt,function(){var e=1e3,d=6e4,h=36e5,l="millisecond",k="second",g="minute",y="hour",u="day",w="week",m="month",V="quarter",z="year",M="date",I="Invalid Date",A=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,X=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,_={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(c){var r=["th","st","nd","rd"],n=c%100;return"["+c+(r[(n-20)%10]||r[n]||r[0])+"]"}},W=function(c,r,n){var i=String(c);return!i||i.length>=r?c:""+Array(r+1-i.length).join(n)+c},$={s:W,z:function(c){var r=-c.utcOffset(),n=Math.abs(r),i=Math.floor(n/60),o=n%60;return(r<=0?"+":"-")+W(i,2,"0")+":"+W(o,2,"0")},m:function c(r,n){if(r.date()<n.date())return-c(n,r);var i=12*(n.year()-r.year())+(n.month()-r.month()),o=r.clone().add(i,m),p=n-o<0,f=r.clone().add(i+(p?-1:1),m);return+(-(i+(n-o)/(p?o-f:f-o))||0)},a:function(c){return c<0?Math.ceil(c)||0:Math.floor(c)},p:function(c){return{M:m,y:z,w,d:u,D:M,h:y,m:g,s:k,ms:l,Q:V}[c]||String(c||"").toLowerCase().replace(/s$/,"")},u:function(c){return c===void 0}},S="en",b={};b[S]=_;var T="$isDayjsObject",L=function(c){return c instanceof F||!(!c||!c[T])},E=function c(r,n,i){var o;if(!r)return S;if(typeof r=="string"){var p=r.toLowerCase();b[p]&&(o=p),n&&(b[p]=n,o=p);var f=r.split("-");if(!o&&f.length>1)return c(f[0])}else{var D=r.name;b[D]=r,o=D}return!i&&o&&(S=o),o||!i&&S},x=function(c,r){if(L(c))return c.clone();var n=typeof r=="object"?r:{};return n.date=c,n.args=arguments,new F(n)},B=$;B.l=E,B.i=L,B.w=function(c,r){return x(c,{locale:r.$L,utc:r.$u,x:r.$x,$offset:r.$offset})};var F=function(){function c(n){this.$L=E(n.locale,null,!0),this.parse(n),this.$x=this.$x||n.x||{},this[T]=!0}var r=c.prototype;return r.parse=function(n){this.$d=function(i){var o=i.date,p=i.utc;if(o===null)return new Date(NaN);if(B.u(o))return new Date;if(o instanceof Date)return new Date(o);if(typeof o=="string"&&!/Z$/i.test(o)){var f=o.match(A);if(f){var D=f[2]-1||0,Y=(f[7]||"0").substring(0,3);return p?new Date(Date.UTC(f[1],D,f[3]||1,f[4]||0,f[5]||0,f[6]||0,Y)):new Date(f[1],D,f[3]||1,f[4]||0,f[5]||0,f[6]||0,Y)}}return new Date(o)}(n),this.init()},r.init=function(){var n=this.$d;this.$y=n.getFullYear(),this.$M=n.getMonth(),this.$D=n.getDate(),this.$W=n.getDay(),this.$H=n.getHours(),this.$m=n.getMinutes(),this.$s=n.getSeconds(),this.$ms=n.getMilliseconds()},r.$utils=function(){return B},r.isValid=function(){return this.$d.toString()!==I},r.isSame=function(n,i){var o=x(n);return this.startOf(i)<=o&&o<=this.endOf(i)},r.isAfter=function(n,i){return x(n)<this.startOf(i)},r.isBefore=function(n,i){return this.endOf(i)<x(n)},r.$g=function(n,i,o){return B.u(n)?this[i]:this.set(o,n)},r.unix=function(){return Math.floor(this.valueOf()/1e3)},r.valueOf=function(){return this.$d.getTime()},r.startOf=function(n,i){var o=this,p=!!B.u(i)||i,f=B.p(n),D=function(G,P){var R=B.w(o.$u?Date.UTC(o.$y,P,G):new Date(o.$y,P,G),o);return p?R:R.endOf(u)},Y=function(G,P){return B.w(o.toDate()[G].apply(o.toDate("s"),(p?[0,0,0,0]:[23,59,59,999]).slice(P)),o)},C=this.$W,O=this.$M,H=this.$D,q="set"+(this.$u?"UTC":"");switch(f){case z:return p?D(1,0):D(31,11);case m:return p?D(1,O):D(0,O+1);case w:var U=this.$locale().weekStart||0,Z=(C<U?C+7:C)-U;return D(p?H-Z:H+(6-Z),O);case u:case M:return Y(q+"Hours",0);case y:return Y(q+"Minutes",1);case g:return Y(q+"Seconds",2);case k:return Y(q+"Milliseconds",3);default:return this.clone()}},r.endOf=function(n){return this.startOf(n,!1)},r.$set=function(n,i){var o,p=B.p(n),f="set"+(this.$u?"UTC":""),D=(o={},o[u]=f+"Date",o[M]=f+"Date",o[m]=f+"Month",o[z]=f+"FullYear",o[y]=f+"Hours",o[g]=f+"Minutes",o[k]=f+"Seconds",o[l]=f+"Milliseconds",o)[p],Y=p===u?this.$D+(i-this.$W):i;if(p===m||p===z){var C=this.clone().set(M,1);C.$d[D](Y),C.init(),this.$d=C.set(M,Math.min(this.$D,C.daysInMonth())).$d}else D&&this.$d[D](Y);return this.init(),this},r.set=function(n,i){return this.clone().$set(n,i)},r.get=function(n){return this[B.p(n)]()},r.add=function(n,i){var o,p=this;n=Number(n);var f=B.p(i),D=function(O){var H=x(p);return B.w(H.date(H.date()+Math.round(O*n)),p)};if(f===m)return this.set(m,this.$M+n);if(f===z)return this.set(z,this.$y+n);if(f===u)return D(1);if(f===w)return D(7);var Y=(o={},o[g]=d,o[y]=h,o[k]=e,o)[f]||1,C=this.$d.getTime()+n*Y;return B.w(C,this)},r.subtract=function(n,i){return this.add(-1*n,i)},r.format=function(n){var i=this,o=this.$locale();if(!this.isValid())return o.invalidDate||I;var p=n||"YYYY-MM-DDTHH:mm:ssZ",f=B.z(this),D=this.$H,Y=this.$m,C=this.$M,O=o.weekdays,H=o.months,q=o.meridiem,U=function(P,R,Q,v){return P&&(P[R]||P(i,p))||Q[R].slice(0,v)},Z=function(P){return B.s(D%12||12,P,"0")},G=q||function(P,R,Q){var v=P<12?"AM":"PM";return Q?v.toLowerCase():v};return p.replace(X,function(P,R){return R||function(Q){switch(Q){case"YY":return String(i.$y).slice(-2);case"YYYY":return B.s(i.$y,4,"0");case"M":return C+1;case"MM":return B.s(C+1,2,"0");case"MMM":return U(o.monthsShort,C,H,3);case"MMMM":return U(H,C);case"D":return i.$D;case"DD":return B.s(i.$D,2,"0");case"d":return String(i.$W);case"dd":return U(o.weekdaysMin,i.$W,O,2);case"ddd":return U(o.weekdaysShort,i.$W,O,3);case"dddd":return O[i.$W];case"H":return String(D);case"HH":return B.s(D,2,"0");case"h":return Z(1);case"hh":return Z(2);case"a":return G(D,Y,!0);case"A":return G(D,Y,!1);case"m":return String(Y);case"mm":return B.s(Y,2,"0");case"s":return String(i.$s);case"ss":return B.s(i.$s,2,"0");case"SSS":return B.s(i.$ms,3,"0");case"Z":return f}return null}(P)||f.replace(":","")})},r.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},r.diff=function(n,i,o){var p,f=this,D=B.p(i),Y=x(n),C=(Y.utcOffset()-this.utcOffset())*d,O=this-Y,H=function(){return B.m(f,Y)};switch(D){case z:p=H()/12;break;case m:p=H();break;case V:p=H()/3;break;case w:p=(O-C)/6048e5;break;case u:p=(O-C)/864e5;break;case y:p=O/h;break;case g:p=O/d;break;case k:p=O/e;break;default:p=O}return o?p:B.a(p)},r.daysInMonth=function(){return this.endOf(m).$D},r.$locale=function(){return b[this.$L]},r.locale=function(n,i){if(!n)return this.$L;var o=this.clone(),p=E(n,i,!0);return p&&(o.$L=p),o},r.clone=function(){return B.w(this.$d,this)},r.toDate=function(){return new Date(this.valueOf())},r.toJSON=function(){return this.isValid()?this.toISOString():null},r.toISOString=function(){return this.$d.toISOString()},r.toString=function(){return this.$d.toUTCString()},c}(),j=F.prototype;return x.prototype=j,[["$ms",l],["$s",k],["$m",g],["$H",y],["$W",u],["$M",m],["$y",z],["$D",M]].forEach(function(c){j[c[1]]=function(r){return this.$g(r,c[0],c[1])}}),x.extend=function(c,r){return c.$i||(c(r,F,x),c.$i=!0),x},x.locale=E,x.isDayjs=L,x.unix=function(c){return x(1e3*c)},x.en=b[S],x.Ls=b,x.p={},x})})(et);var yt=et.exports;const N=ft(yt),ut=[{status:"finish",text:"已完成"},{status:"finishOvertime",text:"已完成"},{status:"overtime",text:"已超时"},{status:"progress",text:"进行中"},{status:"wait",text:"待接受"}],Bt=(a,s)=>{const e=new Date(a.slice(0,8)),d=new Date(s.slice(0,8)),h=[];for(;e<=d;)h.push(N(e).format("YYYY-MM")),e.setMonth(e.getMonth()+1);return h},wt=(a,s,e)=>{const d=new Date(a),h=e==="day"?new Date(s):new Date(new Date(s).getTime()+864e5*30),l=d,k=[];if(e==="day"){const g=Bt(a,s);g.forEach((y,u)=>{const w=Number(y.split("-")[0]),m=Number(y.split("-")[1]);u===0?k.push({year:`${w}-${m}`,length:N(a).endOf("month").date()-N(a).date()+1}):u===g.length-1?k.push({year:`${w}-${m}`,length:new Date(s).getDate()}):k.push({year:`${w}-${m}`,length:new Date(w,m,0).getDate()})})}else if(e==="month"){const g=[];for(;l<=h;)g.push(N(l).format("YYYY-MM")),l.setMonth(l.getMonth()+1);g.forEach(y=>{const u=Number(y.split("-")[0]),w=Number(y.split("-")[1]);k.push({year:`${u}-${w}`,length:new Date(u,w,0).getDate()})})}return k},kt=(a,s)=>{const e=N(a),d=N(s),h=[];for(let l=e;l.isBefore(d);l=l.add(1,"day"))h.push(l.format("YYYY-MM-DD"));return h.push(s),h},$t=(a,s)=>a?(new Date(a).getTime()-new Date(s).getTime())/1e3/3600:(new Date().getTime()-new Date(s).getTime())/1e3/3600;function _t(a,s){let e;return function(...d){clearTimeout(e),e=setTimeout(()=>{a.apply(this,d)},s)}}function tt(){let a="";const s="0123456789abcdef";for(let e=0;e<36;e++)if(e===8||e===13||e===18||e===23)a+="-";else if(e===14)a+="4";else{const d=Math.floor(Math.random()*16);a+=s[e===19?d&3|8:d]}return a}const Dt=a=>{const s=[];return a.forEach((e,d)=>{d>0&&s.push({...e,ganttId:tt(),isParent:!0,isEmpty:!1,parentIsEmpty:!0,height:10,left:0,width:0,progress:0}),s.push({...e,ganttId:tt(),isParent:!0,height:40,isEmpty:!1,parentIsEmpty:!1,left:0,width:0,progress:0}),e.children&&e.children.forEach((h,l)=>{l===0&&s.push({...h,ganttId:tt(),isParent:!1,parentIsEmpty:!1,isEmpty:!0,height:15,left:0,width:0,progress:0})})}),s};function Et(){const a=document.createElement("div");a.style.position="absolute",a.style.visibility="hidden",a.style.overflow="scroll",a.style.width="100px",a.style.height="100px",document.body.appendChild(a);const s=100-a.clientWidth;return document.body.removeChild(a),s}const nt=t.defineComponent({__name:"index",props:{item:{},ganttProgressBarId:{}},setup(a){const s=a,e=t.reactive({top:0,left:0,bottom:0,height:0});return t.onUnmounted(()=>{const d=document.getElementsByClassName("progressBar");console.log("elements",d);for(let h=0;h<d.length;h++)d[h].classList.remove("gantt-animation");document.getElementById("top-time-width").innerHTML=""}),t.onMounted(()=>{console.log("props.item.ganttProgressBarId",s.item.ganttProgressBarId);const d=document.getElementById("gantt-right-body-content"),h=document.getElementById(s.item.ganttProgressBarId);if(d&&h){const g=d.getBoundingClientRect().top-h.getBoundingClientRect().top;e.top=g-1,e.height=d.clientHeight||0}const l=document.getElementsByClassName("progressBar");let k=document.getElementById("top-time-width");console.log("elementById",k),k.innerHTML=`
<div class="top-time-width-item" style="left:${s.item.left+5}px;">
<div class="top-time-width-item-child" style="width:${s.item.width+1}px; background:var(--finishColor)"></div>
</div>`;for(let g=0;g<l.length;g++){const y=l[g];y.id!=s.ganttProgressBarId&&y.classList.add("gantt-animation")}}),(d,h)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",{class:t.normalizeClass("helpLine-line helpLine-line-finish"),style:t.normalizeStyle({top:e.top+"px",left:s.item.left+5+"px",height:e.height+"px"})},null,4),t.createElementVNode("div",{class:t.normalizeClass("helpLine-line helpLine-line-finish"),style:t.normalizeStyle({left:s.item.left+5+s.item.width+"px",top:e.top+"px",height:e.height+"px"})},null,4)],64))}}),Mt={class:"gantt-right-body-cell gantt-right-body-cell-isParent-true"},St=["onMouseenter","onMouseleave","id"],bt={class:"progressBar-box"},xt={class:"progressBar-render"},Yt=t.defineComponent({__name:"index",props:{item:{},index:{},showLine:{type:Boolean},statusList:{}},emits:["onClickText"],setup(a,{emit:s}){const e=a,d=t.ref(""),h=y=>{d.value=`gantt-progressBar-Id${e.index}-${y}`},l=y=>{d.value=""},k=["#E1F7E7","#D1EAF5","#C3D6F2","#768CCE","#F886AB","#FE8D6F","#FDC453","#DFDD6C","#9ADBC5"],g=y=>k[Math.floor(Math.random()*k.length)];return(y,u)=>(t.openBlock(),t.createElementBlock("div",Mt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.timePositions,(w,m)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:m},[t.createElementVNode("div",{onMouseenter:()=>h(m),onMouseleave:()=>l(),id:`gantt-progressBar-Id${e.index}-${m}`,class:t.normalizeClass("progressBar"),style:t.normalizeStyle({left:w.left+"px"})},[t.createElementVNode("div",bt,[t.createElementVNode("div",xt,[t.renderSlot(y.$slots,"parentSlot",t.mergeProps({ref_for:!0},{...e.item,timePosition:w,width:w.width,activeWidth:w.width*(e.item.progress||0),surplusWidth:w.width-w.width*(e.item.progress||0),overflowWidth:w.overtimeWidth}))]),t.createElementVNode("div",{class:"progressBar-default",style:t.normalizeStyle({width:w.width+"px"})},[t.createElementVNode("div",{class:"progressBar-active",style:t.normalizeStyle({width:w.width+"px",background:g(),textAlign:"center"})},t.toDisplayString(w.name),5)],4)])],44,St),e.showLine&&d.value===`gantt-progressBar-Id${e.index}-${m}`?(t.openBlock(),t.createBlock(nt,{key:0,ganttProgressBarId:d.value,item:{...w,ganttProgressBarId:`gantt-progressBar-Id${e.index}-${m}`}},null,8,["ganttProgressBarId","item"])):t.createCommentVNode("",!0)],64))),128))]))}}),Ct={class:"gantt-right-body-cell gantt-right-body-cell-isParent-false"},Tt=["id"],Lt={class:"progressBar-box"},Nt={class:"progressBar-render progressBar-render-child"},Ot=t.defineComponent({__name:"index",props:{item:{},index:{},showLine:{type:Boolean},ganttProgressBarId:{}},setup(a){const s=a,e=t.ref(""),d=()=>{e.value=`gantt-progressBar-Id${s.index}`},h=()=>{e.value=""};return(l,k)=>(t.openBlock(),t.createElementBlock("div",Ct,[t.createElementVNode("div",{onMouseenter:d,onMouseleave:h,id:"gantt-progressBar-Id"+l.index,class:t.normalizeClass(`progressBar progressBar-${s.item.status}`),style:t.normalizeStyle({padding:"5px",border:"0",background:"transparent",left:s.item.left+"px"})},[t.createElementVNode("div",Lt,[t.createElementVNode("div",Nt,[t.renderSlot(l.$slots,"childrenSlot",t.normalizeProps(t.guardReactiveProps({...l.item,width:l.item.width,activeWidth:l.item.width*l.item.progress,surplusWidth:l.item.width-l.item.width*l.item.progress,overflowWidth:l.item.overtimeWidth})))]),t.createElementVNode("div",{class:"progressBar-default progressBar-default-child",style:t.normalizeStyle({width:s.item.width+"px"})},[t.createElementVNode("div",{class:"progressBar-active progressBar-active-child",style:t.normalizeStyle({width:s.item.progress*100+"%"})},null,4)],4),(s.item.status==="overtime"||s.item.status==="finishOvertime")&&s.item.overtimeWidth?(t.openBlock(),t.createElementBlock("div",{key:0,class:"progressBar-overTimeWidth progressBar-overTimeWidth-child",style:t.normalizeStyle({width:s.item.overtimeWidth+"px"})},k[0]||(k[0]=[t.createElementVNode("div",{class:"overtimeRender"},null,-1)]),4)):t.createCommentVNode("",!0)])],46,Tt),s.showLine&&e.value===`gantt-progressBar-Id${s.index}`?(t.openBlock(),t.createBlock(nt,{key:0,ganttProgressBarId:e.value,item:{...l.item,ganttProgressBarId:`gantt-progressBar-Id${s.index}`}},null,8,["ganttProgressBarId","item"])):t.createCommentVNode("",!0)]))}}),Wt={className:"gantt-right-body-content-mark"},Pt=t.defineComponent({__name:"index",props:{days:{},width:{},bodyRect:{}},setup(a){const s=a;return(e,d)=>(t.openBlock(),t.createElementBlock("div",Wt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.days,(h,l)=>(t.openBlock(),t.createElementBlock("div",{key:l,class:"gantt-right-body-content-mark-item",style:t.normalizeStyle({width:s.width*h.length+"px",minWidth:s.width*h.length+"px",height:s.bodyRect.scrollHeight?s.bodyRect.scrollHeight+"px":"100%"})},null,4))),128))]))}}),Vt={class:"gantt-right",id:"gantt-right"},Ht={class:"gantt-right-body-head-box"},zt={class:"gantt-right-body-head"},It={class:"gantt-right-body-head-list gantt-right-body-head-year"},Ft={class:"gantt-right-body-head-list"},Rt={class:"gantt-right-body-body"},At={style:{flex:"1",overflow:"hidden"}},jt={key:0,class:"gantt-right-body-cell gantt-right-body-cell-isEmpty"},Ut={key:1,class:"gantt-right-body-cell gantt-right-body-cell-parentIsEmpty"},Gt=t.defineComponent({__name:"TimeData",props:{list:{},headBodyPaddingY:{},showLine:{type:Boolean},ganttType:{},statusList:{default:()=>ut}},emits:["onChangeScrollBarHeight","onClickText"],setup(a,{expose:s,emit:e}){const d=a,h=e,l=t.ref([]),k=t.ref([]),g=t.ref([]),y=t.ref(0),u=t.ref(0),w=t.ref(""),m=t.ref(),V=t.reactive({height:0,scrollWidth:0,scrollHeight:0}),z=_=>{_&&_.target&&(document.getElementsByClassName("gantt-right-body-head")[0].scrollLeft=_.target.scrollLeft,document.getElementsByClassName("ganttOverview-body-height")[0].scrollTop=_.target.scrollTop)},M=_=>{h("onClickText",_)},I=(_,W,$)=>{const S=_/24,b=$.map(T=>{const L=T.timeInfoList.map(E=>{const B=N(E.startTime).diff(W.startDate,"day"),F=new Date(E.startTime).getHours(),j=$t(E.endTime,E.startTime);return{startTime:E.startTime,endTime:E.endTime,start:E.start,overtimeWidth:0*S,width:j*S,left:B*_+F*S-5}});return{...T,timePositions:L}});g.value=b,t.nextTick(()=>{const T=m.value.offsetHeight-m.value.clientHeight;V.scrollHeight=m.value.scrollHeight>m.value.clientHeight?m.value.scrollHeight:0,V.height=m.value.offsetHeight,V.scrollWidth=m.value.offsetWidth-m.value.clientWidth,h("onChangeScrollBarHeight",T)})},A=(_,W)=>{var b;const $=(b=document.getElementById("gantt-right"))==null?void 0:b.offsetWidth;let S=d.headBodyPaddingY*2;if(W.forEach(T=>{S+=T.height}),$){const T=m.value.offsetHeight,L=Et(),E=S>T?$-L:$,x=wt(_.startDate,_.endDate,d.ganttType);let B=0;l.value=x;const F=kt(_.startDate,_.endDate),j=E/F.length;B=j>40?j:40;const c=F.map(r=>({year:r,length:1}));k.value=c,u.value=$,I(B,_,W),y.value=B}},X=()=>{g.value=[];const _=Dt(d.list),W=_.flatMap(L=>L.timeInfoList.map(E=>new Date(E.startTime).getTime())).sort((L,E)=>L-E),$=_.flatMap(L=>L.timeInfoList.map(E=>new Date(E.endTime).getTime())).sort((L,E)=>E-L);if(W.length===0||$.length===0)return;const S=W,b=$,T={startDate:"",endDate:""};if(N(S[0]).format("YYYY-MM")===N(b[0]).format("YYYY-MM")){const L=N(b[0]+1728e5).format("YYYY-MM"),E=N(b[0]).format("YYYY-MM"),x=N(b[0]+864e5*2).endOf("month").format("YYYY-MM-DD");T.startDate=N(S[0]).format("YYYY-MM")+"-01",T.endDate=L===E?x:N(b[0]+864e5*2).format("YYYY-MM-DD")}else T.startDate=N(S[0]-864e5).format("YYYY-MM-DD"),T.endDate=N(b[0]+864e5*2).format("YYYY-MM-DD");A(T,_)};return t.onMounted(()=>{X(),window.addEventListener("resize",_t(X,200))}),t.onUnmounted(()=>{window.removeEventListener("resize",X)}),s({initList:X}),(_,W)=>(t.openBlock(),t.createElementBlock("div",Vt,[t.createElementVNode("div",{class:"gantt-right-body",id:"gantt-right-body",style:t.normalizeStyle({width:u.value+"px"})},[t.createElementVNode("div",Ht,[t.createElementVNode("div",zt,[W[0]||(W[0]=t.createElementVNode("div",{id:"top-time-width"},null,-1)),t.createElementVNode("div",It,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.value,($,S)=>(t.openBlock(),t.createElementBlock("div",{key:S,style:t.normalizeStyle({width:y.value*$.length+"px",minWidth:y.value*$.length+"px"}),class:"gantt-right-body-head-year-item"},t.toDisplayString($.year),5))),128))]),t.createElementVNode("div",Ft,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(k.value,($,S)=>(t.openBlock(),t.createElementBlock("div",{key:S,style:t.normalizeStyle({width:y.value*$.length+"px",minWidth:y.value*$.length+"px"}),class:"gantt-right-head-item-day"},t.toDisplayString(_.ganttType==="day"?$.year.split("-")[2]:$.year.split("-")[1]),5))),128))])]),t.createElementVNode("div",{class:"gantt-right-head-scrollBarWidth",style:t.normalizeStyle({width:V.scrollWidth+"px"})},null,4)]),t.createElementVNode("div",Rt,[t.createElementVNode("div",At,[t.createElementVNode("div",{class:"gantt-right-body-content",ref_key:"bodyContentRef",ref:m,onScroll:z,id:"gantt-right-body-content"},[g.value.length?(t.openBlock(),t.createBlock(Pt,{key:0,days:k.value,width:y.value,bodyRect:V},null,8,["days","width","bodyRect"])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:"gantt-right-body-cell",style:t.normalizeStyle({height:d.headBodyPaddingY+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(g.value,($,S)=>(t.openBlock(),t.createElementBlock("div",{key:$.ganttId},[$.isEmpty?(t.openBlock(),t.createElementBlock("div",jt)):$.parentIsEmpty?(t.openBlock(),t.createElementBlock("div",Ut)):$.isParent?$.isParent?(t.openBlock(),t.createBlock(Yt,{key:3,item:$,index:S,showLine:d.showLine,ganttProgressBarId:w.value,statusList:_.statusList,onOnClickText:M},{parentSlot:t.withCtx(b=>[t.renderSlot(_.$slots,"parentSlot",t.mergeProps({ref_for:!0},b))]),_:2},1032,["item","index","showLine","ganttProgressBarId","statusList"])):t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(Ot,{key:2,item:$,index:S,showLine:d.showLine,ganttProgressBarId:w.value},{childrenSlot:t.withCtx(b=>[t.renderSlot(_.$slots,"childrenSlot",t.mergeProps({ref_for:!0},b))]),_:2},1032,["item","index","showLine","ganttProgressBarId"]))]))),128)),t.createElementVNode("div",{class:"gantt-right-body-cell",style:t.normalizeStyle({height:d.headBodyPaddingY+"px"})},null,4)],544)])])],4)]))}}),K=t.defineComponent({__name:"index",props:{data:{},head:{},ganttType:{default:"day"},height:{default:"auto"},headWidth:{default:"400px"},showLine:{type:Boolean,default:!0},headBodyPaddingY:{default:10},headBodyPaddingX:{default:0},open:{type:Boolean,default:!0}},emits:["onClickText"],setup(a,{expose:s,emit:e}){const d=e,h=a,l=t.ref(),k=t.ref(0),g=t.ref(!0),y=t.ref(h.ganttType),u=()=>{g.value=!g.value,setTimeout(()=>{var M;(M=l.value)==null||M.initList()},300)},w=M=>{d("onClickText",M)},m=M=>{k.value=M};return s({setGanttType:M=>{y.value=M,setTimeout(()=>{var I;(I=l.value)==null||I.initList()})},initGantt:M=>{setTimeout(()=>{var I;(I=l.value)==null||I.initList()},M)}}),(M,I)=>(t.openBlock(),t.createElementBlock("div",{className:"gantt",style:t.normalizeStyle({height:M.height})},[t.createVNode(mt,{head:h.head,list:h.data,openStatus:g.value,open:h.open,headBodyPaddingY:h.headBodyPaddingY,headBodyPaddingX:h.headBodyPaddingX,headWidth:h.headWidth,scrollBarHeight:k.value,onOnChange:u},null,8,["head","list","openStatus","open","headBodyPaddingY","headBodyPaddingX","headWidth","scrollBarHeight"]),t.createVNode(Gt,{ref_key:"timeDataRef",ref:l,showLine:h.showLine,ganttType:y.value,list:h.data,headBodyPaddingY:h.headBodyPaddingY,onOnChangeScrollBarHeight:m,onOnClickText:w},{parentSlot:t.withCtx(A=>[t.renderSlot(M.$slots,"parentSlot",t.normalizeProps(t.guardReactiveProps(A)))]),childrenSlot:t.withCtx(A=>[t.renderSlot(M.$slots,"childrenSlot",t.normalizeProps(t.guardReactiveProps(A)))]),_:3},8,["showLine","ganttType","list","headBodyPaddingY"]),t.createVNode(rt)],4))}});return K.install=a=>{a.component(K.__name,K)},K});