cnhis-design-vue 3.1.54-beta.15 → 3.1.54-beta.17

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 (39) hide show
  1. package/README.md +87 -87
  2. package/es/components/button-print/index.d.ts +13 -0
  3. package/es/components/button-print/src/ButtonPrint.vue.d.ts +16 -1
  4. package/es/components/button-print/src/ButtonPrint.vue2.js +1 -1
  5. package/es/components/expand-field/src/components/form.vue2.js +1 -1
  6. package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcess.js +1 -1
  7. package/es/components/fabric-chart/src/hooks/electrocardiogram/hooks/useDetailEvent.js +1 -1
  8. package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogram.js +1 -1
  9. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useCenter.js +1 -1
  10. package/es/components/fabric-chart/src/hooks/temperature/useCenter.d.ts +1 -1
  11. package/es/components/fabric-chart/src/hooks/temperature/useLeft.d.ts +1 -1
  12. package/es/components/fabric-chart/src/hooks/temperature/useTemperatureChart.js +1 -1
  13. package/es/components/fabric-chart/src/hooks/useCumputedPoint.d.ts +3 -3
  14. package/es/components/fabric-chart/src/hooks/useCumputedPoint.js +1 -1
  15. package/es/components/form-render/src/hooks/useFieldVisitor.js +1 -1
  16. package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
  17. package/es/components/select-label/src/LabelFormContent.vue2.js +1 -1
  18. package/es/components/select-person/src/SearchMultiple.vue.d.ts +6 -0
  19. package/es/components/table-export-field/src/components/ExportModal.vue.d.ts +0 -3
  20. package/es/env.d.ts +25 -25
  21. package/es/shared/assets/img/failure.png.js +1 -1
  22. package/es/shared/assets/img/no-permission.png.js +1 -1
  23. package/es/shared/assets/img/nodata.png.js +1 -1
  24. package/es/shared/assets/img/notfound.png.js +1 -1
  25. package/es/shared/assets/img/qr.png.js +1 -1
  26. package/es/shared/assets/img/success.png.js +1 -1
  27. package/es/shared/assets/img/video.png.js +1 -1
  28. package/es/shared/assets/img/video_default_cover.png.js +1 -1
  29. package/es/shared/assets/img/xb_big.png.js +1 -1
  30. package/es/shared/assets/img/xb_small.png.js +1 -1
  31. package/es/shared/package.json.js +1 -1
  32. package/package.json +2 -2
  33. package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
  34. package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +0 -1
  35. package/es/components/bpmn-workflow/types/ModelingModule.d.ts +0 -1
  36. package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +0 -1
  37. package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +0 -86
  38. package/es/shared/utils/fabricjs/index.d.ts +0 -6823
  39. package/es/shared/utils/tapable/index.d.ts +0 -139
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
+ ```
@@ -78,6 +78,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
78
78
  signature: {
79
79
  type: StringConstructor;
80
80
  };
81
+ showLoading: {
82
+ type: BooleanConstructor;
83
+ default: boolean;
84
+ };
81
85
  }, {
82
86
  $message: import("naive-ui").MessageApi;
83
87
  printInstance: import("./src/utils").Print | null;
@@ -158,6 +162,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
158
162
  signature: {
159
163
  type: StringConstructor;
160
164
  };
165
+ showLoading: {
166
+ type: BooleanConstructor;
167
+ default: boolean;
168
+ };
161
169
  }>> & {
162
170
  onError?: ((...args: any[]) => any) | undefined;
163
171
  onSuccess?: ((...args: any[]) => any) | undefined;
@@ -1923,6 +1931,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
1923
1931
  signature: {
1924
1932
  type: StringConstructor;
1925
1933
  };
1934
+ showLoading: {
1935
+ type: BooleanConstructor;
1936
+ default: boolean;
1937
+ };
1926
1938
  }>> & {
1927
1939
  onError?: ((...args: any[]) => any) | undefined;
1928
1940
  onSuccess?: ((...args: any[]) => any) | undefined;
@@ -1947,5 +1959,6 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
1947
1959
  options: import("../../../es/shared/types").AnyObject[];
1948
1960
  onSelect: (key: string | number, option: import("../../../es/shared/types").AnyObject) => void;
1949
1961
  }>;
1962
+ showLoading: boolean;
1950
1963
  }>>;
1951
1964
  export default ButtonPrint;
@@ -82,6 +82,10 @@ declare const _default: import("vue").DefineComponent<{
82
82
  signature: {
83
83
  type: StringConstructor;
84
84
  };
85
+ showLoading: {
86
+ type: BooleanConstructor;
87
+ default: boolean;
88
+ };
85
89
  }, {
86
90
  $message: import("naive-ui").MessageApi;
87
91
  printInstance: Print | null;
@@ -165,6 +169,10 @@ declare const _default: import("vue").DefineComponent<{
165
169
  signature: {
166
170
  type: StringConstructor;
167
171
  };
172
+ showLoading: {
173
+ type: BooleanConstructor;
174
+ default: boolean;
175
+ };
168
176
  }>> & {
169
177
  onError?: ((...args: any[]) => any) | undefined;
170
178
  onSuccess?: ((...args: any[]) => any) | undefined;
@@ -250,7 +258,9 @@ declare const _default: import("vue").DefineComponent<{
250
258
  }, {
251
259
  $message: import("naive-ui").MessageApi;
252
260
  DEFAULT_FORM: {
253
- account: string;
261
+ account: string; /**
262
+ * 打印预览按钮文本
263
+ */
254
264
  password: string;
255
265
  };
256
266
  props: {
@@ -1933,6 +1943,10 @@ declare const _default: import("vue").DefineComponent<{
1933
1943
  signature: {
1934
1944
  type: StringConstructor;
1935
1945
  };
1946
+ showLoading: {
1947
+ type: BooleanConstructor;
1948
+ default: boolean;
1949
+ };
1936
1950
  }>> & {
1937
1951
  onError?: ((...args: any[]) => any) | undefined;
1938
1952
  onSuccess?: ((...args: any[]) => any) | undefined;
@@ -1957,5 +1971,6 @@ declare const _default: import("vue").DefineComponent<{
1957
1971
  options: AnyObject[];
1958
1972
  onSelect: (key: string | number, option: AnyObject) => void;
1959
1973
  }>;
1974
+ showLoading: boolean;
1960
1975
  }>;
1961
1976
  export default _default;
@@ -1 +1 @@
1
- import{defineComponent as t,reactive as e,computed as r,onMounted as a,watch as n,openBlock as i,createElementBlock as s,Fragment as o,createVNode as l,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:()=>({})},signature:{type:String}},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=>l("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,signature:E.signature};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,signature:E.signature};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,signature:E.signature};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(),s(o,null,[l(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},(()=>[l(m(I),{class:"dropdown-button",onClick:r[1]||(r[1]=u((()=>A("button")),["stop"]))},{default:p((()=>[c(f(t.btnText)+" ",1),l(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"]),l(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 n,onMounted as i,watch as r,openBlock as a,createElementBlock as s,Fragment as o,createVNode as l,unref as p,withCtx as d,renderSlot as m,withModifiers as u,createTextVNode as c,toDisplayString as f,mergeProps as g}from"vue";import{isObject as v}from"@vue/shared";import{useMessage as y,NDropdown as b,NButton as I,NIcon as w}from"naive-ui";import{ChevronDown as P}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 L=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:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!1}},emits:["success","error","clickoutside"],setup(t,{expose:L,emit:D}){var O;const j=t,E=y();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:j.printText,key:"printText"},{label:j.previewText,key:"previewText"},{label:j.pdfLoadText,key:"downloadPdf"},{label:j.formatEditText,key:"formatEditText"},...(null==(O=j.externalOptionConfig)?void 0:O.options)||[]]),Y=n((()=>{if(!V.currentFormatId)return{};let t=V.currentFormatId;return V.formatList.find((e=>e.id===t))})),B=n((()=>{var t;return(null==(t=Y.value)?void 0:t.name)||"格式选择"})),J=n((()=>{let t=V.formatList.find((t=>t.id===V.currentFormatId));return null==t?void 0:t.templateId})),U=async t=>{if(j.directPrint){if(V.spinning)return;return"button"===t?void await rt():et()}return et()},A=t=>l("span",{class:{active:t.key===V.currentFormatId}},[t.label]),q=(t,e)=>{V.spinning=!1;let n={type:e,formatId:V.currentFormatId,templateId:J.value};D("success",t,n)},R=t=>{V.spinning=!1,D("error",t),v(t)&&"notInstalledApp"===t.type&&E.error(t.message)},_=t=>{D("error",{message:"前置条件执行错误",type:t,preExecution:!0})},z=(t=0)=>{var e;const n=(null==(e=j.printParams)?void 0:e.length)?j.printParams[t]:V.printParams[t];return JSON.stringify({...n||{},...j.token?{token:j.token}:{}})},H=()=>{var t,e;let n={},i={};if(null==(t=V.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(V.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(V.printParams.map((e=>JSON.parse(e.datasetData[t]))));i={datasetData:{}},i.datasetData[t]=n}else Object.keys(V.printParams[0]).forEach((t=>{i[t]=[],V.printParams.forEach((e=>{i[t].push(e[t])})),i[t]=i[t].join(",")}));return n=Object.assign({},JSON.parse(z(0)),i),JSON.stringify(n)},$=()=>{let t=V.printParams.length;const e=async e=>{try{--t<=0&&q(e,"print")}catch(t){console.log("error",t)}};j.showLoading&&V.spinning||(V.spinning=!0,j.prevFn("print").then((()=>{const t={formatId:V.currentFormatId,templateId:J.value,printdlgshow:j.printdlgshow,signature:j.signature};if("MULTI"===j.strategy)for(let n=0;n<V.printParams.length;n++)n>0&&(t.printdlgshow="0"),M.printDirect({...t,params:z(n)},e,R);else M.printDirect({...t,params:H()},(t=>{q(t,"print")}),R)})).catch((()=>{_("print"),V.spinning=!1})).finally((()=>{V.visible=!1})))},G=async(t,e)=>{var n,i;switch(t){case"printText":$();break;case"previewText":(async()=>{j.showLoading&&V.spinning||(V.spinning=!0,j.prevFn("preview").then((()=>{const t="MULTI"===j.strategy?z():H(),e={formatId:V.currentFormatId,templateId:J.value,params:t,btnprint:j.btnprint,signature:j.signature};M.preview(e,(t=>{q(t,"preview")}),R)})).catch((()=>{_("preview"),V.spinning=!1})).finally((()=>{V.visible=!1})))})();break;case"formatEditText":j.showLoading&&V.spinning||(V.spinning=!0,j.prevFn("edit").then((()=>{V.identityVerification.visible=!0})).catch((()=>{_("edit")})).finally((()=>{V.visible=!1,V.spinning=!1})));break;case"downloadPdf":(async()=>{j.showLoading&&V.spinning||(V.spinning=!0,j.prevFn("download").then((()=>{const t="MULTI"===j.strategy?z():H(),e={formatId:V.currentFormatId,templateId:J.value,print:{print:"1",type:"1"},params:t,signature:j.signature};M.downloadPDF(e,(t=>q(t,"preview")),R)})).catch((()=>{_("download"),V.spinning=!1})).finally((()=>{V.visible=!1})))})();break;default:{V.visible=!1;const r=V.formatList.find((e=>e.id===t))||{};if(Object.keys(r).length>0){V.currentFormatId=t;const[e]=C;e.label=(null==r?void 0:r.name)||e.label,await x({formatForms:[{...r}],name:N.name||r.templateName,number:N.number||r.number,templateId:N.templateId||r.templateId,...N.id?{id:N.id}:{}},{token:j.token})}else null==(i=null==(n=j.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},K=()=>{V.visible=!1,D("clickoutside")},Q=()=>(V.isInited=!1,V.spinning=!1,setTimeout((()=>{V.visible=!1}),0),!1),W=(t,e,n)=>{const i={};return e.forEach((e=>{let r=((t,e)=>{const n={DATE:"YYYY-MM-DD",DATETIME:"YYYY-MM-DD HH:mm:ss"};let i=e;return Object.keys(n).includes(t.type)&&e&&(i=T(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},X=({customizeDataset:t=[],param:e=[]},n=[])=>n.map((n=>{let i={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;i.datasetData={[t.name]:JSON.stringify(W(n,e,"fieldName"))}})),i=Object.assign({},i,W(n,e,"key")),i})),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 n;if(!(null==t?void 0:t.length))return"";const{data:i}=await S({templateId:t[0].templateId},{token:j.token});if("SUCCESS"===i.result){const{formatForms:e=[]}=i.map||{};Object.assign(N,i.map||{});const r=null==(n=null==e?void 0:e[0])?void 0:n.id;if(r&&t.map((t=>t.id)).includes(r))return r}const r=t.find((t=>1==t[e]));return(null==r?void 0:r.id)||t[0].id})(V.formatList,"defaultFlag"),!V.currentFormatId)return E.error("获取打印格式失败,请联系管理员!"),Q();(()=>{const t=V.formatList.map((t=>({label:t.name,key:t.id})));C.unshift({label:B.value,key:"format",children:t})})();let n=null==(e=await j.queryTemplateParams())?void 0:e.obj;if(!n||!J.value)return E.error("获取打印模板失败,请联系管理员!"),Q();V.templateParams=n,V.printParams=X(V.templateParams,j.params)},tt=async()=>{if(V.isInited)return!0;V.isInited=!0,V.spinning=!0,(()=>{if(M)return!1;M=new h})();const t=await j.queryPrintFormatByNumber();return await Z(t),V.spinning=!1,!0},et=async(t=!0)=>{var e;if(await j.clickPrevFn())if(null==(e=j.params)?void 0:e.length){if(!V.visible){if(!await tt())return!1}t&&(V.visible=!V.visible)}else E.warning(j.noDataMsg)},nt=()=>{V.watchPrintParamsReformatFn&&V.watchPrintParamsReformatFn(),V.isInited?V.printParams=X(V.templateParams,j.params):V.watchPrintParamsReformatFn=()=>r((()=>V.isInited),(t=>{if(!t)return!1;nt()}))},it=t=>{if(V.identityVerification.visible=!1,F(V.currentFormatId))return q(null,"edit");const e={formatId:V.currentFormatId,templateId:J.value,params:z(),token:t};M.editPrintFormat(e,(t=>{q(t,"edit")}),R)};async function rt(){await et(!1),$()}return i((()=>{V.isInited=!1})),r((()=>j.params),(t=>{if(!(null==t?void 0:t.length))return!1;nt()}),{deep:!0}),L({directPrint:rt}),(e,n)=>(a(),s(o,null,[l(p(b),{class:"c-dropdown",placement:"bottom-start",trigger:"click",show:V.visible,onClickoutside:K,options:C,onSelect:G,"render-label":A},{default:d((()=>[m(e.$slots,"button",{handleClickPrintBtn:et,printSpinning:V.spinning,printbtnText:t.btnText,printVisible:V.visible},(()=>[l(p(I),{class:"dropdown-button",loading:t.showLoading&&V.spinning,onClick:n[1]||(n[1]=u((()=>U("button")),["stop"]))},{default:d((()=>[c(f(t.btnText)+" ",1),l(p(w),{component:p(P),style:{"margin-left":"5px"},onClick:n[0]||(n[0]=u((()=>U("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["show","options"]),l(k,g(e.$attrs,{modelValue:V.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>V.identityVerification.visible=t),formatId:V.currentFormatId,templateId:p(J),onSuccess:it}),null,16,["modelValue","formatId","templateId"])],64))}});export{L as default};
@@ -1 +1 @@
1
- import{defineComponent as e,ref as l,inject as a,computed as t,watch as u,openBlock as n,createBlock as i,unref as o,normalizeClass as v,isRef as d,withCtx as r,createVNode as s,normalizeStyle as p,createElementVNode as f,createTextVNode as m,createCommentVNode as c,createElementBlock as y,Fragment as h,renderList as _,withDirectives as g,withKeys as b,withModifiers as x,vShow as k,toDisplayString as M}from"vue";import{useMessage as w,NModal as H,NCard as C,NButton as U,NForm as S,NFormItem as j,NInput as O,NTooltip as I,NSelect as z,NGrid as T,NGridItem as N,NIcon as Y,NInputNumber as $,NPopover as L,NDatePicker as V,NTimePicker as B,NSwitch as D}from"naive-ui";import{isMulti as F,isShowOptions as P,isNumber as q,isDate as A,isCandidate as E,isTextarea as J}from"../utils/index.js";import K from"moment";import{InjectionExpandFieldApiConfig as R}from"../constants/index.js";import W from"../hooks/useAsyncData.js";import{HtmlTypeList as X}from"../utils/constant.js";import{isJSON as G,isValidDate as Q}from"../utils/tool.js";import Z from"./FormBatchOptionsModal.vue.js";import ee from"./FormItemPerson.vue.js";const le={class:"svg-wrap"},ae={class:"flex_right"},te={class:"options-title"},ue=f("span",null,"字段键名",-1),ne=f("i",{class:"iconfont-expand-field icon-expand-field-help"},null,-1),ie={class:"options-title"},oe=f("span",null,"字段问号提示",-1),ve=f("i",{class:"iconfont-expand-field icon-expand-field-help"},null,-1),de={class:"options-title"},re=f("span",null,"选项值",-1),se=f("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 32 32"},[f("path",{d:"M12 12h2v12h-2z",fill:"currentColor"}),f("path",{d:"M18 12h2v12h-2z",fill:"currentColor"}),f("path",{d:"M4 6v2h2v20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8h2V6zm4 22V8h16v20z",fill:"currentColor"}),f("path",{d:"M12 2h8v2h-8z",fill:"currentColor"})],-1),pe={class:"options-title"},fe=f("span",null,"默认值",-1),me=f("i",{class:"iconfont-expand-field icon-expand-field-help"},null,-1),ce={style:{display:"flex","align-items":"center"}},ye=f("span",null,"选择",-1),he={style:{width:"100%"}},_e={key:0,class:"validate_tip"};var ge=e({__name:"form",props:{visible:{type:Boolean,default:!1},formOntype:{type:String,default:"add"},formItemData:{type:Object,default:()=>({})},id:{type:String,default:""},orgId:{type:String,default:""},conditionList:{type:Array,default:()=>[]},searchFieldList:{type:Array,default:()=>[]}},emits:["cancelModal"],setup(e,{emit:ge}){const be=e,xe=w(),ke="请输入默认值",Me={name:[{required:!0,message:"请输入字段标题",trigger:["input","blur"]}],html_type:[{required:!0,message:"请选择字段类型",trigger:["input","blur"]}]},we=[{value:"yyyy-MM-dd HH:mm:ss",label:"年-月-日 时:分:秒"},{value:"yyyy-MM-dd HH:mm",label:"年-月-日 时:分"},{value:"yyyy-MM-dd",label:"年-月-日"},{value:"yyyy-MM",label:"年-月"},{value:"MM-dd HH:mm",label:"月-日 时:分"},{value:"MM-dd",label:"月-日"},{value:"HH:mm:ss",label:"时:分:秒"},{value:"HH:mm",label:"时:分"}],He=[{value:"12",label:"整行"},{value:"6",label:"半行"},{value:"4",label:"1/3行"},{value:"8",label:"2/3行"},{value:"3",label:"1/4行"},{value:"9",label:"3/4行"},{value:"2",label:"1/6行"},{value:"10",label:"5/6行"},{value:"1.5",label:"1/8行"},{value:"10.5",label:"7/8行"}],Ce=l(!1),Ue=l("860px");let Se=l({maxHeight:"496px",height:"496px"});const{saveOrUpdateExtendField:je}=W(),Oe=a(R),Ie=l(null),ze=l({name:void 0,remark:void 0,is_edit:"1",is_null:"1",is_show:"1",key:"",val_key:void 0,validate:{},html_type:"INPUT",name_i18n:void 0,elem_width:"12",default_val:void 0,label_type:void 0,isMultiSelect:"0",decimal_length:void 0,date_format:""}),Te=l([{text:void 0,value:void 0}]),Ne=l({format:"yyyy-MM-dd HH:mm:ss",dateType:"date",mode:"date",value:null,showTime:!0,open:!1,componentType:"datetime"}),Ye=l({obj_type:"",vali_obj:"",event_obj:"",max_length:"",min_length:"",min_value:"",max_value:""}),$e=l({value_key:"",levelSetting:[],search_key:[],level_num:void 0,render_key:[],name:"",level_key:"",id:"",type:"",primary_key:"",sqlExpression:"",conObj:"",add_btn:"",setting:{cascading:[]}}),Le=l(!1),Ve=l(!1),Be=l(void 0),De=l(!1),Fe=l(!1);l(!1);const Pe=l(!1),qe=l(""),Ae=t((()=>"edit"===be.formOntype)),Ee=t((()=>ze.value.html_type||""));t((()=>"TEXTAREA"===Ee.value?1e3:255));const Je=t((()=>Te.value.filter((e=>e.value&&e.text)))),Ke=t((()=>F(Ee.value))),Re=t((()=>"date"===Ne.value.dateType));function We(e){Pe.value=e}function Xe(e){let l=e;"string"!=typeof e&&(l=JSON.stringify(e)),ze.value.default_val=l}function Ge(e){Ne.value.value=null,ze.value.default_val=void 0,il(e)}function Qe(){Ce.value=!Ce.value;let e=document.body.clientHeight;"860px"===Ue.value?(Ue.value="100%",Se.value.maxHeight=`${e}px`,Se.value.height=`${e}px`):(Ue.value="860px",Se.value.maxHeight="496px",Se.value.height="")}function Ze(e){return["HH:mm:ss","HH:mm"].includes(e)}function el(e,l){switch(e){case"isNull":Le.value=l,ze.value.is_null=l?"0":"1";break;case"isMultiSelect":Ve.value=l,ze.value.isMultiSelect=l?"1":"0"}}function ll(){if("add"===be.formOntype)return;let e=Object.assign({},be.formItemData),l=e.setting;l&&G(l)&&(l=JSON.parse(l),delete e.setting,Object.assign(e,{...l})),e.key=e.code,delete e.code,A(e.html_type)&&function(e){il(e.date_format);let l=e.default_val;l&&!l.startsWith("${")&&(Ze(e.date_format)&&(l=`${K().format("YYYY-MM-dd")} ${l}`),Q(new Date(l))&&(Ne.value.value=K(l)))}(e),F(e.html_type)&&(e.default_val=function(e){let l=e.default_val;return l?l.split(",").filter(Boolean):[]}(e)),Le.value="0"==e.is_null,Ve.value="1"==e.isMultiSelect,Ye.value=Object.assign(Ye.value,e.validate||{}),$e.value=Object.assign($e.value,e.wordbook||{}),ze.value=Object.assign(ze.value,e||{}),P(e.html_type)&&function(e){let l=(null==e?void 0:e.optionValue)||[];l.length||l.push({text:void 0,value:void 0}),Te.value=[...l],delete e.optionValue}(e)}function al(e){ze.value.html_type=e,Te.value=[{text:void 0,value:void 0}];let l=function(){if(F(Ee.value))return[]}();ze.value.default_val=l,A(e)?ze.value.date_format="yyyy-MM-dd HH:mm:ss":ze.value.date_format=""}function tl(){Te.value.push({value:"",text:""})}function ul(e){let l=e;(e<0||0===e)&&(l=0),e>5&&(l=5),Be.value=0===l?l:l||void 0}function nl(e){Te.value=e}function il(e){let l=e||"yyyy-MM-dd HH:mm:ss",a=Ze(l)?"time":"date",t="yyyy-MM"===l?"month":"date";let u=function(e){return["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm","MM-dd HH:mm"].includes(e)}(l),n="";["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm","MM-dd HH:mm"].includes(e)&&(n="datetime"),["yyyy-MM-dd","MM-dd"].includes(e)&&(n="date"),Object.assign(Ne.value,{format:l,dateType:a,mode:t,showTime:u,componentType:n})}function ol(e,l){if(e)return l&&(l.includes("yyyy")&&(l=l.replace("yyyy","YYYY")),l.includes("dd")&&(l=l.replace("dd","DD"))),K(e).format(l)}function vl(){Ne.value.open=!Ne.value.open}function dl(e){let l=ol(e,Ne.value.format);ze.value.default_val=l}function rl(e){let l=ol(e,Ne.value.format);ze.value.default_val=l,Ne.value.format.includes("HH:mm")||vl()}function sl(e){let l=ol(e,Ne.value.format);ze.value.default_val=l}function pl(){ge("cancelModal"),Ue.value="860px",Se.value={height:"496px",maxHeight:"496px"},Ce.value=!1,ze.value={name:void 0,remark:void 0,is_edit:"1",is_null:"1",is_show:"1",key:"",val_key:void 0,validate:{},html_type:"INPUT",name_i18n:void 0,elem_width:"12",default_val:void 0,label_type:void 0,isMultiSelect:"0",decimal_length:void 0,date_format:""}}function fl(){var e;null==(e=Ie.value)||e.validate((async e=>{if(e)return;let l=Object.assign({},ze.value);if(l.validate={...Ye.value},l.extendId=be.id,P(Ee.value)){let e=function(){let e={validate:!1,message:"请完善选项配置"};if(!Te.value||!Te.value.length)return e;let l,a,t,u=0,n=Te.value.length,i=!1;for(;u<n;u++){if(l=Te.value[u],a=l.value?l.value.trim():l.value,t=l.text?l.text.trim():l.text,!a||!t){i=!0;break}l.value=a,l.text=t}return[...new Set(Te.value.map((e=>e.value)))].length!==Te.value.length?(e.message="选项值不能重复",e):(!i&&(e.validate=!0),e)}();if(!e.validate)return De.value=!0,void xe.warning(e.message);De.value=!1,l.option=[...Te.value]}if(q(Ee.value)?l.default_val=function(e){let l=e.default_val;if(void 0===Be.value)return l;if(!l)return l;let a=String(l).split(".")[1];return a&&a.length!==Be.value?Number(l.toFixed(Be.value)):l}(l):F(Ee.value)&&(l.default_val=l.default_val.join(",")),!E(Ee.value)||function(e){let{default_val:l}=e;qe.value="",l&&G(l)&&(l=JSON.parse(l));let a=function(e,l){if(!e)return;if("string"!=typeof e)return;if(!(e=e.trim()))return!0;if(!e.startsWith("${"))return ml(l,"请输入有效系统变量"),"error";let a=/\${sys.(.*?)\}/g.exec(e);if(!a||!a[1])return ml(l,"请输入有效系统变量"),"error";return!0}(l,e);if(a)return"error"!==a;if(console.log("saveOjb.isMultiSelect>>>",e.isMultiSelect),console.log("default_val?.length>>>",null==l?void 0:l.length),"0"===e.isMultiSelect&&(null==l?void 0:l.length)>1)return console.log("进入到判断里面了>>>>>"),ml(e,"选人组件为单选"),!1;return!0}(l)){for(let e in l){let a=l[e];"string"==typeof a&&(l[e]=null==a?void 0:a.trim())}console.log("saveOjb>>>",l),await async function(e={}){Fe.value=!0;try{const l=await je(e,Oe);if(Fe.value=!1,"SUCCESS"!==(null==l?void 0:l.result))return void xe.error((null==l?void 0:l.resultMsg)||"保存失败");pl()}catch(e){Fe.value=!1}}(l)}}))}function ml(e,l){qe.value=l}return u((()=>be.visible),(e=>{e&&ll()})),(l,a)=>(n(),i(o(H),{class:v(["expand-field-modal-block",{"modal-screen":Ce.value}]),show:e.visible,"onUpdate:show":a[22]||(a[22]=e=>d(visible)?visible.value=e:null),maskClosable:!1,width:Ue.value,bodyStyle:o(Se),closable:!1,centered:"",onPositiveClick:fl,onNegativeClick:pl},{default:r((()=>[s(o(C),{style:p({width:Ue.value,...o(Se)}),title:"add"===be.formOntype?"新增拓展字段":"编辑拓展字段",bordered:!1,size:"huge",role:"dialog","aria-modal":"true"},{"header-extra":r((()=>[f("div",le,[f("i",{onClick:Qe,class:v(["iconfont-expand-field",Ce.value?"icon-expand-field-menzhenyishengzhanxitongtubiaozuixiaohua2":"icon-expand-field-menzhenyishengzhanxitongtubiaozuidahua"])},null,2),f("i",{onClick:pl,class:"iconfont-expand-field icon-expand-field-menzhenyishengzhanxitongtubiaoguanbi"})])])),footer:r((()=>[f("div",ae,[s(o(U),{onClick:pl},{default:r((()=>[m("取消")])),_:1}),s(o(U),{type:"info",onClick:fl},{default:r((()=>[m("保存")])),_:1})])])),default:r((()=>[s(o(S),{ref_key:"formRef",ref:Ie,model:ze.value,rules:Me},{default:r((()=>[s(o(j),{path:"name",label:"字段标题","require-mark-placement":"left"},{default:r((()=>[s(o(O),{value:ze.value.name,"onUpdate:value":a[0]||(a[0]=e=>ze.value.name=e),maxlength:100,clearable:"",placeholder:"请输入"},null,8,["value"])])),_:1}),s(o(j),{path:"key"},{label:r((()=>[f("div",te,[ue,s(o(I),{duration:0},{trigger:r((()=>[ne])),default:r((()=>[m(" 数据库字段键名,不填写时由系统生成,填写则以填写为准 ")])),_:1})])])),default:r((()=>[s(o(O),{value:ze.value.key,"onUpdate:value":a[1]||(a[1]=e=>ze.value.key=e),maxlength:32,disabled:o(Ae),clearable:"",placeholder:"数据库字段键名,不填写时由系统生成,填写则以填写为准"},null,8,["value","disabled"])])),_:1}),s(o(j),{path:"html_type",label:"字段类型","require-mark-placement":"left"},{default:r((()=>[s(o(z),{value:ze.value.html_type,"onUpdate:value":[a[2]||(a[2]=e=>ze.value.html_type=e),al],placeholder:"请选择字段类型",clearable:"",filterable:"",options:o(X)},null,8,["value","options"])])),_:1}),s(o(j),{path:"remark",label:"字段问号提示"},{label:r((()=>[f("div",ie,[oe,s(o(I),{duration:0},{trigger:r((()=>[ve])),default:r((()=>[m(" 设置后该字段旁会有问号图标,鼠标悬浮展示“问号提示”内容,常用于告诉用户该字段的含义 ")])),_:1})])])),default:r((()=>[s(o(O),{value:ze.value.remark,"onUpdate:value":a[3]||(a[3]=e=>ze.value.remark=e),placeholder:"请输入",type:"textarea",clearable:"",maxlength:255,rows:3},null,8,["value"])])),_:1}),c(" 选项值>>>>>类型对应关系 "),o(P)(o(Ee))?(n(),i(o(j),{key:0},{label:r((()=>[f("div",de,[re,f("span",{class:"batch-span",onClick:tl},"添加选项"),f("span",{class:"batch-span",onClick:a[4]||(a[4]=()=>We(!0))},"批量编辑")])])),default:r((()=>[f("div",{class:v(["options-item",{"options-item-err":De.value}])},[(n(!0),y(h,null,_(Te.value,((e,l)=>(n(),i(o(T),{class:"mgb-10",key:l,cols:24,"x-gap":8,"y-gap":8},{default:r((()=>[s(o(N),{span:11},{default:r((()=>[s(o(O),{value:e.value,"onUpdate:value":l=>e.value=l,maxLength:100,allowClear:"",placeholder:"选项值"},null,8,["value","onUpdate:value"])])),_:2},1024),s(o(N),{span:11},{default:r((()=>[s(o(O),{value:e.text,"onUpdate:value":l=>e.text=l,maxLength:100,allowClear:"",placeholder:"选项文本"},null,8,["value","onUpdate:value"])])),_:2},1024),s(o(N),{span:2,class:"flex-center"},{default:r((()=>[Te.value.length>1?(n(),i(o(Y),{key:0,onClick:a=>function(e,l){Te.value.splice(l,1);let a=ze.value.default_val;if(F(Ee.value)){if(!a||!a.length)return;let l=a.findIndex((l=>l===e.value));l||a.splice(l,1)}else{if(!a)return;a===e.value&&(a=void 0)}ze.value.default_val=a}(e,l)},{default:r((()=>[se])),_:2},1032,["onClick"])):c("v-if",!0)])),_:2},1024)])),_:2},1024)))),128))],2)])),_:1})):c("v-if",!0),o(q)(o(Ee))?(n(),i(o(j),{key:1,path:"decimal_length",label:"小数位"},{default:r((()=>[s(o($),{style:{width:"100%"},min:0,max:5,placeholder:"请输入",precision:0,clearable:"",value:ze.value.decimal_length,"onUpdate:value":[a[5]||(a[5]=e=>ze.value.decimal_length=e),ul]},null,8,["value"])])),_:1})):c("v-if",!0),o(A)(o(Ee))?(n(),i(o(j),{key:2,path:"date_format",label:"日期格式"},{default:r((()=>[s(o(z),{style:{width:"100%"},value:ze.value.date_format,"onUpdate:value":[a[6]||(a[6]=e=>ze.value.date_format=e),Ge],placeholder:"请选择",options:we},null,8,["value"])])),_:1})):c("v-if",!0),c(" 默认值>>>>>类型对应关系 "),s(o(j),{path:"default_val",label:"默认值"},{label:r((()=>[f("div",pe,[fe,o(E)(o(Ee))?(n(),i(o(I),{key:0,duration:0},{trigger:r((()=>[me])),default:r((()=>[m(" 支持输入系统变量当前操作人${sys.userId},也支持选择一个人 ")])),_:1})):c("v-if",!0)])])),default:r((()=>[o(J)(o(Ee))?(n(),i(o(O),{key:0,value:ze.value.default_val,"onUpdate:value":a[7]||(a[7]=e=>ze.value.default_val=e),placeholder:ke,type:"textarea",clearable:"",maxlength:1e3,rows:3},null,8,["value"])):o(q)(o(Ee))?(n(),y(h,{key:1},[c(" 数字框 "),s(o($),{style:{width:"100%"},clearable:"",placeholder:ke,precision:Be.value,value:ze.value.default_val,"onUpdate:value":a[8]||(a[8]=e=>ze.value.default_val=e)},null,8,["precision","value"])],2112)):o(P)(o(Ee))?(n(),y(h,{key:2},[c(" 下拉框、横向单选、纵向单选、横向多选、纵向多选、下拉多选框 "),s(o(z),{style:{width:"100%"},multiple:o(Ke),clearable:"",value:ze.value.default_val,"onUpdate:value":a[9]||(a[9]=e=>ze.value.default_val=e),"label-field":"text",placeholder:ke,options:o(Je)},null,8,["multiple","value","options"])],2112)):o(A)(o(Ee))?(n(),y(h,{key:3},[c(" 日期 "),f("div",ce,[s(o(O),{clearable:"",maxLength:255,value:ze.value.default_val,"onUpdate:value":a[10]||(a[10]=e=>ze.value.default_val=e),placeholder:ke},null,8,["value"]),o(Re)?(n(),y(h,{key:0},["month"===Ne.value.mode?(n(),i(o(L),{key:0,trigger:"click",show:Ne.value.open},{trigger:r((()=>[s(o(U),{type:"info",onClick:vl},{default:r((()=>[m("选择")])),_:1})])),default:r((()=>[s(o(V),{panel:"",value:Ne.value.value,"onUpdate:value":[a[11]||(a[11]=e=>Ne.value.value=e),dl],type:"month","input-readonly":"",clearable:"",onConfirm:vl},null,8,["value"])])),_:1},8,["show"])):(n(),i(o(L),{key:1,trigger:"click",show:Ne.value.open},{trigger:r((()=>[s(o(U),{type:"info",onClick:vl},{default:r((()=>[m("选择")])),_:1})])),default:r((()=>[s(o(V),{panel:"",value:Ne.value.value,"onUpdate:value":[a[12]||(a[12]=e=>Ne.value.value=e),rl],format:Ne.value.format,type:Ne.value.componentType,"input-readonly":"",clearable:"",onConfirm:vl},null,8,["value","format","type"])])),_:1},8,["show"]))],64)):(n(),y(h,{key:1},[c(' <n-input\n allowClear\n :maxLength="255"\n v-model:value="dateInfo.value"\n @keydown.enter.prevent\n :placeholder="defaultPlaceholder"\n /> '),s(o(U),{type:"info",class:"date-time-button"},{default:r((()=>[ye,s(o(B),{value:Ne.value.value,"onUpdate:value":[a[13]||(a[13]=e=>Ne.value.value=e),sl],format:Ne.value.format,"input-readonly":"",clearable:""},null,8,["value","format"])])),_:1}),c(' <n-popover trigger="click">\n <template #trigger>\n <n-button type="info">选择</n-button>\n </template>\n <n-time-picker\n panel\n v-model:value="dateInfo.value"\n :format="dateInfo.format"\n input-readonly\n clearable\n @update:value="timeChange"\n >\n <template v-slot:icon>111</template>\n\n </n-time-picker>\n </n-popover> ')],64))])],2112)):o(E)(o(Ee))?(n(),y(h,{key:4},[c(" 选人组件(增加一个选人组件) "),f("div",he,[g(s(o(O),{allowClear:"",maxLength:255,value:ze.value.default_val,"onUpdate:value":a[14]||(a[14]=e=>ze.value.default_val=e),onKeydown:a[15]||(a[15]=b(x((()=>{}),["prevent"]),["enter"])),placeholder:ke},null,8,["value"]),[[k,!1]]),c(' 点击弹出选人组件弹窗 :mainForm="this" '),s(ee,{orgId:e.orgId,defaultValue:ze.value.default_val,onCheckPerson:Xe},null,8,["orgId","defaultValue"]),qe.value?(n(),y("span",_e,M(qe.value),1)):c("v-if",!0),c(' <n-button type="info">选择</n-button> ')])],2112)):(n(),y(h,{key:5},[c(" 其他 "),s(o(O),{value:ze.value.default_val,"onUpdate:value":a[16]||(a[16]=e=>ze.value.default_val=e),onKeydown:a[17]||(a[17]=b(x((()=>{}),["prevent"]),["enter"])),placeholder:"请输入默认值"},null,8,["value"])],2112))])),_:1}),s(o(j),{path:"elem_width",label:"宽度"},{default:r((()=>[s(o(z),{value:ze.value.elem_width,"onUpdate:value":a[18]||(a[18]=e=>ze.value.elem_width=e),placeholder:"请选择宽度",options:He},null,8,["value"])])),_:1}),s(o(j),{path:"isNull",label:"是否必填","label-placement":"left"},{default:r((()=>[s(o(D),{value:Le.value,"onUpdate:value":[a[19]||(a[19]=e=>Le.value=e),a[20]||(a[20]=e=>el("isNull",e))]},null,8,["value"])])),_:1}),o(E)(o(Ee))?(n(),i(o(j),{key:3,"label-placement":"left",path:"isMultiSelect",label:"是否多选"},{default:r((()=>[s(o(D),{value:Ve.value,"onUpdate:value":a[21]||(a[21]=e=>el("isMultiSelect",e))},null,8,["value"])])),_:1})):c("v-if",!0)])),_:1},8,["model"]),s(Z,{visible:Pe.value,options:Te.value,onHandleSaveBatch:nl,onTriggerBatch:We},null,8,["visible","options"])])),_:1},8,["style","title"])])),_:1},8,["class","show","width","bodyStyle"]))}});export{ge as default};
1
+ import{defineComponent as e,ref as l,inject as a,computed as t,watch as u,openBlock as n,createBlock as i,unref as o,normalizeClass as v,isRef as d,withCtx as r,createVNode as s,normalizeStyle as p,createElementVNode as f,createTextVNode as m,createCommentVNode as c,createElementBlock as y,Fragment as h,renderList as _,withDirectives as g,withKeys as b,withModifiers as x,vShow as k,toDisplayString as M}from"vue";import{useMessage as w,NModal as H,NCard as C,NButton as U,NForm as S,NFormItem as j,NInput as O,NTooltip as I,NSelect as z,NGrid as T,NGridItem as N,NIcon as Y,NInputNumber as $,NPopover as L,NDatePicker as V,NTimePicker as B,NSwitch as D}from"naive-ui";import{isMulti as F,isShowOptions as P,isNumber as q,isDate as A,isCandidate as E,isTextarea as J}from"../utils/index.js";import K from"moment";import{InjectionExpandFieldApiConfig as R}from"../constants/index.js";import W from"../hooks/useAsyncData.js";import{HtmlTypeList as X}from"../utils/constant.js";import{isJSON as G,isValidDate as Q}from"../utils/tool.js";import Z from"./FormBatchOptionsModal.vue.js";import ee from"./FormItemPerson.vue.js";const le={class:"svg-wrap"},ae={class:"flex_right"},te={class:"options-title"},ue=f("span",null,"字段键名",-1),ne=f("i",{class:"iconfont-expand-field icon-expand-field-help"},null,-1),ie={class:"options-title"},oe=f("span",null,"字段问号提示",-1),ve=f("i",{class:"iconfont-expand-field icon-expand-field-help"},null,-1),de={class:"options-title"},re=f("span",null,"选项值",-1),se=f("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 32 32"},[f("path",{d:"M12 12h2v12h-2z",fill:"currentColor"}),f("path",{d:"M18 12h2v12h-2z",fill:"currentColor"}),f("path",{d:"M4 6v2h2v20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8h2V6zm4 22V8h16v20z",fill:"currentColor"}),f("path",{d:"M12 2h8v2h-8z",fill:"currentColor"})],-1),pe={class:"options-title"},fe=f("span",null,"默认值",-1),me=f("i",{class:"iconfont-expand-field icon-expand-field-help"},null,-1),ce={style:{display:"flex","align-items":"center"}},ye=f("span",null,"选择",-1),he={style:{width:"100%"}},_e={key:0,class:"validate_tip"};var ge=e({__name:"form",props:{visible:{type:Boolean,default:!1},formOntype:{type:String,default:"add"},formItemData:{type:Object,default:()=>({})},id:{type:String,default:""},orgId:{type:String,default:""},conditionList:{type:Array,default:()=>[]},searchFieldList:{type:Array,default:()=>[]}},emits:["cancelModal"],setup(e,{emit:ge}){const be=e,xe=w(),ke="请输入默认值",Me={name:[{required:!0,message:"请输入字段标题",trigger:["input","blur"]}],html_type:[{required:!0,message:"请选择字段类型",trigger:["input","blur"]}]},we=[{value:"yyyy-MM-dd HH:mm:ss",label:"年-月-日 时:分:秒"},{value:"yyyy-MM-dd HH:mm",label:"年-月-日 时:分"},{value:"yyyy-MM-dd",label:"年-月-日"},{value:"yyyy-MM",label:"年-月"},{value:"MM-dd HH:mm",label:"月-日 时:分"},{value:"MM-dd",label:"月-日"},{value:"HH:mm:ss",label:"时:分:秒"},{value:"HH:mm",label:"时:分"}],He=[{value:"12",label:"整行"},{value:"6",label:"半行"},{value:"4",label:"1/3行"},{value:"8",label:"2/3行"},{value:"3",label:"1/4行"},{value:"9",label:"3/4行"},{value:"2",label:"1/6行"},{value:"10",label:"5/6行"},{value:"1.5",label:"1/8行"},{value:"10.5",label:"7/8行"}],Ce=l(!1),Ue=l("860px");let Se=l({maxHeight:"496px",height:"496px"});const{saveOrUpdateExtendField:je}=W(),Oe=a(R),Ie=l(null),ze=l({name:void 0,remark:void 0,is_edit:"1",is_null:"1",is_show:"1",key:"",val_key:void 0,validate:{},html_type:"INPUT",name_i18n:void 0,elem_width:"12",default_val:void 0,label_type:void 0,isMultiSelect:"0",decimal_length:void 0,date_format:""}),Te=l([{text:void 0,value:void 0}]),Ne=l({format:"yyyy-MM-dd HH:mm:ss",dateType:"date",mode:"date",value:null,showTime:!0,open:!1,componentType:"datetime"}),Ye=l({obj_type:"",vali_obj:"",event_obj:"",max_length:"",min_length:"",min_value:"",max_value:""}),$e=l({value_key:"",levelSetting:[],search_key:[],level_num:void 0,render_key:[],name:"",level_key:"",id:"",type:"",primary_key:"",sqlExpression:"",conObj:"",add_btn:"",setting:{cascading:[]}}),Le=l(!1),Ve=l(!1),Be=l(void 0),De=l(!1),Fe=l(!1);l(!1);const Pe=l(!1),qe=l(""),Ae=t((()=>"edit"===be.formOntype)),Ee=t((()=>ze.value.html_type||""));t((()=>"TEXTAREA"===Ee.value?1e3:255));const Je=t((()=>Te.value.filter((e=>e.value&&e.text)))),Ke=t((()=>F(Ee.value))),Re=t((()=>"date"===Ne.value.dateType));function We(e){Pe.value=e}function Xe(e){let l=e;"string"!=typeof e&&(l=JSON.stringify(e)),ze.value.default_val=l}function Ge(e){Ne.value.value=null,ze.value.default_val=void 0,il(e)}function Qe(){Ce.value=!Ce.value;let e=document.body.clientHeight;"860px"===Ue.value?(Ue.value="100%",Se.value.maxHeight=`${e}px`,Se.value.height=`${e}px`):(Ue.value="860px",Se.value.maxHeight="496px",Se.value.height="")}function Ze(e){return["HH:mm:ss","HH:mm"].includes(e)}function el(e,l){switch(e){case"isNull":Le.value=l,ze.value.is_null=l?"0":"1";break;case"isMultiSelect":Ve.value=l,ze.value.isMultiSelect=l?"1":"0"}}function ll(){if("add"===be.formOntype)return;let e=Object.assign({},be.formItemData),l=e.setting;l&&G(l)&&(l=JSON.parse(l),delete e.setting,Object.assign(e,{...l})),e.key=e.code,delete e.code,A(e.html_type)&&function(e){il(e.date_format);let l=e.default_val;l&&!l.startsWith("${")&&(Ze(e.date_format)&&(l=`${K().format("YYYY-MM-dd")} ${l}`),Q(new Date(l))&&(Ne.value.value=K(l)))}(e),F(e.html_type)&&(e.default_val=function(e){let l=e.default_val;return l?l.split(",").filter(Boolean):[]}(e)),Le.value="0"==e.is_null,Ve.value="1"==e.isMultiSelect,Ye.value=Object.assign(Ye.value,e.validate||{}),$e.value=Object.assign($e.value,e.wordbook||{}),ze.value=Object.assign(ze.value,e||{}),P(e.html_type)&&function(e){let l=(null==e?void 0:e.optionValue)||[];l.length||l.push({text:void 0,value:void 0}),Te.value=[...l],delete e.optionValue}(e)}function al(e){ze.value.html_type=e,Te.value=[{text:void 0,value:void 0}];let l=function(){if(F(Ee.value))return[]}();ze.value.default_val=l,A(e)?ze.value.date_format="yyyy-MM-dd HH:mm:ss":ze.value.date_format=""}function tl(){Te.value.push({value:"",text:""})}function ul(e){let l=e;(e<0||0===e)&&(l=0),e>5&&(l=5),Be.value=0===l?l:l||void 0}function nl(e){Te.value=e}function il(e){let l=e||"yyyy-MM-dd HH:mm:ss",a=Ze(l)?"time":"date",t="yyyy-MM"===l?"month":"date";let u=function(e){return["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm","MM-dd HH:mm"].includes(e)}(l),n="";["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm","MM-dd HH:mm"].includes(e)&&(n="datetime"),["yyyy-MM-dd","MM-dd"].includes(e)&&(n="date"),Object.assign(Ne.value,{format:l,dateType:a,mode:t,showTime:u,componentType:n})}function ol(e,l){if(e)return l&&(l.includes("yyyy")&&(l=l.replace("yyyy","YYYY")),l.includes("dd")&&(l=l.replace("dd","DD"))),K(e).format(l)}function vl(){Ne.value.open=!Ne.value.open}function dl(e){let l=ol(e,Ne.value.format);ze.value.default_val=l}function rl(e){let l=ol(e,Ne.value.format);ze.value.default_val=l,Ne.value.format.includes("HH:mm")||vl()}function sl(e){let l=ol(e,Ne.value.format);ze.value.default_val=l}function pl(){ge("cancelModal"),Ue.value="860px",Se.value={height:"496px",maxHeight:"496px"},Ce.value=!1,ze.value={name:void 0,remark:void 0,is_edit:"1",is_null:"1",is_show:"1",key:"",val_key:void 0,validate:{},html_type:"INPUT",name_i18n:void 0,elem_width:"12",default_val:void 0,label_type:void 0,isMultiSelect:"0",decimal_length:void 0,date_format:""}}function fl(){var e;null==(e=Ie.value)||e.validate((async e=>{if(e)return;let l=Object.assign({},ze.value);if(l.validate={...Ye.value},l.extendId=be.id,P(Ee.value)){let e=function(){let e={validate:!1,message:"请完善选项配置"};if(!Te.value||!Te.value.length)return e;let l,a,t,u=0,n=Te.value.length,i=!1;for(;u<n;u++){if(l=Te.value[u],a=l.value?l.value.trim():l.value,t=l.text?l.text.trim():l.text,!a||!t){i=!0;break}l.value=a,l.text=t}return[...new Set(Te.value.map((e=>e.value)))].length!==Te.value.length?(e.message="选项值不能重复",e):(!i&&(e.validate=!0),e)}();if(!e.validate)return De.value=!0,void xe.warning(e.message);De.value=!1,l.option=[...Te.value]}if(q(Ee.value)?l.default_val=function(e){let l=e.default_val;if(void 0===Be.value)return l;if(!l)return l;let a=String(l).split(".")[1];return a&&a.length!==Be.value?Number(l.toFixed(Be.value)):l}(l):F(Ee.value)&&(l.default_val=l.default_val.join(",")),!E(Ee.value)||function(e){let{default_val:l}=e;qe.value="",l&&G(l)&&(l=JSON.parse(l));let a=function(e,l){if(!e)return;if("string"!=typeof e)return;if(!(e=e.trim()))return!0;if(!e.startsWith("${"))return ml(l,"请输入有效系统变量"),"error";let a=/\${sys.(.*?)\}/g.exec(e);if(!a||!a[1])return ml(l,"请输入有效系统变量"),"error";return!0}(l,e);if(a)return"error"!==a;if(console.log("saveOjb.isMultiSelect>>>",e.isMultiSelect),console.log("default_val?.length>>>",null==l?void 0:l.length),"0"===e.isMultiSelect&&(null==l?void 0:l.length)>1)return console.log("进入到判断里面了>>>>>"),ml(e,"选人组件为单选"),!1;return!0}(l)){for(let e in l){let a=l[e];"string"==typeof a&&(l[e]=null==a?void 0:a.trim())}console.log("saveOjb>>>",l),await async function(e={}){Fe.value=!0;try{const l=await je(e,Oe);if(Fe.value=!1,"SUCCESS"!==(null==l?void 0:l.result))return void xe.error((null==l?void 0:l.resultMsg)||"保存失败");pl()}catch(e){Fe.value=!1}}(l)}}))}function ml(e,l){qe.value=l}return u((()=>be.visible),(e=>{e&&ll()})),(l,a)=>(n(),i(o(H),{class:v(["expand-field-modal-block",{"modal-screen":Ce.value}]),show:e.visible,"onUpdate:show":a[22]||(a[22]=e=>d(visible)?visible.value=e:null),maskClosable:!1,width:Ue.value,bodyStyle:o(Se),closable:!1,centered:"",onPositiveClick:fl,onNegativeClick:pl},{default:r((()=>[s(o(C),{style:p({width:Ue.value,...o(Se)}),title:"add"===be.formOntype?"新增拓展字段":"编辑拓展字段",bordered:!1,size:"huge",role:"dialog","aria-modal":"true"},{"header-extra":r((()=>[f("div",le,[f("i",{onClick:Qe,class:v(["iconfont-expand-field",Ce.value?"icon-expand-field-menzhenyishengzhanxitongtubiaozuixiaohua2":"icon-expand-field-menzhenyishengzhanxitongtubiaozuidahua"])},null,2),f("i",{onClick:pl,class:"iconfont-expand-field icon-expand-field-menzhenyishengzhanxitongtubiaoguanbi"})])])),footer:r((()=>[f("div",ae,[s(o(U),{onClick:pl},{default:r((()=>[m("取消")])),_:1}),s(o(U),{type:"info",onClick:fl},{default:r((()=>[m("保存")])),_:1})])])),default:r((()=>[s(o(S),{ref_key:"formRef",ref:Ie,model:ze.value,rules:Me},{default:r((()=>[s(o(j),{path:"name",label:"字段标题","require-mark-placement":"left"},{default:r((()=>[s(o(O),{value:ze.value.name,"onUpdate:value":a[0]||(a[0]=e=>ze.value.name=e),maxlength:100,clearable:"",placeholder:"请输入"},null,8,["value"])])),_:1}),s(o(j),{path:"key"},{label:r((()=>[f("div",te,[ue,s(o(I),{duration:0},{trigger:r((()=>[ne])),default:r((()=>[m(" 数据库字段键名,不填写时由系统生成,填写则以填写为准 ")])),_:1})])])),default:r((()=>[s(o(O),{value:ze.value.key,"onUpdate:value":a[1]||(a[1]=e=>ze.value.key=e),maxlength:32,disabled:o(Ae),clearable:"",placeholder:"数据库字段键名,不填写时由系统生成,填写则以填写为准"},null,8,["value","disabled"])])),_:1}),s(o(j),{path:"html_type",label:"字段类型","require-mark-placement":"left"},{default:r((()=>[s(o(z),{value:ze.value.html_type,"onUpdate:value":[a[2]||(a[2]=e=>ze.value.html_type=e),al],placeholder:"请选择字段类型",clearable:"",filterable:"",options:o(X)},null,8,["value","options"])])),_:1}),s(o(j),{path:"remark",label:"字段问号提示"},{label:r((()=>[f("div",ie,[oe,s(o(I),{duration:0},{trigger:r((()=>[ve])),default:r((()=>[m(" 设置后该字段旁会有问号图标,鼠标悬浮展示“问号提示”内容,常用于告诉用户该字段的含义 ")])),_:1})])])),default:r((()=>[s(o(O),{value:ze.value.remark,"onUpdate:value":a[3]||(a[3]=e=>ze.value.remark=e),placeholder:"请输入",type:"textarea",clearable:"",maxlength:255,rows:3},null,8,["value"])])),_:1}),c(" 选项值>>>>>类型对应关系 "),o(P)(o(Ee))?(n(),i(o(j),{key:0},{label:r((()=>[f("div",de,[re,f("span",{class:"batch-span",onClick:tl},"添加选项"),f("span",{class:"batch-span",onClick:a[4]||(a[4]=()=>We(!0))},"批量编辑")])])),default:r((()=>[f("div",{class:v(["options-item",{"options-item-err":De.value}])},[(n(!0),y(h,null,_(Te.value,((e,l)=>(n(),i(o(T),{class:"mgb-10",key:l,cols:24,"x-gap":8,"y-gap":8},{default:r((()=>[s(o(N),{span:11},{default:r((()=>[s(o(O),{value:e.value,"onUpdate:value":l=>e.value=l,maxLength:100,allowClear:"",placeholder:"选项值"},null,8,["value","onUpdate:value"])])),_:2},1024),s(o(N),{span:11},{default:r((()=>[s(o(O),{value:e.text,"onUpdate:value":l=>e.text=l,maxLength:100,allowClear:"",placeholder:"选项文本"},null,8,["value","onUpdate:value"])])),_:2},1024),s(o(N),{span:2,class:"flex-center"},{default:r((()=>[Te.value.length>1?(n(),i(o(Y),{key:0,onClick:a=>function(e,l){Te.value.splice(l,1);let a=ze.value.default_val;if(F(Ee.value)){if(!a||!a.length)return;let l=a.findIndex((l=>l===e.value));l||a.splice(l,1)}else{if(!a)return;a===e.value&&(a=void 0)}ze.value.default_val=a}(e,l)},{default:r((()=>[se])),_:2},1032,["onClick"])):c("v-if",!0)])),_:2},1024)])),_:2},1024)))),128))],2)])),_:1})):c("v-if",!0),o(q)(o(Ee))?(n(),i(o(j),{key:1,path:"decimal_length",label:"小数位"},{default:r((()=>[s(o($),{style:{width:"100%"},min:0,max:5,placeholder:"请输入",precision:0,clearable:"",value:ze.value.decimal_length,"onUpdate:value":[a[5]||(a[5]=e=>ze.value.decimal_length=e),ul]},null,8,["value"])])),_:1})):c("v-if",!0),o(A)(o(Ee))?(n(),i(o(j),{key:2,path:"date_format",label:"日期格式"},{default:r((()=>[s(o(z),{style:{width:"100%"},value:ze.value.date_format,"onUpdate:value":[a[6]||(a[6]=e=>ze.value.date_format=e),Ge],placeholder:"请选择",options:we},null,8,["value"])])),_:1})):c("v-if",!0),c(" 默认值>>>>>类型对应关系 "),s(o(j),{path:"default_val",label:"默认值"},{label:r((()=>[f("div",pe,[fe,o(E)(o(Ee))?(n(),i(o(I),{key:0,duration:0},{trigger:r((()=>[me])),default:r((()=>[m(" 支持输入系统变量当前操作人${sys.userId},也支持选择一个人 ")])),_:1})):c("v-if",!0)])])),default:r((()=>[o(J)(o(Ee))?(n(),i(o(O),{key:0,value:ze.value.default_val,"onUpdate:value":a[7]||(a[7]=e=>ze.value.default_val=e),placeholder:ke,type:"textarea",clearable:"",maxlength:1e3,rows:3},null,8,["value"])):o(q)(o(Ee))?(n(),y(h,{key:1},[c(" 数字框 "),s(o($),{style:{width:"100%"},clearable:"",placeholder:ke,precision:Be.value,value:ze.value.default_val,"onUpdate:value":a[8]||(a[8]=e=>ze.value.default_val=e)},null,8,["precision","value"])],2112)):o(P)(o(Ee))?(n(),y(h,{key:2},[c(" 下拉框、横向单选、纵向单选、横向多选、纵向多选、下拉多选框 "),s(o(z),{style:{width:"100%"},multiple:o(Ke),clearable:"",value:ze.value.default_val,"onUpdate:value":a[9]||(a[9]=e=>ze.value.default_val=e),"label-field":"text",placeholder:ke,options:o(Je)},null,8,["multiple","value","options"])],2112)):o(A)(o(Ee))?(n(),y(h,{key:3},[c(" 日期 "),f("div",ce,[s(o(O),{clearable:"",maxLength:255,value:ze.value.default_val,"onUpdate:value":a[10]||(a[10]=e=>ze.value.default_val=e),placeholder:ke},null,8,["value"]),o(Re)?(n(),y(h,{key:0},["month"===Ne.value.mode?(n(),i(o(L),{key:0,trigger:"click",show:Ne.value.open},{trigger:r((()=>[s(o(U),{type:"info",onClick:vl},{default:r((()=>[m("选择")])),_:1})])),default:r((()=>[s(o(V),{panel:"",value:Ne.value.value,"onUpdate:value":[a[11]||(a[11]=e=>Ne.value.value=e),dl],type:"month","input-readonly":"",clearable:"",onConfirm:vl},null,8,["value"])])),_:1},8,["show"])):(n(),i(o(L),{key:1,trigger:"click",show:Ne.value.open},{trigger:r((()=>[s(o(U),{type:"info",onClick:vl},{default:r((()=>[m("选择")])),_:1})])),default:r((()=>[s(o(V),{panel:"",value:Ne.value.value,"onUpdate:value":[a[12]||(a[12]=e=>Ne.value.value=e),rl],format:Ne.value.format,type:Ne.value.componentType,"input-readonly":"",clearable:"",onConfirm:vl},null,8,["value","format","type"])])),_:1},8,["show"]))],64)):(n(),y(h,{key:1},[c(' <n-input\r\n allowClear\r\n :maxLength="255"\r\n v-model:value="dateInfo.value"\r\n @keydown.enter.prevent\r\n :placeholder="defaultPlaceholder"\r\n /> '),s(o(U),{type:"info",class:"date-time-button"},{default:r((()=>[ye,s(o(B),{value:Ne.value.value,"onUpdate:value":[a[13]||(a[13]=e=>Ne.value.value=e),sl],format:Ne.value.format,"input-readonly":"",clearable:""},null,8,["value","format"])])),_:1}),c(' <n-popover trigger="click">\r\n <template #trigger>\r\n <n-button type="info">选择</n-button>\r\n </template>\r\n <n-time-picker\r\n panel\r\n v-model:value="dateInfo.value"\r\n :format="dateInfo.format"\r\n input-readonly\r\n clearable\r\n @update:value="timeChange"\r\n >\r\n <template v-slot:icon>111</template>\r\n\r\n </n-time-picker>\r\n </n-popover> ')],64))])],2112)):o(E)(o(Ee))?(n(),y(h,{key:4},[c(" 选人组件(增加一个选人组件) "),f("div",he,[g(s(o(O),{allowClear:"",maxLength:255,value:ze.value.default_val,"onUpdate:value":a[14]||(a[14]=e=>ze.value.default_val=e),onKeydown:a[15]||(a[15]=b(x((()=>{}),["prevent"]),["enter"])),placeholder:ke},null,8,["value"]),[[k,!1]]),c(' 点击弹出选人组件弹窗 :mainForm="this" '),s(ee,{orgId:e.orgId,defaultValue:ze.value.default_val,onCheckPerson:Xe},null,8,["orgId","defaultValue"]),qe.value?(n(),y("span",_e,M(qe.value),1)):c("v-if",!0),c(' <n-button type="info">选择</n-button> ')])],2112)):(n(),y(h,{key:5},[c(" 其他 "),s(o(O),{value:ze.value.default_val,"onUpdate:value":a[16]||(a[16]=e=>ze.value.default_val=e),onKeydown:a[17]||(a[17]=b(x((()=>{}),["prevent"]),["enter"])),placeholder:"请输入默认值"},null,8,["value"])],2112))])),_:1}),s(o(j),{path:"elem_width",label:"宽度"},{default:r((()=>[s(o(z),{value:ze.value.elem_width,"onUpdate:value":a[18]||(a[18]=e=>ze.value.elem_width=e),placeholder:"请选择宽度",options:He},null,8,["value"])])),_:1}),s(o(j),{path:"isNull",label:"是否必填","label-placement":"left"},{default:r((()=>[s(o(D),{value:Le.value,"onUpdate:value":[a[19]||(a[19]=e=>Le.value=e),a[20]||(a[20]=e=>el("isNull",e))]},null,8,["value"])])),_:1}),o(E)(o(Ee))?(n(),i(o(j),{key:3,"label-placement":"left",path:"isMultiSelect",label:"是否多选"},{default:r((()=>[s(o(D),{value:Ve.value,"onUpdate:value":a[21]||(a[21]=e=>el("isMultiSelect",e))},null,8,["value"])])),_:1})):c("v-if",!0)])),_:1},8,["model"]),s(Z,{visible:Pe.value,options:Te.value,onHandleSaveBatch:nl,onTriggerBatch:We},null,8,["visible","options"])])),_:1},8,["style","title"])])),_:1},8,["class","show","width","bodyStyle"]))}});export{ge as default};
@@ -1 +1 @@
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"../useEvent.js";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";import"naive-ui";import"@vueuse/core";function x(x,b,j,C,P){const{computedX:S,cumputedY:E,getXValue:G,getYValue:M}=c(b),{getEqualXTypes:T,handleAddPrevent:Y,isGridLimit:L,setPrevAndNextPoint:X}=h(x,j,b),{xAxis:A,grid:I,originX:H,originY:W,xCellWidth:N,endY:O,startTime:V,leftAddAreaWidth:D,leftScales:R,rightScales:$,yCellHeight:B,endX:F,scaleValues:q,canvasWidth:z,borderStyle:J,rightAddAreaWidth:K,event:Q,originYCervix:U,other:Z,canvasHeight:_}=b,ee=k(q),te=new Set;function oe(){ee.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=se(P,e);if(s&&S&&!d.breakpoint)h=t([...s,...S],{...v});else if(s&&!S&&!d.breakpoint){const o=se(P,e);h=o?t([...s,...o],{...v}):null}let E,T;if(d.childbirth){const e=s[1]+B;E=o([s[0],s[1],e],w),c.push(E),T=n([s[0]+N/2,e-B/2],{value:String(d.childbirth),...i,originX:"left",originY:"center",...w}),c.push(T)}const Y=u[f-1],L={origin:{data:d,title:m,key:y||"",dataIndex:l,index:f},leftLine:Y,rightLine:h,arrowGroup:E,arrowGroupText:T,...g,...b.event.hovered?b.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:b.event};Y?p=r(k,{left:Y.get("x2"),top:Y.get("y2"),...L}):s&&(L.leftLine=null,p=r(k,{left:s[0],top:s[1],...L}));u.push(h),p&&(!function(e){Q.hovered&&(e.on("mouseover",(()=>{le(e,"hover")})),e.on("mouseout",(()=>{C.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{re(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+N/2,top:e.top+B/2})}(e),Q.hovered&&le(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:G(e.left),value:M(t,e.top)}};x.value.discardActiveObject(),j("change",o),ne(o,"change")}}))}(p),a.push(p),te.add(p))}(se(s,e),s,d)})),Promise.all(a).then((e=>{const t=u.filter((e=>e));X(e),Promise.all(c).then((o=>{x.value.add(...t,...e,...o),e.forEach((e=>{null==e||e.bringToFront()}))}))}))}))}function ne(e,t="add"){const{dataIndex:o,data:n,index:i,key:r}=e,l=ee.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}}ie()}function ie(){var e;te.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}([...te]))),te.clear(),oe()}function re(e){const t=e.prevPoint?e.prevPoint.left:H,o=e.nextPoint?e.nextPoint.left:F;e.setCoords(),["cervix","fetalPresentation"].includes(e.origin.key)&&e.top<U&&e.set("top",U),e.top<W&&e.set("top",W),e.top>O&&e.set("top",O),e.left<t&&e.set("left",t),e.left>o&&e.set("left",o)}function le(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:M(n,e.top)}`,`时间 ${G(e.left).slice(-5)}`],C.show=!0}function se(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=E(t.key,t.range,e.value);return[o,n<W?W:n>O?O:n]}}function ae(e,t){return e+1>t[1]?t[0]:e+1}return u(x,b),function(){const t=new e.Rect({...J,width:z-D-K-1,height:O-1,left:D,top:0,fill:"transparent"});x.value.add(t)}(),function(){function t(t,o="left"){let r="left"===o?D:F;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),E=S.length;S.forEach(((e,o)=>{const{lineXMain:n,lineXSub:i,textLeft:l}=d(m,r,c),s=O-o*B*k,a=0===o?O-8:o!==S.length-1||W||U&&"FHR"!==v?s:W+8;!w||(0===o||o===E-1)&&!b||j.push(f(String(e),t,l,a)),C.push(...p(t,o,n,i,s,B,W,E))}));const G=new e.Rect({...a,strokeWidth:.5,width:c,height:O,left:P,top:O/2}),M=n([P,W>0?W-B/2:B/2],{value:String(h),...i,...g}),T=new e.Group([...C,...j,G,...M?[M]:[]],{objectCaching:!1,...s});x.value.add(T),T.sendToBack(),r+=c}))}t(R),t($,"right")}(),function(){const{show:t,startTime:o,range:r=[0,23],position:l="top",style:a}=A.time,{show:u,range:c=[0,23],position:d,style:f}=A.processTime;if(t||u){const p=[],h=[],g=[],v=[],m=H+N/2,y=B/2;for(let e=0;e<I.mainXCell;e++){if(t){const t=0===e?+o.slice(11,13):ae(p.at(-1),r);p.push(t);const s="top"===l?W-y:O+y;g.push(n([m+e*N,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:_-y;v.push(n([m+e*N,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(Z),n=[],i={},r=ee.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=E(o,n,10),l=[0,t],s=[-t/e,0],a=[(O-i-t)/e,O-i],u=[F-H,e*(F-H)+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>=H&&o<=F&&n>=i&&n<=O}function h([e,t]){return[H+e,O-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}=ee.find((e=>e.key===o));if(r){const r=E(o,i,0);n.push(t([H,r,F,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)-H,O-E(o,a,l.value)],[p,h]=[S(c.time)-H,O-E(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)}(),oe(),function(){function e(e,t){const o=ee.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>=H&&o<=F&&n>=W&&n<=O&&(P.point={x:o,y:n},P.show=!0,t.target?(P.target=t.target,P.list=["删除节点"],[...te].forEach((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=["新增节点"],ee.filter((e=>e.show)).forEach((i=>{if(!T([...te],o,"key").includes(i.key)){if(["cervix","fetalPresentation"].includes(i.key)&&n<U)return;P.list.push(e(i,t.pointer))}})),1===P.list.length&&(P.show=!1,Y("repeat"),console.log("当前时间段内无可新增节点"))))}}))}(),function(){const e=z-K/2;function t(e,t){if(!e.length)return;let n=W;const i=[];e.forEach((e=>{const o=e.title.split("").join("\n"),r=q.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)?(re(u),le(u)):C.show=!1})),u.on("mouseup:before",(e=>{if(C.show=!1,0===e.e.button&&L(u))if(T([...te],u.left,"key").includes(u.origin.key))Y("repeat");else{const e={data:{time:G(u.left),value:M(u.origin.key,u.top)},...u.origin};j("add",e),ne(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=(O-W)/2,n=(t.height+t.top-W)/2;e.forEach((e=>{const t=e.top+o-n;e.set({top:t,originTop:t})}))}t(R,D/2),t($,e)}(),{clickMenu:function({item:e,target:t}){const o={...e.origin};"remove"===e.mode?(j("remove",o),ne(o,"remove")):(Object.assign(o,{data:{time:G(e.pointer.x),value:M(e.origin.key,e.pointer.y)}}),j("add",o),ne(o))},redrawPoints:ie}}export{x 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"../useEvent.js";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";import"naive-ui";import"@vueuse/core";function x(x,b,j,C,P){const{computedX:S,computedY:E,getXValue:G,getYValue:M}=c(b),{getEqualXTypes:T,handleAddPrevent:Y,isGridLimit:L,setPrevAndNextPoint:X}=h(x,j,b),{xAxis:A,grid:I,originX:H,originY:W,xCellWidth:N,endY:O,startTime:V,leftAddAreaWidth:D,leftScales:R,rightScales:$,yCellHeight:B,endX:F,scaleValues:q,canvasWidth:z,borderStyle:J,rightAddAreaWidth:K,event:Q,originYCervix:U,other:Z,canvasHeight:_}=b,ee=k(q),te=new Set;function oe(){ee.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=se(P,e);if(s&&S&&!d.breakpoint)h=t([...s,...S],{...v});else if(s&&!S&&!d.breakpoint){const o=se(P,e);h=o?t([...s,...o],{...v}):null}let E,T;if(d.childbirth){const e=s[1]+B;E=o([s[0],s[1],e],w),c.push(E),T=n([s[0]+N/2,e-B/2],{value:String(d.childbirth),...i,originX:"left",originY:"center",...w}),c.push(T)}const Y=u[f-1],L={origin:{data:d,title:m,key:y||"",dataIndex:l,index:f},leftLine:Y,rightLine:h,arrowGroup:E,arrowGroupText:T,...g,...b.event.hovered?b.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:b.event};Y?p=r(k,{left:Y.get("x2"),top:Y.get("y2"),...L}):s&&(L.leftLine=null,p=r(k,{left:s[0],top:s[1],...L}));u.push(h),p&&(!function(e){Q.hovered&&(e.on("mouseover",(()=>{le(e,"hover")})),e.on("mouseout",(()=>{C.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{re(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+N/2,top:e.top+B/2})}(e),Q.hovered&&le(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:G(e.left),value:M(t,e.top)}};x.value.discardActiveObject(),j("change",o),ne(o,"change")}}))}(p),a.push(p),te.add(p))}(se(s,e),s,d)})),Promise.all(a).then((e=>{const t=u.filter((e=>e));X(e),Promise.all(c).then((o=>{x.value.add(...t,...e,...o),e.forEach((e=>{null==e||e.bringToFront()}))}))}))}))}function ne(e,t="add"){const{dataIndex:o,data:n,index:i,key:r}=e,l=ee.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}}ie()}function ie(){var e;te.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}([...te]))),te.clear(),oe()}function re(e){const t=e.prevPoint?e.prevPoint.left:H,o=e.nextPoint?e.nextPoint.left:F;e.setCoords(),["cervix","fetalPresentation"].includes(e.origin.key)&&e.top<U&&e.set("top",U),e.top<W&&e.set("top",W),e.top>O&&e.set("top",O),e.left<t&&e.set("left",t),e.left>o&&e.set("left",o)}function le(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:M(n,e.top)}`,`时间 ${G(e.left).slice(-5)}`],C.show=!0}function se(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=E(t.key,t.range,e.value);return[o,n<W?W:n>O?O:n]}}function ae(e,t){return e+1>t[1]?t[0]:e+1}return u(x,b),function(){const t=new e.Rect({...J,width:z-D-K-1,height:O-1,left:D,top:0,fill:"transparent"});x.value.add(t)}(),function(){function t(t,o="left"){let r="left"===o?D:F;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),E=S.length;S.forEach(((e,o)=>{const{lineXMain:n,lineXSub:i,textLeft:l}=d(m,r,c),s=O-o*B*k,a=0===o?O-8:o!==S.length-1||W||U&&"FHR"!==v?s:W+8;!w||(0===o||o===E-1)&&!b||j.push(f(String(e),t,l,a)),C.push(...p(t,o,n,i,s,B,W,E))}));const G=new e.Rect({...a,strokeWidth:.5,width:c,height:O,left:P,top:O/2}),M=n([P,W>0?W-B/2:B/2],{value:String(h),...i,...g}),T=new e.Group([...C,...j,G,...M?[M]:[]],{objectCaching:!1,...s});x.value.add(T),T.sendToBack(),r+=c}))}t(R),t($,"right")}(),function(){const{show:t,startTime:o,range:r=[0,23],position:l="top",style:a}=A.time,{show:u,range:c=[0,23],position:d,style:f}=A.processTime;if(t||u){const p=[],h=[],g=[],v=[],m=H+N/2,y=B/2;for(let e=0;e<I.mainXCell;e++){if(t){const t=0===e?+o.slice(11,13):ae(p.at(-1),r);p.push(t);const s="top"===l?W-y:O+y;g.push(n([m+e*N,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:_-y;v.push(n([m+e*N,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(Z),n=[],i={},r=ee.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=E(o,n,10),l=[0,t],s=[-t/e,0],a=[(O-i-t)/e,O-i],u=[F-H,e*(F-H)+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>=H&&o<=F&&n>=i&&n<=O}function h([e,t]){return[H+e,O-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}=ee.find((e=>e.key===o));if(r){const r=E(o,i,0);n.push(t([H,r,F,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)-H,O-E(o,a,l.value)],[p,h]=[S(c.time)-H,O-E(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)}(),oe(),function(){function e(e,t){const o=ee.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>=H&&o<=F&&n>=W&&n<=O&&(P.point={x:o,y:n},P.show=!0,t.target?(P.target=t.target,P.list=["删除节点"],[...te].forEach((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=["新增节点"],ee.filter((e=>e.show)).forEach((i=>{if(!T([...te],o,"key").includes(i.key)){if(["cervix","fetalPresentation"].includes(i.key)&&n<U)return;P.list.push(e(i,t.pointer))}})),1===P.list.length&&(P.show=!1,Y("repeat"),console.log("当前时间段内无可新增节点"))))}}))}(),function(){const e=z-K/2;function t(e,t){if(!e.length)return;let n=W;const i=[];e.forEach((e=>{const o=e.title.split("").join("\n"),r=q.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)?(re(u),le(u)):C.show=!1})),u.on("mouseup:before",(e=>{if(C.show=!1,0===e.e.button&&L(u))if(T([...te],u.left,"key").includes(u.origin.key))Y("repeat");else{const e={data:{time:G(u.left),value:M(u.origin.key,u.top)},...u.origin};j("add",e),ne(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=(O-W)/2,n=(t.height+t.top-W)/2;e.forEach((e=>{const t=e.top+o-n;e.set({top:t,originTop:t})}))}t(R,D/2),t($,e)}(),{clickMenu:function({item:e,target:t}){const o={...e.origin};"remove"===e.mode?(j("remove",o),ne(o,"remove")):(Object.assign(o,{data:{time:G(e.pointer.x),value:M(e.origin.key,e.pointer.y)}}),j("add",o),ne(o))},redrawPoints:ie}}export{x as useBirthProcess};
@@ -1 +1 @@
1
- import{fabric as e}from"../../../../../../shared/utils/fabricjs/index.js";import{range as t}from"lodash-es";import{defaultStyle as n}from"../../useDraw.js";import{useElectrocardiogramCumputedPoint as o}from"../../useCumputedPoint.js";import"../../useEvent.js";import"vue";import"date-fns";import"../../temperature/useShadow.js";import"naive-ui";import"@vueuse/core";function r(r,i){const{scale:l,beforeEvent:a,endY:s,endX:u,showScaleText:c,showNumberText:y,detailRadius:f,points:p,lineStartIndex:h,xCellWidth:d,yCellHeight:m,grid:x={subLineStyle:{},mainLineStyle:{x:{},y:{}}}}=i;let w=null;const{computedX:g,cumputedY:v,getYValue:b}=o(i);function S(e){return g(e)*l}function L(e){return v(e)*l}function k(e){return b(e/l)}const M=m*l;function j(){var e;w&&(null==(e=r.canvas)||e.remove(w)),w=null}r.on("mousedown",(async o=>{var i,d;if(await(null==a?void 0:a()),1!==o.button||!o.target||!o.pointer)return;const m=o.target;if(!m.points)return;const{x:g,y:v}=o.pointer,b=Math.floor((g-m.left)/m.width*m.points.length)+h;let G=b-f,T=b+f;G<=0?(G=0,T=Math.min(2*f,p.length-1)):T>=p.length-1&&(T=p.length-1,G=Math.max(p.length-2*f,0));const C=p.slice(G,T).map(((e,t)=>({x:G+S(t),y:L(e)}))),W=b-G;let Y=0,$=0;C.forEach(((e,t)=>{e.y>C[Y].y&&(Y=t),e.y<C[$].y&&($=t)}));const E=S(2*f-1),X=C[Y].y-C[$].y-1,z=X+30+70,A={x:u-g<=E?g-E:g,y:s-v<=z?v-z:v};j(),w=new e.Group;const D=[new e.Rect({...n,left:A.x,top:A.y,width:E,height:z,stroke:"transparent",fill:"#fff",shadow:new e.Shadow({color:"rgba(0, 0, 0, 0.3)",blur:15,offsetX:8,offsetY:8})}),function(n,o){const r=e=>e%5?x.subLineStyle:null,i=M/5,l=30+n[Y].y/Math.abs(n[Y].y-n[$].y)*X,a=Math.ceil(l/i),s=Math.ceil((z-l)/i);function u(t,n){return new e.Line([A.x,A.y+t,A.x+E,A.y+t],{...x.mainLineStyle.x,...r(n)})}const c=new e.Group([...t(s).map((e=>u(e*i+l,e))),...t(a).map((e=>u(-e*i+l,e)))]),y=o/n.length*E,f=Math.ceil(y/i),p=Math.ceil((E-y)/i);function h(t,n){return new e.Line([A.x+t,A.y,A.x+t,A.y+z],{...x.mainLineStyle.y,...0===n?x.subLineStyle:r(n)})}const d=new e.Group([...t(p).map((e=>h(e*i+y,e))),...t(f).map((e=>h(-e*i+y,e)))]);return new e.Group([d,c])}(C,W),(H=C.map((({x:e,y:t})=>({x:e,y:-t}))),new e.Polyline(H,{...n,fill:"transparent",stroke:"red",strokeWidth:1,left:A.x,top:A.y+30})),function(t,o){const r={strokeDashArray:[3,4],width:3,top:A.y},i=new e.Line(s(t[Y]),{...n,...r,left:A.x+Y/t.length*E,stroke:"red"}),l=new e.Line(s(t[$]),{...n,...r,stroke:"blue",left:A.x+$/t.length*E}),a=new e.Line(s(t[o]),{...n,...r,stroke:"green",left:A.x+o/t.length*E});return new e.Group([i,l,a]);function s(e){return[e.x,e.y,e.x,e.y-z]}}(C,W),(P=C,R=W,new e.Circle({...n,radius:5,fill:"transparent",stroke:"green",strokeWidth:1,left:A.x+R/P.length*E-5,top:A.y+30+(P[Y].y-P[R].y)/Math.abs(P[Y].y-P[$].y)*X-5}))];var P,R,H;c&&D.push(new e.Text(`x${l}`,{...n,fill:"black",fontSize:20,left:A.x+10,top:A.y+z-30})),y&&D.push(function(t,o){const r={fontSize:16,left:A.x+E/2+10},i=new e.Text(`最大: ${k(t[Y].y)} mv`,{...n,...r,fill:"red",top:A.y+z-20}),l=new e.Text(`最小: ${k(t[$].y)} mv`,{...n,...r,fill:"blue",top:A.y+z-40}),a=new e.Text(`当前: ${k(t[o].y)} mv`,{...n,...r,fill:"green",top:A.y+z-60});return new e.Group([i,l,a])}(C,W)),w.add(...D).addWithUpdate(),null==(i=r.canvas)||i.add(w),null==(d=r.canvas)||d.discardActiveObject()})),r.on("mouseup",(async e=>{await(null==a?void 0:a()),1===e.button&&j()}))}export{r as useDetailEvent};
1
+ import{fabric as e}from"../../../../../../shared/utils/fabricjs/index.js";import{range as t}from"lodash-es";import{defaultStyle as n}from"../../useDraw.js";import{useElectrocardiogramCumputedPoint as o}from"../../useCumputedPoint.js";import"../../useEvent.js";import"vue";import"date-fns";import"../../temperature/useShadow.js";import"naive-ui";import"@vueuse/core";function r(r,i){const{scale:l,beforeEvent:a,endY:s,endX:u,showScaleText:c,showNumberText:y,detailRadius:f,points:p,lineStartIndex:h,xCellWidth:d,yCellHeight:m,grid:x={subLineStyle:{},mainLineStyle:{x:{},y:{}}}}=i;let w=null;const{computedX:g,computedY:v,getYValue:b}=o(i);function S(e){return g(e)*l}function L(e){return v(e)*l}function k(e){return b(e/l)}const M=m*l;function j(){var e;w&&(null==(e=r.canvas)||e.remove(w)),w=null}r.on("mousedown",(async o=>{var i,d;if(await(null==a?void 0:a()),1!==o.button||!o.target||!o.pointer)return;const m=o.target;if(!m.points)return;const{x:g,y:v}=o.pointer,b=Math.floor((g-m.left)/m.width*m.points.length)+h;let G=b-f,T=b+f;G<=0?(G=0,T=Math.min(2*f,p.length-1)):T>=p.length-1&&(T=p.length-1,G=Math.max(p.length-2*f,0));const C=p.slice(G,T).map(((e,t)=>({x:G+S(t),y:L(e)}))),W=b-G;let Y=0,$=0;C.forEach(((e,t)=>{e.y>C[Y].y&&(Y=t),e.y<C[$].y&&($=t)}));const E=S(2*f-1),X=C[Y].y-C[$].y-1,z=X+30+70,A={x:u-g<=E?g-E:g,y:s-v<=z?v-z:v};j(),w=new e.Group;const D=[new e.Rect({...n,left:A.x,top:A.y,width:E,height:z,stroke:"transparent",fill:"#fff",shadow:new e.Shadow({color:"rgba(0, 0, 0, 0.3)",blur:15,offsetX:8,offsetY:8})}),function(n,o){const r=e=>e%5?x.subLineStyle:null,i=M/5,l=30+n[Y].y/Math.abs(n[Y].y-n[$].y)*X,a=Math.ceil(l/i),s=Math.ceil((z-l)/i);function u(t,n){return new e.Line([A.x,A.y+t,A.x+E,A.y+t],{...x.mainLineStyle.x,...r(n)})}const c=new e.Group([...t(s).map((e=>u(e*i+l,e))),...t(a).map((e=>u(-e*i+l,e)))]),y=o/n.length*E,f=Math.ceil(y/i),p=Math.ceil((E-y)/i);function h(t,n){return new e.Line([A.x+t,A.y,A.x+t,A.y+z],{...x.mainLineStyle.y,...0===n?x.subLineStyle:r(n)})}const d=new e.Group([...t(p).map((e=>h(e*i+y,e))),...t(f).map((e=>h(-e*i+y,e)))]);return new e.Group([d,c])}(C,W),(H=C.map((({x:e,y:t})=>({x:e,y:-t}))),new e.Polyline(H,{...n,fill:"transparent",stroke:"red",strokeWidth:1,left:A.x,top:A.y+30})),function(t,o){const r={strokeDashArray:[3,4],width:3,top:A.y},i=new e.Line(s(t[Y]),{...n,...r,left:A.x+Y/t.length*E,stroke:"red"}),l=new e.Line(s(t[$]),{...n,...r,stroke:"blue",left:A.x+$/t.length*E}),a=new e.Line(s(t[o]),{...n,...r,stroke:"green",left:A.x+o/t.length*E});return new e.Group([i,l,a]);function s(e){return[e.x,e.y,e.x,e.y-z]}}(C,W),(P=C,R=W,new e.Circle({...n,radius:5,fill:"transparent",stroke:"green",strokeWidth:1,left:A.x+R/P.length*E-5,top:A.y+30+(P[Y].y-P[R].y)/Math.abs(P[Y].y-P[$].y)*X-5}))];var P,R,H;c&&D.push(new e.Text(`x${l}`,{...n,fill:"black",fontSize:20,left:A.x+10,top:A.y+z-30})),y&&D.push(function(t,o){const r={fontSize:16,left:A.x+E/2+10},i=new e.Text(`最大: ${k(t[Y].y)} mv`,{...n,...r,fill:"red",top:A.y+z-20}),l=new e.Text(`最小: ${k(t[$].y)} mv`,{...n,...r,fill:"blue",top:A.y+z-40}),a=new e.Text(`当前: ${k(t[o].y)} mv`,{...n,...r,fill:"green",top:A.y+z-60});return new e.Group([i,l,a])}(C,W)),w.add(...D).addWithUpdate(),null==(i=r.canvas)||i.add(w),null==(d=r.canvas)||d.discardActiveObject()})),r.on("mouseup",(async e=>{await(null==a?void 0:a()),1===e.button&&j()}))}export{r as useDetailEvent};
@@ -1 +1 @@
1
- import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useThrottleFn as t}from"@vueuse/core";import{range as r}from"lodash-es";import{useDetailEvent as o}from"./hooks/useDetailEvent.js";import{defaultTextStyle as n,drawLine as i}from"../useDraw.js";import{useGrid as s}from"../useGrid.js";import{useElectrocardiogramCumputedPoint as a}from"../useCumputedPoint.js";import"../useEvent.js";import"vue";import"date-fns";import"../temperature/useShadow.js";import{SMALLCELLNUMBER as l}from"../../constants/index.js";import"naive-ui";function u(u,d,c){const{computedX:m,cumputedY:h}=a(d),{borderStyle:f,originX:p,originY:g,xCellWidth:v,yCellHeight:x,canvasWidth:b,canvasHeight:j,dataList:w,columnNumber:C,gridYNumber:k,gridXNumber:y}=d,S=new Set,E=new Set;function N(t=0){w.forEach(((r,o)=>{if(o===w.length-1&&arguments.length)return;const{x:i,y:s}=r.origin,a=~~(r.data.length/C),l=r.data.reduce(((e,r,n)=>{const i=o<12&&n>=t&&n<=t+a||12===o?[{x:m(e.length+1),y:h(-+r)}]:[];return e.concat(i)}),[]),u=new e.Polyline(l,{fill:"transparent",stroke:"red",strokeWidth:1,left:i,top:s,hasControls:!1,hasBorders:!1,hoverCursor:"default",lockMovementX:!0,lockMovementY:!0,objectCaching:!0});if(X(u,{...d.config,...d,lineStartIndex:t,points:r.data,scale:4,showScaleText:!0,showNumberText:!0,detailRadius:370,beforeEvent:()=>c.value&&Promise.reject()}),u.startIdx=t,o<w.length-1?S.add(u):E.add(u),arguments.length)return;const f=new e.Text(String(r.title),{...n,left:i+v,top:s});E.add(f)}));const r=arguments.length?[...S]:[...S,...E];u.value.add(...r)}function X(e,t){o(e,t)}s(u,{...d,gridXNumber:y*l,gridYNumber:k*l,xCellWidth:v/l,yCellHeight:x/l,grid:{...d.grid,subXCell:l,subYCell:l}}),function(){const{strokeWidth:t}=f,r=new e.Rect({...f,width:b-t,height:j-t,left:p,top:g,fill:"transparent"});u.value.add(r)}(),function(){const e=b/C,t=[];r(C).forEach((r=>{if(r+1>=C)return;const o=(r+1)*e,n=i([o,0,o,j],{stroke:"#000"});t.push(n)})),u.value.add(...t)}(),N();return{updatePolyline:t((t=>{if(1===C)return;const r=w[w.length-1].data.length,o=~~(r/C),n=t/100*r-o/2,i=n+o>r?r-o:Math.max(0,n);e.util.requestAnimFrame((()=>{if(S.size){const[e]=[...S];if(e.startIdx===i)return;[...S].forEach((e=>u.value.remove(e))),S.clear()}N(i)}))}),150)}}export{u as useElectrocardiogram};
1
+ import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useThrottleFn as t}from"@vueuse/core";import{range as r}from"lodash-es";import{useDetailEvent as o}from"./hooks/useDetailEvent.js";import{defaultTextStyle as n,drawLine as i}from"../useDraw.js";import{useGrid as s}from"../useGrid.js";import{useElectrocardiogramCumputedPoint as a}from"../useCumputedPoint.js";import"../useEvent.js";import"vue";import"date-fns";import"../temperature/useShadow.js";import{SMALLCELLNUMBER as l}from"../../constants/index.js";import"naive-ui";function d(d,u,c){const{computedX:m,computedY:h}=a(u),{borderStyle:f,originX:p,originY:g,xCellWidth:v,yCellHeight:x,canvasWidth:b,canvasHeight:j,dataList:w,columnNumber:C,gridYNumber:k,gridXNumber:y}=u,S=new Set,E=new Set;function N(t=0){w.forEach(((r,o)=>{if(o===w.length-1&&arguments.length)return;const{x:i,y:s}=r.origin,a=~~(r.data.length/C),l=r.data.reduce(((e,r,n)=>{const i=o<12&&n>=t&&n<=t+a||12===o?[{x:m(e.length+1),y:h(-+r)}]:[];return e.concat(i)}),[]),d=new e.Polyline(l,{fill:"transparent",stroke:"red",strokeWidth:1,left:i,top:s,hasControls:!1,hasBorders:!1,hoverCursor:"default",lockMovementX:!0,lockMovementY:!0,objectCaching:!0});if(X(d,{...u.config,...u,lineStartIndex:t,points:r.data,scale:4,showScaleText:!0,showNumberText:!0,detailRadius:370,beforeEvent:()=>c.value&&Promise.reject()}),d.startIdx=t,o<w.length-1?S.add(d):E.add(d),arguments.length)return;const f=new e.Text(String(r.title),{...n,left:i+v,top:s});E.add(f)}));const r=arguments.length?[...S]:[...S,...E];d.value.add(...r)}function X(e,t){o(e,t)}s(d,{...u,gridXNumber:y*l,gridYNumber:k*l,xCellWidth:v/l,yCellHeight:x/l,grid:{...u.grid,subXCell:l,subYCell:l}}),function(){const{strokeWidth:t}=f,r=new e.Rect({...f,width:b-t,height:j-t,left:p,top:g,fill:"transparent"});d.value.add(r)}(),function(){const e=b/C,t=[];r(C).forEach((r=>{if(r+1>=C)return;const o=(r+1)*e,n=i([o,0,o,j],{stroke:"#000"});t.push(n)})),d.value.add(...t)}(),N();return{updatePolyline:t((t=>{if(1===C)return;const r=w[w.length-1].data.length,o=~~(r/C),n=t/100*r-o/2,i=n+o>r?r-o:Math.max(0,n);e.util.requestAnimFrame((()=>{if(S.size){const[e]=[...S];if(e.startIdx===i)return;[...S].forEach((e=>d.value.remove(e))),S.clear()}N(i)}))}),150)}}export{d as useElectrocardiogram};
@@ -1 +1 @@
1
- import{onUnmounted as e}from"vue";import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{defaultStyle as n,drawLine as i,drawPoint as o}from"../useDraw.js";import{useGrid as l}from"../useGrid.js";import{useBirthProcessCumputedPoint as r}from"../useCumputedPoint.js";import{bus as a}from"../useEvent.js";import{useCommon as s}from"../useCommon.js";import{getPointRange as f,getIndex as c,isEffectiveNode as u,getTime as d}from"../../utils/index.js";import{cloneDeep as p,omit as m}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";import"naive-ui";import{useIntervalFn as v}from"@vueuse/core";function g(g,y,h,k,x){const{computedX:L,cumputedY:P,getXValue:b,getYValue:w}=r(y),{xCellWidth:A,pointSelectionStyle:I,originX:C,endX:K,originY:j,endY:E,event:X,scaleValues:M,xAxis:T,startTime:V,timeXCell:Y,itemList:S,dialog:$}=y,F=new Map,O=new Set,D=p(M);let _=[],z=null;const N=new Set;l(g,y);const{getEqualXTypes:G,handleAddPrevent:J,setPrevAndNextPoint:q}=s(g,h,y),{pause:R,resume:W}=v((()=>{!function(){if(!N.size)return;for(const e of N)e.set("opacity",1===e.opacity?.5:1);g.value.renderAll()}()}),800);function B(){D.forEach((e=>{e.dataList.forEach(((t,n)=>{t.show&&(!function(e,t){const{max:n={},min:o={}}=e.panicValue||{},{max:l={},min:r={}}=e.diffValue||{};function a({show:e=!1,value:n,name:o,lineStyle:l}){if(!e||!n)return;const r=P(t.type,t.range,n),a=i([C,r,K,r],{...l,evented:!0,lockMovementX:!0,lockMovementY:!0,hoverCursor:"pointer"});X.hovered&&o&&(a.on("mousemove",(({pointer:e})=>{k.point={...e||{x:a.left,y:a.top}},k.list=[`${o} ${n}${t.unit||""}`],k.show=!0})),a.on("mouseout",(()=>{k.show=!1}))),g.value.add(a)}a(n),a(o),a(l),a(r)}(t,e),Z(t,n,e))}))}))}function H(e=[]){if(!(null==z?void 0:z.areaPos))return[];const{startPos:t,endPos:n}=z.areaPos,[i,o]=[t.x,n.x].sort(((e,t)=>e-t)),[l,r]=[t.y,n.y].sort(((e,t)=>e-t));return(e.length?e:se()).filter((e=>e.left>=i&&e.left<=o&&e.top>=l&&e.top<=r))}function Q(e){$.warning({maskClosable:!1,closeOnEsc:!1,title:"警告",content:"确认删除当前选中的节点?",positiveText:"确定",negativeText:"取消",onPositiveClick:()=>{e(),U()},onNegativeClick:()=>U(),onClose:()=>U()})}function U(){z&&g.value.remove(z),z=null}function Z(e,t,n){var l;const{type:r,unit:a,dataList:s=[]}=n,f=[];F.set(e.key,[]),function(e,t){N.size&&[...N].forEach((n=>{const{dataIndex:i,type:o}=n.origin;i===t&&o===e&&N.delete(n)}))}(r,t),null==(l=e.list)||l.forEach(((l,c)=>{!function(e,l,c,u){var d;let p,v,x=u;l.key&&(x=s.find((e=>e.key===l.key)));const{pointAttr:L={},lineAttr:P={},title:I="",key:C,type:K="circle"}=x,j=ae(u.list[c+1],n);e&&j&&!l.breakpoint&&e[0]!==j[0]&&(v=i([...e,...j],P));const E=f[c-1],M={origin:{data:l,title:I,key:u.key,selfKey:C,unit:a,type:r,dataIndex:t,index:c,lineAttr:P},__type:"main",leftLine:E,rightLine:v,...L,...y.event.hovered?y.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:y.event};E?p=o(K,{left:E.get("x2"),top:E.get("y2"),...M}):e&&(M.leftLine=null,p=o(K,{left:e[0],top:e[1],...M}));f.push(v),p&&(p.originLeft=p.left,p.originTop=p.top,function(e){X.hovered&&(e.on("mouseover",(()=>{le(e,"hover")})),e.on("mouseout",(()=>{k.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{re(e),function(e){var t,n;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(n=e.rightLine)||n.setCoords().set({x1:e.left,y1:e.top})}(e),X.hovered&&le(e),function(e){var t,n,i,o;const{originLeft:l,originTop:r,left:a,top:s,origin:f}=e,c=~~((a-l)/A);if(a>l+A){if(0===_.length){te(e,[...e.leftLine?[e.leftLine.x1,e.leftLine.y1]:[l,r],l,r]),null==(n=null==(t=e.leftLine)?void 0:t.set)||n.call(t,"stroke","transparent"),null==(o=null==(i=e.rightLine)?void 0:i.set)||o.call(i,"stroke","transparent")}const u=l+A*c;if(_.every((e=>e.left!==u))){const t=b(u),n=w(f.type,s);_.push({data:{time:t,value:n,...f.selfKey!==f.key?{key:f.selfKey}:{}},left:u,top:s}),te(e,[...e.prevPointer,u,s])}if(_.length<c&&function(e,t){const{originLeft:n,originTop:i,origin:o}=e;let l=1;for(;l<=t;){const t=n+A*l,r=_.some((e=>Math.abs(e.left-t)<=1));if(!r){let l=0;const r=_.find(((e,n)=>(e.left>t&&(l=n),e.left>t)));if(r){const a=JSON.parse(JSON.stringify(r)),s=_[l-1]||{left:n,top:i},f=~~((r.left-(t-A))/A),c=(r.top-s.top)/f;a.top=s.top+c,a.left=t,a.data={time:b(t),value:w(o.type,a.top),...o.selfKey!==o.key?{key:o.selfKey}:{}},_.splice(l,0,a),te(e,[s.left,s.top,a.left,a.top])}}l++}}(e,c),e.nextPoint){const t=F.get(f.key);!function(e,t){const{left:n,top:i,origin:o}=t,l=A/2,r=e.findIndex((e=>Math.abs(n-e.left)<l&&Math.abs(i-e.top)<l&&o.index!==e.origin.index));r>-1?(t.set({scaleX:2.5,scaleY:2.5}),t.coincidePoint=e[r]):t.set({scaleX:t.scale,scaleY:t.scale})}(t,e),null==t||t.forEach((e=>{e.left<=l||f.index===e.origin.index||(e.left<a?ee(e,"#999"):ee(e,e.origin.lineAttr.stroke))}))}}!function(e){var t,n;const{left:i}=e;if(_.length>0&&i<_[_.length-1].left){for(const e of O)e.left>i&&(e.leftLine&&g.value.remove(e.leftLine),g.value.remove(e));if(_=_.filter((e=>e.left<=i)),0===_.length){null==(n=null==(t=e.leftLine)?void 0:t.set)||n.call(t,e.origin.lineAttr);for(const e of O)e.leftLine&&g.value.remove(e.leftLine),g.value.remove(e)}if(_.length>0){const t=_.at(-1);e.prevPointer=[t.left,t.top]}}}(e)}(e)})),e.on("mouseup",(t=>{if(k.show=!1,1===t.button){const{type:t,selfKey:n,dataIndex:i}=e.origin,o={...e.origin,data:{...e.origin.data,time:b(e.left),value:w(t,e.top)}};if(g.value.discardActiveObject(),_.length>0){const l=D.find((e=>e.type===t));let r=-1;const a=_.map((e=>e.data));if(e.nextPoint){if(2.5!==e.scaleX)return void ie({dataIndex:i,scaleValue:l});const t=e.coincidePoint.origin,n=t.data;r=t.index;const o=a.findIndex((e=>e.time===n.time));o>-1?a[o].value=n.value:a.push({...a.at(-1),time:n.time,value:n.value})}const s=l.dataList.findIndex((e=>e.key===n));h("add",{...m(o,["index","selfKey","lineAttr"]),dataIndex:s,key:n,data:a}),ne({...o,data:a,coincideIndex:r})}else h("change",{...m(o,["selfKey","lineAttr"]),key:n}),ne(o,"change")}}))}(p),null==(d=F.get(u.key))||d.push(p))}(ae(l,n),l,c,e)})),Promise.all(F.get(e.key)).then((t=>{const n=f.filter((e=>e));q(t),g.value.add(...n,...t),function(e,t){const{max:n={},min:i={}}=t.panicValue||{},{max:o={},min:l={}}=t.diffValue||{};function r({show:t=!1,value:n,flickerable:i},o){!t&&n&&i&&e.forEach((e=>{const t=e.origin.data.value;"max"===o&&t<n||"min"===o&&t>n||N.add(e)}))}r(n,"max"),r(i,"min"),r(o,"max"),r(l,"min")}(t,e)}))}function ee(e,t){["stroke","fill"].forEach((n=>{const i=e[n];i&&!["transparent","#fff","#ffffff","#FFFFFF"].includes(i)&&i!==t&&e.set(n,t)})),e.rightLine&&e.rightLine.stroke!==t&&e.rightLine.set("stroke",t)}function te(e,t){const[,,n,o]=t;e.clone((l=>{l.set({left:n,top:o,scaleX:1,scaleY:1}),e.prevPointer=[n,o];const r=i(t,e.origin.lineAttr);l.leftLine=r,O.add(l),g.value.add(r,l)}))}function ne(e,t="add",n=1){const{data:i,index:o,key:l,type:r,coincideIndex:a}=e;let{dataIndex:s}=e;const f=D.find((e=>e.type===r)),u=f.dataList.find(((e,t)=>(s=t,e.key===l)));switch(t){case"remove":u.list.splice(o,n),u.list[o-1]&&(u.list[o-1].breakpoint=!0);break;case"change":u.list[o]=i;break;default:{const e=Array.isArray(i)?i[0].time:i.time,t=c(e,u.list),n=Array.isArray(i)?i:[i];u.list.splice(t,a>-1?a-t+1:0,...n);break}}ie({dataIndex:s,scaleValue:f})}function ie(e){var t,n,i;if(O.size&&(null==(t=g.value)||t.remove(...oe([...O]))),O.clear(),_=[],e){const{dataIndex:t,scaleValue:i}=e,o=i.dataList[t];null==(n=g.value)||n.remove(...oe(F.get(o.key))),F.delete(o.key),Z(o,t,i)}else F.size&&(null==(i=g.value)||i.remove(...oe(se()))),F.clear(),B()}function oe(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine)})),t}function le(e,t="moving"){const{title:n,type:i,data:o,unit:l}=e.origin;k.point={x:e.left,y:e.top};const r=`${"hover"===t?o.value:w(i,e.top)}`;k.list=[`${n} ${r}${l||""}`,`时间 ${b(e.left).slice(-5)}`],k.show=!0}function re(e){e.setCoords();const t=6e4/Y,n=e.prevPoint?e.prevPoint.left+t:C,i=K;e.top<j&&e.set("top",j),e.top>E&&e.set("top",E),e.left<n&&e.set("left",n),e.left>i&&e.set("left",i)}function ae(e,t){if(u(e)&&function(e){const t=Date.parse(T.list.at(-1)),n=d(e);return n>=V&&n<=t}(e.time)){const n=L(e.time),i=P(t.type,t.range,e.value);return[n,i<j?j:i>E?E:i]}}function se(){return Array.from(F.values()).flat()}return e((()=>{R()})),B(),function(){if(!X.evented)return;let e=!1,i={x:0,y:0};g.value.on("mouse:up",(t=>{if(3===t.button&&function(e){const{x:t=0,y:n=0}=e.pointer||{};if(t>=C&&t<=K&&n>=j&&n<=E)if(e.target){if("main"!==e.target.__type)return;i(e.pointer,e.target,["删除节点"]);const{minLeft:t,maxLeft:n,minTop:o,maxTop:l}=f(e.target);se().forEach((i=>{"main"===i.__type&&i.left>t&&i.left<n&&i.top>o&&i.top<l&&x.list.push({renderItem:()=>i.origin.title,origin:{...i.origin},mode:"remove",pointer:e.pointer})})),1===x.list.length&&(x.show=!1,console.log("当前时间段内无可删除节点"))}else i(e.pointer,null,["新增节点"]),S.forEach((n=>{G(se(),t,"key",2*A).includes(n.linkKey||n.key)||x.list.push({renderItem:()=>n.title,origin:{title:n.title,unit:n.unit,type:n.bigType,dataIndex:n.dataIndex,key:n.key,linkKey:n.linkKey},pointer:e.pointer})})),1===x.list.length&&(x.show=!1,J("repeat"),console.log("当前时间段内无可新增节点"));function i(e,t,n){Object.assign(x,{point:e,show:!0,target:t,list:n})}}(t),1===t.button&&e){e=!1;const t=H();t.length>0?Q((()=>{const e=function(e){const t=e.reduce(((e,t)=>{const{key:n}=t.origin;return e[n]=e[n]?e[n].concat(t.origin):[t.origin],e}),{});return Object.keys(t).map((e=>{const n=t[e].sort(((e,t)=>Date.parse(e.data.time)-Date.parse(t.data.time)));return ne(n[0],"remove",n.length),n.map((e=>({...m(e,["selfKey","lineAttr"]),key:e.selfKey})))}))}(t);h("remove",e)})):a.emit(z)}})),g.value.on("mouse:down",(t=>{1!==t.button||t.target||(e=!0,i=t.pointer)})),g.value.on("mouse:move",(o=>{if(!e)return;const{x:l,y:r}=i,{x:a,y:s}=o.pointer;z&&g.value.remove(z),z=new t.Rect({...n,fill:"#CAF982",opacity:.4,...I,left:l,top:r,width:a-l,height:s-r,objectCaching:!0}),z.areaPos={startPos:i,endPos:o.pointer},g.value.add(z)}))}(),{redrawPoints:ie,clickMenu:function({item:e,target:t}){const n={...e.origin};"remove"===e.mode?(h("remove",n),ne(n,"remove")):(Object.assign(n,{data:{time:b(e.pointer.x),value:w(e.origin.type,e.pointer.y),...e.origin.linkKey?{key:e.origin.key}:{}}}),h("add",n),ne({...n,key:e.origin.linkKey||e.origin.key}))},moveLimit:re,setPopup:le,updateData:ne,getGridPoints:se,getContainPoints:H,showDialog:Q,removeCurrentSelection:U}}export{g as useCenter};
1
+ import{onUnmounted as e}from"vue";import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{defaultStyle as n,drawLine as i,drawPoint as o}from"../useDraw.js";import{useGrid as l}from"../useGrid.js";import{useBirthProcessCumputedPoint as r}from"../useCumputedPoint.js";import{bus as a}from"../useEvent.js";import{useCommon as s}from"../useCommon.js";import{getPointRange as f,getIndex as c,isEffectiveNode as u,getTime as d}from"../../utils/index.js";import{cloneDeep as p,omit as m}from"lodash-es";import"date-fns";import"../temperature/useShadow.js";import"naive-ui";import{useIntervalFn as v}from"@vueuse/core";function g(g,y,h,k,x){const{computedX:L,computedY:P,getXValue:b,getYValue:w}=r(y),{xCellWidth:A,pointSelectionStyle:I,originX:C,endX:K,originY:j,endY:E,event:X,scaleValues:M,xAxis:T,startTime:V,timeXCell:Y,itemList:S,dialog:$}=y,F=new Map,O=new Set,D=p(M);let _=[],z=null;const N=new Set;l(g,y);const{getEqualXTypes:G,handleAddPrevent:J,setPrevAndNextPoint:q}=s(g,h,y),{pause:R,resume:W}=v((()=>{!function(){if(!N.size)return;for(const e of N)e.set("opacity",1===e.opacity?.5:1);g.value.renderAll()}()}),800);function B(){D.forEach((e=>{e.dataList.forEach(((t,n)=>{t.show&&(!function(e,t){const{max:n={},min:o={}}=e.panicValue||{},{max:l={},min:r={}}=e.diffValue||{};function a({show:e=!1,value:n,name:o,lineStyle:l}){if(!e||!n)return;const r=P(t.type,t.range,n),a=i([C,r,K,r],{...l,evented:!0,lockMovementX:!0,lockMovementY:!0,hoverCursor:"pointer"});X.hovered&&o&&(a.on("mousemove",(({pointer:e})=>{k.point={...e||{x:a.left,y:a.top}},k.list=[`${o} ${n}${t.unit||""}`],k.show=!0})),a.on("mouseout",(()=>{k.show=!1}))),g.value.add(a)}a(n),a(o),a(l),a(r)}(t,e),Z(t,n,e))}))}))}function H(e=[]){if(!(null==z?void 0:z.areaPos))return[];const{startPos:t,endPos:n}=z.areaPos,[i,o]=[t.x,n.x].sort(((e,t)=>e-t)),[l,r]=[t.y,n.y].sort(((e,t)=>e-t));return(e.length?e:se()).filter((e=>e.left>=i&&e.left<=o&&e.top>=l&&e.top<=r))}function Q(e){$.warning({maskClosable:!1,closeOnEsc:!1,title:"警告",content:"确认删除当前选中的节点?",positiveText:"确定",negativeText:"取消",onPositiveClick:()=>{e(),U()},onNegativeClick:()=>U(),onClose:()=>U()})}function U(){z&&g.value.remove(z),z=null}function Z(e,t,n){var l;const{type:r,unit:a,dataList:s=[]}=n,f=[];F.set(e.key,[]),function(e,t){N.size&&[...N].forEach((n=>{const{dataIndex:i,type:o}=n.origin;i===t&&o===e&&N.delete(n)}))}(r,t),null==(l=e.list)||l.forEach(((l,c)=>{!function(e,l,c,u){var d;let p,v,x=u;l.key&&(x=s.find((e=>e.key===l.key)));const{pointAttr:L={},lineAttr:P={},title:I="",key:C,type:K="circle"}=x,j=ae(u.list[c+1],n);e&&j&&!l.breakpoint&&e[0]!==j[0]&&(v=i([...e,...j],P));const E=f[c-1],M={origin:{data:l,title:I,key:u.key,selfKey:C,unit:a,type:r,dataIndex:t,index:c,lineAttr:P},__type:"main",leftLine:E,rightLine:v,...L,...y.event.hovered?y.event.evented?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:y.event};E?p=o(K,{left:E.get("x2"),top:E.get("y2"),...M}):e&&(M.leftLine=null,p=o(K,{left:e[0],top:e[1],...M}));f.push(v),p&&(p.originLeft=p.left,p.originTop=p.top,function(e){X.hovered&&(e.on("mouseover",(()=>{le(e,"hover")})),e.on("mouseout",(()=>{k.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{re(e),function(e){var t,n;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(n=e.rightLine)||n.setCoords().set({x1:e.left,y1:e.top})}(e),X.hovered&&le(e),function(e){var t,n,i,o;const{originLeft:l,originTop:r,left:a,top:s,origin:f}=e,c=~~((a-l)/A);if(a>l+A){if(0===_.length){te(e,[...e.leftLine?[e.leftLine.x1,e.leftLine.y1]:[l,r],l,r]),null==(n=null==(t=e.leftLine)?void 0:t.set)||n.call(t,"stroke","transparent"),null==(o=null==(i=e.rightLine)?void 0:i.set)||o.call(i,"stroke","transparent")}const u=l+A*c;if(_.every((e=>e.left!==u))){const t=b(u),n=w(f.type,s);_.push({data:{time:t,value:n,...f.selfKey!==f.key?{key:f.selfKey}:{}},left:u,top:s}),te(e,[...e.prevPointer,u,s])}if(_.length<c&&function(e,t){const{originLeft:n,originTop:i,origin:o}=e;let l=1;for(;l<=t;){const t=n+A*l,r=_.some((e=>Math.abs(e.left-t)<=1));if(!r){let l=0;const r=_.find(((e,n)=>(e.left>t&&(l=n),e.left>t)));if(r){const a=JSON.parse(JSON.stringify(r)),s=_[l-1]||{left:n,top:i},f=~~((r.left-(t-A))/A),c=(r.top-s.top)/f;a.top=s.top+c,a.left=t,a.data={time:b(t),value:w(o.type,a.top),...o.selfKey!==o.key?{key:o.selfKey}:{}},_.splice(l,0,a),te(e,[s.left,s.top,a.left,a.top])}}l++}}(e,c),e.nextPoint){const t=F.get(f.key);!function(e,t){const{left:n,top:i,origin:o}=t,l=A/2,r=e.findIndex((e=>Math.abs(n-e.left)<l&&Math.abs(i-e.top)<l&&o.index!==e.origin.index));r>-1?(t.set({scaleX:2.5,scaleY:2.5}),t.coincidePoint=e[r]):t.set({scaleX:t.scale,scaleY:t.scale})}(t,e),null==t||t.forEach((e=>{e.left<=l||f.index===e.origin.index||(e.left<a?ee(e,"#999"):ee(e,e.origin.lineAttr.stroke))}))}}!function(e){var t,n;const{left:i}=e;if(_.length>0&&i<_[_.length-1].left){for(const e of O)e.left>i&&(e.leftLine&&g.value.remove(e.leftLine),g.value.remove(e));if(_=_.filter((e=>e.left<=i)),0===_.length){null==(n=null==(t=e.leftLine)?void 0:t.set)||n.call(t,e.origin.lineAttr);for(const e of O)e.leftLine&&g.value.remove(e.leftLine),g.value.remove(e)}if(_.length>0){const t=_.at(-1);e.prevPointer=[t.left,t.top]}}}(e)}(e)})),e.on("mouseup",(t=>{if(k.show=!1,1===t.button){const{type:t,selfKey:n,dataIndex:i}=e.origin,o={...e.origin,data:{...e.origin.data,time:b(e.left),value:w(t,e.top)}};if(g.value.discardActiveObject(),_.length>0){const l=D.find((e=>e.type===t));let r=-1;const a=_.map((e=>e.data));if(e.nextPoint){if(2.5!==e.scaleX)return void ie({dataIndex:i,scaleValue:l});const t=e.coincidePoint.origin,n=t.data;r=t.index;const o=a.findIndex((e=>e.time===n.time));o>-1?a[o].value=n.value:a.push({...a.at(-1),time:n.time,value:n.value})}const s=l.dataList.findIndex((e=>e.key===n));h("add",{...m(o,["index","selfKey","lineAttr"]),dataIndex:s,key:n,data:a}),ne({...o,data:a,coincideIndex:r})}else h("change",{...m(o,["selfKey","lineAttr"]),key:n}),ne(o,"change")}}))}(p),null==(d=F.get(u.key))||d.push(p))}(ae(l,n),l,c,e)})),Promise.all(F.get(e.key)).then((t=>{const n=f.filter((e=>e));q(t),g.value.add(...n,...t),function(e,t){const{max:n={},min:i={}}=t.panicValue||{},{max:o={},min:l={}}=t.diffValue||{};function r({show:t=!1,value:n,flickerable:i},o){!t&&n&&i&&e.forEach((e=>{const t=e.origin.data.value;"max"===o&&t<n||"min"===o&&t>n||N.add(e)}))}r(n,"max"),r(i,"min"),r(o,"max"),r(l,"min")}(t,e)}))}function ee(e,t){["stroke","fill"].forEach((n=>{const i=e[n];i&&!["transparent","#fff","#ffffff","#FFFFFF"].includes(i)&&i!==t&&e.set(n,t)})),e.rightLine&&e.rightLine.stroke!==t&&e.rightLine.set("stroke",t)}function te(e,t){const[,,n,o]=t;e.clone((l=>{l.set({left:n,top:o,scaleX:1,scaleY:1}),e.prevPointer=[n,o];const r=i(t,e.origin.lineAttr);l.leftLine=r,O.add(l),g.value.add(r,l)}))}function ne(e,t="add",n=1){const{data:i,index:o,key:l,type:r,coincideIndex:a}=e;let{dataIndex:s}=e;const f=D.find((e=>e.type===r)),u=f.dataList.find(((e,t)=>(s=t,e.key===l)));switch(t){case"remove":u.list.splice(o,n),u.list[o-1]&&(u.list[o-1].breakpoint=!0);break;case"change":u.list[o]=i;break;default:{const e=Array.isArray(i)?i[0].time:i.time,t=c(e,u.list),n=Array.isArray(i)?i:[i];u.list.splice(t,a>-1?a-t+1:0,...n);break}}ie({dataIndex:s,scaleValue:f})}function ie(e){var t,n,i;if(O.size&&(null==(t=g.value)||t.remove(...oe([...O]))),O.clear(),_=[],e){const{dataIndex:t,scaleValue:i}=e,o=i.dataList[t];null==(n=g.value)||n.remove(...oe(F.get(o.key))),F.delete(o.key),Z(o,t,i)}else F.size&&(null==(i=g.value)||i.remove(...oe(se()))),F.clear(),B()}function oe(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine)})),t}function le(e,t="moving"){const{title:n,type:i,data:o,unit:l}=e.origin;k.point={x:e.left,y:e.top};const r=`${"hover"===t?o.value:w(i,e.top)}`;k.list=[`${n} ${r}${l||""}`,`时间 ${b(e.left).slice(-5)}`],k.show=!0}function re(e){e.setCoords();const t=6e4/Y,n=e.prevPoint?e.prevPoint.left+t:C,i=K;e.top<j&&e.set("top",j),e.top>E&&e.set("top",E),e.left<n&&e.set("left",n),e.left>i&&e.set("left",i)}function ae(e,t){if(u(e)&&function(e){const t=Date.parse(T.list.at(-1)),n=d(e);return n>=V&&n<=t}(e.time)){const n=L(e.time),i=P(t.type,t.range,e.value);return[n,i<j?j:i>E?E:i]}}function se(){return Array.from(F.values()).flat()}return e((()=>{R()})),B(),function(){if(!X.evented)return;let e=!1,i={x:0,y:0};g.value.on("mouse:up",(t=>{if(3===t.button&&function(e){const{x:t=0,y:n=0}=e.pointer||{};if(t>=C&&t<=K&&n>=j&&n<=E)if(e.target){if("main"!==e.target.__type)return;i(e.pointer,e.target,["删除节点"]);const{minLeft:t,maxLeft:n,minTop:o,maxTop:l}=f(e.target);se().forEach((i=>{"main"===i.__type&&i.left>t&&i.left<n&&i.top>o&&i.top<l&&x.list.push({renderItem:()=>i.origin.title,origin:{...i.origin},mode:"remove",pointer:e.pointer})})),1===x.list.length&&(x.show=!1,console.log("当前时间段内无可删除节点"))}else i(e.pointer,null,["新增节点"]),S.forEach((n=>{G(se(),t,"key",2*A).includes(n.linkKey||n.key)||x.list.push({renderItem:()=>n.title,origin:{title:n.title,unit:n.unit,type:n.bigType,dataIndex:n.dataIndex,key:n.key,linkKey:n.linkKey},pointer:e.pointer})})),1===x.list.length&&(x.show=!1,J("repeat"),console.log("当前时间段内无可新增节点"));function i(e,t,n){Object.assign(x,{point:e,show:!0,target:t,list:n})}}(t),1===t.button&&e){e=!1;const t=H();t.length>0?Q((()=>{const e=function(e){const t=e.reduce(((e,t)=>{const{key:n}=t.origin;return e[n]=e[n]?e[n].concat(t.origin):[t.origin],e}),{});return Object.keys(t).map((e=>{const n=t[e].sort(((e,t)=>Date.parse(e.data.time)-Date.parse(t.data.time)));return ne(n[0],"remove",n.length),n.map((e=>({...m(e,["selfKey","lineAttr"]),key:e.selfKey})))}))}(t);h("remove",e)})):a.emit(z)}})),g.value.on("mouse:down",(t=>{1!==t.button||t.target||(e=!0,i=t.pointer)})),g.value.on("mouse:move",(o=>{if(!e)return;const{x:l,y:r}=i,{x:a,y:s}=o.pointer;z&&g.value.remove(z),z=new t.Rect({...n,fill:"#CAF982",opacity:.4,...I,left:l,top:r,width:a-l,height:s-r,objectCaching:!0}),z.areaPos={startPos:i,endPos:o.pointer},g.value.add(z)}))}(),{redrawPoints:ie,clickMenu:function({item:e,target:t}){const n={...e.origin};"remove"===e.mode?(h("remove",n),ne(n,"remove")):(Object.assign(n,{data:{time:b(e.pointer.x),value:w(e.origin.type,e.pointer.y),...e.origin.linkKey?{key:e.origin.key}:{}}}),h("add",n),ne({...n,key:e.origin.linkKey||e.origin.key}))},moveLimit:re,setPopup:le,updateData:ne,getGridPoints:se,getContainPoints:H,showDialog:Q,removeCurrentSelection:U}}export{g as useCenter};
@@ -2,7 +2,7 @@ import { type Ref } from 'vue';
2
2
  import { fabric } from '../../../../../../es/shared/utils/fabricjs';
3
3
  import { IObject, IPropItems, IPointTipProps, IPointMenuProps } from '../../../../../../es/components/fabric-chart/src/interface';
4
4
  import { AnyObject } from '../../../../../../es/shared/types';
5
- export declare function useCenter(canvas: Ref<fabric.Canvas>, propItems: IPropItems, emits: Function, computedX: Function, cumputedY: Function, getXValue: Function, getYValue: Function, addRenderItem: Function | undefined, pointTipProps: IPointTipProps, pointMenuProps: IPointMenuProps): {
5
+ export declare function useCenter(canvas: Ref<fabric.Canvas>, propItems: IPropItems, emits: Function, computedX: Function, computedY: Function, getXValue: Function, getYValue: Function, addRenderItem: Function | undefined, pointTipProps: IPointTipProps, pointMenuProps: IPointMenuProps): {
6
6
  clickMenu: ({ item, target }: {
7
7
  item: any;
8
8
  target: any;
@@ -1,6 +1,6 @@
1
1
  import { Ref } from 'vue';
2
2
  import { fabric } from '../../../../../../es/shared/utils/fabricjs';
3
3
  import { IPropItems, IPointTipProps, IObject } from '../../../../../../es/components/fabric-chart/src/interface';
4
- export declare function useLeft(canvas: Ref<fabric.Canvas>, propItems: IPropItems, emits: Function, setPopup: Function, pointTipProps: IPointTipProps, computedX: Function, cumputedY: Function, getXValue: Function, getYValue: Function, isAddPoint: Function, updateData: Function, gridPoints: Set<IObject>): {
4
+ export declare function useLeft(canvas: Ref<fabric.Canvas>, propItems: IPropItems, emits: Function, setPopup: Function, pointTipProps: IPointTipProps, computedX: Function, computedY: Function, getXValue: Function, getYValue: Function, isAddPoint: Function, updateData: Function, gridPoints: Set<IObject>): {
5
5
  drawScaleValue: (yScaleValueList: any[]) => void;
6
6
  };