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