cnhis-design-vue 3.1.47-release.2 → 3.1.47-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.
Files changed (68) hide show
  1. package/README.md +87 -87
  2. package/es/components/button-print/src/ButtonPrint.vue2.js +1 -1
  3. package/es/components/button-print/src/utils/print.d.ts +3 -3
  4. package/es/components/button-print/src/utils/print.js +1 -1
  5. package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcess.js +1 -1
  6. package/es/components/fabric-chart/src/hooks/index.js +1 -1
  7. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/index.d.ts +2 -0
  8. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/index.js +1 -1
  9. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useCenter.js +1 -1
  10. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useLeft.d.ts +4 -0
  11. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useLeft.js +1 -0
  12. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useOther.d.ts +4 -0
  13. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useOther.js +1 -0
  14. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useSurgicalAnesthesiaChart.js +1 -1
  15. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useTop.js +1 -1
  16. package/es/components/fabric-chart/src/hooks/temperature/useCenter.js +1 -1
  17. package/es/components/fabric-chart/src/hooks/temperature/useLeft.js +1 -1
  18. package/es/components/fabric-chart/src/hooks/useCommon.d.ts +4 -1
  19. package/es/components/fabric-chart/src/hooks/useCommon.js +1 -1
  20. package/es/components/fabric-chart/src/hooks/useDraw.d.ts +8 -0
  21. package/es/components/fabric-chart/src/hooks/useDraw.js +1 -1
  22. package/es/components/fabric-chart/src/utils/index.d.ts +7 -0
  23. package/es/components/fabric-chart/src/utils/index.js +1 -1
  24. package/es/components/form-render/src/hooks/useFormEvent.js +1 -1
  25. package/es/components/iho-table/src/hooks/useColumnConfigAdaptor.js +1 -1
  26. package/es/components/index.css +1 -1
  27. package/es/components/info-header/src/InfoHeader.vue2.js +1 -1
  28. package/es/components/info-header/style/index.css +1 -1
  29. package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
  30. package/es/components/select-label/src/LabelFormContent.vue2.js +1 -1
  31. package/es/components/select-person/index.d.ts +4 -0
  32. package/es/components/select-person/src/SearchMultiple.vue.d.ts +6 -0
  33. package/es/components/select-person/src/SelectPerson.vue.d.ts +1 -0
  34. package/es/components/select-person/src/SelectPerson.vue2.js +1 -1
  35. package/es/components/select-person/src/utils/index.d.ts +1 -1
  36. package/es/components/select-person/src/utils/index.js +1 -1
  37. package/es/components/shortcut-provider/src/hooks/useShortcuts.js +1 -1
  38. package/es/components/shortcut-provider/src/types/index.d.ts +1 -1
  39. package/es/components/table-export-field/src/components/ExportModal.vue.d.ts +0 -3
  40. package/es/components/table-filter/src/components/render-widget/components/DateInner.vue2.js +1 -1
  41. package/es/components/table-filter/src/components/render-widget/components/DateRangeInner.vue2.js +1 -1
  42. package/es/components/table-filter/src/components/render-widget/components/SelectDynamic.vue.d.ts +5 -2
  43. package/es/components/table-filter/src/components/render-widget/components/SelectDynamic.vue2.js +1 -1
  44. package/es/components/table-filter/src/components/render-widget/components/index.d.ts +5 -2
  45. package/es/components/table-filter/src/components/render-widget/widgetCfgMaps.d.ts +5 -2
  46. package/es/components/table-filter/src/hooks/useAdvanced.js +1 -1
  47. package/es/env.d.ts +25 -25
  48. package/es/shared/assets/img/failure.png.js +1 -1
  49. package/es/shared/assets/img/no-permission.png.js +1 -1
  50. package/es/shared/assets/img/nodata.png.js +1 -1
  51. package/es/shared/assets/img/notfound.png.js +1 -1
  52. package/es/shared/assets/img/qr.png.js +1 -1
  53. package/es/shared/assets/img/success.png.js +1 -1
  54. package/es/shared/assets/img/video.png.js +1 -1
  55. package/es/shared/assets/img/video_default_cover.png.js +1 -1
  56. package/es/shared/assets/img/xb_big.png.js +1 -1
  57. package/es/shared/assets/img/xb_small.png.js +1 -1
  58. package/es/shared/package.json.js +1 -1
  59. package/package.json +2 -2
  60. package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
  61. package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +0 -1
  62. package/es/components/bpmn-workflow/types/ModelingModule.d.ts +0 -1
  63. package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +0 -1
  64. package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +0 -86
  65. package/es/shared/utils/fabricjs/index.d.ts +0 -6823
  66. package/es/shared/utils/tapable/index.d.ts +0 -139
  67. package/es/shared/utils/tapableLess.d.ts +0 -28
  68. package/es/shared/utils/tapableLess.js +0 -1
