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