cnhis-design-vue 3.2.9-beta.9 → 3.2.9-release.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/base-search/index.d.ts +2 -0
- package/es/components/base-search/src/index.vue.d.ts +2 -0
- package/es/components/button-print/index.d.ts +30 -0
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +30 -0
- package/es/components/button-print/src/ButtonPrint.vue2.js +1 -1
- package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +9 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
- package/es/components/button-print/src/components/OldPrintComponent.vue.d.ts +9 -0
- package/es/components/button-print/src/components/OldPrintComponent.vue2.js +1 -1
- package/es/components/button-print/src/utils/print.d.ts +6 -5
- package/es/components/button-print/src/utils/print.js +1 -1
- package/es/components/classification/index.d.ts +87 -0
- package/es/components/classification/src/components/search-filter/index.vue.d.ts +87 -0
- package/es/components/classification/src/components/set-classification/index.vue.d.ts +87 -0
- package/es/components/classification/src/components/table-modal/index.vue.d.ts +3 -0
- package/es/components/classification/src/index.vue.d.ts +87 -0
- package/es/components/date-picker/index.d.ts +29 -0
- package/es/components/date-picker/src/DatePicker.vue.d.ts +30 -1
- package/es/components/date-picker/src/DatePicker.vue2.js +1 -1
- package/es/components/fabric-chart/src/hooks/temperature/useLeft.js +1 -1
- package/es/components/fabric-chart/src/hooks/temperature/useOther.js +1 -1
- package/es/components/field-set/index.d.ts +8 -1
- package/es/components/field-set/src/FieldColor.vue.d.ts +90 -7
- package/es/components/field-set/src/FieldColor.vue2.js +1 -1
- package/es/components/field-set/src/FieldFilter.vue.d.ts +32 -7
- package/es/components/field-set/src/FieldFilter.vue2.js +1 -1
- package/es/components/field-set/src/FieldSet.vue.d.ts +74 -31
- package/es/components/field-set/src/FieldSet.vue2.js +1 -1
- package/es/components/field-set/src/Index.vue.d.ts +8 -1
- package/es/components/field-set/src/Index.vue2.js +1 -1
- package/es/components/field-set/src/TableStyle.vue2.js +1 -1
- package/es/components/field-set/src/components/condition.vue.d.ts +29 -0
- package/es/components/field-set/src/components/edit-dialog.vue.d.ts +58 -0
- package/es/components/field-set/src/components/edit-filter.vue.d.ts +29 -0
- package/es/components/field-set/src/components/table-row.vue.d.ts +29 -2
- package/es/components/field-set/src/components/table-row.vue2.js +1 -1
- package/es/components/field-set/src/types/index.d.ts +4 -3
- package/es/components/field-set/src/utils/index.js +1 -1
- package/es/components/field-set/style/index.css +1 -1
- package/es/components/form-render/src/components/renderer/select.d.ts +2 -1
- package/es/components/form-render/src/components/renderer/select.js +1 -1
- package/es/components/form-render/src/hooks/useFieldListAdaptor.js +1 -1
- package/es/components/iho-chat/index.d.ts +316 -6
- package/es/components/iho-chat/src/Index.vue.d.ts +316 -6
- package/es/components/iho-chat/src/Index.vue2.js +1 -1
- package/es/components/iho-chat/src/api/index.js +1 -1
- package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +5 -0
- package/es/components/iho-chat/src/components/ChatAdd.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatFile.vue.d.ts +121 -1
- package/es/components/iho-chat/src/components/ChatFile.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +6 -0
- package/es/components/iho-chat/src/components/ChatFooter.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +160 -2
- package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +122 -0
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatRecord.vue.d.ts +29 -0
- package/es/components/iho-chat/src/components/ChatRecord.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +6 -1
- package/es/components/iho-chat/src/components/ChatSet.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ContextMenu.js +1 -1
- package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +5 -0
- package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
- package/es/components/iho-chat/src/components/SiderList.vue.d.ts +1 -3
- package/es/components/iho-chat/src/components/SiderList.vue2.js +1 -1
- package/es/components/iho-chat/src/constants/index.d.ts +2 -1
- package/es/components/iho-chat/src/constants/index.js +1 -1
- package/es/components/iho-chat/src/hooks/useSearchUserList.js +1 -1
- package/es/components/iho-chat/src/hooks/useSession.js +1 -1
- package/es/components/iho-chat/src/hooks/useState.d.ts +6 -0
- package/es/components/iho-chat/src/hooks/useState.js +1 -1
- package/es/components/iho-chat/src/types/index.d.ts +3 -1
- package/es/components/iho-chat/src/types/index.js +1 -1
- package/es/components/iho-chat/src/utils/chatSock.js +1 -1
- package/es/components/iho-chat/style/index.css +1 -1
- package/es/components/iho-table/src/plugins/filterDaterangeRenderPlugin/filter.vue.d.ts +29 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/editDate.vue.d.ts +29 -0
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/hooks/index.js +1 -1
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/hooks/useRowHeight.d.ts +2 -0
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/hooks/useRowHeight.js +1 -0
- package/es/components/iho-table/src/types/index.d.ts +3 -0
- package/es/components/iho-table/style/index.css +1 -1
- package/es/components/index.css +1 -1
- package/es/components/quick-search/index.d.ts +3 -0
- package/es/components/quick-search/src/index.vue.d.ts +3 -0
- package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
- package/es/components/table-filter/src/components/bi-filter/ValueCfg.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/bi-filter/components/Date.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/bi-filter/components/index.d.ts +29 -0
- package/es/components/table-filter/src/components/bi-filter/index.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/classify-filter/ValueCfg.vue.d.ts +58 -0
- package/es/components/table-filter/src/components/classify-filter/components/Date.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/classify-filter/components/DateRange.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/classify-filter/components/index.d.ts +58 -0
- package/es/components/table-filter/src/components/classify-filter/index.vue.d.ts +58 -0
- package/es/components/table-filter/src/components/render-widget/components/DateInner.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/render-widget/components/DateOut.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/render-widget/components/DateRangeInner.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/render-widget/components/DateRangeOut.vue.d.ts +29 -0
- package/es/components/table-filter/src/components/render-widget/components/index.d.ts +116 -0
- package/es/components/table-filter/src/components/render-widget/widgetCfgMaps.d.ts +116 -0
- package/es/components/table-filter/src/hooks/useAdvanced.d.ts +1 -0
- package/es/components/table-filter/src/hooks/useAdvanced.js +1 -1
- package/es/components/table-filter/src/hooks/useRenderWidget.js +1 -1
- package/es/components/table-filter/src/types/index.d.ts +2 -0
- package/es/components/vod-chunk-upload/src/chunk-upload-new.vue2.js +1 -1
- package/es/env.d.ts +25 -25
- package/es/shared/package.json.js +1 -1
- package/es/shared/utils/index.d.ts +1 -0
- package/es/shared/utils/index.js +1 -1
- package/package.json +2 -2
@@ -74,6 +74,7 @@ declare const CBaseSearch: SFCWithInstall<import("vue").DefineComponent<{
|
|
74
74
|
placeholder: string | undefined;
|
75
75
|
advanceColWidth: number | null | undefined;
|
76
76
|
accurateSearch: any;
|
77
|
+
extendKey: string;
|
77
78
|
}[];
|
78
79
|
transformParams: (paramsList: any[]) => any;
|
79
80
|
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
@@ -150,6 +151,7 @@ declare const CBaseSearch: SFCWithInstall<import("vue").DefineComponent<{
|
|
150
151
|
alias?: string | undefined;
|
151
152
|
accurateSearch?: any;
|
152
153
|
isAccurateSearchVal?: boolean | undefined;
|
154
|
+
extendKey?: string | undefined;
|
153
155
|
}[]>;
|
154
156
|
filterChangeFnList: import("vue").Ref<any[]>;
|
155
157
|
showQuickSearch: import("vue").ComputedRef<boolean>;
|
@@ -75,6 +75,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
75
75
|
placeholder: string | undefined;
|
76
76
|
advanceColWidth: number | null | undefined;
|
77
77
|
accurateSearch: any;
|
78
|
+
extendKey: string;
|
78
79
|
}[];
|
79
80
|
transformParams: (paramsList: any[]) => any;
|
80
81
|
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
@@ -151,6 +152,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
151
152
|
alias?: string | undefined;
|
152
153
|
accurateSearch?: any;
|
153
154
|
isAccurateSearchVal?: boolean | undefined;
|
155
|
+
extendKey?: string | undefined;
|
154
156
|
}[]>;
|
155
157
|
filterChangeFnList: import("vue").Ref<any[]>;
|
156
158
|
showQuickSearch: import("vue").ComputedRef<boolean>;
|
@@ -108,6 +108,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
108
108
|
type: ObjectConstructor;
|
109
109
|
default: () => {};
|
110
110
|
};
|
111
|
+
svrUpdateIp: {
|
112
|
+
type: StringConstructor;
|
113
|
+
};
|
111
114
|
}, {
|
112
115
|
$attrs: {
|
113
116
|
[x: string]: unknown;
|
@@ -219,6 +222,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
219
222
|
type: ObjectConstructor;
|
220
223
|
default: () => {};
|
221
224
|
};
|
225
|
+
svrUpdateIp: {
|
226
|
+
type: StringConstructor;
|
227
|
+
};
|
222
228
|
}>> & {
|
223
229
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
224
230
|
onError?: ((...args: any[]) => any) | undefined;
|
@@ -331,6 +337,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
331
337
|
shortcut: {};
|
332
338
|
};
|
333
339
|
};
|
340
|
+
svrUpdateIp: {
|
341
|
+
type: StringConstructor;
|
342
|
+
};
|
334
343
|
}, {
|
335
344
|
baseDownListSetting: {
|
336
345
|
label: string;
|
@@ -444,6 +453,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
444
453
|
shortcut: {};
|
445
454
|
};
|
446
455
|
};
|
456
|
+
svrUpdateIp: {
|
457
|
+
type: StringConstructor;
|
458
|
+
};
|
447
459
|
}>> & {}>>;
|
448
460
|
emit: any;
|
449
461
|
defaultFormatInfo: import("../../shared/types").AnyObject;
|
@@ -810,6 +822,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
810
822
|
shortcut: {};
|
811
823
|
};
|
812
824
|
};
|
825
|
+
svrUpdateIp: {
|
826
|
+
type: StringConstructor;
|
827
|
+
};
|
813
828
|
}>>, {
|
814
829
|
params: import("../../shared/types").AnyObject[];
|
815
830
|
btnText: string;
|
@@ -935,6 +950,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
935
950
|
placement: {
|
936
951
|
type: StringConstructor;
|
937
952
|
};
|
953
|
+
svrUpdateIp: {
|
954
|
+
type: StringConstructor;
|
955
|
+
};
|
938
956
|
}, {
|
939
957
|
$attrs: {
|
940
958
|
[x: string]: unknown;
|
@@ -1045,6 +1063,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
1045
1063
|
placement: {
|
1046
1064
|
type: StringConstructor;
|
1047
1065
|
};
|
1066
|
+
svrUpdateIp: {
|
1067
|
+
type: StringConstructor;
|
1068
|
+
};
|
1048
1069
|
}>> & {}>>;
|
1049
1070
|
emit: any;
|
1050
1071
|
defaultFormatInfo: import("../../shared/types").AnyObject;
|
@@ -1384,6 +1405,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
1384
1405
|
placement: {
|
1385
1406
|
type: StringConstructor;
|
1386
1407
|
};
|
1408
|
+
svrUpdateIp: {
|
1409
|
+
type: StringConstructor;
|
1410
|
+
};
|
1387
1411
|
}>>, {
|
1388
1412
|
params: import("../../shared/types").AnyObject[];
|
1389
1413
|
btnText: string;
|
@@ -1516,6 +1540,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
1516
1540
|
type: ObjectConstructor;
|
1517
1541
|
default: () => {};
|
1518
1542
|
};
|
1543
|
+
svrUpdateIp: {
|
1544
|
+
type: StringConstructor;
|
1545
|
+
};
|
1519
1546
|
}>> & {
|
1520
1547
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
1521
1548
|
onError?: ((...args: any[]) => any) | undefined;
|
@@ -1634,6 +1661,9 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
1634
1661
|
type: ObjectConstructor;
|
1635
1662
|
default: () => {};
|
1636
1663
|
};
|
1664
|
+
svrUpdateIp: {
|
1665
|
+
type: StringConstructor;
|
1666
|
+
};
|
1637
1667
|
}>> & {
|
1638
1668
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
1639
1669
|
onError?: ((...args: any[]) => any) | undefined;
|
@@ -111,6 +111,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
111
111
|
type: ObjectConstructor;
|
112
112
|
default: () => {};
|
113
113
|
};
|
114
|
+
svrUpdateIp: {
|
115
|
+
type: StringConstructor;
|
116
|
+
};
|
114
117
|
}, {
|
115
118
|
$attrs: {
|
116
119
|
[x: string]: unknown;
|
@@ -225,6 +228,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
225
228
|
type: ObjectConstructor;
|
226
229
|
default: () => {};
|
227
230
|
};
|
231
|
+
svrUpdateIp: {
|
232
|
+
type: StringConstructor;
|
233
|
+
};
|
228
234
|
}>> & {
|
229
235
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
230
236
|
onError?: ((...args: any[]) => any) | undefined;
|
@@ -337,6 +343,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
337
343
|
shortcut: {};
|
338
344
|
};
|
339
345
|
};
|
346
|
+
svrUpdateIp: {
|
347
|
+
type: StringConstructor;
|
348
|
+
};
|
340
349
|
}, {
|
341
350
|
baseDownListSetting: {
|
342
351
|
label: string;
|
@@ -450,6 +459,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
450
459
|
shortcut: {};
|
451
460
|
};
|
452
461
|
};
|
462
|
+
svrUpdateIp: {
|
463
|
+
type: StringConstructor;
|
464
|
+
};
|
453
465
|
}>> & {}>>;
|
454
466
|
emit: any;
|
455
467
|
defaultFormatInfo: AnyObject;
|
@@ -816,6 +828,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
816
828
|
shortcut: {};
|
817
829
|
};
|
818
830
|
};
|
831
|
+
svrUpdateIp: {
|
832
|
+
type: StringConstructor;
|
833
|
+
};
|
819
834
|
}>>, {
|
820
835
|
params: AnyObject[];
|
821
836
|
btnText: string;
|
@@ -941,6 +956,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
941
956
|
placement: {
|
942
957
|
type: StringConstructor;
|
943
958
|
};
|
959
|
+
svrUpdateIp: {
|
960
|
+
type: StringConstructor;
|
961
|
+
};
|
944
962
|
}, {
|
945
963
|
$attrs: {
|
946
964
|
[x: string]: unknown;
|
@@ -1051,6 +1069,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
1051
1069
|
placement: {
|
1052
1070
|
type: StringConstructor;
|
1053
1071
|
};
|
1072
|
+
svrUpdateIp: {
|
1073
|
+
type: StringConstructor;
|
1074
|
+
};
|
1054
1075
|
}>> & {}>>;
|
1055
1076
|
emit: any;
|
1056
1077
|
defaultFormatInfo: AnyObject;
|
@@ -1390,6 +1411,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
1390
1411
|
placement: {
|
1391
1412
|
type: StringConstructor;
|
1392
1413
|
};
|
1414
|
+
svrUpdateIp: {
|
1415
|
+
type: StringConstructor;
|
1416
|
+
};
|
1393
1417
|
}>>, {
|
1394
1418
|
params: AnyObject[];
|
1395
1419
|
btnText: string;
|
@@ -1525,6 +1549,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
1525
1549
|
type: ObjectConstructor;
|
1526
1550
|
default: () => {};
|
1527
1551
|
};
|
1552
|
+
svrUpdateIp: {
|
1553
|
+
type: StringConstructor;
|
1554
|
+
};
|
1528
1555
|
}>> & {
|
1529
1556
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
1530
1557
|
onError?: ((...args: any[]) => any) | undefined;
|
@@ -1646,6 +1673,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
1646
1673
|
type: ObjectConstructor;
|
1647
1674
|
default: () => {};
|
1648
1675
|
};
|
1676
|
+
svrUpdateIp: {
|
1677
|
+
type: StringConstructor;
|
1678
|
+
};
|
1649
1679
|
}>> & {
|
1650
1680
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
1651
1681
|
onError?: ((...args: any[]) => any) | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as t,useAttrs as e,ref as r,computed as n,provide as o,openBlock as i,createBlock as
|
1
|
+
import{defineComponent as t,useAttrs as e,ref as r,computed as n,provide as o,openBlock as i,createBlock as p,resolveDynamicComponent as a,unref as u,mergeProps as s,withCtx as l,createCommentVNode as d,renderSlot as y,normalizeProps as f,guardReactiveProps as m}from"vue";import{InjectionButtonPrintEmits as c}from"./constants/index.js";import g from"./components/NewPrintComponent.vue.js";import P from"./components/OldPrintComponent.vue.js";var v=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},noDefaultFormatMsg:{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:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},printCustomProps:{type:Object,default:()=>({})},resolution:{type:Number},placement:{type:String,default:"bottom-start"},newPrintSetting:{type:Object,default:()=>({})},svrUpdateIp:{type:String}},emits:["success","error","cancel","clickoutside","saveOuterPrint"],setup(t,{expose:v,emit:S}){const b=t,x=e(),j=r(),F=n((()=>{var t;return(null==(t=Object.keys(b.newPrintSetting))?void 0:t.length)>0?g:P})),O=n((()=>Object.assign({},b,x)));o(c,(function(t,...e){S(t,...e)}));return v({directPrint:async()=>{var t;null==(t=j.value)||t.directPrint()}}),(t,e)=>(i(),p(a(u(F)),s({ref_key:"printComponentRef",ref:j},u(O)),{button:l((e=>[d(" 自定义按钮样式 "),y(t.$slots,"button",f(m(e)))])),_:3},16))}});export{v as default};
|
@@ -108,6 +108,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
108
108
|
shortcut: {};
|
109
109
|
};
|
110
110
|
};
|
111
|
+
svrUpdateIp: {
|
112
|
+
type: StringConstructor;
|
113
|
+
};
|
111
114
|
}, {
|
112
115
|
baseDownListSetting: {
|
113
116
|
label: string;
|
@@ -224,6 +227,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
224
227
|
shortcut: {};
|
225
228
|
};
|
226
229
|
};
|
230
|
+
svrUpdateIp: {
|
231
|
+
type: StringConstructor;
|
232
|
+
};
|
227
233
|
}>> & {}>>;
|
228
234
|
emit: any;
|
229
235
|
defaultFormatInfo: AnyObject;
|
@@ -593,6 +599,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
593
599
|
shortcut: {};
|
594
600
|
};
|
595
601
|
};
|
602
|
+
svrUpdateIp: {
|
603
|
+
type: StringConstructor;
|
604
|
+
};
|
596
605
|
}>>, {
|
597
606
|
params: AnyObject[];
|
598
607
|
btnText: string;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,inject as t,ref as n,reactive as r,computed as i,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as f,renderList as y,createBlock as g,normalizeClass as h,createTextVNode as k,toDisplayString as b,isRef as P,renderSlot as w,withModifiers as S,mergeProps as O}from"vue";import{isObject as I}from"@vue/shared";import{useMessage as C,NButtonGroup as L,NDropdown as T,NButton as j,NIcon as M,NPopover as F,NCheckbox as E,NDivider as x}from"naive-ui";import{PrintOutline as N,SettingsOutline as _,ChevronDownSharp as D,ArrowForwardOutline as J}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as R}from"../constants/index.js";import{Print as z}from"../utils/print.js";import{isIReport as A}from"../utils/browserPrint.js";import U from"./IdentityVerification.vue.js";import{format as V}from"date-fns";import"../api.js";import"../../../shortcut-provider/index.js";import{useShortcuts as B}from"../../../shortcut-provider/src/hooks/useShortcuts.js";const K={class:"newprint-button-outer"},G={key:0,class:"newprint-button-outer__shortcut"},q=d("span",{class:"label bold"},"外显设置",-1),Y={class:"newprint-button-poperOver"},H={class:"print-lite"},$={class:"label bold"},Q={class:"print-li"},W={class:"print-lite"},X={key:0,class:"newprint-button-outer__shortcut"},Z={class:"newprint-button-poperOver"},ee=["onMouseenter","onClick"],te={class:"label bold"},ne={class:"newprint-button-poperOver"},re={class:"print-lite"},ie={class:"label bold"},ae={class:"print-li"},le={class:"print-lite"},oe=["onClick"],se={key:0,class:"newprint-button-outer__shortcut"},ue={class:"newprint-button-poperOver"},ce=["onMouseenter"],de={class:"print-lite"},pe=["onClick"];var me=e({__name:"NewPrintComponent",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:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:"",shortcut:{}})}},setup(e,{expose:me}){const ve=e,fe=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],ye=C();let ge;const he=t(R),ke=n(""),be=r({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],iReportExecuteMode:1}),Pe=n({});let we=n([]),Se=n([{label:ve.previewText,key:"previewText"},{label:ve.pdfLoadText,key:"downloadPdf"},{label:ve.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Oe=r({oneMouseType:"",oneClickType:"",twoMouseType:""}),Ie=r({oneShow:!1,isOperation:!1,isOutSetting:!1}),Ce=n([]),Le=n([]),Te=i((()=>{if(!be.currentFormatId)return{};let e=be.currentFormatId;return be.formatList.find((t=>t.id===e))}));i((()=>{var e;return(null==(e=Te.value)?void 0:e.name)||"格式选择"}));const je=i((()=>{let e=be.formatList.find((e=>e.id===be.currentFormatId));return null==e?void 0:e.templateId})),Me=i((()=>{let e=be.formatList.find((e=>e.id===be.currentFormatId));return null==e?void 0:e.number})),Fe=i((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.isShowPrintAll})),Ee=i((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.isShowOutSetting})),xe=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.customProps)||{}})),Ne=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.defaultFormatId)||""})),_e=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.printAllType)||1})),De=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.shortcut)||{}})),Je=i((()=>{var e,t;const n=Object.keys(De.value);if(n.length>0){if(Ne.value&&n.includes(Ne.value))return(null==(e=De.value[Ne.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=De.value.all)?void 0:t.shortcutLabel)||""}return""})),Re=i((()=>{const e=fe.map((e=>e.key));return we.value.filter((t=>!e.includes(t.key)))})),ze=i({get:()=>Re.value.every((e=>e.selected)),set(e){Re.value.forEach((t=>{t.selected=e}))}}),Ae=async()=>{var e,t;(null==(t=null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await mt(),Ie.oneShow=!0},Ue=async e=>{if(ve.directPrint){if(be.spinning)return;return"button"===e?void(Fe.value?await yt():Ne.value?async function(e){await mt(!1);const t=Ce.value.find((t=>t.key==e));t&&et(t.templateCode,t.templateId,t.key,!1)}(Ne.value):Ae()):Ae()}return Ae()},Ve=(e,t)=>{Oe[e]=t},Be=()=>{Ce.value=we.value.filter((e=>!e.selected)),Le.value=Re.value.filter((e=>e.selected)),Ge("oneShow"),Ge("isOutSetting"),he("saveOuterPrint",Le.value)},Ke=e=>{Ie[e]=!0},Ge=e=>{Oe.oneClickType="",Ie[e]=!1,"isOutSetting"==e&&(Ie.isOutSetting=!1)},qe=(e,t)=>{Xe(!1);let n={type:t,formatId:be.currentFormatId,templateId:(null==e?void 0:e.templateId)||je.value,templateCode:(null==e?void 0:e.templateCode)||Me.value};he("success",e,n)},Ye=e=>{Xe(!1),he("error",e),I(e)&&"notInstalledApp"===e.type&&ye.error(e.message)},He=e=>{Xe(!1),he("cancel",e)},$e=e=>{he("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Qe=()=>JSON.stringify({...ve.token?{token:ve.token}:{}}),We=(e=[],t)=>{var n,r;let i={},a={};if((null==(n=be.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(r=Object.keys(e[0].datasetData||{}))?void 0:r[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return i=Object.assign({},JSON.parse(Qe()),xe.value,a),JSON.stringify(i)},Xe=(e,t)=>{if(be.isClickOuterPrint){if(e&&t){const n=Le.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Le.value.forEach((e=>{e.isLoading=!1}))}else be.spinning=e},Ze=()=>be.isClickOuterPrint?Le.value.some((e=>e.isLoading)):be.spinning,et=(e,t,n,r)=>{const i=be.printParams[e];if(!i)return;be.isClickOuterPrint=r,be.currentFormatId=n;const a=be.originParams[e]||[];tt(i,e,t,n,a)},tt=async(e=[],t,n,r,i=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&qe(e,"print")}catch(e){console.log("error",e)}};ve.showLoading&&Ze()&&!a||(Xe(!0,r),ve.prevFn("print",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e;const a={formatId:r,iReportExecuteMode:be.iReportExecuteMode,templateId:n,authorizationKey:ke.value,printdlgshow:ve.printdlgshow,signature:ve.signature,copies:ve.printCopies};if("MULTI"===ve.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[t]));ge.printDirect({...a,params:n},o,Ye,He)}else ge.printDirect({...a,params:We(e,t)},(e=>{e.params=i,e.templateCode=t,e.templateId=n,qe(e,"print")}),Ye,He)})).catch((()=>{$e("print"),Xe(!1)})).finally((()=>{be.visible=!1})))},nt=async(e,{templateCode:t,templateId:n,key:r},i)=>{const a=be.printParams[t];if(a)switch(be.isClickOuterPrint=i,be.currentFormatId=r,e){case"previewText":(async(e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("preview",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[0])),a="MULTI"===ve.strategy?i:We(e,t),l={formatId:r,templateId:n,iReportExecuteMode:be.iReportExecuteMode,authorizationKey:ke.value,params:a,btnprint:ve.btnprint,signature:ve.signature};ge.preview(l,(e=>{qe(e,"preview")}),Ye)})).catch((()=>{$e("preview"),Xe(!1)})).finally((()=>{be.visible=!1})))})(a,t,n,r);break;case"formatEditText":((e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("edit",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e,be.currentFormatId=r,be.identityVerification.visible=!0})).catch((()=>{$e("edit")})).finally((()=>{Xe(!1)})))})(a,0,n,r);break;case"downloadPdf":(async(e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("download",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[0])),a="MULTI"===ve.strategy?i:We(e,t),l={formatId:r,templateId:n,iReportExecuteMode:be.iReportExecuteMode,authorizationKey:ke.value,print:{print:"1",type:"1",resolution:null==ve?void 0:ve.resolution},params:a,signature:ve.signature};ge.downloadPDF(l,(e=>qe(e,"preview")),Ye)})).catch((()=>{$e("download"),Xe(!1)})).finally((()=>{be.visible=!1})))})(a,t,n,r);break;case"resetPrinter":(async(e=[],t,n,r)=>{if(!ve.showLoading||!Ze()){Xe(!0,r);try{const e=await ge.resetPrinter(r);if(Xe(!1),"success"==(null==e?void 0:e.result))return void ye.success(e.message||"重置打印机成功");ye.warning("重置打印机失败")}catch(e){Xe(!1),ye.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,r)}},rt=()=>{},it=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},st(n,t,e))})),n},at=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ut(n,t,e))})),n},lt=(e,t,n)=>{const r={};return t.forEach((t=>{let i=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(r=V(t,n[e.type])),(null==e?void 0:e.defaultValue)||r})(t,e[t[n]]);e[t[n]]&&i&&(r[t[n]]=i)})),r},ot=({customizeDataset:e=[],param:t=[]},n={})=>{let r={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;r.datasetData||(r.datasetData={}),r.datasetData[e.name]=JSON.stringify(lt(n,t,"fieldName"))})),r=Object.assign({},r,lt(n,t,"key")),r},st=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r],a=n[i];if(!a)return ye.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(ot(a,t))}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i],l=n[a];if(!l)return ye.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(ot(l,t))}return e},ut=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r];if(!n[i])return ye.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(t)}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i];if(!n[a])return ye.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},ct=async e=>{var t;be.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],be.iReportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].iReportExecuteMode||1,(()=>{var e,t,n;const r=Object.keys(De.value),i=be.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(r.includes(e.id)){const n=De.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));we.value.unshift(...i),Ee.value&&we.value.push(...fe),(null==(t=null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(we.value.forEach((e=>{var t;(null==(t=ve.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Le.value=we.value.filter((e=>e.selected))),Ce.value=we.value.filter((e=>!e.selected)),ve.hideButtons.length>0&&(Se.value=Se.value.filter((e=>!ve.hideButtons.includes(e.key))));const a=sessionStorage.getItem("portal");if(a){const e=JSON.parse(a),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},r=Object.keys(t);r.includes("RY7.2.21.1.M2.G94181E")||(Se.value=Se.value.filter((e=>"downloadPdf"!=e.key))),r.includes("RY7.2.21.1.M2.G33633A")||(Se.value=Se.value.filter((e=>"formatEditText"!=e.key))),r.includes("RY7.2.21.1.M2.G99314S")||(Se.value=Se.value.filter((e=>"resetPrinter"!=e.key)))}})(),be.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),be.printParams=it(be.templateParams,ve.params),be.originParams=at(be.templateParams,ve.params),pt()},dt=async()=>{var e;if(be.isInited)return!0;be.isInited=!0,be.spinning=!0,(()=>{if(ge)return!1;ge=new z})();const t=await ve.queryPrintFormatByNumber();return await ct(t),(null==(e=t.obj)?void 0:e.length)>0&&(ke.value=t.obj[0].authorizationKey||""),be.spinning=!1,!0},pt=async()=>{const e=Object.keys(De.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],r=De.value[n],{stop:i,signature:a}=B().register({label:r.code,shortcutSignature:r.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ue("button");const e=Re.value.map((e=>e.key)),t=be.originParams;if(e.includes(n)){const e=Re.value.find((e=>e.key==n));if(e){const n=be.printParams[null==e?void 0:e.templateCode],r=t[null==e?void 0:e.templateCode]||[];tt(n,e.templateCode,e.templateId,e.key,r)}}}});Pe.value[n]=i}},mt=async(e=!0)=>{if(await ve.clickPrevFn()){if(!be.visible){if(!await dt())return!1}e&&(be.visible=!be.visible)}},vt=e=>{if(be.identityVerification.visible=!1,A(be.currentFormatId))return qe({result:"success",message:""},"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,be.curPrintParamList[0])),n="MULTI"===ve.strategy?t:We(be.curPrintParamList,Me.value),r={formatId:be.currentFormatId,templateId:je.value,params:n,token:e};ge.editPrintFormat(r,(e=>{qe(e,"edit")}),Ye)},ft=(e,t)=>{const n=Le.value[t+1];return t<Le.value.length-1&&!be.printParams[e.templateCode]&&be.printParams[n.templateCode]};async function yt(){await mt(!1),(()=>{const e=Object.keys(be.printParams);be.isClickOuterPrint=!1;const t=be.originParams;if(1==_e.value)for(let n=0;n<e.length;n++){const r=e[n],i=be.printParams[r],a=t[r]||[],l=be.formatList.filter((e=>e.number==r));l&&l.length>0&&l.forEach((e=>{be.currentFormatId=e.id,tt(i,e.number,e.templateId,e.id,a,!0)}))}2==_e.value&&Le.value.forEach((e=>{const n=be.printParams[e.templateCode],r=t[e.templateCode]||[];be.currentFormatId=e.key,tt(n,e.templateCode,e.templateId,e.key,r,!0)}))})()}return a((()=>{be.isInited=!1,mt()})),l((()=>{const e=Object.keys(Pe.value);e.length>0&&e.forEach((e=>{Pe.value[e]&&Pe.value[e]()}))})),o((()=>ve.params),(e=>{Object.keys(be.templateParams).length>0&&(be.printParams=it(be.templateParams,ve.params),be.originParams=at(be.templateParams,ve.params))}),{deep:!0}),o((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await mt(!1)}),{deep:!0,immediate:!0}),me({directPrint:yt}),(t,n)=>(s(),u(c,null,[d("div",K,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:f((()=>[(s(!0),u(c,null,y(Le.value,((t,n)=>{return s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:rt,options:(r=v(Se),i=t,be.printParams[i.templateCode]?r:[]),onSelect:e=>nt(e,t,!0)},{default:f((()=>[m(v(j),{disabled:!be.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>et(t.templateCode,t.templateId,t.key,!0),class:h(n==Le.value.length-1?"outerLastButton":ft(t,n)?"isPrintDisabled":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(t.label)+" ",1),t.shortcutLabel?(s(),u("span",G,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var r,i})),128))])),_:1}),p(" 外显设置按钮 "),Le.value.length>0&&Le.value.length==v(Re).length&&v(Ee)&&2!=v(_e)?(s(),g(v(F),{key:0,trigger:"click","show-arrow":!1,show:Ie.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Ge("isOutSetting"))},{trigger:f((()=>[m(v(j),{class:h(Le.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>Ke("isOutSetting"))},{default:f((()=>[q,m(v(M),{style:{"margin-left":"8px"},component:v(_),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:f((()=>[d("div",Y,[(s(!0),u(c,null,y(v(Re),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",H,[d("span",$,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",Q,[m(v(x)),d("div",W,[m(v(j),{type:"primary",size:"small",onClick:Be},{default:f((()=>[k("保存")])),_:1}),v(Re)&&v(Re).length>1?(s(),g(v(E),{key:0,checked:v(ze),"onUpdate:checked":n[1]||(n[1]=e=>P(ze)?ze.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:1},8,["show"])):(s(),u(c,{key:1},[p(" 打印全部按钮 "),m(v(F),{trigger:"click","show-arrow":!1,show:Ie.oneShow,onClickoutside:n[10]||(n[10]=e=>Ge("oneShow"))},{trigger:f((()=>[w(t.$slots,"button",{handleClickPrintBtn:mt,printSpinning:be.spinning,printbtnText:e.btnText,printVisible:be.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ue("icon")),["stop"]))},{default:f((()=>[m(v(j),{loading:e.showLoading&&be.spinning,onClick:n[3]||(n[3]=S((()=>Ue("button")),["stop"])),class:h(Le.value.length>0?"printAllLeftCls":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(v(Fe)?"打印全部":e.btnText)+" ",1),v(Je)?(s(),u("span",X,b(v(Je)),1)):p("v-if",!0)])),_:1},8,["loading","class"]),m(v(j),{class:"icon-select"},{icon:f((()=>[m(v(M),{component:v(D),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:f((()=>[d("div",Z,[(s(!0),u(c,null,y(Ce.value,(e=>(s(),u("div",{class:h(["print-li",Oe.oneMouseType==e.key||Oe.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ve("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ve("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!be.printParams[n.templateCode])return[];Ve(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),g(v(x),{key:0})):"outSetting"==e.key?(s(),u(c,{key:1},[p(" 第二层外显设置 "),m(v(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:Ie.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Ge("isOutSetting"))},{trigger:f((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>Ke("isOutSetting"))},[d("span",te,b(e.label),1),m(v(M),{color:Le.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:f((()=>[d("div",ne,[(s(!0),u(c,null,y(v(Re),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",re,[d("span",ie,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",ae,[m(v(x)),d("div",le,[m(v(j),{type:"primary",size:"small",onClick:Be},{default:f((()=>[k("保存")])),_:1}),v(Re)&&v(Re).length>1?(s(),g(v(E),{key:0,checked:v(ze),"onUpdate:checked":n[6]||(n[6]=e=>P(ze)?ze.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(s(),u(c,{key:2},[p(" 第二层功能操作 "),d("div",{class:h(["print-lite",be.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>et(e.templateCode,e.templateId,e.key,!1)},[k(b(e.label)+" ",1),e.shortcutLabel?(s(),u("span",se,b(e.shortcutLabel),1)):p("v-if",!0)],8,oe),be.printParams[e.templateCode]?(s(),g(v(F),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Ie[e.key],onClickoutside:t=>Ge(e.key)},{trigger:f((()=>[m(v(M),{component:v(J),size:"18",onClick:t=>Ke(e.key)},null,8,["component","onClick"])])),default:f((()=>[d("div",ue,[(s(!0),u(c,null,y(v(Se),(t=>(s(),u("div",{class:h(["print-li",Oe.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ve("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ve("twoMouseType",""))},[d("div",de,[d("span",{class:"label",onClick:n=>nt(t.key,e,!1)},b(t.label),9,pe)])],42,ce)))),128))])])),_:2},1032,["show","onClickoutside"])):p("v-if",!0)],2)],2112))],42,ee)))),128))])])),_:3},8,["show"])],2112))]),m(U,O(t.$attrs,{modelValue:be.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>be.identityVerification.visible=e),formatId:be.currentFormatId,templateId:v(je),onSuccess:vt}),null,16,["modelValue","formatId","templateId"])],64))}});export{me as default};
|
1
|
+
import{defineComponent as e,inject as t,ref as n,reactive as r,computed as i,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as y,renderList as f,createBlock as g,normalizeClass as h,createTextVNode as k,toDisplayString as b,isRef as P,renderSlot as w,withModifiers as S,mergeProps as I}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as L,NDropdown as T,NButton as j,NIcon as M,NPopover as x,NCheckbox as E,NDivider as F}from"naive-ui";import{PrintOutline as N,SettingsOutline as _,ChevronDownSharp as D,ArrowForwardOutline as R}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}from"../constants/index.js";import{Print as U}from"../utils/print.js";import{isIReport as z}from"../utils/browserPrint.js";import K from"./IdentityVerification.vue.js";import{format as A}from"date-fns";import"../api.js";import"../../../shortcut-provider/index.js";import{encapBrowserLog as V}from"../../../../shared/utils/index.js";import{useShortcuts as B}from"../../../shortcut-provider/src/hooks/useShortcuts.js";const q={class:"newprint-button-outer"},G={key:0,class:"newprint-button-outer__shortcut"},Y=d("span",{class:"label bold"},"外显设置",-1),H={class:"newprint-button-poperOver"},$={class:"print-lite"},Q={class:"label bold"},W={class:"print-li"},X={class:"print-lite"},Z={key:0,class:"newprint-button-outer__shortcut"},ee={class:"newprint-button-poperOver"},te=["onMouseenter","onClick"],ne={class:"label bold"},re={class:"newprint-button-poperOver"},ie={class:"print-lite"},ae={class:"label bold"},le={class:"print-li"},oe={class:"print-lite"},se=["onClick"],ue={key:0,class:"newprint-button-outer__shortcut"},ce={class:"newprint-button-poperOver"},de=["onMouseenter"],pe={class:"print-lite"},me=["onClick"];var ve=e({__name:"NewPrintComponent",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:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:"",shortcut:{}})},svrUpdateIp:{type:String}},setup(e,{expose:ve}){const ye=e,fe=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],ge=C();let he;const ke=t(J),be=n(""),Pe=r({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],iReportExecuteMode:1}),we=n({});let Se=n([]),Ie=n([{label:ye.previewText,key:"previewText"},{label:ye.pdfLoadText,key:"downloadPdf"},{label:ye.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Oe=r({oneMouseType:"",oneClickType:"",twoMouseType:""}),Ce=r({oneShow:!1,isOperation:!1,isOutSetting:!1}),Le=n([]),Te=n([]),je=i((()=>{if(!Pe.currentFormatId)return{};let e=Pe.currentFormatId;return Pe.formatList.find((t=>t.id===e))}));i((()=>{var e;return(null==(e=je.value)?void 0:e.name)||"格式选择"}));const Me=i((()=>{let e=Pe.formatList.find((e=>e.id===Pe.currentFormatId));return null==e?void 0:e.templateId})),xe=i((()=>{let e=Pe.formatList.find((e=>e.id===Pe.currentFormatId));return null==e?void 0:e.number})),Ee=i((()=>{var e;return null==(e=ye.newPrintSetting)?void 0:e.isShowPrintAll})),Fe=i((()=>{var e;return null==(e=ye.newPrintSetting)?void 0:e.isShowOutSetting})),Ne=i((()=>{var e;return(null==(e=ye.newPrintSetting)?void 0:e.customProps)||{}})),_e=i((()=>{var e;return(null==(e=ye.newPrintSetting)?void 0:e.defaultFormatId)||""})),De=i((()=>{var e;return(null==(e=ye.newPrintSetting)?void 0:e.printAllType)||1})),Re=i((()=>{var e;return(null==(e=ye.newPrintSetting)?void 0:e.shortcut)||{}})),Je=i((()=>{var e,t;const n=Object.keys(Re.value);if(n.length>0){if(_e.value&&n.includes(_e.value))return(null==(e=Re.value[_e.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=Re.value.all)?void 0:t.shortcutLabel)||""}return""})),Ue=i((()=>{const e=fe.map((e=>e.key));return Se.value.filter((t=>!e.includes(t.key)))})),ze=i({get:()=>Ue.value.every((e=>e.selected)),set(e){Ue.value.forEach((t=>{t.selected=e}))}}),Ke=async()=>{var e,t;(null==(t=null==(e=ye.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await vt(),Ce.oneShow=!0},Ae=async e=>{if(ye.directPrint){if(Pe.spinning)return;return"button"===e?void(Ee.value?await gt():_e.value?async function(e){await vt(!1);const t=Le.value.find((t=>t.key==e));t&&tt(t.templateCode,t.templateId,t.key,!1)}(_e.value):Ke()):Ke()}return Ke()},Ve=(e,t)=>{Oe[e]=t},Be=()=>{Le.value=Se.value.filter((e=>!e.selected)),Te.value=Ue.value.filter((e=>e.selected)),Ge("oneShow"),Ge("isOutSetting"),ke("saveOuterPrint",Te.value)},qe=e=>{Ce[e]=!0},Ge=e=>{Oe.oneClickType="",Ce[e]=!1,"isOutSetting"==e&&(Ce.isOutSetting=!1)},Ye=(e,t)=>{Ze(!1);let n={type:t,formatId:Pe.currentFormatId,templateId:(null==e?void 0:e.templateId)||Me.value,templateCode:(null==e?void 0:e.templateCode)||xe.value};V({type:"进入成功的回调",res:e,info:n},"PRINT-SDK"),ke("success",e,n)},He=e=>{Ze(!1),V({type:"进入失败的回调",res:e},"PRINT-SDK"),ke("error",e),O(e)&&"notInstalledApp"===e.type&&ge.error(e.message)},$e=e=>{Ze(!1),ke("cancel",e)},Qe=e=>{ke("error",{message:"前置条件执行错误",type:e,preExecution:!0})},We=()=>JSON.stringify({...ye.token?{token:ye.token}:{}}),Xe=(e=[],t)=>{var n,r;let i={},a={};if((null==(n=Pe.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(r=Object.keys(e[0].datasetData||{}))?void 0:r[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return i=Object.assign({},JSON.parse(We()),Ne.value,a),JSON.stringify(i)},Ze=(e,t)=>{if(Pe.isClickOuterPrint){if(e&&t){const n=Te.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Te.value.forEach((e=>{e.isLoading=!1}))}else Pe.spinning=e},et=()=>Pe.isClickOuterPrint?Te.value.some((e=>e.isLoading)):Pe.spinning,tt=(e,t,n,r)=>{const i=Pe.printParams[e];if(!i)return;Pe.isClickOuterPrint=r,Pe.currentFormatId=n;const a=Pe.originParams[e]||[];nt(i,e,t,n,a)},nt=async(e=[],t,n,r,i=[],a)=>{V({type:"点击打印的入参",templateCode:t,templateId:n,formatId:r,printToParam:i},"PRINT-SDK");let l=e.length;const o=async e=>{try{--l<=0&&Ye(e,"print")}catch(e){console.log("error",e)}};ye.showLoading&&et()&&!a||(Ze(!0,r),ye.prevFn("print",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e;const a={formatId:r,iReportExecuteMode:Pe.iReportExecuteMode,templateId:n,authorizationKey:be.value,printdlgshow:ye.printdlgshow,signature:ye.signature,copies:ye.printCopies,svrUpdateIp:ye.svrUpdateIp};if(V({type:"准备开始打印",queryParams:a,printToParam:i},"PRINT-SDK"),"MULTI"===ye.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,e[t]));he.printDirect({...a,params:n},o,He,$e)}else he.printDirect({...a,params:Xe(e,t)},(e=>{e.params=i,e.templateCode=t,e.templateId=n,Ye(e,"print")}),He,$e)})).catch((()=>{Qe("print"),Ze(!1)})).finally((()=>{Pe.visible=!1})))},rt=async(e,{templateCode:t,templateId:n,key:r},i)=>{const a=Pe.printParams[t];if(a)switch(Pe.isClickOuterPrint=i,Pe.currentFormatId=r,e){case"previewText":(async(e=[],t,n,r)=>{ye.showLoading&&et()||(Ze(!0,r),ye.prevFn("preview",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,e[0])),a="MULTI"===ye.strategy?i:Xe(e,t),l={formatId:r,templateId:n,iReportExecuteMode:Pe.iReportExecuteMode,authorizationKey:be.value,params:a,btnprint:ye.btnprint,signature:ye.signature};he.preview(l,(e=>{Ye(e,"preview")}),He)})).catch((()=>{Qe("preview"),Ze(!1)})).finally((()=>{Pe.visible=!1})))})(a,t,n,r);break;case"formatEditText":((e=[],t,n,r)=>{ye.showLoading&&et()||(Ze(!0,r),ye.prevFn("edit",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e,Pe.currentFormatId=r,Pe.identityVerification.visible=!0})).catch((()=>{Qe("edit")})).finally((()=>{Ze(!1)})))})(a,0,n,r);break;case"downloadPdf":(async(e=[],t,n,r)=>{ye.showLoading&&et()||(Ze(!0,r),ye.prevFn("download",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,e[0])),a="MULTI"===ye.strategy?i:Xe(e,t),l={formatId:r,templateId:n,iReportExecuteMode:Pe.iReportExecuteMode,authorizationKey:be.value,print:{print:"1",type:"1",resolution:null==ye?void 0:ye.resolution},params:a,signature:ye.signature};he.downloadPDF(l,(e=>Ye(e,"preview")),He)})).catch((()=>{Qe("download"),Ze(!1)})).finally((()=>{Pe.visible=!1})))})(a,t,n,r);break;case"resetPrinter":(async(e=[],t,n,r)=>{if(!ye.showLoading||!et()){Ze(!0,r);try{const e=await he.resetPrinter(r,Pe.iReportExecuteMode);if(Ze(!1),"success"==(null==e?void 0:e.result))return void ge.success(e.message||"重置打印机成功");ge.warning("重置打印机失败")}catch(e){Ze(!1),ge.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,r)}},it=()=>{},at=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ut(n,t,e))})),n},lt=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ct(n,t,e))})),n},ot=(e,t,n)=>{const r={};return t.forEach((t=>{let i=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(r=A(t,n[e.type])),(null==e?void 0:e.defaultValue)||r})(t,e[t[n]]);e[t[n]]&&i&&(r[t[n]]=i)})),r},st=({customizeDataset:e=[],param:t=[]},n={})=>{let r={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;r.datasetData||(r.datasetData={}),r.datasetData[e.name]=JSON.stringify(ot(n,t,"fieldName"))})),r=Object.assign({},r,ot(n,t,"key")),r},ut=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r],a=n[i];if(!a)return ge.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(st(a,t))}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i],l=n[a];if(!l)return ge.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(st(l,t))}return e},ct=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r];if(!n[i])return ge.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(t)}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i];if(!n[a])return ge.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},dt=async e=>{var t;Pe.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],Pe.iReportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].iReportExecuteMode||1,(()=>{var e,t,n;const r=Object.keys(Re.value),i=Pe.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(r.includes(e.id)){const n=Re.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));Se.value.unshift(...i),Fe.value&&Se.value.push(...fe),(null==(t=null==(e=ye.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(Se.value.forEach((e=>{var t;(null==(t=ye.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Te.value=Se.value.filter((e=>e.selected))),Le.value=Se.value.filter((e=>!e.selected)),ye.hideButtons.length>0&&(Ie.value=Ie.value.filter((e=>!ye.hideButtons.includes(e.key))));const a=sessionStorage.getItem("portal");if(a){const e=JSON.parse(a),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},r=Object.keys(t);r.includes("RY7.2.21.1.M2.G94181E")||(Ie.value=Ie.value.filter((e=>"downloadPdf"!=e.key))),r.includes("RY7.2.21.1.M2.G33633A")||(Ie.value=Ie.value.filter((e=>"formatEditText"!=e.key))),r.includes("RY7.2.21.1.M2.G99314S")||(Ie.value=Ie.value.filter((e=>"resetPrinter"!=e.key)))}})(),Pe.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),Pe.printParams=at(Pe.templateParams,ye.params),Pe.originParams=lt(Pe.templateParams,ye.params),mt()},pt=async()=>{var e;if(Pe.isInited)return!0;Pe.isInited=!0,Pe.spinning=!0,(()=>{if(he)return!1;he=new U})();const t=await ye.queryPrintFormatByNumber();return await dt(t),(null==(e=t.obj)?void 0:e.length)>0&&(be.value=t.obj[0].authorizationKey||""),Pe.spinning=!1,!0},mt=async()=>{const e=Object.keys(Re.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],r=Re.value[n],{stop:i,signature:a}=B().register({label:r.code,shortcutSignature:r.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ae("button");const e=Ue.value.map((e=>e.key)),t=Pe.originParams;if(e.includes(n)){const e=Ue.value.find((e=>e.key==n));if(e){const n=Pe.printParams[null==e?void 0:e.templateCode],r=t[null==e?void 0:e.templateCode]||[];nt(n,e.templateCode,e.templateId,e.key,r)}}}});we.value[n]=i}},vt=async(e=!0)=>{if(await ye.clickPrevFn()){if(!Pe.visible){if(!await pt())return!1}e&&(Pe.visible=!Pe.visible)}},yt=e=>{if(Pe.identityVerification.visible=!1,z(Pe.currentFormatId))return Ye({result:"success",message:""},"edit");const t=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,Pe.curPrintParamList[0])),n="MULTI"===ye.strategy?t:Xe(Pe.curPrintParamList,xe.value),r={formatId:Pe.currentFormatId,templateId:Me.value,params:n,token:e};he.editPrintFormat(r,(e=>{Ye(e,"edit")}),He)},ft=(e,t)=>{const n=Te.value[t+1];return t<Te.value.length-1&&!Pe.printParams[e.templateCode]&&Pe.printParams[n.templateCode]};async function gt(){await vt(!1),(()=>{const e=Object.keys(Pe.printParams);Pe.isClickOuterPrint=!1;const t=Pe.originParams;if(1==De.value)for(let n=0;n<e.length;n++){const r=e[n],i=Pe.printParams[r],a=t[r]||[],l=Pe.formatList.filter((e=>e.number==r));l&&l.length>0&&l.forEach((e=>{Pe.currentFormatId=e.id,nt(i,e.number,e.templateId,e.id,a,!0)}))}2==De.value&&Te.value.forEach((e=>{const n=Pe.printParams[e.templateCode],r=t[e.templateCode]||[];Pe.currentFormatId=e.key,nt(n,e.templateCode,e.templateId,e.key,r,!0)}))})()}return a((()=>{Pe.isInited=!1,vt()})),l((()=>{const e=Object.keys(we.value);e.length>0&&e.forEach((e=>{we.value[e]&&we.value[e]()}))})),o((()=>ye.params),(e=>{Object.keys(Pe.templateParams).length>0&&(Pe.printParams=at(Pe.templateParams,ye.params),Pe.originParams=lt(Pe.templateParams,ye.params))}),{deep:!0}),o((()=>{var e;return null==(e=ye.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await vt(!1)}),{deep:!0,immediate:!0}),ve({directPrint:gt}),(t,n)=>(s(),u(c,null,[d("div",q,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:y((()=>[(s(!0),u(c,null,f(Te.value,((t,n)=>{return s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:it,options:(r=v(Ie),i=t,Pe.printParams[i.templateCode]?r:[]),onSelect:e=>rt(e,t,!0)},{default:y((()=>[m(v(j),{disabled:!Pe.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>tt(t.templateCode,t.templateId,t.key,!0),class:h(n==Te.value.length-1?"outerLastButton":ft(t,n)?"isPrintDisabled":"")},{icon:y((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:y((()=>[k(" "+b(t.label)+" ",1),t.shortcutLabel?(s(),u("span",G,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var r,i})),128))])),_:1}),p(" 外显设置按钮 "),Te.value.length>0&&Te.value.length==v(Ue).length&&v(Fe)&&2!=v(De)?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,show:Ce.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Ge("isOutSetting"))},{trigger:y((()=>[m(v(j),{class:h(Te.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>qe("isOutSetting"))},{default:y((()=>[Y,m(v(M),{style:{"margin-left":"8px"},component:v(_),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:y((()=>[d("div",H,[(s(!0),u(c,null,f(v(Ue),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",$,[d("span",Q,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",W,[m(v(F)),d("div",X,[m(v(j),{type:"primary",size:"small",onClick:Be},{default:y((()=>[k("保存")])),_:1}),v(Ue)&&v(Ue).length>1?(s(),g(v(E),{key:0,checked:v(ze),"onUpdate:checked":n[1]||(n[1]=e=>P(ze)?ze.value=e:null)},{default:y((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:1},8,["show"])):(s(),u(c,{key:1},[p(" 打印全部按钮 "),m(v(x),{trigger:"click","show-arrow":!1,show:Ce.oneShow,onClickoutside:n[10]||(n[10]=e=>Ge("oneShow"))},{trigger:y((()=>[w(t.$slots,"button",{handleClickPrintBtn:vt,printSpinning:Pe.spinning,printbtnText:e.btnText,printVisible:Pe.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ae("icon")),["stop"]))},{default:y((()=>[m(v(j),{loading:e.showLoading&&Pe.spinning,onClick:n[3]||(n[3]=S((()=>Ae("button")),["stop"])),class:h(Te.value.length>0?"printAllLeftCls":"")},{icon:y((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:y((()=>[k(" "+b(v(Ee)?"打印全部":e.btnText)+" ",1),v(Je)?(s(),u("span",Z,b(v(Je)),1)):p("v-if",!0)])),_:1},8,["loading","class"]),m(v(j),{class:"icon-select"},{icon:y((()=>[m(v(M),{component:v(D),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:y((()=>[d("div",ee,[(s(!0),u(c,null,f(Le.value,(e=>(s(),u("div",{class:h(["print-li",Oe.oneMouseType==e.key||Oe.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ve("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ve("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!Pe.printParams[n.templateCode])return[];Ve(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),g(v(F),{key:0})):"outSetting"==e.key?(s(),u(c,{key:1},[p(" 第二层外显设置 "),m(v(x),{trigger:"click","show-arrow":!1,placement:"right-start",show:Ce.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Ge("isOutSetting"))},{trigger:y((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>qe("isOutSetting"))},[d("span",ne,b(e.label),1),m(v(M),{color:Te.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:y((()=>[d("div",re,[(s(!0),u(c,null,f(v(Ue),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",ie,[d("span",ae,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",le,[m(v(F)),d("div",oe,[m(v(j),{type:"primary",size:"small",onClick:Be},{default:y((()=>[k("保存")])),_:1}),v(Ue)&&v(Ue).length>1?(s(),g(v(E),{key:0,checked:v(ze),"onUpdate:checked":n[6]||(n[6]=e=>P(ze)?ze.value=e:null)},{default:y((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(s(),u(c,{key:2},[p(" 第二层功能操作 "),d("div",{class:h(["print-lite",Pe.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>tt(e.templateCode,e.templateId,e.key,!1)},[k(b(e.label)+" ",1),e.shortcutLabel?(s(),u("span",ue,b(e.shortcutLabel),1)):p("v-if",!0)],8,se),Pe.printParams[e.templateCode]?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Ce[e.key],onClickoutside:t=>Ge(e.key)},{trigger:y((()=>[m(v(M),{component:v(R),size:"18",onClick:t=>qe(e.key)},null,8,["component","onClick"])])),default:y((()=>[d("div",ce,[(s(!0),u(c,null,f(v(Ie),(t=>(s(),u("div",{class:h(["print-li",Oe.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ve("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ve("twoMouseType",""))},[d("div",pe,[d("span",{class:"label",onClick:n=>rt(t.key,e,!1)},b(t.label),9,me)])],42,de)))),128))])])),_:2},1032,["show","onClickoutside"])):p("v-if",!0)],2)],2112))],42,te)))),128))])])),_:3},8,["show"])],2112))]),m(K,I(t.$attrs,{modelValue:Pe.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>Pe.identityVerification.visible=e),formatId:Pe.currentFormatId,templateId:v(Me),onSuccess:yt}),null,16,["modelValue","formatId","templateId"])],64))}});export{ve as default};
|
@@ -107,6 +107,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
107
107
|
placement: {
|
108
108
|
type: StringConstructor;
|
109
109
|
};
|
110
|
+
svrUpdateIp: {
|
111
|
+
type: StringConstructor;
|
112
|
+
};
|
110
113
|
}, {
|
111
114
|
$attrs: {
|
112
115
|
[x: string]: unknown;
|
@@ -220,6 +223,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
220
223
|
placement: {
|
221
224
|
type: StringConstructor;
|
222
225
|
};
|
226
|
+
svrUpdateIp: {
|
227
|
+
type: StringConstructor;
|
228
|
+
};
|
223
229
|
}>> & {}>>;
|
224
230
|
emit: any;
|
225
231
|
defaultFormatInfo: AnyObject;
|
@@ -562,6 +568,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
562
568
|
placement: {
|
563
569
|
type: StringConstructor;
|
564
570
|
};
|
571
|
+
svrUpdateIp: {
|
572
|
+
type: StringConstructor;
|
573
|
+
};
|
565
574
|
}>>, {
|
566
575
|
params: AnyObject[];
|
567
576
|
btnText: string;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as t,useAttrs as e,inject as n,ref as i,reactive as r,computed as a,onMounted as o,watch as l,openBlock as s,createElementBlock as p,Fragment as d,createVNode as u,unref as m,withCtx as c,renderSlot as f,withModifiers as v,createTextVNode as y,toDisplayString as g,mergeProps as b}from"vue";import{isObject as I}from"@vue/shared";import{useMessage as h,NDropdown as P,NButton as w,NIcon as F}from"naive-ui";import{ChevronDown as k}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as x}from"../constants/index.js";import{Print as T}from"../utils/print.js";import{isIReport as S}from"../utils/browserPrint.js";import E from"./IdentityVerification.vue.js";import{format as j}from"date-fns";import{savePrivateFormatApi as M,getPrivateFormatApi as O}from"../api.js";var L=t({__name:"OldPrintComponent",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},noDefaultFormatMsg:{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:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},printCustomProps:{type:Object,default:()=>({})},placement:{type:String}},setup(t,{expose:L}){var D;const R=t,C=e(),N=h();let V;const B=n(x),z={},A=i(""),J=r({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,iReportExecuteMode:1});let U=i([{label:R.printText,key:"printText"},{label:R.previewText,key:"previewText"},{label:R.pdfLoadText,key:"downloadPdf"},{label:R.formatEditText,key:"formatEditText"},...(null==(D=R.externalOptionConfig)?void 0:D.options)||[]]);const q=a((()=>{if(!J.currentFormatId)return{};let t=J.currentFormatId;return J.formatList.find((e=>e.id===t))})),K=a((()=>{var t;return(null==(t=q.value)?void 0:t.name)||"格式选择"})),_=a((()=>{let t=J.formatList.find((t=>t.id===J.currentFormatId));return null==t?void 0:t.templateId})),G=async t=>{if(R.directPrint){if(J.spinning)return;return"button"===t?void await ut():st()}return st()},H=t=>u("span",{class:{active:t.key===J.currentFormatId}},[t.label]),Y=(t,e)=>{J.spinning=!1;let n={type:e,formatId:J.currentFormatId,templateId:_.value};B("success",t,n)},$=t=>{J.spinning=!1,B("error",t),I(t)&&"notInstalledApp"===t.type&&N.error(t.message)},Q=t=>{J.spinning=!1,B("cancel",t)},W=t=>{B("error",{message:"前置条件执行错误",type:t,preExecution:!0})},X=(t=0)=>{var e;const n=(null==(e=R.printParams)?void 0:e.length)?R.printParams[t]:J.printParams[t];return JSON.stringify({...n||{},...R.token?{token:R.token}:{},...R.printCustomProps||{}})},Z=()=>{var t,e;let n={},i={};if(null==(t=J.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(J.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(J.printParams.map((e=>JSON.parse(e.datasetData[t]))));i={datasetData:{}},i.datasetData[t]=n}else Object.keys(J.printParams[0]).forEach((t=>{i[t]=[],J.printParams.forEach((e=>{i[t].includes(e[t])||i[t].push(e[t])})),i[t]=i[t].join(",")}));return n=Object.assign({},JSON.parse(X(0)),i),JSON.stringify(n)},tt=((t,e,n=!0)=>{let i=null;return function(...r){i&&clearTimeout(i),n&&!i&&t.apply(null,r),i=setTimeout((()=>{i=null,!n&&t.apply(null,r)}),e)}})((()=>{let t=J.printParams.length;const e=async e=>{try{--t<=0&&Y(e,"print")}catch(t){console.log("error",t)}};R.showLoading&&J.spinning||(J.spinning=!0,R.prevFn("print",{formatId:J.currentFormatId,templateId:_.value}).then((()=>{const t={iReportExecuteMode:J.iReportExecuteMode,formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,printdlgshow:R.printdlgshow,signature:R.signature,copies:R.printCopies};if("MULTI"===R.strategy)for(let n=0;n<J.printParams.length;n++)n>0&&(t.printdlgshow="0"),V.printDirect({...t,params:X(n)},e,$,Q);else V.printDirect({...t,params:Z()},(t=>{Y(t,"print")}),$,Q)})).catch((()=>{W("print"),J.spinning=!1})).finally((()=>{J.visible=!1})))}),800,!0),et=async(t,e)=>{var n,i;switch(t){case"printText":tt();break;case"previewText":(async()=>{R.showLoading&&J.spinning||(J.spinning=!0,R.prevFn("preview",{formatId:J.currentFormatId,templateId:_.value}).then((()=>{const t="MULTI"===R.strategy?X():Z(),e={formatId:J.currentFormatId,iReportExecuteMode:J.iReportExecuteMode,templateId:_.value,authorizationKey:A.value,params:t,btnprint:R.btnprint,signature:R.signature};V.preview(e,(t=>{Y(t,"preview")}),$)})).catch((()=>{W("preview"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;case"formatEditText":R.showLoading&&J.spinning||(J.spinning=!0,R.prevFn("edit",{formatId:J.currentFormatId,templateId:_.value}).then((()=>{J.identityVerification.visible=!0})).catch((()=>{W("edit")})).finally((()=>{J.visible=!1,J.spinning=!1})));break;case"downloadPdf":(async()=>{R.showLoading&&J.spinning||(J.spinning=!0,R.prevFn("download",{formatId:J.currentFormatId,templateId:_.value}).then((()=>{const t="MULTI"===R.strategy?X():Z(),e={formatId:J.currentFormatId,iReportExecuteMode:J.iReportExecuteMode,templateId:_.value,authorizationKey:A.value,print:{print:"1",type:"1",resolution:null==R?void 0:R.resolution},params:t,signature:R.signature};V.downloadPDF(e,(t=>Y(t,"preview")),$)})).catch((()=>{W("download"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;default:{J.visible=!1;const r=J.formatList.find((e=>e.id===t))||{};if(Object.keys(r).length>0){J.currentFormatId=t;const[e]=U.value;e.label=(null==r?void 0:r.name)||e.label,await M({formatForms:[{...r}],name:z.name||r.templateName,number:z.number||r.number,templateId:z.templateId||r.templateId,...z.id?{id:z.id}:{}},{token:R.token})}else null==(i=null==(n=R.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},nt=()=>{J.visible=!1,B("clickoutside")},it=()=>(J.isInited=!1,J.spinning=!1,setTimeout((()=>{J.visible=!1}),0),!1),rt=(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&&e instanceof Date&&(i=j(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},at=({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(rt(n,e,"fieldName"))}})),i=Object.assign({},i,rt(n,e,"key")),i})),ot=async t=>{var e,n;if(J.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):[],J.iReportExecuteMode=(null==(e=null==t?void 0:t.obj)?void 0:e.length)>0&&t.obj[0].iReportExecuteMode||1,J.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";if(!C.isDoc){const{data:e}=await O({templateId:t[0].templateId},{token:R.token});if("SUCCESS"===e.result){const{formatForms:i=[]}=e.map||{};Object.assign(z,e.map||{});const r=null==(n=null==i?void 0:i[0])?void 0:n.id;if(r&&t.map((t=>t.id)).includes(r))return r}}const i=t.find((t=>1==t[e]));return(null==i?void 0:i.id)||t[0].id})(J.formatList,"defaultFlag"),!J.currentFormatId)return U.value=[],N.error(R.noDefaultFormatMsg),it();(()=>{var t;const e=J.formatList.map((t=>({label:t.name,key:t.id})));U.value.unshift({label:K.value,key:"format",children:e}),R.hideButtons.length>0&&(U.value=U.value.filter((t=>!R.hideButtons.includes(t.key))));const n=sessionStorage.getItem("portal");if(n){const e=JSON.parse(n),i=(null==(t=null==e?void 0:e.user)?void 0:t.currentRoleResourceObj)||{},r=Object.keys(i);r.includes("RY7.2.21.1.M2.G94181E")||(U.value=U.value.filter((t=>"downloadPdf"!=t.key))),r.includes("RY7.2.21.1.M2.G33633A")||(U.value=U.value.filter((t=>"formatEditText"!=t.key)))}})();let i=null==(n=await R.queryTemplateParams())?void 0:n.obj;if(!i||!_.value)return N.error("获取打印模板失败,请联系管理员!"),it();J.templateParams=i,J.printParams=at(J.templateParams,R.params)},lt=async()=>{var t;if(J.isInited)return!0;J.isInited=!0,J.spinning=!0,(()=>{if(V)return!1;V=new T})();const e=await R.queryPrintFormatByNumber();return await ot(e),(null==(t=e.obj)?void 0:t.length)>0&&(A.value=e.obj[0].authorizationKey||""),J.spinning=!1,!0},st=async(t=!0)=>{var e,n;if(await R.clickPrevFn())if((null==(e=R.params)?void 0:e.length)||(null==(n=R.printParams)?void 0:n.length)){if(!J.visible){if(!await lt())return!1}t&&(J.visible=!J.visible)}else N.warning(R.noDataMsg)},pt=()=>{J.watchPrintParamsReformatFn&&J.watchPrintParamsReformatFn(),J.isInited?J.printParams=at(J.templateParams,R.params):J.watchPrintParamsReformatFn=()=>l((()=>J.isInited),(t=>{if(!t)return!1;pt()}))},dt=t=>{if(J.identityVerification.visible=!1,S(J.currentFormatId))return Y(null,"edit");const e={formatId:J.currentFormatId,templateId:_.value,params:X(),token:t};V.editPrintFormat(e,(t=>{Y(t,"edit")}),$)};async function ut(){await st(!1),tt()}return o((()=>{J.isInited=!1})),l((()=>R.params),(t=>{if(!(null==t?void 0:t.length))return!1;pt()}),{deep:!0}),L({directPrint:ut}),(e,n)=>(s(),p(d,null,[u(m(P),{class:"c-dropdown",placement:t.placement,trigger:"click",show:J.visible,onClickoutside:nt,options:m(U),onSelect:et,"render-label":H},{default:c((()=>[f(e.$slots,"button",{handleClickPrintBtn:st,printSpinning:J.spinning,printbtnText:t.btnText,printVisible:J.visible},(()=>[u(m(w),{class:"dropdown-button",loading:t.showLoading&&J.spinning,onClick:n[1]||(n[1]=v((()=>G("button")),["stop"]))},{default:c((()=>[y(g(t.btnText)+" ",1),u(m(F),{component:m(k),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=v((()=>G("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["placement","show","options"]),u(E,b(m(C),{modelValue:J.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>J.identityVerification.visible=t),formatId:J.currentFormatId,templateId:m(_),onSuccess:dt}),null,16,["modelValue","formatId","templateId"])],64))}});export{L as default};
|
1
|
+
import{defineComponent as t,useAttrs as e,inject as n,ref as r,reactive as i,computed as a,onMounted as o,watch as l,openBlock as s,createElementBlock as p,Fragment as d,createVNode as u,unref as m,withCtx as c,renderSlot as f,withModifiers as v,createTextVNode as y,toDisplayString as g,mergeProps as b}from"vue";import{isObject as I}from"@vue/shared";import{useMessage as h,NDropdown as P,NButton as w,NIcon as F}from"naive-ui";import{ChevronDown as k}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as x}from"../constants/index.js";import{Print as T}from"../utils/print.js";import{isIReport as S}from"../utils/browserPrint.js";import E from"./IdentityVerification.vue.js";import{format as j}from"date-fns";import{savePrivateFormatApi as M,getPrivateFormatApi as O}from"../api.js";var L=t({__name:"OldPrintComponent",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},noDefaultFormatMsg:{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:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},printCustomProps:{type:Object,default:()=>({})},placement:{type:String},svrUpdateIp:{type:String}},setup(t,{expose:L}){var D;const R=t,C=e(),N=h();let V;const U=n(x),B={},z=r(""),A=i({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,iReportExecuteMode:1});let J=r([{label:R.printText,key:"printText"},{label:R.previewText,key:"previewText"},{label:R.pdfLoadText,key:"downloadPdf"},{label:R.formatEditText,key:"formatEditText"},...(null==(D=R.externalOptionConfig)?void 0:D.options)||[]]);const q=a((()=>{if(!A.currentFormatId)return{};let t=A.currentFormatId;return A.formatList.find((e=>e.id===t))})),K=a((()=>{var t;return(null==(t=q.value)?void 0:t.name)||"格式选择"})),_=a((()=>{let t=A.formatList.find((t=>t.id===A.currentFormatId));return null==t?void 0:t.templateId})),G=async t=>{if(R.directPrint){if(A.spinning)return;return"button"===t?void await ut():st()}return st()},H=t=>u("span",{class:{active:t.key===A.currentFormatId}},[t.label]),Y=(t,e)=>{A.spinning=!1;let n={type:e,formatId:A.currentFormatId,templateId:_.value};U("success",t,n)},$=t=>{A.spinning=!1,U("error",t),I(t)&&"notInstalledApp"===t.type&&N.error(t.message)},Q=t=>{A.spinning=!1,U("cancel",t)},W=t=>{U("error",{message:"前置条件执行错误",type:t,preExecution:!0})},X=(t=0)=>{var e;const n=(null==(e=R.printParams)?void 0:e.length)?R.printParams[t]:A.printParams[t];return JSON.stringify({...n||{},...R.token?{token:R.token}:{},...R.printCustomProps||{}})},Z=()=>{var t,e;let n={},r={};if(null==(t=A.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(A.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(A.printParams.map((e=>JSON.parse(e.datasetData[t]))));r={datasetData:{}},r.datasetData[t]=n}else Object.keys(A.printParams[0]).forEach((t=>{r[t]=[],A.printParams.forEach((e=>{r[t].includes(e[t])||r[t].push(e[t])})),r[t]=r[t].join(",")}));return n=Object.assign({},JSON.parse(X(0)),r),JSON.stringify(n)},tt=((t,e,n=!0)=>{let r=null;return function(...i){r&&clearTimeout(r),n&&!r&&t.apply(null,i),r=setTimeout((()=>{r=null,!n&&t.apply(null,i)}),e)}})((()=>{let t=A.printParams.length;const e=async e=>{try{--t<=0&&Y(e,"print")}catch(t){console.log("error",t)}};R.showLoading&&A.spinning||(A.spinning=!0,R.prevFn("print",{formatId:A.currentFormatId,templateId:_.value}).then((()=>{const t={iReportExecuteMode:A.iReportExecuteMode,formatId:A.currentFormatId,templateId:_.value,authorizationKey:z.value,printdlgshow:R.printdlgshow,signature:R.signature,copies:R.printCopies,svrUpdateIp:R.svrUpdateIp};if("MULTI"===R.strategy)for(let n=0;n<A.printParams.length;n++)n>0&&(t.printdlgshow="0"),V.printDirect({...t,params:X(n)},e,$,Q);else V.printDirect({...t,params:Z()},(t=>{Y(t,"print")}),$,Q)})).catch((()=>{W("print"),A.spinning=!1})).finally((()=>{A.visible=!1})))}),800,!0),et=async(t,e)=>{var n,r;switch(t){case"printText":tt();break;case"previewText":(async()=>{R.showLoading&&A.spinning||(A.spinning=!0,R.prevFn("preview",{formatId:A.currentFormatId,templateId:_.value}).then((()=>{const t="MULTI"===R.strategy?X():Z(),e={formatId:A.currentFormatId,iReportExecuteMode:A.iReportExecuteMode,templateId:_.value,authorizationKey:z.value,params:t,btnprint:R.btnprint,signature:R.signature};V.preview(e,(t=>{Y(t,"preview")}),$)})).catch((()=>{W("preview"),A.spinning=!1})).finally((()=>{A.visible=!1})))})();break;case"formatEditText":R.showLoading&&A.spinning||(A.spinning=!0,R.prevFn("edit",{formatId:A.currentFormatId,templateId:_.value}).then((()=>{A.identityVerification.visible=!0})).catch((()=>{W("edit")})).finally((()=>{A.visible=!1,A.spinning=!1})));break;case"downloadPdf":(async()=>{R.showLoading&&A.spinning||(A.spinning=!0,R.prevFn("download",{formatId:A.currentFormatId,templateId:_.value}).then((()=>{const t="MULTI"===R.strategy?X():Z(),e={formatId:A.currentFormatId,iReportExecuteMode:A.iReportExecuteMode,templateId:_.value,authorizationKey:z.value,print:{print:"1",type:"1",resolution:null==R?void 0:R.resolution},params:t,signature:R.signature};V.downloadPDF(e,(t=>Y(t,"preview")),$)})).catch((()=>{W("download"),A.spinning=!1})).finally((()=>{A.visible=!1})))})();break;default:{A.visible=!1;const i=A.formatList.find((e=>e.id===t))||{};if(Object.keys(i).length>0){A.currentFormatId=t;const[e]=J.value;e.label=(null==i?void 0:i.name)||e.label,await M({formatForms:[{...i}],name:B.name||i.templateName,number:B.number||i.number,templateId:B.templateId||i.templateId,...B.id?{id:B.id}:{}},{token:R.token})}else null==(r=null==(n=R.externalOptionConfig)?void 0:n.onSelect)||r.call(n,t,e);break}}},nt=()=>{A.visible=!1,U("clickoutside")},rt=()=>(A.isInited=!1,A.spinning=!1,setTimeout((()=>{A.visible=!1}),0),!1),it=(t,e,n)=>{const r={};return e.forEach((e=>{let i=((t,e)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=e;return Object.keys(n).includes(t.type)&&e&&e instanceof Date&&(r=j(e,n[t.type])),(null==t?void 0:t.defaultValue)||r})(e,t[e[n]]);t[e[n]]&&i&&(r[e[n]]=i)})),r},at=({customizeDataset:t=[],param:e=[]},n=[])=>n.map((n=>{let r={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;r.datasetData={[t.name]:JSON.stringify(it(n,e,"fieldName"))}})),r=Object.assign({},r,it(n,e,"key")),r})),ot=async t=>{var e,n;if(A.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):[],A.iReportExecuteMode=(null==(e=null==t?void 0:t.obj)?void 0:e.length)>0&&t.obj[0].iReportExecuteMode||1,A.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";if(!C.isDoc){const{data:e}=await O({templateId:t[0].templateId},{token:R.token});if("SUCCESS"===e.result){const{formatForms:r=[]}=e.map||{};Object.assign(B,e.map||{});const i=null==(n=null==r?void 0:r[0])?void 0:n.id;if(i&&t.map((t=>t.id)).includes(i))return i}}const r=t.find((t=>1==t[e]));return(null==r?void 0:r.id)||t[0].id})(A.formatList,"defaultFlag"),!A.currentFormatId)return J.value=[],N.error(R.noDefaultFormatMsg),rt();(()=>{var t;const e=A.formatList.map((t=>({label:t.name,key:t.id})));J.value.unshift({label:K.value,key:"format",children:e}),R.hideButtons.length>0&&(J.value=J.value.filter((t=>!R.hideButtons.includes(t.key))));const n=sessionStorage.getItem("portal");if(n){const e=JSON.parse(n),r=(null==(t=null==e?void 0:e.user)?void 0:t.currentRoleResourceObj)||{},i=Object.keys(r);i.includes("RY7.2.21.1.M2.G94181E")||(J.value=J.value.filter((t=>"downloadPdf"!=t.key))),i.includes("RY7.2.21.1.M2.G33633A")||(J.value=J.value.filter((t=>"formatEditText"!=t.key)))}})();let r=null==(n=await R.queryTemplateParams())?void 0:n.obj;if(!r||!_.value)return N.error("获取打印模板失败,请联系管理员!"),rt();A.templateParams=r,A.printParams=at(A.templateParams,R.params)},lt=async()=>{var t;if(A.isInited)return!0;A.isInited=!0,A.spinning=!0,(()=>{if(V)return!1;V=new T})();const e=await R.queryPrintFormatByNumber();return await ot(e),(null==(t=e.obj)?void 0:t.length)>0&&(z.value=e.obj[0].authorizationKey||""),A.spinning=!1,!0},st=async(t=!0)=>{var e,n;if(await R.clickPrevFn())if((null==(e=R.params)?void 0:e.length)||(null==(n=R.printParams)?void 0:n.length)){if(!A.visible){if(!await lt())return!1}t&&(A.visible=!A.visible)}else N.warning(R.noDataMsg)},pt=()=>{A.watchPrintParamsReformatFn&&A.watchPrintParamsReformatFn(),A.isInited?A.printParams=at(A.templateParams,R.params):A.watchPrintParamsReformatFn=()=>l((()=>A.isInited),(t=>{if(!t)return!1;pt()}))},dt=t=>{if(A.identityVerification.visible=!1,S(A.currentFormatId))return Y(null,"edit");const e={formatId:A.currentFormatId,templateId:_.value,params:X(),token:t};V.editPrintFormat(e,(t=>{Y(t,"edit")}),$)};async function ut(){await st(!1),tt()}return o((()=>{A.isInited=!1})),l((()=>R.params),(t=>{if(!(null==t?void 0:t.length))return!1;pt()}),{deep:!0}),L({directPrint:ut}),(e,n)=>(s(),p(d,null,[u(m(P),{class:"c-dropdown",placement:t.placement,trigger:"click",show:A.visible,onClickoutside:nt,options:m(J),onSelect:et,"render-label":H},{default:c((()=>[f(e.$slots,"button",{handleClickPrintBtn:st,printSpinning:A.spinning,printbtnText:t.btnText,printVisible:A.visible},(()=>[u(m(w),{class:"dropdown-button",loading:t.showLoading&&A.spinning,onClick:n[1]||(n[1]=v((()=>G("button")),["stop"]))},{default:c((()=>[y(g(t.btnText)+" ",1),u(m(F),{component:m(k),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=v((()=>G("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["placement","show","options"]),u(E,b(m(C),{modelValue:A.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>A.identityVerification.visible=t),formatId:A.currentFormatId,templateId:m(_),onSuccess:dt}),null,16,["modelValue","formatId","templateId"])],64))}});export{L as default};
|
@@ -36,7 +36,7 @@ export declare class Print {
|
|
36
36
|
showPreview(...args: Parameters<PreviewDialog['show']>): Promise<string>;
|
37
37
|
_testDomesticSystemConnection(): Promise<unknown>;
|
38
38
|
_testConnection(): Promise<unknown>;
|
39
|
-
resetPrinter(
|
39
|
+
resetPrinter(originFormatId: string, iReportExecuteMode: number): Promise<any>;
|
40
40
|
_queryServicesPrint(params: AnyObject): Promise<any>;
|
41
41
|
_queryBase64ServicesPrint(params: AnyObject): Promise<any>;
|
42
42
|
_callPrintWithFile(queryParams: AnyObject): Promise<any>;
|
@@ -55,25 +55,26 @@ export declare class Print {
|
|
55
55
|
pageCount: any;
|
56
56
|
formatId: string;
|
57
57
|
};
|
58
|
-
_handleEventDirect({ templateId, formatId, params, paramsArr, cmdid, print, signature, copies, printdlgshow, nobillnode, btnprint, messageTimeout }: AnyObject): Promise<any>;
|
58
|
+
_handleEventDirect({ templateId, formatId, svrUpdateIp, params, paramsArr, cmdid, print, signature, copies, printdlgshow, nobillnode, btnprint, messageTimeout }: AnyObject): Promise<any>;
|
59
59
|
_handleEventEditFormat({ templateId, formatId, params, token, messageTimeout }: AnyObject): Promise<any>;
|
60
60
|
_queryProxyOrigin(): Promise<void>;
|
61
61
|
_queryPrintFile(formatId: string, params?: string): Promise<any>;
|
62
62
|
paramsSerializer(params: AnyObject): AnyObject;
|
63
63
|
getIReportFormatId: (isIReport: boolean, formatId: string) => string;
|
64
64
|
_queryPrintForBase64(templateId: string, formatId: string, params: string | undefined, authorizationKey: String): Promise<any>;
|
65
|
+
_queryPrintForBase16(templateId: string, formatId: string, params: string | undefined, authorizationKey: String): Promise<any>;
|
65
66
|
_queryPrintForPdf(templateId: string, formatId: string, params: string | undefined, authorizationKey: String): Promise<any>;
|
66
67
|
_browserPrint(result: AnyObject, mode: string): Promise<string | void>;
|
67
68
|
_base64ToBlob(fileBase64: string, fileType: string): Blob;
|
68
|
-
preview({ iReportExecuteMode, templateId, formatId, params, paramsArr, authorizationKey, signature, btnprint, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<any>;
|
69
|
+
preview({ iReportExecuteMode, templateId, formatId: originFormatId, params, paramsArr, authorizationKey, signature, btnprint, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<any>;
|
69
70
|
printSync(data: AnyObject[], successCallbackFn: AnyFn, errorCallbackFn: AnyFn): Promise<void>;
|
70
|
-
printDirect({ iReportExecuteMode, templateId, formatId, params, paramsArr, authorizationKey, print, signature, printdlgshow, nobillnode, copies, isDownloadFile, messageTimeout }: AnyObject, successCallbackFn: AnyFn, errorCallbackFn: AnyFn, cancelCallbackFn?: AnyFn, mode?: string): Promise<false | undefined>;
|
71
|
+
printDirect({ iReportExecuteMode, templateId, formatId: originFormatId, params, paramsArr, authorizationKey, print, signature, printdlgshow, nobillnode, copies, svrUpdateIp, isDownloadFile, messageTimeout }: AnyObject, successCallbackFn: AnyFn, errorCallbackFn: AnyFn, cancelCallbackFn?: AnyFn, mode?: string): Promise<false | undefined>;
|
71
72
|
printToHiPrint({ templateId, formatId, params, authorizationKey }: any, successCallbackFn: AnyFn, errorCallbackFn: AnyFn, cancelCallbackFn?: AnyFn): Promise<any>;
|
72
73
|
private _downloadPDF;
|
73
74
|
/**
|
74
75
|
* 下载pdf
|
75
76
|
*/
|
76
|
-
downloadPDF(
|
77
|
+
downloadPDF(paramsObj: AnyObject, onResolve: AnyFn, onReject: AnyFn): Promise<any>;
|
77
78
|
print({ templateId, formatId, params, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<false | undefined>;
|
78
79
|
queryPrintData({ templateId, formatId, params, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<false | {
|
79
80
|
file: any;
|
@@ -1 +1 @@
|
|
1
|
-
import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as r,useBrowserPrint as n,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as c}from"date-fns";import{io as h}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),p=`${window.location.protocol}//${window.location.host}`,d=`${p}/fdp-api/print/assembly/printIReport`,g=`${p}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${p}/bi-api/reprot/print/open/client/previewIReport`,y=`${p}/bi-api/reprot/print/open/client/getRemote`,w=`${p}/printService/file`;let P=null;class v{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this;const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=h(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","cancel"==(null==t?void 0:t.result)?this._cancelCallbackFn&&this._cancelCallbackFn(t):this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("hiprint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{m({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}resetPrinter(t){return this.webview?this.postMessage({exec:"resetprint",data:{formatID:t}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:t}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:"error",errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({result:"error",type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o,printdlgshow:l="0",nobillnode:h="1",btnprint:u="1",messageTimeout:m=0}){const p={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:u,copies:o,messageTimeout:m,...a?{signature:a}:{}};if(s&&(p.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}p.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");p.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=p,await this._queryServicesPrint(p)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:r=0}){const n={};let a={};try{a=Object.assign({},n,JSON.parse(i))}catch(t){a=n}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:r};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:y})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=p+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:d,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}paramsSerializer(t){return Object.keys(t).forEach((e=>{const i=t[e];t[e]=i,"biParams"==e&&(t[e]=encodeURIComponent(i))})),t}async _queryPrintForBase64(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:g,params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _queryPrintForPdf(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:f,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await r(`${w}/${a}/${o}`),c=n(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let s=i.length;const r=new Uint8Array(s);for(;s--;)r[s]=i.charCodeAt(s);return new Blob([r],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:l,signature:c,btnprint:h,messageTimeout:m=0},p,d){const g=a(i);if(i=this.getIReportFormatId(g,i),g&&(u||2==t)){const t=await this._queryPrintForPdf(e,i,s,l);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const r=n(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,r),null==p?void 0:p({result:"success",message:"",file:t})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:m}),n=this._handleResult(t,d);if(!n)return!1;if(this.isRemote){const t=await this._browserPrint(n,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}await this.getPicAndUpload(n),null==p||p(n)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:"error",errinfo:t})}}catch(t){const e={error:t,result:"error",message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({iReportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:m,isDownloadFile:p=!0,messageTimeout:d=0},g,f,y,w="printDirect"){const P=a(i);if(i=this.getIReportFormatId(P,i),P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notOpenedApp",result:"error",message:"请开启hiPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},g,f,y):f({type:"connectAppFail",result:"error",message:"连接hiPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},g,f,y))}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:m,messageTimeout:d}),n=this._handleResult(t,f,y);if(!n)return!1;p&&["downloadPDF"].includes(w)&&await this._browserPrint(n,w),null==g||g(n)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:s},r,n,a){const o=await this._queryPrintForBase64(t,e,i,s);if(!o.success)return n({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=r,this._errorCallbackFn=n,a&&(this._cancelCallbackFn=a),this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:c,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=c(new Date,"yyyy-MM-dd"),i=l(),s=c(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}const r=a(t.formatId);if(t.formatId=this.getIReportFormatId(r,t.formatId),r&&(u||2==t.iReportExecuteMode)){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e,result:"success",message:""})):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(t,(async t=>{t||s({result:"error",message:""});const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
|
1
|
+
import t from"axios";import{cloneDeep as e,isArray as i}from"lodash-es";import{IdentityVerificationDialog as r,PreviewDialog as s}from"./dialog.js";import{isIReport as a,getFileUrl as n,useBrowserPrint as o}from"./browserPrint.js";import{getCurrentInstance as l}from"vue";import{uuidGenerator as c}from"../../../../shared/utils/index.js";import{format as h}from"date-fns";import{io as p}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,g=`${d}/fdp-api/print/assembly/printIReport`,y=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${d}/bi-api/reprot/print/open/client/printIReportForHex`,w=`${d}/bi-api/reprot/print/open/client/previewIReport`,v=`${d}/bi-api/reprot/print/open/client/getRemote`,P=`${d}/printService/file`;let _=null;class b{constructor(){var t,e,i;if(this.webview=null,this.dialog=new r,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,_)return _;_=this;const a=window;this.CMonitor=a.$CMonitor;try{this.webview=a.top?null==(t=a.top.chrome)?void 0:t.webview:null==(e=a.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(i=a.chrome)?void 0:i.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:r,reject:s}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void r({result:(null==i?void 0:i.res)?"success":"fail"});r(i.res||"")}catch(t){s(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=p(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","cancel"==(null==t?void 0:t.result)?this._cancelCallbackFn&&this._cancelCallbackFn(t):this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("ihoPrint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=c();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)})),new Promise(((e,r)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),r({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{m({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}async resetPrinter(t,e){const i=a(t),r=this.getIReportFormatId(i,t);if(i&&(u||2==e)){return await this._testDomesticSystemConnection()?m({url:`${this.printDomesticOrigin}/resetPrint`,method:"get",withCredentials:!1,params:{formatId:r}}).then((({data:t})=>t.status?{type:"resetSuccess",result:"success",message:null==t?void 0:t.message}:{type:"resetError",result:"error",message:null==t?void 0:t.message})).catch((t=>({type:"resetError",result:"error",message:"重置打印机错误"}))):{type:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"}}return this.webview?this.postMessage({exec:"resetprint",data:{formatID:r}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:r}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:r(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[r]}).then((({data:t})=>t));function r(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:"error",errinfo:t}),!1}if("success"!==t.result){const r=t.message||t.Message;this._handleMonitorNotify(r);const s={type:"printError",message:r,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:r,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(s),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,r,s){const a={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:r},n=await this._queryServicesPrint(a);return this._handleQueryPrintDataResult(n,e,s)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({result:"error",type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,svrUpdateIp:i,params:r,paramsArr:s,cmdid:a,print:n,signature:o,copies:l,printdlgshow:c="0",nobillnode:p="1",btnprint:u="1",messageTimeout:m=0}){const d={templateId:t,formatId:e,svrUpdateIp:i,params:r,cmdid:a,nobillnode:p,printdlgshow:c,btnprint:u,copies:l,messageTimeout:m,...o?{signature:o}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=h(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=d,await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:r,messageTimeout:s=0}){const a={};let n={};try{n=Object.assign({},a,JSON.parse(i))}catch(t){n=a}const o={templateId:t,formatId:e,cmdid:"9",token:r,params:JSON.stringify(n),messageTimeout:s};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:v})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:g,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}paramsSerializer(t){return Object.keys(t).forEach((e=>{const i=t[e];t[e]=i,"biParams"==e&&(t[e]=encodeURIComponent(i))})),t}async _queryPrintForBase64(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:y,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForBase16(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:f,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForPdf(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:w,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,r=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),s=r[r.length-2],a=r[r.length-1],l=await n(`${P}/${s}/${a}`),c=o(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let r=i.length;const s=new Uint8Array(r);for(;r--;)s[r]=i.charCodeAt(r);return new Blob([s],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,signature:c,btnprint:h,messageTimeout:p=0},m,d){const g=a(i),y=this.getIReportFormatId(g,i);if(g&&(u||2==t)){const t=await this._queryPrintForPdf(e,y,r,n);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const i=o(t,"preview");return this.instance||(this.instance=l()),this.showPreview(this.instance,i),null==m?void 0:m({result:"success",message:"",file:t})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:y,params:r,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),i=this._handleResult(t,d);if(!i)return!1;if(this.isRemote){const t=await this._browserPrint(i,"preview");this.instance||(this.instance=l()),this.showPreview(this.instance,t)}await this.getPicAndUpload(i),null==m||m(i)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const r=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=c(),s=await this.messageCollect(t,{exec:"printA",data:r});if(s&&Array.isArray(s)){s.some((t=>"success"===t.res.result))?null==e||e(s):(null==i||i(s),this._handleMonitorNotify(s))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(s||""),null==i||i({type:"printError",message:t,result:"error",errinfo:t})}}catch(t){const e={error:t,result:"error",message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,isDownloadFile:d=!0,messageTimeout:g=0},y,f,w,v="printDirect"){const P=a(i),_=this.getIReportFormatId(P,i);if(P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w):f({type:"connectAppFail",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w))}await this._queryProxyOrigin();const b=await this._testConnection();if(!this._handleResultTest(b,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:_,params:r,paramsArr:s,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,messageTimeout:g}),i=this._handleResult(t,f,w);if(!i)return!1;d&&["downloadPDF"].includes(v)&&await this._browserPrint(i,v),null==y||y(i)}catch(t){const e="printDirect"===v?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:r},s,a,n){const o=await this._queryPrintForBase64(t,e,i,r);if(!o.success)return a({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=s,this._errorCallbackFn=a,n&&(this._cancelCallbackFn=n),this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:c,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,r,s){var n;const o=e(t);if(this.webview&&this.downloadPath&&(Reflect.has(o,"print")||Reflect.set(o,"print",{print:"1",type:"1"}),!o.print.filename)){const t=h(new Date,"yyyy-MM-dd"),e=c(),i=h(new Date,"yyyyMMddHHmmss")+e;o.print.filename=`${this.downloadPath}/${t}/${i}/${i}`.replace(/\\/g,"/")}const l=a(o.formatId);if(o.formatId=this.getIReportFormatId(l,o.formatId),l&&(u||2==o.iReportExecuteMode)){const t=await this._queryPrintForBase16(o.templateId||"",o.formatId,o.params||"",o.authorizationKey);return(null==t?void 0:t.success)?r({filebase64:null==(n=null==t?void 0:t.map)?void 0:n.hex,isIreport:!0}):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(o,(async t=>{t||s({result:"error",message:""});const e=this,a=await async function(t){const r=[],s=JSON.parse(t);if(!i(s))return await e._downloadPDF("");if(1===s.length)return await e._downloadPDF(s[0]||"");for(let t=0,i=s.length;t<i;t++)r.push(await e._downloadPDF(s[t]||""));return r}(t.filedir);r(a,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:r},void 0,a);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,a);if(!l)return!1;s&&s(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this._handleEventQueryPrintData(t,e,i,r,a);return!!o&&(s&&s(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(n,s);return!!o&&(r&&r(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s=0},a,n){const o=await this._testConnection();if(!this._handleResultTest(o,n))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s}),c=this._handleResult(l,n);if(!c)return!1;a&&a(c)}async addPrintFormat({templateId:t,params:e,token:i},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(n,s);if(!o)return!1;r&&r(o)}}export{b as Print};
|