package/README.md CHANGED
@@ -1,87 +1,87 @@
1
- # 安装
2
-
3
- ```shell
4
- npm i cnhis-design-vue@[版本号]
5
- # or
6
- yarn add cnhis-design-vue@[版本号] #推荐
7
- ```
8
-
9
- ## 1.全局引入
10
-
11
- ```typescript
12
- // main.ts
13
- import { createApp } from 'vue';
14
- import App from './App.vue';
15
- import 'cnhis-design-vue/es/packages/index.css';
16
- import cui from 'cnhis-design-vue';
17
-
18
- const app = createApp(App);
19
- app.use(cui).mount('#app');
20
- ```
21
-
22
- ## 2. 按需引入
23
-
24
- 组件现在支持了自动按需引入, 但是样式文件需要额外的处理
25
-
26
- ### 2.1 样式处理方式1 (按需引入样式)
27
-
28
- ```shell
29
- # 安装自动导入样式的插件
30
- npm i -d vite-plugin-style-import
31
- ```
32
-
33
- ```typescript
34
- // vite.config.ts
35
- import { defineConfig } from 'vite';
36
- import { createStyleImportPlugin } from 'vite-plugin-style-import';
37
-
38
- export default defineConfig({
39
- plugins: [
40
- // ...otherPlugins
41
- createStyleImportPlugin({
42
- libs: [
43
- {
44
- libraryName: 'cnhis-design-vue',
45
- esModule: true,
46
- ensureStyleFile: true,
47
- resolveStyle: name => {
48
- return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
49
- }
50
- }
51
- ]
52
- })
53
- ]
54
- });
55
- ```
56
-
57
- ### 2.2 样式处理方式2 (全局引入样式)
58
-
59
- ```typescript
60
- // main.ts
61
- import 'cnhis-design-vue/es/components/index.css';
62
- ```
63
-
64
- ## 3.FAQ
65
-
66
- ### 3.1 项目打包后样式丢失
67
-
68
- 处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
69
-
70
- ```typescript
71
- // vite.config.ts
72
- import { defineConfig } from 'vite';
73
-
74
- export default defineConfig({
75
- build: {
76
- rollupOptions: {
77
- // ..otherOptions
78
- output: {
79
- dir: './dist',
80
- manualChunks: {
81
- 'cnhis-vendor': ['cnhis-design-vue']
82
- }
83
- }
84
- }
85
- }
86
- });
87
- ```
1
+ # 安装
2
+
3
+ ```shell
4
+ npm i cnhis-design-vue@[版本号]
5
+ # or
6
+ yarn add cnhis-design-vue@[版本号] #推荐
7
+ ```
8
+
9
+ ## 1.全局引入
10
+
11
+ ```typescript
12
+ // main.ts
13
+ import { createApp } from 'vue';
14
+ import App from './App.vue';
15
+ import 'cnhis-design-vue/es/packages/index.css';
16
+ import cui from 'cnhis-design-vue';
17
+
18
+ const app = createApp(App);
19
+ app.use(cui).mount('#app');
20
+ ```
21
+
22
+ ## 2. 按需引入
23
+
24
+ 组件现在支持了自动按需引入, 但是样式文件需要额外的处理
25
+
26
+ ### 2.1 样式处理方式1 (按需引入样式)
27
+
28
+ ```shell
29
+ # 安装自动导入样式的插件
30
+ npm i -d vite-plugin-style-import
31
+ ```
32
+
33
+ ```typescript
34
+ // vite.config.ts
35
+ import { defineConfig } from 'vite';
36
+ import { createStyleImportPlugin } from 'vite-plugin-style-import';
37
+
38
+ export default defineConfig({
39
+ plugins: [
40
+ // ...otherPlugins
41
+ createStyleImportPlugin({
42
+ libs: [
43
+ {
44
+ libraryName: 'cnhis-design-vue',
45
+ esModule: true,
46
+ ensureStyleFile: true,
47
+ resolveStyle: name => {
48
+ return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
49
+ }
50
+ }
51
+ ]
52
+ })
53
+ ]
54
+ });
55
+ ```
56
+
57
+ ### 2.2 样式处理方式2 (全局引入样式)
58
+
59
+ ```typescript
60
+ // main.ts
61
+ import 'cnhis-design-vue/es/components/index.css';
62
+ ```
63
+
64
+ ## 3.FAQ
65
+
66
+ ### 3.1 项目打包后样式丢失
67
+
68
+ 处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
69
+
70
+ ```typescript
71
+ // vite.config.ts
72
+ import { defineConfig } from 'vite';
73
+
74
+ export default defineConfig({
75
+ build: {
76
+ rollupOptions: {
77
+ // ..otherOptions
78
+ output: {
79
+ dir: './dist',
80
+ manualChunks: {
81
+ 'cnhis-vendor': ['cnhis-design-vue']
82
+ }
83
+ }
84
+ }
85
+ }
86
+ });
87
+ ```
@@ -1 +1 @@
1
- import{defineComponent as t,reactive as e,computed as r,onMounted as a,watch as n,openBlock as i,createElementBlock as o,Fragment as l,createVNode as s,unref as m,withCtx as p,renderSlot as d,withModifiers as u,createTextVNode as c,toDisplayString as f,mergeProps as v}from"vue";import{isObject as y}from"@vue/shared";import{useMessage as b,NDropdown as g,NButton as I,NIcon as P}from"naive-ui";import{ChevronDown as w}from"@vicons/ionicons5";import{Print as h}from"./utils/print.js";import{isIReport as F}from"./utils/browserPrint.js";import k from"./components/IdentityVerification.vue.js";import{format as T}from"date-fns";import{savePrivateFormatApi as x,getPrivateFormatApi as S}from"./api.js";var D=t({__name:"ButtonPrint",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})}},emits:["success","error","clickoutside"],setup(t,{expose:D,emit:O}){var j;const E=t,L=b();let M;const N={},V=e({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null}),C=e([{label:E.printText,key:"printText"},{label:E.previewText,key:"previewText"},{label:E.pdfLoadText,key:"downloadPdf"},{label:E.formatEditText,key:"formatEditText"},...(null==(j=E.externalOptionConfig)?void 0:j.options)||[]]),Y=r((()=>{if(!V.currentFormatId)return{};let t=V.currentFormatId;return V.formatList.find((e=>e.id===t))})),J=r((()=>{var t;return(null==(t=Y.value)?void 0:t.name)||"格式选择"})),U=r((()=>{let t=V.formatList.find((t=>t.id===V.currentFormatId));return null==t?void 0:t.templateId})),A=async t=>{if(E.directPrint){if(V.spinning)return;return"button"===t?void await nt():et()}return et()},B=t=>s("span",{class:{active:t.key===V.currentFormatId}},[t.label]),q=(t,e)=>{let r={type:e,formatId:V.currentFormatId,templateId:U.value};O("success",t,r)},R=t=>{O("error",t),y(t)&&"notInstalledApp"===t.type&&L.error(t.message)},_=t=>{O("error",{message:"前置条件执行错误",type:t,preExecution:!0})},z=(t=0)=>{var e;const r=(null==(e=E.printParams)?void 0:e.length)?E.printParams[t]:V.printParams[t];return JSON.stringify({...r||{},...E.token?{token:E.token}:{}})},H=()=>{var t,e;let r={},a={};if(null==(t=V.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(V.printParams[0].datasetData||{}))?void 0:e[0])||"",r=JSON.stringify(V.printParams.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=r}else Object.keys(V.printParams[0]).forEach((t=>{a[t]=[],V.printParams.forEach((e=>{a[t].push(e[t])})),a[t]=a[t].join(",")}));return r=Object.assign({},JSON.parse(z(0)),a),JSON.stringify(r)},$=()=>{let t=V.printParams.length;const e=async e=>{try{--t<=0&&q(e,"print")}catch(t){console.log("error",t)}};E.prevFn("print").then((()=>{const t={formatId:V.currentFormatId,templateId:U.value,printdlgshow:E.printdlgshow};if("MULTI"===E.strategy)for(let r=0;r<V.printParams.length;r++)r>0&&(t.printdlgshow="0"),M.printDirect({...t,messageTimeout:0,params:z(r)},e,R);else M.printDirect({...t,messageTimeout:0,params:H()},(t=>{q(t,"print")}),R)})).catch((()=>{_("print")})).finally((()=>{V.visible=!1}))},G=async(t,e)=>{var r,a;switch(t){case"printText":$();break;case"previewText":(async()=>{E.prevFn("preview").then((()=>{const t="MULTI"===E.strategy?z():H(),e={formatId:V.currentFormatId,templateId:U.value,params:t,btnprint:E.btnprint};M.preview(e,(t=>{q(t,"preview")}),R)})).catch((()=>{_("preview")})).finally((()=>{V.visible=!1}))})();break;case"formatEditText":E.prevFn("edit").then((()=>{V.identityVerification.visible=!0})).catch((()=>{_("edit")})).finally((()=>{V.visible=!1}));break;case"downloadPdf":(async()=>{E.prevFn("download").then((()=>{const t="MULTI"===E.strategy?z():H(),e={formatId:V.currentFormatId,templateId:U.value,print:{print:"1",type:"1"},params:t};M.downloadPDF(e,(t=>q(t,"preview")),R)})).catch((()=>{_("download")})).finally((()=>{V.visible=!1}))})();break;default:{V.visible=!1;const n=V.formatList.find((e=>e.id===t))||{};if(Object.keys(n).length>0){V.currentFormatId=t;const[e]=C;e.label=(null==n?void 0:n.name)||e.label,await x({formatForms:[{...n}],name:N.name||n.templateName,number:N.number||n.number,templateId:N.templateId||n.templateId,...N.id?{id:N.id}:{}},{token:E.token})}else null==(a=null==(r=E.externalOptionConfig)?void 0:r.onSelect)||a.call(r,t,e);break}}},K=()=>{V.visible=!1,O("clickoutside")},Q=()=>(V.isInited=!1,V.spinning=!1,setTimeout((()=>{V.visible=!1}),0),!1),W=(t,e,r)=>{const a={};return e.forEach((e=>{let n=((t,e)=>{const r={DATE:"YYYY-MM-DD",DATETIME:"YYYY-MM-DD HH:mm:ss"};let a=e;return Object.keys(r).includes(t.type)&&e&&(a=T(e,r[t.type])),(null==t?void 0:t.defaultValue)||a})(e,t[e[r]]);t[e[r]]&&n&&(a[e[r]]=n)})),a},X=({customizeDataset:t=[],param:e=[]},r=[])=>r.map((r=>{let a={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;a.datasetData={[t.name]:JSON.stringify(W(r,e,"fieldName"))}})),a=Object.assign({},a,W(r,e,"key")),a})),Z=async t=>{var e;if(V.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],V.currentFormatId=await(async(t,e)=>{var r;if(!(null==t?void 0:t.length))return"";const{data:a}=await S({templateId:t[0].templateId},{token:E.token});if("SUCCESS"===a.result){const{formatForms:e=[]}=a.map||{};Object.assign(N,a.map||{});const n=null==(r=null==e?void 0:e[0])?void 0:r.id;if(n&&t.map((t=>t.id)).includes(n))return n}const n=t.find((t=>1==t[e]));return(null==n?void 0:n.id)||t[0].id})(V.formatList,"defaultFlag"),!V.currentFormatId)return L.error("获取打印格式失败,请联系管理员!"),Q();(()=>{const t=V.formatList.map((t=>({label:t.name,key:t.id})));C.unshift({label:J.value,key:"format",children:t})})();let r=null==(e=await E.queryTemplateParams())?void 0:e.obj;if(!r||!U.value)return L.error("获取打印模板失败,请联系管理员!"),Q();V.templateParams=r,V.printParams=X(V.templateParams,E.params)},tt=async()=>{if(V.isInited)return!0;V.isInited=!0,V.spinning=!0,(()=>{if(M)return!1;M=new h})();const t=await E.queryPrintFormatByNumber();return await Z(t),V.spinning=!1,!0},et=async(t=!0)=>{var e;if(await E.clickPrevFn())if(null==(e=E.params)?void 0:e.length){if(!V.visible){if(!await tt())return!1}t&&(V.visible=!V.visible)}else L.warning(E.noDataMsg)},rt=()=>{V.watchPrintParamsReformatFn&&V.watchPrintParamsReformatFn(),V.isInited?V.printParams=X(V.templateParams,E.params):V.watchPrintParamsReformatFn=()=>n((()=>V.isInited),(t=>{if(!t)return!1;rt()}))},at=t=>{if(V.identityVerification.visible=!1,F(V.currentFormatId))return q(null,"edit");const e={formatId:V.currentFormatId,templateId:U.value,params:z(),token:t};M.editPrintFormat(e,(t=>{q(t,"edit")}),R)};async function nt(){await et(!1),$()}return a((()=>{V.isInited=!1})),n((()=>E.params),(t=>{if(!(null==t?void 0:t.length))return!1;rt()}),{deep:!0}),D({directPrint:nt}),(e,r)=>(i(),o(l,null,[s(m(g),{class:"c-dropdown",placement:"bottom-start",trigger:"click",show:V.visible,onClickoutside:K,options:C,onSelect:G,"render-label":B},{default:p((()=>[d(e.$slots,"button",{handleClickPrintBtn:et,printSpinning:V.spinning,printbtnText:t.btnText,printVisible:V.visible},(()=>[s(m(I),{class:"dropdown-button",onClick:r[1]||(r[1]=u((()=>A("button")),["stop"]))},{default:p((()=>[c(f(t.btnText)+" ",1),s(m(P),{component:m(w),style:{"margin-left":"5px"},onClick:r[0]||(r[0]=u((()=>A("icon")),["stop"]))},null,8,["component"])])),_:1})]))])),_:3},8,["show","options"]),s(k,v(e.$attrs,{modelValue:V.identityVerification.visible,"onUpdate:modelValue":r[2]||(r[2]=t=>V.identityVerification.visible=t),formatId:V.currentFormatId,templateId:m(U),onSuccess:at}),null,16,["modelValue","formatId","templateId"])],64))}});export{D as default};
1
+ import{defineComponent as t,reactive as e,computed as r,onMounted as a,watch as n,openBlock as i,createElementBlock as o,Fragment as l,createVNode as s,unref as m,withCtx as p,renderSlot as d,withModifiers as u,createTextVNode as c,toDisplayString as f,mergeProps as v}from"vue";import{isObject as y}from"@vue/shared";import{useMessage as b,NDropdown as g,NButton as I,NIcon as P}from"naive-ui";import{ChevronDown as w}from"@vicons/ionicons5";import{Print as h}from"./utils/print.js";import{isIReport as F}from"./utils/browserPrint.js";import k from"./components/IdentityVerification.vue.js";import{format as T}from"date-fns";import{savePrivateFormatApi as x,getPrivateFormatApi as S}from"./api.js";var D=t({__name:"ButtonPrint",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})}},emits:["success","error","clickoutside"],setup(t,{expose:D,emit:O}){var j;const E=t,L=b();let M;const N={},V=e({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null}),C=e([{label:E.printText,key:"printText"},{label:E.previewText,key:"previewText"},{label:E.pdfLoadText,key:"downloadPdf"},{label:E.formatEditText,key:"formatEditText"},...(null==(j=E.externalOptionConfig)?void 0:j.options)||[]]),Y=r((()=>{if(!V.currentFormatId)return{};let t=V.currentFormatId;return V.formatList.find((e=>e.id===t))})),J=r((()=>{var t;return(null==(t=Y.value)?void 0:t.name)||"格式选择"})),U=r((()=>{let t=V.formatList.find((t=>t.id===V.currentFormatId));return null==t?void 0:t.templateId})),A=async t=>{if(E.directPrint){if(V.spinning)return;return"button"===t?void await nt():et()}return et()},B=t=>s("span",{class:{active:t.key===V.currentFormatId}},[t.label]),q=(t,e)=>{let r={type:e,formatId:V.currentFormatId,templateId:U.value};O("success",t,r)},R=t=>{O("error",t),y(t)&&"notInstalledApp"===t.type&&L.error(t.message)},_=t=>{O("error",{message:"前置条件执行错误",type:t,preExecution:!0})},z=(t=0)=>{var e;const r=(null==(e=E.printParams)?void 0:e.length)?E.printParams[t]:V.printParams[t];return JSON.stringify({...r||{},...E.token?{token:E.token}:{}})},H=()=>{var t,e;let r={},a={};if(null==(t=V.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(V.printParams[0].datasetData||{}))?void 0:e[0])||"",r=JSON.stringify(V.printParams.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=r}else Object.keys(V.printParams[0]).forEach((t=>{a[t]=[],V.printParams.forEach((e=>{a[t].push(e[t])})),a[t]=a[t].join(",")}));return r=Object.assign({},JSON.parse(z(0)),a),JSON.stringify(r)},$=()=>{let t=V.printParams.length;const e=async e=>{try{--t<=0&&q(e,"print")}catch(t){console.log("error",t)}};E.prevFn("print").then((()=>{const t={formatId:V.currentFormatId,templateId:U.value,printdlgshow:E.printdlgshow};if("MULTI"===E.strategy)for(let r=0;r<V.printParams.length;r++)r>0&&(t.printdlgshow="0"),M.printDirect({...t,params:z(r)},e,R);else M.printDirect({...t,params:H()},(t=>{q(t,"print")}),R)})).catch((()=>{_("print")})).finally((()=>{V.visible=!1}))},G=async(t,e)=>{var r,a;switch(t){case"printText":$();break;case"previewText":(async()=>{E.prevFn("preview").then((()=>{const t="MULTI"===E.strategy?z():H(),e={formatId:V.currentFormatId,templateId:U.value,params:t,btnprint:E.btnprint};M.preview(e,(t=>{q(t,"preview")}),R)})).catch((()=>{_("preview")})).finally((()=>{V.visible=!1}))})();break;case"formatEditText":E.prevFn("edit").then((()=>{V.identityVerification.visible=!0})).catch((()=>{_("edit")})).finally((()=>{V.visible=!1}));break;case"downloadPdf":(async()=>{E.prevFn("download").then((()=>{const t="MULTI"===E.strategy?z():H(),e={formatId:V.currentFormatId,templateId:U.value,print:{print:"1",type:"1"},params:t};M.downloadPDF(e,(t=>q(t,"preview")),R)})).catch((()=>{_("download")})).finally((()=>{V.visible=!1}))})();break;default:{V.visible=!1;const n=V.formatList.find((e=>e.id===t))||{};if(Object.keys(n).length>0){V.currentFormatId=t;const[e]=C;e.label=(null==n?void 0:n.name)||e.label,await x({formatForms:[{...n}],name:N.name||n.templateName,number:N.number||n.number,templateId:N.templateId||n.templateId,...N.id?{id:N.id}:{}},{token:E.token})}else null==(a=null==(r=E.externalOptionConfig)?void 0:r.onSelect)||a.call(r,t,e);break}}},K=()=>{V.visible=!1,O("clickoutside")},Q=()=>(V.isInited=!1,V.spinning=!1,setTimeout((()=>{V.visible=!1}),0),!1),W=(t,e,r)=>{const a={};return e.forEach((e=>{let n=((t,e)=>{const r={DATE:"YYYY-MM-DD",DATETIME:"YYYY-MM-DD HH:mm:ss"};let a=e;return Object.keys(r).includes(t.type)&&e&&(a=T(e,r[t.type])),(null==t?void 0:t.defaultValue)||a})(e,t[e[r]]);t[e[r]]&&n&&(a[e[r]]=n)})),a},X=({customizeDataset:t=[],param:e=[]},r=[])=>r.map((r=>{let a={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;a.datasetData={[t.name]:JSON.stringify(W(r,e,"fieldName"))}})),a=Object.assign({},a,W(r,e,"key")),a})),Z=async t=>{var e;if(V.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],V.currentFormatId=await(async(t,e)=>{var r;if(!(null==t?void 0:t.length))return"";const{data:a}=await S({templateId:t[0].templateId},{token:E.token});if("SUCCESS"===a.result){const{formatForms:e=[]}=a.map||{};Object.assign(N,a.map||{});const n=null==(r=null==e?void 0:e[0])?void 0:r.id;if(n&&t.map((t=>t.id)).includes(n))return n}const n=t.find((t=>1==t[e]));return(null==n?void 0:n.id)||t[0].id})(V.formatList,"defaultFlag"),!V.currentFormatId)return L.error("获取打印格式失败,请联系管理员!"),Q();(()=>{const t=V.formatList.map((t=>({label:t.name,key:t.id})));C.unshift({label:J.value,key:"format",children:t})})();let r=null==(e=await E.queryTemplateParams())?void 0:e.obj;if(!r||!U.value)return L.error("获取打印模板失败,请联系管理员!"),Q();V.templateParams=r,V.printParams=X(V.templateParams,E.params)},tt=async()=>{if(V.isInited)return!0;V.isInited=!0,V.spinning=!0,(()=>{if(M)return!1;M=new h})();const t=await E.queryPrintFormatByNumber();return await Z(t),V.spinning=!1,!0},et=async(t=!0)=>{var e;if(await E.clickPrevFn())if(null==(e=E.params)?void 0:e.length){if(!V.visible){if(!await tt())return!1}t&&(V.visible=!V.visible)}else L.warning(E.noDataMsg)},rt=()=>{V.watchPrintParamsReformatFn&&V.watchPrintParamsReformatFn(),V.isInited?V.printParams=X(V.templateParams,E.params):V.watchPrintParamsReformatFn=()=>n((()=>V.isInited),(t=>{if(!t)return!1;rt()}))},at=t=>{if(V.identityVerification.visible=!1,F(V.currentFormatId))return q(null,"edit");const e={formatId:V.currentFormatId,templateId:U.value,params:z(),token:t};M.editPrintFormat(e,(t=>{q(t,"edit")}),R)};async function nt(){await et(!1),$()}return a((()=>{V.isInited=!1})),n((()=>E.params),(t=>{if(!(null==t?void 0:t.length))return!1;rt()}),{deep:!0}),D({directPrint:nt}),(e,r)=>(i(),o(l,null,[s(m(g),{class:"c-dropdown",placement:"bottom-start",trigger:"click",show:V.visible,onClickoutside:K,options:C,onSelect:G,"render-label":B},{default:p((()=>[d(e.$slots,"button",{handleClickPrintBtn:et,printSpinning:V.spinning,printbtnText:t.btnText,printVisible:V.visible},(()=>[s(m(I),{class:"dropdown-button",onClick:r[1]||(r[1]=u((()=>A("button")),["stop"]))},{default:p((()=>[c(f(t.btnText)+" ",1),s(m(P),{component:m(w),style:{"margin-left":"5px"},onClick:r[0]||(r[0]=u((()=>A("icon")),["stop"]))},null,8,["component"])])),_:1})]))])),_:3},8,["show","options"]),s(k,v(e.$attrs,{modelValue:V.identityVerification.visible,"onUpdate:modelValue":r[2]||(r[2]=t=>V.identityVerification.visible=t),formatId:V.currentFormatId,templateId:m(U),onSuccess:at}),null,16,["modelValue","formatId","templateId"])],64))}});export{D as default};
@@ -41,11 +41,11 @@ export declare class Print {
41
41
  formatId: string;
42
42
  };
43
43
  _handleEventDirect({ templateId, formatId, params, cmdid, print, printdlgshow, nobillnode, btnprint, messageTimeout }: AnyObject): Promise<any>;
44
- _handleEventEditFormat({ templateId, formatId, params, token }: AnyObject): Promise<any>;
44
+ _handleEventEditFormat({ templateId, formatId, params, token, messageTimeout }: AnyObject): Promise<any>;
45
45
  _queryProxyOrigin(): Promise<void>;
46
46
  _queryPrintFile(formatId: string, params?: string): Promise<any>;
47
47
  _browserPrint(result: AnyObject, mode: string): Promise<string | void>;
48
- preview({ templateId, formatId, params, btnprint }: AnyObject, successCallbackFn?: Func, errorCallbackFn?: Func): Promise<any>;
48
+ preview({ templateId, formatId, params, btnprint, messageTimeout }: AnyObject, successCallbackFn?: Func, errorCallbackFn?: Func): Promise<any>;
49
49
  printDirect({ templateId, formatId, params, print, printdlgshow, nobillnode, isDownloadFile, messageTimeout }: AnyObject, successCallbackFn: Func, errorCallbackFn: Func, mode?: string): Promise<any>;
50
50
  private _downloadPDF;
