cnhis-design-vue 3.2.7 → 3.2.8-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +87 -87
  2. package/es/components/button-print/index.d.ts +2 -0
  3. package/es/components/button-print/src/ButtonPrint.vue.d.ts +2 -0
  4. package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +1 -0
  5. package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
  6. package/es/components/button-print/src/components/OldPrintComponent.vue.d.ts +1 -0
  7. package/es/components/button-print/src/components/OldPrintComponent.vue2.js +1 -1
  8. package/es/components/button-print/src/utils/print.d.ts +2 -2
  9. package/es/components/button-print/src/utils/print.js +1 -1
  10. package/es/components/classification/src/components/table-modal/index.vue.d.ts +3 -0
  11. package/es/components/field-set/src/FieldColor.vue.d.ts +12 -1
  12. package/es/components/field-set/src/FieldColor.vue2.js +1 -1
  13. package/es/components/field-set/src/FieldFilter.vue.d.ts +12 -1
  14. package/es/components/field-set/src/FieldFilter.vue2.js +1 -1
  15. package/es/components/field-set/src/FieldSet.vue.d.ts +24 -2
  16. package/es/components/field-set/src/FieldSet.vue2.js +1 -1
  17. package/es/components/field-set/src/components/{Row.vue.d.ts → table-row.vue.d.ts} +12 -1
  18. package/es/components/field-set/src/components/table-row.vue.js +1 -0
  19. package/es/components/field-set/src/components/table-row.vue2.js +1 -0
  20. package/es/components/form-render/src/components/renderer/searchCascade.js +1 -1
  21. package/es/components/iho-chat/index.d.ts +133 -21
  22. package/es/components/iho-chat/src/Index.vue.d.ts +133 -21
  23. package/es/components/iho-chat/src/Index.vue2.js +1 -1
  24. package/es/components/iho-chat/src/api/index.d.ts +1 -0
  25. package/es/components/iho-chat/src/api/index.js +1 -1
  26. package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +2 -2
  27. package/es/components/iho-chat/src/components/ChatAdd.vue2.js +1 -1
  28. package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +3 -7
  29. package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +126 -8
  30. package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +0 -3
  31. package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
  32. package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +125 -3
  33. package/es/components/iho-chat/src/components/ChatSet.vue2.js +1 -1
  34. package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +2 -2
  35. package/es/components/iho-chat/src/components/MultipleVideo.vue2.js +1 -1
  36. package/es/components/iho-chat/src/components/PersonProfile.vue.d.ts +0 -3
  37. package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
  38. package/es/components/iho-chat/src/components/SiderList.vue2.js +1 -1
  39. package/es/components/iho-chat/src/hooks/useSession.js +1 -1
  40. package/es/components/iho-chat/src/types/index.d.ts +5 -0
  41. package/es/components/iho-chat/style/index.css +1 -1
  42. package/es/components/index.css +1 -1
  43. package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
  44. package/es/components/select-label/src/LabelFormContent.vue2.js +1 -1
  45. package/es/env.d.ts +25 -25
  46. package/es/shared/assets/img/defaultCover/10review_successful.png.js +1 -1
  47. package/es/shared/assets/img/defaultCover/11review_fail.png.js +1 -1
  48. package/es/shared/assets/img/defaultCover/12no_setting.png.js +1 -1
  49. package/es/shared/assets/img/defaultCover/13no_menu_setting.png.js +1 -1
  50. package/es/shared/assets/img/defaultCover/14no_call_setting.png.js +1 -1
  51. package/es/shared/assets/img/defaultCover/15no_use_tag.png.js +1 -1
  52. package/es/shared/assets/img/defaultCover/16no_table_data.png.js +1 -1
  53. package/es/shared/assets/img/defaultCover/1location.png.js +1 -1
  54. package/es/shared/assets/img/defaultCover/2notfound.png.js +1 -1
  55. package/es/shared/assets/img/defaultCover/3loading.png.js +1 -1
  56. package/es/shared/assets/img/defaultCover/4no_permission.png.js +1 -1
  57. package/es/shared/assets/img/defaultCover/5no_data.png.js +1 -1
  58. package/es/shared/assets/img/defaultCover/6no_network.png.js +1 -1
  59. package/es/shared/assets/img/defaultCover/7no_doctor.png.js +1 -1
  60. package/es/shared/assets/img/defaultCover/8system_error.png.js +1 -1
  61. package/es/shared/assets/img/defaultCover/9system_upgrade.png.js +1 -1
  62. package/es/shared/assets/img/failure.png.js +1 -1
  63. package/es/shared/assets/img/no-permission.png.js +1 -1
  64. package/es/shared/assets/img/nodata.png.js +1 -1
  65. package/es/shared/assets/img/notfound.png.js +1 -1
  66. package/es/shared/assets/img/qr.png.js +1 -1
  67. package/es/shared/assets/img/success.png.js +1 -1
  68. package/es/shared/assets/img/table_style_2.png.js +1 -1
  69. package/es/shared/assets/img/video.png.js +1 -1
  70. package/es/shared/assets/img/video_default_cover.png.js +1 -1
  71. package/es/shared/assets/img/xb_big.png.js +1 -1
  72. package/es/shared/assets/img/xb_small.png.js +1 -1
  73. package/es/shared/package.json.js +1 -1
  74. package/package.json +2 -2
  75. package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
  76. package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +0 -1
  77. package/es/components/bpmn-workflow/types/ModelingModule.d.ts +0 -1
  78. package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +0 -1
  79. package/es/components/field-set/src/components/Row.vue.js +0 -1
  80. package/es/components/field-set/src/components/Row.vue2.js +0 -1
  81. package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +0 -86
  82. package/es/shared/utils/fabricjs/index.d.ts +0 -6823
  83. package/es/shared/utils/tapable/index.d.ts +0 -139
package/README.md CHANGED
@@ -1,87 +1,87 @@
1
- # 安装
2
-
3
- ```shell
4
- npm i cnhis-design-vue@[版本号]
5
- # or
6
- yarn add cnhis-design-vue@[版本号] #推荐
7
- ```
8
-
9
- ## 1.全局引入
10
-
11
- ```typescript
12
- // main.ts
13
- import { createApp } from 'vue';
14
- import App from './App.vue';
15
- import 'cnhis-design-vue/es/packages/index.css';
16
- import cui from 'cnhis-design-vue';
17
-
18
- const app = createApp(App);
19
- app.use(cui).mount('#app');
20
- ```
21
-
22
- ## 2. 按需引入
23
-
24
- 组件现在支持了自动按需引入, 但是样式文件需要额外的处理
25
-
26
- ### 2.1 样式处理方式1 (按需引入样式)
27
-
28
- ```shell
29
- # 安装自动导入样式的插件
30
- npm i -d vite-plugin-style-import
31
- ```
32
-
33
- ```typescript
34
- // vite.config.ts
35
- import { defineConfig } from 'vite';
36
- import { createStyleImportPlugin } from 'vite-plugin-style-import';
37
-
38
- export default defineConfig({
39
- plugins: [
40
- // ...otherPlugins
41
- createStyleImportPlugin({
42
- libs: [
43
- {
44
- libraryName: 'cnhis-design-vue',
45
- esModule: true,
46
- ensureStyleFile: true,
47
- resolveStyle: name => {
48
- return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
49
- }
50
- }
51
- ]
52
- })
53
- ]
54
- });
55
- ```
56
-
57
- ### 2.2 样式处理方式2 (全局引入样式)
58
-
59
- ```typescript
60
- // main.ts
61
- import 'cnhis-design-vue/es/components/index.css';
62
- ```
63
-
64
- ## 3.FAQ
65
-
66
- ### 3.1 项目打包后样式丢失
67
-
68
- 处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
69
-
70
- ```typescript
71
- // vite.config.ts
72
- import { defineConfig } from 'vite';
73
-
74
- export default defineConfig({
75
- build: {
76
- rollupOptions: {
77
- // ..otherOptions
78
- output: {
79
- dir: './dist',
80
- manualChunks: {
81
- 'cnhis-vendor': ['cnhis-design-vue']
82
- }
83
- }
84
- }
85
- }
86
- });
87
- ```
1
+ # 安装
2
+
3
+ ```shell
4
+ npm i cnhis-design-vue@[版本号]
5
+ # or
6
+ yarn add cnhis-design-vue@[版本号] #推荐
7
+ ```
8
+
9
+ ## 1.全局引入
10
+
11
+ ```typescript
12
+ // main.ts
13
+ import { createApp } from 'vue';
14
+ import App from './App.vue';
15
+ import 'cnhis-design-vue/es/packages/index.css';
16
+ import cui from 'cnhis-design-vue';
17
+
18
+ const app = createApp(App);
19
+ app.use(cui).mount('#app');
20
+ ```
21
+
22
+ ## 2. 按需引入
23
+
24
+ 组件现在支持了自动按需引入, 但是样式文件需要额外的处理
25
+
26
+ ### 2.1 样式处理方式1 (按需引入样式)
27
+
28
+ ```shell
29
+ # 安装自动导入样式的插件
30
+ npm i -d vite-plugin-style-import
31
+ ```
32
+
33
+ ```typescript
34
+ // vite.config.ts
35
+ import { defineConfig } from 'vite';
36
+ import { createStyleImportPlugin } from 'vite-plugin-style-import';
37
+
38
+ export default defineConfig({
39
+ plugins: [
40
+ // ...otherPlugins
41
+ createStyleImportPlugin({
42
+ libs: [
43
+ {
44
+ libraryName: 'cnhis-design-vue',
45
+ esModule: true,
46
+ ensureStyleFile: true,
47
+ resolveStyle: name => {
48
+ return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
49
+ }
50
+ }
51
+ ]
52
+ })
53
+ ]
54
+ });
55
+ ```
56
+
57
+ ### 2.2 样式处理方式2 (全局引入样式)
58
+
59
+ ```typescript
60
+ // main.ts
61
+ import 'cnhis-design-vue/es/components/index.css';
62
+ ```
63
+
64
+ ## 3.FAQ
65
+
66
+ ### 3.1 项目打包后样式丢失
67
+
68
+ 处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
69
+
70
+ ```typescript
71
+ // vite.config.ts
72
+ import { defineConfig } from 'vite';
73
+
74
+ export default defineConfig({
75
+ build: {
76
+ rollupOptions: {
77
+ // ..otherOptions
78
+ output: {
79
+ dir: './dist',
80
+ manualChunks: {
81
+ 'cnhis-vendor': ['cnhis-design-vue']
82
+ }
83
+ }
84
+ }
85
+ }
86
+ });
87
+ ```
@@ -453,6 +453,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
453
453
  spinTimer: null;
