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