st-comp 0.0.245 → 0.0.246

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 be=require("./el-dialog-ad7309e9.cjs");require("./el-overlay-d7a6e4a9.cjs");require("./el-input-172c49f8.cjs");const xe=require("./el-input-number-c2e71528.cjs"),he=require("./el-button-68baab7b.cjs"),_e=require("./el-empty-1697ded8.cjs"),le=require("./el-menu-item-7f986598.cjs");require("./el-tooltip-0ea8fbf8.cjs");require("./el-popper-7ba87e05.cjs");const e=require("vue"),Ye=require("echarts"),f=require("./dayjs.min-2c20abe6.cjs"),A=require("./index-8901a38c.cjs"),J=require("./el-message-a86c0efa.cjs"),U=require("./_plugin-vue_export-helper-f246444f.cjs");require("./el-tag-789f05d3.cjs");const ie=require("./el-select-12f6deb7.cjs");require("./el-scrollbar-bc3f790d.cjs");require("./index-cebc7160.cjs");require("./use-form-common-props-344056f9.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-cf78ebac.cjs");require("./index-4f48940d.cjs");require("./typescript-b63f8e83.cjs");require("./index-c04f444f.cjs");require("./index-eea0bcb3.cjs");require("./config-provider-2182708a.cjs");require("./index-8de94a49.cjs");require("./index-696b6a94.cjs");require("./castArray-35947698.cjs");require("./debounce-62f5b6e8.cjs");function ke(n){const Y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const b in n)if(b!=="default"){const l=Object.getOwnPropertyDescriptor(n,b);Object.defineProperty(Y,b,l.get?l:{enumerable:!0,get:()=>n[b]})}}return Y.default=n,Object.freeze(Y)}const ne=ke(Ye);let K=null;const we=n=>{const Y=A.y(n,{handleReq:b=>{A.v()&&(b.headers.token=A.U())},handleRes:b=>{const{data:l}=b;if(l.code===401)return location.origin.includes("localhost")?location.href=`${location.origin}/#/404`:A.K(),!0}});Y.get,K=Y.post},De=n=>K("/middleLayer/kline/getKlineBasic",{...n,userId:A.V("id")}),Me=n=>K("/middleLayer/kline/getKline",n),Se=async n=>K("/alarm/deliversign/addAlarmPrice",{...n,userId:A.V("id")}),Ve=async n=>K("/alarm/deliversign/findAlarmPriceByUserId",{...n,userId:A.V("id")}),ue=async n=>K("/alarm/deliversign/updateAlarmPrice",{...n,userId:A.V("id")}),Te=async n=>K("/alarm/deliversign/deleteAlarmPrice",{...n,userId:A.V("id")}),{round:z}=A.x,Le=(n,Y,b,l,u)=>{const{data:t,time:M}=n,{gridTop:d,gridRight:x,gridLeft:p,maxShowCounts:g,showSubChart:r}=Y;return{animation:!1,grid:{top:`${d}px`,right:`${x}px`,bottom:r?"6px":"24px",left:`${p}px`},dataZoom:[{type:"inside",startValue:b,endValue:l,maxValueSpan:g}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:a=>{const{axisDimension:h,value:_}=a;return h==="x"?r?"":["6","7","8"].includes(u)?f.dayjs(_).format("YYYY-MM-DD"):_:String(z(_))}}},formatter:()=>""},xAxis:{show:!r,type:"category",data:M,splitLine:{show:!1},axisLabel:{formatter:a=>["6","7","8"].includes(u)?f.dayjs(a).format("YYYY-MM-DD"):a}},yAxis:{type:"value",axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}},min:a=>z(a.min),max:a=>z(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)"}}}},Be=(n,Y,b,l,u)=>{const{variety:t,featureId:M,featureType:d}=b,{gridTop:x,gridLeft:p,gridRight:g}=l;return Y.reduce((r,a)=>{const{warnPrice:h}=a,_=n==null?void 0:n.convertToPixel({yAxisIndex:0},h);if(_<=x||_>=(n==null?void 0:n.getHeight()))return r;let N=0;return[...r,{type:"group",name:"warningLine",info:a,draggable:"vertical",children:[{type:"line",info:a,shape:{x1:p,y1:_,x2:(n==null?void 0:n.getWidth())-g,y2:_},style:{stroke:"#FFF",lineWidth:1,lineDash:[8,4]},z:10},{type:"text",info:a,x:(n==null?void 0:n.getWidth())-g,y:_-5,style:{fill:"#FFF",text:h,stroke:"#000",lineWidth:1,opacity:1},z:10}],ondragstart:V=>{N=V.offsetY},ondrag:V=>{var R;if(V.target&&V.target.childAt(1)){const T=n.convertFromPixel({yAxisIndex:0},_+(V.offsetY-N));(R=V.target.childAt(1))==null||R.animate("style",!1).when(1,{text:z(T,3)}).start()}},ondragend:async V=>{const T=V.offsetY-N;if(T!==0){const E=n==null?void 0:n.convertFromPixel({yAxisIndex:0},T+_),m={id:a.id,warnPrice:z(E,3),featureId:M,featureCode:t,featureType:d};await ue(m),J.ElMessage.success("画线预警修改成功"),u&&u()}}}]},[])};function ce(n){function Y(l){if(typeof l=="number")return Number.isFinite(l)?l:null;if(typeof l=="string"){const u=l.trim();if(u==="")return null;const t=Number(u);return Number.isFinite(t)?t:null}return null}const b=Y(n);if(b===null)return"-";try{if(b>=1||b<=-1)return z(b);{const l=b.toPrecision(3);return z(l,l.split(".")[1].length-1)}}catch{return"-"}}const Ne=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){const Y=n,b=e.ref(null),l=e.ref([]);return e.watch(()=>Y.data,()=>{l.value.length===0&&e.nextTick(()=>{Array.from(b.value.children).forEach((u,t)=>{var M,d,x,p,g,r,a,h;((d=(M=Y.data)==null?void 0:M[t])==null?void 0:d.label)==="涨跌"?l.value[t]="85px":((p=(x=Y.data)==null?void 0:x[t])==null?void 0:p.label)==="至今涨幅"?l.value[t]="115px":((r=(g=Y.data)==null?void 0:g[t])==null?void 0:r.label)==="额"?l.value[t]="85px":["开","高","低","收"].includes((h=(a=Y.data)==null?void 0:a[t])==null?void 0:h.label)?l.value[t]=`${u.offsetWidth+24}px`:l.value[t]=`${u.offsetWidth+36}px`})})}),(u,t)=>(e.openBlock(),e.createElementBlock("div",{class:"kline-tips",ref_key:"tipsRef",ref:b},[(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:l.value[d]?l.value[d]:null})},e.toDisplayString(M.label)+" "+e.toDisplayString(M.value),5))),128))],512))}});const se=U._export_sfc(Ne,[["__scopeId","data-v-096c0d10"]]);const Ee={class:"kline-tips"},Fe={__name:"index",props:{data:{type:Object,require:!0},activeIndex:{type:[Number,String],require:!0},variety:{type:[String,Number],default:()=>null}},setup(n){const{round:Y,formatValue:b}=A.x,l=n,u=e.ref(null);e.watch(()=>l.activeIndex,()=>{u.value===null&&(u.value=l.data.data[l.activeIndex][1])}),e.watch(()=>l.data,()=>{u.value===null&&(u.value=l.data.data[l.activeIndex][1])}),e.watch(()=>l.variety,()=>{u.value=null});const t=e.computed(()=>{const{data:d,activeIndex:x}=l;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:b(p[4])});let r;p[6]>0?r="red":p[6]<0&&(r="green"),g.push({label:"涨跌",value:`${Y(p[6])}%`,color:r});const a=(u.value/p[1]-1)*100;let h;return a>0?h="red":a<0&&(h="green"),g.push({label:"至今涨幅",value:`${Y(a)}%`,color:h}),g}return[]}),M=e.computed(()=>{var p;const{data:d,activeIndex:x}=l;return((p=d==null?void 0:d.mainIndicator)==null?void 0:p.map(g=>({label:g.key,value:ce(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"])]))}},qe=U._export_sfc(Fe,[["__scopeId","data-v-5be4d504"]]),Ae={class:"kline-averageTips"},Re=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){return(Y,b)=>(e.openBlock(),e.createElementBlock("div",Ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(l,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"kline-averageTips-item",style:e.normalizeStyle({color:l.color})},e.toDisplayString(l.label)+" "+e.toDisplayString(l.value),5))),128))]))}});const je=U._export_sfc(Re,[["__scopeId","data-v-2ce54548"]]);const Ie={class:"klineSub"},Oe={class:"klineSub-tips"},$e={key:0,class:"klineSub-tips-select"},Pe={__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:Y,emit:b}){const{round:l}=A.x;let u,t;const M=b,d=n,x=e.ref(),p=e.computed({get(){return d.modelValue},set(a){M("update:modelValue",a)}}),g=e.computed(()=>{var _;const{data:a,activeIndex:h}=d;return((_=a==null?void 0:a.subIndicator)==null?void 0:_.map(N=>({label:N.key,color:N.color,value:ce(N.data[h])})))||[]});e.onMounted(()=>{u=ne.init(x.value);let a=!0;t=new ResizeObserver(()=>{if(a){a=null;return}u.resize()}),t.observe(x.value)}),e.onUnmounted(()=>{u.dispose(),t.disconnect(),t=null});const r=(a,h)=>{const _=a[h],N=h===0?a[h]:a[h-1];return _[0]===_[1]?_[0]>=N[1]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}:_[1]>_[0]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}};return Y({connect:a=>{ne.connect([a,u])},draw:(a,h)=>{e.nextTick(()=>{const{startValue:_,endValue:N,maxValueSpan:V}=a,{leftYAxisRange:R,rightYAxisRange:T}=d.data.subIndicator[0],E=d.data.subIndicator.map(m=>{if(m.series==="bar")return{name:"subMain",xAxisIndex:0,yAxisIndex:1,type:"bar",silent:!0,symbol:"none",data:m.data.map((I,$)=>m.seriesColor==="kline"?{value:I,itemStyle:r(d.data.data,$)}:m.seriesColor==="value"?{value:I,itemStyle:{color:I>=0?"#FF0000":"#00FFFF"}}:{value:I,itemStyle:{color:m.seriesColor}})};if(m.series==="line")return{xAxisIndex:0,yAxisIndex:m.yAxis==="right"?2:1,name:m.key,type:"line",silent:!0,symbol:"none",data:m.data,lineStyle:{width:1},itemStyle:{color:m.color}}});u.setOption({animation:!1,grid:{left:`${h.gridLeft}px`,top:"10px",right:`${h.gridRight}px`,bottom:"20px"},dataZoom:[{type:"inside",startValue:_,endValue:N,maxValueSpan:V}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:m=>{const{axisDimension:I,value:$}=m;if(I==="x")return["6","7","8"].includes(d.cycle)?f.dayjs($).format("YYYY-MM-DD"):$;if(m.axisIndex===1)return String(l($))}}},formatter:()=>""},xAxis:{type:"category",data:d.data.time,axisLine:{show:!0},splitLine:{show:!1},axisLabel:{formatter:m=>["6","7","8"].includes(d.cycle)?f.dayjs(m).format("YYYY-MM-DD"):m}},yAxis:[{position:"right"},{position:"left",min:R==="cover"?m=>m.min:null,max:R==="cover"?m=>m.max:null,splitNumber:1,axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}}},{position:"right",min:T==="cover"?m=>m.min:null,max:T==="cover"?m=>m.max:null,splitNumber:1,axisLine:{show:!1},splitLine:{show:!1},axisLabel:{show:!1}}],series:E},!0)})}}),(a,h)=>{const _=ie.ElOption,N=ie.ElSelect;return e.openBlock(),e.createElementBlock("div",Ie,[e.createElementVNode("div",Oe,[g.value.length?(e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(N,{modelValue:p.value,"onUpdate:modelValue":h[0]||(h[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(_,{key:V.value,label:V.label,value:V.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createVNode(je,{data:g.value},null,8,["data"])]),e.createElementVNode("div",{class:"klineSub-chart",ref_key:"subChartRef",ref:x},null,512)])}}},Ce=U._export_sfc(Pe,[["__scopeId","data-v-a6bfe8fe"]]),We=e.defineComponent({__name:"index",emits:["closeContextMenuCallBack"],setup(n,{emit:Y}){const b=Y,l=e.ref(),u=e.ref(),t=e.ref({display:"none",top:"0px",left:"0px"}),M=()=>{t.value.display="none",b("closeContextMenuCallBack"),document.removeEventListener("click",M)},d=x=>{if(x.preventDefault(),t.value.display==="block"){const{offsetX:p,offsetY:g}=x,{offsetWidth:r,offsetHeight:a}=u.value;if(p<=r&&g<=a)return}l.value.click(),t.value={display:"block",top:`${x.offsetY}px`,left:`${x.offsetX}px`},e.nextTick(()=>{const p=l.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:l,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 ze=U._export_sfc(We,[["__scopeId","data-v-811db6b4"]]);const de=n=>(e.pushScopeId("data-v-e675b051"),n=n(),e.popScopeId(),n),Ke={class:"klineBasic-tips"},Ue={key:0,class:"klineBasic-sub"},He={key:1,class:"klineBasic-empty"},Ze={key:2,class:"klineBasic-error"},Xe=de(()=>e.createElementVNode("div",{class:"klineBasic-error-content"},"加载失败,请刷新重试",-1)),Ge={style:{"text-align":"center"}},Je=de(()=>e.createElementVNode("span",{style:{"margin-right":"10px"}},"预警价格:",-1)),Qe={class:"dialog-footer"},et={__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:Y,emit:b}){const l=[{label:"画线预警",key:"drawWarningLine"}];let u=null,t=null,M,d,x=!1,p=!1;const g=b,r=n,a=e.ref(!1),h=e.ref(!1),_=e.ref(!1),N=e.ref(null),V=e.ref(null),R=e.ref("VOL"),T=e.ref(0),E=e.ref({}),m=e.ref([]),I=e.ref({}),$=e.ref(!1),H=e.ref(""),Q=e.ref([...l]),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 s,o;return[r.variety,r.cycle,r.mainIndicator,R.value,(s=r.indicatorStore)==null?void 0:s.filterIndicator,(o=r.indicatorStore)==null?void 0:o.customIndicator]},()=>{ee()},{deep:!0}),e.onMounted(()=>{we(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(),u==null||u.dispose(),window.removeEventListener("keydown",oe)});const fe=()=>{t||(t=ne.init(N.value),pe(),C.value.showSubChart&&V.value.connect(t),u=A.D(N.value),u.listen(()=>{requestAnimationFrame(()=>{t.resize()})}))},oe=({code:s,ctrlKey:o})=>{if(!(o||a.value))return;const{xAxis:k,dataZoom:y}=t.getOption(),{data:v}=(k==null?void 0:k[0])??{data:[]};let{startValue:i,endValue:c}=(y==null?void 0:y[0])??{};if(v!=null&&v.length){switch(s){case"ArrowUp":{if(c-i<5)return;const S=Math.floor((c-i)/2)+1;i=i+S,c-i<5&&(i=c-4);break}case"ArrowDown":{const S=Math.min(500,c-i);i=i-S-1;break}case"ArrowLeft":{i>0&&(i-=1,c-=1),T.value>0&&(T.value-=1);break}case"ArrowRight":{c<v.length-1&&(i+=1,c+=1),a.value&&T.value<v.length-1&&(T.value+=1);break}}t.dispatchAction({type:"dataZoom",startValue:i,endValue:c}),t.dispatchAction({type:"updateAxisPointer",seriesIndex:0,dataIndex:a.value?T.value:null}),t.dispatchAction({type:"highlight",dataIndex:a.value?T.value:c})}},pe=()=>{t==null||t.on("datazoom",o=>{clearTimeout(d),d=setTimeout(()=>{var y,v,i,c;const{loadCheckCounts:k}=C.value;if((v=(y=t==null?void 0:t.getOption())==null?void 0:y.dataZoom)!=null&&v[0]){const{startValue:S}=(c=(i=t==null?void 0:t.getOption())==null?void 0:i.dataZoom)==null?void 0:c[0];S<k&&x===!1&&p===!1&&(x=!0,me("history")),Z()}clearTimeout(d)},100)}),t==null||t.on("highlight",o=>{var y,v;let k=o.dataIndex||-1;o.batch&&(k=typeof((y=o==null?void 0:o.batch[0])==null?void 0:y.dataIndex)=="number"?(v=o==null?void 0:o.batch[0])==null?void 0:v.dataIndex:-1),clearTimeout(M),M=setTimeout(()=>{T.value=k,clearTimeout(M)},20)}),t==null||t.on("globalout",()=>{const o=setTimeout(()=>{var y,v,i;clearTimeout(o);const k=(i=(v=(y=t==null?void 0:t.getOption())==null?void 0:y.dataZoom)==null?void 0:v[0])==null?void 0:i.endValue;T.value=k},30)});let s=null;t==null||t.on("contextmenu",o=>{s=setTimeout(()=>{o.componentType==="graphic"&&(I.value=o.info,Q.value=[{label:"删除画线",key:"deleteWarningLine"},{label:"修改画线",key:"changeWarningLine"}]),clearTimeout(s),s=null})})},ee=async()=>{var s,o,k,y,v,i;try{if(!r.variety||!r.cycle)return;const{variety:c,featureId:S,cycle:L,indicatorStore:D,mainIndicator:O,right:P,startTime:W,endTime:B}=r,{defaultShowCounts:F,addCounts:w,showWarningLine:te,getFactorData:G}=C.value,q={variety:c,featureId:S,cycle:L,mainIndicatorList:D.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+w):B?(q.endTime=B,q.limit=F+w):(q.endTime=f.dayjs().add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),q.limit=F+w);const j=await De(q);if((k=(o=(s=j==null?void 0:j.body)==null?void 0:s.kline)==null?void 0:o.time)!=null&&k.length)h.value=!1,_.value=!1;else{h.value=!0,_.value=!1;return}E.value=(y=j==null?void 0:j.body)==null?void 0:y.kline,m.value=((v=j==null?void 0:j.body)==null?void 0:v.warningLine)||[],ae(),Z(),G&&g("getFactorData",(i=j==null?void 0:j.body)==null?void 0:i.factor)}catch(c){throw _.value=!0,h.value=!1,new Error(c)}},me=async s=>{const{variety:o,cycle:k,indicatorStore:y,mainIndicator:v,right:i}=r,{addCounts:c}=C.value,{time:S}=E.value;if(s==="history"){const L=await Me({variety:o,cycle:k,endTime:S[0],limit:c,mainIndicatorList:y.getIndicatorParams(v),subIndicator:R.value,right:i});E.value={time:[...L.body.time,...E.value.time.slice(1)],data:[...L.body.data,...E.value.data.slice(1)],mainIndicator:E.value.mainIndicator.map((D,O)=>{var P;return{...D,data:[...((P=L.body.mainIndicator[O])==null?void 0:P.data)??[],...D.data.slice(1)]}}),subIndicator:E.value.subIndicator.map((D,O)=>{var P;return{...D,data:[...((P=L.body.subIndicator[O])==null?void 0:P.data)??[],...D.data.slice(1)]}})},ae(!0),L.body.data.length<c&&(p=!0),x=!1}},ae=(s=!1)=>{var O,P,W;fe();const{time:o}=E.value,{gridRight:k,gridLeft:y,defaultShowCounts:v,maxShowCounts:i,showSubChart:c}=C.value;let S=o.length-1-v,L=o.length-1;if(s){const B=t.getOption(),F=(P=(O=B==null?void 0:B.xAxis)==null?void 0:O[0])==null?void 0:P.data,w=(W=B==null?void 0:B.dataZoom)==null?void 0:W[0],te=F[w==null?void 0:w.startValue],G=F[w==null?void 0:w.endValue];S=o.findIndex(q=>q===te),L=o.findIndex(q=>q===G)}const D=Le(E.value,C.value,S,L,r.cycle);if(t.setOption(D,!0),T.value=L,r.brushRange){let B=null,F=null;switch(r.cycle){case"6":{B=o.find(w=>new Date(w).getTime()>=new Date(r.brushRange[0]).getTime()||f.dayjs(w).format("YYYY-MM-DD")===f.dayjs(r.brushRange[0]).format("YYYY-MM-DD")),F=o.findLast(w=>new Date(w).getTime()<=new Date(r.brushRange[1]).getTime()||f.dayjs(w).format("YYYY-MM-DD")===f.dayjs(r.brushRange[1]).format("YYYY-MM-DD"));break}case"7":{B=o.find(w=>f.dayjs(w).day(5).format("YYYY-MM-DD")===f.dayjs(r.brushRange[0]).day(5).format("YYYY-MM-DD")),F=o.findLast(w=>f.dayjs(w).day(5).format("YYYY-MM-DD")===f.dayjs(r.brushRange[1]).day(5).format("YYYY-MM-DD"));break}case"8":{B=o.find(w=>f.dayjs(w).endOf("month").format("YYYY-MM-DD")===f.dayjs(r.brushRange[0]).endOf("month").format("YYYY-MM-DD")),F=o.findLast(w=>f.dayjs(w).endOf("month").format("YYYY-MM-DD")===f.dayjs(r.brushRange[1]).endOf("month").format("YYYY-MM-DD"));break}default:B=o.find(w=>new Date(w).getTime()>=new Date(r.brushRange[0]).getTime()),F=o.findLast(w=>new Date(w).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:i},{gridLeft:y,gridRight:k}),re()},Z=()=>{if(!t)return;const s=t==null?void 0:t.getOption();s&&(t==null||t.setOption({...s,graphic:[...Be(t,m.value,r,C.value,()=>{X()})]},!0),re())},re=()=>{const{time:s}=E.value;if(r.brushRange&&(s!=null&&s.length)){let o=f.dayjs(r.brushRange[0]).format("YYYY-MM-DD 00:00:00"),k=f.dayjs(r.brushRange[1]).format("YYYY-MM-DD 23:59:59"),y=null,v=null;switch(r.cycle){case"6":{y=s.find(i=>f.dayjs(i).format("YYYY-MM-DD")===f.dayjs(o).format("YYYY-MM-DD")),v=y;break}case"7":{y=s.find(i=>f.dayjs(i).day(5).format("YYYY-MM-DD")===f.dayjs(o).day(5).format("YYYY-MM-DD")),v=s.findLast(i=>f.dayjs(i).day(5).format("YYYY-MM-DD")===f.dayjs(k).day(5).format("YYYY-MM-DD"));break}case"8":{y=s.find(i=>f.dayjs(i).endOf("month").format("YYYY-MM-DD")===f.dayjs(o).endOf("month").format("YYYY-MM-DD")),v=s.findLast(i=>f.dayjs(i).endOf("month").format("YYYY-MM-DD")===f.dayjs(k).endOf("month").format("YYYY-MM-DD"));break}default:y=s.find(i=>{const c=f.dayjs(i).format("YYYY-MM-DD")===f.dayjs(o).format("YYYY-MM-DD"),S=new Date(i).getTime()>=new Date(o).getTime();return c&&S}),v=s.findLast(i=>{const c=f.dayjs(i).format("YYYY-MM-DD")===f.dayjs(k).format("YYYY-MM-DD"),S=new Date(i).getTime()<=new Date(k).getTime();return c&&S})}t.dispatchAction({type:"brush",areas:[{brushType:"lineX",coordRange:[y,v],xAxisIndex:0}]})}},X=async()=>{const s=await Ve({featureId:r.featureId});m.value=(s==null?void 0:s.body)||[],Z(),g("change","warningLine",m.value)},ye=async s=>{const{variety:o,varietyName:k,featureId:y,featureType:v}=r;if(s.key==="drawWarningLine"){const i=t==null?void 0:t.getOption(),c=i.tooltip[0];t==null||t.setOption({...i,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 D=t==null?void 0:t.convertFromPixel({yAxisIndex:0},L.offsetY),O=Math.round(D*1e3)/1e3;t==null||t.setOption({...i,tooltip:{...c,axisPointer:{...c.axisPointer,lineStyle:{width:1},crossStyle:{width:1},label:{...c.axisPointer.label,backgroundColor:null}}}}),await Se({featureCode:o,featureName:k,featureId:y,featureType:v,warnPrice:O}),J.ElMessage.success("画线预警成功!"),X()};t==null||t.getZr().on("mousedown",S)}else s.key==="deleteWarningLine"?(await Te({id:I.value.id}),J.ElMessage.success("画线预警删除成功"),X()):s.key==="changeWarningLine"&&($.value=!0,H.value=I.value.warnPrice)},ge=async()=>{const{variety:s,varietyName:o,featureId:k,featureType:y}=r;await ue({id:I.value.id,featureCode:s,featureName:o,featureId:k,featureType:y,warnPrice:H.value}),J.ElMessage.success("画线预警修改成功"),X()},ve=()=>{Q.value=[...l]};return Y({draw:(s,o)=>{s==="warningLine"&&(m.value=o,Z())}}),(s,o)=>{var L;const k=le.ElMenuItem,y=le.ElMenu,v=_e.ElEmpty,i=he.ElButton,c=xe.ElInputNumber,S=be.ElDialog;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"klineBasic",onMousemove:o[1]||(o[1]=D=>a.value=!0),onMouseout:o[2]||(o[2]=D=>a.value=!1)},[e.createElementVNode("div",Ke,[e.createVNode(qe,{variety:n.variety,data:E.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(ze,{onCloseContextMenuCallBack:ve},{popover:e.withCtx(()=>[e.createVNode(y,{style:{borderRadius:"4px",overflow:"hidden",background:"#fff",borderRight:0}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Q.value,D=>(e.openBlock(),e.createBlock(k,{style:{height:"36px"},key:D.key,index:D.key,onClick:O=>ye(D)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.label),1)]),_:2},1032,["index","onClick"]))),128))]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"klineBasicMainRef",ref:N,style:{height:"100%"}},null,512)]),_:1})],4),C.value.showSubChart?(e.openBlock(),e.createElementBlock("div",Ue,[e.createVNode(Ce,{ref_key:"klineSubRef",ref:V,modelValue:R.value,"onUpdate:modelValue":o[0]||(o[0]=D=>R.value=D),data:E.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),h.value?(e.openBlock(),e.createElementBlock("div",He,[e.createVNode(v,{class:"klineBasic-empty-content",description:"暂无数据"})])):e.createCommentVNode("",!0),_.value?(e.openBlock(),e.createElementBlock("div",Ze,[Xe,e.createElementVNode("div",Ge,[e.createVNode(i,{onClick:ee},{default:e.withCtx(()=>[e.createTextVNode("刷新")]),_:1})])])):e.createCommentVNode("",!0)],32),e.createVNode(S,{modelValue:$.value,"onUpdate:modelValue":o[5]||(o[5]=D=>$.value=D),title:"画线预警-修改价格",width:"30%","align-center":""},{footer:e.withCtx(()=>[e.createElementVNode("span",Qe,[e.createVNode(i,{onClick:o[4]||(o[4]=D=>$.value=!1)},{default:e.withCtx(()=>[e.createTextVNode("取消")]),_:1}),e.createVNode(i,{type:"primary",onClick:ge},{default:e.withCtx(()=>[e.createTextVNode("确定")]),_:1})])]),default:e.withCtx(()=>[Je,e.createVNode(c,{modelValue:H.value,"onUpdate:modelValue":o[3]||(o[3]=D=>H.value=D),placeholder:"输入预警价格"},null,8,["modelValue"])]),_:1},8,["modelValue"])],64)}}},tt=U._export_sfc(et,[["__scopeId","data-v-e675b051"]]),nt={install(n){n.component("st-klineBasic",tt)}};module.exports=nt;
1
+ "use strict";require("./base-ef747d02.cjs");const Ye=require("./el-dialog-ad7309e9.cjs");require("./el-overlay-d7a6e4a9.cjs");require("./el-input-172c49f8.cjs");const Se=require("./el-input-number-c2e71528.cjs"),De=require("./el-button-68baab7b.cjs"),Ve=require("./el-empty-1697ded8.cjs"),ce=require("./el-menu-item-7f986598.cjs");require("./el-tooltip-0ea8fbf8.cjs");require("./el-popper-7ba87e05.cjs");const e=require("vue"),V=require("./dayjs.min-2c20abe6.cjs"),Me=require("echarts"),N=require("./index-8901a38c.cjs"),te=require("./el-message-a86c0efa.cjs"),U=require("./_plugin-vue_export-helper-f246444f.cjs");require("./el-tag-789f05d3.cjs");const ue=require("./el-select-12f6deb7.cjs");require("./el-scrollbar-bc3f790d.cjs");require("./index-cebc7160.cjs");require("./use-form-common-props-344056f9.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-cf78ebac.cjs");require("./index-4f48940d.cjs");require("./typescript-b63f8e83.cjs");require("./index-c04f444f.cjs");require("./index-eea0bcb3.cjs");require("./config-provider-2182708a.cjs");require("./index-8de94a49.cjs");require("./index-696b6a94.cjs");require("./castArray-35947698.cjs");require("./debounce-62f5b6e8.cjs");function Le(n){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const _ in n)if(_!=="default"){const l=Object.getOwnPropertyDescriptor(n,_);Object.defineProperty(k,_,l.get?l:{enumerable:!0,get:()=>n[_]})}}return k.default=n,Object.freeze(k)}const le=Le(Me);let C=null;const Fe=n=>{const k=N.y(n,{handleReq:_=>{N.v()&&(_.headers.token=N.U())},handleRes:_=>{const{data:l}=_;if(l.code===401)return location.origin.includes("localhost")?location.href=`${location.origin}/#/404`:N.K(),!0}});k.get,C=k.post},Be=n=>C("/middleLayer/kline/getKlineBasic",{...n,userId:N.V("id")}),Te=n=>C("/middleLayer/kline/getKline",n),Ne=async n=>C("/alarm/deliversign/addAlarmPrice",{...n,userId:N.V("id")}),Ee=async n=>C("/alarm/deliversign/findAlarmPriceByUserId",{...n,userId:N.V("id")}),fe=async n=>C("/alarm/deliversign/updateAlarmPrice",{...n,userId:N.V("id")}),qe=async n=>C("/alarm/deliversign/deleteAlarmPrice",{...n,userId:N.V("id")}),{round:W}=N.x,Ae=(n,k,_,l,p)=>{const{data:t,time:h}=n,{gridTop:c,gridRight:b,gridLeft:m,maxShowCounts:g,showSubChart:S}=k;return{animation:!1,grid:{top:`${c}px`,right:`${b}px`,bottom:S?"6px":"24px",left:`${m}px`},dataZoom:[{type:"inside",startValue:_,endValue:l,maxValueSpan:g}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:r=>{const{axisDimension:w,value:i}=r;return w==="x"?S?"":["6","7","8"].includes(p)?V.dayjs(i).format("YYYY-MM-DD"):i:String(W(i))}}},formatter:()=>""},xAxis:{show:!S,type:"category",data:h,splitLine:{show:!1},axisLabel:{formatter:r=>["6","7","8"].includes(p)?V.dayjs(r).format("YYYY-MM-DD"):r}},yAxis:{type:"value",axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}},min:r=>W(r.min),max:r=>W(r.max)},series:[{type:"candlestick",data:t,itemStyle:{color:"transparent",color0:"#00FFFF",borderColor:"#FF0000",borderColor0:"#00FFFF",borderWidth:1}},...n.mainIndicator.map(r=>({name:r.key,type:"line",silent:!0,symbol:"none",data:r.data,lineStyle:{width:r.width||1},itemStyle:{color:r.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)"}}}},Re=(n,k,_,l,p)=>{const{variety:t,featureId:h,featureType:c}=_,{gridTop:b,gridLeft:m,gridRight:g}=l;return k.reduce((S,r)=>{const{warnPrice:w}=r,i=n==null?void 0:n.convertToPixel({yAxisIndex:0},w);if(i<=b||i>=(n==null?void 0:n.getHeight()))return S;let M=0;return[...S,{type:"group",name:"warningLine",info:r,draggable:"vertical",children:[{type:"line",info:r,shape:{x1:m,y1:i,x2:(n==null?void 0:n.getWidth())-g,y2:i},style:{stroke:"#FFF",lineWidth:1,lineDash:[8,4]},z:10},{type:"text",info:r,x:(n==null?void 0:n.getWidth())-g,y:i-5,style:{fill:"#FFF",text:w,stroke:"#000",lineWidth:1,opacity:1},z:10}],ondragstart:D=>{M=D.offsetY},ondrag:D=>{var q;if(D.target&&D.target.childAt(1)){const A=n.convertFromPixel({yAxisIndex:0},i+(D.offsetY-M));(q=D.target.childAt(1))==null||q.animate("style",!1).when(1,{text:W(A,3)}).start()}},ondragend:async D=>{const A=D.offsetY-M;if(A!==0){const j=n==null?void 0:n.convertFromPixel({yAxisIndex:0},A+i),v={id:r.id,warnPrice:W(j,3),featureId:h,featureCode:t,featureType:c};await fe(v),te.ElMessage.success("画线预警修改成功"),p&&p()}}}]},[])};function pe(n){function k(l){if(typeof l=="number")return Number.isFinite(l)?l:null;if(typeof l=="string"){const p=l.trim();if(p==="")return null;const t=Number(p);return Number.isFinite(t)?t:null}return null}const _=k(n);if(_===null)return"-";try{if(_>=1||_<=-1)return W(_);{const l=_.toPrecision(3);return W(l,l.split(".")[1].length-1)}}catch{return"-"}}const Oe=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){const k=n,_=e.ref(null),l=e.ref([]);return e.watch(()=>k.data,()=>{l.value.length===0&&e.nextTick(()=>{Array.from(_.value.children).forEach((p,t)=>{var h,c,b,m,g,S,r,w;((c=(h=k.data)==null?void 0:h[t])==null?void 0:c.label)==="涨跌"?l.value[t]="85px":((m=(b=k.data)==null?void 0:b[t])==null?void 0:m.label)==="至今涨幅"?l.value[t]="115px":((S=(g=k.data)==null?void 0:g[t])==null?void 0:S.label)==="额"?l.value[t]="85px":["开","高","低","收"].includes((w=(r=k.data)==null?void 0:r[t])==null?void 0:w.label)?l.value[t]=`${p.offsetWidth+24}px`:l.value[t]=`${p.offsetWidth+36}px`})})}),(p,t)=>(e.openBlock(),e.createElementBlock("div",{class:"kline-tips",ref_key:"tipsRef",ref:_},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(h,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"kline-tips-item",style:e.normalizeStyle({color:h.color,width:l.value[c]?l.value[c]:null})},e.toDisplayString(h.label)+" "+e.toDisplayString(h.value),5))),128))],512))}});const de=U._export_sfc(Oe,[["__scopeId","data-v-096c0d10"]]);const Ie={class:"kline-tips"},je={__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:_}=N.x,l=n,p=e.ref(null);e.watch(()=>l.activeIndex,()=>{p.value===null&&(p.value=l.data.data[l.activeIndex][1])}),e.watch(()=>l.data,()=>{p.value===null&&(p.value=l.data.data[l.activeIndex][1])}),e.watch(()=>l.variety,()=>{p.value=null});const t=e.computed(()=>{const{data:c,activeIndex:b}=l;if(c.data&&c.data[b]){const m=c.data[b],g=[{label:"开",value:m[0]},{label:"高",value:m[3]},{label:"低",value:m[2]},{label:"收",value:m[1]}];m[4]!==null&&g.push({label:"额",value:_(m[4])});let S;m[6]>0?S="red":m[6]<0&&(S="green"),g.push({label:"涨跌",value:`${k(m[6])}%`,color:S});const r=(p.value/m[1]-1)*100;let w;return r>0?w="red":r<0&&(w="green"),g.push({label:"至今涨幅",value:`${k(r)}%`,color:w}),g}return[]}),h=e.computed(()=>{var m;const{data:c,activeIndex:b}=l;return((m=c==null?void 0:c.mainIndicator)==null?void 0:m.map(g=>({label:g.key,value:pe(g.data[b]),color:g.color})))||[]});return(c,b)=>(e.openBlock(),e.createElementBlock("div",Ie,[e.createVNode(de,{data:t.value},null,8,["data"]),e.createVNode(de,{data:h.value},null,8,["data"])]))}},$e=U._export_sfc(je,[["__scopeId","data-v-5be4d504"]]),Pe={class:"kline-averageTips"},We=e.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(n){return(k,_)=>(e.openBlock(),e.createElementBlock("div",Pe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.data,(l,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:"kline-averageTips-item",style:e.normalizeStyle({color:l.color})},e.toDisplayString(l.label)+" "+e.toDisplayString(l.value),5))),128))]))}});const Ce=U._export_sfc(We,[["__scopeId","data-v-2ce54548"]]);const ze={class:"klineSub"},Ze={class:"klineSub-tips"},Ue={key:0,class:"klineSub-tips-select"},He={__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:_}){const{round:l}=N.x;let p,t;const h=_,c=n,b=e.ref(),m=e.computed({get(){return c.modelValue},set(r){h("update:modelValue",r)}}),g=e.computed(()=>{var i;const{data:r,activeIndex:w}=c;return((i=r==null?void 0:r.subIndicator)==null?void 0:i.map(M=>({label:M.key,color:M.color,value:pe(M.data[w])})))||[]});e.onMounted(()=>{p=le.init(b.value);let r=!0;t=new ResizeObserver(()=>{if(r){r=null;return}p.resize()}),t.observe(b.value)}),e.onUnmounted(()=>{p.dispose(),t.disconnect(),t=null});const S=(r,w)=>{const i=r[w],M=w===0?r[w]:r[w-1];return i[0]===i[1]?i[0]>=M[1]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}:i[1]>i[0]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}};return k({connect:r=>{le.connect([r,p])},draw:(r,w)=>{e.nextTick(()=>{const{startValue:i,endValue:M,maxValueSpan:D}=r,{leftYAxisRange:q,rightYAxisRange:A}=c.data.subIndicator[0],j=c.data.subIndicator.map(v=>{if(v.series==="bar")return{name:"subMain",xAxisIndex:0,yAxisIndex:1,type:"bar",silent:!0,symbol:"none",data:v.data.map((B,F)=>v.seriesColor==="kline"?{value:B,itemStyle:S(c.data.data,F)}:v.seriesColor==="value"?{value:B,itemStyle:{color:B>=0?"#FF0000":"#00FFFF"}}:{value:B,itemStyle:{color:v.seriesColor}})};if(v.series==="line")return{xAxisIndex:0,yAxisIndex:v.yAxis==="right"?2:1,name:v.key,type:"line",silent:!0,symbol:"none",data:v.data,lineStyle:{width:1},itemStyle:{color:v.color}}});p.setOption({animation:!1,grid:{left:`${w.gridLeft}px`,top:"10px",right:`${w.gridRight}px`,bottom:"20px"},dataZoom:[{type:"inside",startValue:i,endValue:M,maxValueSpan:D}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:v=>{const{axisDimension:B,value:F}=v;if(B==="x")return["6","7","8"].includes(c.cycle)?V.dayjs(F).format("YYYY-MM-DD"):F;if(v.axisIndex===1)return String(l(F))}}},formatter:()=>""},xAxis:{type:"category",data:c.data.time,axisLine:{show:!0},splitLine:{show:!1},axisLabel:{formatter:v=>["6","7","8"].includes(c.cycle)?V.dayjs(v).format("YYYY-MM-DD"):v}},yAxis:[{position:"right"},{position:"left",min:q==="cover"?v=>v.min:null,max:q==="cover"?v=>v.max:null,splitNumber:1,axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}}},{position:"right",min:A==="cover"?v=>v.min:null,max:A==="cover"?v=>v.max:null,splitNumber:1,axisLine:{show:!1},splitLine:{show:!1},axisLabel:{show:!1}}],series:j},!0)})}}),(r,w)=>{const i=ue.ElOption,M=ue.ElSelect;return e.openBlock(),e.createElementBlock("div",ze,[e.createElementVNode("div",Ze,[g.value.length?(e.openBlock(),e.createElementBlock("div",Ue,[e.createVNode(M,{modelValue:m.value,"onUpdate:modelValue":w[0]||(w[0]=D=>m.value=D),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,D=>(e.openBlock(),e.createBlock(i,{key:D.value,label:D.label,value:D.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createVNode(Ce,{data:g.value},null,8,["data"])]),e.createElementVNode("div",{class:"klineSub-chart",ref_key:"subChartRef",ref:b},null,512)])}}},Ke=U._export_sfc(He,[["__scopeId","data-v-a6bfe8fe"]]),Xe=e.defineComponent({__name:"index",emits:["closeContextMenuCallBack"],setup(n,{emit:k}){const _=k,l=e.ref(),p=e.ref(),t=e.ref({display:"none",top:"0px",left:"0px"}),h=()=>{t.value.display="none",_("closeContextMenuCallBack"),document.removeEventListener("click",h)},c=b=>{if(b.preventDefault(),t.value.display==="block"){const{offsetX:m,offsetY:g}=b,{offsetWidth:S,offsetHeight:r}=p.value;if(m<=S&&g<=r)return}l.value.click(),t.value={display:"block",top:`${b.offsetY}px`,left:`${b.offsetX}px`},e.nextTick(()=>{const m=l.value.getBoundingClientRect(),g=p.value.getBoundingClientRect();g.left+g.width>=m.right&&(t.value.left=`${b.offsetX-g.width}px`),g.top+g.height>=m.bottom&&(console.log("高度超出"),t.value.top=`${b.offsetY-g.height}px`)}),document.addEventListener("click",h)};return(b,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"contextmenuRef",ref:l,class:"contextmenu",onContextmenu:c,onMouseleave:h},[e.renderSlot(b.$slots,"default",{},void 0,!0),t.value.display!=="none"?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"contextmenuContentRef",ref:p,class:"contextmenu-popover",style:e.normalizeStyle(t.value)},[e.renderSlot(b.$slots,"popover",{},void 0,!0)],4)):e.createCommentVNode("",!0)],544))}});const Ge=U._export_sfc(Xe,[["__scopeId","data-v-811db6b4"]]);const me=n=>(e.pushScopeId("data-v-8efc10f3"),n=n(),e.popScopeId(),n),Je={class:"klineBasic-tips"},Qe={key:0,class:"klineBasic-sub"},et={key:1,class:"klineBasic-empty"},tt={key:2,class:"klineBasic-error"},nt=me(()=>e.createElementVNode("div",{class:"klineBasic-error-content"},"加载失败,请刷新重试",-1)),ot={style:{"text-align":"center"}},at=me(()=>e.createElementVNode("span",{style:{"margin-right":"10px"}},"预警价格:",-1)),lt={class:"dialog-footer"},rt={__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:_}){const l=[{label:"画线预警",key:"drawWarningLine"}];let p=null,t=null,h=null,c=null,b=null,m,g,S=!1,r=!1;const w=_,i=n,M=e.ref(!1),D=e.ref(!1),q=e.ref(!1),A=e.ref(null),j=e.ref(null),v=e.ref("VOL"),B=e.ref(0),F=e.ref({}),H=e.ref([]),G=e.ref({}),J=e.ref(!1),Q=e.ref(""),ne=e.ref([...l]),R=e.computed(()=>({defaultShowCounts:500,addCounts:2e3,maxShowCounts:5e3,loadCheckCounts:500,showSubChart:!0,gridTop:48,gridLeft:80,gridRight:50,showWarningLine:!0,getFactorData:!0,...i.config})),ye=()=>{t||(t=le.init(A.value),_e(),R.value.showSubChart&&j.value.connect(t),p=N.D(A.value),p.listen(()=>{requestAnimationFrame(()=>{t==null||t.resize(),K()})}))},oe=()=>{t&&!t.isDisposed()&&t.hideLoading()},re=(s=!1)=>{h&&(cancelAnimationFrame(h),h=null),h=requestAnimationFrame(()=>{ge(s),h=requestAnimationFrame(()=>{ve(),h=requestAnimationFrame(()=>{K(),h=null})})})},ge=(s=!1)=>{var u,Y,L;if(!t||t.isDisposed())return;const{time:o}=F.value,{defaultShowCounts:x}=R.value;let d=o.length-1-x,f=o.length-1;if(s&&t){const y=t.getOption(),T=(Y=(u=y==null?void 0:y.xAxis)==null?void 0:u[0])==null?void 0:Y.data,O=(L=y==null?void 0:y.dataZoom)==null?void 0:L[0];if(T!=null&&T.length&&O){const $=T[O.startValue],P=T[O.endValue];if($&&P){const z=o.findIndex(X=>new Date(X).getTime()>=new Date($).getTime()),Z=o.findLastIndex(X=>new Date(X).getTime()<=new Date(P).getTime());d=z!==-1?z:0,f=Z!==-1?Z:o.length-1,d>f&&(d=Math.max(0,f-Math.min(100,o.length-1)))}}}const a=Ae(F.value,R.value,d,f,i.cycle);requestAnimationFrame(()=>{t==null||t.setOption(a,!0),B.value=f,requestAnimationFrame(()=>{xe()})})},ve=()=>{var Y;if(!R.value.showSubChart||!j.value)return;const{time:s}=F.value,{gridLeft:o,gridRight:x,maxShowCounts:d,defaultShowCounts:f}=R.value;let a=s.length-1-f,u=s.length-1;if(t&&!t.isDisposed()){const L=t.getOption();if((Y=L==null?void 0:L.dataZoom)!=null&&Y[0]){const{startValue:y,endValue:T}=L.dataZoom[0];y!==void 0&&T!==void 0&&(a=y,u=T)}}requestAnimationFrame(()=>{j.value.draw({startValue:a,endValue:u,maxValueSpan:d},{gridLeft:o,gridRight:x})})},K=()=>{t&&(c&&(cancelAnimationFrame(c),c=null),c=requestAnimationFrame(()=>{if(!(t==null?void 0:t.getOption()))return;const o=t==null?void 0:t.getWidth(),x=t==null?void 0:t.getHeight();!o||!x||(t==null||t.setOption({graphic:Re(t,H.value,i,R.value,()=>{ee()})},{notMerge:!1,replaceMerge:["graphic"],lazyUpdate:!0}),c=null)}))},xe=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{const{time:s}=F.value;if(!i.brushRange||!(s!=null&&s.length)||!t)return;let o=V.dayjs(i.brushRange[0]).format("YYYY-MM-DD 00:00:00"),x=V.dayjs(i.brushRange[1]).format("YYYY-MM-DD 23:59:59"),d=null,f=null;switch(String(i.cycle)){case"6":{d=s.find(a=>V.dayjs(a).format("YYYY-MM-DD")===V.dayjs(o).format("YYYY-MM-DD")),f=d;break}case"7":{d=s.find(a=>V.dayjs(a).day(5).format("YYYY-MM-DD")===V.dayjs(o).day(5).format("YYYY-MM-DD")),f=s.findLast(a=>V.dayjs(a).day(5).format("YYYY-MM-DD")===V.dayjs(x).day(5).format("YYYY-MM-DD"));break}case"8":{d=s.find(a=>V.dayjs(a).endOf("month").format("YYYY-MM-DD")===V.dayjs(o).endOf("month").format("YYYY-MM-DD")),f=s.findLast(a=>V.dayjs(a).endOf("month").format("YYYY-MM-DD")===V.dayjs(x).endOf("month").format("YYYY-MM-DD"));break}default:d=s.find(a=>{const u=V.dayjs(a).format("YYYY-MM-DD")===V.dayjs(o).format("YYYY-MM-DD"),Y=new Date(a).getTime()>=new Date(o).getTime();return u&&Y}),f=s.findLast(a=>{const u=V.dayjs(a).format("YYYY-MM-DD")===V.dayjs(x).format("YYYY-MM-DD"),Y=new Date(a).getTime()<=new Date(x).getTime();return u&&Y})}d&&f&&t.dispatchAction({type:"brush",areas:[{brushType:"lineX",coordRange:[d,f],xAxisIndex:0}]}),b=null})},ae=async()=>{var s,o,x,d,f,a;try{if(!i.variety||!i.cycle)return;const{variety:u,featureId:Y,cycle:L,indicatorStore:y,mainIndicator:T,right:O,startTime:$,endTime:P}=i,{defaultShowCounts:z,addCounts:Z,showWarningLine:X,getFactorData:se}=R.value;ye(),t&&!t.isDisposed()&&t.showLoading({text:"加载中...",color:"#409eff",textColor:"#fff",maskColor:"rgba(0, 0, 0, 0.7)",zlevel:0});const I={variety:u,featureId:Y,cycle:L,mainIndicatorList:y.getIndicatorParams(T),subIndicator:v.value,right:O,showWarningLine:X,getFactorData:se};$&&P?(I.startTime=$,I.endTime=P):$?(I.startTime=$,I.limit=z+Z):P?(I.endTime=P,I.limit=z+Z):(I.endTime=V.dayjs().add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),I.limit=z+Z);const E=await Be(I);if(!((x=(o=(s=E==null?void 0:E.body)==null?void 0:s.kline)==null?void 0:o.time)!=null&&x.length)){D.value=!0,q.value=!1,oe();return}D.value=!1,q.value=!1,F.value=(d=E==null?void 0:E.body)==null?void 0:d.kline,H.value=((f=E==null?void 0:E.body)==null?void 0:f.warningLine)||[],await e.nextTick(),re(!1),se&&w("getFactorData",(a=E==null?void 0:E.body)==null?void 0:a.factor),oe()}catch(u){throw oe(),q.value=!0,D.value=!1,new Error(u)}},be=async s=>{const{variety:o,cycle:x,indicatorStore:d,mainIndicator:f,right:a}=i,{addCounts:u}=R.value,{time:Y}=F.value;if(s==="history"){const L=await Te({variety:o,cycle:x,endTime:Y[0],limit:u,mainIndicatorList:d.getIndicatorParams(f),subIndicator:v.value,right:a});F.value={time:[...L.body.time,...F.value.time.slice(1)],data:[...L.body.data,...F.value.data.slice(1)],mainIndicator:F.value.mainIndicator.map((y,T)=>{var O;return{...y,data:[...((O=L.body.mainIndicator[T])==null?void 0:O.data)??[],...y.data.slice(1)]}}),subIndicator:F.value.subIndicator.map((y,T)=>{var O;return{...y,data:[...((O=L.body.subIndicator[T])==null?void 0:O.data)??[],...y.data.slice(1)]}})},console.log("触发了加载更多数据"),await e.nextTick(),re(!0),L.body.data.length<u&&(r=!0,console.log("历史数据已经全部加载完毕")),S=!1}},ie=({code:s,ctrlKey:o})=>{if(!(o||M.value))return;const{xAxis:x,dataZoom:d}=t.getOption(),{data:f}=(x==null?void 0:x[0])??{data:[]};let{startValue:a,endValue:u}=(d==null?void 0:d[0])??{};if(f!=null&&f.length){switch(s){case"ArrowUp":{if(u-a<5)return;const Y=Math.floor((u-a)/2)+1;a=a+Y,u-a<5&&(a=u-4);break}case"ArrowDown":{const Y=Math.min(500,u-a);a=a-Y-1;break}case"ArrowLeft":{a>0&&(a-=1,u-=1),B.value>0&&(B.value-=1);break}case"ArrowRight":{u<f.length-1&&(a+=1,u+=1),M.value&&B.value<f.length-1&&(B.value+=1);break}}requestAnimationFrame(()=>{t.dispatchAction({type:"dataZoom",startValue:a,endValue:u}),t.dispatchAction({type:"updateAxisPointer",seriesIndex:0,dataIndex:M.value?B.value:null}),t.dispatchAction({type:"highlight",dataIndex:M.value?B.value:u})})}},_e=()=>{t==null||t.on("datazoom",o=>{clearTimeout(g),g=setTimeout(()=>{var d,f,a,u;const{loadCheckCounts:x}=R.value;if((f=(d=t==null?void 0:t.getOption())==null?void 0:d.dataZoom)!=null&&f[0]){const{startValue:Y}=(u=(a=t==null?void 0:t.getOption())==null?void 0:a.dataZoom)==null?void 0:u[0];Y<x&&!S&&!r&&(S=!0,be("history")),K()}clearTimeout(g)},100)}),t==null||t.on("highlight",o=>{var d,f;let x=o.dataIndex||-1;o.batch&&(x=typeof((d=o==null?void 0:o.batch[0])==null?void 0:d.dataIndex)=="number"?(f=o==null?void 0:o.batch[0])==null?void 0:f.dataIndex:-1),clearTimeout(m),m=setTimeout(()=>{B.value=x,clearTimeout(m)},20)}),t==null||t.on("globalout",()=>{const o=setTimeout(()=>{var d,f,a;clearTimeout(o);const x=(a=(f=(d=t==null?void 0:t.getOption())==null?void 0:d.dataZoom)==null?void 0:f[0])==null?void 0:a.endValue;B.value=x},30)});let s=null;t==null||t.on("contextmenu",o=>{s=setTimeout(()=>{o.componentType==="graphic"&&(G.value=o.info,ne.value=[{label:"删除画线",key:"deleteWarningLine"},{label:"修改画线",key:"changeWarningLine"}]),clearTimeout(s),s=null})})},ee=async()=>{const s=await Ee({featureId:i.featureId});H.value=(s==null?void 0:s.body)||[],K(),w("change","warningLine",H.value)},he=async s=>{const{variety:o,varietyName:x,featureId:d,featureType:f}=i;if(s.key==="drawWarningLine"){const a=t==null?void 0:t.getOption(),u=a.tooltip[0];t==null||t.setOption({...a,tooltip:{...u,axisPointer:{...u.axisPointer,lineStyle:{width:0},crossStyle:{width:2},label:{...u.axisPointer.label,backgroundColor:"transparent",formatter:()=>""}}}});const Y=async L=>{t==null||t.getZr().off("mousedown",Y);const y=t==null?void 0:t.convertFromPixel({yAxisIndex:0},L.offsetY),T=Math.round(y*1e3)/1e3;t==null||t.setOption({...a,tooltip:{...u,axisPointer:{...u.axisPointer,lineStyle:{width:1},crossStyle:{width:1},label:{...u.axisPointer.label,backgroundColor:null}}}}),await Ne({featureCode:o,featureName:x,featureId:d,featureType:f,warnPrice:T}),te.ElMessage.success("画线预警成功!"),ee()};t==null||t.getZr().on("mousedown",Y)}else s.key==="deleteWarningLine"?(await qe({id:G.value.id}),te.ElMessage.success("画线预警删除成功"),ee()):s.key==="changeWarningLine"&&(J.value=!0,Q.value=G.value.warnPrice)},ke=async()=>{const{variety:s,varietyName:o,featureId:x,featureType:d}=i;await fe({id:G.value.id,featureCode:s,featureName:o,featureId:x,featureType:d,warnPrice:Q.value}),te.ElMessage.success("画线预警修改成功"),ee()},we=()=>{ne.value=[...l]};return e.onMounted(()=>{Fe(i.env),ae(),window.addEventListener("keydown",ie)}),e.watch(()=>{var s,o;return[i.variety,i.cycle,i.mainIndicator,v.value,(s=i.indicatorStore)==null?void 0:s.filterIndicator,(o=i.indicatorStore)==null?void 0:o.customIndicator]},()=>{S=!1,r=!1,ae()},{deep:!0}),e.onUnmounted(()=>{h&&(cancelAnimationFrame(h),h=null),c&&(cancelAnimationFrame(c),c=null),t==null||t.off("datazoom"),t==null||t.off("highlight"),t==null||t.off("globalout"),t==null||t.dispose(),p==null||p.dispose(),window.removeEventListener("keydown",ie)}),k({draw:(s,o)=>{s==="warningLine"&&(H.value=o,K())}}),(s,o)=>{var L;const x=ce.ElMenuItem,d=ce.ElMenu,f=Ve.ElEmpty,a=De.ElButton,u=Se.ElInputNumber,Y=Ye.ElDialog;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"klineBasic",onMousemove:o[1]||(o[1]=y=>M.value=!0),onMouseout:o[2]||(o[2]=y=>M.value=!1)},[e.createElementVNode("div",Je,[e.createVNode($e,{variety:n.variety,data:F.value,activeIndex:B.value},null,8,["variety","data","activeIndex"])]),e.createElementVNode("div",{class:"klineBasic-main",style:e.normalizeStyle({height:R.value.showSubChart?"70%":"100%"})},[e.createVNode(Ge,{onCloseContextMenuCallBack:we},{popover:e.withCtx(()=>[e.createVNode(d,{style:{borderRadius:"4px",overflow:"hidden",background:"#fff",borderRight:0}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ne.value,y=>(e.openBlock(),e.createBlock(x,{style:{height:"36px"},key:y.key,index:y.key,onClick:T=>he(y)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.label),1)]),_:2},1032,["index","onClick"]))),128))]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"klineBasicMainRef",ref:A,style:{height:"100%"}},null,512)]),_:1})],4),R.value.showSubChart?(e.openBlock(),e.createElementBlock("div",Qe,[e.createVNode(Ke,{ref_key:"klineSubRef",ref:j,modelValue:v.value,"onUpdate:modelValue":o[0]||(o[0]=y=>v.value=y),data:F.value,cycle:n.cycle,activeIndex:B.value,subIndicatorList:(L=n.indicatorStore)==null?void 0:L.subIndicatorList},null,8,["modelValue","data","cycle","activeIndex","subIndicatorList"])])):e.createCommentVNode("",!0),D.value?(e.openBlock(),e.createElementBlock("div",et,[e.createVNode(f,{class:"klineBasic-empty-content",description:"暂无数据"})])):e.createCommentVNode("",!0),q.value?(e.openBlock(),e.createElementBlock("div",tt,[nt,e.createElementVNode("div",ot,[e.createVNode(a,{onClick:ae},{default:e.withCtx(()=>[e.createTextVNode("刷新")]),_:1})])])):e.createCommentVNode("",!0)],32),e.createVNode(Y,{modelValue:J.value,"onUpdate:modelValue":o[5]||(o[5]=y=>J.value=y),title:"画线预警-修改价格",width:"30%","align-center":""},{footer:e.withCtx(()=>[e.createElementVNode("span",lt,[e.createVNode(a,{onClick:o[4]||(o[4]=y=>J.value=!1)},{default:e.withCtx(()=>[e.createTextVNode("取消")]),_:1}),e.createVNode(a,{type:"primary",onClick:ke},{default:e.withCtx(()=>[e.createTextVNode("确定")]),_:1})])]),default:e.withCtx(()=>[at,e.createVNode(u,{modelValue:Q.value,"onUpdate:modelValue":o[3]||(o[3]=y=>Q.value=y),placeholder:"输入预警价格"},null,8,["modelValue"])]),_:1},8,["modelValue"])],64)}}},it=U._export_sfc(rt,[["__scopeId","data-v-8efc10f3"]]),st={install(n){n.component("st-klineBasic",it)}};module.exports=st;