st-comp 0.0.228 → 0.0.230

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/KlineBasic.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("./base-ef747d02.cjs");const ve=require("./el-dialog-ae86edb8.cjs");require("./el-overlay-9e34965f.cjs");require("./el-input-7fd293af.cjs");const xe=require("./el-input-number-22e21d16.cjs"),be=require("./el-button-eec58cff.cjs"),he=require("./el-empty-1697ded8.cjs"),le=require("./el-menu-item-17dc717e.cjs");require("./el-tooltip-0ea8fbf8.cjs");require("./el-popper-b6c99b28.cjs");const e=require("vue"),_e=require("echarts"),d=require("./dayjs.min-2c20abe6.cjs"),A=require("./index-8901a38c.cjs"),J=require("./el-message-5e6a6be9.cjs"),K=require("./_plugin-vue_export-helper-f246444f.cjs");require("./el-tag-a33c4b22.cjs");const ie=require("./el-select-d8d91db1.cjs");require("./el-scrollbar-bc3f790d.cjs");require("./index-098c2447.cjs");require("./use-form-common-props-fd9b61a0.cjs");require("./index-9780a537.cjs");require("./index-bb833443.cjs");require("./index-f1c702f6.cjs");require("./vnode-b906ae6d.cjs");require("./scroll-b108dabd.cjs");require("./use-global-config-30d7d8ce.cjs");require("./index-c108567d.cjs");require("./typescript-b63f8e83.cjs");require("./index-11547a0c.cjs");require("./index-eea0bcb3.cjs");require("./config-provider-a584d81e.cjs");require("./index-298075cf.cjs");require("./index-f3562b52.cjs");require("./castArray-35947698.cjs");require("./debounce-62f5b6e8.cjs");function Ye(n){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const D in n)if(D!=="default"){const s=Object.getOwnPropertyDescriptor(n,D);Object.defineProperty(k,D,s.get?s:{enumerable:!0,get:()=>n[D]})}}return k.default=n,Object.freeze(k)}const ne=Ye(_e);let z=null;const ke=n=>{const k=A.y(n,{handleReq:D=>{A.v()&&(D.headers.token=A.U())},handleRes:D=>{const{data:s}=D;if(s.code===401)return location.origin.includes("localhost")?location.href=`${location.origin}/#/404`:A.K(),!0}});k.get,z=k.post},we=n=>z("/middleLayer/kline/getKlineBasic",{...n,userId:A.V("id")}),De=n=>z("/middleLayer/kline/getKline",n),Me=async n=>z("/alarm/deliversign/addAlarmPrice",{...n,userId:A.V("id")}),Se=async n=>z("/alarm/deliversign/findAlarmPriceByUserId",{...n,userId:A.V("id")}),ce=async n=>z("/alarm/deliversign/updateAlarmPrice",{...n,userId:A.V("id")}),Ve=async n=>z("/alarm/deliversign/deleteAlarmPrice",{...n,userId:A.V("id")}),{round:U}=A.x,Te=(n,k,D,s,f)=>{const{data:t,time:M}=n,{gridTop:u,gridRight:x,gridLeft:p,maxShowCounts:g,showSubChart:r}=k;return{animation:!1,grid:{top:`${u}px`,right:`${x}px`,bottom:r?"6px":"24px",left:`${p}px`},dataZoom:[{type:"inside",startValue:D,endValue:s,maxValueSpan:g}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:a=>{const{axisDimension:b,value:h}=a;return b==="x"?r?"":["6","7","8"].includes(f)?d.dayjs(h).format("YYYY-MM-DD"):h:String(U(h))}}},formatter:()=>""},xAxis:{show:!r,type:"category",data:M,splitLine:{show:!1},axisLabel:{formatter:a=>["6","7","8"].includes(f)?d.dayjs(a).format("YYYY-MM-DD"):a}},yAxis:{type:"value",axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}},min:a=>U(a.min),max:a=>U(a.max)},series:[{type:"candlestick",data:t,itemStyle:{color:"transparent",color0:"#00FFFF",borderColor:"#FF0000",borderColor0:"#00FFFF",borderWidth:1}},...n.mainIndicator.map(a=>({name:a.key,type:"line",silent:!0,symbol:"none",data:a.data,lineStyle:{width:a.width||1},itemStyle:{color:a.color}}))],toolbox:{show:!1},brush:{xAxisIndex:"all",brushLink:"all",transformable:!1,outOfBrush:{colorAlpha:2},brushStyle:{color:"rgba(255,255,255,0.1)",borderColor:"rgba(255,255,255,0.4)"}}}},Le=(n,k,D,s,f)=>{const{variety:t,featureId:M,featureType:u}=D,{gridTop:x,gridLeft:p,gridRight:g}=s;return k.reduce((r,a)=>{const{warnPrice:b}=a,h=n==null?void 0:n.convertToPixel({yAxisIndex:0},b);if(h<=x||h>=(n==null?void 0:n.getHeight()))return r;let E=0;return[...r,{type:"group",name:"warningLine",info:a,draggable:"vertical",children:[{type:"line",info:a,shape:{x1:p,y1:h,x2:(n==null?void 0:n.getWidth())-g,y2:h},style:{stroke:"#FFF",lineWidth:1,lineDash:[8,4]},z:10},{type:"text",info:a,x:(n==null?void 0:n.getWidth())-g,y:h-5,style:{fill:"#FFF",text:b,stroke:"#000",lineWidth:1,opacity:1},z:10}],ondragstart:V=>{E=V.offsetY},ondrag:V=>{var R;if(V.target&&V.target.childAt(1)){const T=n.convertFromPixel({yAxisIndex:0},h+(V.offsetY-E));(R=V.target.childAt(1))==null||R.animate("style",!1).when(1,{text:U(T,3)}).start()}},ondragend:async V=>{const T=V.offsetY-E;if(T!==0){const N=n==null?void 0:n.convertFromPixel({yAxisIndex:0},T+h),y={id:a.id,warnPrice:U(N,3),featureId:M,featureCode:t,featureType:u};await ce(y),J.ElMessage.success("画线预警修改成功"),f&&f()}}}]},[])},Be=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){const k=n,D=e.ref(null),s=e.ref([]);return e.watch(()=>k.data,()=>{s.value.length===0&&e.nextTick(()=>{Array.from(D.value.children).forEach((f,t)=>{var M,u,x,p,g,r,a,b;((u=(M=k.data)==null?void 0:M[t])==null?void 0:u.label)==="涨跌"?s.value[t]="85px":((p=(x=k.data)==null?void 0:x[t])==null?void 0:p.label)==="至今涨幅"?s.value[t]="115px":((r=(g=k.data)==null?void 0:g[t])==null?void 0:r.label)==="额"?s.value[t]="75px":["开","高","低","收"].includes((b=(a=k.data)==null?void 0:a[t])==null?void 0:b.label)?s.value[t]=`${f.offsetWidth+20}px`:s.value[t]=`${f.offsetWidth+36}px`})})}),(f,t)=>(e.openBlock(),e.createElementBlock("div",{class:"kline-tips",ref_key:"tipsRef",ref:D},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(M,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"kline-tips-item",style:e.normalizeStyle({color:M.color,width:s.value[u]?s.value[u]:null})},e.toDisplayString(M.label)+" "+e.toDisplayString(M.value),5))),128))],512))}});const se=K._export_sfc(Be,[["__scopeId","data-v-c6a71281"]]);const Ee={class:"kline-tips"},Ne={__name:"index",props:{data:{type:Object,require:!0},activeIndex:{type:[Number,String],require:!0},variety:{type:[String,Number],default:()=>null}},setup(n){const{round:k,formatValue:D}=A.x,s=n,f=e.ref(null);e.watch(()=>s.activeIndex,()=>{f.value===null&&(f.value=s.data.data[s.activeIndex][1])}),e.watch(()=>s.variety,()=>{f.value});const t=e.computed(()=>{const{data:u,activeIndex:x}=s;if(u.data&&u.data[x]){const p=u.data[x],g=[{label:"开",value:p[0]},{label:"高",value:p[3]},{label:"低",value:p[2]},{label:"收",value:p[1]}];p[4]!==null&&g.push({label:"额",value:D(p[4])});let r;p[6]>0?r="red":p[6]<0&&(r="green"),g.push({label:"涨跌",value:`${k(p[6])}%`,color:r});const a=(f.value/p[1]-1)*100;let b;return a>0?b="red":a<0&&(b="green"),g.push({label:"至今涨幅",value:`${k(a)}%`,color:b}),g}return[]}),M=e.computed(()=>{var p;const{data:u,activeIndex:x}=s;return((p=u==null?void 0:u.mainIndicator)==null?void 0:p.map(g=>({label:g.key,value:k(g.data[x]),color:g.color})))||[]});return(u,x)=>(e.openBlock(),e.createElementBlock("div",Ee,[e.createVNode(se,{data:t.value},null,8,["data"]),e.createVNode(se,{data:M.value},null,8,["data"])]))}},Fe=K._export_sfc(Ne,[["__scopeId","data-v-946e09fc"]]),qe={class:"kline-averageTips"},Ae=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){return(k,D)=>(e.openBlock(),e.createElementBlock("div",qe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(s,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:"kline-averageTips-item",style:e.normalizeStyle({color:s.color,width:`calc(100% / ${n.data.length} - 10px)`})},e.toDisplayString(s.label)+" "+e.toDisplayString(s.value),5))),128))]))}});const Re=K._export_sfc(Ae,[["__scopeId","data-v-c47865cb"]]);const je={class:"klineSub"},Oe={class:"klineSub-tips"},Ie={key:0,class:"klineSub-tips-select"},$e={__name:"index",props:{cycle:{type:[String,Number],default:()=>null},data:{type:Object,require:!0},activeIndex:{type:[Number,String],require:!0},modelValue:{type:String,required:!0},subIndicatorList:{type:Array,required:!0}},emits:["update:modelValue"],setup(n,{expose:k,emit:D}){const{round:s}=A.x;let f,t;const M=D,u=n,x=e.ref(),p=e.computed({get(){return u.modelValue},set(a){M("update:modelValue",a)}}),g=e.computed(()=>{var h;const{data:a,activeIndex:b}=u;return((h=a==null?void 0:a.subIndicator)==null?void 0:h.map(E=>({label:E.key,color:E.color,value:E.data[b]||"-"})))||[]});e.onMounted(()=>{f=ne.init(x.value);let a=!0;t=new ResizeObserver(()=>{if(a){a=null;return}f.resize()}),t.observe(x.value)}),e.onUnmounted(()=>{f.dispose(),t.disconnect(),t=null});const r=(a,b)=>{const h=a[b],E=b===0?a[b]:a[b-1];return h[0]===h[1]?h[0]>=E[1]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}:h[1]>h[0]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}};return k({connect:a=>{ne.connect([a,f])},draw:(a,b)=>{e.nextTick(()=>{const{startValue:h,endValue:E,maxValueSpan:V}=a,{leftYAxisRange:R,rightYAxisRange:T}=u.data.subIndicator[0],N=u.data.subIndicator.map(y=>{if(y.series==="bar")return{name:"subMain",xAxisIndex:0,yAxisIndex:1,type:"bar",silent:!0,symbol:"none",data:y.data.map((O,$)=>y.seriesColor==="kline"?{value:O,itemStyle:r(u.data.data,$)}:y.seriesColor==="value"?{value:O,itemStyle:{color:O>=0?"#FF0000":"#00FFFF"}}:{value:O,itemStyle:{color:y.seriesColor}})};if(y.series==="line")return{xAxisIndex:0,yAxisIndex:y.yAxis==="right"?2:1,name:y.key,type:"line",silent:!0,symbol:"none",data:y.data,lineStyle:{width:1},itemStyle:{color:y.color}}});f.setOption({animation:!1,grid:{left:`${b.gridLeft}px`,top:"10px",right:`${b.gridRight}px`,bottom:"20px"},dataZoom:[{type:"inside",startValue:h,endValue:E,maxValueSpan:V}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:y=>{const{axisDimension:O,value:$}=y;if(O==="x")return["6","7","8"].includes(u.cycle)?d.dayjs($).format("YYYY-MM-DD"):$;if(y.axisIndex===1)return String(s($))}}},formatter:()=>""},xAxis:{type:"category",data:u.data.time,axisLine:{show:!0},splitLine:{show:!1},axisLabel:{formatter:y=>["6","7","8"].includes(u.cycle)?d.dayjs(y).format("YYYY-MM-DD"):y}},yAxis:[{position:"right"},{position:"left",min:R==="cover"?y=>y.min:null,max:R==="cover"?y=>y.max:null,splitNumber:1,axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}}},{position:"right",min:T==="cover"?y=>y.min:null,max:T==="cover"?y=>y.max:null,splitNumber:1,axisLine:{show:!1},splitLine:{show:!1},axisLabel:{show:!1}}],series:N},!0)})}}),(a,b)=>{const h=ie.ElOption,E=ie.ElSelect;return e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Oe,[g.value.length?(e.openBlock(),e.createElementBlock("div",Ie,[e.createVNode(E,{modelValue:p.value,"onUpdate:modelValue":b[0]||(b[0]=V=>p.value=V),size:"small","popper-class":"element-dark",class:"element-dark subIndicator"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.subIndicatorList,V=>(e.openBlock(),e.createBlock(h,{key:V.value,label:V.label,value:V.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createVNode(Re,{data:g.value},null,8,["data"])]),e.createElementVNode("div",{class:"klineSub-chart",ref_key:"subChartRef",ref:x},null,512)])}}},Pe=K._export_sfc($e,[["__scopeId","data-v-7ec4c8cf"]]),Ce=e.defineComponent({__name:"index",emits:["closeContextMenuCallBack"],setup(n,{emit:k}){const D=k,s=e.ref(),f=e.ref(),t=e.ref({display:"none",top:"0px",left:"0px"}),M=()=>{t.value.display="none",D("closeContextMenuCallBack"),document.removeEventListener("click",M)},u=x=>{if(x.preventDefault(),t.value.display==="block"){const{offsetX:p,offsetY:g}=x,{offsetWidth:r,offsetHeight:a}=f.value;if(p<=r&&g<=a)return}s.value.click(),t.value={display:"block",top:`${x.offsetY}px`,left:`${x.offsetX}px`},e.nextTick(()=>{const p=s.value.getBoundingClientRect(),g=f.value.getBoundingClientRect();g.left+g.width>=p.right&&(t.value.left=`${x.offsetX-g.width}px`),g.top+g.height>=p.bottom&&(console.log("高度超出"),t.value.top=`${x.offsetY-g.height}px`)}),document.addEventListener("click",M)};return(x,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"contextmenuRef",ref:s,class:"contextmenu",onContextmenu:u,onMouseleave:M},[e.renderSlot(x.$slots,"default",{},void 0,!0),t.value.display!=="none"?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"contextmenuContentRef",ref:f,class:"contextmenu-popover",style:e.normalizeStyle(t.value)},[e.renderSlot(x.$slots,"popover",{},void 0,!0)],4)):e.createCommentVNode("",!0)],544))}});const We=K._export_sfc(Ce,[["__scopeId","data-v-811db6b4"]]);const ue=n=>(e.pushScopeId("data-v-e675b051"),n=n(),e.popScopeId(),n),ze={class:"klineBasic-tips"},Ke={key:0,class:"klineBasic-sub"},Ue={key:1,class:"klineBasic-empty"},He={key:2,class:"klineBasic-error"},Ze=ue(()=>e.createElementVNode("div",{class:"klineBasic-error-content"},"加载失败,请刷新重试",-1)),Xe={style:{"text-align":"center"}},Ge=ue(()=>e.createElementVNode("span",{style:{"margin-right":"10px"}},"预警价格:",-1)),Je={class:"dialog-footer"},Qe={__name:"index",props:{variety:{type:[String,Number],default:()=>null},varietyName:{type:[String,Number],default:()=>null},featureId:{type:[String,Number],default:()=>null},featureType:{type:[String,Number],default:()=>null},cycle:{type:[String,Number],default:()=>null},mainIndicator:{type:String,default:()=>""},indicatorStore:{type:Object,default:()=>null},startTime:{type:String,default:()=>null},endTime:{type:String,default:()=>null},right:{type:[String,Number],default:1},config:{type:Object,default:()=>({})},env:{type:Object,default:()=>({})},brushRange:{type:[Array,null],default:()=>null}},emits:["change","getFactorData"],setup(n,{expose:k,emit:D}){const s=[{label:"画线预警",key:"drawWarningLine"}];let f=null,t=null,M,u,x=!1,p=!1;const g=D,r=n,a=e.ref(!1),b=e.ref(!1),h=e.ref(!1),E=e.ref(null),V=e.ref(null),R=e.ref("VOL"),T=e.ref(0),N=e.ref({}),y=e.ref([]),O=e.ref({}),$=e.ref(!1),H=e.ref(""),Q=e.ref([...s]),C=e.computed(()=>({defaultShowCounts:500,addCounts:2e3,maxShowCounts:5e3,loadCheckCounts:500,showSubChart:!0,gridTop:48,gridLeft:80,gridRight:50,showWarningLine:!0,getFactorData:!0,...r.config}));e.watch(()=>{var i,o;return[r.variety,r.cycle,r.mainIndicator,R.value,(i=r.indicatorStore)==null?void 0:i.filterIndicator,(o=r.indicatorStore)==null?void 0:o.customIndicator]},()=>{ee()},{deep:!0}),e.onMounted(()=>{ke(r.env),ee(),window.addEventListener("keydown",oe)}),e.onUnmounted(()=>{t==null||t.off("datazoom"),t==null||t.off("highlight"),t==null||t.off("globalout"),t==null||t.dispose(),f==null||f.dispose(),window.removeEventListener("keydown",oe)});const de=()=>{t||(t=ne.init(E.value),fe(),C.value.showSubChart&&V.value.connect(t),f=A.D(E.value),f.listen(()=>{requestAnimationFrame(()=>{t.resize()})}))},oe=({code:i,ctrlKey:o})=>{if(!(o||a.value))return;const{xAxis:_,dataZoom:m}=t.getOption(),{data:v}=(_==null?void 0:_[0])??{data:[]};let{startValue:l,endValue:c}=(m==null?void 0:m[0])??{};if(v!=null&&v.length){switch(i){case"ArrowUp":{if(c-l<5)return;const S=Math.floor((c-l)/2)+1;l=l+S,c-l<5&&(l=c-4);break}case"ArrowDown":{const S=Math.min(500,c-l);l=l-S-1;break}case"ArrowLeft":{l>0&&(l-=1,c-=1),T.value>0&&(T.value-=1);break}case"ArrowRight":{c<v.length-1&&(l+=1,c+=1),a.value&&T.value<v.length-1&&(T.value+=1);break}}t.dispatchAction({type:"dataZoom",startValue:l,endValue:c}),t.dispatchAction({type:"updateAxisPointer",seriesIndex:0,dataIndex:a.value?T.value:null}),t.dispatchAction({type:"highlight",dataIndex:a.value?T.value:c})}},fe=()=>{t==null||t.on("datazoom",o=>{clearTimeout(u),u=setTimeout(()=>{var m,v,l,c;const{loadCheckCounts:_}=C.value;if((v=(m=t==null?void 0:t.getOption())==null?void 0:m.dataZoom)!=null&&v[0]){const{startValue:S}=(c=(l=t==null?void 0:t.getOption())==null?void 0:l.dataZoom)==null?void 0:c[0];S<_&&x===!1&&p===!1&&(x=!0,pe("history")),Z()}clearTimeout(u)},100)}),t==null||t.on("highlight",o=>{var m,v;let _=o.dataIndex||-1;o.batch&&(_=typeof((m=o==null?void 0:o.batch[0])==null?void 0:m.dataIndex)=="number"?(v=o==null?void 0:o.batch[0])==null?void 0:v.dataIndex:-1),clearTimeout(M),M=setTimeout(()=>{T.value=_,clearTimeout(M)},20)}),t==null||t.on("globalout",()=>{const o=setTimeout(()=>{var m,v,l;clearTimeout(o);const _=(l=(v=(m=t==null?void 0:t.getOption())==null?void 0:m.dataZoom)==null?void 0:v[0])==null?void 0:l.endValue;T.value=_},30)});let i=null;t==null||t.on("contextmenu",o=>{i=setTimeout(()=>{o.componentType==="graphic"&&(O.value=o.info,Q.value=[{label:"删除画线",key:"deleteWarningLine"},{label:"修改画线",key:"changeWarningLine"}]),clearTimeout(i),i=null})})},ee=async()=>{var i,o,_,m,v,l;try{if(!r.variety||!r.cycle)return;const{variety:c,featureId:S,cycle:L,indicatorStore:w,mainIndicator:I,right:P,startTime:W,endTime:B}=r,{defaultShowCounts:F,addCounts:Y,showWarningLine:te,getFactorData:G}=C.value,q={variety:c,featureId:S,cycle:L,mainIndicatorList:w.getIndicatorParams(I),subIndicator:R.value,right:P,showWarningLine:te,getFactorData:G};W&&B?(q.startTime=W,q.endTime=B):W?(q.startTime=W,q.limit=F+Y):B?(q.endTime=B,q.limit=F+Y):(q.endTime=d.dayjs().add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),q.limit=F+Y);const j=await we(q);if((_=(o=(i=j==null?void 0:j.body)==null?void 0:i.kline)==null?void 0:o.time)!=null&&_.length)b.value=!1,h.value=!1;else{b.value=!0,h.value=!1;return}N.value=(m=j==null?void 0:j.body)==null?void 0:m.kline,y.value=((v=j==null?void 0:j.body)==null?void 0:v.warningLine)||[],ae(),Z(),G&&g("getFactorData",(l=j==null?void 0:j.body)==null?void 0:l.factor)}catch(c){throw h.value=!0,b.value=!1,new Error(c)}},pe=async i=>{const{variety:o,cycle:_,indicatorStore:m,mainIndicator:v,right:l}=r,{addCounts:c}=C.value,{time:S}=N.value;if(i==="history"){const L=await De({variety:o,cycle:_,endTime:S[0],limit:c,mainIndicatorList:m.getIndicatorParams(v),subIndicator:R.value,right:l});N.value={time:[...L.body.time,...N.value.time.slice(1)],data:[...L.body.data,...N.value.data.slice(1)],mainIndicator:N.value.mainIndicator.map((w,I)=>{var P;return{...w,data:[...((P=L.body.mainIndicator[I])==null?void 0:P.data)??[],...w.data.slice(1)]}}),subIndicator:N.value.subIndicator.map((w,I)=>{var P;return{...w,data:[...((P=L.body.subIndicator[I])==null?void 0:P.data)??[],...w.data.slice(1)]}})},ae(!0),L.body.data.length<c&&(p=!0),x=!1}},ae=(i=!1)=>{var I,P,W;de();const{time:o}=N.value,{gridRight:_,gridLeft:m,defaultShowCounts:v,maxShowCounts:l,showSubChart:c}=C.value;let S=o.length-1-v,L=o.length-1;if(i){const B=t.getOption(),F=(P=(I=B==null?void 0:B.xAxis)==null?void 0:I[0])==null?void 0:P.data,Y=(W=B==null?void 0:B.dataZoom)==null?void 0:W[0],te=F[Y==null?void 0:Y.startValue],G=F[Y==null?void 0:Y.endValue];S=o.findIndex(q=>q===te),L=o.findIndex(q=>q===G)}const w=Te(N.value,C.value,S,L,r.cycle);if(t.setOption(w,!0),T.value=L,r.brushRange){let B=null,F=null;switch(r.cycle){case"6":{B=o.find(Y=>new Date(Y).getTime()>=new Date(r.brushRange[0]).getTime()||d.dayjs(Y).format("YYYY-MM-DD")===d.dayjs(r.brushRange[0]).format("YYYY-MM-DD")),F=o.findLast(Y=>new Date(Y).getTime()<=new Date(r.brushRange[1]).getTime()||d.dayjs(Y).format("YYYY-MM-DD")===d.dayjs(r.brushRange[1]).format("YYYY-MM-DD"));break}case"7":{B=o.find(Y=>d.dayjs(Y).day(5).format("YYYY-MM-DD")===d.dayjs(r.brushRange[0]).day(5).format("YYYY-MM-DD")),F=o.findLast(Y=>d.dayjs(Y).day(5).format("YYYY-MM-DD")===d.dayjs(r.brushRange[1]).day(5).format("YYYY-MM-DD"));break}case"8":{B=o.find(Y=>d.dayjs(Y).endOf("month").format("YYYY-MM-DD")===d.dayjs(r.brushRange[0]).endOf("month").format("YYYY-MM-DD")),F=o.findLast(Y=>d.dayjs(Y).endOf("month").format("YYYY-MM-DD")===d.dayjs(r.brushRange[1]).endOf("month").format("YYYY-MM-DD"));break}default:B=o.find(Y=>new Date(Y).getTime()>=new Date(r.brushRange[0]).getTime()),F=o.findLast(Y=>new Date(Y).getTime()<=new Date(r.brushRange[1]).getTime())}console.log(B,F),t.dispatchAction({type:"brush",areas:[{brushType:"lineX",coordRange:[B,F],xAxisIndex:0}]})}c&&V.value.draw({startValue:S,endValue:L,maxValueSpan:l},{gridLeft:m,gridRight:_}),re()},Z=()=>{if(!t)return;const i=t==null?void 0:t.getOption();i&&(t==null||t.setOption({...i,graphic:[...Le(t,y.value,r,C.value,()=>{X()})]},!0),re())},re=()=>{const{time:i}=N.value;if(r.brushRange&&(i!=null&&i.length)){let o=d.dayjs(r.brushRange[0]).format("YYYY-MM-DD 00:00:00"),_=d.dayjs(r.brushRange[1]).format("YYYY-MM-DD 23:59:59"),m=null,v=null;switch(r.cycle){case"6":{m=i.find(l=>d.dayjs(l).format("YYYY-MM-DD")===d.dayjs(o).format("YYYY-MM-DD")),v=m;break}case"7":{m=i.find(l=>d.dayjs(l).day(5).format("YYYY-MM-DD")===d.dayjs(o).day(5).format("YYYY-MM-DD")),v=i.findLast(l=>d.dayjs(l).day(5).format("YYYY-MM-DD")===d.dayjs(_).day(5).format("YYYY-MM-DD"));break}case"8":{m=i.find(l=>d.dayjs(l).endOf("month").format("YYYY-MM-DD")===d.dayjs(o).endOf("month").format("YYYY-MM-DD")),v=i.findLast(l=>d.dayjs(l).endOf("month").format("YYYY-MM-DD")===d.dayjs(_).endOf("month").format("YYYY-MM-DD"));break}default:m=i.find(l=>{const c=d.dayjs(l).format("YYYY-MM-DD")===d.dayjs(o).format("YYYY-MM-DD"),S=new Date(l).getTime()>=new Date(o).getTime();return c&&S}),v=i.findLast(l=>{const c=d.dayjs(l).format("YYYY-MM-DD")===d.dayjs(_).format("YYYY-MM-DD"),S=new Date(l).getTime()<=new Date(_).getTime();return c&&S})}t.dispatchAction({type:"brush",areas:[{brushType:"lineX",coordRange:[m,v],xAxisIndex:0}]})}},X=async()=>{const i=await Se({featureId:r.featureId});y.value=(i==null?void 0:i.body)||[],Z(),g("change","warningLine",y.value)},ye=async i=>{const{variety:o,varietyName:_,featureId:m,featureType:v}=r;if(i.key==="drawWarningLine"){const l=t==null?void 0:t.getOption(),c=l.tooltip[0];t==null||t.setOption({...l,tooltip:{...c,axisPointer:{...c.axisPointer,lineStyle:{width:0},crossStyle:{width:2},label:{...c.axisPointer.label,backgroundColor:"transparent",formatter:L=>""}}}});const S=async L=>{t==null||t.getZr().off("mousedown",S);const w=t==null?void 0:t.convertFromPixel({yAxisIndex:0},L.offsetY),I=Math.round(w*1e3)/1e3;t==null||t.setOption({...l,tooltip:{...c,axisPointer:{...c.axisPointer,lineStyle:{width:1},crossStyle:{width:1},label:{...c.axisPointer.label,backgroundColor:null}}}}),await Me({featureCode:o,featureName:_,featureId:m,featureType:v,warnPrice:I}),J.ElMessage.success("画线预警成功!"),X()};t==null||t.getZr().on("mousedown",S)}else i.key==="deleteWarningLine"?(await Ve({id:O.value.id}),J.ElMessage.success("画线预警删除成功"),X()):i.key==="changeWarningLine"&&($.value=!0,H.value=O.value.warnPrice)},me=async()=>{const{variety:i,varietyName:o,featureId:_,featureType:m}=r;await ce({id:O.value.id,featureCode:i,featureName:o,featureId:_,featureType:m,warnPrice:H.value}),J.ElMessage.success("画线预警修改成功"),X()},ge=()=>{Q.value=[...s]};return k({draw:(i,o)=>{i==="warningLine"&&(y.value=o,Z())}}),(i,o)=>{var L;const _=le.ElMenuItem,m=le.ElMenu,v=he.ElEmpty,l=be.ElButton,c=xe.ElInputNumber,S=ve.ElDialog;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"klineBasic",onMousemove:o[1]||(o[1]=w=>a.value=!0),onMouseout:o[2]||(o[2]=w=>a.value=!1)},[e.createElementVNode("div",ze,[e.createVNode(Fe,{variety:n.variety,data:N.value,activeIndex:T.value},null,8,["variety","data","activeIndex"])]),e.createElementVNode("div",{class:"klineBasic-main",style:e.normalizeStyle({height:C.value.showSubChart?"70%":"100%"})},[e.createVNode(We,{onCloseContextMenuCallBack:ge},{popover:e.withCtx(()=>[e.createVNode(m,{style:{borderRadius:"4px",overflow:"hidden",background:"#fff",borderRight:0}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Q.value,w=>(e.openBlock(),e.createBlock(_,{style:{height:"36px"},key:w.key,index:w.key,onClick:I=>ye(w)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.label),1)]),_:2},1032,["index","onClick"]))),128))]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"klineBasicMainRef",ref:E,style:{height:"100%"}},null,512)]),_:1})],4),C.value.showSubChart?(e.openBlock(),e.createElementBlock("div",Ke,[e.createVNode(Pe,{ref_key:"klineSubRef",ref:V,modelValue:R.value,"onUpdate:modelValue":o[0]||(o[0]=w=>R.value=w),data:N.value,cycle:n.cycle,activeIndex:T.value,subIndicatorList:(L=n.indicatorStore)==null?void 0:L.subIndicatorList},null,8,["modelValue","data","cycle","activeIndex","subIndicatorList"])])):e.createCommentVNode("",!0),b.value?(e.openBlock(),e.createElementBlock("div",Ue,[e.createVNode(v,{class:"klineBasic-empty-content",description:"暂无数据"})])):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("div",He,[Ze,e.createElementVNode("div",Xe,[e.createVNode(l,{onClick:ee},{default:e.withCtx(()=>[e.createTextVNode("刷新")]),_:1})])])):e.createCommentVNode("",!0)],32),e.createVNode(S,{modelValue:$.value,"onUpdate:modelValue":o[5]||(o[5]=w=>$.value=w),title:"画线预警-修改价格",width:"30%","align-center":""},{footer:e.withCtx(()=>[e.createElementVNode("span",Je,[e.createVNode(l,{onClick:o[4]||(o[4]=w=>$.value=!1)},{default:e.withCtx(()=>[e.createTextVNode("取消")]),_:1}),e.createVNode(l,{type:"primary",onClick:me},{default:e.withCtx(()=>[e.createTextVNode("确定")]),_:1})])]),default:e.withCtx(()=>[Ge,e.createVNode(c,{modelValue:H.value,"onUpdate:modelValue":o[3]||(o[3]=w=>H.value=w),placeholder:"输入预警价格"},null,8,["modelValue"])]),_:1},8,["modelValue"])],64)}}},et=K._export_sfc(Qe,[["__scopeId","data-v-e675b051"]]),tt={install(n){n.component("st-klineBasic",et)}};module.exports=tt;
1
+ "use strict";require("./base-ef747d02.cjs");const ve=require("./el-dialog-ae86edb8.cjs");require("./el-overlay-9e34965f.cjs");require("./el-input-7fd293af.cjs");const xe=require("./el-input-number-22e21d16.cjs"),be=require("./el-button-eec58cff.cjs"),he=require("./el-empty-1697ded8.cjs"),le=require("./el-menu-item-17dc717e.cjs");require("./el-tooltip-0ea8fbf8.cjs");require("./el-popper-b6c99b28.cjs");const e=require("vue"),_e=require("echarts"),f=require("./dayjs.min-2c20abe6.cjs"),A=require("./index-8901a38c.cjs"),J=require("./el-message-5e6a6be9.cjs"),K=require("./_plugin-vue_export-helper-f246444f.cjs");require("./el-tag-a33c4b22.cjs");const ie=require("./el-select-d8d91db1.cjs");require("./el-scrollbar-bc3f790d.cjs");require("./index-098c2447.cjs");require("./use-form-common-props-fd9b61a0.cjs");require("./index-9780a537.cjs");require("./index-bb833443.cjs");require("./index-f1c702f6.cjs");require("./vnode-b906ae6d.cjs");require("./scroll-b108dabd.cjs");require("./use-global-config-30d7d8ce.cjs");require("./index-c108567d.cjs");require("./typescript-b63f8e83.cjs");require("./index-11547a0c.cjs");require("./index-eea0bcb3.cjs");require("./config-provider-a584d81e.cjs");require("./index-298075cf.cjs");require("./index-f3562b52.cjs");require("./castArray-35947698.cjs");require("./debounce-62f5b6e8.cjs");function Ye(n){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const D in n)if(D!=="default"){const s=Object.getOwnPropertyDescriptor(n,D);Object.defineProperty(k,D,s.get?s:{enumerable:!0,get:()=>n[D]})}}return k.default=n,Object.freeze(k)}const ne=Ye(_e);let z=null;const ke=n=>{const k=A.y(n,{handleReq:D=>{A.v()&&(D.headers.token=A.U())},handleRes:D=>{const{data:s}=D;if(s.code===401)return location.origin.includes("localhost")?location.href=`${location.origin}/#/404`:A.K(),!0}});k.get,z=k.post},we=n=>z("/middleLayer/kline/getKlineBasic",{...n,userId:A.V("id")}),De=n=>z("/middleLayer/kline/getKline",n),Me=async n=>z("/alarm/deliversign/addAlarmPrice",{...n,userId:A.V("id")}),Se=async n=>z("/alarm/deliversign/findAlarmPriceByUserId",{...n,userId:A.V("id")}),ce=async n=>z("/alarm/deliversign/updateAlarmPrice",{...n,userId:A.V("id")}),Ve=async n=>z("/alarm/deliversign/deleteAlarmPrice",{...n,userId:A.V("id")}),{round:U}=A.x,Te=(n,k,D,s,u)=>{const{data:t,time:M}=n,{gridTop:d,gridRight:x,gridLeft:p,maxShowCounts:g,showSubChart:r}=k;return{animation:!1,grid:{top:`${d}px`,right:`${x}px`,bottom:r?"6px":"24px",left:`${p}px`},dataZoom:[{type:"inside",startValue:D,endValue:s,maxValueSpan:g}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:o=>{const{axisDimension:b,value:h}=o;return b==="x"?r?"":["6","7","8"].includes(u)?f.dayjs(h).format("YYYY-MM-DD"):h:String(U(h))}}},formatter:()=>""},xAxis:{show:!r,type:"category",data:M,splitLine:{show:!1},axisLabel:{formatter:o=>["6","7","8"].includes(u)?f.dayjs(o).format("YYYY-MM-DD"):o}},yAxis:{type:"value",axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}},min:o=>U(o.min),max:o=>U(o.max)},series:[{type:"candlestick",data:t,itemStyle:{color:"transparent",color0:"#00FFFF",borderColor:"#FF0000",borderColor0:"#00FFFF",borderWidth:1}},...n.mainIndicator.map(o=>({name:o.key,type:"line",silent:!0,symbol:"none",data:o.data,lineStyle:{width:o.width||1},itemStyle:{color:o.color}}))],toolbox:{show:!1},brush:{xAxisIndex:"all",brushLink:"all",transformable:!1,outOfBrush:{colorAlpha:2},brushStyle:{color:"rgba(255,255,255,0.1)",borderColor:"rgba(255,255,255,0.4)"}}}},Le=(n,k,D,s,u)=>{const{variety:t,featureId:M,featureType:d}=D,{gridTop:x,gridLeft:p,gridRight:g}=s;return k.reduce((r,o)=>{const{warnPrice:b}=o,h=n==null?void 0:n.convertToPixel({yAxisIndex:0},b);if(h<=x||h>=(n==null?void 0:n.getHeight()))return r;let E=0;return[...r,{type:"group",name:"warningLine",info:o,draggable:"vertical",children:[{type:"line",info:o,shape:{x1:p,y1:h,x2:(n==null?void 0:n.getWidth())-g,y2:h},style:{stroke:"#FFF",lineWidth:1,lineDash:[8,4]},z:10},{type:"text",info:o,x:(n==null?void 0:n.getWidth())-g,y:h-5,style:{fill:"#FFF",text:b,stroke:"#000",lineWidth:1,opacity:1},z:10}],ondragstart:V=>{E=V.offsetY},ondrag:V=>{var R;if(V.target&&V.target.childAt(1)){const T=n.convertFromPixel({yAxisIndex:0},h+(V.offsetY-E));(R=V.target.childAt(1))==null||R.animate("style",!1).when(1,{text:U(T,3)}).start()}},ondragend:async V=>{const T=V.offsetY-E;if(T!==0){const N=n==null?void 0:n.convertFromPixel({yAxisIndex:0},T+h),y={id:o.id,warnPrice:U(N,3),featureId:M,featureCode:t,featureType:d};await ce(y),J.ElMessage.success("画线预警修改成功"),u&&u()}}}]},[])},Be=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){const k=n,D=e.ref(null),s=e.ref([]);return e.watch(()=>k.data,()=>{s.value.length===0&&e.nextTick(()=>{Array.from(D.value.children).forEach((u,t)=>{var M,d,x,p,g,r,o,b;((d=(M=k.data)==null?void 0:M[t])==null?void 0:d.label)==="涨跌"?s.value[t]="85px":((p=(x=k.data)==null?void 0:x[t])==null?void 0:p.label)==="至今涨幅"?s.value[t]="115px":((r=(g=k.data)==null?void 0:g[t])==null?void 0:r.label)==="额"?s.value[t]="85px":["开","高","低","收"].includes((b=(o=k.data)==null?void 0:o[t])==null?void 0:b.label)?s.value[t]=`${u.offsetWidth+20}px`:s.value[t]=`${u.offsetWidth+36}px`})})}),(u,t)=>(e.openBlock(),e.createElementBlock("div",{class:"kline-tips",ref_key:"tipsRef",ref:D},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(M,d)=>(e.openBlock(),e.createElementBlock("div",{key:d,class:"kline-tips-item",style:e.normalizeStyle({color:M.color,width:s.value[d]?s.value[d]:null})},e.toDisplayString(M.label)+" "+e.toDisplayString(M.value),5))),128))],512))}});const se=K._export_sfc(Be,[["__scopeId","data-v-1ccf76bf"]]);const Ee={class:"kline-tips"},Ne={__name:"index",props:{data:{type:Object,require:!0},activeIndex:{type:[Number,String],require:!0},variety:{type:[String,Number],default:()=>null}},setup(n){const{round:k,formatValue:D}=A.x,s=n,u=e.ref(null);e.watch(()=>s.activeIndex,()=>{u.value===null&&(u.value=s.data.data[s.activeIndex][1])}),e.watch(()=>s.data,()=>{u.value===null&&(u.value=s.data.data[s.activeIndex][1])}),e.watch(()=>s.variety,()=>{u.value=null});const t=e.computed(()=>{const{data:d,activeIndex:x}=s;if(d.data&&d.data[x]){const p=d.data[x],g=[{label:"开",value:p[0]},{label:"高",value:p[3]},{label:"低",value:p[2]},{label:"收",value:p[1]}];p[4]!==null&&g.push({label:"额",value:D(p[4])});let r;p[6]>0?r="red":p[6]<0&&(r="green"),g.push({label:"涨跌",value:`${k(p[6])}%`,color:r});const o=(u.value/p[1]-1)*100;let b;return o>0?b="red":o<0&&(b="green"),g.push({label:"至今涨幅",value:`${k(o)}%`,color:b}),g}return[]}),M=e.computed(()=>{var p;const{data:d,activeIndex:x}=s;return((p=d==null?void 0:d.mainIndicator)==null?void 0:p.map(g=>({label:g.key,value:k(g.data[x]),color:g.color})))||[]});return(d,x)=>(e.openBlock(),e.createElementBlock("div",Ee,[e.createVNode(se,{data:t.value},null,8,["data"]),e.createVNode(se,{data:M.value},null,8,["data"])]))}},Fe=K._export_sfc(Ne,[["__scopeId","data-v-d24c4fcf"]]),qe={class:"kline-averageTips"},Ae=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){return(k,D)=>(e.openBlock(),e.createElementBlock("div",qe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(s,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"kline-averageTips-item",style:e.normalizeStyle({color:s.color,width:`calc(100% / ${n.data.length} - 10px)`})},e.toDisplayString(s.label)+" "+e.toDisplayString(s.value),5))),128))]))}});const Re=K._export_sfc(Ae,[["__scopeId","data-v-c47865cb"]]);const je={class:"klineSub"},Ie={class:"klineSub-tips"},Oe={key:0,class:"klineSub-tips-select"},$e={__name:"index",props:{cycle:{type:[String,Number],default:()=>null},data:{type:Object,require:!0},activeIndex:{type:[Number,String],require:!0},modelValue:{type:String,required:!0},subIndicatorList:{type:Array,required:!0}},emits:["update:modelValue"],setup(n,{expose:k,emit:D}){const{round:s}=A.x;let u,t;const M=D,d=n,x=e.ref(),p=e.computed({get(){return d.modelValue},set(o){M("update:modelValue",o)}}),g=e.computed(()=>{var h;const{data:o,activeIndex:b}=d;return((h=o==null?void 0:o.subIndicator)==null?void 0:h.map(E=>({label:E.key,color:E.color,value:E.data[b]||"-"})))||[]});e.onMounted(()=>{u=ne.init(x.value);let o=!0;t=new ResizeObserver(()=>{if(o){o=null;return}u.resize()}),t.observe(x.value)}),e.onUnmounted(()=>{u.dispose(),t.disconnect(),t=null});const r=(o,b)=>{const h=o[b],E=b===0?o[b]:o[b-1];return h[0]===h[1]?h[0]>=E[1]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}:h[1]>h[0]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}};return k({connect:o=>{ne.connect([o,u])},draw:(o,b)=>{e.nextTick(()=>{const{startValue:h,endValue:E,maxValueSpan:V}=o,{leftYAxisRange:R,rightYAxisRange:T}=d.data.subIndicator[0],N=d.data.subIndicator.map(y=>{if(y.series==="bar")return{name:"subMain",xAxisIndex:0,yAxisIndex:1,type:"bar",silent:!0,symbol:"none",data:y.data.map((I,$)=>y.seriesColor==="kline"?{value:I,itemStyle:r(d.data.data,$)}:y.seriesColor==="value"?{value:I,itemStyle:{color:I>=0?"#FF0000":"#00FFFF"}}:{value:I,itemStyle:{color:y.seriesColor}})};if(y.series==="line")return{xAxisIndex:0,yAxisIndex:y.yAxis==="right"?2:1,name:y.key,type:"line",silent:!0,symbol:"none",data:y.data,lineStyle:{width:1},itemStyle:{color:y.color}}});u.setOption({animation:!1,grid:{left:`${b.gridLeft}px`,top:"10px",right:`${b.gridRight}px`,bottom:"20px"},dataZoom:[{type:"inside",startValue:h,endValue:E,maxValueSpan:V}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:y=>{const{axisDimension:I,value:$}=y;if(I==="x")return["6","7","8"].includes(d.cycle)?f.dayjs($).format("YYYY-MM-DD"):$;if(y.axisIndex===1)return String(s($))}}},formatter:()=>""},xAxis:{type:"category",data:d.data.time,axisLine:{show:!0},splitLine:{show:!1},axisLabel:{formatter:y=>["6","7","8"].includes(d.cycle)?f.dayjs(y).format("YYYY-MM-DD"):y}},yAxis:[{position:"right"},{position:"left",min:R==="cover"?y=>y.min:null,max:R==="cover"?y=>y.max:null,splitNumber:1,axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}}},{position:"right",min:T==="cover"?y=>y.min:null,max:T==="cover"?y=>y.max:null,splitNumber:1,axisLine:{show:!1},splitLine:{show:!1},axisLabel:{show:!1}}],series:N},!0)})}}),(o,b)=>{const h=ie.ElOption,E=ie.ElSelect;return e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Ie,[g.value.length?(e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(E,{modelValue:p.value,"onUpdate:modelValue":b[0]||(b[0]=V=>p.value=V),size:"small","popper-class":"element-dark",class:"element-dark subIndicator"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.subIndicatorList,V=>(e.openBlock(),e.createBlock(h,{key:V.value,label:V.label,value:V.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createVNode(Re,{data:g.value},null,8,["data"])]),e.createElementVNode("div",{class:"klineSub-chart",ref_key:"subChartRef",ref:x},null,512)])}}},Pe=K._export_sfc($e,[["__scopeId","data-v-7ec4c8cf"]]),Ce=e.defineComponent({__name:"index",emits:["closeContextMenuCallBack"],setup(n,{emit:k}){const D=k,s=e.ref(),u=e.ref(),t=e.ref({display:"none",top:"0px",left:"0px"}),M=()=>{t.value.display="none",D("closeContextMenuCallBack"),document.removeEventListener("click",M)},d=x=>{if(x.preventDefault(),t.value.display==="block"){const{offsetX:p,offsetY:g}=x,{offsetWidth:r,offsetHeight:o}=u.value;if(p<=r&&g<=o)return}s.value.click(),t.value={display:"block",top:`${x.offsetY}px`,left:`${x.offsetX}px`},e.nextTick(()=>{const p=s.value.getBoundingClientRect(),g=u.value.getBoundingClientRect();g.left+g.width>=p.right&&(t.value.left=`${x.offsetX-g.width}px`),g.top+g.height>=p.bottom&&(console.log("高度超出"),t.value.top=`${x.offsetY-g.height}px`)}),document.addEventListener("click",M)};return(x,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"contextmenuRef",ref:s,class:"contextmenu",onContextmenu:d,onMouseleave:M},[e.renderSlot(x.$slots,"default",{},void 0,!0),t.value.display!=="none"?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"contextmenuContentRef",ref:u,class:"contextmenu-popover",style:e.normalizeStyle(t.value)},[e.renderSlot(x.$slots,"popover",{},void 0,!0)],4)):e.createCommentVNode("",!0)],544))}});const We=K._export_sfc(Ce,[["__scopeId","data-v-811db6b4"]]);const ue=n=>(e.pushScopeId("data-v-e675b051"),n=n(),e.popScopeId(),n),ze={class:"klineBasic-tips"},Ke={key:0,class:"klineBasic-sub"},Ue={key:1,class:"klineBasic-empty"},He={key:2,class:"klineBasic-error"},Ze=ue(()=>e.createElementVNode("div",{class:"klineBasic-error-content"},"加载失败,请刷新重试",-1)),Xe={style:{"text-align":"center"}},Ge=ue(()=>e.createElementVNode("span",{style:{"margin-right":"10px"}},"预警价格:",-1)),Je={class:"dialog-footer"},Qe={__name:"index",props:{variety:{type:[String,Number],default:()=>null},varietyName:{type:[String,Number],default:()=>null},featureId:{type:[String,Number],default:()=>null},featureType:{type:[String,Number],default:()=>null},cycle:{type:[String,Number],default:()=>null},mainIndicator:{type:String,default:()=>""},indicatorStore:{type:Object,default:()=>null},startTime:{type:String,default:()=>null},endTime:{type:String,default:()=>null},right:{type:[String,Number],default:1},config:{type:Object,default:()=>({})},env:{type:Object,default:()=>({})},brushRange:{type:[Array,null],default:()=>null}},emits:["change","getFactorData"],setup(n,{expose:k,emit:D}){const s=[{label:"画线预警",key:"drawWarningLine"}];let u=null,t=null,M,d,x=!1,p=!1;const g=D,r=n,o=e.ref(!1),b=e.ref(!1),h=e.ref(!1),E=e.ref(null),V=e.ref(null),R=e.ref("VOL"),T=e.ref(0),N=e.ref({}),y=e.ref([]),I=e.ref({}),$=e.ref(!1),H=e.ref(""),Q=e.ref([...s]),C=e.computed(()=>({defaultShowCounts:500,addCounts:2e3,maxShowCounts:5e3,loadCheckCounts:500,showSubChart:!0,gridTop:48,gridLeft:80,gridRight:50,showWarningLine:!0,getFactorData:!0,...r.config}));e.watch(()=>{var i,a;return[r.variety,r.cycle,r.mainIndicator,R.value,(i=r.indicatorStore)==null?void 0:i.filterIndicator,(a=r.indicatorStore)==null?void 0:a.customIndicator]},()=>{ee()},{deep:!0}),e.onMounted(()=>{ke(r.env),ee(),window.addEventListener("keydown",ae)}),e.onUnmounted(()=>{t==null||t.off("datazoom"),t==null||t.off("highlight"),t==null||t.off("globalout"),t==null||t.dispose(),u==null||u.dispose(),window.removeEventListener("keydown",ae)});const de=()=>{t||(t=ne.init(E.value),fe(),C.value.showSubChart&&V.value.connect(t),u=A.D(E.value),u.listen(()=>{requestAnimationFrame(()=>{t.resize()})}))},ae=({code:i,ctrlKey:a})=>{if(!(a||o.value))return;const{xAxis:_,dataZoom:m}=t.getOption(),{data:v}=(_==null?void 0:_[0])??{data:[]};let{startValue:l,endValue:c}=(m==null?void 0:m[0])??{};if(v!=null&&v.length){switch(i){case"ArrowUp":{if(c-l<5)return;const S=Math.floor((c-l)/2)+1;l=l+S,c-l<5&&(l=c-4);break}case"ArrowDown":{const S=Math.min(500,c-l);l=l-S-1;break}case"ArrowLeft":{l>0&&(l-=1,c-=1),T.value>0&&(T.value-=1);break}case"ArrowRight":{c<v.length-1&&(l+=1,c+=1),o.value&&T.value<v.length-1&&(T.value+=1);break}}t.dispatchAction({type:"dataZoom",startValue:l,endValue:c}),t.dispatchAction({type:"updateAxisPointer",seriesIndex:0,dataIndex:o.value?T.value:null}),t.dispatchAction({type:"highlight",dataIndex:o.value?T.value:c})}},fe=()=>{t==null||t.on("datazoom",a=>{clearTimeout(d),d=setTimeout(()=>{var m,v,l,c;const{loadCheckCounts:_}=C.value;if((v=(m=t==null?void 0:t.getOption())==null?void 0:m.dataZoom)!=null&&v[0]){const{startValue:S}=(c=(l=t==null?void 0:t.getOption())==null?void 0:l.dataZoom)==null?void 0:c[0];S<_&&x===!1&&p===!1&&(x=!0,pe("history")),Z()}clearTimeout(d)},100)}),t==null||t.on("highlight",a=>{var m,v;let _=a.dataIndex||-1;a.batch&&(_=typeof((m=a==null?void 0:a.batch[0])==null?void 0:m.dataIndex)=="number"?(v=a==null?void 0:a.batch[0])==null?void 0:v.dataIndex:-1),clearTimeout(M),M=setTimeout(()=>{T.value=_,clearTimeout(M)},20)}),t==null||t.on("globalout",()=>{const a=setTimeout(()=>{var m,v,l;clearTimeout(a);const _=(l=(v=(m=t==null?void 0:t.getOption())==null?void 0:m.dataZoom)==null?void 0:v[0])==null?void 0:l.endValue;T.value=_},30)});let i=null;t==null||t.on("contextmenu",a=>{i=setTimeout(()=>{a.componentType==="graphic"&&(I.value=a.info,Q.value=[{label:"删除画线",key:"deleteWarningLine"},{label:"修改画线",key:"changeWarningLine"}]),clearTimeout(i),i=null})})},ee=async()=>{var i,a,_,m,v,l;try{if(!r.variety||!r.cycle)return;const{variety:c,featureId:S,cycle:L,indicatorStore:w,mainIndicator:O,right:P,startTime:W,endTime:B}=r,{defaultShowCounts:F,addCounts:Y,showWarningLine:te,getFactorData:G}=C.value,q={variety:c,featureId:S,cycle:L,mainIndicatorList:w.getIndicatorParams(O),subIndicator:R.value,right:P,showWarningLine:te,getFactorData:G};W&&B?(q.startTime=W,q.endTime=B):W?(q.startTime=W,q.limit=F+Y):B?(q.endTime=B,q.limit=F+Y):(q.endTime=f.dayjs().add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),q.limit=F+Y);const j=await we(q);if((_=(a=(i=j==null?void 0:j.body)==null?void 0:i.kline)==null?void 0:a.time)!=null&&_.length)b.value=!1,h.value=!1;else{b.value=!0,h.value=!1;return}N.value=(m=j==null?void 0:j.body)==null?void 0:m.kline,y.value=((v=j==null?void 0:j.body)==null?void 0:v.warningLine)||[],oe(),Z(),G&&g("getFactorData",(l=j==null?void 0:j.body)==null?void 0:l.factor)}catch(c){throw h.value=!0,b.value=!1,new Error(c)}},pe=async i=>{const{variety:a,cycle:_,indicatorStore:m,mainIndicator:v,right:l}=r,{addCounts:c}=C.value,{time:S}=N.value;if(i==="history"){const L=await De({variety:a,cycle:_,endTime:S[0],limit:c,mainIndicatorList:m.getIndicatorParams(v),subIndicator:R.value,right:l});N.value={time:[...L.body.time,...N.value.time.slice(1)],data:[...L.body.data,...N.value.data.slice(1)],mainIndicator:N.value.mainIndicator.map((w,O)=>{var P;return{...w,data:[...((P=L.body.mainIndicator[O])==null?void 0:P.data)??[],...w.data.slice(1)]}}),subIndicator:N.value.subIndicator.map((w,O)=>{var P;return{...w,data:[...((P=L.body.subIndicator[O])==null?void 0:P.data)??[],...w.data.slice(1)]}})},oe(!0),L.body.data.length<c&&(p=!0),x=!1}},oe=(i=!1)=>{var O,P,W;de();const{time:a}=N.value,{gridRight:_,gridLeft:m,defaultShowCounts:v,maxShowCounts:l,showSubChart:c}=C.value;let S=a.length-1-v,L=a.length-1;if(i){const B=t.getOption(),F=(P=(O=B==null?void 0:B.xAxis)==null?void 0:O[0])==null?void 0:P.data,Y=(W=B==null?void 0:B.dataZoom)==null?void 0:W[0],te=F[Y==null?void 0:Y.startValue],G=F[Y==null?void 0:Y.endValue];S=a.findIndex(q=>q===te),L=a.findIndex(q=>q===G)}const w=Te(N.value,C.value,S,L,r.cycle);if(t.setOption(w,!0),T.value=L,r.brushRange){let B=null,F=null;switch(r.cycle){case"6":{B=a.find(Y=>new Date(Y).getTime()>=new Date(r.brushRange[0]).getTime()||f.dayjs(Y).format("YYYY-MM-DD")===f.dayjs(r.brushRange[0]).format("YYYY-MM-DD")),F=a.findLast(Y=>new Date(Y).getTime()<=new Date(r.brushRange[1]).getTime()||f.dayjs(Y).format("YYYY-MM-DD")===f.dayjs(r.brushRange[1]).format("YYYY-MM-DD"));break}case"7":{B=a.find(Y=>f.dayjs(Y).day(5).format("YYYY-MM-DD")===f.dayjs(r.brushRange[0]).day(5).format("YYYY-MM-DD")),F=a.findLast(Y=>f.dayjs(Y).day(5).format("YYYY-MM-DD")===f.dayjs(r.brushRange[1]).day(5).format("YYYY-MM-DD"));break}case"8":{B=a.find(Y=>f.dayjs(Y).endOf("month").format("YYYY-MM-DD")===f.dayjs(r.brushRange[0]).endOf("month").format("YYYY-MM-DD")),F=a.findLast(Y=>f.dayjs(Y).endOf("month").format("YYYY-MM-DD")===f.dayjs(r.brushRange[1]).endOf("month").format("YYYY-MM-DD"));break}default:B=a.find(Y=>new Date(Y).getTime()>=new Date(r.brushRange[0]).getTime()),F=a.findLast(Y=>new Date(Y).getTime()<=new Date(r.brushRange[1]).getTime())}console.log(B,F),t.dispatchAction({type:"brush",areas:[{brushType:"lineX",coordRange:[B,F],xAxisIndex:0}]})}c&&V.value.draw({startValue:S,endValue:L,maxValueSpan:l},{gridLeft:m,gridRight:_}),re()},Z=()=>{if(!t)return;const i=t==null?void 0:t.getOption();i&&(t==null||t.setOption({...i,graphic:[...Le(t,y.value,r,C.value,()=>{X()})]},!0),re())},re=()=>{const{time:i}=N.value;if(r.brushRange&&(i!=null&&i.length)){let a=f.dayjs(r.brushRange[0]).format("YYYY-MM-DD 00:00:00"),_=f.dayjs(r.brushRange[1]).format("YYYY-MM-DD 23:59:59"),m=null,v=null;switch(r.cycle){case"6":{m=i.find(l=>f.dayjs(l).format("YYYY-MM-DD")===f.dayjs(a).format("YYYY-MM-DD")),v=m;break}case"7":{m=i.find(l=>f.dayjs(l).day(5).format("YYYY-MM-DD")===f.dayjs(a).day(5).format("YYYY-MM-DD")),v=i.findLast(l=>f.dayjs(l).day(5).format("YYYY-MM-DD")===f.dayjs(_).day(5).format("YYYY-MM-DD"));break}case"8":{m=i.find(l=>f.dayjs(l).endOf("month").format("YYYY-MM-DD")===f.dayjs(a).endOf("month").format("YYYY-MM-DD")),v=i.findLast(l=>f.dayjs(l).endOf("month").format("YYYY-MM-DD")===f.dayjs(_).endOf("month").format("YYYY-MM-DD"));break}default:m=i.find(l=>{const c=f.dayjs(l).format("YYYY-MM-DD")===f.dayjs(a).format("YYYY-MM-DD"),S=new Date(l).getTime()>=new Date(a).getTime();return c&&S}),v=i.findLast(l=>{const c=f.dayjs(l).format("YYYY-MM-DD")===f.dayjs(_).format("YYYY-MM-DD"),S=new Date(l).getTime()<=new Date(_).getTime();return c&&S})}t.dispatchAction({type:"brush",areas:[{brushType:"lineX",coordRange:[m,v],xAxisIndex:0}]})}},X=async()=>{const i=await Se({featureId:r.featureId});y.value=(i==null?void 0:i.body)||[],Z(),g("change","warningLine",y.value)},ye=async i=>{const{variety:a,varietyName:_,featureId:m,featureType:v}=r;if(i.key==="drawWarningLine"){const l=t==null?void 0:t.getOption(),c=l.tooltip[0];t==null||t.setOption({...l,tooltip:{...c,axisPointer:{...c.axisPointer,lineStyle:{width:0},crossStyle:{width:2},label:{...c.axisPointer.label,backgroundColor:"transparent",formatter:L=>""}}}});const S=async L=>{t==null||t.getZr().off("mousedown",S);const w=t==null?void 0:t.convertFromPixel({yAxisIndex:0},L.offsetY),O=Math.round(w*1e3)/1e3;t==null||t.setOption({...l,tooltip:{...c,axisPointer:{...c.axisPointer,lineStyle:{width:1},crossStyle:{width:1},label:{...c.axisPointer.label,backgroundColor:null}}}}),await Me({featureCode:a,featureName:_,featureId:m,featureType:v,warnPrice:O}),J.ElMessage.success("画线预警成功!"),X()};t==null||t.getZr().on("mousedown",S)}else i.key==="deleteWarningLine"?(await Ve({id:I.value.id}),J.ElMessage.success("画线预警删除成功"),X()):i.key==="changeWarningLine"&&($.value=!0,H.value=I.value.warnPrice)},me=async()=>{const{variety:i,varietyName:a,featureId:_,featureType:m}=r;await ce({id:I.value.id,featureCode:i,featureName:a,featureId:_,featureType:m,warnPrice:H.value}),J.ElMessage.success("画线预警修改成功"),X()},ge=()=>{Q.value=[...s]};return k({draw:(i,a)=>{i==="warningLine"&&(y.value=a,Z())}}),(i,a)=>{var L;const _=le.ElMenuItem,m=le.ElMenu,v=he.ElEmpty,l=be.ElButton,c=xe.ElInputNumber,S=ve.ElDialog;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"klineBasic",onMousemove:a[1]||(a[1]=w=>o.value=!0),onMouseout:a[2]||(a[2]=w=>o.value=!1)},[e.createElementVNode("div",ze,[e.createVNode(Fe,{variety:n.variety,data:N.value,activeIndex:T.value},null,8,["variety","data","activeIndex"])]),e.createElementVNode("div",{class:"klineBasic-main",style:e.normalizeStyle({height:C.value.showSubChart?"70%":"100%"})},[e.createVNode(We,{onCloseContextMenuCallBack:ge},{popover:e.withCtx(()=>[e.createVNode(m,{style:{borderRadius:"4px",overflow:"hidden",background:"#fff",borderRight:0}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Q.value,w=>(e.openBlock(),e.createBlock(_,{style:{height:"36px"},key:w.key,index:w.key,onClick:O=>ye(w)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.label),1)]),_:2},1032,["index","onClick"]))),128))]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"klineBasicMainRef",ref:E,style:{height:"100%"}},null,512)]),_:1})],4),C.value.showSubChart?(e.openBlock(),e.createElementBlock("div",Ke,[e.createVNode(Pe,{ref_key:"klineSubRef",ref:V,modelValue:R.value,"onUpdate:modelValue":a[0]||(a[0]=w=>R.value=w),data:N.value,cycle:n.cycle,activeIndex:T.value,subIndicatorList:(L=n.indicatorStore)==null?void 0:L.subIndicatorList},null,8,["modelValue","data","cycle","activeIndex","subIndicatorList"])])):e.createCommentVNode("",!0),b.value?(e.openBlock(),e.createElementBlock("div",Ue,[e.createVNode(v,{class:"klineBasic-empty-content",description:"暂无数据"})])):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("div",He,[Ze,e.createElementVNode("div",Xe,[e.createVNode(l,{onClick:ee},{default:e.withCtx(()=>[e.createTextVNode("刷新")]),_:1})])])):e.createCommentVNode("",!0)],32),e.createVNode(S,{modelValue:$.value,"onUpdate:modelValue":a[5]||(a[5]=w=>$.value=w),title:"画线预警-修改价格",width:"30%","align-center":""},{footer:e.withCtx(()=>[e.createElementVNode("span",Je,[e.createVNode(l,{onClick:a[4]||(a[4]=w=>$.value=!1)},{default:e.withCtx(()=>[e.createTextVNode("取消")]),_:1}),e.createVNode(l,{type:"primary",onClick:me},{default:e.withCtx(()=>[e.createTextVNode("确定")]),_:1})])]),default:e.withCtx(()=>[Ge,e.createVNode(c,{modelValue:H.value,"onUpdate:modelValue":a[3]||(a[3]=w=>H.value=w),placeholder:"输入预警价格"},null,8,["modelValue"])]),_:1},8,["modelValue"])],64)}}},et=K._export_sfc(Qe,[["__scopeId","data-v-e675b051"]]),tt={install(n){n.component("st-klineBasic",et)}};module.exports=tt;