cnhis-design-vue 3.1.51-release.1 → 3.1.51-release.3
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/README.md +87 -87
- package/es/components/base-search/src/index.vue2.js +1 -1
- package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
- package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +1 -0
- package/es/components/bpmn-workflow/types/ModelingModule.d.ts +1 -0
- package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +1 -0
- package/es/components/callback/index.d.ts +69 -0
- package/es/components/callback/index.js +1 -0
- package/es/components/callback/src/components/dialog/drawer.vue.d.ts +353 -0
- package/es/components/callback/src/components/dialog/drawer.vue.js +1 -0
- package/es/components/callback/src/components/dialog/drawer.vue2.js +1 -0
- package/es/components/callback/src/components/dialog/modal.vue.d.ts +166 -0
- package/es/components/callback/src/components/dialog/modal.vue.js +1 -0
- package/es/components/callback/src/components/dialog/modal.vue2.js +1 -0
- package/es/components/callback/src/components/popup/index.vue.d.ts +48 -0
- package/es/components/callback/src/components/popup/index.vue.js +1 -0
- package/es/components/callback/src/components/render/drawerIframe/index.vue.d.ts +62 -0
- package/es/components/callback/src/components/render/drawerIframe/index.vue.js +1 -0
- package/es/components/callback/src/components/render/drawerIframe/index.vue2.js +1 -0
- package/es/components/callback/src/components/render/enums.d.ts +5 -0
- package/es/components/callback/src/components/render/enums.js +1 -0
- package/es/components/callback/src/components/render/index.vue.d.ts +57 -0
- package/es/components/callback/src/components/render/index.vue.js +1 -0
- package/es/components/callback/src/components/render/popupMaps.d.ts +5702 -0
- package/es/components/callback/src/components/render/popupMaps.js +1 -0
- package/es/components/callback/src/index.vue.d.ts +68 -0
- package/es/components/callback/src/index.vue.js +1 -0
- package/es/components/callback/src/index.vue2.js +1 -0
- package/es/components/callback/src/types/index.d.ts +11 -0
- package/es/components/callback/style/callback-iconfont.ttf +0 -0
- package/es/components/callback/style/index.css +1 -0
- package/es/components/classification/src/index.vue2.js +1 -1
- package/es/components/expand-field/index.d.ts +0 -13
- package/es/components/expand-field/src/components/FormItemPerson.vue.d.ts +0 -13
- package/es/components/expand-field/src/components/PersonModal.vue.d.ts +0 -13
- package/es/components/expand-field/src/components/PersonModal.vue2.js +1 -1
- package/es/components/expand-field/src/components/form.vue.d.ts +0 -13
- package/es/components/expand-field/src/components/form.vue2.js +1 -1
- package/es/components/expand-field/src/index.vue.d.ts +0 -13
- package/es/components/expand-field/src/index.vue2.js +1 -1
- package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcessChart.js +1 -1
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useCenter.js +1 -1
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useOther.js +1 -1
- package/es/components/fabric-chart/src/hooks/temperature/useTemperatureChart.js +1 -1
- package/es/components/form-config/index.d.ts +6 -2
- package/es/components/form-config/src/FormConfig.vue.d.ts +6 -2
- package/es/components/form-config/src/components/FormConfigCreator.vue.d.ts +3 -1
- package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +3 -1
- package/es/components/form-render/index.d.ts +3 -1
- package/es/components/form-render/src/FormRender.vue.d.ts +3 -1
- package/es/components/form-render/src/FormRender.vue2.js +1 -1
- package/es/components/form-render/src/FormRenderWrapper.vue.d.ts +3 -1
- package/es/components/form-render/src/components/renderer/remoteSearch.d.ts +79 -2
- package/es/components/form-render/src/components/renderer/remoteSearch.js +1 -1
- package/es/components/form-render/src/components/renderer/select.js +1 -1
- package/es/components/form-render/src/hooks/useFormEvent.d.ts +3 -1
- package/es/components/form-render/src/hooks/useFormEvent.js +1 -1
- package/es/components/form-render/src/hooks/useFormRenderOptions.d.ts +16 -10
- package/es/components/form-render/src/hooks/useFormRenderOptions.js +1 -1
- package/es/components/form-render/src/types/index.d.ts +4 -1
- package/es/components/iho-table/src/plugins/keyboardEventPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/hooks/useSelectOption.d.ts +2 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/hooks/useSelectOption.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/editSelect.d.ts +27 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/editSelect.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/selectUtils.d.ts +2 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/selectUtils.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/separateUtils.d.ts +4 -3
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/separateUtils.js +1 -1
- package/es/components/iho-table/src/plugins/varialbleHeightPlugin/index.js +1 -1
- package/es/components/iho-table/src/types/index.d.ts +8 -1
- package/es/components/index.css +1 -1
- package/es/components/index.d.ts +5 -3
- package/es/components/index.js +1 -1
- package/es/components/info-header/index.d.ts +6 -2
- package/es/components/info-header/src/InfoHeader.vue.d.ts +6 -2
- package/es/components/info-header/src/components/infoDescription/index.vue.d.ts +3 -1
- package/es/components/info-header/src/components/patientInfo/index.vue.d.ts +3 -1
- package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
- package/es/components/scale-view/src/hooks/use-component.d.ts +615 -255
- package/es/components/select-label/index.d.ts +617 -256
- package/es/components/select-label/index.js +1 -1
- package/es/components/select-label/src/LabelFormContent.vue2.js +1 -1
- package/es/components/{iho-select-label/src/LabelFormContent.vue.d.ts → select-label/src/ihoLabel/IhoLabelFormContent.vue.d.ts} +5 -5
- package/es/components/select-label/src/ihoLabel/IhoLabelFormContent.vue.js +1 -0
- package/es/components/select-label/src/ihoLabel/IhoLabelFormContent.vue2.js +1 -0
- package/es/components/{iho-select-label/src/SelectLabel.vue.d.ts → select-label/src/ihoLabel/IhoSelectLabel.vue.d.ts} +7 -7
- package/es/components/select-label/src/ihoLabel/IhoSelectLabel.vue.js +1 -0
- package/es/components/select-label/src/ihoLabel/IhoSelectLabel.vue2.js +1 -0
- package/es/components/{iho-select-label/src/components/label-classify.vue.d.ts → select-label/src/ihoLabel/iho-label-classify.vue.d.ts} +1 -1
- package/es/components/select-label/src/ihoLabel/iho-label-classify.vue.js +1 -0
- package/es/components/select-label/src/ihoLabel/iho-label-classify.vue2.js +1 -0
- package/es/components/select-label/src/index.vue.d.ts +899 -0
- package/es/components/select-label/src/index.vue.js +1 -0
- package/es/components/select-label/src/index.vue2.js +1 -0
- package/es/components/select-person/src/SearchMultiple.vue.d.ts +0 -6
- package/es/components/shortcut-provider/src/hooks/useShortcuts.d.ts +1 -0
- package/es/components/shortcut-provider/src/hooks/useShortcuts.js +1 -1
- package/es/components/shortcut-setter/index.d.ts +4 -1
- package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +4 -1
- package/es/components/slider-tree/index.d.ts +153 -0
- package/es/components/slider-tree/index.js +1 -0
- package/es/components/slider-tree/src/hooks/useAsyncData.d.ts +6 -0
- package/es/components/slider-tree/src/hooks/useAsyncData.js +1 -0
- package/es/components/slider-tree/src/index.vue.d.ts +152 -0
- package/es/components/slider-tree/src/index.vue.js +1 -0
- package/es/components/slider-tree/src/index.vue2.js +1 -0
- package/es/components/slider-tree/src/utils/index.d.ts +1 -0
- package/es/components/slider-tree/src/utils/index.js +1 -0
- package/es/components/slider-tree/style/index.css +1 -0
- package/es/components/table-export-field/src/components/ExportModal.vue.d.ts +3 -0
- package/es/components/table-filter/src/components/render-widget/components/SelectDynamicOption/index.vue2.js +1 -1
- package/es/components/table-filter/src/hooks/useAdvanced.js +1 -1
- package/es/env.d.ts +25 -25
- package/es/shared/assets/img/failure.png.js +1 -1
- package/es/shared/assets/img/no-permission.png.js +1 -1
- package/es/shared/assets/img/nodata.png.js +1 -1
- package/es/shared/assets/img/notfound.png.js +1 -1
- package/es/shared/assets/img/qr.png.js +1 -1
- package/es/shared/assets/img/success.png.js +1 -1
- package/es/shared/assets/img/video.png.js +1 -1
- package/es/shared/assets/img/video_default_cover.png.js +1 -1
- package/es/shared/assets/img/xb_big.png.js +1 -1
- package/es/shared/assets/img/xb_small.png.js +1 -1
- package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +86 -0
- package/es/shared/directive/flexibleResize.d.ts +4 -0
- package/es/{components/classification/src → shared}/directive/flexibleResize.js +1 -1
- package/es/shared/directive/index.d.ts +1 -0
- package/es/shared/directive/index.js +1 -0
- package/es/shared/package.json.js +1 -1
- package/es/shared/types/business.d.ts +7 -0
- package/es/shared/utils/fabricjs/index.d.ts +6823 -0
- package/es/shared/utils/index.d.ts +3 -3
- package/es/shared/utils/index.js +1 -1
- package/es/shared/utils/tapable/index.d.ts +139 -0
- package/package.json +2 -2
- package/es/components/classification/src/directive/flexibleResize.d.ts +0 -28
- package/es/components/iho-select-label/index.d.ts +0 -363
- package/es/components/iho-select-label/index.js +0 -1
- package/es/components/iho-select-label/src/LabelFormContent.vue.js +0 -1
- package/es/components/iho-select-label/src/LabelFormContent.vue2.js +0 -1
- package/es/components/iho-select-label/src/SelectLabel.vue.js +0 -1
- package/es/components/iho-select-label/src/SelectLabel.vue2.js +0 -1
- package/es/components/iho-select-label/src/components/label-classify.vue.js +0 -1
- package/es/components/iho-select-label/src/components/label-classify.vue2.js +0 -1
- package/es/components/iho-select-label/style/iho-select-label-iconfont.ttf +0 -0
- package/es/components/iho-select-label/style/index.css +0 -1
- package/es/components/table-filter/src/types/tool.d.ts +0 -7
- /package/es/components/{iho-select-label → callback}/src/types/index.js +0 -0
- /package/es/components/{iho-select-label → select-label}/src/types/index.d.ts +0 -0
- /package/es/components/{table-filter/src/types/tool.js → select-label/src/types/index.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{onUnmounted as e}from"vue";import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{defaultStyle as n,drawLine as o,drawPoint as i}from"../useDraw.js";import{useGrid as l}from"../useGrid.js";import{useBirthProcessCumputedPoint as r}from"../useCumputedPoint.js";import{bus as a}from"../useEvent.js";import{useCommon as s}from"../useCommon.js";import{getPointRange as f,getIndex as u,isEffectiveNode as c,getTime as p}from"../../utils/index.js";import{cloneDeep as d,omit as m}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";import"naive-ui";import{useIntervalFn as v}from"@vueuse/core";function y(y,g,h,k,x){const{cumputedX:L,cumputedY:P,getXValue:w,getYValue:b}=r(g),{xCellWidth:A,pointSelectionStyle:C,originX:K,endX:j,originY:E,endY:I,event:T,scaleValues:M,xAxis:S,startTime:V,timeXCell:X,itemList:$,dialog:O}=g,Y=new Map,D=new Set,_=d(M);let N=[],z=null;const G=new Set;l(y,g);const{getEqualXTypes:J,handleAddPrevent:q,setPrevAndNextPoint:F}=s(y,h,g),{pause:R,resume:W}=v((()=>{!function(){for(const e of G)e.set("opacity",1===e.opacity?.5:1),y.value.renderAll()}()}),800);function B(){_.forEach((e=>{e.dataList.forEach(((t,n)=>{t.show&&(!function(e,t){const{max:n={},min:i={}}=e.panicValue||{},{max:l={},min:r={}}=e.diffValue||{};function a({show:e=!1,value:n,name:i,lineStyle:l}){if(!e||!n)return;const r=P(t.type,t.range,n),a=o([K,r,j,r],{...l,evented:!0,lockMovementX:!0,lockMovementY:!0,hoverCursor:"pointer"});T.hovered&&i&&(a.on("mousemove",(({pointer:e})=>{k.point={...e||{x:a.left,y:a.top}},k.list=[`${i} ${n}${t.unit||""}`],k.show=!0})),a.on("mouseout",(()=>{k.show=!1}))),y.value.add(a)}a(n),a(i),a(l),a(r)}(t,e),Z(t,n,e))}))}))}function H(e=[]){if(!(null==z?void 0:z.areaPos))return[];const{startPos:t,endPos:n}=z.areaPos,[o,i]=[t.x,n.x].sort(((e,t)=>e-t)),[l,r]=[t.y,n.y].sort(((e,t)=>e-t));return(e.length?e:ae()).filter((e=>e.left>=o&&e.left<=i&&e.top>=l&&e.top<=r))}function Q(e){O.warning({maskClosable:!1,closeOnEsc:!1,title:"警告",content:"确认删除当前选中的节点?",positiveText:"确定",negativeText:"取消",onPositiveClick:()=>{e(),U()},onNegativeClick:()=>U(),onClose:()=>U()})}function U(){z&&y.value.remove(z),z=null}function Z(e,t,n){var l;const{type:r,unit:a,dataList:s=[]}=n,f=[];Y.set(e.key,[]),function(e,t){G.size&&[...G].forEach((n=>{const{dataIndex:o,type:i}=n.origin;o===t&&i===e&&G.delete(n)}))}(r,t),null==(l=e.list)||l.forEach(((l,u)=>{!function(e,l,u,c){var p;let d,v,x=c;l.key&&(x=s.find((e=>e.key===l.key)));const{pointAttr:L={},lineAttr:P={},title:C="",key:K,type:j="circle"}=x,E=re(c.list[u+1],n);e&&E&&!l.breakpoint&&e[0]!==E[0]&&(v=o([...e,...E],P));const I=f[u-1],M={origin:{data:l,title:C,key:c.key,selfKey:K,unit:a,type:r,dataIndex:t,index:u,lineAttr:P},__type:"main",leftLine:I,rightLine:v,...L,...g.event.hovered?g.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:g.event};I?d=i(j,{left:I.get("x2"),top:I.get("y2"),...M}):e&&(M.leftLine=null,d=i(j,{left:e[0],top:e[1],...M}));f.push(v),d&&(d.originLeft=d.left,d.originTop=d.top,function(e){T.hovered&&(e.on("mouseover",(()=>{ie(e,"hover")})),e.on("mouseout",(()=>{k.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{le(e),function(e){var t,n;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(n=e.rightLine)||n.setCoords().set({x1:e.left,y1:e.top})}(e),T.hovered&&ie(e),function(e){const{originLeft:t,originTop:n,left:o,top:i,origin:l}=e,r=~~((o-t)/A);if(o>t+A&&!e.nextPoint){if(0===N.length){ee(e,[...e.leftLine?[e.leftLine.x1,e.leftLine.y1]:[t,n],t,n]),e.leftLine&&e.leftLine.set({stroke:"transparent"})}const o=t+A*r;if(N.every((e=>e.left!==o))){const t=w(o),n=b(l.type,i);N.push({data:{time:t,value:n,...l.selfKey!==l.key?{key:l.selfKey}:{}},left:o,top:i}),ee(e,[...e.prevPointer,o,i])}N.length<r&&function(e,t){const{originLeft:n,originTop:o,origin:i}=e;let l=1;for(;l<=t;){const t=n+A*l,r=N.some((e=>Math.abs(e.left-t)<=1));if(!r){let l=0;const r=N.find(((e,n)=>(e.left>t&&(l=n),e.left>t)));if(r){const a=JSON.parse(JSON.stringify(r)),s=N[l-1]||{left:n,top:o},f=~~((r.left-(t-A))/A),u=(r.top-s.top)/f;a.top=s.top+u,a.left=t,a.data={time:w(t),value:b(i.type,a.top),...i.selfKey!==i.key?{key:i.selfKey}:{}},N.splice(l,0,a),ee(e,[s.left,s.top,a.left,a.top])}}l++}}(e,r)}if(N.length>0&&o<N[N.length-1].left){for(const e of D)e.left>o&&(e.leftLine&&y.value.remove(e.leftLine),y.value.remove(e));if(N=N.filter((e=>e.left<=o)),0===N.length){e.leftLine&&e.leftLine.set(e.origin.lineAttr);for(const e of D)e.leftLine&&y.value.remove(e.leftLine),y.value.remove(e)}if(N.length>0){const t=N.at(-1);e.prevPointer=[t.left,t.top]}}}(e)})),e.on("mouseup",(t=>{if(k.show=!1,1===t.button){const{type:t,selfKey:n}=e.origin,o={...e.origin,data:{...e.origin.data,time:w(e.left),value:b(t,e.top)}};if(y.value.discardActiveObject(),N.length>0){const e=N.map((e=>e.data)),i=_.find((e=>e.type===t)),l=i.dataList.findIndex((e=>e.key===n));h("add",{...m(o,["index","selfKey","lineAttr"]),dataIndex:l,key:n,data:e}),te({...o,data:e})}else h("change",{...m(o,["selfKey","lineAttr"]),key:n}),te(o,"change")}}))}(d),null==(p=Y.get(c.key))||p.push(d))}(re(l,n),l,u,e)})),Promise.all(Y.get(e.key)).then((t=>{const n=f.filter((e=>e));F(t),y.value.add(...n,...t),function(e,t){const{max:n={},min:o={}}=t.panicValue||{},{max:i={},min:l={}}=t.diffValue||{};function r({show:t=!1,value:n,flickerable:o},i){!t&&n&&o&&e.forEach((e=>{const t=e.origin.data.value;"max"===i&&t<n||"min"===i&&t>n||G.add(e)}))}r(n,"max"),r(o,"min"),r(i,"max"),r(l,"min")}(t,e)}))}function ee(e,t){const[,,n,i]=t;e.clone((l=>{l.set({left:n,top:i}),e.prevPointer=[n,i];const r=o(t,e.origin.lineAttr);l.leftLine=r,D.add(l),y.value.add(r,l)}))}function te(e,t="add",n=1){const{data:o,index:i,key:l,type:r}=e;let{dataIndex:a}=e;const s=_.find((e=>e.type===r)),f=s.dataList.find(((e,t)=>(a=t,e.key===l)));switch(t){case"remove":f.list.splice(i,n);break;case"change":f.list[i]=o;break;default:{const e=Array.isArray(o)?o[0].time:o.time,t=u(e,f.list),n=Array.isArray(o)?o:[o];f.list.splice(t,0,...n);break}}ne({dataIndex:a,scaleValue:s})}function ne(e){var t,n,o;if(D.size&&(null==(t=y.value)||t.remove(...oe([...D]))),D.clear(),N=[],e){const{dataIndex:t,scaleValue:o}=e,i=o.dataList[t];null==(n=y.value)||n.remove(...oe(Y.get(i.key))),Y.delete(i.key),Z(i,t,o)}else Y.size&&(null==(o=y.value)||o.remove(...oe(ae()))),Y.clear(),B()}function oe(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine)})),t}function ie(e,t="moving"){const{title:n,type:o,data:i,unit:l}=e.origin;k.point={x:e.left,y:e.top};const r=`${"hover"===t?i.value:b(o,e.top)}`;k.list=[`${n} ${r}${l||""}`,`时间 ${w(e.left).slice(-5)}`],k.show=!0}function le(e){e.setCoords();const t=6e4/X,n=e.prevPoint?e.prevPoint.left+t:K,o=e.nextPoint?e.nextPoint.left-t:j;e.top<E&&e.set("top",E),e.top>I&&e.set("top",I),e.left<n&&e.set("left",n),e.left>o&&e.set("left",o)}function re(e,t){if(c(e)&&function(e){const t=Date.parse(S.list.at(-1)),n=p(e);return n>=V&&n<=t}(e.time)){const n=L(e.time),o=P(t.type,t.range,e.value);return[n,o<E?E:o>I?I:o]}}function ae(){return Array.from(Y.values()).flat()}return e((()=>{R()})),B(),function(){if(!T.evented)return;let e=!1,o={x:0,y:0};y.value.on("mouse:up",(t=>{if(3===t.button&&function(e){const{x:t=0,y:n=0}=e.pointer||{};if(t>=K&&t<=j&&n>=E&&n<=I)if(e.target){if("main"!==e.target.__type)return;o(e.pointer,e.target,["删除节点"]);const{minLeft:t,maxLeft:n,minTop:i,maxTop:l}=f(e.target);ae().forEach((o=>{"main"===o.__type&&o.left>t&&o.left<n&&o.top>i&&o.top<l&&x.list.push({renderItem:()=>o.origin.title,origin:{...o.origin},mode:"remove",pointer:e.pointer})})),1===x.list.length&&(x.show=!1,console.log("当前时间段内无可删除节点"))}else o(e.pointer,null,["新增节点"]),$.forEach((n=>{J(ae(),t,"key",2*A).includes(n.linkKey||n.key)||x.list.push({renderItem:()=>n.title,origin:{title:n.title,unit:n.unit,type:n.bigType,dataIndex:n.dataIndex,key:n.key,linkKey:n.linkKey},pointer:e.pointer})})),1===x.list.length&&(x.show=!1,q("repeat"),console.log("当前时间段内无可新增节点"));function o(e,t,n){Object.assign(x,{point:e,show:!0,target:t,list:n})}}(t),1===t.button&&e){e=!1;const t=H();t.length>0?Q((()=>{const e=function(e){const t=e.reduce(((e,t)=>{const{key:n}=t.origin;return e[n]=e[n]?e[n].concat(t.origin):[t.origin],e}),{});return Object.keys(t).map((e=>{const n=t[e].sort(((e,t)=>Date.parse(e.data.time)-Date.parse(t.data.time)));return te(n[0],"remove",n.length),n.map((e=>({...m(e,["selfKey","lineAttr"]),key:e.selfKey})))}))}(t);h("remove",e)})):a.emit(z)}})),y.value.on("mouse:down",(t=>{1!==t.button||t.target||(e=!0,o=t.pointer)})),y.value.on("mouse:move",(i=>{if(!e)return;const{x:l,y:r}=o,{x:a,y:s}=i.pointer;z&&y.value.remove(z),z=new t.Rect({...n,fill:"#CAF982",opacity:.4,...C,left:l,top:r,width:a-l,height:s-r,objectCaching:!0}),z.areaPos={startPos:o,endPos:i.pointer},y.value.add(z)}))}(),{redrawPoints:ne,clickMenu:function({item:e,target:t}){const n={...e.origin};"remove"===e.mode?(h("remove",n),te(n,"remove")):(Object.assign(n,{data:{time:w(e.pointer.x),value:b(e.origin.type,e.pointer.y),...e.origin.linkKey?{key:e.origin.key}:{}}}),h("add",n),te({...n,key:e.origin.linkKey||e.origin.key}))},moveLimit:le,setPopup:ie,updateData:te,getGridPoints:ae,getContainPoints:H,showDialog:Q,removeCurrentSelection:U}}export{y as useCenter};
|
|
1
|
+
import{onUnmounted as e}from"vue";import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{defaultStyle as n,drawLine as i,drawPoint as o}from"../useDraw.js";import{useGrid as l}from"../useGrid.js";import{useBirthProcessCumputedPoint as r}from"../useCumputedPoint.js";import{bus as a}from"../useEvent.js";import{useCommon as s}from"../useCommon.js";import{getPointRange as f,getIndex as c,isEffectiveNode as u,getTime as d}from"../../utils/index.js";import{cloneDeep as p,omit as m}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";import"naive-ui";import{useIntervalFn as v}from"@vueuse/core";function g(g,y,h,k,x){const{cumputedX:L,cumputedY:P,getXValue:b,getYValue:w}=r(y),{xCellWidth:A,pointSelectionStyle:I,originX:C,endX:K,originY:j,endY:E,event:X,scaleValues:M,xAxis:T,startTime:V,timeXCell:Y,itemList:S,dialog:$}=y,F=new Map,O=new Set,D=p(M);let _=[],z=null;const N=new Set;l(g,y);const{getEqualXTypes:G,handleAddPrevent:J,setPrevAndNextPoint:q}=s(g,h,y),{pause:R,resume:W}=v((()=>{!function(){if(!N.size)return;for(const e of N)e.set("opacity",1===e.opacity?.5:1);g.value.renderAll()}()}),800);function B(){D.forEach((e=>{e.dataList.forEach(((t,n)=>{t.show&&(!function(e,t){const{max:n={},min:o={}}=e.panicValue||{},{max:l={},min:r={}}=e.diffValue||{};function a({show:e=!1,value:n,name:o,lineStyle:l}){if(!e||!n)return;const r=P(t.type,t.range,n),a=i([C,r,K,r],{...l,evented:!0,lockMovementX:!0,lockMovementY:!0,hoverCursor:"pointer"});X.hovered&&o&&(a.on("mousemove",(({pointer:e})=>{k.point={...e||{x:a.left,y:a.top}},k.list=[`${o} ${n}${t.unit||""}`],k.show=!0})),a.on("mouseout",(()=>{k.show=!1}))),g.value.add(a)}a(n),a(o),a(l),a(r)}(t,e),Z(t,n,e))}))}))}function H(e=[]){if(!(null==z?void 0:z.areaPos))return[];const{startPos:t,endPos:n}=z.areaPos,[i,o]=[t.x,n.x].sort(((e,t)=>e-t)),[l,r]=[t.y,n.y].sort(((e,t)=>e-t));return(e.length?e:se()).filter((e=>e.left>=i&&e.left<=o&&e.top>=l&&e.top<=r))}function Q(e){$.warning({maskClosable:!1,closeOnEsc:!1,title:"警告",content:"确认删除当前选中的节点?",positiveText:"确定",negativeText:"取消",onPositiveClick:()=>{e(),U()},onNegativeClick:()=>U(),onClose:()=>U()})}function U(){z&&g.value.remove(z),z=null}function Z(e,t,n){var l;const{type:r,unit:a,dataList:s=[]}=n,f=[];F.set(e.key,[]),function(e,t){N.size&&[...N].forEach((n=>{const{dataIndex:i,type:o}=n.origin;i===t&&o===e&&N.delete(n)}))}(r,t),null==(l=e.list)||l.forEach(((l,c)=>{!function(e,l,c,u){var d;let p,v,x=u;l.key&&(x=s.find((e=>e.key===l.key)));const{pointAttr:L={},lineAttr:P={},title:I="",key:C,type:K="circle"}=x,j=ae(u.list[c+1],n);e&&j&&!l.breakpoint&&e[0]!==j[0]&&(v=i([...e,...j],P));const E=f[c-1],M={origin:{data:l,title:I,key:u.key,selfKey:C,unit:a,type:r,dataIndex:t,index:c,lineAttr:P},__type:"main",leftLine:E,rightLine:v,...L,...y.event.hovered?y.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:y.event};E?p=o(K,{left:E.get("x2"),top:E.get("y2"),...M}):e&&(M.leftLine=null,p=o(K,{left:e[0],top:e[1],...M}));f.push(v),p&&(p.originLeft=p.left,p.originTop=p.top,function(e){X.hovered&&(e.on("mouseover",(()=>{le(e,"hover")})),e.on("mouseout",(()=>{k.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{re(e),function(e){var t,n;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(n=e.rightLine)||n.setCoords().set({x1:e.left,y1:e.top})}(e),X.hovered&&le(e),function(e){var t,n,i,o;const{originLeft:l,originTop:r,left:a,top:s,origin:f}=e,c=~~((a-l)/A);if(a>l+A){if(0===_.length){te(e,[...e.leftLine?[e.leftLine.x1,e.leftLine.y1]:[l,r],l,r]),null==(n=null==(t=e.leftLine)?void 0:t.set)||n.call(t,"stroke","transparent"),null==(o=null==(i=e.rightLine)?void 0:i.set)||o.call(i,"stroke","transparent")}const u=l+A*c;if(_.every((e=>e.left!==u))){const t=b(u),n=w(f.type,s);_.push({data:{time:t,value:n,...f.selfKey!==f.key?{key:f.selfKey}:{}},left:u,top:s}),te(e,[...e.prevPointer,u,s])}if(_.length<c&&function(e,t){const{originLeft:n,originTop:i,origin:o}=e;let l=1;for(;l<=t;){const t=n+A*l,r=_.some((e=>Math.abs(e.left-t)<=1));if(!r){let l=0;const r=_.find(((e,n)=>(e.left>t&&(l=n),e.left>t)));if(r){const a=JSON.parse(JSON.stringify(r)),s=_[l-1]||{left:n,top:i},f=~~((r.left-(t-A))/A),c=(r.top-s.top)/f;a.top=s.top+c,a.left=t,a.data={time:b(t),value:w(o.type,a.top),...o.selfKey!==o.key?{key:o.selfKey}:{}},_.splice(l,0,a),te(e,[s.left,s.top,a.left,a.top])}}l++}}(e,c),e.nextPoint){const t=F.get(f.key);!function(e,t){const{left:n,top:i,origin:o}=t,l=A/2,r=e.findIndex((e=>Math.abs(n-e.left)<l&&Math.abs(i-e.top)<l&&o.index!==e.origin.index));r>-1?(t.set({scaleX:2.5,scaleY:2.5}),t.coincidePoint=e[r]):t.set({scaleX:t.scale,scaleY:t.scale})}(t,e),null==t||t.forEach((e=>{e.left<=l||f.index===e.origin.index||(e.left<a?ee(e,"#999"):ee(e,e.origin.lineAttr.stroke))}))}}!function(e){var t,n;const{left:i}=e;if(_.length>0&&i<_[_.length-1].left){for(const e of O)e.left>i&&(e.leftLine&&g.value.remove(e.leftLine),g.value.remove(e));if(_=_.filter((e=>e.left<=i)),0===_.length){null==(n=null==(t=e.leftLine)?void 0:t.set)||n.call(t,e.origin.lineAttr);for(const e of O)e.leftLine&&g.value.remove(e.leftLine),g.value.remove(e)}if(_.length>0){const t=_.at(-1);e.prevPointer=[t.left,t.top]}}}(e)}(e)})),e.on("mouseup",(t=>{if(k.show=!1,1===t.button){const{type:t,selfKey:n,dataIndex:i}=e.origin,o={...e.origin,data:{...e.origin.data,time:b(e.left),value:w(t,e.top)}};if(g.value.discardActiveObject(),_.length>0){const l=D.find((e=>e.type===t));let r=-1;const a=_.map((e=>e.data));if(e.nextPoint){if(2.5!==e.scaleX)return void ie({dataIndex:i,scaleValue:l});const t=e.coincidePoint.origin,n=t.data;r=t.index;const o=a.findIndex((e=>e.time===n.time));o>-1?a[o].value=n.value:a.push({...a.at(-1),time:n.time,value:n.value})}const s=l.dataList.findIndex((e=>e.key===n));h("add",{...m(o,["index","selfKey","lineAttr"]),dataIndex:s,key:n,data:a}),ne({...o,data:a,coincideIndex:r})}else h("change",{...m(o,["selfKey","lineAttr"]),key:n}),ne(o,"change")}}))}(p),null==(d=F.get(u.key))||d.push(p))}(ae(l,n),l,c,e)})),Promise.all(F.get(e.key)).then((t=>{const n=f.filter((e=>e));q(t),g.value.add(...n,...t),function(e,t){const{max:n={},min:i={}}=t.panicValue||{},{max:o={},min:l={}}=t.diffValue||{};function r({show:t=!1,value:n,flickerable:i},o){!t&&n&&i&&e.forEach((e=>{const t=e.origin.data.value;"max"===o&&t<n||"min"===o&&t>n||N.add(e)}))}r(n,"max"),r(i,"min"),r(o,"max"),r(l,"min")}(t,e)}))}function ee(e,t){["stroke","fill"].forEach((n=>{const i=e[n];i&&!["transparent","#fff","#ffffff","#FFFFFF"].includes(i)&&i!==t&&e.set(n,t)})),e.rightLine&&e.rightLine.stroke!==t&&e.rightLine.set("stroke",t)}function te(e,t){const[,,n,o]=t;e.clone((l=>{l.set({left:n,top:o,scaleX:1,scaleY:1}),e.prevPointer=[n,o];const r=i(t,e.origin.lineAttr);l.leftLine=r,O.add(l),g.value.add(r,l)}))}function ne(e,t="add",n=1){const{data:i,index:o,key:l,type:r,coincideIndex:a}=e;let{dataIndex:s}=e;const f=D.find((e=>e.type===r)),u=f.dataList.find(((e,t)=>(s=t,e.key===l)));switch(t){case"remove":u.list.splice(o,n),u.list[o-1]&&(u.list[o-1].breakpoint=!0);break;case"change":u.list[o]=i;break;default:{const e=Array.isArray(i)?i[0].time:i.time,t=c(e,u.list),n=Array.isArray(i)?i:[i];u.list.splice(t,a>-1?a-t+1:0,...n);break}}ie({dataIndex:s,scaleValue:f})}function ie(e){var t,n,i;if(O.size&&(null==(t=g.value)||t.remove(...oe([...O]))),O.clear(),_=[],e){const{dataIndex:t,scaleValue:i}=e,o=i.dataList[t];null==(n=g.value)||n.remove(...oe(F.get(o.key))),F.delete(o.key),Z(o,t,i)}else F.size&&(null==(i=g.value)||i.remove(...oe(se()))),F.clear(),B()}function oe(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine)})),t}function le(e,t="moving"){const{title:n,type:i,data:o,unit:l}=e.origin;k.point={x:e.left,y:e.top};const r=`${"hover"===t?o.value:w(i,e.top)}`;k.list=[`${n} ${r}${l||""}`,`时间 ${b(e.left).slice(-5)}`],k.show=!0}function re(e){e.setCoords();const t=6e4/Y,n=e.prevPoint?e.prevPoint.left+t:C,i=K;e.top<j&&e.set("top",j),e.top>E&&e.set("top",E),e.left<n&&e.set("left",n),e.left>i&&e.set("left",i)}function ae(e,t){if(u(e)&&function(e){const t=Date.parse(T.list.at(-1)),n=d(e);return n>=V&&n<=t}(e.time)){const n=L(e.time),i=P(t.type,t.range,e.value);return[n,i<j?j:i>E?E:i]}}function se(){return Array.from(F.values()).flat()}return e((()=>{R()})),B(),function(){if(!X.evented)return;let e=!1,i={x:0,y:0};g.value.on("mouse:up",(t=>{if(3===t.button&&function(e){const{x:t=0,y:n=0}=e.pointer||{};if(t>=C&&t<=K&&n>=j&&n<=E)if(e.target){if("main"!==e.target.__type)return;i(e.pointer,e.target,["删除节点"]);const{minLeft:t,maxLeft:n,minTop:o,maxTop:l}=f(e.target);se().forEach((i=>{"main"===i.__type&&i.left>t&&i.left<n&&i.top>o&&i.top<l&&x.list.push({renderItem:()=>i.origin.title,origin:{...i.origin},mode:"remove",pointer:e.pointer})})),1===x.list.length&&(x.show=!1,console.log("当前时间段内无可删除节点"))}else i(e.pointer,null,["新增节点"]),S.forEach((n=>{G(se(),t,"key",2*A).includes(n.linkKey||n.key)||x.list.push({renderItem:()=>n.title,origin:{title:n.title,unit:n.unit,type:n.bigType,dataIndex:n.dataIndex,key:n.key,linkKey:n.linkKey},pointer:e.pointer})})),1===x.list.length&&(x.show=!1,J("repeat"),console.log("当前时间段内无可新增节点"));function i(e,t,n){Object.assign(x,{point:e,show:!0,target:t,list:n})}}(t),1===t.button&&e){e=!1;const t=H();t.length>0?Q((()=>{const e=function(e){const t=e.reduce(((e,t)=>{const{key:n}=t.origin;return e[n]=e[n]?e[n].concat(t.origin):[t.origin],e}),{});return Object.keys(t).map((e=>{const n=t[e].sort(((e,t)=>Date.parse(e.data.time)-Date.parse(t.data.time)));return ne(n[0],"remove",n.length),n.map((e=>({...m(e,["selfKey","lineAttr"]),key:e.selfKey})))}))}(t);h("remove",e)})):a.emit(z)}})),g.value.on("mouse:down",(t=>{1!==t.button||t.target||(e=!0,i=t.pointer)})),g.value.on("mouse:move",(o=>{if(!e)return;const{x:l,y:r}=i,{x:a,y:s}=o.pointer;z&&g.value.remove(z),z=new t.Rect({...n,fill:"#CAF982",opacity:.4,...I,left:l,top:r,width:a-l,height:s-r,objectCaching:!0}),z.areaPos={startPos:i,endPos:o.pointer},g.value.add(z)}))}(),{redrawPoints:ie,clickMenu:function({item:e,target:t}){const n={...e.origin};"remove"===e.mode?(h("remove",n),ne(n,"remove")):(Object.assign(n,{data:{time:b(e.pointer.x),value:w(e.origin.type,e.pointer.y),...e.origin.linkKey?{key:e.origin.key}:{}}}),h("add",n),ne({...n,key:e.origin.linkKey||e.origin.key}))},moveLimit:re,setPopup:le,updateData:ne,getGridPoints:se,getContainPoints:H,showDialog:Q,removeCurrentSelection:U}}export{g as useCenter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawPoint as e,drawText as i}from"../useDraw.js";import{useBirthProcessCumputedPoint as o}from"../useCumputedPoint.js";import{bus as n}from"../useEvent.js";import{useCommon as r}from"../useCommon.js";import"vue";import{getIndex as a}from"../../utils/index.js";import{cloneDeep as l}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";import{OTHER_MENU as s}from"../../constants/index.js";import"naive-ui";import"@vueuse/core";function d(d,c,u,f,h,m,g,p,v){const{cumputedX:x,getXValue:k}=o(c),{getEqualXTypes:y,handleAddPrevent:X,isGridLimit:b}=r(d,u,c),{other:P,yCellHeight:w,xCellWidth:j,endX:
|
|
1
|
+
import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawPoint as e,drawText as i}from"../useDraw.js";import{useBirthProcessCumputedPoint as o}from"../useCumputedPoint.js";import{bus as n}from"../useEvent.js";import{useCommon as r}from"../useCommon.js";import"vue";import{getIndex as a}from"../../utils/index.js";import{cloneDeep as l}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";import{OTHER_MENU as s}from"../../constants/index.js";import"naive-ui";import"@vueuse/core";function d(d,c,u,f,h,m,g,p,v){const{cumputedX:x,getXValue:k}=o(c),{getEqualXTypes:y,handleAddPrevent:X,isGridLimit:b}=r(d,u,c),{other:P,yCellHeight:w,xCellWidth:j,endX:z,originX:C,originY:E,endY:A,markHeight:L,event:M,topGridYCellHeight:S}=c,I=new Map,T=l(P);function H(){var o;if(!(null==(o=null==T?void 0:T.horizontal)?void 0:o.length))return;const n="horizontal";I.set(n,[]);const{horizontal:r}=T;let a=E+w/2;r.forEach(((o,r)=>{const{title:l,type:s,pointAttr:c={},textStyle:u={},data:f}=o;let h=null;f.forEach(((o,f)=>{const{time:m,value:g}=o,p=x(m);if(!B(p))return;const v=e(s,{...c,left:p,top:a}),k=p+v.width/2+2,y=i([k,a],{value:g,...u,originX:"left"}),X=new t.Group([v,y],{lockMovementY:!0,objectCaching:!1,hasControls:!1,hasBorders:!1,hoverCursor:"pointer"});Object.assign(X,{originLeft:p,iconHalfWidth:v.width/2,origin:{type:"other",key:n,dataIndex:r,index:f,data:o,title:l},limitX:{x1:C,x2:z-X.width}}),h&&(X.limitX.x1=h.left,h.limitX.x2=X.left,X.prevPoint=h,h.nextPoint=X),h=X,O(X),I.get(n).push(X),d.value.add(X)})),a+=w}))}function W(){var t;if(!(null==(t=null==T?void 0:T.vertical)?void 0:t.length))return;const i="vertical";I.set(i,[]);const{vertical:o}=T;o.forEach(((t,o)=>{const{textStyle:n={},data:r,time:a}=t,l=x(a);if(!B(l))return;let s=E+w/2;r.forEach(((t,r)=>{const a=e(String(t),{...n,lockMovementY:!0,left:l,originX:"left",top:s,origin:{type:"other",key:i,dataIndex:o,index:r,data:{value:t}}});s+=w,O(a),I.get(i).push(a),d.value.add(a)}));const c=I.get(i).filter((t=>t.origin.dataIndex===o)),u=Math.max(...c.map((t=>t.width))),f=l>z-u;c.forEach(((t,e,i)=>{t.siblingPoints=i.filter((e=>e.origin.index!==t.origin.index)),t.maxTextWidth=u,f&&t.setCoords().set("originX","right")}))}))}function Y(t,e="add"){const{dataIndex:i,data:o,index:n,key:r}=t,l=T[r],s=["mark"].includes(r)?l.dataList[i]:l[i];switch(e){case"remove":s.data.splice(n,1);break;case"change":s.data[n]=o;break;default:{const t=Array.isArray(o)?o[0].time:o.time,e=a(t,s.data),i=Array.isArray(o)?o:[o];s.data.splice(e,0,...i);break}}V(t)}function V(t){var e;const{key:i}=t;switch(null==(e=d.value)||e.remove(...I.get(i)),I.delete(i),i){case"horizontal":H();break;case"vertical":W();break;case"mark":G()}}function G(){if(!(null==P?void 0:P.mark)||!L)return;const{title:t,titleStyle:o,pointAttr:n,dataList:r}=P.mark,a=i([C-5,A+L/2],{value:t,...o,originX:"right"});d.value.add(a);const l=A+L,s=[];r.forEach((t=>{const{time:i,list:o=[]}=t,r=x(i);if(!B(r))return;let a=A;o.forEach((t=>{let i=!1;const o=e("circleAndText",{...n,text:t.text,left:r,top:a,origin:{data:t,key:"mark",type:"other"}}),c=o.height;a+c<=l&&a>=A?(o.set("top",a+c/2),a+=c):(i||(a=A,i=!0),o.set("top",a-c/2),a-=c),s.push(o),O(o),d.value.add(o)}))})),function(t){const e=t=>{var e,i;return null==(i=null==(e=t.origin)?void 0:e.data)?void 0:i.isStart},i=t.find((t=>e(t))),o=t.find((t=>!e(t)&&t.left>i.left)),n=t.filter((t=>!e(t)));t.forEach((t=>{const r={x1:C,x2:z};e(t)?(r.x2=o.left,t.otherPoints=n):(r.x1=i.left,t.startPoint=i),t.limitX=r}))}(s)}function O(t){if(M.hovered&&(t.on("mouseover",(()=>{q(t)})),t.on("mouseout",(()=>{f.show=!1}))),!M.evented)return;const{key:e}=t.origin,i=["mark","horizontal"].includes(e),o=["mark","vertical"].includes(e);t.on("moving",(()=>{i?function(t){const e=t.origin.key,i="horizontal"===e;t.setCoords(),t.left<t.limitX.x1&&t.set("left",t.limitX.x1+(i?1:0));t.left>t.limitX.x2&&t.set("left",t.limitX.x2+(i?-1:0));if("mark"===e){t.top<E&&t.set("top",E);const e=A+L-t.height/2;t.top>e&&t.set("top",e)}i&&(t.originLeft=t.left+t.iconHalfWidth)}(t):(m(t),function(t){const e=t.left+t.maxTextWidth>z?"right":"left";t.setCoords().set({originX:e}),t.siblingPoints.forEach((i=>i.setCoords().set({originX:e,left:t.left})))}(t)),M.hovered&&q(t)})),t.on("mouseup",(n=>{var r;if(f.show=!1,1===n.button){i&&function(t){var e,i;if("mark"===t.origin.key){if((null==(i=null==(e=t.origin)?void 0:e.data)?void 0:i.isStart)&&t.otherPoints)t.otherPoints.forEach((e=>{e.limitX.x1=t.left}));else{const e=t.startPoint.otherPoints.map((t=>t.left)),i=Math.min(...e);t.startPoint.limitX.x2=i}return}t.prevPoint&&(t.prevPoint.limitX.x2=t.left);t.nextPoint&&(t.nextPoint.limitX.x1=t.left)}(t);const e=k(null!=(r=t.originLeft)?r:t.left),n={...t.origin,...o?{time:e}:{data:{...t.origin.data,time:e}}};d.value.discardActiveObject(),u("change",n)}3===n.button&&["horizontal","vertical"].includes(e)&&(h.point={x:t.left,y:t.top},h.show=!0,h.target=t,h.list=s.map((t=>({...t,renderItem:()=>t.label}))))}))}function q(t){f.point={x:t.left,y:"mark"===t.origin.key?t.top:t.top+S/2};const e=!t.origin.isMenu&&t.originLeft?t.originLeft:t.left;f.list=[`时间 ${k(e).slice(-5)}`],"mark"===t.origin.key&&f.list.unshift(t.origin.data.name+" "),f.show=!0}function B(t){return t>=C&&t<=z}return function(){var t;if(!(null==(t=null==T?void 0:T.horizontal)?void 0:t.length))return;const{horizontal:i}=T,o=C-5;let n=E+w/2;i.forEach(((t,i)=>{const{title:r,titleStyle:a={},defaultAddValue:l}=t,s=r&&e(r,{...a,originX:"right",left:o,top:n,origin:{defaultAddValue:l,dataIndex:i,type:"other",key:"horizontal",title:r,isMenu:!0},originLeft:o,originTop:n});var c;(c=s).on("moving",(()=>{c.set("originX","center"),b(c)?q(c):f.show=!1})),c.on("mouseup:before",(t=>{if(f.show=!1,0===t.e.button&&b(c))if(y(I.get("horizontal"),c.left,"key",j).includes(c.origin.key))X("repeat"),console.log("重复节点");else{const t={data:{time:k(c.left),value:c.origin.defaultAddValue},...c.origin};u("add",t),Y(t)}!function(t){t.setCoords().set({originX:"right",left:t.originLeft,top:t.originTop})}(c)})),d.value.add(s),n+=w}))}(),H(),W(),G(),n.on((()=>{const t="horizontal",e=g(I.get(t));e.length>0?p((()=>{const i=function(t){const e=t.reduce(((t,e)=>{const{dataIndex:i}=e.origin;return t[i]=t[i]?t[i].concat(e.origin):[e.origin],t}),{});return Object.keys(e).map((t=>{const i=e[t];return T.horizontal[t].data.splice(i[0].index,i.length),i})).flat()}(e);V({key:t}),u("remove",i)})):v()})),{clickMenu:function({item:t,target:e}){if(!e)return;const{type:i}=t,o={...e.origin,type:"other"};u(i,o),"remove"===i&&Y(o,i)}}}export{d as useOther};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ref as e,computed as t,reactive as a,
|
|
1
|
+
import{ref as e,computed as t,reactive as a,watch as l}from"vue";import{defaultBorderStyle as u}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{useCumputedPoint as i}from"../useCumputedPoint.js";import{useCanvasEvent as r}from"../useEvent.js";import{setOtherType as n,getFloorNumber as o}from"../../utils/index.js";import"lodash-es";import{format as s,addDays as d}from"date-fns";import"naive-ui";import"@vueuse/core";import{useTop as v}from"./useTop.js";import{useLeft as c}from"./useLeft.js";import{useRight as p}from"./useRight.js";import{useCenter as h}from"./useCenter.js";import{useBottom as g}from"./useBottom.js";import{useOther as m}from"./useOther.js";function f(f,y,Y,S,b,w){const C=15,x=e(),D=e(),j=e(),V=t((()=>{const{top:e}=y.data;return e.date.show&&(e.date.height||C)||0})),X=t((()=>{var e;const{top:t}=y.data;return(null==(e=t.hospitalDays)?void 0:e.show)&&(t.hospitalDays.height||C)||0})),H=t((()=>{var e;const{top:t}=y.data;return(null==(e=t.operationDays)?void 0:e.show)&&(t.operationDays.height||C)||0})),L=t((()=>{var e,t,a;const{top:l}=y.data;return((null==(e=l.xScalevalue)?void 0:e.show)&&(l.xScalevalue.height||C)||0)+((null==(t=l.xScalevalue)?void 0:t.show)&&null!=(a=l.dayHeight)?a:0)})),I=t((()=>{var e;const{bottom:t}=y.data;return(null==(e=null==t?void 0:t.breathing)?void 0:e.show)&&(t.breathing.height||30)||0})),M=t((()=>{const{grid:e}=y.data;return e.mainXCell*e.subXCell+e.surplusXCell})),P=t((()=>{const{grid:e}=y.data;return e.mainYCell*e.subYCell+e.surplusYCell})),N=t((()=>{var e;const{width:t,right:a=null,top:l}=y.data;if(!a)return t;return t-(null!=(e=a.width)?e:0)})),O=t((()=>{const{grid:e}=y.data;return N.value-e.surplusXCell*R.value})),W=t((()=>{const{top:e,left:t}=y.data;return e.titleWidth+z.value})),$=t((()=>{const{bottom:e=null,height:t}=y.data;if(!e)return t;return t-(e.height||30)})),k=t((()=>{var e;const{top:t}=y.data,a=t.xScalevalue.show&&(null!=(e=t.dayHeight)?e:0)||0,l=t.xScalevalue.show&&(t.xScalevalue.height||C)||0;return V.value+a+l+X.value+H.value})),G=t((()=>{const{grid:e}=y.data;return k.value+e.surplusYCell*q.value})),R=t((()=>(N.value-W.value)/M.value)),q=t((()=>($.value-k.value)/P.value)),z=t((()=>{var e,t;const{left:a}=y.data;return(null==(e=a.icons)?void 0:e.show)&&((null==(t=a.icons)?void 0:t.width)||100)||0})),T=t((()=>{var e,t;const{top:a,grid:l}=y.data,u=(null==(t=null==(e=a.date.list)?void 0:e.slice)?void 0:t.call(e,0,l.mainXCell))||[],i=a.xScalevalue.times;let r=W.value-R.value;const n=a.date.startDate||s(new Date,"yyyy-MM-dd");return u.reduce(((e,t,a)=>0===a?e.concat(n):e.concat(s(d(new Date(n.replace(/-/g,"/")),a),"yyyy-MM-dd"))),[]).map((e=>i.map((t=>{r+=R.value;const a=Date.parse(`${e} ${t.start}`),l=Date.parse(`${e} ${t.end}`);return{start:a,end:l,left:r,center:r+R.value/2,scaleCell:(l-a)/R.value}})))).flat()})),A=t((()=>le("breathe"))),B=t((()=>le("pulse"))),E=t((()=>le("temperature"))),F=t((()=>le("pain"))),J=t((()=>{var e;return(null==(e=y.data.grid)?void 0:e.event)||{selectable:!0,evented:!0,hovered:!0}})),K=t((()=>{const{left:e}=y.data;return e.yScaleValue.map((e=>e.dataList.filter((e=>e.show)).map(((t,a)=>({...t,bigType:n(t.title,e.type),unit:e.unit,dataIndex:a}))))).flat()})),Q=t((()=>{const{left:e}=y.data;return e.yScaleValue.findIndex((e=>"pain"===e.type))})),U=t((()=>{const{grid:e}=y.data;return-1===Q.value?0:q.value*e.subYCell})),Z=t((()=>{const{left:e}=y.data,t={originY:$.value,endY:$.value};return 0===Q.value&&e.yScaleValue.length>1?(t.originY=G.value,t.endY=G.value+U.value):Q.value===e.yScaleValue.length-1&&(t.originY=$.value-U.value,t.endY=$.value),t})),_=t((()=>{const{left:e}=y.data,t={originY:k.value,endY:$.value};return 0===Q.value&&e.yScaleValue.length>1?(t.originY=G.value+U.value,t.endY=$.value):Q.value===e.yScaleValue.length-1&&(t.originY=G.value,t.endY=$.value-U.value),t})),ee=t((()=>{var e,t;const{top:a,grid:l}=y.data,u=[];for(const i in a)a[i].show&&u.push({...a[i],list:(null==(t=null==(e=a[i].list)?void 0:e.slice)?void 0:t.call(e,0,l.mainXCell))||[],key:i});return u.sort(((e,t)=>e.seq-t.seq))})),te=t((()=>{var e;const{left:t,right:a}=y.data,l=t.yScaleValue.find((e=>"temperature"===e.type)),u=(null==a?void 0:a.yScaleValue)||{};return(null==(e=null==l?void 0:l.list)?void 0:e.length)&&Object.assign(u,{list:l.list.map((e=>o(1.8*e+32))),spaceGridNumber:l.spaceGridNumber}),u})),ae=a({canvasWidth:y.data.width,canvasHeight:y.data.height,borderStyle:{...u,...y.data.borderStyle||{}},selectionStyle:y.data.selectionStyle||{},dateHeight:V.value,hospitalDaysHeight:X.value,operationDaysHeight:H.value,xScalevalueHeight:L.value,topList:ee.value,breathingHeight:I.value,hospitalizationDate:y.data.hospitalizationDate,grid:y.data.grid,top:y.data.top,left:y.data.left,right:y.data.right,bottom:y.data.bottom,other:y.data.other,painIndex:Q.value,painHeight:U.value,painOriginY:Z.value,vitalSignsOriginY:_.value,gridXNumber:M.value,gridYNumber:P.value,iconsWidth:z.value,originX:W.value,originY:k.value,originYLimit:G.value,endX:N.value,endXLimit:O.value,endY:$.value,xCellWidth:R.value,yCellHeight:q.value,xScaleList:T.value,breatheYCell:A.value,pulseYCell:B.value,temperatureYCell:E.value,painYCell:F.value,event:J.value,itemList:K.value,getRightInfo:te.value,config:y.data.config||{}});function le(e){const{yScaleValue:t}=y.data.left,a=t.find((t=>t.type===e)),l=(null==a?void 0:a.list)||[];return l.length?q.value/((l[1]-l[0])/a.spaceGridNumber):0}const{cumputedX:ue,cumputedY:ie,getXValue:re,getYValue:ne}=i(ae);return l((()=>f.value),(e=>{e&&function(){v(f,ae);const{setPopup:e,isAddPoint:t,updateData:a,redrawPoints:l,clickMenu:u,gridPoints:i}=h(f,ae,Y,ue,ie,re,ne,y.addRenderItem,b,w);D.value=l,j.value=u;const{drawScaleValue:n}=c(f,ae,Y,e,b,ue,ie,re,ne,t,a,i);p(f,ae,n),g(f,ae),m(f,ae,ue);const{select:o}=r(f,ae,Y);x.value=o}()}),{immediate:!0}),{propItems:ae,redrawPoints:D,select:x,clickMenu:j}}export{f as useTemperatureChart};
|
|
@@ -7839,7 +7839,9 @@ declare const FormConfig: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
7839
7839
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
7840
7840
|
clearSpan: (uuid: string) => void;
|
|
7841
7841
|
exposeEvent: {
|
|
7842
|
-
validate(path?: string
|
|
7842
|
+
validate(path?: string, { force }?: {
|
|
7843
|
+
force?: boolean | undefined;
|
|
7844
|
+
}): Promise<void>;
|
|
7843
7845
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
7844
7846
|
setFormValues(values: import("../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
7845
7847
|
setFieldState(path: string, setter: (field: Partial<Pick<import("@formily/core").Field<any, any, any, any>, import("@formily/core").NonFunctionPropertyNames<{
|
|
@@ -14221,7 +14223,9 @@ declare const FormConfig: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
14221
14223
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
14222
14224
|
clearSpan: (uuid: string) => void;
|
|
14223
14225
|
exposeEvent: {
|
|
14224
|
-
validate(path?: string
|
|
14226
|
+
validate(path?: string, { force }?: {
|
|
14227
|
+
force?: boolean | undefined;
|
|
14228
|
+
}): Promise<void>;
|
|
14225
14229
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
14226
14230
|
setFormValues(values: import("../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
14227
14231
|
setFieldState(path: string, setter: (field: Partial<Pick<import("@formily/core").Field<any, any, any, any>, import("@formily/core").NonFunctionPropertyNames<{
|
|
@@ -7841,7 +7841,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
7841
7841
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
7842
7842
|
clearSpan: (uuid: string) => void;
|
|
7843
7843
|
exposeEvent: {
|
|
7844
|
-
validate(path?: string
|
|
7844
|
+
validate(path?: string, { force }?: {
|
|
7845
|
+
force?: boolean | undefined;
|
|
7846
|
+
}): Promise<void>;
|
|
7845
7847
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
7846
7848
|
setFormValues(values: import("../../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
7847
7849
|
setFieldState(path: string, setter: (field: Partial<Pick<import("../../../../es/components/form-render").Field<any, any, any, any>, import("../../../../es/components/form-render").NonFunctionPropertyNames<{
|
|
@@ -14223,7 +14225,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
14223
14225
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
14224
14226
|
clearSpan: (uuid: string) => void;
|
|
14225
14227
|
exposeEvent: {
|
|
14226
|
-
validate(path?: string
|
|
14228
|
+
validate(path?: string, { force }?: {
|
|
14229
|
+
force?: boolean | undefined;
|
|
14230
|
+
}): Promise<void>;
|
|
14227
14231
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
14228
14232
|
setFormValues(values: import("../../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
14229
14233
|
setFieldState(path: string, setter: (field: Partial<Pick<import("../../../../es/components/form-render").Field<any, any, any, any>, import("../../../../es/components/form-render").NonFunctionPropertyNames<{
|
|
@@ -573,7 +573,9 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
573
573
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
574
574
|
clearSpan: (uuid: string) => void;
|
|
575
575
|
exposeEvent: {
|
|
576
|
-
validate(path?: string
|
|
576
|
+
validate(path?: string, { force }?: {
|
|
577
|
+
force?: boolean | undefined;
|
|
578
|
+
}): Promise<void>;
|
|
577
579
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
578
580
|
setFormValues(values: AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
579
581
|
setFieldState(path: string, setter: (field: Partial<Pick<import("../../../../../es/components/form-render").Field<any, any, any, any>, import("../../../../../es/components/form-render").NonFunctionPropertyNames<{
|
|
@@ -5945,7 +5945,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
5945
5945
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
5946
5946
|
clearSpan: (uuid: string) => void;
|
|
5947
5947
|
exposeEvent: {
|
|
5948
|
-
validate(path?: string
|
|
5948
|
+
validate(path?: string, { force }?: {
|
|
5949
|
+
force?: boolean | undefined;
|
|
5950
|
+
}): Promise<void>;
|
|
5949
5951
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
5950
5952
|
setFormValues(values: import("../../../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
5951
5953
|
setFieldState(path: string, setter: (field: Partial<Pick<import("../../../../../es/components/form-render").Field<any, any, any, any>, import("../../../../../es/components/form-render").NonFunctionPropertyNames<{
|
|
@@ -560,7 +560,9 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{}, {
|
|
|
560
560
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
561
561
|
clearSpan: (uuid: string) => void;
|
|
562
562
|
exposeEvent: {
|
|
563
|
-
validate(path?: string
|
|
563
|
+
validate(path?: string, { force }?: {
|
|
564
|
+
force?: boolean | undefined;
|
|
565
|
+
}): Promise<void>;
|
|
564
566
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
565
567
|
setFormValues(values: import("../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
566
568
|
setFieldState(path: string, setter: (field: Partial<Pick<import("@formily/core/esm/models/Field").Field<any, any, any, any>, import("@formily/core/esm/types").NonFunctionPropertyNames<{
|
|
@@ -555,7 +555,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
555
555
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
556
556
|
clearSpan: (uuid: string) => void;
|
|
557
557
|
exposeEvent: {
|
|
558
|
-
validate(path?: string
|
|
558
|
+
validate(path?: string, { force }?: {
|
|
559
|
+
force?: boolean | undefined;
|
|
560
|
+
}): Promise<void>;
|
|
559
561
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
560
562
|
setFormValues(values: AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
561
563
|
setFieldState(path: string, setter: (field: Partial<Pick<Field<any, any, any, any>, import("@formily/core").NonFunctionPropertyNames<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,ref as o,computed as t,provide as r,onMounted as s,onUnmounted as a,nextTick as i,openBlock as l,createBlock as n,unref as m,normalizeClass as d,normalizeStyle as p,withCtx as u,createElementBlock as c,createVNode as f,isRef as h,Fragment as y,renderList as g,createCommentVNode as j,createElementVNode as b,withKeys as k,toDisplayString as v,renderSlot as F}from"vue";import{useTheme as C}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import"date-fns";import{isNumber as S,cloneDeep as H,isObject as x,isBoolean as A}from"lodash-es";import{createForm as L,onFieldValueChange as B,onFieldMount as O,onFieldUnmount as R,onFieldReact as w,onFormMount as _}from"@formily/core";import{FormProvider as D,FormConsumer as V}from"@formily/vue";import{NForm as I,NTabs as N,NTabPane as q,NConfigProvider as W}from"naive-ui";import{InjectionFormLifeCycleCaller as E,InjectionFormGraph as K}from"./constants/index.js";import{useAutoHidden as T}from"./hooks/useAutoHidden.js";import{useComplexOptionsSpan as U}from"./hooks/useComplexOptions.js";import{useFormDomEvent as G,useFormExposeEvent as M}from"./hooks/useFormEvent.js";import{useFormGraph as P}from"./hooks/useFormGraph.js";import{useFormRenderLifeCycle as J}from"./hooks/useFormRenderLifeCycle.js";import{useLowCodeEvent as $}from"./hooks/useLowCodeEvent.js";import{useLowCodeReactions as z}from"./hooks/useLowCodeReactions.js";import{useNuiThemeOverrides as Q}from"./hooks/useNuiThemeOverrides.js";import{useOperationalForm as X}from"./hooks/useOperationalForm.js";import{useWordbookSetting as Y}from"./hooks/useWordbookSetting.js";import"../../../shared/utils/index.js";import"@formily/path";import"@vicons/ionicons5";import"@vue/shared";import"../index.js";import{createObjSchema as Z}from"./utils/schema.js";import{useFieldListAdaptor as ee}from"./hooks/useFieldListAdaptor.js";import{useFieldVisitor as oe}from"./hooks/useFieldVisitor.js";import"../../../shared/utils/tapable/SyncHook.js";import"../../../shared/utils/tapable/SyncBailHook.js";import"../../../shared/utils/tapable/SyncWaterfallHook.js";import"../../../shared/utils/tapable/SyncLoopHook.js";import"../../../shared/utils/tapable/AsyncParallelHook.js";import"../../../shared/utils/tapable/AsyncParallelBailHook.js";import"../../../shared/utils/tapable/AsyncSeriesHook.js";import"../../../shared/utils/tapable/AsyncSeriesBailHook.js";import"../../../shared/utils/tapable/AsyncSeriesLoopHook.js";import"../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js";import{validateMessageLocale as te}from"./hooks/useFormValidator.js";import{useAnchor as re}from"./hooks/useAnchor.js";import{useFormContext as se}from"./hooks/useFormContext.js";import"./hooks/useFormRenderOptions.js";const ae={key:0,style:{height:"54px"}},ie={style:{"white-space":"pre"}};var le=e({__name:"FormRender",props:{fieldList:{type:Array},initialData:{type:Object,default:()=>({})},fieldVisitor:{type:Object},column:{type:Number,default:24},maxHeight:{type:[Number,String],default:""},anchor:{type:Boolean,default:!1},parallelism:{type:Number,default:3},businessFormatter:{type:Function},schema:{type:Object},components:{type:Object,default:()=>({})},scope:{type:Object,default:()=>({})},annotation:{type:Object},consumer:{type:Boolean,default:!1},uuid:{type:String},lifeCycle:{type:Object},requestInstance:{type:Object},enterToNextWidget:{type:[Boolean,Function],default:!0},lowCodeReactions:{type:Array},operationalForm:{type:Object},linebarAutoHidden:{type:Boolean},bordered:{type:[Boolean,String],default:!0},outBordered:{type:Boolean,default:!1},uniqueCacheData:{type:Boolean,default:!1},forceClearable:Boolean},emits:["formChange","annotationChange","scroll"],setup(e,{expose:le,emit:ne}){const me=e,de=C(),{nuiThemeOverrides:pe}=Q();te();const ue=o(),ce=t((()=>S(me.maxHeight)?me.maxHeight+"px":me.maxHeight)),{SchemaField:fe,businessCollector:he,formItemDepsCollector:ye,changeContextCollector:ge,formUUID:je}=se(me,ne),{anchorBarRef:be,currentAnchor:ke,updateAnchorList:ve,anchorIdList:Fe,onScroll:Ce}=re(me,ne,ue,ye),{callLifeCycle:Se}=J(me);r(E,Se),Se("onSetup");const{trigger:He}=T(),{observeFormGraph:xe,setGraph:Ae,removeGraph:Le}=P();r(K,xe);const{lowCodeEventTrigger:Be}=$(),Oe=L({initialValues:me.initialData,effects(e){B("*",(o=>{const t=o.props.name.toString();he.trigger(e,t),ye.trigger(t),ne("formChange",{fieldInstance:o,fieldKey:t,fieldName:o.title,value:o.value,context:ge.getContext(t,o.value)}),Be(o),Re(t),_e(t),Ve(t,o.value)})),O("*",Ae),R("*",Le),me.linebarAutoHidden&&(w("*",He),_((e=>e.query("*").forEach(He)))),me.anchor&&w("*",ve)}}),{lowCodeReactionsHandler:Re,triggerAllReactionsHandler:we}=z(t((()=>me.lowCodeReactions)),Oe),{operationalFormHandler:_e,triggerAllOperationalFormHandler:De}=X(t((()=>me.operationalForm)),Oe),{wordbookSettingHandler:Ve}=Y(Oe,ge);s(we),s(De);const{schemaAdaptor:Ie}=ee(he);let Ne=me.fieldList||[];const qe=t((()=>me.schema?me.schema:me.fieldList?(Ne=oe().traverse(H(me.fieldList),me.fieldVisitor),Z(Ie(Ne,me))):Z({}))),{onKeydown:We}=G({formModel:Oe,formRenderRef:ue,props:me}),{clearSpan:Ee}=U();a((()=>Ee(je)));const Ke=M({formModel:Oe,formRenderRef:ue,formItemDepsCollector:ye,getFieldList:()=>Ne,formUUID:je});return le({formModel:Oe,validate:(e="*")=>Ke.validate(e),getFormValues:(e=!0)=>Ke.getFormValues(e),async setFormValues(e,o={},t=!1,r=!0){var s,a,l,n;let m=!0,d=!0;x(o)?(d=null==(s=o.needSplitExtendKey)||s,m=null==(a=o.avoidDependKeyConnection)||a,t=null!=(l=o.avoidBusinessConnection)&&l,r=null==(n=o.overwrite)||n):A(o)&&(d=o),t&&(he.triggerLock=!0),m&&(ye.triggerDisabled=!0),Ke.setFormValues(e,d,r),await i(),he.triggerLock=!1,ye.triggerDisabled=!1},setFieldState(e,o){Ke.setFieldState(e,o)},resetFields(e="*"){Ke.resetFields(e)},queryWidget:async e=>Ke.queryWidget(e),getFieldList:()=>Ne,async reload(){console.error("reload function is abstract,it should be overwrite!")}}),(o,t)=>(l(),n(m(I),{class:d(["form-render",{"form-render--out-border":e.outBordered}]),"require-mark-placement":"left",style:p(m(de))},{default:u((()=>[e.anchor?(l(),c("section",ae,[f(m(N),{value:m(ke),"onUpdate:value":t[0]||(t[0]=e=>h(ke)?ke.value=e:null),type:"line",ref_key:"anchorBarRef",ref:be},{default:u((()=>[(l(!0),c(y,null,g(m(Fe),(e=>(l(),n(m(q),{name:e.name,tab:e.title,key:e.name},null,8,["name","tab"])))),128))])),_:1},8,["value"])])):j("v-if",!0),f(m(W),{"theme-overrides":m(pe)},{default:u((()=>[b("section",{class:"form-render__wrapper",style:p({"--column":e.column,"--form-height":m(ce)}),ref_key:"formRenderRef",ref:ue,onScroll:t[1]||(t[1]=(...e)=>m(Ce)&&m(Ce)(...e)),onKeydownCapture:t[2]||(t[2]=k(((...e)=>m(We)&&m(We)(...e)),["enter"]))},[f(m(D),{form:m(Oe)},{default:u((()=>[f(m(fe),{schema:m(qe)},null,8,["schema"]),e.consumer?(l(),n(m(V),{key:0},{default:u((({form:e})=>[b("div",ie,v(JSON.stringify(e.values,null,2)),1)])),_:1})):j("v-if",!0),F(o.$slots,"default")])),_:3},8,["form"])],36)])),_:3},8,["theme-overrides"])])),_:3},8,["class","style"]))}});export{le as default};
|
|
1
|
+
import{defineComponent as e,ref as o,computed as t,provide as r,onMounted as s,onUnmounted as a,nextTick as i,openBlock as l,createBlock as n,unref as m,normalizeClass as d,normalizeStyle as p,withCtx as u,createElementBlock as c,createVNode as f,isRef as h,Fragment as y,renderList as g,createCommentVNode as j,createElementVNode as b,withKeys as k,toDisplayString as v,renderSlot as F}from"vue";import{useTheme as C}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import"date-fns";import{isNumber as S,cloneDeep as H,isObject as x,isBoolean as A}from"lodash-es";import{createForm as L,onFieldValueChange as B,onFieldMount as O,onFieldUnmount as R,onFieldReact as w,onFormMount as _}from"@formily/core";import{FormProvider as D,FormConsumer as V}from"@formily/vue";import{NForm as I,NTabs as N,NTabPane as q,NConfigProvider as W}from"naive-ui";import{InjectionFormLifeCycleCaller as E,InjectionFormGraph as K}from"./constants/index.js";import{useAutoHidden as T}from"./hooks/useAutoHidden.js";import{useComplexOptionsSpan as U}from"./hooks/useComplexOptions.js";import{useFormDomEvent as G,useFormExposeEvent as M}from"./hooks/useFormEvent.js";import{useFormGraph as P}from"./hooks/useFormGraph.js";import{useFormRenderLifeCycle as J}from"./hooks/useFormRenderLifeCycle.js";import{useLowCodeEvent as $}from"./hooks/useLowCodeEvent.js";import{useLowCodeReactions as z}from"./hooks/useLowCodeReactions.js";import{useNuiThemeOverrides as Q}from"./hooks/useNuiThemeOverrides.js";import{useOperationalForm as X}from"./hooks/useOperationalForm.js";import{useWordbookSetting as Y}from"./hooks/useWordbookSetting.js";import"../../../shared/utils/index.js";import"@formily/path";import"@vicons/ionicons5";import"@vue/shared";import"../index.js";import{createObjSchema as Z}from"./utils/schema.js";import{useFieldListAdaptor as ee}from"./hooks/useFieldListAdaptor.js";import{useFieldVisitor as oe}from"./hooks/useFieldVisitor.js";import"../../../shared/utils/tapable/SyncHook.js";import"../../../shared/utils/tapable/SyncBailHook.js";import"../../../shared/utils/tapable/SyncWaterfallHook.js";import"../../../shared/utils/tapable/SyncLoopHook.js";import"../../../shared/utils/tapable/AsyncParallelHook.js";import"../../../shared/utils/tapable/AsyncParallelBailHook.js";import"../../../shared/utils/tapable/AsyncSeriesHook.js";import"../../../shared/utils/tapable/AsyncSeriesBailHook.js";import"../../../shared/utils/tapable/AsyncSeriesLoopHook.js";import"../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js";import{validateMessageLocale as te}from"./hooks/useFormValidator.js";import{useAnchor as re}from"./hooks/useAnchor.js";import{useFormContext as se}from"./hooks/useFormContext.js";import"./hooks/useFormRenderOptions.js";const ae={key:0,style:{height:"54px"}},ie={style:{"white-space":"pre"}};var le=e({__name:"FormRender",props:{fieldList:{type:Array},initialData:{type:Object,default:()=>({})},fieldVisitor:{type:Object},column:{type:Number,default:24},maxHeight:{type:[Number,String],default:""},anchor:{type:Boolean,default:!1},parallelism:{type:Number,default:3},businessFormatter:{type:Function},schema:{type:Object},components:{type:Object,default:()=>({})},scope:{type:Object,default:()=>({})},annotation:{type:Object},consumer:{type:Boolean,default:!1},uuid:{type:String},lifeCycle:{type:Object},requestInstance:{type:Object},enterToNextWidget:{type:[Boolean,Function],default:!0},lowCodeReactions:{type:Array},operationalForm:{type:Object},linebarAutoHidden:{type:Boolean},bordered:{type:[Boolean,String],default:!0},outBordered:{type:Boolean,default:!1},uniqueCacheData:{type:Boolean,default:!1},forceClearable:Boolean},emits:["formChange","annotationChange","scroll"],setup(e,{expose:le,emit:ne}){const me=e,de=C(),{nuiThemeOverrides:pe}=Q();te();const ue=o(),ce=t((()=>S(me.maxHeight)?me.maxHeight+"px":me.maxHeight)),{SchemaField:fe,businessCollector:he,formItemDepsCollector:ye,changeContextCollector:ge,formUUID:je}=se(me,ne),{anchorBarRef:be,currentAnchor:ke,updateAnchorList:ve,anchorIdList:Fe,onScroll:Ce}=re(me,ne,ue,ye),{callLifeCycle:Se}=J(me);r(E,Se),Se("onSetup");const{trigger:He}=T(),{observeFormGraph:xe,setGraph:Ae,removeGraph:Le}=P();r(K,xe);const{lowCodeEventTrigger:Be}=$(),Oe=L({initialValues:me.initialData,effects(e){B("*",(o=>{const t=o.props.name.toString();he.trigger(e,t),ye.trigger(t),ne("formChange",{fieldInstance:o,fieldKey:t,fieldName:o.title,value:o.value,context:ge.getContext(t,o.value)}),Be(o),Re(t),_e(t),Ve(t,o.value)})),O("*",Ae),R("*",Le),me.linebarAutoHidden&&(w("*",He),_((e=>e.query("*").forEach(He)))),me.anchor&&w("*",ve)}}),{lowCodeReactionsHandler:Re,triggerAllReactionsHandler:we}=z(t((()=>me.lowCodeReactions)),Oe),{operationalFormHandler:_e,triggerAllOperationalFormHandler:De}=X(t((()=>me.operationalForm)),Oe),{wordbookSettingHandler:Ve}=Y(Oe,ge);s(we),s(De);const{schemaAdaptor:Ie}=ee(he);let Ne=me.fieldList||[];const qe=t((()=>me.schema?me.schema:me.fieldList?(Ne=oe().traverse(H(me.fieldList),me.fieldVisitor),Z(Ie(Ne,me))):Z({}))),{onKeydown:We}=G({formModel:Oe,formRenderRef:ue,props:me}),{clearSpan:Ee}=U();a((()=>Ee(je)));const Ke=M({formModel:Oe,formRenderRef:ue,formItemDepsCollector:ye,getFieldList:()=>Ne,formUUID:je});return le({formModel:Oe,validate:(e="*",o={})=>Ke.validate(e,o),getFormValues:(e=!0)=>Ke.getFormValues(e),async setFormValues(e,o={},t=!1,r=!0){var s,a,l,n;let m=!0,d=!0;x(o)?(d=null==(s=o.needSplitExtendKey)||s,m=null==(a=o.avoidDependKeyConnection)||a,t=null!=(l=o.avoidBusinessConnection)&&l,r=null==(n=o.overwrite)||n):A(o)&&(d=o),t&&(he.triggerLock=!0),m&&(ye.triggerDisabled=!0),Ke.setFormValues(e,d,r),await i(),he.triggerLock=!1,ye.triggerDisabled=!1},setFieldState(e,o){Ke.setFieldState(e,o)},resetFields(e="*"){Ke.resetFields(e)},queryWidget:async e=>Ke.queryWidget(e),getFieldList:()=>Ne,async reload(){console.error("reload function is abstract,it should be overwrite!")}}),(o,t)=>(l(),n(m(I),{class:d(["form-render",{"form-render--out-border":e.outBordered}]),"require-mark-placement":"left",style:p(m(de))},{default:u((()=>[e.anchor?(l(),c("section",ae,[f(m(N),{value:m(ke),"onUpdate:value":t[0]||(t[0]=e=>h(ke)?ke.value=e:null),type:"line",ref_key:"anchorBarRef",ref:be},{default:u((()=>[(l(!0),c(y,null,g(m(Fe),(e=>(l(),n(m(q),{name:e.name,tab:e.title,key:e.name},null,8,["name","tab"])))),128))])),_:1},8,["value"])])):j("v-if",!0),f(m(W),{"theme-overrides":m(pe)},{default:u((()=>[b("section",{class:"form-render__wrapper",style:p({"--column":e.column,"--form-height":m(ce)}),ref_key:"formRenderRef",ref:ue,onScroll:t[1]||(t[1]=(...e)=>m(Ce)&&m(Ce)(...e)),onKeydownCapture:t[2]||(t[2]=k(((...e)=>m(We)&&m(We)(...e)),["enter"]))},[f(m(D),{form:m(Oe)},{default:u((()=>[f(m(fe),{schema:m(qe)},null,8,["schema"]),e.consumer?(l(),n(m(V),{key:0},{default:u((({form:e})=>[b("div",ie,v(JSON.stringify(e.values,null,2)),1)])),_:1})):j("v-if",!0),F(o.$slots,"default")])),_:3},8,["form"])],36)])),_:3},8,["theme-overrides"])])),_:3},8,["class","style"]))}});export{le as default};
|
|
@@ -558,7 +558,9 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
558
558
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
|
559
559
|
clearSpan: (uuid: string) => void;
|
|
560
560
|
exposeEvent: {
|
|
561
|
-
validate(path?: string
|
|
561
|
+
validate(path?: string, { force }?: {
|
|
562
|
+
force?: boolean | undefined;
|
|
563
|
+
}): Promise<void>;
|
|
562
564
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
563
565
|
setFormValues(values: import("../../../../es/shared/types").AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
564
566
|
setFieldState(path: string, setter: (field: Partial<Pick<import("../../../../es/components/form-render").Field<any, any, any, any>, import("../../../../es/components/form-render").NonFunctionPropertyNames<{
|
|
@@ -3,7 +3,7 @@ import { PropType } from 'vue';
|
|
|
3
3
|
import { UrlConfig } from '../../../../../../es/components/form-render';
|
|
4
4
|
export declare const REMOTE_SEARCH: import("vue").DefineComponent<{
|
|
5
5
|
value: {
|
|
6
|
-
type: PropType<
|
|
6
|
+
type: PropType<string | null>;
|
|
7
7
|
};
|
|
8
8
|
requestCache: {
|
|
9
9
|
type: BooleanConstructor;
|
|
@@ -22,17 +22,54 @@ export declare const REMOTE_SEARCH: import("vue").DefineComponent<{
|
|
|
22
22
|
type: StringConstructor;
|
|
23
23
|
default: string;
|
|
24
24
|
};
|
|
25
|
+
showField: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
};
|
|
25
28
|
urlConfig: {
|
|
26
29
|
type: PropType<UrlConfig>;
|
|
27
30
|
};
|
|
31
|
+
autograph: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
};
|
|
34
|
+
wordbook: {
|
|
35
|
+
type: PropType<Partial<{
|
|
36
|
+
level_num: number;
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
render_key: string[];
|
|
40
|
+
search_key: string[];
|
|
41
|
+
value_key: string;
|
|
42
|
+
queryParams: string[];
|
|
43
|
+
primary_key: string;
|
|
44
|
+
type: string;
|
|
45
|
+
level_key: string;
|
|
46
|
+
link_key: string;
|
|
47
|
+
link_key_split: string;
|
|
48
|
+
show_key: string | string[];
|
|
49
|
+
conObj: AnyObject[];
|
|
50
|
+
conObjFirstLevel: AnyObject[];
|
|
51
|
+
setting: Partial<{
|
|
52
|
+
cascading: {
|
|
53
|
+
'form.name': string;
|
|
54
|
+
value: string;
|
|
55
|
+
}[];
|
|
56
|
+
}>;
|
|
57
|
+
}>>;
|
|
58
|
+
};
|
|
28
59
|
onChange: {};
|
|
29
60
|
useLoading: {
|
|
30
61
|
type: BooleanConstructor;
|
|
31
62
|
default: boolean;
|
|
32
63
|
};
|
|
64
|
+
lazyRequest: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
default: boolean;
|
|
67
|
+
};
|
|
68
|
+
multiple: BooleanConstructor;
|
|
69
|
+
deletable: BooleanConstructor;
|
|
33
70
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:value"[], "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
71
|
value: {
|
|
35
|
-
type: PropType<
|
|
72
|
+
type: PropType<string | null>;
|
|
36
73
|
};
|
|
37
74
|
requestCache: {
|
|
38
75
|
type: BooleanConstructor;
|
|
@@ -51,21 +88,61 @@ export declare const REMOTE_SEARCH: import("vue").DefineComponent<{
|
|
|
51
88
|
type: StringConstructor;
|
|
52
89
|
default: string;
|
|
53
90
|
};
|
|
91
|
+
showField: {
|
|
92
|
+
type: StringConstructor;
|
|
93
|
+
};
|
|
54
94
|
urlConfig: {
|
|
55
95
|
type: PropType<UrlConfig>;
|
|
56
96
|
};
|
|
97
|
+
autograph: {
|
|
98
|
+
type: StringConstructor;
|
|
99
|
+
};
|
|
100
|
+
wordbook: {
|
|
101
|
+
type: PropType<Partial<{
|
|
102
|
+
level_num: number;
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
render_key: string[];
|
|
106
|
+
search_key: string[];
|
|
107
|
+
value_key: string;
|
|
108
|
+
queryParams: string[];
|
|
109
|
+
primary_key: string;
|
|
110
|
+
type: string;
|
|
111
|
+
level_key: string;
|
|
112
|
+
link_key: string;
|
|
113
|
+
link_key_split: string;
|
|
114
|
+
show_key: string | string[];
|
|
115
|
+
conObj: AnyObject[];
|
|
116
|
+
conObjFirstLevel: AnyObject[];
|
|
117
|
+
setting: Partial<{
|
|
118
|
+
cascading: {
|
|
119
|
+
'form.name': string;
|
|
120
|
+
value: string;
|
|
121
|
+
}[];
|
|
122
|
+
}>;
|
|
123
|
+
}>>;
|
|
124
|
+
};
|
|
57
125
|
onChange: {};
|
|
58
126
|
useLoading: {
|
|
59
127
|
type: BooleanConstructor;
|
|
60
128
|
default: boolean;
|
|
61
129
|
};
|
|
130
|
+
lazyRequest: {
|
|
131
|
+
type: BooleanConstructor;
|
|
132
|
+
default: boolean;
|
|
133
|
+
};
|
|
134
|
+
multiple: BooleanConstructor;
|
|
135
|
+
deletable: BooleanConstructor;
|
|
62
136
|
}>> & {
|
|
63
137
|
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
64
138
|
}, {
|
|
65
139
|
options: AnyObject[];
|
|
140
|
+
multiple: boolean;
|
|
66
141
|
labelField: string;
|
|
67
142
|
valueField: string;
|
|
143
|
+
lazyRequest: boolean;
|
|
68
144
|
requestCache: boolean;
|
|
145
|
+
deletable: boolean;
|
|
69
146
|
allowCreate: boolean;
|
|
70
147
|
useLoading: boolean;
|
|
71
148
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,
|
|
1
|
+
import{defineComponent as e,watch as l,inject as o,computed as a,ref as t,createVNode as n}from"vue";import{connect as u,mapProps as r}from"@formily/vue";import{HelpCircleSharp as i}from"@vicons/ionicons5";import{useVModel as s,useDebounceFn as p}from"@vueuse/core";import{cloneDeep as v,isString as d}from"lodash-es";import{NSelect as m,NSpin as c,NEmpty as f,NTooltip as y,NIcon as g,NTag as h}from"naive-ui";import"../../../index.js";import{InjectionChangeContextCollector as C}from"../../constants/index.js";import{useCommonInjection as b,useSelectOptionProps as j}from"../../hooks/useCommonInjection.js";import{assignUpdateValue as F,assignClearBindVisited as w,createVisitedSetter as x}from"../../utils/schema.js";import{useFormField as B}from"../../hooks/useFormField.js";import{useUrlConfigOptions as K,useAutographOptions as S}from"../../hooks/useFormRenderOptions.js";const k=u(e({name:"FormRemoteSearch",props:{value:{type:String},requestCache:{type:Boolean,default:!0},options:{type:Array,default:()=>[]},allowCreate:Boolean,labelField:{type:String,default:"text"},valueField:{type:String,default:"value"},showField:{type:String},urlConfig:{type:Object},autograph:{type:String},wordbook:{type:Object},onChange:{},useLoading:{type:Boolean,default:!0},lazyRequest:{type:Boolean,default:!0},multiple:Boolean,deletable:Boolean},emits:["update:value"],setup(e,{slots:u,emit:r}){const F=s(e,"value",r),{field:w,fieldKey:k}=B(),{injectValueValidate:O,injectValueBindKey:D}=b();O(F);const R=D(F),q={onRequestConfigChange:({fetchData:e,valueKey:l})=>e(F.value,{[l]:F.value}),onDepsChange:({fetchData:e,valueKey:l})=>e(F.value,{[l]:F.value})},{labelKey:L,valueKey:P,showKey:V,fetchData:I,searchContent:U,fullOptions:z,loading:A}=e.urlConfig?K(e,F,q):S(e,F,q),T=p(((e="",l="label")=>I(e,{["value"===l?P.value:"keyword"]:e})),300);l(F,(e=>{if(e&&!z.value.find((l=>l[P.value]===e)))return T(e,"value")}));o(C).setContext(k.value,(e=>{return{currentOption:v((l=e,z.value.find((e=>e[P.value]===l))))};var l}));const{menuProps:$,nodeProps:E}=j(),G=a((()=>z.value.length||!e.allowCreate?z.value:U.value?[{[L.value]:U.value,[P.value]:U.value},...z.value]:z.value));async function H(e){A.value=e,e&&T()}function J(e){const l=e.alias||e[L.value];if(!l||!d(l))return"";const o=l;return e.desc?n("section",{style:{display:"flex",alignItems:"center",gap:"4px"}},[o,e.desc?n(y,null,{trigger:()=>n(g,{component:i},null),default:()=>e.desc}):null]):o}function M({option:l,handleClose:o}){var a;const t=null!=(a=V.value&&l[V.value])?a:l[L.value];if(!e.multiple)return N.value=t,t;return N.value="",e.deletable?n(h,{closable:!0,onClose:function(e){e.stopPropagation(),o()}},{default:()=>t}):`${t};`}const N=t("");return()=>n(m,{title:N.value,remote:!0,filterable:!0,key:R.value,value:F.value,"onUpdate:value":e=>F.value=e,labelField:L.value,valueField:P.value,"menu-props":$,"node-props":E,onSearch:T,"onUpdate:show":H,options:G.value,onFocus:x(w),renderLabel:J,renderTag:M},{empty:()=>e.useLoading&&A.value?n(c,null,null):n(f,{description:"无数据"},null),...u})}}),r(F,w));export{k as REMOTE_SEARCH};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,computed as l,inject as t,useAttrs as o,ref as a,createVNode as u,mergeProps as n,toRaw as r,nextTick as s}from"vue";import{arrayed as i}from"../../../../../shared/utils/index.js";import{HelpCircleSharp as p}from"@vicons/ionicons5";import{promiseTimeout as m}from"@vueuse/shared";import{cloneDeep as c,isArray as d,isString as v,isObject as f,omit as y}from"lodash-es";import{useCommonInjection as h,useSelectOptionProps as g}from"../../hooks/useCommonInjection.js";import{useComplexOptions as S,useComplexOptionsSpan as b}from"../../hooks/useComplexOptions.js";import{InjectionChangeContextCollector as j,InjectionFormUUID as C}from"../../constants/index.js";import"../../../index.js";import"@formily/core";import"@formily/path";import"@vue/shared";import"@vueuse/core";import{NSelect as w,NTooltip as k,NIcon as F,NTag as B}from"naive-ui";import"date-fns";import{assignUpdateValue as x,assignClearBindVisited as O,createVisitedSetter as A}from"../../utils/schema.js";import{useFormField as H}from"../../hooks/useFormField.js";import"../../../../../shared/utils/tapable/SyncHook.js";import"../../../../../shared/utils/tapable/SyncBailHook.js";import"../../../../../shared/utils/tapable/SyncWaterfallHook.js";import"../../../../../shared/utils/tapable/SyncLoopHook.js";import"../../../../../shared/utils/tapable/AsyncParallelHook.js";import"../../../../../shared/utils/tapable/AsyncParallelBailHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesBailHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js";import"../../hooks/useFormValidator.js";import{connect as P,mapProps as R}from"@formily/vue";import"./index.js";import{useUrlConfigOptions as V,useAutographOptions as K,useRecommendOptions as L,searchContentMatcher as E}from"../../hooks/useFormRenderOptions.js";const _=P(e({name:"FormSelect",props:{value:{type:[String,Array,Number]},lazyRequest:{type:Boolean,default:!0},requestCache:{type:Boolean,default:!0},options:{type:Array,default:()=>[]},onChange:{},labelField:{type:String,default:"text"},valueField:{type:String,default:"value"},showField:{type:String},allowCreate:Boolean,shouldSave:Boolean,allowModify:Boolean,showCustomValue:Boolean,cursorPlacement:{type:String,default:"end"},urlConfig:{type:Object},autograph:{type:String},wordbook:{type:Object},recommend:{type:Boolean,default:!1},commonList:{type:Array},recentList:{type:Array},getRecommendInfo:{type:Function},commonNum:{type:Number,default:10},recentNum:{type:Number,default:10},recommendCache:{type:Boolean,default:!1},useLoading:{type:Boolean,default:!0},multiple:{type:Boolean},deletable:{type:Boolean,default:!0}},emits:["update:value","postRecommend"],setup(e,{slots:x,emit:O}){const P=l({get:()=>e.value,async set(e){O("update:value",e),J(e)}}),R=l((()=>(e.multiple&&e.allowModify&&console.warn("多选模式下不支持allowModify"),!e.multiple&&e.allowModify))),{labelKey:_,valueKey:I,showKey:N,fetchData:M,searchContent:W,fullOptions:q,filterOptions:U,remoteOptions:z,loading:D}=e.urlConfig?V(e,P):K(e,P),{renderComplexOption:T,hasComplexOption:$}=S(e,P),{getRecommend:G,postRecommend:J,sortedOptions:Q}=L(e,U,O,_,I),{field:X,fieldKey:Y}=H();t(j).setContext(Y.value,(e=>({currentOption:c(function(e){const l=re(q.value);return d(e)?function(e){const t=l.reduce(((e,l)=>(e[l[I.value]]=l,e)),{});return e.map((e=>t[e]))}(e):(t=e,l.find((e=>e[I.value]===t)));var t}(e))})));const Z=async(e="")=>(W.value=e,Promise.allSettled([M(e),G(e)])),{injectValueValidate:ee,injectValueWatchFromEmpty:le,injectValueBindKey:te}=h();le(P,Z),ee(P);const oe=te(P),{menuProps:ae,nodeProps:ue}=g();function ne(e){const l=e[_.value];if(!l||!v(l))return"";const t=W.value?E(W.value,l):null,o=t?u("section",null,[t.map(((e,l)=>0!==l&&e?u("span",{style:{color:l%2==0?"var(--n-option-text-color-active)":""}},[e]):null))]):l;return e.desc?u("section",{style:{display:"flex",alignItems:"center",gap:"4px"}},[o,e.desc?u(k,null,{trigger:()=>u(F,{component:p},null),default:()=>e.desc}):null]):o}function re(l){return e.allowCreate&&W.value&&!l.some((e=>e[_.value]===W.value))?[...l,{[_.value]:W.value,[I.value]:W.value,created:!0,shouldSave:e.shouldSave}]:l}const se=l((()=>re(R.value?q.value:Q.value))),ie=o(),pe=l((()=>{if(e.allowCreate||e.showCustomValue)return P.value;const l=e.multiple&&d(P.value);return q.value.find((e=>l?P.value.includes(e[I.value]):e[I.value]===P.value))?P.value:null})),me=a(!1);async function ce(e){e&&await Z(),me.value=e}let de=null;async function ve(l,t){P.value=l,de&&f(t)&&R.value&&(de.focus(),await s(),de.value=t[_.value]||"",de.dispatchEvent(new CustomEvent("input")),"start"===e.cursorPlacement&&de.setSelectionRange(0,0)),z.value&&t&&i(t).forEach((e=>{if(!f(e))return;const l=e;l.created&&l.shouldSave&&z.value.push(y(r(l),["created","shouldSave"]))}))}const fe=t(C),{getSpan:ye}=b(),he=A(X,(async l=>{var t,o,a;R.value&&(de=l.target,de&&P.value&&(await s(),de.value=null!=(a=null!=(o=null==(t=q.value.find((e=>e[I.value]===P.value)))?void 0:t[_.value])?o:P.value)?a:"",de.dispatchEvent(new CustomEvent("input")),"start"===e.cursorPlacement&&(await m(0),de.setSelectionRange(0,0))))}));function ge(e){if(!R.value)return;if(de=e.target,!de)return;if(!de.value)return P.value=null;const l=q.value.find((e=>e[_.value]===de.value));l?P.value=l[I.value]:(W.value=de.value,P.value=de.value)}
|
|
1
|
+
import{defineComponent as e,computed as l,inject as t,useAttrs as o,ref as a,createVNode as u,mergeProps as n,toRaw as r,nextTick as s}from"vue";import{arrayed as i}from"../../../../../shared/utils/index.js";import{HelpCircleSharp as p}from"@vicons/ionicons5";import{promiseTimeout as m}from"@vueuse/shared";import{cloneDeep as c,isArray as d,isString as v,isObject as f,omit as y}from"lodash-es";import{useCommonInjection as h,useSelectOptionProps as g}from"../../hooks/useCommonInjection.js";import{useComplexOptions as S,useComplexOptionsSpan as b}from"../../hooks/useComplexOptions.js";import{InjectionChangeContextCollector as j,InjectionFormUUID as C}from"../../constants/index.js";import"../../../index.js";import"@formily/core";import"@formily/path";import"@vue/shared";import"@vueuse/core";import{NSelect as w,NTooltip as k,NIcon as F,NTag as B}from"naive-ui";import"date-fns";import{assignUpdateValue as x,assignClearBindVisited as O,createVisitedSetter as A}from"../../utils/schema.js";import{useFormField as H}from"../../hooks/useFormField.js";import"../../../../../shared/utils/tapable/SyncHook.js";import"../../../../../shared/utils/tapable/SyncBailHook.js";import"../../../../../shared/utils/tapable/SyncWaterfallHook.js";import"../../../../../shared/utils/tapable/SyncLoopHook.js";import"../../../../../shared/utils/tapable/AsyncParallelHook.js";import"../../../../../shared/utils/tapable/AsyncParallelBailHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesBailHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js";import"../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js";import"../../hooks/useFormValidator.js";import{connect as P,mapProps as R}from"@formily/vue";import"./index.js";import{useUrlConfigOptions as V,useAutographOptions as K,useRecommendOptions as L,searchContentMatcher as E}from"../../hooks/useFormRenderOptions.js";const _=P(e({name:"FormSelect",props:{value:{type:[String,Array,Number]},lazyRequest:{type:Boolean,default:!0},requestCache:{type:Boolean,default:!0},options:{type:Array,default:()=>[]},onChange:{},labelField:{type:String,default:"text"},valueField:{type:String,default:"value"},showField:{type:String},allowCreate:Boolean,shouldSave:Boolean,allowModify:Boolean,showCustomValue:Boolean,cursorPlacement:{type:String,default:"end"},urlConfig:{type:Object},autograph:{type:String},wordbook:{type:Object},recommend:{type:Boolean,default:!1},commonList:{type:Array},recentList:{type:Array},getRecommendInfo:{type:Function},commonNum:{type:Number,default:10},recentNum:{type:Number,default:10},recommendCache:{type:Boolean,default:!1},useLoading:{type:Boolean,default:!0},multiple:{type:Boolean},deletable:{type:Boolean,default:!0}},emits:["update:value","postRecommend"],setup(e,{slots:x,emit:O}){const P=l({get:()=>e.value,async set(e){O("update:value",e),J(e)}}),R=l((()=>(e.multiple&&e.allowModify&&console.warn("多选模式下不支持allowModify"),!e.multiple&&e.allowModify))),{labelKey:_,valueKey:I,showKey:N,fetchData:M,searchContent:W,fullOptions:q,filterOptions:U,remoteOptions:z,loading:D}=e.urlConfig?V(e,P):K(e,P),{renderComplexOption:T,hasComplexOption:$}=S(e,P),{getRecommend:G,postRecommend:J,sortedOptions:Q}=L(e,U,O,_,I),{field:X,fieldKey:Y}=H();t(j).setContext(Y.value,(e=>({currentOption:c(function(e){const l=re(q.value);return d(e)?function(e){const t=l.reduce(((e,l)=>(e[l[I.value]]=l,e)),{});return e.map((e=>t[e]))}(e):(t=e,l.find((e=>e[I.value]===t)));var t}(e))})));const Z=async(e="")=>(W.value=e,Promise.allSettled([M(e),G(e)])),{injectValueValidate:ee,injectValueWatchFromEmpty:le,injectValueBindKey:te}=h();le(P,Z),ee(P);const oe=te(P),{menuProps:ae,nodeProps:ue}=g();function ne(e){const l=e[_.value];if(!l||!v(l))return"";const t=W.value?E(W.value,l):null,o=t?u("section",null,[t.map(((e,l)=>0!==l&&e?u("span",{style:{color:l%2==0?"var(--n-option-text-color-active)":""}},[e]):null))]):l;return e.desc?u("section",{style:{display:"flex",alignItems:"center",gap:"4px"}},[o,e.desc?u(k,null,{trigger:()=>u(F,{component:p},null),default:()=>e.desc}):null]):o}function re(l){return e.allowCreate&&W.value&&!l.some((e=>e[_.value]===W.value))?[...l,{[_.value]:W.value,[I.value]:W.value,created:!0,shouldSave:e.shouldSave}]:l}const se=l((()=>re(R.value?q.value:Q.value))),ie=o(),pe=l((()=>{if(e.allowCreate||e.showCustomValue)return P.value;const l=e.multiple&&d(P.value);return q.value.find((e=>l?P.value.includes(e[I.value]):e[I.value]===P.value))?P.value:null})),me=a(!1);async function ce(e){e&&await Z(),me.value=e}let de=null;async function ve(l,t){P.value=l,de&&f(t)&&R.value&&(de.focus(),await s(),de.value=t[_.value]||"",de.dispatchEvent(new CustomEvent("input")),"start"===e.cursorPlacement&&de.setSelectionRange(0,0)),z.value&&t&&i(t).forEach((e=>{if(!f(e))return;const l=e;l.created&&l.shouldSave&&z.value.push(y(r(l),["created","shouldSave"]))}))}const fe=t(C),{getSpan:ye}=b(),he=A(X,(async l=>{var t,o,a;R.value&&(de=l.target,de&&P.value&&(await s(),de.value=null!=(a=null!=(o=null==(t=q.value.find((e=>e[I.value]===P.value)))?void 0:t[_.value])?o:P.value)?a:"",de.dispatchEvent(new CustomEvent("input")),"start"===e.cursorPlacement&&(await m(0),de.setSelectionRange(0,0))))}));function ge(e){if(!R.value)return;if(de=e.target,!de)return;if(!de.value)return P.value=null;const l=q.value.find((e=>e[_.value]===de.value));l?P.value=l[I.value]:(W.value=de.value,P.value=de.value)}const Se=a("");function be({option:l,handleClose:t}){var o;const a=null!=(o=N.value&&l[N.value])?o:l[_.value];return e.multiple?(Se.value="",e.deletable?u(B,{closable:!0,onClose:e=>{e.stopPropagation(),t()}},{default:()=>u("span",{title:a},[a])}):`${a} ;`):(Se.value=a,a)}function je(l){return u(w,n({title:Se.value,key:oe.value,multiple:e.multiple,remote:!0,filterable:!0,loading:D.value,value:pe.value,onUpdateValue:ve,"menu-props":ae,"node-props":ue,labelField:_.value,valueField:I.value,options:se.value,onSearch:Z,show:me.value,"onUpdate:show":ce,onFocus:he,onBlur:ge,renderLabel:ne,renderTag:be},l,ie),x)}return()=>{var e,l;if(!$.value)return je();const t=null!=(l=null==(e=X.value.decoratorProps)?void 0:e.span)?l:6,o=ye(fe,X.value.address);return u("section",{class:"form-render__selectChildField",style:{"--column":o+t}},[je({class:"form-render__selectChildFieldItem",style:{"--form-item-column":t}}),q.value.map((e=>T({option:e,value:P.value,valueKey:I.value,labelKey:_.value,childFieldStrategy:"checked",renderLabel:!1,attrs:{class:"form-render__selectChildFieldItem",style:{"--form-item-column":o}}})))])}}}),R({dataSource:"options"},x,O));export{_ as SELECT};
|
|
@@ -9,7 +9,9 @@ export declare function useFormExposeEvent({ formModel, formRenderRef, formUUID,
|
|
|
9
9
|
getFieldList: () => FieldItem[];
|
|
10
10
|
formItemDepsCollector: FormItemDepsCollector;
|
|
11
11
|
}): {
|
|
12
|
-
validate(path?: string
|
|
12
|
+
validate(path?: string, { force }?: {
|
|
13
|
+
force?: boolean | undefined;
|
|
14
|
+
}): Promise<void>;
|
|
13
15
|
getFormValues(needCombineExtendKey?: boolean): any;
|
|
14
16
|
setFormValues(values: AnyObject, needSplitExtendKey?: boolean, overwrite?: boolean): void;
|
|
15
17
|
setFieldState(path: string, setter: (field: IFieldState) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arrayed as e,findAncestor as t}from"../../../../shared/utils/index.js";import{isField as r}from"@formily/core";import{Path as o}from"@formily/path";import{isObject as i}from"@vue/shared";import{promiseTimeout as n}from"@vueuse/shared";import{isArray as
|
|
1
|
+
import{arrayed as e,findAncestor as t}from"../../../../shared/utils/index.js";import{isField as r}from"@formily/core";import{Path as o}from"@formily/path";import{isObject as i}from"@vue/shared";import{promiseTimeout as n}from"@vueuse/shared";import{isArray as a,isString as s,isFunction as m}from"lodash-es";import{nextTick as f}from"vue";import"../../index.js";import{FormItemLineBarDepKeyPrepend as u,NESTED_FORM_ITEM_TYPE as l}from"../constants/index.js";import{queryDecoratorByAddress as d,queryInput as c,queryDecoratorByFieldKey as p,findNextWidget as g}from"../utils/dom.js";import{validateMessageParser as v,combineExtendKey as y,splitExtendKey as h}from"../utils/index.js";import{getParentLinebar as x}from"../utils/schema.js";function I({formModel:t,formRenderRef:n,formUUID:m,getFieldList:l,formItemDepsCollector:g}){return{validate(o="*",{force:f}={}){const u=[];f&&t.setFieldState(o,(e=>{"visible"===e.display&&"editable"!==e.pattern&&r(e)&&(u.push({pattern:e.pattern,state:e}),e.pattern="editable")}));const l=t.validate(o).catch((e=>Promise.reject(Array.isArray(e)?e.reduce(p,[]):e)));return f&&u.forEach((({pattern:e,state:t})=>t.pattern=e)),l;function p(t,r){if(!i(r))return t;let o=!1;return a(r.messages)&&r.messages.forEach((r=>{i(r)&&(t.push(...e(r).map(g)),o=!0)})),!o&&t.push(g(r)),t}function g(e){if(e.decoratorElement)return e;const r=t.query(e.path),o=r.get("title"),a=e.messages.map((e=>function(e,t){if(!t||!i(t.fieldItem))return e;const r=t.fieldItem.defined_error_msg;return v(r&&s(r)?r:e,t.fieldItem)}(e,r.get("decoratorProps")))),f=d(e.address,n.value,m);return{...e,messages:a,title:o,decoratorElement:f,...c(f)}}},getFormValues(e=!0){let r=t.getFormState().values;return e&&(r=y(l(),r)),r},setFormValues(e,i=!0,n=!0){i&&(e=h(l(),e)),t.setFieldState("*",(t=>{r(t)&&(n||o.existIn(e,t.path))&&(t.value=o.getIn(e,t.path))}))},setFieldState(e,r){t.setFieldState(e,r)},resetFields:(e="*")=>t.reset(e),queryWidget:async e=>n.value?await async function(e,t,r){if(!n.value)return a();const o=p(e,t,m);if(o)return a(o);const i=x(e,r);return i?(g.trigger(u+i,!0),await f(),a(p(e,t,m))):a();function a(e){return{decoratorElement:e,...c(e)}}}(e,n.value,l()):null}}function F({props:e,formRenderRef:r,formModel:o}){return{onKeydown:async function i(a){var s;if(e.enterToNextWidget&&a.target){if("TEXTAREA"===a.target.tagName&&!a.ctrlKey)return;a.preventDefault()}if(await n(0),Reflect.get(a,"stopCapture")||!e.enterToNextWidget||!r.value)return;const f=t(a.target,(e=>e.classList.contains("form-render__formItem")));if(!f)return;const u=`.form-render__formItem${l.map((e=>`:not([widget-type=${e}])`)).join("")}`,d=Array.from(r.value.querySelectorAll(u)),c=d.findIndex((e=>e.id===f.id));if(!~c)return;const{widget:p,field:v}=g(d,c,a.target);if(p)if(m(e.enterToNextWidget)){const t=v&&o.query(v).take();!t||e.enterToNextWidget(null==(s=t.decoratorProps)?void 0:s.fieldItem)?y():i({target:p})}else y();async function y(){await n(0),p.focus()}}}}export{F as useFormDomEvent,I as useFormExposeEvent};
|
|
@@ -2,6 +2,11 @@ import { AnyObject, Func } from '../../../../../es/shared/types';
|
|
|
2
2
|
import { Ref } from 'vue';
|
|
3
3
|
import { FormWordbook, RecommendIds, UrlConfig } from '../../../../../es/components/form-render';
|
|
4
4
|
import { RecommendItem } from '../../../../../es/components/recommend-search/src/types';
|
|
5
|
+
declare type UseOptionHooks = Partial<Record<'onRequestConfigChange' | 'onDepsChange', (payload: {
|
|
6
|
+
fetchData: (content?: string | null, otherParams?: AnyObject) => any;
|
|
7
|
+
labelKey: string;
|
|
8
|
+
valueKey: string;
|
|
9
|
+
}) => any>>;
|
|
5
10
|
export declare const searchContentMatcher: (searchContent: string, label: string) => RegExpMatchArray | null;
|
|
6
11
|
export declare function useRecommendOptions(props: {
|
|
7
12
|
recommend: boolean;
|
|
@@ -16,15 +21,15 @@ export declare function useRecommendOptions(props: {
|
|
|
16
21
|
getRecommend: (content?: string) => Promise<void>;
|
|
17
22
|
sortedOptions: import("vue").ComputedRef<AnyObject[]>;
|
|
18
23
|
};
|
|
19
|
-
export declare function useUrlConfigOptions(props: {
|
|
20
|
-
labelField
|
|
21
|
-
valueField
|
|
22
|
-
showField
|
|
23
|
-
urlConfig
|
|
24
|
-
options
|
|
24
|
+
export declare function useUrlConfigOptions(props: Partial<{
|
|
25
|
+
labelField: string;
|
|
26
|
+
valueField: string;
|
|
27
|
+
showField: string;
|
|
28
|
+
urlConfig: UrlConfig;
|
|
29
|
+
options: AnyObject[];
|
|
25
30
|
requestCache: boolean;
|
|
26
31
|
lazyRequest: boolean;
|
|
27
|
-
}
|
|
32
|
+
}>, valueRef: Ref, hooks?: UseOptionHooks): {
|
|
28
33
|
labelKey: import("vue").ComputedRef<string>;
|
|
29
34
|
loading: Ref<boolean>;
|
|
30
35
|
showKey: import("vue").ComputedRef<string | undefined>;
|
|
@@ -32,7 +37,7 @@ export declare function useUrlConfigOptions(props: {
|
|
|
32
37
|
remoteOptions: Ref<AnyObject[] | null>;
|
|
33
38
|
filterOptions: import("vue").ComputedRef<AnyObject[]>;
|
|
34
39
|
fullOptions: import("vue").ComputedRef<AnyObject[]>;
|
|
35
|
-
fetchData: (content?: string) => Promise<null | undefined>;
|
|
40
|
+
fetchData: (content?: string | null, otherParams?: AnyObject) => Promise<null | undefined>;
|
|
36
41
|
searchContent: Ref<string | undefined>;
|
|
37
42
|
};
|
|
38
43
|
export declare function useAutographOptions(props: Partial<{
|
|
@@ -44,7 +49,7 @@ export declare function useAutographOptions(props: Partial<{
|
|
|
44
49
|
autograph: string;
|
|
45
50
|
lazyRequest: boolean;
|
|
46
51
|
options: AnyObject[];
|
|
47
|
-
}>, valueRef: Ref): {
|
|
52
|
+
}>, valueRef: Ref, hooks?: UseOptionHooks): {
|
|
48
53
|
labelKey: import("vue").ComputedRef<string>;
|
|
49
54
|
showKey: import("vue").ComputedRef<string | undefined>;
|
|
50
55
|
loading: Ref<boolean>;
|
|
@@ -52,6 +57,7 @@ export declare function useAutographOptions(props: Partial<{
|
|
|
52
57
|
valueKey: import("vue").ComputedRef<string>;
|
|
53
58
|
filterOptions: import("vue").ComputedRef<AnyObject[]>;
|
|
54
59
|
fullOptions: import("vue").ComputedRef<AnyObject[]>;
|
|
55
|
-
fetchData: (content?: string) => Promise<null | undefined>;
|
|
60
|
+
fetchData: (content?: string | null, otherParams?: AnyObject) => Promise<null | undefined>;
|
|
56
61
|
searchContent: Ref<string | undefined>;
|
|
57
62
|
};
|
|
63
|
+
export {};
|