454
454
  isClickOuterPrint: boolean;
455
455
  curPrintParamList: never[];
456
+ ireportExecuteMode: number;
456
457
  };
457
458
  options: import("vue").Ref<import("../../shared/types").AnyObject[]>;
458
459
  operations: import("vue").Ref<import("../../shared/types").AnyObject[]>;
@@ -1065,6 +1066,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
1065
1066
  isInited: boolean;
1066
1067
  watchPrintParamsReformatFn: null;
1067
1068
  spinTimer: null;
1069
+ ireportExecuteMode: number;
1068
1070
  };
1069
1071
  options: import("vue").Ref<import("../../shared/types").AnyObject[]>;
1070
1072
  currentFormatItem: import("vue").ComputedRef<{} | undefined>;
@@ -459,6 +459,7 @@ declare const _default: import("vue").DefineComponent<{
459
459
  spinTimer: null;
460
460
  isClickOuterPrint: boolean;
461
461
  curPrintParamList: never[];
462
+ ireportExecuteMode: number;
462
463
  };
463
464
  options: import("vue").Ref<AnyObject[]>;
464
465
  operations: import("vue").Ref<AnyObject[]>;
@@ -1071,6 +1072,7 @@ declare const _default: import("vue").DefineComponent<{
1071
1072
  isInited: boolean;
1072
1073
  watchPrintParamsReformatFn: null;
1073
1074
  spinTimer: null;
1075
+ ireportExecuteMode: number;
1074
1076
  };
1075
1077
  options: import("vue").Ref<AnyObject[]>;
1076
1078
  currentFormatItem: import("vue").ComputedRef<{} | undefined>;
@@ -237,6 +237,7 @@ declare const _default: import("vue").DefineComponent<{
237
237
  spinTimer: null;
238
238
  isClickOuterPrint: boolean;
239
239
  curPrintParamList: never[];
240
+ ireportExecuteMode: number;
240
241
  };
241
242
  options: import("vue").Ref<AnyObject[]>;
242
243
  operations: import("vue").Ref<AnyObject[]>;