51
51
  /**
@@ -60,6 +60,6 @@ export declare class Print {
60
60
  formatId: string;
61
61
  }>;
62
62
  printFileData({ formatId, file, printerName }: AnyObject, successCallbackFn?: Func, errorCallbackFn?: Func): Promise<false | AnyObject>;
63
- editPrintFormat({ templateId, formatId, params, token }: AnyObject, successCallbackFn?: Func, errorCallbackFn?: Func): Promise<false | undefined>;
63
+ editPrintFormat({ templateId, formatId, params, token, messageTimeout }: AnyObject, successCallbackFn?: Func, errorCallbackFn?: Func): Promise<false | undefined>;
64
64
  addPrintFormat({ templateId, params, token }: AnyObject, successCallbackFn?: Func, errorCallbackFn?: Func): Promise<false | undefined>;
65
65
  }
@@ -1 +1 @@
1
- import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as n,useBrowserPrint as r,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as d}from"date-fns";const h=t.create({timeout:1e3,withCredentials:!1}),c=`${window.location.protocol}//${window.location.host}`,m=`${c}/fdp-api/print/assembly/printIReport`,u=`${c}/bi-api/reprot/print/open/client/getRemote`,p=`${c}/printService/file`;let f=null;class w{constructor(){var t;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.isRemote=!1,this.CMonitor=null,this.messageHandlerQueue=[],f)return f;f=this;const e=window;if(this.CMonitor=e.$CMonitor,this.webview=null==(t=e.chrome)?void 0:t.webview,this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:n}=e;try{s(i.res||"")}catch(t){n(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}async postMessage(t,e=5e3){if(!this.webview)return Promise.reject();const i=l();return 0===e?this.messageCollect(i,t):this.messageCollectAndNotifyFail(i,t,e)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{h({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):h({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const i=t.message||t.Message;this._handleMonitorNotify(i);const s={type:"printError",message:i,result:t.result,errinfo:t.errinfo};return null==e||e(s),!1}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,n){const r={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(r);return this._handleQueryPrintDataResult(a,e,n)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,cmdid:s,print:n,printdlgshow:r="0",nobillnode:a="1",btnprint:o="1",messageTimeout:l=5e3}){const h={templateId:t,formatId:e,params:i,cmdid:s,nobillnode:a,printdlgshow:r,btnprint:o,messageTimeout:l};if(n){try{n=JSON.parse(n)}catch(t){}h.print=n}else if(this.isRemote){const t=d(new Date,"yyyyMMddHHmmss");h.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return await this._queryServicesPrint(h)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s}){const n={};let r={};try{r=Object.assign({},n,JSON.parse(i))}catch(t){r=n}const a={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(r)};return await this._queryServicesPrint(a)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await h({method:"get",url:u})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=c+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await h({method:"post",url:m,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await n(`${p}/${a}/${o}`),d=r(null,e,l);if("preview"===e)return d}}async preview({templateId:t,formatId:e,params:i="",btnprint:s},n,l){if(a(e)){const t=await this._queryPrintFile(e,i);if(!t)return null==l?void 0:l("获取文件失败!");const s=r(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,s),void(null==n||n({file:t}))}await this._queryProxyOrigin();const d=await this._testConnection();if(!this._handleResultTest(d,l))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:this.isRemote?"7":"8",btnprint:s}),a=this._handleResult(r,l);if(!a)return!1;if(this.isRemote){const t=await this._browserPrint(a,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}null==n||n(a)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==l||l(i),this._handleMonitorNotify(i)}}async printDirect({templateId:t,formatId:e,params:i="",print:s,printdlgshow:n,nobillnode:o,isDownloadFile:l=!0,messageTimeout:d=5e3},h,c,m="printDirect"){if(a(e)){const t=await this._queryPrintFile(e,i);return t?(r(t,m),void(null==h||h({file:t}))):null==c?void 0:c("获取文件失败!")}await this._queryProxyOrigin();const u=await this._testConnection();if(!this._handleResultTest(u,c))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:"7",print:s,printdlgshow:n,nobillnode:o,messageTimeout:d}),a=this._handleResult(r,c);if(!a)return!1;l&&["downloadPDF"].includes(m)&&await this._browserPrint(a,m),null==h||h(a)}catch(t){const e="printDirect"===m?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==c||c(i),this._handleMonitorNotify(i)}}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):h.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}downloadPDF(t,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=d(new Date,"yyyy-MM-dd"),i=l(),s=d(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}this.printDirect(t,(async n=>{if(n||s(null),a(t.formatId))return i(n);const r=this,o=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(n.filedir);i(o,n)}),(t=>s(t)),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=5e3},n,r){const a=await this._testConnection();if(!this._handleResultTest(a,r))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,r);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,r);if(!l)return!1;n&&n(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=5e3},n,r){const a=await this._testConnection();if(!this._handleResultTest(a,r))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,r);return!!o&&(n&&n(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,n){const r=await this._testConnection();if(!this._handleResultTest(r,n))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,n);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s},n,r){const a=await this._testConnection();if(!this._handleResultTest(a,r))return!1;const o=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s}),l=this._handleResult(o,r);if(!l)return!1;n&&n(l)}async addPrintFormat({templateId:t,params:e,token:i},s,n){const r=await this._testConnection();if(!this._handleResultTest(r,n))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,n);if(!o)return!1;s&&s(o)}}export{w as Print};
1
+ import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as n,useBrowserPrint as r,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as d}from"date-fns";const h=t.create({timeout:1e3,withCredentials:!1}),m=`${window.location.protocol}//${window.location.host}`,c=`${m}/fdp-api/print/assembly/printIReport`,u=`${m}/bi-api/reprot/print/open/client/getRemote`,p=`${m}/printService/file`;let w=null;class f{constructor(){var t,e,n;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.isRemote=!1,this.CMonitor=null,this.messageHandlerQueue=[],w)return w;w=this;const r=window;this.CMonitor=r.$CMonitor;try{this.webview=r.top?null==(t=r.top.chrome)?void 0:t.webview:null==(e=r.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(n=r.chrome)?void 0:n.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:n}=e;try{s(i.res||"")}catch(t){n(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{h({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):h({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const i=t.message||t.Message;this._handleMonitorNotify(i);const s={type:"printError",message:i,result:t.result,errinfo:t.errinfo};return null==e||e(s),!1}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,n){const r={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(r);return this._handleQueryPrintDataResult(a,e,n)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,cmdid:s,print:n,printdlgshow:r="0",nobillnode:a="1",btnprint:o="1",messageTimeout:l=0}){const h={templateId:t,formatId:e,params:i,cmdid:s,nobillnode:a,printdlgshow:r,btnprint:o,messageTimeout:l};if(n){try{n=JSON.parse(n)}catch(t){}h.print=n}else if(this.isRemote){const t=d(new Date,"yyyyMMddHHmmss");h.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return await this._queryServicesPrint(h)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:n=0}){const r={};let a={};try{a=Object.assign({},r,JSON.parse(i))}catch(t){a=r}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:n};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await h({method:"get",url:u})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=m+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await h({method:"post",url:c,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await n(`${p}/${a}/${o}`),d=r(null,e,l);if("preview"===e)return d}}async preview({templateId:t,formatId:e,params:i="",btnprint:s,messageTimeout:n=0},l,d){if(a(e)){const t=await this._queryPrintFile(e,i);if(!t)return null==d?void 0:d("获取文件失败!");const s=r(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,s),void(null==l||l({file:t}))}await this._queryProxyOrigin();const h=await this._testConnection();if(!this._handleResultTest(h,d))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:this.isRemote?"7":"8",btnprint:s,messageTimeout:n}),a=this._handleResult(r,d);if(!a)return!1;if(this.isRemote){const t=await this._browserPrint(a,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}null==l||l(a)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==d||d(i),this._handleMonitorNotify(i)}}async printDirect({templateId:t,formatId:e,params:i="",print:s,printdlgshow:n,nobillnode:o,isDownloadFile:l=!0,messageTimeout:d=0},h,m,c="printDirect"){if(a(e)){const t=await this._queryPrintFile(e,i);return t?(r(t,c),void(null==h||h({file:t}))):null==m?void 0:m("获取文件失败!")}await this._queryProxyOrigin();const u=await this._testConnection();if(!this._handleResultTest(u,m))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:"7",print:s,printdlgshow:n,nobillnode:o,messageTimeout:d}),a=this._handleResult(r,m);if(!a)return!1;l&&["downloadPDF"].includes(c)&&await this._browserPrint(a,c),null==h||h(a)}catch(t){const e="printDirect"===c?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==m||m(i),this._handleMonitorNotify(i)}}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):h.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}downloadPDF(t,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=d(new Date,"yyyy-MM-dd"),i=l(),s=d(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}this.printDirect(t,(async n=>{if(n||s(null),a(t.formatId))return i(n);const r=this,o=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(n.filedir);i(o,n)}),(t=>s(t)),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},n,r){const a=await this._testConnection();if(!this._handleResultTest(a,r))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,r);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,r);if(!l)return!1;n&&n(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},n,r){const a=await this._testConnection();if(!this._handleResultTest(a,r))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,r);return!!o&&(n&&n(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,n){const r=await this._testConnection();if(!this._handleResultTest(r,n))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,n);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:n=0},r,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:n}),d=this._handleResult(l,a);if(!d)return!1;r&&r(d)}async addPrintFormat({templateId:t,params:e,token:i},s,n){const r=await this._testConnection();if(!this._handleResultTest(r,n))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,n);if(!o)return!1;s&&s(o)}}export{f as Print};
@@ -1 +1 @@
1
- import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawLine as e,drawArrow as n,drawText as o,defaultTextStyle as i,drawPoint as r,defaultStyle as l,defaultRectStyle as s}from"../useDraw.js";import{useGrid as a}from"../useGrid.js";import{useBirthProcessCumputedPoint as u}from"../useCumputedPoint.js";import"@vueuse/core";import{getScaleInfo as c,drawScaleNumber as f,drawScaleLine as d}from"../useScaleColumn.js";import{useCommon as p}from"../useCommon.js";import"vue";import{getIndex as h,isEffectiveNode as g,getTime as v}from"../../utils/index.js";import"../temperature/useShadow.js";import{cloneDeep as m}from"lodash-es";import{format as y}from"date-fns";function k(k,w,x,b,j){const{cumputedX:S,cumputedY:C,getXValue:T,getYValue:M}=u(w),{getEqualXTypes:P,handleAddPrevent:E}=p(k,x),{xAxis:G,grid:L,originX:Y,originY:X,xCellWidth:A,endY:H,startTime:I,leftAddAreaWidth:O,leftScales:W,rightScales:V,yCellHeight:D,endX:N,scaleValues:R,canvasWidth:$,borderStyle:B,rightAddAreaWidth:F,event:q,originYCervix:z,other:J,canvasHeight:K}=w,Q=m(R),U=new Set;function Z(){Q.filter((t=>t.show)).forEach(((t,l)=>{var s;const a=[],u=[],c=[];null==(s=t.data)||s.forEach(((s,f)=>{!function(s,f,d){let p,h;const{pointAttr:g={},lineAttr:v={},title:m="",key:y,type:j="circle",childbirthStyle:S={}}=t,C=t.data[d+1],P=ot(C,t);if(s&&P&&!f.breakpoint)h=e([...s,...P],{...v});else if(s&&!P&&!f.breakpoint){const n=ot(C,t);h=n?e([...s,...n],{...v}):null}let E,G;if(f.childbirth){const t=s[1]+D;E=n([s[0],s[1],t],S),c.push(E),G=o([s[0]+A/2,t-D/2],{value:String(f.childbirth),...i,originX:"left",originY:"center",...S}),c.push(G)}const L=u[d-1],Y={origin:{data:f,title:m,key:y||"",dataIndex:l,index:d},leftLine:L,rightLine:h,arrowGroup:E,arrowGroupText:G,...g,...w.event.hovered?w.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:w.event};L?p=r(j,{left:L.get("x2"),top:L.get("y2"),...Y}):s&&(Y.leftLine=null,p=r(j,{left:s[0],top:s[1],...Y}));u.push(h),p&&(!function(t){q.hovered&&(t.on("mouseover",(()=>{nt(t,"hover")})),t.on("mouseout",(()=>{b.show=!1})));if(t.lockMovementX&&t.lockMovementY)return;t.on("moving",(()=>{et(t),function(t){var e,n,o,i;null==(e=t.leftLine)||e.setCoords().set({x2:t.left,y2:t.top}),null==(n=t.rightLine)||n.setCoords().set({x1:t.left,y1:t.top}),null==(o=t.arrowGroup)||o.setCoords().set({left:t.left,top:t.top}),null==(i=t.arrowGroupText)||i.setCoords().set({left:t.left+A/2,top:t.top+D/2})}(t),q.hovered&&nt(t)})),t.on("mouseup",(e=>{if(b.show=!1,1===e.button){const{key:e}=t.origin,n={...t.origin,data:{...t.origin.data,time:T(t.left),value:M(e,t.top)}};k.value.discardActiveObject(),x("change",n),_(n,"change")}}))}(p),a.push(p),U.add(p))}(ot(s,t),s,f)})),Promise.all(a).then((t=>{const e=u.filter((t=>t));let n=null;t=t.filter((t=>(t&&n&&(n.nextPoint=t,t.prevPoint=n),n=t||n,t))),Promise.all(c).then((n=>{k.value.add(...e,...t,...n),t.forEach((t=>{null==t||t.bringToFront()}))}))}))}))}function _(t,e="add"){const{dataIndex:n,data:o,index:i,key:r}=t,l=Q.find((t=>t.key===r));switch(e){case"remove":l.data.splice(i,1);break;case"change":l.data[i]=o;break;default:{const t=h(o.time,l.data);l.data.splice(t,0,o);break}}tt()}function tt(){var t;U.size&&(null==(t=k.value)||t.remove(...function(t){const e=[];return t.forEach((t=>{t&&e.push(t),(null==t?void 0:t.leftLine)&&e.push(null==t?void 0:t.leftLine),(null==t?void 0:t.rightLine)&&e.push(null==t?void 0:t.rightLine),(null==t?void 0:t.arrowGroup)&&e.push(null==t?void 0:t.arrowGroup),(null==t?void 0:t.arrowGroupText)&&e.push(null==t?void 0:t.arrowGroupText)})),e}([...U]))),U.clear(),Z()}function et(t){const e=t.prevPoint?t.prevPoint.left:Y,n=t.nextPoint?t.nextPoint.left:N;t.setCoords(),["cervix","fetalPresentation"].includes(t.origin.key)&&t.top<z&&t.set("top",z),t.top<X&&t.set("top",X),t.top>H&&t.set("top",H),t.left<e&&t.set("left",e),t.left>n&&t.set("left",n)}function nt(t,e="moving"){const{title:n,key:o,data:i}=t.origin;b.point={x:t.left,y:t.top},b.list=[`${n} ${"hover"===e?i.value:M(o,t.top)}`,`时间 ${T(t.left).slice(-5)}`],b.show=!0}function ot(t,e){if(g(t)&&function(t){const e=I+864e5,n=v(t);return n>=I&&n<=e}(t.time)){const n=S(t.time),o=C(e.key,e.range,t.value);return[n,o<X?X:o>H?H:o]}}function it(t,e){return t+1>e[1]?e[0]:t+1}return a(k,w),function(){const e=new t.Rect({...B,width:$-O-F-1,height:H-1,left:O,top:0,fill:"transparent"});k.value.add(e)}(),function(){function e(e,n="left"){let r="left"===n?O:N;e.forEach(((e,n)=>{const{range:a,spaceValue:u,width:p,title:h,titleStyle:g,key:v,position:m="center",spaceGridNumber:y=1,showNumber:w,showMaxMinNumber:x}=e,b=[],j=[],S=r+p/2,C=function(t,e){const n=[],[o,i]=t;for(let t=o;e>0?t<=i:t>=i;t+=e)n.push(t);return n}(a,u),T=C.length;C.forEach(((t,n)=>{const{lineXMain:o,lineXSub:i,textLeft:l}=c(m,r,p),s=H-n*D*y,a=0===n?H-8:n!==C.length-1||X||z&&"FHR"!==v?s:X+8;!w||(0===n||n===T-1)&&!x||b.push(f(String(t),e,l,a)),j.push(...d(e,n,o,i,s,D,X,T))}));const M=new t.Rect({...s,strokeWidth:.5,width:p,height:H,left:S,top:H/2}),P=o([S,X>0?X-D/2:D/2],{value:String(h),...i,...g}),E=new t.Group([...j,...b,M,...P?[P]:[]],{objectCaching:!1,...l});k.value.add(E),E.sendToBack(),r+=p}))}e(W),e(V,"right")}(),function(){const{show:e,startTime:n,range:r=[0,23],position:s="top",style:a}=G.time,{show:u,range:c=[0,23],position:f,style:d}=G.processTime;if(e||u){const p=[],h=[],g=[],v=[],m=Y+A/2,y=D/2;for(let t=0;t<L.mainXCell;t++){if(e){const e=0===t?+n.slice(11,13):it(p.at(-1),r);p.push(e);const l="top"===s?X-y:H+y;g.push(o([m+t*A,l],{value:String(e),...i,...a||{}}))}if(u){const e=0===t?c[0]:h.at(-1)+1;h.push(e);const n="top"===f?y:K-y;v.push(o([m+t*A,n],{value:String(e),...i,...d||{}}))}}const w=new t.Group([...g,...v],{objectCaching:!1,...l});k.value.add(w),k.value.sendToBack(w)}}(),function(){var t;const n=Object.values(J),o=[],i={},r=Q.find((t=>"cervix"===t.key&&t.show)),l=null==(t=null==r?void 0:r.data)?void 0:t.find((t=>3==+t.value));function s(t,e){const{key:n,range:o}=r||{},i=C(n,o,10),l=[0,e],s=[-e/t,0],a=[(H-i-e)/t,H-i],u=[N-Y,t*(N-Y)+e];let c=[],f=[];function d([n,o]){return Math.abs(o-t*n-e)<=1}function p([t,e]){const[n,o]=[...h([t,e])];return n>=Y&&n<=N&&o>=i&&o<=H}function h([t,e]){return[Y+t,H-e]}return d(l)&&p(l)&&(c=h(l)),d(s)&&p(s)&&(c=h(s)),d(a)&&p(a)&&(f=h(a)),d(u)&&p(u)&&(f=h(u)),[...c,...f]}n.forEach((t=>{if(!t.show)return;const{key:n}=t;switch(n){case"fetalPresentation":{const{range:i,show:r}=Q.find((t=>t.key===n));if(r){const r=C(n,i,0);o.push(e([Y,r,N,r],{...t}))}break}case"alert":if(l){const{key:n,range:a}=r||{},u=216e5,c={time:y(new Date(v(l.time)+u),"yyyy-MM-dd HH:mm"),value:10},[f,d]=[S(l.time)-Y,H-C(n,a,l.value)],[p,h]=[S(c.time)-Y,H-C(n,a,c.value)],g=(h-d)/(p-f),m=d-f*g,k=s(g,m);k.length>0&&(o.push(e(k,{...t})),Object.assign(i,{k:g,b:m}))}break;case"handling":if(l){const{k:n,b:r}=i,a=144e5,u=s(n,r-(S(y(new Date(v(l.time)+a),"yyyy-MM-dd HH:mm"))-S(l.time))*n);u.length>0&&o.push(e(u,{...t}))}}})),k.value.add(...o)}(),Z(),function(){function t(t,e){const n=Q.findIndex((e=>e.key===t.key));return{renderItem:()=>t.title,origin:{title:t.title,unit:t.unit,dataIndex:n,key:t.key},pointer:e}}w.event.evented&&k.value.on("mouse:up",(e=>{if(3===e.button){const{x:n=0,y:o=0}=e.pointer||{};n>=Y&&n<=N&&o>=X&&o<=H&&(j.point={x:n,y:o},j.show=!0,e.target?(j.target=e.target,j.list=["删除节点"],k.value.forEachObject((t=>{t.origin&&t.left===e.target.left&&t.top===e.target.top&&j.list.push({renderItem:()=>t.origin.title,origin:{...t.origin},mode:"remove",pointer:e.pointer})}))):(j.target=null,j.list=["新增节点"],Q.filter((t=>t.show)).forEach((i=>{if(!P(n,"key",A).includes(i.key)){if(["cervix","fetalPresentation"].includes(i.key)&&o<z)return;j.list.push(t(i,e.pointer))}})),1===j.list.length&&(j.show=!1,E("repeat"),console.log("当前时间段内无可新增节点"))))}}))}(),function(){const e=$-F/2;function n(e,n){if(!e.length)return;let l=X;const s=[];e.forEach((e=>{const o=e.title.split("").join("\n"),a=R.findIndex((t=>t.key===e.key)),u=new t.Text(String(o),{...i,...e.titleStyle||{},originY:"top",left:n,top:l,lineHeight:1}),c=r(e.type,{left:n,top:l+u.height+3,...e.pointAttr,originY:"top",origin:{title:e.title,unit:e.unit,type:e.type,dataIndex:a,key:e.key,isMenu:!0},originLeft:n,originTop:l+u.height+3,...w.event});l+=u.height+c.height+15,function(t){function e(t){const{left:e,top:n}=t;return e>=Y&&e<=N&&n>=X&&n<=H}t.on("moving",(()=>{t.set("originY","center"),e(t)?(et(t),nt(t)):b.show=!1})),t.on("mouseup:before",(n=>{if(b.show=!1,0===n.e.button&&e(t))if(P(t.left,"key",A).includes(t.origin.key))E("repeat");else{const e={data:{time:T(t.left),value:M(t.origin.key,t.top)},...t.origin};x("add",e),_(e)}!function(t){t.setCoords().set({originY:"top",left:t.originLeft,top:t.originTop})}(t)}))}(c),s.push(u,c)})),o(s),k.value.add(...s)}function o(t){const e=t.at(-1),n=(H-X)/2,o=(e.height+e.top-X)/2;t.forEach((t=>{const e=t.top+n-o;t.set({top:e,originTop:e})}))}n(W,O/2),n(V,e)}(),{clickMenu:function({item:t,target:e}){const n={...t.origin};"remove"===t.mode?(x("remove",n),_(n,"remove")):(Object.assign(n,{data:{time:T(t.pointer.x),value:M(t.origin.key,t.pointer.y)}}),x("add",n),_(n))},redrawPoints:tt}}export{k as useBirthProcess};
1
+ import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{drawLine as t,drawArrow as o,drawText as n,defaultTextStyle as i,drawPoint as r,drawTextAndIconGroup as l,defaultStyle as s,defaultRectStyle as a}from"../useDraw.js";import{useGrid as u}from"../useGrid.js";import{useBirthProcessCumputedPoint as c}from"../useCumputedPoint.js";import"@vueuse/core";import{getScaleInfo as d,drawScaleNumber as f,drawScaleLine as p}from"../useScaleColumn.js";import{useCommon as h}from"../useCommon.js";import"vue";import{getIndex as g,isEffectiveNode as v,getTime as m,getScaleNumberList as y}from"../../utils/index.js";import"../temperature/useShadow.js";import{cloneDeep as k}from"lodash-es";import{format as w}from"date-fns";function x(x,b,j,C,P){const{cumputedX:S,cumputedY:G,getXValue:M,getYValue:T}=c(b),{getEqualXTypes:Y,handleAddPrevent:E,isGridLimit:L}=h(x,j,b),{xAxis:X,grid:A,originX:I,originY:H,xCellWidth:O,endY:W,startTime:V,leftAddAreaWidth:D,leftScales:N,rightScales:R,yCellHeight:$,endX:B,scaleValues:F,canvasWidth:q,borderStyle:z,rightAddAreaWidth:J,event:K,originYCervix:Q,other:U,canvasHeight:Z}=b,_=k(F),ee=new Set;function te(){_.filter((e=>e.show)).forEach(((e,l)=>{var s;const a=[],u=[],c=[];null==(s=e.data)||s.forEach(((s,d)=>{!function(s,d,f){let p,h;const{pointAttr:g={},lineAttr:v={},title:m="",key:y,type:k="circle",childbirthStyle:w={}}=e,P=e.data[f+1],S=le(P,e);if(s&&S&&!d.breakpoint)h=t([...s,...S],{...v});else if(s&&!S&&!d.breakpoint){const o=le(P,e);h=o?t([...s,...o],{...v}):null}let G,Y;if(d.childbirth){const e=s[1]+$;G=o([s[0],s[1],e],w),c.push(G),Y=n([s[0]+O/2,e-$/2],{value:String(d.childbirth),...i,originX:"left",originY:"center",...w}),c.push(Y)}const E=u[f-1],L={origin:{data:d,title:m,key:y||"",dataIndex:l,index:f},leftLine:E,rightLine:h,arrowGroup:G,arrowGroupText:Y,...g,...b.event.hovered?b.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:b.event};E?p=r(k,{left:E.get("x2"),top:E.get("y2"),...L}):s&&(L.leftLine=null,p=r(k,{left:s[0],top:s[1],...L}));u.push(h),p&&(!function(e){K.hovered&&(e.on("mouseover",(()=>{re(e,"hover")})),e.on("mouseout",(()=>{C.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{ie(e),function(e){var t,o,n,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(o=e.rightLine)||o.setCoords().set({x1:e.left,y1:e.top}),null==(n=e.arrowGroup)||n.setCoords().set({left:e.left,top:e.top}),null==(i=e.arrowGroupText)||i.setCoords().set({left:e.left+O/2,top:e.top+$/2})}(e),K.hovered&&re(e)})),e.on("mouseup",(t=>{if(C.show=!1,1===t.button){const{key:t}=e.origin,o={...e.origin,data:{...e.origin.data,time:M(e.left),value:T(t,e.top)}};x.value.discardActiveObject(),j("change",o),oe(o,"change")}}))}(p),a.push(p),ee.add(p))}(le(s,e),s,d)})),Promise.all(a).then((e=>{const t=u.filter((e=>e));let o=null;e=e.filter((e=>(e&&o&&(o.nextPoint=e,e.prevPoint=o),o=e||o,e))),Promise.all(c).then((o=>{x.value.add(...t,...e,...o),e.forEach((e=>{null==e||e.bringToFront()}))}))}))}))}function oe(e,t="add"){const{dataIndex:o,data:n,index:i,key:r}=e,l=_.find((e=>e.key===r));switch(t){case"remove":l.data.splice(i,1);break;case"change":l.data[i]=n;break;default:{const e=g(n.time,l.data);l.data.splice(e,0,n);break}}ne()}function ne(){var e;ee.size&&(null==(e=x.value)||e.remove(...function(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),(null==e?void 0:e.arrowGroup)&&t.push(null==e?void 0:e.arrowGroup),(null==e?void 0:e.arrowGroupText)&&t.push(null==e?void 0:e.arrowGroupText)})),t}([...ee]))),ee.clear(),te()}function ie(e){const t=e.prevPoint?e.prevPoint.left:I,o=e.nextPoint?e.nextPoint.left:B;e.setCoords(),["cervix","fetalPresentation"].includes(e.origin.key)&&e.top<Q&&e.set("top",Q),e.top<H&&e.set("top",H),e.top>W&&e.set("top",W),e.left<t&&e.set("left",t),e.left>o&&e.set("left",o)}function re(e,t="moving"){const{title:o,key:n,data:i}=e.origin;C.point={x:e.left,y:e.top},C.list=[`${o} ${"hover"===t?i.value:T(n,e.top)}`,`时间 ${M(e.left).slice(-5)}`],C.show=!0}function le(e,t){if(v(e)&&function(e){const t=V+864e5,o=m(e);return o>=V&&o<=t}(e.time)){const o=S(e.time),n=G(t.key,t.range,e.value);return[o,n<H?H:n>W?W:n]}}function se(e,t){return e+1>t[1]?t[0]:e+1}return u(x,b),function(){const t=new e.Rect({...z,width:q-D-J-1,height:W-1,left:D,top:0,fill:"transparent"});x.value.add(t)}(),function(){function t(t,o="left"){let r="left"===o?D:B;t.forEach(((t,o)=>{const{range:l,spaceValue:u,width:c,title:h,titleStyle:g,key:v,position:m="center",spaceGridNumber:k=1,showNumber:w,showMaxMinNumber:b}=t,j=[],C=[],P=r+c/2,S=y(l,u),G=S.length;S.forEach(((e,o)=>{const{lineXMain:n,lineXSub:i,textLeft:l}=d(m,r,c),s=W-o*$*k,a=0===o?W-8:o!==S.length-1||H||Q&&"FHR"!==v?s:H+8;!w||(0===o||o===G-1)&&!b||j.push(f(String(e),t,l,a)),C.push(...p(t,o,n,i,s,$,H,G))}));const M=new e.Rect({...a,strokeWidth:.5,width:c,height:W,left:P,top:W/2}),T=n([P,H>0?H-$/2:$/2],{value:String(h),...i,...g}),Y=new e.Group([...C,...j,M,...T?[T]:[]],{objectCaching:!1,...s});x.value.add(Y),Y.sendToBack(),r+=c}))}t(N),t(R,"right")}(),function(){const{show:t,startTime:o,range:r=[0,23],position:l="top",style:a}=X.time,{show:u,range:c=[0,23],position:d,style:f}=X.processTime;if(t||u){const p=[],h=[],g=[],v=[],m=I+O/2,y=$/2;for(let e=0;e<A.mainXCell;e++){if(t){const t=0===e?+o.slice(11,13):se(p.at(-1),r);p.push(t);const s="top"===l?H-y:W+y;g.push(n([m+e*O,s],{value:String(t),...i,...a||{}}))}if(u){const t=0===e?c[0]:h.at(-1)+1;h.push(t);const o="top"===d?y:Z-y;v.push(n([m+e*O,o],{value:String(t),...i,...f||{}}))}}const k=new e.Group([...g,...v],{objectCaching:!1,...s});x.value.add(k),x.value.sendToBack(k)}}(),function(){var e;const o=Object.values(U),n=[],i={},r=_.find((e=>"cervix"===e.key&&e.show)),l=null==(e=null==r?void 0:r.data)?void 0:e.find((e=>3==+e.value));function s(e,t){const{key:o,range:n}=r||{},i=G(o,n,10),l=[0,t],s=[-t/e,0],a=[(W-i-t)/e,W-i],u=[B-I,e*(B-I)+t];let c=[],d=[];function f([o,n]){return Math.abs(n-e*o-t)<=1}function p([e,t]){const[o,n]=[...h([e,t])];return o>=I&&o<=B&&n>=i&&n<=W}function h([e,t]){return[I+e,W-t]}return f(l)&&p(l)&&(c=h(l)),f(s)&&p(s)&&(c=h(s)),f(a)&&p(a)&&(d=h(a)),f(u)&&p(u)&&(d=h(u)),[...c,...d]}o.forEach((e=>{if(!e.show)return;const{key:o}=e;switch(o){case"fetalPresentation":{const{range:i,show:r}=_.find((e=>e.key===o));if(r){const r=G(o,i,0);n.push(t([I,r,B,r],{...e}))}break}case"alert":if(l){const{key:o,range:a}=r||{},u=216e5,c={time:w(new Date(m(l.time)+u),"yyyy-MM-dd HH:mm"),value:10},[d,f]=[S(l.time)-I,W-G(o,a,l.value)],[p,h]=[S(c.time)-I,W-G(o,a,c.value)],g=(h-f)/(p-d),v=f-d*g,y=s(g,v);y.length>0&&(n.push(t(y,{...e})),Object.assign(i,{k:g,b:v}))}break;case"handling":if(l){const{k:o,b:r}=i,a=144e5,u=s(o,r-(S(w(new Date(m(l.time)+a),"yyyy-MM-dd HH:mm"))-S(l.time))*o);u.length>0&&n.push(t(u,{...e}))}}})),x.value.add(...n)}(),te(),function(){function e(e,t){const o=_.findIndex((t=>t.key===e.key));return{renderItem:()=>e.title,origin:{title:e.title,unit:e.unit,dataIndex:o,key:e.key},pointer:t}}b.event.evented&&x.value.on("mouse:up",(t=>{if(3===t.button){const{x:o=0,y:n=0}=t.pointer||{};o>=I&&o<=B&&n>=H&&n<=W&&(P.point={x:o,y:n},P.show=!0,t.target?(P.target=t.target,P.list=["删除节点"],x.value.forEachObject((e=>{e.origin&&e.left===t.target.left&&e.top===t.target.top&&P.list.push({renderItem:()=>e.origin.title,origin:{...e.origin},mode:"remove",pointer:t.pointer})}))):(P.target=null,P.list=["新增节点"],_.filter((e=>e.show)).forEach((i=>{if(!Y(o,"key",O).includes(i.key)){if(["cervix","fetalPresentation"].includes(i.key)&&n<Q)return;P.list.push(e(i,t.pointer))}})),1===P.list.length&&(P.show=!1,E("repeat"),console.log("当前时间段内无可新增节点"))))}}))}(),function(){const e=q-J/2;function t(e,t){if(!e.length)return;let n=H;const i=[];e.forEach((e=>{const o=e.title.split("").join("\n"),r=F.findIndex((t=>t.key===e.key)),{text:s,icon:a}=l(o,e,{text:{originY:"top",left:t,top:n},icon:{left:t,topY:n,originY:"top",origin:{type:e.type,dataIndex:r},...b.event}},"vertical");var u;n+=s.height+a.height+15,(u=a).on("moving",(()=>{u.set("originY","center"),L(u)?(ie(u),re(u)):C.show=!1})),u.on("mouseup:before",(e=>{if(C.show=!1,0===e.e.button&&L(u))if(Y(u.left,"key",O).includes(u.origin.key))E("repeat");else{const e={data:{time:M(u.left),value:T(u.origin.key,u.top)},...u.origin};j("add",e),oe(e)}!function(e){e.setCoords().set({originY:"top",left:e.originLeft,top:e.originTop})}(u)})),i.push(s,a)})),o(i),x.value.add(...i)}function o(e){const t=e.at(-1),o=(W-H)/2,n=(t.height+t.top-H)/2;e.forEach((e=>{const t=e.top+o-n;e.set({top:t,originTop:t})}))}t(N,D/2),t(R,e)}(),{clickMenu:function({item:e,target:t}){const o={...e.origin};"remove"===e.mode?(j("remove",o),oe(o,"remove")):(Object.assign(o,{data:{time:M(e.pointer.x),value:T(e.origin.key,e.pointer.y)}}),j("add",o),oe(o))},redrawPoints:ne}}export{x as useBirthProcess};
@@ -1 +1 @@
1
- export{defaultBorderStyle,defaultLineStyle,defaultRectStyle,defaultStyle,defaultTextStyle,drawArrow,drawLine,drawPoint,drawText,drawTextGroup}from"./useDraw.js";export{useGrid}from"./useGrid.js";export{useBirthProcessCumputedPoint,useCumputedPoint}from"./useCumputedPoint.js";export{useCanvasEvent,useEvent}from"./useEvent.js";export{drawScaleLine,drawScaleNumber,getScaleInfo}from"./useScaleColumn.js";export{useCommon}from"./useCommon.js";export{useBirthProcessChart}from"./birthProcess/useBirthProcessChart.js";export{useTemperatureChart}from"./temperature/useTemperatureChart.js";export{useSurgicalAnesthesiaChart}from"./surgicalAnesthesia/useSurgicalAnesthesiaChart.js";
1
+ export{defaultBorderStyle,defaultLineStyle,defaultRectStyle,defaultStyle,defaultTextStyle,drawArrow,drawLine,drawPoint,drawText,drawTextAndIconGroup,drawTextGroup}from"./useDraw.js";export{useGrid}from"./useGrid.js";export{useBirthProcessCumputedPoint,useCumputedPoint}from"./useCumputedPoint.js";export{useCanvasEvent,useEvent}from"./useEvent.js";export{drawScaleLine,drawScaleNumber,getScaleInfo}from"./useScaleColumn.js";export{useCommon}from"./useCommon.js";export{useBirthProcessChart}from"./birthProcess/useBirthProcessChart.js";export{useTemperatureChart}from"./temperature/useTemperatureChart.js";export{useSurgicalAnesthesiaChart}from"./surgicalAnesthesia/useSurgicalAnesthesiaChart.js";
@@ -1,2 +1,4 @@
1
1
  export * from './useTop';
2
+ export * from './useLeft';
2
3
  export * from './useCenter';
4
+ export * from './useOther';
@@ -1 +1 @@
1
- export{useTop}from"./useTop.js";export{useCenter}from"./useCenter.js";
1
+ export{useTop}from"./useTop.js";export{useLeft}from"./useLeft.js";export{useCenter}from"./useCenter.js";export{useOther}from"./useOther.js";
@@ -1 +1 @@
1
- import"../useDraw.js";import{useGrid as r}from"../useGrid.js";import"date-fns";import"lodash-es";import"@vueuse/core";import"../../../../../shared/utils/fabricjs/index.js";import"vue";import"../temperature/useShadow.js";function e(e,o){r(e,o)}export{e as useCenter};
1
+ import{drawLine as t,drawPoint as e}from"../useDraw.js";import{useGrid as o}from"../useGrid.js";import{useBirthProcessCumputedPoint as n}from"../useCumputedPoint.js";import"@vueuse/core";import"../../../../../shared/utils/fabricjs/index.js";import"vue";import{isEffectiveNode as i,getTime as s}from"../../utils/index.js";import{cloneDeep as l}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";function r(r,u){const{cumputedX:a,cumputedY:p,getXValue:f,getYValue:c}=n(u),{left:m,xCellWidth:d,yCellHeight:v,originX:h,endX:x,originY:g,endY:y,itemList:L,event:P,canvasHeight:j,scaleValues:k,xAxis:C,startTime:X}=u,Y=new Set,b=l(k);function M(t,e){if(i(t)&&function(t){const e=Date.parse(C.list.at(-1)),o=s(t);return o>=X&&o<=e}(t.time)){const o=a(t.time),n=p(e.type,e.range,t.value);return[o,n<g?g:n>y?y:n]}}o(r,u),b.forEach((o=>{o.dataList.forEach(((n,i)=>{!function(o,n,i){var s;const{type:l,dataList:a=[]}=i,p=[],f=[];function c(o,s,r,a){let c,m;const{pointAttr:d={},lineAttr:v={},title:L="",key:j,type:k="circle"}=a,C=M(a.list[r+1],i);o&&C&&!s.breakpoint&&o[0]!==C[0]&&(m=t([...o,...C],{...v}));const X=f[r-1],b={origin:{data:s,title:L,key:j||"",unit:i.unit,type:l,dataIndex:n,index:r},leftLine:X,rightLine:m,...d,...u.event.hovered?u.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:u.event};X?c=e(k,{left:X.get("x2"),top:X.get("y2"),...b}):o&&(b.leftLine=null,c=e(k,{left:o[0],top:o[1],...b})),f.push(m),c&&(function(t){P.hovered&&(t.on("mouseover",(()=>{})),t.on("mouseout",(()=>{}))),t.lockMovementX&&t.lockMovementY||(t.on("moving",(()=>{!function(t){t.setCoords();const e=t.prevPoint?t.prevPoint.left:h,o=t.nextPoint?t.nextPoint.left:x;t.top<g&&t.set("top",g),t.top>y&&t.set("top",y),t.left<e&&t.set("left",e),t.left>o&&t.set("left",o)}(t),function(t){var e,o;null==(e=t.leftLine)||e.setCoords().set({x2:t.left,y2:t.top}),null==(o=t.rightLine)||o.setCoords().set({x1:t.left,y1:t.top})}(t)})),t.on("mouseup",(t=>{})))}(c),p.push(c),Y.add(c))}null==(s=o.list)||s.forEach(((t,e)=>{c(M(t,i),t,e,o)})),Promise.all(p).then((t=>{const e=f.filter((t=>t));let o=null;t=t.map((t=>(t&&o&&(o.nextPoint=t,t.prevPoint=o),o=t||o,t))),r.value.add(...e,...t)}))}(n,i,o)}))}))}export{r as useCenter};
@@ -0,0 +1,4 @@
1
+ import { type Ref } from 'vue';
2
+ import { fabric } from '../../../../../../es/shared/utils/fabricjs';
3
+ import { AnyObject } from '../../../../../../es/shared/types';
4
+ export declare function useLeft(canvas: Ref<fabric.Canvas>, propItems: AnyObject, emits: Function): void;
@@ -0,0 +1 @@
1
+ import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawTextGroup as e,defaultRectStyle as i,drawTextAndIconGroup as o,drawText as l,defaultTextStyle as n,defaultStyle as r}from"../useDraw.js";import"date-fns";import{getScaleNumberList as a}from"../../utils/index.js";import"@vueuse/core";import{drawScaleNumber as s}from"../useScaleColumn.js";import"vue";import"lodash-es";import"../temperature/useShadow.js";function u(u,d,h){const{originY:c,endY:p,borderStyle:f,left:m,itemList:g,scaleValues:v,originX:w,endX:j,yCellHeight:y,markHeight:S,canvasWidth:W,canvasHeight:b}=d;!function(){if(!m)return;const{title:t,titleWidth:i,titleStyle:o}=m,l=e({width:i,height:p-c+S,...f},{value:t.split("").join("\n"),...o||{}},{left:0,top:c},!0);u.value.add(l)}(),v.forEach(((e,i)=>{var o,d;const h="left"===e.layout?w-5:j+5,{range:c,spaceValue:f,title:g,unit:v,titleStyle:S,spaceGridNumber:b=1,showNumber:x,showMaxMinNumber:N}=e,k=[],X=a(c,f),Y=X.length;X.forEach(((t,i)=>{const o=0===i?p-5:p-i*y*b;!x||(0===i||i===Y-1)&&!N||k.push(s(String(t),{...e,position:e.layout},h,o))}));const C=g&&l(["left"===e.layout?m.width/2:j+(W-j)/2,(null!=(d=null==(o=k.at(-1))?void 0:o.top)?d:330)-y],{value:`${g}${v?"\n"+v:""}`,...n,...S}),E=new t.Group([...k,...C?[C]:[]],{objectCaching:!1,...r});u.value.add(E),E.sendToBack()})),function(){const e=new t.Rect({width:w-m.titleWidth,height:p-c+S,left:m.titleWidth,top:c,...i,originX:"left",originY:"top",...f});u.value.add(e);const l=JSON.parse(JSON.stringify(g));let n=p;const r=m.titleWidth+15;l.reverse().forEach((t=>{n-=10;const e=t.title,{text:i,icon:l}=o(e,t,{text:{left:r,top:n},icon:{leftX:r,topY:n}});n-=i.height||30,u.value.add(i,l)}))}(),u.value.add(new t.Rect({left:0,top:0,width:W-f.strokeWidth,height:b-f.strokeWidth,fill:"transparent",...f}))}export{u as useLeft};
@@ -0,0 +1,4 @@
1
+ import { Ref } from 'vue';
2
+ import { fabric } from '../../../../../../es/shared/utils/fabricjs';
3
+ import { AnyObject } from '../../../../../../es/shared/types';
4
+ export declare function useOther(canvas: Ref<fabric.Canvas>, propItems: AnyObject, emits: Function): void;
@@ -0,0 +1 @@
1
+ import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawPoint as o,drawText as e}from"../useDraw.js";import{useBirthProcessCumputedPoint as r}from"../useCumputedPoint.js";import"@vueuse/core";import"vue";import"lodash-es";import"date-fns";import"../temperature/useShadow.js";function i(i,n,l){const{cumputedX:a}=r(n),{other:u,yCellHeight:c,endX:s,originX:f,originY:d}=n;function m(t){return t>=f&&t<=s}!function(){if(!(null==u?void 0:u.horizontal))return;const{horizontal:r}=u,n=f-5;let l=d+c/2;r.forEach((r=>{const{title:u,titleStyle:s={},type:f,pointAttr:d={},textStyle:p={},data:h}=r,v=u&&o(u,{...s,originX:"right",left:n,top:l});i.value.add(v),h.forEach((r=>{const{time:n,value:u}=r,c=a(n);if(!m(c))return;const s=o(f,{...d,left:c,top:l}),h=c+s.width/2+2,v=e([h,l],{value:u,...p,originX:"left"}),g=new t.Group([s,v],{lockMovementX:!0,lockMovementY:!0,objectCaching:!1,hasControls:!1,hasBorders:!1,hoverCursor:"pointer"});i.value.add(g)})),l+=c}))}(),function(){if(!(null==u?void 0:u.vertical))return;const{vertical:t}=u;t.forEach((t=>{const{textStyle:e={},data:r,time:n}=t,l=a(n);if(!m(l))return;let u=d+c/2;r.forEach((t=>{const r=o(String(t),{...e,lockMovementX:!0,lockMovementY:!0,left:l,originX:"left",top:u});u+=c,i.value.add(r)}))}))}()}export{i as useOther};
@@ -1 +1 @@
1
- import{ref as t,reactive as e,computed as a,unref as r,onMounted as i,nextTick as l}from"vue";import{defaultBorderStyle as o}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{format as n}from"date-fns";import{getChildrenSize as s}from"../../utils/index.js";import"@vueuse/core";import{cloneDeep as d,range as u}from"lodash-es";import"../temperature/useShadow.js";import{useTop as p}from"./useTop.js";import{useCenter as h}from"./useCenter.js";function m(m,c,v,g){const f=t(),x=t(),w=t(),y=e({show:!1,point:{x:0,y:0},list:[]}),b=e({show:!1,point:{x:0,y:0},list:[],target:null}),C=a((()=>{var t;return null!=(t=c.data.left.width)?t:0})),H=a((()=>s(c.data.top.treeData))),Y=a((()=>{const{xAxis:t}=c.data;return"top"===t.position?t.height:0})),j=function(){const t=d(c.data.top.treeData);let e=0;const{cellWidth:a,cellHeight:r}=c.data.top.tree;return function t(i,l=0){i.forEach((i=>{var o;const n={top:e*r+Y.value,left:l*a,width:a,height:r};if(e++,null==(o=i.children)?void 0:o.length){e--;const a=s(i.children);n.height=a*r,t(i.children,l+1)}else n.width=C.value-n.left;Object.assign(i,n)}))}(t),t}();const D=a((()=>{const{grid:t}=c.data;return t.mainXCell*t.subXCell})),T=a((()=>c.data.top.tree.cellHeight)),M=a((()=>Y.value+T.value*H.value)),X=a((()=>{const t=d(c.data.xAxis),{position:e,spaceValue:a,spaceTimeStamp:r}=t,i=u(D.value/a+1).map((e=>0===e?t.startTime:n(new Date(E.value+e*a*r),"yyyy-MM-dd HH:mm:ss")));return{...t,list:i,left:C.value,top:"top"===e?0:M.value}})),A=a((()=>{const{grid:t}=c.data;return t.mainYCell*t.subYCell})),S=a((()=>{var t;const{width:e,right:a}=c.data;if(!a)return e;return e-(null!=(t=a.width)?t:0)})),G=a((()=>c.data.xAxis.height+T.value*H.value)),N=a((()=>{var t;const{bottom:e=null,height:a}=c.data;if(!e)return a;return a-(null!=(t=e.height)?t:0)})),P=a((()=>(S.value-C.value)/D.value)),W=a((()=>(N.value-G.value)/A.value)),E=a((()=>{var t;return Date.parse((null==(t=c.data.xAxis)?void 0:t.startTime)||n(new Date,"yyyy-MM-dd HH:mm:ss"))})),O=a((()=>X.value.spaceTimeStamp/P.value)),k=e({canvasWidth:c.data.width,canvasHeight:c.data.height,borderStyle:{...o,...c.data.borderStyle||{}},grid:c.data.grid,top:c.data.top,other:c.data.other,topGridYNumber:r(H),topGridYCellHeight:r(T),topGridOriginY:r(Y),topGridEndY:r(M),treeData:j,xAxis:r(X),startTime:r(E),timeXCell:r(O),gridXNumber:r(D),gridYNumber:r(A),xCellWidth:r(P),yCellHeight:r(W),originX:r(C),endX:r(S),originY:r(G),endY:r(N)});return i((async()=>{await l(),p(m,k),h(m,k)})),{propItems:k,redrawPoints:x,select:f,pointTipProps:y,pointMenuProps:b,clickMenu:w}}export{m as useSurgicalAnesthesiaChart};
1
+ import{ref as e,reactive as t,computed as a,unref as r,onMounted as i,nextTick as l}from"vue";import{defaultBorderStyle as u}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{format as n}from"date-fns";import{getChildrenSize as s}from"../../utils/index.js";import"@vueuse/core";import{cloneDeep as o,range as d}from"lodash-es";import"../temperature/useShadow.js";import{useTop as p}from"./useTop.js";import{useLeft as c}from"./useLeft.js";import{useCenter as h}from"./useCenter.js";import{useOther as m}from"./useOther.js";function v(v,f,g,y){const x=e(),w=e(),b=e(),Y=t({show:!1,point:{x:0,y:0},list:[]}),j=t({show:!1,point:{x:0,y:0},list:[],target:null}),C=a((()=>f.data.layout||{top:"drug",center:"xAxis",bottom:"intraoperatively"})),H=a((()=>{var e;return null!=(e=f.data.left.width)?e:0})),T=a((()=>{const{grid:e}=f.data;return e.mainXCell*e.subXCell})),V=a((()=>{const{grid:e}=f.data;return e.mainYCell*e.subYCell})),A=a((()=>s(f.data.top.treeData))),D=a((()=>f.data.top.tree.cellHeight)),X=a((()=>D.value*A.value)),M=a((()=>Z(R("drug")||"top"))),S=a((()=>M.value+X.value)),G=a((()=>{var e;return Date.parse((null==(e=f.data.xAxis)?void 0:e.startTime)||n(new Date,"yyyy-MM-dd HH:mm:ss"))})),O=a((()=>{const e=o(f.data.xAxis),{spaceValue:t,spaceTimeStamp:a}=e,r=d(T.value/t+1).map((r=>0===r?e.startTime:n(new Date(G.value+r*t*a),"yyyy-MM-dd HH:mm:ss")));return{...e,list:r,left:H.value}})),k=function(){const e=o(f.data.top.treeData);let t=0;const{cellWidth:a,cellHeight:r}=f.data.top.tree;return function e(i,l=0){i.forEach((i=>{var u;const n={top:t*r+M.value,left:l*a,width:a,height:r};if(t++,null==(u=i.children)?void 0:u.length){t--;const a=s(i.children);n.height=a*r,e(i.children,l+1)}else n.width=H.value-n.left;Object.assign(i,n)}))}(e),e}(),L=a((()=>Z(R("xAxis")||"center"))),N=a((()=>{var e;const{width:t,right:a}=f.data;if(!a)return t;return t-(null!=(e=a.width)?e:0)})),P=a((()=>Z(R("intraoperatively")||"bottom"))),W=a((()=>{var e;const{show:t=!0,height:a}=(null==(e=f.data.other)?void 0:e.mark)||{};return t&&a?a:0})),E=a((()=>P.value+(f.data.height-X.value-O.value.height-W.value))),I=a((()=>(N.value-H.value)/T.value)),q=a((()=>(E.value-P.value)/V.value)),z=a((()=>O.value.spaceTimeStamp/I.value)),B=a((()=>{const{scaleValues:e}=f.data;return e.map((e=>e.dataList.filter((e=>e.show)).map(((t,a)=>({...t,bigType:e.type,unit:e.unit,dataIndex:a}))))).flat()})),F=a((()=>{const{scaleValues:e}=f.data,t=e.find((e=>"pulse"===e.type));return((null==t?void 0:t.spaceValue)||20)/q.value})),J=a((()=>{const{scaleValues:e}=f.data,t=e.find((e=>"temperature"===e.type));return((null==t?void 0:t.spaceValue)||2)/q.value})),K=a((()=>{var e;return(null==(e=f.data.grid)?void 0:e.event)||{selectable:!0,evented:!0,hovered:!0}})),Q=t({canvasWidth:f.data.width,canvasHeight:f.data.height,borderStyle:{...u,...f.data.borderStyle||{}},grid:f.data.grid,top:f.data.top,left:f.data.left,other:f.data.other,topGridYNumber:r(A),topGridYCellHeight:r(D),topGridOriginY:r(M),topGridEndY:r(S),treeData:k,xAxis:r(O),originYXAxis:r(L),startTime:r(G),timeXCell:r(z),gridXNumber:r(T),gridYNumber:r(V),xCellWidth:r(I),yCellHeight:r(q),originX:r(H),endX:r(N),originY:r(P),endY:r(E),markHeight:r(W),itemList:r(B),scaleValues:f.data.scaleValues,pulseYCell:r(F),temperatureYCell:r(J),event:r(K)});function R(e){let t="";return Object.entries(C.value).some((([a,r])=>{if(r===e)return t=a,!0})),t}function U(e){const t=C.value[e],a=O.value.height;switch(t){case"drug":return X.value;case"xAxis":return a;default:return f.data.height-X.value-a}}function Z(e){switch(e){case"top":return 0;case"center":return U("top");default:return U("top")+U("center")}}return i((async()=>{await l(),p(v,Q),c(v,Q),m(v,Q),h(v,Q)})),{propItems:Q,redrawPoints:w,select:x,pointTipProps:Y,pointMenuProps:j,clickMenu:b}}export{v as useSurgicalAnesthesiaChart};
@@ -1 +1 @@
1
- import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawText as e,defaultStyle as i,drawTextGroup as n,drawLine as o,drawPoint as l}from"../useDraw.js";import{useGrid as r}from"../useGrid.js";import{useBirthProcessCumputedPoint as s}from"../useCumputedPoint.js";import"@vueuse/core";import"vue";import"lodash-es";import"date-fns";import"../temperature/useShadow.js";function f(f,c,a){const{cumputedX:u}=s(c),{grid:d,originX:L,endX:p,xCellWidth:m,gridXNumber:x,top:h,topList:g,canvasWidth:X,borderStyle:v,treeData:C,xAxis:y,topGridYNumber:w,topGridOriginY:S,topGridYCellHeight:Y,topGridEndY:b}=c,j=new Set;function G(t,i,n){let o;const{content:l}=t.value||{};if(l){const{lineStyle:t,textStyle:r,totalStyle:s}=h.data||{},{startLine:f,centerLine:c,endLine:a}=i;o=e([0,0],{...r,value:l,backgroundColor:"#fff"});const u=I(o,i,n);o&&(o.set(u),f&&(f.text=o),a&&(a.text=o))}return o}function I(t,e,i){const n=t.width+1,{startLine:o,centerLine:l,endLine:r}=e,s={top:i,originX:"center",originY:"center"};return l&&n<=l.width?s.left=l.x1+l.width/2:r&&n<=r.limitX.x2-r.left?(s.originX="left",s.left=r.left+1):o&&!r&&n<=o.limitX.x2-o.left?(s.originX="left",s.left=o.left+(o.isCustomIcon?5:1)):o&&n<=o.left-o.limitX.x1?(s.originX="right",s.left=o.left-(o.isCustomIcon?5:1)):l?(s.originY="top",s.left=l.x1+l.width/2,s.top=i+1,s.fontSize=10):o&&(s.originX="left",s.originY="top",s.fontSize=10,s.left=o.left,s.top=i+1),s}function k(e,{isCustomIcon:i,isContinue:n,isLeft:r}){const{x:s,y1:f,y2:c,halfY:a}=e;if(!s||s<L||s>p)return;const{lineStyle:u}=h.data||{};let d;const x={left:s,top:a};d=i?l("circle",{fill:u.stroke,...x}):n?l(">",{fill:u.stroke,...x,fontSize:18}):o([s,f,s,a],u);const g=new t.Rect({width:m,height:Y,fill:"transparent",left:s-m/2,top:f}),X=new t.Group([d,g],{originX:"center",originY:"center",hasControls:!1,hasBorders:!1,objectCaching:!1,lockMovementY:!0});var v;return X.isLeft=r,X.isCustomIcon=i,(v=X).on("moving",(()=>{!function(t){t.setCoords(),t.left<t.limitX.x1&&t.set("left",t.limitX.x1),t.left>t.limitX.x2&&t.set("left",t.limitX.x2)}(v),function(t){if(t.centerLine){const e=t.isLeft?{x1:t.left}:{x2:t.left};t.centerLine.setCoords().set(e)}if(t.text){const e=I(t.text,{startLine:t.isLeft?t:t.nearLine,centerLine:t.centerLine,endLine:t.isLeft?t.nearLine:t},t.top);t.text.setCoords().set(e)}}(v)})),v.on("mouseup",(t=>{1===t.button&&function(t){t.isLeft?(t.preLine&&(t.preLine.limitX.x2=t.left),t.nearLine&&(t.nearLine.limitX.x1=t.left)):(t.nextLine&&(t.nextLine.limitX.x1=t.left),t.nearLine&&(t.nearLine.limitX.x2=t.left))}(v)})),X}r(f,{...c,gridYNumber:w,originY:S,yCellHeight:Y,endY:b}),function(){const{height:n,list:o,left:l,top:r,spaceValue:s}=y,c=[],a=r+n/2;o.forEach(((t,i)=>{const n=l+i*m*s;c.push(e([n,a],{value:t.slice(11,16)}))}));const u=c.length>0?new t.Group([...c],{...i,objectCaching:!1}):null;u&&f.value.add(u)}(),function(){var e;const l=(null==(e=null==h?void 0:h.tree)?void 0:e.textStyle)||{},r=[];!function t(e){e.forEach((e=>{var i;const{width:s,height:f,left:c,top:a,title:d=""}=e,m={value:d,...l};(null==(i=e.children)?void 0:i.length)?(m.value=d.split("").join("\n"),t(e.children)):(m.textAlign="left",function(t){if(!(null==t?void 0:t.data)||!Array.isArray(t.data))return;const{lineStyle:e,textStyle:i,totalStyle:n}=h.data||{},l=t.top,r=l+Y,s=r-Y/2,f={y1:l,y2:r,halfY:s},c=[];t.data.forEach(((t,i,n)=>{const{time:l,continue:r,value:a}=t,[d,m]=l,x=d&&u(d),h=m&&u(m),g=k({...f,x:x},{isCustomIcon:!h&&!r,isContinue:!1,isLeft:!0}),X=k({...f,x:h},{isCustomIcon:!1,isContinue:!!r});let v,C,y;if((g||x<L)&&(X||h>p)){v=o([g?x:L,s,X?h:p,s],e)}c.push({startLine:g,centerLine:v,endLine:X}),function(t,e){const{startLine:i,centerLine:n,endLine:o}=e[t],{startLine:l,endLine:r}=e[t-1]||{};if(i){const t={x1:L,x2:o?o.left:p};r?(t.x1=r.left,r.limitX.x2=i.left,i.preLine=r,r.nextLine=i):l&&(t.x1=l.left,l.limitX.x2=i.left,i.preLine=l,l.nextLine=i),i.limitX=t,n&&(i.centerLine=n)}if(o){const t={x1:i?i.left:L,x2:p};o.limitX=t,n&&(o.centerLine=n)}i&&o&&(i.nearLine=o,o.nearLine=i)}(i,c),n[i-1]&&(C=G(n[i-1],c[i-1],s)),i===n.length-1&&(y=G(t,c[i],s)),v&&j.add(v),g&&j.add(g),X&&j.add(X),C&&j.add(C),y&&j.add(y)}))}(e)),r.push(n({width:s,height:f,...v},m,{left:c,top:a},!0))}))}(C);const s=r.length>0?new t.Group([...r],{...i,objectCaching:!1}):null;s&&f.value.add(s),j.size&&f.value.add(...j)}()}export{f as useTop};
1
+ import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawText as e,defaultStyle as i,defaultRectStyle as n,drawTextGroup as o,drawLine as l,drawPoint as r}from"../useDraw.js";import{useGrid as s}from"../useGrid.js";import{useBirthProcessCumputedPoint as f}from"../useCumputedPoint.js";import"@vueuse/core";import"vue";import"lodash-es";import"date-fns";import"../temperature/useShadow.js";function c(c,a,u){const{cumputedX:d}=f(a),{originX:p,endX:h,xCellWidth:L,originYXAxis:x,top:m,topList:g,canvasWidth:v,borderStyle:X,treeData:C,xAxis:w,topGridYNumber:y,topGridOriginY:Y,topGridYCellHeight:S,topGridEndY:j}=a,b=new Set;function G(t,i,n){let o;const{content:l}=t.value||{};if(l){const{lineStyle:t,textStyle:r,totalStyle:s}=m.data||{},{startLine:f,centerLine:c,endLine:a}=i;o=e([0,0],{...r,value:l,backgroundColor:"#fff"});const u=I(o,i,n);o&&(o.set(u),f&&(f.text=o),a&&(a.text=o))}return o}function I(t,e,i){const n=t.width+1,{startLine:o,centerLine:l,endLine:r}=e,s={top:i,originX:"center",originY:"center"};return l&&n<=l.width?s.left=l.x1+l.width/2:r&&n<=r.limitX.x2-r.left?(s.originX="left",s.left=r.left+1):o&&!r&&n<=o.limitX.x2-o.left?(s.originX="left",s.left=o.left+(o.isCustomIcon?5:1)):o&&n<=o.left-o.limitX.x1?(s.originX="right",s.left=o.left-(o.isCustomIcon?5:1)):l?(s.originY="top",s.left=l.x1+l.width/2,s.top=i+1,s.fontSize=10):o&&(s.originX="left",s.originY="top",s.fontSize=10,s.left=o.left,s.top=i+1),s}function A(e,{isCustomIcon:i,isContinue:n,isLeft:o}){const{x:s,y1:f,y2:c,halfY:a}=e;if(!s||s<p||s>h)return;const{lineStyle:u}=m.data||{};let d;const x={left:s,top:a};d=i?r("circle",{fill:u.stroke,...x}):n?r(">",{fill:u.stroke,...x,fontSize:18}):l([s,f,s,a],u);const g=new t.Rect({width:L,height:S,fill:"transparent",left:s-L/2,top:f}),v=new t.Group([d,g],{originX:"center",originY:"center",hasControls:!1,hasBorders:!1,objectCaching:!1,hoverCursor:"pointer",lockMovementY:!0});var X;return v.isLeft=o,v.isCustomIcon=i,(X=v).on("moving",(()=>{!function(t){t.setCoords(),t.left<t.limitX.x1&&t.set("left",t.limitX.x1),t.left>t.limitX.x2&&t.set("left",t.limitX.x2)}(X),function(t){if(t.centerLine){const e=t.isLeft?{x1:t.left}:{x2:t.left};t.centerLine.setCoords().set(e)}if(t.text){const e=I(t.text,{startLine:t.isLeft?t:t.nearLine,centerLine:t.centerLine,endLine:t.isLeft?t.nearLine:t},t.top);t.text.setCoords().set(e)}}(X)})),X.on("mouseup",(t=>{1===t.button&&function(t){t.isLeft?(t.prevLine&&(t.prevLine.limitX.x2=t.left),t.nearLine&&(t.nearLine.limitX.x1=t.left)):(t.nextLine&&(t.nextLine.limitX.x1=t.left),t.nearLine&&(t.nearLine.limitX.x2=t.left))}(X)})),v}s(c,{...a,gridYNumber:y,originY:Y,yCellHeight:S,endY:j}),function(){const{height:o,list:l,left:r,spaceValue:s}=w;if(!o)return;const f=[],a=x+o/2;l.forEach(((t,i)=>{const n=r+i*L*s;f.push(e([n,a],{value:t.slice(11,16)}))}));const u=f.length>0?new t.Group([...f],{...i,objectCaching:!1}):null;u&&c.value.add(u);const d=new t.Rect({width:v,height:o,left:0,top:x,...n,originX:"left",originY:"top",...X});c.value.add(d)}(),function(){var e;const n=(null==(e=null==m?void 0:m.tree)?void 0:e.textStyle)||{},r=[];!function t(e){e.forEach((e=>{var i;const{width:s,height:f,left:c,top:a,title:u=""}=e,L={value:u,...n};(null==(i=e.children)?void 0:i.length)?(L.value=u.split("").join("\n"),t(e.children)):(L.textAlign="left",function(t){if(!(null==t?void 0:t.data)||!Array.isArray(t.data))return;const{lineStyle:e,textStyle:i,totalStyle:n}=m.data||{},o=t.top,r=o+S,s=r-S/2,f={y1:o,y2:r,halfY:s},c=[];t.data.forEach(((t,i,n)=>{const{time:o,continue:r,value:a}=t,[u,L]=o,x=u&&d(u),m=L&&d(L),g=A({...f,x:x},{isCustomIcon:!m&&!r,isContinue:!1,isLeft:!0}),v=A({...f,x:m},{isCustomIcon:!1,isContinue:!!r});let X,C,w;if((g||x<p)&&(v||m>h)){X=l([g?x:p,s,v?m:h,s],e)}c.push({startLine:g,centerLine:X,endLine:v}),function(t,e){const{startLine:i,centerLine:n,endLine:o}=e[t],{startLine:l,endLine:r}=e[t-1]||{};if(i){const t={x1:p,x2:o?o.left:h};r?(t.x1=r.left,r.limitX.x2=i.left,i.prevLine=r,r.nextLine=i):l&&(t.x1=l.left,l.limitX.x2=i.left,i.prevLine=l,l.nextLine=i),i.limitX=t,n&&(i.centerLine=n)}if(o){const t={x1:i?i.left:p,x2:h};o.limitX=t,n&&(o.centerLine=n)}i&&o&&(i.nearLine=o,o.nearLine=i)}(i,c),n[i-1]&&(C=G(n[i-1],c[i-1],s)),i===n.length-1&&(w=G(t,c[i],s)),X&&b.add(X),g&&b.add(g),v&&b.add(v),C&&b.add(C),w&&b.add(w)}))}(e)),r.push(o({width:s,height:f,...X},L,{left:c,top:a},!0))}))}(C);const s=r.length>0?new t.Group([...r],{...i,objectCaching:!1}):null;s&&c.value.add(s),b.size&&c.value.add(...b)}()}export{c as useTop};
@@ -1 +1 @@
1
- import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useShadow as t}from"./useShadow.js";import{drawLine as i,defaultStyle as n,drawPoint as o,drawText as l,drawArrow as s}from"../useDraw.js";import{useGrid as r}from"../useGrid.js";import"date-fns";import{isOneLine as a,getType as u,isOverlapPoint as p,isValidValue as d,setOtherType as c,isEffectiveNode as f,getTime as h,getIndex as v,deleteProperty as g}from"../../utils/index.js";import"@vueuse/core";import{useCommon as y}from"../useCommon.js";import"vue";import{cloneDeep as m}from"lodash-es";import{TEMPERATURE_MENU as x,PAIN_MENU as b,OVERLAP as w}from"../../constants/index.js";function j(j,k,Y,S,E,$,M,P,O,T){r(j,k);const{getEqualXTypes:A,handleAddPrevent:I}=y(j,Y),{createShadowLines:C}=t(),{left:R,xScaleList:X,xCellWidth:F,yCellHeight:z,originX:D,endX:V,originY:_,endY:G,itemList:H,event:q,vitalSignsOriginY:W,painOriginY:B,hospitalizationDate:J,config:K,canvasHeight:N}=k,Q=new Set,U=["xinmai","mai"],Z=new Map,ee=new Set,te=new Set,ie=new Set,ne=m(R.yScaleValue);function oe(t){var i;const o=ne.find((e=>"pulse"===e.type));if(o&&(null==(i=o.dataList)?void 0:i.length)&&(Q.size&&j.value.remove(...Q),Q.clear(),Z.size>1)){if(t){const{type:e,key:i}=t.origin||{};if("pulse"===e){const e=Z.get(i),n=null==e?void 0:e.findIndex((e=>e[0]===t.left));e.splice(n,1,[t.left,t.top])}}(function(){const e=[],t=[],i=[];for(const e of Z)t.push(e[1]),e[0]===U[0]&&e[1].forEach((e=>{(Z.get(U[1])||[]).findIndex((t=>t[0]===e[0]))>-1&&i.push(e[0])}));const[n,o]=t;let l=[],s=[];return i.forEach((t=>{const i=n.findIndex((e=>e[0]===t)),r=o.findIndex((e=>e[0]===t)),a=n[i],u=o[r],p=n[i-1],d=n[i+1],c=o[r-1],f=o[r+1];if(p&&c){if(p[0]!==c[0]){const e=Math.max(p[0],c[0]);l.push([p,c].find((t=>t[0]===e)))}}else p?l.push(p):c&&s.push(c);const h=Math.min(a[1],u[1]);l.push([a,u].find((e=>e[1]===h)));const v=Math.max(a[1],u[1]);s.push([a,u].find((e=>e[1]===v)));const g=()=>{const t=[...l,...s.reverse()],[i]=t,n=t.at(-1);i[0]===n[0]&&i[1]===n[1]&&t.splice(-1,1),e.push(t),l=[],s=[]};if(d&&f){if(d[0]!==f[0]){const e=Math.min(d[0],f[0]);l.push([d,f].find((t=>t[0]===e))),g()}}else d?(l.push(d),g()):f?(s.push(f),g()):g()})),e})().forEach((t=>{var i,l,s,r,a,u;const p=t.map((e=>({x:e[0],y:e[1]}))),d=new e.Polygon(p,{...n,...(null==(i=o.shadow)?void 0:i.style)||{}});if("slash"==(null==(l=o.shadow)?void 0:l.mode)){d.set({fill:"transparent",stroke:(null==(r=null==(s=o.shadow)?void 0:s.style)?void 0:r.stroke)||"#f00"});const e=C(t,null==(a=o.shadow)?void 0:a.style._angle,null==(u=o.shadow)?void 0:u.style.space);e.forEach((e=>{var t;Object.assign(e,{...n,...(null==(t=o.shadow)?void 0:t.style)||{}}),Q.add(e)})),j.value.add(...e)}Q.add(d),j.value.add(d)}))}}function le(){var e;const t=ne.find((e=>"pulse"===e.type));if(!t||!(null==(e=t.dataList)?void 0:e.length))return;if(!t.dataList.some((e=>e.title.includes("脉搏"))))return;const i=Object.assign({},w,R.overlap||{}),l=[];ee.size&&[...ee].forEach((e=>{[...te].forEach((t=>{if(t.origin&&p(e,t)){const e=t.origin.key;if(e){const s={left:t.left,top:t.top,...n,hoverCursor:"default"};let r="koumai";"yemai"===e&&(r=e),"humai"===e&&(r="circle"),l.push(o(r,{...i[e]||{},...s}))}}}))})),setTimeout((()=>{j.value.add(...l),l.forEach((e=>{null==e||e.bringToFront(),ie.add(e)}))}))}function se(e,t,r){var u;const{type:p,riseStyle:f={},noRiseStyle:h={},verifiedStyle:v={},reduceStyle:g={},pacemaker:y={},upArrowStyle:m={},limitValueStyle:x={},nonePainPointStyle:b={},dataList:w=[]}=r,S=[],$=[],P=[];null==(u=e.list)||u.forEach(((u,T)=>{const A=a(p)?w.find((e=>e.key===u.key)):e,I=ue(u,r),C={};C.value=function(e,t,i){if(!(null==e?void 0:e.length)||!K.showValue)return;const{lineAttr:n={}}=i,o=e[1]<=W.originY+z?e[1]+z:e[1]-z,s=l([e[0],o],{value:t.value,originX:"center",originY:"center",fill:n.stroke||"#000"});return P.push(s),{obj:s,top:-z}}(I,u,A),function(e,t,r,a,u){var c,y;if(!(null==e?void 0:e.length)||!["temperature","pain"].includes(p))return;const{lineAttr:m={}}=r,{value:x}=a;let b,w,j,k,Y,S;if(t.noRise&&h.show){const t=L(h)?E(u.type,u.list,35):e[1];if(h.text)j=l([e[0],L(h)?t:t+5],{value:h.text.split("").join("\n"),originY:"top",...h.style||{}}),P.push(j);else{const i=t+2*z;k=s([e[0],t,i],h.style||{}),P.push(k)}}t.rise&&f.show&&f.text&&(Y=l([e[0],e[1]-(x?z:0)-5],{value:f.text.split("").join("\n"),originY:"bottom",...f.style||{}}),P.push(Y));t.verified&&(S=l([e[0],e[1]-(x?z:0)-5],{value:"v",originX:"center",originY:"bottom",...v}),P.push(S));if(d(t.physicsReduce)||d(t.drugReduce)){const l=E(p,u.list,null!=(c=t.physicsReduce)?c:t.drugReduce);b=i([...e,e[0],l],{...m,...g.line,...n}),w=o((null==(y=null==g?void 0:g.point)?void 0:y.type)||"circle",{left:e[0],top:l,...g.point,...n,originY:l===N?"bottom":"center"}),b&&P.push(b),w&&P.push(w)}Object.assign(a,{reduceLine:{obj:b,type:"line"},noRiseText:{obj:j,top:5,isFixed:L(h)},arrowGroup:{obj:k,top:2*z,isFixed:L(h)},riseText:{obj:Y,top:(x?-z:0)-5},verifiedText:{obj:S,top:(x?-z:0)-5},reducePoint:{obj:w,type:"reduce"}})}(I,u,A,C,r),function(e,t,i,n){if(!(null==e?void 0:e.length)||!["pulse"].includes(p))return;let o,a;const{upArrowShow:u=!1,limitValueShow:d=!1}=i;if(u&&+t.value>180){let t=e[1]-2.5*z,i=[e[1]-z/2,t];t<W.originY&&(t=e[1]+2.5*z,i=[t,e[1]+z/2]),o=s([e[0],i[0],i[1]],m,"up"),P.push(o)}if(d){const i={value:t.value,originX:"center",originY:"center",...x};if(+t.value>Math.max(...r.list)){const t=o?e[1]+z/2+o.height:e[1]+z;a=l([e[0],t],i),P.push(a)}+t.value<Math.min(...r.list)&&(a=l([e[0],e[1]-z],i),P.push(a))}Object.assign(n,{upArrow:{obj:o},limitValue:{obj:a,top:-z}})}(I,u,A,C),function(n,l,s,a,u){let d,f;const{pointAttr:h={},lineAttr:v={},title:g="",key:m,type:x="circle"}=a,w=e.list[s+1],L=ue(w,r),E=re(p,e.list[s].value),P=L&&re(p,w.value);!n||!L||l.breakpoint||E||P||n[0]===L[0]||(f=i([...n,...L],{...v}));const T=l.pacemakerShow&&"pulse"==p?y.value:E?0:x,A=$[s-1],I={origin:{data:l,title:g,key:m||"",unit:r.unit,type:p,_type:c(g,p),dataIndex:t,index:s},leftLine:A,rightLine:f,otherObj:u,lockMovementX:!0,...l.pacemakerShow&&"pulse"==p?y.style:h,...k.event.hovered?k.event.evented?{selectable:!0}:{selectable:!0,lockMovementY:!0}:k.event,...E?{selectable:!1,evented:!1,...b}:{}};if(A){const e=A.get("y2");d=o(T,{left:A.get("x2"),top:E?e-5:e,...I})}else n&&(I.leftLine=null,d=o(T,{left:n[0],top:E?n[1]-5:n[1],...I}));$.push(f),d&&(g.includes("脉搏")?ee.add(d):te.add(d),function(e){q.hovered&&(e.on("mouseover",(()=>{ae(e,"hover")})),e.on("mouseout",(()=>{O.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{!function(e){e.setCoords();const t="pain"===e.origin.type?B:W;e.top<t.originY&&e.set("top",t.originY);e.top>t.endY&&e.set("top",t.endY)}(e),function(e){var t,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(i=e.rightLine)||i.setCoords().set({x1:e.left,y1:e.top}),Object.values(e.otherObj).forEach((t=>{const{obj:i,type:n="",top:o=0,isFixed:l}=t||{};"reduce"!==n&&("line"===n?null==i||i.setCoords().set({x1:e.left,y1:e.top}):!l&&(null==i||i.setCoords().set({left:e.left,top:e.top+o})))})),oe(e)}(e),q.hovered&&ae(e)})),e.on("mouseup",(t=>{if(O.show=!1,1===t.button){const{type:t}=e.origin,i=M(t,e.top),n={...e.origin,data:{...e.origin.data,value:i}};j.value.discardActiveObject(),Y("change",n),de(n,"change")}}))}(d),S.push(d),ie.add(d))}(I,u,T,A,C)})),"pulse"===p&&U.forEach((e=>{Z.set(e,S.filter((t=>{var i;return(null==(i=t.origin)?void 0:i.key)===e})).map((e=>[e.left,e.top])))})),Promise.all(S).then((e=>{const t=$.filter((e=>e));let i=null;e=e.map((e=>(e&&i&&(i.nextPoint=e,e.prevPoint=i),i=e||i,e))),Promise.all(P).then((i=>{j.value.add(...t,...e,...i),e.forEach((t=>{null==t||t.bringToFront(),function(e,t){if("pulse"===e.origin.type){t.filter((t=>t.left===e.left&&"pulse"===t.origin.type)).length>1&&(e.leftLine&&j.value.remove(e.leftLine),e.rightLine&&j.value.remove(e.rightLine))}}(t,e)}))}))}))}function re(e,t){return"pain"===e&&0==t}function ae(e,t="moving"){const{title:i,unit:n,type:o,data:l}=e.origin;O.point={x:e.left,y:e.top},O.list=[function(){const{drugReduce:s,physicsReduce:r}=l||{},a="hover"===t?l.value:M(o,e.top);if(d(s))return`药物降${"pain"==o?"痛":"温"} ${a}—>${s}${n||""}`;if(d(r))return`物理降${"pain"==o?"痛":"温"} ${a}—>${r}${n||""}`;return`${i} ${a}${n||""}`}(),`时间 ${((null==l?void 0:l.time)||$(e.left)).slice(-5)}`],O.show=!0}function ue(e,t){const i="pain"===t.type?B:W;if(f(e)&&function(e){const[t]=X,i=X.at(-1),n=t.start,o=i.end,l=h(e);return l>=n&&l<=o}(e.time)){const n=S(e.time),o=E(t.type,t.list,e.value);return[n,o<i.originY?i.originY:o>i.endY?i.endY:o]}}function pe(e){const t=new Date,i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=h(`${t.getFullYear()}-${i}-${n} 23:59:59`),l=h(`${$(e)}:00`);return J&&l<h(J)?(I("exceedMin"),!1):!(l>o)||(I("exceedMax"),!1)}function de(e,t="add"){const{type:i,dataIndex:n,index:o,data:l,key:s}=e,r=ne.find((e=>e.type===i));if("add"===t){const e=a(i)?r.dataList.find((e=>e.enable)):r.dataList[n],t=v(l.time,e.list);e.list.splice(t,0,l)}else r.dataList[n].list[o]=l;ce()}function ce(){var e;ie.size&&(null==(e=j.value)||e.remove(...function(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),Object.values((null==e?void 0:e.otherObj)||{}).forEach((e=>{(null==e?void 0:e.obj)&&t.push(null==e?void 0:e.obj)}))})),t}([...ie]))),Z.clear(),ie.clear(),ee.clear(),te.clear(),ne.forEach((e=>{e.dataList.forEach(((t,i)=>{a(e.type)&&!t.enable||se(t,i,e)}))})),oe(),le()}return Z.clear(),ee.clear(),te.clear(),ne.forEach((e=>{!function(e){if("temperature"!==e.type||!e.positionLine)return;const t=E(e.type,e.list,e.positionLine.value),n=i([D,t,V,t],e.positionLine);j.value.add(n)}(e),e.dataList.forEach(((t,i)=>{a(e.type)&&!t.enable||se(t,i,e)}))})),oe(),le(),k.event.evented&&j.value.on("mouse:up",(e=>{var t;if(3===e.button){const{x:i=0,y:n=0}=e.pointer||{};if(i>=D&&i<=V&&n>=_&&n<=G){T.point={x:i,y:n},T.show=!0;const{type:o}=(null==(t=e.target)?void 0:t.origin)||{};if(e.target&&["temperature","pain"].includes(o))"temperature"===o&&(T.list=[...x]),"pain"===o&&(T.list=[...b]),T.target=e.target;else{T.target=null,T.list=["新增节点"],H.forEach((t=>{if(!A(i,"_type",F).includes(t.bigType)){const i=["pain"].includes(t.bigType)?B:W;n>=i.originY&&n<=i.endY&&T.list.push({renderItem:P?P(t):()=>t.title,origin:{title:t.title,unit:t.unit,type:u(t.bigType),dataIndex:t.dataIndex,key:t.key},pointer:e.pointer})}}));const t=pe(i);t&&1!==T.list.length||(T.show=!1,1===T.list.length&&t&&I("repeat"))}}}})),{pointTipProps:O,pointMenuProps:T,clickMenu:function({item:e,target:t}){if(t){const{data:i,type:n,dataIndex:o,index:l}=t.origin,s=g(i,[...x,...b]);s[`${e.type}`]=e.value,a(n)&&(s.key=t.origin.key);const r={...t.origin,data:s};Y("change",r),de(r,"change")}else{const t={data:{time:$(e.pointer.x),value:M(e.origin.type,e.pointer.y),...a(e.origin.type)?{key:e.origin.key}:{}},...e.origin};Y("add",t),de(t)}},setPopup:ae,isAddPoint:pe,updateData:de,redrawPoints:ce}}function L(e){return"fixed"===e.position}export{j as useCenter};
1
+ import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useShadow as t}from"./useShadow.js";import{drawLine as i,defaultStyle as n,drawPoint as o,drawText as l,drawArrow as s}from"../useDraw.js";import{useGrid as r}from"../useGrid.js";import"date-fns";import{isOneLine as a,getType as u,isOverlapPoint as p,isValidValue as d,setOtherType as c,isEffectiveNode as f,getTime as h,getIndex as v,deleteProperty as g}from"../../utils/index.js";import"@vueuse/core";import{useCommon as y}from"../useCommon.js";import"vue";import{cloneDeep as m}from"lodash-es";import{TEMPERATURE_MENU as x,PAIN_MENU as b,OVERLAP as w}from"../../constants/index.js";function j(j,k,Y,S,E,$,M,P,O,T){r(j,k);const{getEqualXTypes:A,handleAddPrevent:I}=y(j,Y,k),{createShadowLines:C}=t(),{left:R,xScaleList:X,xCellWidth:F,yCellHeight:z,originX:D,endX:V,originY:_,endY:G,itemList:H,event:q,vitalSignsOriginY:W,painOriginY:B,hospitalizationDate:J,config:K,canvasHeight:N}=k,Q=new Set,U=["xinmai","mai"],Z=new Map,ee=new Set,te=new Set,ie=new Set,ne=m(R.yScaleValue);function oe(t){var i;const o=ne.find((e=>"pulse"===e.type));if(o&&(null==(i=o.dataList)?void 0:i.length)&&(Q.size&&j.value.remove(...Q),Q.clear(),Z.size>1)){if(t){const{type:e,key:i}=t.origin||{};if("pulse"===e){const e=Z.get(i),n=null==e?void 0:e.findIndex((e=>e[0]===t.left));e.splice(n,1,[t.left,t.top])}}(function(){const e=[],t=[],i=[];for(const e of Z)t.push(e[1]),e[0]===U[0]&&e[1].forEach((e=>{(Z.get(U[1])||[]).findIndex((t=>t[0]===e[0]))>-1&&i.push(e[0])}));const[n,o]=t;let l=[],s=[];return i.forEach((t=>{const i=n.findIndex((e=>e[0]===t)),r=o.findIndex((e=>e[0]===t)),a=n[i],u=o[r],p=n[i-1],d=n[i+1],c=o[r-1],f=o[r+1];if(p&&c){if(p[0]!==c[0]){const e=Math.max(p[0],c[0]);l.push([p,c].find((t=>t[0]===e)))}}else p?l.push(p):c&&s.push(c);const h=Math.min(a[1],u[1]);l.push([a,u].find((e=>e[1]===h)));const v=Math.max(a[1],u[1]);s.push([a,u].find((e=>e[1]===v)));const g=()=>{const t=[...l,...s.reverse()],[i]=t,n=t.at(-1);i[0]===n[0]&&i[1]===n[1]&&t.splice(-1,1),e.push(t),l=[],s=[]};if(d&&f){if(d[0]!==f[0]){const e=Math.min(d[0],f[0]);l.push([d,f].find((t=>t[0]===e))),g()}}else d?(l.push(d),g()):f?(s.push(f),g()):g()})),e})().forEach((t=>{var i,l,s,r,a,u;const p=t.map((e=>({x:e[0],y:e[1]}))),d=new e.Polygon(p,{...n,...(null==(i=o.shadow)?void 0:i.style)||{}});if("slash"==(null==(l=o.shadow)?void 0:l.mode)){d.set({fill:"transparent",stroke:(null==(r=null==(s=o.shadow)?void 0:s.style)?void 0:r.stroke)||"#f00"});const e=C(t,null==(a=o.shadow)?void 0:a.style._angle,null==(u=o.shadow)?void 0:u.style.space);e.forEach((e=>{var t;Object.assign(e,{...n,...(null==(t=o.shadow)?void 0:t.style)||{}}),Q.add(e)})),j.value.add(...e)}Q.add(d),j.value.add(d)}))}}function le(){var e;const t=ne.find((e=>"pulse"===e.type));if(!t||!(null==(e=t.dataList)?void 0:e.length))return;if(!t.dataList.some((e=>e.title.includes("脉搏"))))return;const i=Object.assign({},w,R.overlap||{}),l=[];ee.size&&[...ee].forEach((e=>{[...te].forEach((t=>{if(t.origin&&p(e,t)){const e=t.origin.key;if(e){const s={left:t.left,top:t.top,...n,hoverCursor:"default"};let r="koumai";"yemai"===e&&(r=e),"humai"===e&&(r="circle"),l.push(o(r,{...i[e]||{},...s}))}}}))})),setTimeout((()=>{j.value.add(...l),l.forEach((e=>{null==e||e.bringToFront(),ie.add(e)}))}))}function se(e,t,r){var u;const{type:p,riseStyle:f={},noRiseStyle:h={},verifiedStyle:v={},reduceStyle:g={},pacemaker:y={},upArrowStyle:m={},limitValueStyle:x={},nonePainPointStyle:b={},dataList:w=[]}=r,S=[],$=[],P=[];null==(u=e.list)||u.forEach(((u,T)=>{const A=a(p)?w.find((e=>e.key===u.key)):e,I=ue(u,r),C={};C.value=function(e,t,i){if(!(null==e?void 0:e.length)||!K.showValue)return;const{lineAttr:n={}}=i,o=e[1]<=W.originY+z?e[1]+z:e[1]-z,s=l([e[0],o],{value:t.value,originX:"center",originY:"center",fill:n.stroke||"#000"});return P.push(s),{obj:s,top:-z}}(I,u,A),function(e,t,r,a,u){var c,y;if(!(null==e?void 0:e.length)||!["temperature","pain"].includes(p))return;const{lineAttr:m={}}=r,{value:x}=a;let b,w,j,k,Y,S;if(t.noRise&&h.show){const t=L(h)?E(u.type,u.list,35):e[1];if(h.text)j=l([e[0],L(h)?t:t+5],{value:h.text.split("").join("\n"),originY:"top",...h.style||{}}),P.push(j);else{const i=t+2*z;k=s([e[0],t,i],h.style||{}),P.push(k)}}t.rise&&f.show&&f.text&&(Y=l([e[0],e[1]-(x?z:0)-5],{value:f.text.split("").join("\n"),originY:"bottom",...f.style||{}}),P.push(Y));t.verified&&(S=l([e[0],e[1]-(x?z:0)-5],{value:"v",originX:"center",originY:"bottom",...v}),P.push(S));if(d(t.physicsReduce)||d(t.drugReduce)){const l=E(p,u.list,null!=(c=t.physicsReduce)?c:t.drugReduce);b=i([...e,e[0],l],{...m,...g.line,...n}),w=o((null==(y=null==g?void 0:g.point)?void 0:y.type)||"circle",{left:e[0],top:l,...g.point,...n,originY:l===N?"bottom":"center"}),b&&P.push(b),w&&P.push(w)}Object.assign(a,{reduceLine:{obj:b,type:"line"},noRiseText:{obj:j,top:5,isFixed:L(h)},arrowGroup:{obj:k,top:2*z,isFixed:L(h)},riseText:{obj:Y,top:(x?-z:0)-5},verifiedText:{obj:S,top:(x?-z:0)-5},reducePoint:{obj:w,type:"reduce"}})}(I,u,A,C,r),function(e,t,i,n){if(!(null==e?void 0:e.length)||!["pulse"].includes(p))return;let o,a;const{upArrowShow:u=!1,limitValueShow:d=!1}=i;if(u&&+t.value>180){let t=e[1]-2.5*z,i=[e[1]-z/2,t];t<W.originY&&(t=e[1]+2.5*z,i=[t,e[1]+z/2]),o=s([e[0],i[0],i[1]],m,"up"),P.push(o)}if(d){const i={value:t.value,originX:"center",originY:"center",...x};if(+t.value>Math.max(...r.list)){const t=o?e[1]+z/2+o.height:e[1]+z;a=l([e[0],t],i),P.push(a)}+t.value<Math.min(...r.list)&&(a=l([e[0],e[1]-z],i),P.push(a))}Object.assign(n,{upArrow:{obj:o},limitValue:{obj:a,top:-z}})}(I,u,A,C),function(n,l,s,a,u){let d,f;const{pointAttr:h={},lineAttr:v={},title:g="",key:m,type:x="circle"}=a,w=e.list[s+1],L=ue(w,r),E=re(p,e.list[s].value),P=L&&re(p,w.value);!n||!L||l.breakpoint||E||P||n[0]===L[0]||(f=i([...n,...L],{...v}));const T=l.pacemakerShow&&"pulse"==p?y.value:E?0:x,A=$[s-1],I={origin:{data:l,title:g,key:m||"",unit:r.unit,type:p,_type:c(g,p),dataIndex:t,index:s},leftLine:A,rightLine:f,otherObj:u,lockMovementX:!0,...l.pacemakerShow&&"pulse"==p?y.style:h,...k.event.hovered?k.event.evented?{selectable:!0}:{selectable:!0,lockMovementY:!0}:k.event,...E?{selectable:!1,evented:!1,...b}:{}};if(A){const e=A.get("y2");d=o(T,{left:A.get("x2"),top:E?e-5:e,...I})}else n&&(I.leftLine=null,d=o(T,{left:n[0],top:E?n[1]-5:n[1],...I}));$.push(f),d&&(g.includes("脉搏")?ee.add(d):te.add(d),function(e){q.hovered&&(e.on("mouseover",(()=>{ae(e,"hover")})),e.on("mouseout",(()=>{O.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{!function(e){e.setCoords();const t="pain"===e.origin.type?B:W;e.top<t.originY&&e.set("top",t.originY);e.top>t.endY&&e.set("top",t.endY)}(e),function(e){var t,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(i=e.rightLine)||i.setCoords().set({x1:e.left,y1:e.top}),Object.values(e.otherObj).forEach((t=>{const{obj:i,type:n="",top:o=0,isFixed:l}=t||{};"reduce"!==n&&("line"===n?null==i||i.setCoords().set({x1:e.left,y1:e.top}):!l&&(null==i||i.setCoords().set({left:e.left,top:e.top+o})))})),oe(e)}(e),q.hovered&&ae(e)})),e.on("mouseup",(t=>{if(O.show=!1,1===t.button){const{type:t}=e.origin,i=M(t,e.top),n={...e.origin,data:{...e.origin.data,value:i}};j.value.discardActiveObject(),Y("change",n),de(n,"change")}}))}(d),S.push(d),ie.add(d))}(I,u,T,A,C)})),"pulse"===p&&U.forEach((e=>{Z.set(e,S.filter((t=>{var i;return(null==(i=t.origin)?void 0:i.key)===e})).map((e=>[e.left,e.top])))})),Promise.all(S).then((e=>{const t=$.filter((e=>e));let i=null;e=e.map((e=>(e&&i&&(i.nextPoint=e,e.prevPoint=i),i=e||i,e))),Promise.all(P).then((i=>{j.value.add(...t,...e,...i),e.forEach((t=>{null==t||t.bringToFront(),function(e,t){if("pulse"===e.origin.type){t.filter((t=>t.left===e.left&&"pulse"===t.origin.type)).length>1&&(e.leftLine&&j.value.remove(e.leftLine),e.rightLine&&j.value.remove(e.rightLine))}}(t,e)}))}))}))}function re(e,t){return"pain"===e&&0==t}function ae(e,t="moving"){const{title:i,unit:n,type:o,data:l}=e.origin;O.point={x:e.left,y:e.top},O.list=[function(){const{drugReduce:s,physicsReduce:r}=l||{},a="hover"===t?l.value:M(o,e.top);if(d(s))return`药物降${"pain"==o?"痛":"温"} ${a}—>${s}${n||""}`;if(d(r))return`物理降${"pain"==o?"痛":"温"} ${a}—>${r}${n||""}`;return`${i} ${a}${n||""}`}(),`时间 ${((null==l?void 0:l.time)||$(e.left)).slice(-5)}`],O.show=!0}function ue(e,t){const i="pain"===t.type?B:W;if(f(e)&&function(e){const[t]=X,i=X.at(-1),n=t.start,o=i.end,l=h(e);return l>=n&&l<=o}(e.time)){const n=S(e.time),o=E(t.type,t.list,e.value);return[n,o<i.originY?i.originY:o>i.endY?i.endY:o]}}function pe(e){const t=new Date,i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=h(`${t.getFullYear()}-${i}-${n} 23:59:59`),l=h(`${$(e)}:00`);return J&&l<h(J)?(I("exceedMin"),!1):!(l>o)||(I("exceedMax"),!1)}function de(e,t="add"){const{type:i,dataIndex:n,index:o,data:l,key:s}=e,r=ne.find((e=>e.type===i));if("add"===t){const e=a(i)?r.dataList.find((e=>e.enable)):r.dataList[n],t=v(l.time,e.list);e.list.splice(t,0,l)}else r.dataList[n].list[o]=l;ce()}function ce(){var e;ie.size&&(null==(e=j.value)||e.remove(...function(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),Object.values((null==e?void 0:e.otherObj)||{}).forEach((e=>{(null==e?void 0:e.obj)&&t.push(null==e?void 0:e.obj)}))})),t}([...ie]))),Z.clear(),ie.clear(),ee.clear(),te.clear(),ne.forEach((e=>{e.dataList.forEach(((t,i)=>{a(e.type)&&!t.enable||se(t,i,e)}))})),oe(),le()}return Z.clear(),ee.clear(),te.clear(),ne.forEach((e=>{!function(e){if("temperature"!==e.type||!e.positionLine)return;const t=E(e.type,e.list,e.positionLine.value),n=i([D,t,V,t],e.positionLine);j.value.add(n)}(e),e.dataList.forEach(((t,i)=>{a(e.type)&&!t.enable||se(t,i,e)}))})),oe(),le(),k.event.evented&&j.value.on("mouse:up",(e=>{var t;if(3===e.button){const{x:i=0,y:n=0}=e.pointer||{};if(i>=D&&i<=V&&n>=_&&n<=G){T.point={x:i,y:n},T.show=!0;const{type:o}=(null==(t=e.target)?void 0:t.origin)||{};if(e.target&&["temperature","pain"].includes(o))"temperature"===o&&(T.list=[...x]),"pain"===o&&(T.list=[...b]),T.target=e.target;else{T.target=null,T.list=["新增节点"],H.forEach((t=>{if(!A(i,"_type",F).includes(t.bigType)){const i=["pain"].includes(t.bigType)?B:W;n>=i.originY&&n<=i.endY&&T.list.push({renderItem:P?P(t):()=>t.title,origin:{title:t.title,unit:t.unit,type:u(t.bigType),dataIndex:t.dataIndex,key:t.key},pointer:e.pointer})}}));const t=pe(i);t&&1!==T.list.length||(T.show=!1,1===T.list.length&&t&&I("repeat"))}}}})),{pointTipProps:O,pointMenuProps:T,clickMenu:function({item:e,target:t}){if(t){const{data:i,type:n,dataIndex:o,index:l}=t.origin,s=g(i,[...x,...b]);s[`${e.type}`]=e.value,a(n)&&(s.key=t.origin.key);const r={...t.origin,data:s};Y("change",r),de(r,"change")}else{const t={data:{time:$(e.pointer.x),value:M(e.origin.type,e.pointer.y),...a(e.origin.type)?{key:e.origin.key}:{}},...e.origin};Y("add",t),de(t)}},setPopup:ae,isAddPoint:pe,updateData:de,redrawPoints:ce}}function L(e){return"fixed"===e.position}export{j as useCenter};