@@ -1 +1 @@
1
- import{defineComponent as e,inject as t,ref as n,reactive as i,computed as r,onMounted as a,watch as l,openBlock as s,createElementBlock as o,Fragment as u,createElementVNode as c,createCommentVNode as d,createVNode as p,unref as m,withCtx as y,renderList as v,createBlock as f,normalizeClass as g,createTextVNode as k,toDisplayString as h,isRef as b,renderSlot as P,withModifiers as w,mergeProps as S}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as F,NPopover as j,NCheckbox as M,NDivider as N}from"naive-ui";import{PrintOutline as E,SettingsOutline as x,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}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";const B={class:"newprint-button-outer"},K=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},q={class:"print-lite"},G={class:"label bold"},H={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},ee={class:"label bold"},te={class:"print-li"},ne={class:"print-lite"},ie=["onClick"],re={class:"newprint-button-poperOver"},ae=["onMouseenter"],le={class:"print-lite"},se=["onClick"];var oe=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,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:""})}},setup(e,{expose:oe}){const ue=e,ce=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],de=C();let pe;const me=t(J),ye=n(""),ve=i({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[]});let fe=n([]),ge=n([{label:ue.previewText,key:"previewText"},{label:ue.pdfLoadText,key:"downloadPdf"},{label:ue.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const ke=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),he=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),be=n([]),Pe=n([]),we=r((()=>{if(!ve.currentFormatId)return{};let e=ve.currentFormatId;return ve.formatList.find((t=>t.id===e))}));r((()=>{var e;return(null==(e=we.value)?void 0:e.name)||"格式选择"}));const Se=r((()=>{let e=ve.formatList.find((e=>e.id===ve.currentFormatId));return null==e?void 0:e.templateId})),Oe=r((()=>{let e=ve.formatList.find((e=>e.id===ve.currentFormatId));return null==e?void 0:e.number})),Ce=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowPrintAll})),Ie=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowOutSetting})),Te=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.customProps)||{}})),Le=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.defaultFormatId)||""})),Fe=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.printAllType)||1})),je=r((()=>{const e=ce.map((e=>e.key));return fe.value.filter((t=>!e.includes(t.key)))})),Me=r({get:()=>je.value.every((e=>e.selected)),set(e){je.value.forEach((t=>{t.selected=e}))}}),Ne=async()=>{var e,t;(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await rt(),he.oneShow=!0},Ee=async e=>{if(ue.directPrint){if(ve.spinning)return;return"button"===e?void(Ce.value?await st():Le.value?async function(e){await rt(!1);const t=be.value.find((t=>t.key==e));t&&Ge(t.templateCode,t.templateId,t.key,!1)}(Le.value):Ne()):Ne()}return Ne()},xe=(e,t)=>{ke[e]=t},_e=()=>{be.value=fe.value.filter((e=>!e.selected)),Pe.value=je.value.filter((e=>e.selected)),Je("oneShow"),Je("isOutSetting"),me("saveOuterPrint",Pe.value)},De=e=>{he[e]=!0},Je=e=>{ke.oneClickType="",he[e]=!1,"isOutSetting"==e&&(he.isOutSetting=!1)},ze=(e,t)=>{Re(!1);let n={type:t,formatId:ve.currentFormatId,templateId:(null==e?void 0:e.templateId)||Se.value,templateCode:(null==e?void 0:e.templateCode)||Oe.value};me("success",e,n)},Ae=e=>{Re(!1),me("error",e),O(e)&&"notInstalledApp"===e.type&&de.error(e.message)},Ue=e=>{Re(!1),me("cancel",e)},Ve=e=>{me("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Be=()=>JSON.stringify({...ue.token?{token:ue.token}:{}}),Ke=(e=[],t)=>{var n,i;let r={},a={};if((null==(n=ve.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(i=Object.keys(e[0].datasetData||{}))?void 0:i[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 r=Object.assign({},JSON.parse(Be()),Te.value,a),JSON.stringify(r)},Re=(e,t)=>{if(ve.isClickOuterPrint){if(e&&t){const n=Pe.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Pe.value.forEach((e=>{e.isLoading=!1}))}else ve.spinning=e},qe=()=>ve.isClickOuterPrint?Pe.value.some((e=>e.isLoading)):ve.spinning,Ge=(e,t,n,i)=>{const r=ve.printParams[e];if(!r)return;ve.isClickOuterPrint=i,ve.currentFormatId=n;const a=ve.originParams[e]||[];He(r,e,t,n,a)},He=async(e=[],t,n,i,r=[],a)=>{let l=e.length;const s=async e=>{try{--l<=0&&ze(e,"print")}catch(e){console.log("error",e)}};ue.showLoading&&qe()&&!a||(Re(!0,i),ue.prevFn("print").then((()=>{ve.curPrintParamList=e;const a={formatId:i,templateId:n,authorizationKey:ye.value,printdlgshow:ue.printdlgshow,signature:ue.signature,copies:ue.printCopies};if("MULTI"===ue.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[t]));pe.printDirect({...a,params:n},s,Ae,Ue)}else pe.printDirect({...a,params:Ke(e,t)},(e=>{e.params=r,e.templateCode=t,e.templateId=n,ze(e,"print")}),Ae,Ue)})).catch((()=>{Ve("print"),Re(!1)})).finally((()=>{ve.visible=!1})))},Ye=async(e,{templateCode:t,templateId:n,key:i},r)=>{const a=ve.printParams[t];if(a)switch(ve.isClickOuterPrint=r,ve.currentFormatId=i,e){case"previewText":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("preview").then((()=>{ve.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Ke(e,t),l={formatId:i,templateId:n,authorizationKey:ye.value,params:a,btnprint:ue.btnprint,signature:ue.signature};pe.preview(l,(e=>{ze(e,"preview")}),Ae)})).catch((()=>{Ve("preview"),Re(!1)})).finally((()=>{ve.visible=!1})))})(a,t,n,i);break;case"formatEditText":((e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("edit").then((()=>{ve.curPrintParamList=e,ve.currentFormatId=i,ve.identityVerification.visible=!0})).catch((()=>{Ve("edit")})).finally((()=>{Re(!1)})))})(a,0,0,i);break;case"downloadPdf":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("download").then((()=>{ve.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Ke(e,t),l={formatId:i,templateId:n,authorizationKey:ye.value,print:{print:"1",type:"1"},params:a,signature:ue.signature};pe.downloadPDF(l,(e=>ze(e,"preview")),Ae)})).catch((()=>{Ve("download"),Re(!1)})).finally((()=>{ve.visible=!1})))})(a,t,n,i);break;case"resetPrinter":(async(e=[],t,n,i)=>{if(!ue.showLoading||!qe()){Re(!0,i);try{const e=await pe.resetPrinter(i);if(Re(!1),"success"==(null==e?void 0:e.result))return void de.success(e.message||"重置打印机成功");de.warning("重置打印机失败")}catch(e){Re(!1),de.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,i)}},$e=()=>{},Qe=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},et(n,t,e))})),n},We=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},tt(n,t,e))})),n},Xe=(e,t,n)=>{const i={};return t.forEach((t=>{let r=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(i=V(t,n[e.type])),(null==e?void 0:e.defaultValue)||i})(t,e[t[n]]);e[t[n]]&&r&&(i[t[n]]=r)})),i},Ze=({customizeDataset:e=[],param:t=[]},n={})=>{let i={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[e.name]=JSON.stringify(Xe(n,t,"fieldName"))})),i=Object.assign({},i,Xe(n,t,"key")),i},et=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i],a=n[r];if(!a)return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(Ze(a,t))}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(Ze(l,t))}return e},tt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i];if(!n[r])return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(t)}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r];if(!n[a])return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},nt=async e=>{ve.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):[],(()=>{var e,t,n;const i=ve.formatList.map((e=>({templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1})));fe.value.unshift(...i),Ie.value&&fe.value.push(...ce),(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(fe.value.forEach((e=>{var t;(null==(t=ue.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Pe.value=fe.value.filter((e=>e.selected))),be.value=fe.value.filter((e=>!e.selected)),ue.hideButtons.length>0&&(ge.value=ge.value.filter((e=>!ue.hideButtons.includes(e.key))));const r=sessionStorage.getItem("portal");if(r){const e=JSON.parse(r),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(t);i.includes("RY7.2.21.1.M2.G94181E")||(ge.value=ge.value.filter((e=>"downloadPdf"!=e.key))),i.includes("RY7.2.21.1.M2.G33633A")||(ge.value=ge.value.filter((e=>"formatEditText"!=e.key)))}})(),ve.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),ve.printParams=Qe(ve.templateParams,ue.params),ve.originParams=We(ve.templateParams,ue.params)},it=async()=>{var e;if(ve.isInited)return!0;ve.isInited=!0,ve.spinning=!0,(()=>{if(pe)return!1;pe=new z})();const t=await ue.queryPrintFormatByNumber();return await nt(t),(null==(e=t.obj)?void 0:e.length)>0&&(ye.value=t.obj[0].authorizationKey||""),ve.spinning=!1,!0},rt=async(e=!0)=>{if(await ue.clickPrevFn()){if(!ve.visible){if(!await it())return!1}e&&(ve.visible=!ve.visible)}},at=e=>{if(ve.identityVerification.visible=!1,A(ve.currentFormatId))return ze(null,"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,ve.curPrintParamList[0])),n="MULTI"===ue.strategy?t:Ke(ve.curPrintParamList,Oe.value),i={formatId:ve.currentFormatId,templateId:Se.value,params:n,token:e};pe.editPrintFormat(i,(e=>{ze(e,"edit")}),Ae)},lt=(e,t)=>{const n=Pe.value[t+1];return t<Pe.value.length-1&&!ve.printParams[e.templateCode]&&ve.printParams[n.templateCode]};async function st(){await rt(!1),(()=>{const e=Object.keys(ve.printParams);ve.isClickOuterPrint=!1;const t=ve.originParams;if(1==Fe.value)for(let n=0;n<e.length;n++){const i=e[n],r=ve.printParams[i],a=t[i]||[],l=ve.formatList.filter((e=>e.number==i));l&&l.length>0&&l.forEach((e=>{ve.currentFormatId=e.id,He(r,e.number,e.templateId,e.id,a,!0)}))}2==Fe.value&&Pe.value.forEach((e=>{const n=ve.printParams[e.templateCode],i=t[e.templateCode]||[];ve.currentFormatId=e.key,He(n,e.templateCode,e.templateId,e.key,i,!0)}))})()}return a((()=>{ve.isInited=!1})),l((()=>ue.params),(e=>{Object.keys(ve.templateParams).length>0&&(ve.printParams=Qe(ve.templateParams,ue.params),ve.originParams=We(ve.templateParams,ue.params))}),{deep:!0}),l((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await rt(!1)}),{deep:!0,immediate:!0}),oe({directPrint:st}),(t,n)=>(s(),o(u,null,[c("div",B,[d(" 外显按钮集合 "),p(m(I),{class:"outButtonGroup"},{default:y((()=>[(s(!0),o(u,null,v(Pe.value,((t,n)=>{return s(),f(m(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:$e,options:(i=m(ge),r=t,ve.printParams[r.templateCode]?i:[]),onSelect:e=>Ye(e,t,!0)},{default:y((()=>[p(m(L),{disabled:!ve.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>Ge(t.templateCode,t.templateId,t.key,!0),class:g(n==Pe.value.length-1?"outerLastButton":lt(t,n)?"isPrintDisabled":"")},{icon:y((()=>[p(m(F),{component:m(E),size:"18"},null,8,["component"])])),default:y((()=>[k(" "+h(t.label),1)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var i,r})),128))])),_:1}),d(" 外显设置按钮 "),Pe.value.length>0&&Pe.value.length==m(je).length&&m(Ie)&&2!=m(Fe)?(s(),f(m(j),{key:0,trigger:"click","show-arrow":!1,show:he.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Je("isOutSetting"))},{trigger:y((()=>[p(m(L),{class:g(Pe.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>De("isOutSetting"))},{default:y((()=>[K,p(m(F),{style:{"margin-left":"8px"},component:m(x),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:y((()=>[c("div",R,[(s(!0),o(u,null,v(m(je),(e=>(s(),o("div",{class:"print-li",key:e.key},[c("div",q,[c("span",G,h(e.label),1),p(m(M),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",H,[p(m(N)),c("div",Y,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:y((()=>[k("保存")])),_:1}),m(je)&&m(je).length>1?(s(),f(m(M),{key:0,checked:m(Me),"onUpdate:checked":n[1]||(n[1]=e=>b(Me)?Me.value=e:null)},{default:y((()=>[k("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:1},8,["show"])):(s(),o(u,{key:1},[d(" 打印全部按钮 "),p(m(j),{trigger:"click","show-arrow":!1,show:he.oneShow,onClickoutside:n[10]||(n[10]=e=>Je("oneShow"))},{trigger:y((()=>[P(t.$slots,"button",{handleClickPrintBtn:rt,printSpinning:ve.spinning,printbtnText:e.btnText,printVisible:ve.visible},(()=>[p(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=w((()=>Ee("icon")),["stop"]))},{default:y((()=>[p(m(L),{loading:e.showLoading&&ve.spinning,onClick:n[3]||(n[3]=w((()=>Ee("button")),["stop"])),class:g(Pe.value.length>0?"printAllLeftCls":"")},{icon:y((()=>[p(m(F),{component:m(E),size:"18"},null,8,["component"])])),default:y((()=>[k(" "+h(m(Ce)?"打印全部":e.btnText),1)])),_:1},8,["loading","class"]),p(m(L),{class:"icon-select"},{icon:y((()=>[p(m(F),{component:m(_),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:y((()=>[c("div",$,[(s(!0),o(u,null,v(be.value,(e=>(s(),o("div",{class:g(["print-li",ke.oneMouseType==e.key||ke.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>xe("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>xe("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!ve.printParams[n.templateCode])return[];xe(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),f(m(N),{key:0})):"outSetting"==e.key?(s(),o(u,{key:1},[d(" 第二层外显设置 "),p(m(j),{trigger:"click","show-arrow":!1,placement:"right-start",show:he.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Je("isOutSetting"))},{trigger:y((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>De("isOutSetting"))},[c("span",W,h(e.label),1),p(m(F),{color:Pe.value.length>0?"#2563F4":"",component:m(x),size:"18"},null,8,["color","component"])])])),default:y((()=>[c("div",X,[(s(!0),o(u,null,v(m(je),(e=>(s(),o("div",{class:"print-li",key:e.key},[c("div",Z,[c("span",ee,h(e.label),1),p(m(M),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",te,[p(m(N)),c("div",ne,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:y((()=>[k("保存")])),_:1}),m(je)&&m(je).length>1?(s(),f(m(M),{key:0,checked:m(Me),"onUpdate:checked":n[6]||(n[6]=e=>b(Me)?Me.value=e:null)},{default:y((()=>[k("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(s(),o(u,{key:2},[d(" 第二层功能操作 "),c("div",{class:g(["print-lite",ve.printParams[e.templateCode]?"":"isDisabled"])},[c("span",{class:"label bold",onClick:t=>Ge(e.templateCode,e.templateId,e.key,!1)},h(e.label),9,ie),ve.printParams[e.templateCode]?(s(),f(m(j),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:he[e.key],onClickoutside:t=>Je(e.key)},{trigger:y((()=>[p(m(F),{component:m(D),size:"18",onClick:t=>De(e.key)},null,8,["component","onClick"])])),default:y((()=>[c("div",re,[(s(!0),o(u,null,v(m(ge),(t=>(s(),o("div",{class:g(["print-li",ke.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>xe("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>xe("twoMouseType",""))},[c("div",le,[c("span",{class:"label",onClick:n=>Ye(t.key,e,!1)},h(t.label),9,se)])],42,ae)))),128))])])),_:2},1032,["show","onClickoutside"])):d("v-if",!0)],2)],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),p(U,S(t.$attrs,{modelValue:ve.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>ve.identityVerification.visible=e),formatId:ve.currentFormatId,templateId:m(Se),onSuccess:at}),null,16,["modelValue","formatId","templateId"])],64))}});export{oe as default};
1
+ import{defineComponent as e,inject as t,ref as n,reactive as i,computed as r,onMounted as a,watch as l,openBlock as o,createElementBlock as s,Fragment as u,createElementVNode as c,createCommentVNode as d,createVNode as p,unref as m,withCtx as v,renderList as y,createBlock as f,normalizeClass as g,createTextVNode as k,toDisplayString as h,isRef as b,renderSlot as P,withModifiers as w,mergeProps as S}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as M,NPopover as F,NCheckbox as j,NDivider as E}from"naive-ui";import{PrintOutline as x,SettingsOutline as N,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}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";const B={class:"newprint-button-outer"},K=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},q={class:"print-lite"},G={class:"label bold"},H={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},ee={class:"label bold"},te={class:"print-li"},ne={class:"print-lite"},ie=["onClick"],re={class:"newprint-button-poperOver"},ae=["onMouseenter"],le={class:"print-lite"},oe=["onClick"];var se=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,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:""})}},setup(e,{expose:se}){const ue=e,ce=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],de=C();let pe;const me=t(J),ve=n(""),ye=i({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],ireportExecuteMode:1});let fe=n([]),ge=n([{label:ue.previewText,key:"previewText"},{label:ue.pdfLoadText,key:"downloadPdf"},{label:ue.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const ke=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),he=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),be=n([]),Pe=n([]),we=r((()=>{if(!ye.currentFormatId)return{};let e=ye.currentFormatId;return ye.formatList.find((t=>t.id===e))}));r((()=>{var e;return(null==(e=we.value)?void 0:e.name)||"格式选择"}));const Se=r((()=>{let e=ye.formatList.find((e=>e.id===ye.currentFormatId));return null==e?void 0:e.templateId})),Oe=r((()=>{let e=ye.formatList.find((e=>e.id===ye.currentFormatId));return null==e?void 0:e.number})),Ce=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowPrintAll})),Ie=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowOutSetting})),Te=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.customProps)||{}})),Le=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.defaultFormatId)||""})),Me=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.printAllType)||1})),Fe=r((()=>{const e=ce.map((e=>e.key));return fe.value.filter((t=>!e.includes(t.key)))})),je=r({get:()=>Fe.value.every((e=>e.selected)),set(e){Fe.value.forEach((t=>{t.selected=e}))}}),Ee=async()=>{var e,t;(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await rt(),he.oneShow=!0},xe=async e=>{if(ue.directPrint){if(ye.spinning)return;return"button"===e?void(Ce.value?await ot():Le.value?async function(e){await rt(!1);const t=be.value.find((t=>t.key==e));t&&Ge(t.templateCode,t.templateId,t.key,!1)}(Le.value):Ee()):Ee()}return Ee()},Ne=(e,t)=>{ke[e]=t},_e=()=>{be.value=fe.value.filter((e=>!e.selected)),Pe.value=Fe.value.filter((e=>e.selected)),Je("oneShow"),Je("isOutSetting"),me("saveOuterPrint",Pe.value)},De=e=>{he[e]=!0},Je=e=>{ke.oneClickType="",he[e]=!1,"isOutSetting"==e&&(he.isOutSetting=!1)},ze=(e,t)=>{Re(!1);let n={type:t,formatId:ye.currentFormatId,templateId:(null==e?void 0:e.templateId)||Se.value,templateCode:(null==e?void 0:e.templateCode)||Oe.value};me("success",e,n)},Ae=e=>{Re(!1),me("error",e),O(e)&&"notInstalledApp"===e.type&&de.error(e.message)},Ue=e=>{Re(!1),me("cancel",e)},Ve=e=>{me("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Be=()=>JSON.stringify({...ue.token?{token:ue.token}:{}}),Ke=(e=[],t)=>{var n,i;let r={},a={};if((null==(n=ye.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(i=Object.keys(e[0].datasetData||{}))?void 0:i[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 r=Object.assign({},JSON.parse(Be()),Te.value,a),JSON.stringify(r)},Re=(e,t)=>{if(ye.isClickOuterPrint){if(e&&t){const n=Pe.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Pe.value.forEach((e=>{e.isLoading=!1}))}else ye.spinning=e},qe=()=>ye.isClickOuterPrint?Pe.value.some((e=>e.isLoading)):ye.spinning,Ge=(e,t,n,i)=>{const r=ye.printParams[e];if(!r)return;ye.isClickOuterPrint=i,ye.currentFormatId=n;const a=ye.originParams[e]||[];He(r,e,t,n,a)},He=async(e=[],t,n,i,r=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&ze(e,"print")}catch(e){console.log("error",e)}};ue.showLoading&&qe()&&!a||(Re(!0,i),ue.prevFn("print").then((()=>{ye.curPrintParamList=e;const a={formatId:i,ireportExecuteMode:ye.ireportExecuteMode,templateId:n,authorizationKey:ve.value,printdlgshow:ue.printdlgshow,signature:ue.signature,copies:ue.printCopies};if("MULTI"===ue.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[t]));pe.printDirect({...a,params:n},o,Ae,Ue)}else pe.printDirect({...a,params:Ke(e,t)},(e=>{e.params=r,e.templateCode=t,e.templateId=n,ze(e,"print")}),Ae,Ue)})).catch((()=>{Ve("print"),Re(!1)})).finally((()=>{ye.visible=!1})))},Ye=async(e,{templateCode:t,templateId:n,key:i},r)=>{const a=ye.printParams[t];if(a)switch(ye.isClickOuterPrint=r,ye.currentFormatId=i,e){case"previewText":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("preview").then((()=>{ye.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Ke(e,t),l={formatId:i,templateId:n,ireportExecuteMode:ye.ireportExecuteMode,authorizationKey:ve.value,params:a,btnprint:ue.btnprint,signature:ue.signature};pe.preview(l,(e=>{ze(e,"preview")}),Ae)})).catch((()=>{Ve("preview"),Re(!1)})).finally((()=>{ye.visible=!1})))})(a,t,n,i);break;case"formatEditText":((e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("edit").then((()=>{ye.curPrintParamList=e,ye.currentFormatId=i,ye.identityVerification.visible=!0})).catch((()=>{Ve("edit")})).finally((()=>{Re(!1)})))})(a,0,0,i);break;case"downloadPdf":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("download").then((()=>{ye.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Ke(e,t),l={formatId:i,templateId:n,ireportExecuteMode:ye.ireportExecuteMode,authorizationKey:ve.value,print:{print:"1",type:"1"},params:a,signature:ue.signature};pe.downloadPDF(l,(e=>ze(e,"preview")),Ae)})).catch((()=>{Ve("download"),Re(!1)})).finally((()=>{ye.visible=!1})))})(a,t,n,i);break;case"resetPrinter":(async(e=[],t,n,i)=>{if(!ue.showLoading||!qe()){Re(!0,i);try{const e=await pe.resetPrinter(i);if(Re(!1),"success"==(null==e?void 0:e.result))return void de.success(e.message||"重置打印机成功");de.warning("重置打印机失败")}catch(e){Re(!1),de.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,i)}},$e=()=>{},Qe=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},et(n,t,e))})),n},We=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},tt(n,t,e))})),n},Xe=(e,t,n)=>{const i={};return t.forEach((t=>{let r=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(i=V(t,n[e.type])),(null==e?void 0:e.defaultValue)||i})(t,e[t[n]]);e[t[n]]&&r&&(i[t[n]]=r)})),i},Ze=({customizeDataset:e=[],param:t=[]},n={})=>{let i={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[e.name]=JSON.stringify(Xe(n,t,"fieldName"))})),i=Object.assign({},i,Xe(n,t,"key")),i},et=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i],a=n[r];if(!a)return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(Ze(a,t))}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(Ze(l,t))}return e},tt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i];if(!n[r])return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(t)}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r];if(!n[a])return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},nt=async e=>{var t;ye.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):[],ye.ireportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].ireportExecuteMode||1,(()=>{var e,t,n;const i=ye.formatList.map((e=>({templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1})));fe.value.unshift(...i),Ie.value&&fe.value.push(...ce),(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(fe.value.forEach((e=>{var t;(null==(t=ue.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Pe.value=fe.value.filter((e=>e.selected))),be.value=fe.value.filter((e=>!e.selected)),ue.hideButtons.length>0&&(ge.value=ge.value.filter((e=>!ue.hideButtons.includes(e.key))));const r=sessionStorage.getItem("portal");if(r){const e=JSON.parse(r),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(t);i.includes("RY7.2.21.1.M2.G94181E")||(ge.value=ge.value.filter((e=>"downloadPdf"!=e.key))),i.includes("RY7.2.21.1.M2.G33633A")||(ge.value=ge.value.filter((e=>"formatEditText"!=e.key)))}})(),ye.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),ye.printParams=Qe(ye.templateParams,ue.params),ye.originParams=We(ye.templateParams,ue.params)},it=async()=>{var e;if(ye.isInited)return!0;ye.isInited=!0,ye.spinning=!0,(()=>{if(pe)return!1;pe=new z})();const t=await ue.queryPrintFormatByNumber();return await nt(t),(null==(e=t.obj)?void 0:e.length)>0&&(ve.value=t.obj[0].authorizationKey||""),ye.spinning=!1,!0},rt=async(e=!0)=>{if(await ue.clickPrevFn()){if(!ye.visible){if(!await it())return!1}e&&(ye.visible=!ye.visible)}},at=e=>{if(ye.identityVerification.visible=!1,A(ye.currentFormatId))return ze(null,"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,ye.curPrintParamList[0])),n="MULTI"===ue.strategy?t:Ke(ye.curPrintParamList,Oe.value),i={formatId:ye.currentFormatId,templateId:Se.value,params:n,token:e};pe.editPrintFormat(i,(e=>{ze(e,"edit")}),Ae)},lt=(e,t)=>{const n=Pe.value[t+1];return t<Pe.value.length-1&&!ye.printParams[e.templateCode]&&ye.printParams[n.templateCode]};async function ot(){await rt(!1),(()=>{const e=Object.keys(ye.printParams);ye.isClickOuterPrint=!1;const t=ye.originParams;if(1==Me.value)for(let n=0;n<e.length;n++){const i=e[n],r=ye.printParams[i],a=t[i]||[],l=ye.formatList.filter((e=>e.number==i));l&&l.length>0&&l.forEach((e=>{ye.currentFormatId=e.id,He(r,e.number,e.templateId,e.id,a,!0)}))}2==Me.value&&Pe.value.forEach((e=>{const n=ye.printParams[e.templateCode],i=t[e.templateCode]||[];ye.currentFormatId=e.key,He(n,e.templateCode,e.templateId,e.key,i,!0)}))})()}return a((()=>{ye.isInited=!1})),l((()=>ue.params),(e=>{Object.keys(ye.templateParams).length>0&&(ye.printParams=Qe(ye.templateParams,ue.params),ye.originParams=We(ye.templateParams,ue.params))}),{deep:!0}),l((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await rt(!1)}),{deep:!0,immediate:!0}),se({directPrint:ot}),(t,n)=>(o(),s(u,null,[c("div",B,[d(" 外显按钮集合 "),p(m(I),{class:"outButtonGroup"},{default:v((()=>[(o(!0),s(u,null,y(Pe.value,((t,n)=>{return o(),f(m(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:$e,options:(i=m(ge),r=t,ye.printParams[r.templateCode]?i:[]),onSelect:e=>Ye(e,t,!0)},{default:v((()=>[p(m(L),{disabled:!ye.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>Ge(t.templateCode,t.templateId,t.key,!0),class:g(n==Pe.value.length-1?"outerLastButton":lt(t,n)?"isPrintDisabled":"")},{icon:v((()=>[p(m(M),{component:m(x),size:"18"},null,8,["component"])])),default:v((()=>[k(" "+h(t.label),1)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var i,r})),128))])),_:1}),d(" 外显设置按钮 "),Pe.value.length>0&&Pe.value.length==m(Fe).length&&m(Ie)&&2!=m(Me)?(o(),f(m(F),{key:0,trigger:"click","show-arrow":!1,show:he.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Je("isOutSetting"))},{trigger:v((()=>[p(m(L),{class:g(Pe.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>De("isOutSetting"))},{default:v((()=>[K,p(m(M),{style:{"margin-left":"8px"},component:m(N),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:v((()=>[c("div",R,[(o(!0),s(u,null,y(m(Fe),(e=>(o(),s("div",{class:"print-li",key:e.key},[c("div",q,[c("span",G,h(e.label),1),p(m(j),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:v((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",H,[p(m(E)),c("div",Y,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:v((()=>[k("保存")])),_:1}),m(Fe)&&m(Fe).length>1?(o(),f(m(j),{key:0,checked:m(je),"onUpdate:checked":n[1]||(n[1]=e=>b(je)?je.value=e:null)},{default:v((()=>[k("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:1},8,["show"])):(o(),s(u,{key:1},[d(" 打印全部按钮 "),p(m(F),{trigger:"click","show-arrow":!1,show:he.oneShow,onClickoutside:n[10]||(n[10]=e=>Je("oneShow"))},{trigger:v((()=>[P(t.$slots,"button",{handleClickPrintBtn:rt,printSpinning:ye.spinning,printbtnText:e.btnText,printVisible:ye.visible},(()=>[p(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=w((()=>xe("icon")),["stop"]))},{default:v((()=>[p(m(L),{loading:e.showLoading&&ye.spinning,onClick:n[3]||(n[3]=w((()=>xe("button")),["stop"])),class:g(Pe.value.length>0?"printAllLeftCls":"")},{icon:v((()=>[p(m(M),{component:m(x),size:"18"},null,8,["component"])])),default:v((()=>[k(" "+h(m(Ce)?"打印全部":e.btnText),1)])),_:1},8,["loading","class"]),p(m(L),{class:"icon-select"},{icon:v((()=>[p(m(M),{component:m(_),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:v((()=>[c("div",$,[(o(!0),s(u,null,y(be.value,(e=>(o(),s("div",{class:g(["print-li",ke.oneMouseType==e.key||ke.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ne("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ne("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!ye.printParams[n.templateCode])return[];Ne(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(o(),f(m(E),{key:0})):"outSetting"==e.key?(o(),s(u,{key:1},[d(" 第二层外显设置 "),p(m(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:he.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Je("isOutSetting"))},{trigger:v((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>De("isOutSetting"))},[c("span",W,h(e.label),1),p(m(M),{color:Pe.value.length>0?"#2563F4":"",component:m(N),size:"18"},null,8,["color","component"])])])),default:v((()=>[c("div",X,[(o(!0),s(u,null,y(m(Fe),(e=>(o(),s("div",{class:"print-li",key:e.key},[c("div",Z,[c("span",ee,h(e.label),1),p(m(j),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:v((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",te,[p(m(E)),c("div",ne,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:v((()=>[k("保存")])),_:1}),m(Fe)&&m(Fe).length>1?(o(),f(m(j),{key:0,checked:m(je),"onUpdate:checked":n[6]||(n[6]=e=>b(je)?je.value=e:null)},{default:v((()=>[k("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(o(),s(u,{key:2},[d(" 第二层功能操作 "),c("div",{class:g(["print-lite",ye.printParams[e.templateCode]?"":"isDisabled"])},[c("span",{class:"label bold",onClick:t=>Ge(e.templateCode,e.templateId,e.key,!1)},h(e.label),9,ie),ye.printParams[e.templateCode]?(o(),f(m(F),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:he[e.key],onClickoutside:t=>Je(e.key)},{trigger:v((()=>[p(m(M),{component:m(D),size:"18",onClick:t=>De(e.key)},null,8,["component","onClick"])])),default:v((()=>[c("div",re,[(o(!0),s(u,null,y(m(ge),(t=>(o(),s("div",{class:g(["print-li",ke.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ne("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ne("twoMouseType",""))},[c("div",le,[c("span",{class:"label",onClick:n=>Ye(t.key,e,!1)},h(t.label),9,oe)])],42,ae)))),128))])])),_:2},1032,["show","onClickoutside"])):d("v-if",!0)],2)],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),p(U,S(t.$attrs,{modelValue:ye.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>ye.identityVerification.visible=e),formatId:ye.currentFormatId,templateId:m(Se),onSuccess:at}),null,16,["modelValue","formatId","templateId"])],64))}});export{se as default};
@@ -233,6 +233,7 @@ declare const _default: import("vue").DefineComponent<{
233
233
  isInited: boolean;
234
234
  watchPrintParamsReformatFn: null;
235
235
  spinTimer: null;
236
+ ireportExecuteMode: number;
236
237
  };
237
238
  options: import("vue").Ref<AnyObject[]>;
238
239
  currentFormatItem: import("vue").ComputedRef<{} | undefined>;
@@ -1 +1 @@
1
- import{defineComponent as t,useAttrs as e,inject as n,ref as i,reactive as a,computed as r,onMounted as l,watch as o,openBlock as s,createElementBlock as p,Fragment as d,createVNode as u,unref as m,withCtx as c,renderSlot as f,withModifiers as y,createTextVNode as v,toDisplayString as g,mergeProps as b}from"vue";import{isObject as h}from"@vue/shared";import{useMessage as I,NDropdown as P,NButton as w,NIcon as F}from"naive-ui";import{ChevronDown as k}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as T}from"../constants/index.js";import{Print as S}from"../utils/print.js";import{isIReport as x}from"../utils/browserPrint.js";import O from"./IdentityVerification.vue.js";import{format as j}from"date-fns";import{savePrivateFormatApi as L,getPrivateFormatApi as D}from"../api.js";var E=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,default:1},printCustomProps:{type:Object,default:()=>({})},placement:{type:String}},setup(t,{expose:E}){var M;const C=t,N=e(),V=I();let B;const R=n(T),z={},A=i(""),J=a({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null});let U=i([{label:C.printText,key:"printText"},{label:C.previewText,key:"previewText"},{label:C.pdfLoadText,key:"downloadPdf"},{label:C.formatEditText,key:"formatEditText"},...(null==(M=C.externalOptionConfig)?void 0:M.options)||[]]);const q=r((()=>{if(!J.currentFormatId)return{};let t=J.currentFormatId;return J.formatList.find((e=>e.id===t))})),K=r((()=>{var t;return(null==(t=q.value)?void 0:t.name)||"格式选择"})),_=r((()=>{let t=J.formatList.find((t=>t.id===J.currentFormatId));return null==t?void 0:t.templateId})),G=async t=>{if(C.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};R("success",t,n)},$=t=>{J.spinning=!1,R("error",t),h(t)&&"notInstalledApp"===t.type&&V.error(t.message)},Q=t=>{J.spinning=!1,R("cancel",t)},W=t=>{R("error",{message:"前置条件执行错误",type:t,preExecution:!0})},X=(t=0)=>{var e;const n=(null==(e=C.printParams)?void 0:e.length)?C.printParams[t]:J.printParams[t];return JSON.stringify({...n||{},...C.token?{token:C.token}:{},...C.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(...a){i&&clearTimeout(i),n&&!i&&t.apply(null,a),i=setTimeout((()=>{i=null,!n&&t.apply(null,a)}),e)}})((()=>{let t=J.printParams.length;const e=async e=>{try{--t<=0&&Y(e,"print")}catch(t){console.log("error",t)}};C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("print").then((()=>{const t={formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,printdlgshow:C.printdlgshow,signature:C.signature,copies:C.printCopies};if("MULTI"===C.strategy)for(let n=0;n<J.printParams.length;n++)n>0&&(t.printdlgshow="0"),B.printDirect({...t,params:X(n)},e,$,Q);else B.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()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("preview").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,params:t,btnprint:C.btnprint,signature:C.signature};B.preview(e,(t=>{Y(t,"preview")}),$)})).catch((()=>{W("preview"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;case"formatEditText":C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("edit").then((()=>{J.identityVerification.visible=!0})).catch((()=>{W("edit")})).finally((()=>{J.visible=!1,J.spinning=!1})));break;case"downloadPdf":(async()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("download").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,print:{print:"1",type:"1"},params:t,signature:C.signature};B.downloadPDF(e,(t=>Y(t,"preview")),$)})).catch((()=>{W("download"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;default:{J.visible=!1;const a=J.formatList.find((e=>e.id===t))||{};if(Object.keys(a).length>0){J.currentFormatId=t;const[e]=U.value;e.label=(null==a?void 0:a.name)||e.label,await L({formatForms:[{...a}],name:z.name||a.templateName,number:z.number||a.number,templateId:z.templateId||a.templateId,...z.id?{id:z.id}:{}},{token:C.token})}else null==(i=null==(n=C.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},nt=()=>{J.visible=!1,R("clickoutside")},it=()=>(J.isInited=!1,J.spinning=!1,setTimeout((()=>{J.visible=!1}),0),!1),at=(t,e,n)=>{const i={};return e.forEach((e=>{let a=((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]]&&a&&(i[e[n]]=a)})),i},rt=({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(at(n,e,"fieldName"))}})),i=Object.assign({},i,at(n,e,"key")),i})),lt=async t=>{var e;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.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";if(!N.isDoc){const{data:e}=await D({templateId:t[0].templateId},{token:C.token});if("SUCCESS"===e.result){const{formatForms:i=[]}=e.map||{};Object.assign(z,e.map||{});const a=null==(n=null==i?void 0:i[0])?void 0:n.id;if(a&&t.map((t=>t.id)).includes(a))return a}}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=[],V.error(C.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}),C.hideButtons.length>0&&(U.value=U.value.filter((t=>!C.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)||{},a=Object.keys(i);a.includes("RY7.2.21.1.M2.G94181E")||(U.value=U.value.filter((t=>"downloadPdf"!=t.key))),a.includes("RY7.2.21.1.M2.G33633A")||(U.value=U.value.filter((t=>"formatEditText"!=t.key)))}})();let n=null==(e=await C.queryTemplateParams())?void 0:e.obj;if(!n||!_.value)return V.error("获取打印模板失败,请联系管理员!"),it();J.templateParams=n,J.printParams=rt(J.templateParams,C.params)},ot=async()=>{var t;if(J.isInited)return!0;J.isInited=!0,J.spinning=!0,(()=>{if(B)return!1;B=new S})();const e=await C.queryPrintFormatByNumber();return await lt(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 C.clickPrevFn())if((null==(e=C.params)?void 0:e.length)||(null==(n=C.printParams)?void 0:n.length)){if(!J.visible){if(!await ot())return!1}t&&(J.visible=!J.visible)}else V.warning(C.noDataMsg)},pt=()=>{J.watchPrintParamsReformatFn&&J.watchPrintParamsReformatFn(),J.isInited?J.printParams=rt(J.templateParams,C.params):J.watchPrintParamsReformatFn=()=>o((()=>J.isInited),(t=>{if(!t)return!1;pt()}))},dt=t=>{if(J.identityVerification.visible=!1,x(J.currentFormatId))return Y(null,"edit");const e={formatId:J.currentFormatId,templateId:_.value,params:X(),token:t};B.editPrintFormat(e,(t=>{Y(t,"edit")}),$)};async function ut(){await st(!1),tt()}return l((()=>{J.isInited=!1})),o((()=>C.params),(t=>{if(!(null==t?void 0:t.length))return!1;pt()}),{deep:!0}),E({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]=y((()=>G("button")),["stop"]))},{default:c((()=>[v(g(t.btnText)+" ",1),u(m(F),{component:m(k),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=y((()=>G("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["placement","show","options"]),u(O,b(m(N),{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{E as default};
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 y,createTextVNode as v,toDisplayString as g,mergeProps as b}from"vue";import{isObject as h}from"@vue/shared";import{useMessage as I,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,default:1},printCustomProps:{type:Object,default:()=>({})},placement:{type:String}},setup(t,{expose:L}){var D;const C=t,N=e(),V=I();let B;const R=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:C.printText,key:"printText"},{label:C.previewText,key:"previewText"},{label:C.pdfLoadText,key:"downloadPdf"},{label:C.formatEditText,key:"formatEditText"},...(null==(D=C.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(C.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};R("success",t,n)},$=t=>{J.spinning=!1,R("error",t),h(t)&&"notInstalledApp"===t.type&&V.error(t.message)},Q=t=>{J.spinning=!1,R("cancel",t)},W=t=>{R("error",{message:"前置条件执行错误",type:t,preExecution:!0})},X=(t=0)=>{var e;const n=(null==(e=C.printParams)?void 0:e.length)?C.printParams[t]:J.printParams[t];return JSON.stringify({...n||{},...C.token?{token:C.token}:{},...C.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)}};C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("print").then((()=>{const t={ireportExecuteMode:J.ireportExecuteMode,formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,printdlgshow:C.printdlgshow,signature:C.signature,copies:C.printCopies};if("MULTI"===C.strategy)for(let n=0;n<J.printParams.length;n++)n>0&&(t.printdlgshow="0"),B.printDirect({...t,params:X(n)},e,$,Q);else B.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()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("preview").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,ireportExecuteMode:J.ireportExecuteMode,templateId:_.value,authorizationKey:A.value,params:t,btnprint:C.btnprint,signature:C.signature};B.preview(e,(t=>{Y(t,"preview")}),$)})).catch((()=>{W("preview"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;case"formatEditText":C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("edit").then((()=>{J.identityVerification.visible=!0})).catch((()=>{W("edit")})).finally((()=>{J.visible=!1,J.spinning=!1})));break;case"downloadPdf":(async()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("download").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,ireportExecuteMode:J.ireportExecuteMode,templateId:_.value,authorizationKey:A.value,print:{print:"1",type:"1"},params:t,signature:C.signature};B.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:C.token})}else null==(i=null==(n=C.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},nt=()=>{J.visible=!1,R("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(!N.isDoc){const{data:e}=await O({templateId:t[0].templateId},{token:C.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=[],V.error(C.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}),C.hideButtons.length>0&&(U.value=U.value.filter((t=>!C.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 C.queryTemplateParams())?void 0:n.obj;if(!i||!_.value)return V.error("获取打印模板失败,请联系管理员!"),it();J.templateParams=i,J.printParams=at(J.templateParams,C.params)},lt=async()=>{var t;if(J.isInited)return!0;J.isInited=!0,J.spinning=!0,(()=>{if(B)return!1;B=new T})();const e=await C.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 C.clickPrevFn())if((null==(e=C.params)?void 0:e.length)||(null==(n=C.printParams)?void 0:n.length)){if(!J.visible){if(!await lt())return!1}t&&(J.visible=!J.visible)}else V.warning(C.noDataMsg)},pt=()=>{J.watchPrintParamsReformatFn&&J.watchPrintParamsReformatFn(),J.isInited?J.printParams=at(J.templateParams,C.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};B.editPrintFormat(e,(t=>{Y(t,"edit")}),$)};async function ut(){await st(!1),tt()}return o((()=>{J.isInited=!1})),l((()=>C.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]=y((()=>G("button")),["stop"]))},{default:c((()=>[v(g(t.btnText)+" ",1),u(m(F),{component:m(k),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=y((()=>G("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["placement","show","options"]),u(E,b(m(N),{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};
@@ -64,9 +64,9 @@ export declare class Print {
64
64
  _queryPrintForPdf(templateId: string, formatId: string, params: string | undefined, authorizationKey: String): Promise<any>;
65
65
  _browserPrint(result: AnyObject, mode: string): Promise<string | void>;
66
66
  _base64ToBlob(fileBase64: string, fileType: string): Blob;
67
- preview({ templateId, formatId, params, paramsArr, authorizationKey, signature, btnprint, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<any>;
67
+ preview({ ireportExecuteMode, templateId, formatId, params, paramsArr, authorizationKey, signature, btnprint, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<any>;
68
68
  printSync(data: AnyObject[], successCallbackFn: AnyFn, errorCallbackFn: AnyFn): Promise<void>;
69
- printDirect({ templateId, formatId, params, paramsArr, authorizationKey, print, signature, printdlgshow, nobillnode, copies, isDownloadFile, messageTimeout }: AnyObject, successCallbackFn: AnyFn, errorCallbackFn: AnyFn, cancelCallbackFn?: AnyFn, mode?: string): Promise<false | undefined>;
69
+ 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>;
70
70
  printToHiPrint({ templateId, formatId, params, authorizationKey }: any, successCallbackFn: AnyFn, errorCallbackFn: AnyFn): Promise<any>;
71
71
  private _downloadPDF;
72
72
  /**
@@ -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 m=t.create({timeout:6e4,withCredentials:!1}),p=`${window.location.protocol}//${window.location.host}`,d=`${p}/fdp-api/print/assembly/printIReport`,u=`${p}/bi-api/reprot/print/open/client/printIReportForBase64`,g=`${p}/bi-api/reprot/print/open/client/previewIReport`,f=`${p}/bi-api/reprot/print/open/client/getRemote`,w=`${p}/printService/file`;let y=null;class P{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.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,y)return y;y=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="",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:!1,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:"请打开打印服务器插件"}),!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({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=1,printdlgshow:l="0",nobillnode:h="1",btnprint:m="1",messageTimeout:p=0}){const d={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:m,copies:o,messageTimeout:p,...a?{signature:a}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=c(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: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:f})||{},{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:u,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:g,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({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,signature:n,btnprint:l,messageTimeout:c=0},h,m){const p=a(e);e=this.getIReportFormatId(p,e),await this._queryProxyOrigin();const d=await this._testConnection();if(!this._handleResultTest(d,m))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:n,btnprint:l,messageTimeout:c}),a=this._handleResult(r,m);if(!a)return!1;if(this.isRemote){const t=await this._browserPrint(a,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}await this.getPicAndUpload(a),null==h||h(a)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==m||m(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:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h=1,isDownloadFile:m=!0,messageTimeout:p=0},d,u,g,f="printDirect"){const w=a(e);e=this.getIReportFormatId(w,e),await this._queryProxyOrigin();const y=await this._testConnection();if(!this._handleResultTest(y,u))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:"7",print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h,messageTimeout:p}),a=this._handleResult(r,u,g);if(!a)return!1;m&&["downloadPDF"].includes(f)&&await this._browserPrint(a,f),null==d||d(a)}catch(t){const e="printDirect"===f?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==u||u(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:s},r,n){const a=await this._queryPrintForBase64(t,e,i,s);if(!a.success)return n({message:a.resultMsg});const{base64:o,formatId:l}=a.map;this.base64Fragment=o,this._successCallbackFn=r,this._errorCallbackFn=n,this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:l,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);t.formatId=this.getIReportFormatId(r,t.formatId),this.printDirect(t,(async t=>{t||s(null);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{P as Print};
1
+ import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as 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 m=t.create({timeout:6e4,withCredentials:!1}),p=`${window.location.protocol}//${window.location.host}`,d=`${p}/fdp-api/print/assembly/printIReport`,u=`${p}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${p}/bi-api/reprot/print/open/client/previewIReport`,g=`${p}/bi-api/reprot/print/open/client/getRemote`,y=`${p}/printService/file`;let w=null;class P{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.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,w)return w;w=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="",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:!1,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:"请打开打印服务器插件"}),!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({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=1,printdlgshow:l="0",nobillnode:h="1",btnprint:m="1",messageTimeout:p=0}){const d={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:m,copies:o,messageTimeout:p,...a?{signature:a}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=c(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: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:g})||{},{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:u,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(`${y}/${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 u=a(i);if(i=this.getIReportFormatId(u,i),2==t){const t=await this._queryPrintForPdf(e,i,s,l);if(!t)return null==d?void 0:d("获取文件失败!");const r=n(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,r),null==p?void 0:p({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}:{message:e};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:!1,errinfo:t})}}catch(t){const e={error:t,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=1,isDownloadFile:p=!0,messageTimeout:d=0},u,f,g,y="printDirect"){const w=a(i);if(i=this.getIReportFormatId(w,i),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},u,f):f({type:"connectAppFail",result:"error",message:"连接hiPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},u,f))}await this._queryProxyOrigin();const P=await this._testConnection();if(!this._handleResultTest(P,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,g);if(!n)return!1;p&&["downloadPDF"].includes(y)&&await this._browserPrint(n,y),null==u||u(n)}catch(t){const e="printDirect"===y?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:s},r,n){const a=await this._queryPrintForBase64(t,e,i,s);if(!a.success)return n({message:a.resultMsg});const{base64:o,formatId:l}=a.map;this.base64Fragment=o,this._successCallbackFn=r,this._errorCallbackFn=n,this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:l,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),2==t.ireportExecuteMode){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);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{P as Print};
@@ -175,6 +175,9 @@ declare const _default: import("vue").DefineComponent<{
175
175
  modelValue: unknown[];
176
176
  componentData: Record<string, any>;
177
177
  } & {
178
+ /**
179
+ * 改变弹窗大小
180
+ */
178
181
  itemKey?: string | Function | undefined;
179
182
  }>, {
180
183
  move: Function;
@@ -225,6 +225,9 @@ declare const _default: import("vue").DefineComponent<{
225
225
  type: PropType<"column" | "tooltip">;
226
226
  default: string;
227
227
  };
228
+ developMode: {
229
+ type: BooleanConstructor;
230
+ };
228
231
  }, {
229
232
  fixedWayOptions: {
230
233
  label: string;
@@ -313,6 +316,9 @@ declare const _default: import("vue").DefineComponent<{
313
316
  type: PropType<"column" | "tooltip">;
314
317
  default: string;
315
318
  };
319
+ developMode: {
320
+ type: BooleanConstructor;
321
+ };
316
322
  }>> & {
317
323
  onUpdateChecked?: ((...args: any[]) => any) | undefined;
318
324
  onEdit?: ((...args: any[]) => any) | undefined;
@@ -321,6 +327,7 @@ declare const _default: import("vue").DefineComponent<{
321
327
  onRemove: () => void;
322
328
  onEdit: () => void;
323
329
  isRenderTooltip: (field: string) => any;
330
+ getTooltipContent: () => any;
324
331
  getTextValue: (field: string) => any;
325
332
  isMultiple: (field: string) => boolean;
326
333
  isRender: (field: string) => boolean;
@@ -423,6 +430,9 @@ declare const _default: import("vue").DefineComponent<{
423
430
  type: PropType<"column" | "tooltip">;
424
431
  default: string;
425
432
  };
433
+ developMode: {
434
+ type: BooleanConstructor;
435
+ };
426
436
  }>> & {
427
437
  onUpdateChecked?: ((...args: any[]) => any) | undefined;
428
438
  onEdit?: ((...args: any[]) => any) | undefined;
@@ -465,10 +475,11 @@ declare const _default: import("vue").DefineComponent<{
465
475
  requiredDisable: boolean;
466
476
  hide: boolean;
467
477
  }>;
478
+ developMode: boolean;
468
479
  draggable: boolean;
480
+ isHighlightRow: boolean;
469
481
  idx: number;
470
482
  isHighlight: boolean;
471
- isHighlightRow: boolean;
472
483
  isFieldSet: boolean;
473
484
  fieldDescribeMode: "column" | "tooltip";
474
485
  }>;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as l,reactive as t,openBlock as i,createElementBlock as o,createElementVNode as a,Fragment as s,renderList as r,normalizeStyle as u,unref as d,toDisplayString as n,createCommentVNode as f,createVNode as c,withCtx as p,mergeProps as m,renderSlot as v,createTextVNode as y,createBlock as b}from"vue";import{NButton as h}from"naive-ui";import x from"../../../shared/components/VueDraggable/src/vuedraggable.js";import g from"./components/Row.vue.js";import k from"./components/edit-dialog.vue.js";import{cloneDeep as _,omit as w}from"lodash-es";import{setColorInfo as C,setStyle as F}from"./utils/index.js";import{uuidGenerator as j}from"../../../shared/utils/index.js";import{format as A}from"date-fns";const D={class:"main-wrapper"},S={class:"main-wrapper__table-header"},V={class:"main-wrapper__table-body",ref:"tableBodyRef"},B=["tabindex"],E={key:0,class:"main-wrapper__table-footer"};var R=e({__name:"FieldColor",props:{footerFlag:{type:Boolean,default:!0},isFieldColor:{type:Boolean,default:!0},defaultList:{type:Array,default:()=>[]}},emits:["save","close"],setup(e,{expose:R,emit:L}){const M=e,U=l(!1),Y=l(null),H=l([]),I=l([{title:"名称",type:"text",field:"name"},{title:"字段",type:"text",field:"title"},{title:"创建时间",type:"text",field:"createDate"},{title:"效果",type:"text",field:"result"},{title:"颜色",type:"color",field:"color"},{title:"颜色应用于",type:"select",checkedAll:!1,disabledAll:!1,field:"colorScope"},{title:"显示",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"status"},{title:"操作",type:"custom",field:"opt"}]),N=t({columns:I,data:H,onEdit:function(e){Y.value=_(e),U.value=!0},isHighlightRow:!M.isFieldColor});function T(){L("save")}function $(){L("close")}function q(){Y.value=null,U.value=!0}function z(e){if(C(e),Y.value){const l=H.value.findIndex((l=>l.uuid===e.uuid));H.value.splice(l,1,e)}else{const l=A(new Date,"yyyy-MM-dd");H.value.push({...e,createDate:l,uuid:j()})}}return I.value.forEach((e=>{e.isShow=function(e){return!("result"===e.field&&M.isFieldColor||"title"===e.field&&!M.isFieldColor)}(e)})),H.value=M.defaultList.concat(H.value),H.value.forEach((e=>{e.uuid=j(),e.status="Y"===e.status,C(e)})),R({getTableFields:function(){return H.value.map((e=>{const l=_(e);return l.status=l.status?"Y":"N",w(l,["uuid","style","result"])}))}}),(l,t)=>(i(),o("div",D,[a("div",S,[(i(!0),o(s,null,r(I.value,((e,l)=>(i(),o(s,{key:l},[e.isShow?(i(),o("span",{key:0,class:"table-cell",style:u(d(F)(e,l))},n(e.title),5)):f("v-if",!0)],64)))),128))]),a("div",V,[c(d(x),{modelValue:H.value,"onUpdate:modelValue":t[0]||(t[0]=e=>H.value=e),animation:"150","item-key":"id",draggable:".item"},{item:p((({element:e,index:l})=>[e.hide?f("v-if",!0):(i(),o("div",{key:0,class:"item",tabindex:l},[c(g,m(N,{element:e,index:l}),null,16,["element","index"])],8,B))])),_:1},8,["modelValue"])],512),e.footerFlag?(i(),o("div",E,[f(" 底部按钮插槽 "),v(l.$slots,"colorSetFooter",{},(()=>[c(d(h),{style:{"margin-right":"8px"},onClick:$},{default:p((()=>[y("取消")])),_:1}),c(d(h),{style:{"margin-right":"8px"},onClick:q},{default:p((()=>[y("新增")])),_:1}),c(d(h),{type:"primary",onClick:T},{default:p((()=>[y("保存")])),_:1})]))])):f("v-if",!0),U.value?(i(),b(k,{key:1,visible:U.value,"onUpdate:visible":t[1]||(t[1]=e=>U.value=e),"is-field-color":e.isFieldColor,row:Y.value,onConfirm:z},null,8,["visible","is-field-color","row"])):f("v-if",!0)]))}});export{R as default};
1
+ import{defineComponent as e,ref as l,reactive as t,openBlock as i,createElementBlock as o,createElementVNode as a,Fragment as s,renderList as r,normalizeStyle as u,unref as d,toDisplayString as n,createCommentVNode as f,createVNode as c,withCtx as p,mergeProps as m,renderSlot as v,createTextVNode as y,createBlock as b}from"vue";import{NButton as h}from"naive-ui";import x from"../../../shared/components/VueDraggable/src/vuedraggable.js";import g from"./components/table-row.vue.js";import k from"./components/edit-dialog.vue.js";import{cloneDeep as _,omit as w}from"lodash-es";import{setColorInfo as C,setStyle as F}from"./utils/index.js";import{uuidGenerator as j}from"../../../shared/utils/index.js";import{format as A}from"date-fns";const D={class:"main-wrapper"},S={class:"main-wrapper__table-header"},V={class:"main-wrapper__table-body",ref:"tableBodyRef"},B=["tabindex"],E={key:0,class:"main-wrapper__table-footer"};var L=e({__name:"FieldColor",props:{footerFlag:{type:Boolean,default:!0},isFieldColor:{type:Boolean,default:!0},defaultList:{type:Array,default:()=>[]}},emits:["save","close"],setup(e,{expose:L,emit:M}){const R=e,U=l(!1),Y=l(null),H=l([]),I=l([{title:"名称",type:"text",field:"name"},{title:"字段",type:"text",field:"title"},{title:"创建时间",type:"text",field:"createDate"},{title:"效果",type:"text",field:"result"},{title:"颜色",type:"color",field:"color"},{title:"颜色应用于",type:"select",checkedAll:!1,disabledAll:!1,field:"colorScope"},{title:"显示",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"status"},{title:"操作",type:"custom",field:"opt"}]),N=t({columns:I,data:H,onEdit:function(e){Y.value=_(e),U.value=!0},isHighlightRow:!R.isFieldColor});function T(){M("save")}function $(){M("close")}function q(){Y.value=null,U.value=!0}function z(e){if(C(e),Y.value){const l=H.value.findIndex((l=>l.uuid===e.uuid));H.value.splice(l,1,e)}else{const l=A(new Date,"yyyy-MM-dd");H.value.push({...e,createDate:l,uuid:j()})}}return I.value.forEach((e=>{e.isShow=function(e){return!("result"===e.field&&R.isFieldColor||"title"===e.field&&!R.isFieldColor)}(e)})),H.value=R.defaultList.concat(H.value),H.value.forEach((e=>{e.uuid=j(),e.status="Y"===e.status,C(e)})),L({getTableFields:function(){return H.value.map((e=>{const l=_(e);return l.status=l.status?"Y":"N",w(l,["uuid","style","result"])}))}}),(l,t)=>(i(),o("div",D,[a("div",S,[(i(!0),o(s,null,r(I.value,((e,l)=>(i(),o(s,{key:l},[e.isShow?(i(),o("span",{key:0,class:"table-cell",style:u(d(F)(e,l))},n(e.title),5)):f("v-if",!0)],64)))),128))]),a("div",V,[c(d(x),{modelValue:H.value,"onUpdate:modelValue":t[0]||(t[0]=e=>H.value=e),animation:"150","item-key":"id",draggable:".item"},{item:p((({element:e,index:l})=>[e.hide?f("v-if",!0):(i(),o("div",{key:0,class:"item",tabindex:l},[c(g,m(N,{element:e,index:l}),null,16,["element","index"])],8,B))])),_:1},8,["modelValue"])],512),e.footerFlag?(i(),o("div",E,[f(" 底部按钮插槽 "),v(l.$slots,"colorSetFooter",{},(()=>[c(d(h),{style:{"margin-right":"8px"},onClick:$},{default:p((()=>[y("取消")])),_:1}),c(d(h),{style:{"margin-right":"8px"},onClick:q},{default:p((()=>[y("新增")])),_:1}),c(d(h),{type:"primary",onClick:T},{default:p((()=>[y("保存")])),_:1})]))])):f("v-if",!0),U.value?(i(),b(k,{key:1,visible:U.value,"onUpdate:visible":t[1]||(t[1]=e=>U.value=e),"is-field-color":e.isFieldColor,row:Y.value,onConfirm:z},null,8,["visible","is-field-color","row"])):f("v-if",!0)]))}});export{L as default};
@@ -247,6 +247,9 @@ declare const _default: import("vue").DefineComponent<{
247
247
  type: PropType<"column" | "tooltip">;
248
248
  default: string;
249
249
  };
250
+ developMode: {
251
+ type: BooleanConstructor;
252
+ };
250
253
  }, {
251
254
  fixedWayOptions: {
252
255
  label: string;
@@ -335,6 +338,9 @@ declare const _default: import("vue").DefineComponent<{
335
338
  type: PropType<"column" | "tooltip">;
336
339
  default: string;
337
340
  };
341
+ developMode: {
342
+ type: BooleanConstructor;
343
+ };
338
344
  }>> & {
339
345
  onUpdateChecked?: ((...args: any[]) => any) | undefined;
340
346
  onEdit?: ((...args: any[]) => any) | undefined;
@@ -343,6 +349,7 @@ declare const _default: import("vue").DefineComponent<{
343
349
  onRemove: () => void;
344
350
  onEdit: () => void;
345
351
  isRenderTooltip: (field: string) => any;
352
+ getTooltipContent: () => any;
346
353
  getTextValue: (field: string) => any;
347
354
  isMultiple: (field: string) => boolean;
348
355
  isRender: (field: string) => boolean;
@@ -445,6 +452,9 @@ declare const _default: import("vue").DefineComponent<{
445
452
  type: PropType<"column" | "tooltip">;
446
453
  default: string;
447
454
  };
455
+ developMode: {
456
+ type: BooleanConstructor;
457
+ };
448
458
  }>> & {
449
459
  onUpdateChecked?: ((...args: any[]) => any) | undefined;
450
460
  onEdit?: ((...args: any[]) => any) | undefined;
@@ -487,10 +497,11 @@ declare const _default: import("vue").DefineComponent<{
487
497
  requiredDisable: boolean;
488
498
  hide: boolean;
489
499
  }>;
500
+ developMode: boolean;
490
501
  draggable: boolean;
502
+ isHighlightRow: boolean;
491
503
  idx: number;
492
504
  isHighlight: boolean;
493
- isHighlightRow: boolean;
494
505
  isFieldSet: boolean;
495
506
  fieldDescribeMode: "column" | "tooltip";
496
507
  }>;