cnhis-design-vue 3.1.57 → 3.2.1-beta.11

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 (156) hide show
  1. package/README.md +87 -87
  2. package/es/components/button-print/index.d.ts +1 -0
  3. package/es/components/button-print/src/ButtonPrint.vue.d.ts +1 -0
  4. package/es/components/button-print/src/ButtonPrint.vue2.js +1 -1
  5. package/es/components/button-print/src/utils/print.d.ts +15 -3
  6. package/es/components/button-print/src/utils/print.js +1 -1
  7. package/es/components/calendar/index.d.ts +24 -13
  8. package/es/components/calendar/src/Calendar.vue.d.ts +24 -13
  9. package/es/components/calendar/src/Calendar.vue2.js +1 -1
  10. package/es/components/callback/src/components/render/popupMaps.d.ts +290 -0
  11. package/es/components/classification/src/components/table-modal/index.vue.d.ts +3 -0
  12. package/es/components/classification/src/index.vue.d.ts +3 -3
  13. package/es/components/drag-scroll/index.d.ts +2 -0
  14. package/es/components/drag-scroll/index.js +1 -0
  15. package/es/components/drag-scroll/src/index.d.ts +4 -0
  16. package/es/components/drag-scroll/src/index.js +1 -0
  17. package/es/components/drag-scroll/src/types.d.ts +24 -0
  18. package/es/components/drag-scroll/src/types.js +1 -0
  19. package/es/components/expand-field/src/components/form.vue2.js +1 -1
  20. package/es/components/fabric-chart/src/constants/index.d.ts +2 -1
  21. package/es/components/fabric-chart/src/constants/index.js +1 -1
  22. package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogram.js +1 -1
  23. package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogramChart.js +1 -1
  24. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useCenter.js +1 -1
  25. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useLeft.js +1 -1
  26. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useSurgicalAnesthesiaChart.js +1 -1
  27. package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useTop.js +1 -1
  28. package/es/components/fabric-chart/src/hooks/temperature/useCenter.js +1 -1
  29. package/es/components/fabric-chart/src/interface.d.ts +1 -1
  30. package/es/components/fabric-chart/src/utils/index.js +1 -1
  31. package/es/components/field-set/index.d.ts +1 -1
  32. package/es/components/field-set/src/FieldColor.vue.d.ts +2 -1
  33. package/es/components/field-set/src/FieldSet.vue.d.ts +1 -0
  34. package/es/components/field-set/src/Index.vue.d.ts +1 -1
  35. package/es/components/field-set/src/Index.vue2.js +1 -1
  36. package/es/components/field-set/src/TableStyle.vue.d.ts +71 -0
  37. package/es/components/field-set/src/TableStyle.vue.js +1 -0
  38. package/es/components/field-set/src/TableStyle.vue2.js +1 -0
  39. package/es/components/field-set/src/components/Row.vue.d.ts +1 -0
  40. package/es/components/field-set/src/components/Row.vue2.js +1 -1
  41. package/es/components/field-set/src/components/edit-dialog.vue.d.ts +1 -1
  42. package/es/components/field-set/src/types/index.d.ts +1 -1
  43. package/es/components/field-set/style/index.css +1 -1
  44. package/es/components/form-config/index.d.ts +34 -0
  45. package/es/components/form-config/src/FormConfig.vue.d.ts +34 -0
  46. package/es/components/form-config/src/components/FormConfigCreator.vue.d.ts +14 -0
  47. package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +17 -0
  48. package/es/components/form-render/index.d.ts +14 -0
  49. package/es/components/form-render/src/FormRender.vue.d.ts +14 -0
  50. package/es/components/form-render/src/FormRender.vue2.js +1 -1
  51. package/es/components/form-render/src/FormRenderWrapper.vue.d.ts +14 -0
  52. package/es/components/form-render/src/components/renderer/index.js +1 -1
  53. package/es/components/form-render/src/components/renderer/select.d.ts +2 -0
  54. package/es/components/form-render/src/components/renderer/select.js +1 -1
  55. package/es/components/form-render/src/components/renderer/simpleComponent.js +1 -1
  56. package/es/components/form-render/src/components/renderer/time.d.ts +7 -0
  57. package/es/components/form-render/src/components/renderer/time.js +1 -0
  58. package/es/components/form-render/src/hooks/useFieldListAdaptor.js +1 -1
  59. package/es/components/form-render/src/hooks/useFieldNormalize.d.ts +6 -4
  60. package/es/components/form-render/src/hooks/useFieldNormalize.js +1 -1
  61. package/es/components/form-render/src/hooks/useFormRenderOptions.js +1 -1
  62. package/es/components/form-render/src/types/index.d.ts +1 -0
  63. package/es/components/form-render/src/utils/business.d.ts +1 -1
  64. package/es/components/form-render/src/utils/business.js +1 -1
  65. package/es/components/iho-table/index.d.ts +276 -0
  66. package/es/components/iho-table/src/IhoTable.vue.d.ts +276 -0
  67. package/es/components/iho-table/src/IhoTable.vue2.js +1 -1
  68. package/es/components/iho-table/src/hooks/tapHooks/index.d.ts +1 -5
  69. package/es/components/iho-table/src/hooks/tapHooks/index.js +1 -1
  70. package/es/components/iho-table/src/hooks/tapHooks/useDataHooks.d.ts +2 -1
  71. package/es/components/iho-table/src/hooks/tapHooks/useDataHooks.js +1 -1
  72. package/es/components/iho-table/src/plugins/dragScrollPlugin.js +1 -1
  73. package/es/components/iho-table/src/plugins/filterRenderPlugin/filter.vue.d.ts +1 -1
  74. package/es/components/iho-table/src/plugins/filterRenderPlugin/filter.vue2.js +1 -1
  75. package/es/components/iho-table/src/plugins/filterRenderPlugin/index.js +1 -1
  76. package/es/components/iho-table/src/plugins/headerPlugin.js +1 -1
  77. package/es/components/iho-table/src/plugins/index.js +1 -1
  78. package/es/components/iho-table/src/plugins/lowCodeFieldAdaptorPlugin.js +1 -1
  79. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/index.js +1 -1
  80. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/levelSearchCascadePlugin/index.js +1 -1
  81. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/levelSearchCascadePlugin/levelSearchCascade.vue.d.ts +1 -1
  82. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/numberRendererPlugin.js +1 -1
  83. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/editSelect.js +1 -1
  84. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/index.js +1 -1
  85. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/index.js +1 -1
  86. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue.d.ts +15 -12
  87. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue2.js +1 -1
  88. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/index.js +1 -1
  89. package/es/components/iho-table/src/plugins/varialbleHeightPlugin.js +1 -1
  90. package/es/components/iho-table/src/plugins/verticalTablePlugin/constants.d.ts +1 -0
  91. package/es/components/iho-table/src/plugins/verticalTablePlugin/constants.js +1 -0
  92. package/es/components/iho-table/src/plugins/verticalTablePlugin/index.d.ts +1 -0
  93. package/es/components/iho-table/src/plugins/verticalTablePlugin/index.js +1 -0
  94. package/es/components/iho-table/src/plugins/verticalTablePlugin/renderer.d.ts +6 -0
  95. package/es/components/iho-table/src/plugins/verticalTablePlugin/renderer.js +1 -0
  96. package/es/components/iho-table/src/plugins/verticalTablePlugin/types.d.ts +12 -0
  97. package/es/components/iho-table/src/plugins/verticalTablePlugin/types.js +1 -0
  98. package/es/components/iho-table/src/plugins/verticalTablePlugin/utils.d.ts +28 -0
  99. package/es/components/iho-table/src/plugins/verticalTablePlugin/utils.js +1 -0
  100. package/es/components/iho-table/src/types/index.d.ts +10 -1
  101. package/es/components/iho-table/src/types/pluginType.d.ts +3 -1
  102. package/es/components/iho-table/src/utils/index.d.ts +5 -7
  103. package/es/components/iho-table/src/utils/index.js +1 -1
  104. package/es/components/index.css +1 -1
  105. package/es/components/index.d.ts +1 -0
  106. package/es/components/index.js +1 -1
  107. package/es/components/info-header/index.d.ts +33 -0
  108. package/es/components/info-header/src/InfoHeader.vue.d.ts +33 -0
  109. package/es/components/info-header/src/components/infoDescription/DescriptionItem.vue.d.ts +1 -0
  110. package/es/components/info-header/src/components/infoDescription/DescriptionList.vue.d.ts +1 -0
  111. package/es/components/info-header/src/components/infoDescription/index.vue.d.ts +15 -0
  112. package/es/components/info-header/src/components/patientInfo/index.vue.d.ts +14 -0
  113. package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
  114. package/es/components/search-cascader/index.d.ts +1 -1
  115. package/es/components/search-cascader/src/SearchCascader.vue.d.ts +1 -1
  116. package/es/components/search-cascader/src/components/SearchMenu.d.ts +1 -1
  117. package/es/components/select-label/src/LabelFormContent.vue2.js +1 -1
  118. package/es/components/select-person/src/SearchMultiple.vue.d.ts +6 -0
  119. package/es/components/shortcut-setter/index.d.ts +14 -0
  120. package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +14 -0
  121. package/es/components/steps-wheel/src/StepsWheel.vue2.js +1 -1
  122. package/es/components/table-export-field/src/components/ExportModal.vue.d.ts +0 -3
  123. package/es/components/table-export-field/src/components/ExportModal.vue2.js +1 -1
  124. package/es/components/table-export-field/style/index.css +1 -1
  125. package/es/components/table-export-field/style/table-export-field-iconfont.ttf +0 -0
  126. package/es/env.d.ts +25 -25
  127. package/es/shared/assets/img/failure.png.js +1 -1
  128. package/es/shared/assets/img/no-permission.png.js +1 -1
  129. package/es/shared/assets/img/nodata.png.js +1 -1
  130. package/es/shared/assets/img/notfound.png.js +1 -1
  131. package/es/shared/assets/img/qr.png.js +1 -1
  132. package/es/shared/assets/img/success.png.js +1 -1
  133. package/es/shared/assets/img/table_style_1.png.js +1 -0
  134. package/es/shared/assets/img/table_style_2.png.js +1 -0
  135. package/es/shared/assets/img/table_style_3.png.js +1 -0
  136. package/es/shared/assets/img/table_style_4.png.js +1 -0
  137. package/es/shared/assets/img/video.png.js +1 -1
  138. package/es/shared/assets/img/video_default_cover.png.js +1 -1
  139. package/es/shared/assets/img/xb_big.png.js +1 -1
  140. package/es/shared/assets/img/xb_small.png.js +1 -1
  141. package/es/shared/components/InputNumberSlash/InputNumberSlash.js +1 -1
  142. package/es/shared/hooks/selectHooks/useOptionFiltered.d.ts +3 -1
  143. package/es/shared/hooks/selectHooks/useOptionFiltered.js +1 -1
  144. package/es/shared/hooks/selectHooks/useSearchContent.d.ts +1 -1
  145. package/es/shared/hooks/selectHooks/useSearchContent.js +1 -1
  146. package/es/shared/package.json.js +1 -1
  147. package/es/shared/utils/index.d.ts +2 -1
  148. package/es/shared/utils/index.js +1 -1
  149. package/package.json +3 -2
  150. package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
  151. package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +0 -1
  152. package/es/components/bpmn-workflow/types/ModelingModule.d.ts +0 -1
  153. package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +0 -1
  154. package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +0 -86
  155. package/es/shared/utils/fabricjs/index.d.ts +0 -6823
  156. 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
+ ```
@@ -173,6 +173,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
173
173
  }>>;
174
174
  emit: (event: "success" | "error" | "clickoutside", ...args: any[]) => void;
175
175
  defaultFormatInfo: import("../../shared/types").AnyObject;
176
+ authorizationKey: import("vue").Ref<string>;
176
177
  state: {
177
178
  spinning: boolean;
178
179
  visible: boolean;
@@ -180,6 +180,7 @@ declare const _default: import("vue").DefineComponent<{
180
180
  }>>;
181
181
  emit: (event: "success" | "error" | "clickoutside", ...args: any[]) => void;
182
182
  defaultFormatInfo: AnyObject;
183
+ authorizationKey: import("vue").Ref<string>;
183
184
  state: {
184
185
  spinning: boolean;
185
186
  visible: boolean;
@@ -1 +1 @@
1
- import{defineComponent as t,reactive as e,computed as n,onMounted as i,watch as r,openBlock as a,createElementBlock as s,Fragment as o,createVNode as l,unref as p,withCtx as d,renderSlot as m,withModifiers as u,createTextVNode as c,toDisplayString as f,mergeProps as g}from"vue";import{isObject as y}from"@vue/shared";import{useMessage as v,NDropdown as b,NButton as I,NIcon as P}from"naive-ui";import{ChevronDown as h}from"@vicons/ionicons5";import{Print as w}from"./utils/print.js";import{isIReport as F}from"./utils/browserPrint.js";import k from"./components/IdentityVerification.vue.js";import{format as T}from"date-fns";import{savePrivateFormatApi as x,getPrivateFormatApi as S}from"./api.js";var L=t({__name:"ButtonPrint",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0}},emits:["success","error","clickoutside"],setup(t,{expose:L,emit:O}){var j;const D=t,E=v();let M;const N={},V=e({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null}),C=e([{label:D.printText,key:"printText"},{label:D.previewText,key:"previewText"},{label:D.pdfLoadText,key:"downloadPdf"},{label:D.formatEditText,key:"formatEditText"},...(null==(j=D.externalOptionConfig)?void 0:j.options)||[]]),B=n((()=>{if(!V.currentFormatId)return{};let t=V.currentFormatId;return V.formatList.find((e=>e.id===t))})),J=n((()=>{var t;return(null==(t=B.value)?void 0:t.name)||"格式选择"})),U=n((()=>{let t=V.formatList.find((t=>t.id===V.currentFormatId));return null==t?void 0:t.templateId})),A=async t=>{if(D.directPrint){if(V.spinning)return;return"button"===t?void await rt():et()}return et()},q=t=>l("span",{class:{active:t.key===V.currentFormatId}},[t.label]),R=(t,e)=>{V.spinning=!1;let n={type:e,formatId:V.currentFormatId,templateId:U.value};O("success",t,n)},_=t=>{V.spinning=!1,O("error",t),y(t)&&"notInstalledApp"===t.type&&E.error(t.message)},z=t=>{O("error",{message:"前置条件执行错误",type:t,preExecution:!0})},H=(t=0)=>{var e;const n=(null==(e=D.printParams)?void 0:e.length)?D.printParams[t]:V.printParams[t];return JSON.stringify({...n||{},...D.token?{token:D.token}:{}})},$=()=>{var t,e;let n={},i={};if(null==(t=V.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(V.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(V.printParams.map((e=>JSON.parse(e.datasetData[t]))));i={datasetData:{}},i.datasetData[t]=n}else Object.keys(V.printParams[0]).forEach((t=>{i[t]=[],V.printParams.forEach((e=>{i[t].includes(e[t])||i[t].push(e[t])})),i[t]=i[t].join(",")}));return n=Object.assign({},JSON.parse(H(0)),i),JSON.stringify(n)},G=()=>{let t=V.printParams.length;const e=async e=>{try{--t<=0&&R(e,"print")}catch(t){console.log("error",t)}};D.showLoading&&V.spinning||(V.spinning=!0,D.prevFn("print").then((()=>{const t={formatId:V.currentFormatId,templateId:U.value,printdlgshow:D.printdlgshow,signature:D.signature};if("MULTI"===D.strategy)for(let n=0;n<V.printParams.length;n++)n>0&&(t.printdlgshow="0"),M.printDirect({...t,params:H(n)},e,_);else M.printDirect({...t,params:$()},(t=>{R(t,"print")}),_)})).catch((()=>{z("print"),V.spinning=!1})).finally((()=>{V.visible=!1})))},K=async(t,e)=>{var n,i;switch(t){case"printText":G();break;case"previewText":(async()=>{D.showLoading&&V.spinning||(V.spinning=!0,D.prevFn("preview").then((()=>{const t="MULTI"===D.strategy?H():$(),e={formatId:V.currentFormatId,templateId:U.value,params:t,btnprint:D.btnprint,signature:D.signature};M.preview(e,(t=>{R(t,"preview")}),_)})).catch((()=>{z("preview"),V.spinning=!1})).finally((()=>{V.visible=!1})))})();break;case"formatEditText":D.showLoading&&V.spinning||(V.spinning=!0,D.prevFn("edit").then((()=>{V.identityVerification.visible=!0})).catch((()=>{z("edit")})).finally((()=>{V.visible=!1,V.spinning=!1})));break;case"downloadPdf":(async()=>{D.showLoading&&V.spinning||(V.spinning=!0,D.prevFn("download").then((()=>{const t="MULTI"===D.strategy?H():$(),e={formatId:V.currentFormatId,templateId:U.value,print:{print:"1",type:"1"},params:t,signature:D.signature};M.downloadPDF(e,(t=>R(t,"preview")),_)})).catch((()=>{z("download"),V.spinning=!1})).finally((()=>{V.visible=!1})))})();break;default:{V.visible=!1;const r=V.formatList.find((e=>e.id===t))||{};if(Object.keys(r).length>0){V.currentFormatId=t;const[e]=C;e.label=(null==r?void 0:r.name)||e.label,await x({formatForms:[{...r}],name:N.name||r.templateName,number:N.number||r.number,templateId:N.templateId||r.templateId,...N.id?{id:N.id}:{}},{token:D.token})}else null==(i=null==(n=D.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},Q=()=>{V.visible=!1,O("clickoutside")},W=()=>(V.isInited=!1,V.spinning=!1,setTimeout((()=>{V.visible=!1}),0),!1),X=(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=T(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},Y=({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(X(n,e,"fieldName"))}})),i=Object.assign({},i,X(n,e,"key")),i})),Z=async t=>{var e;if(V.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],V.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";const{data:i}=await S({templateId:t[0].templateId},{token:D.token});if("SUCCESS"===i.result){const{formatForms:e=[]}=i.map||{};Object.assign(N,i.map||{});const r=null==(n=null==e?void 0:e[0])?void 0:n.id;if(r&&t.map((t=>t.id)).includes(r))return r}const r=t.find((t=>1==t[e]));return(null==r?void 0:r.id)||t[0].id})(V.formatList,"defaultFlag"),!V.currentFormatId)return E.error("获取打印格式失败,请联系管理员!"),W();(()=>{const t=V.formatList.map((t=>({label:t.name,key:t.id})));C.unshift({label:J.value,key:"format",children:t})})();let n=null==(e=await D.queryTemplateParams())?void 0:e.obj;if(!n||!U.value)return E.error("获取打印模板失败,请联系管理员!"),W();V.templateParams=n,V.printParams=Y(V.templateParams,D.params)},tt=async()=>{if(V.isInited)return!0;V.isInited=!0,V.spinning=!0,(()=>{if(M)return!1;M=new w})();const t=await D.queryPrintFormatByNumber();return await Z(t),V.spinning=!1,!0},et=async(t=!0)=>{var e,n;if(await D.clickPrevFn())if((null==(e=D.params)?void 0:e.length)||(null==(n=D.printParams)?void 0:n.length)){if(!V.visible){if(!await tt())return!1}t&&(V.visible=!V.visible)}else E.warning(D.noDataMsg)},nt=()=>{V.watchPrintParamsReformatFn&&V.watchPrintParamsReformatFn(),V.isInited?V.printParams=Y(V.templateParams,D.params):V.watchPrintParamsReformatFn=()=>r((()=>V.isInited),(t=>{if(!t)return!1;nt()}))},it=t=>{if(V.identityVerification.visible=!1,F(V.currentFormatId))return R(null,"edit");const e={formatId:V.currentFormatId,templateId:U.value,params:H(),token:t};M.editPrintFormat(e,(t=>{R(t,"edit")}),_)};async function rt(){await et(!1),G()}return i((()=>{V.isInited=!1})),r((()=>D.params),(t=>{if(!(null==t?void 0:t.length))return!1;nt()}),{deep:!0}),L({directPrint:rt}),(e,n)=>(a(),s(o,null,[l(p(b),{class:"c-dropdown",placement:"bottom-start",trigger:"click",show:V.visible,onClickoutside:Q,options:C,onSelect:K,"render-label":q},{default:d((()=>[m(e.$slots,"button",{handleClickPrintBtn:et,printSpinning:V.spinning,printbtnText:t.btnText,printVisible:V.visible},(()=>[l(p(I),{class:"dropdown-button",loading:t.showLoading&&V.spinning,onClick:n[1]||(n[1]=u((()=>A("button")),["stop"]))},{default:d((()=>[c(f(t.btnText)+" ",1),l(p(P),{component:p(h),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=u((()=>A("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["show","options"]),l(k,g(e.$attrs,{modelValue:V.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>V.identityVerification.visible=t),formatId:V.currentFormatId,templateId:p(U),onSuccess:it}),null,16,["modelValue","formatId","templateId"])],64))}});export{L as default};
1
+ import{defineComponent as t,ref as e,reactive as n,computed as i,onMounted as a,watch as r,openBlock as o,createElementBlock as s,Fragment as l,createVNode as p,unref as d,withCtx as m,renderSlot as u,withModifiers as c,createTextVNode as f,toDisplayString as g,mergeProps as y}from"vue";import{isObject as v}from"@vue/shared";import{useMessage as b,NDropdown as h,NButton as I,NIcon as P}from"naive-ui";import{ChevronDown as w}from"@vicons/ionicons5";import{Print as F}from"./utils/print.js";import{isIReport as k}from"./utils/browserPrint.js";import T from"./components/IdentityVerification.vue.js";import{format as x}from"date-fns";import{savePrivateFormatApi as S,getPrivateFormatApi as L}from"./api.js";var j=t({__name:"ButtonPrint",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0}},emits:["success","error","clickoutside"],setup(t,{expose:j,emit:O}){var D;const E=t,M=b();let N;const V={},C=e(""),z=n({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null}),B=n([{label:E.printText,key:"printText"},{label:E.previewText,key:"previewText"},{label:E.pdfLoadText,key:"downloadPdf"},{label:E.formatEditText,key:"formatEditText"},...(null==(D=E.externalOptionConfig)?void 0:D.options)||[]]),J=i((()=>{if(!z.currentFormatId)return{};let t=z.currentFormatId;return z.formatList.find((e=>e.id===t))})),U=i((()=>{var t;return(null==(t=J.value)?void 0:t.name)||"格式选择"})),A=i((()=>{let t=z.formatList.find((t=>t.id===z.currentFormatId));return null==t?void 0:t.templateId})),q=async t=>{if(E.directPrint){if(z.spinning)return;return"button"===t?void await ot():it()}return it()},K=t=>p("span",{class:{active:t.key===z.currentFormatId}},[t.label]),R=(t,e)=>{z.spinning=!1;let n={type:e,formatId:z.currentFormatId,templateId:A.value};O("success",t,n)},_=t=>{z.spinning=!1,O("error",t),v(t)&&"notInstalledApp"===t.type&&M.error(t.message)},H=t=>{O("error",{message:"前置条件执行错误",type:t,preExecution:!0})},$=(t=0)=>{var e;const n=(null==(e=E.printParams)?void 0:e.length)?E.printParams[t]:z.printParams[t];return JSON.stringify({...n||{},...E.token?{token:E.token}:{}})},G=()=>{var t,e;let n={},i={};if(null==(t=z.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(z.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(z.printParams.map((e=>JSON.parse(e.datasetData[t]))));i={datasetData:{}},i.datasetData[t]=n}else Object.keys(z.printParams[0]).forEach((t=>{i[t]=[],z.printParams.forEach((e=>{i[t].includes(e[t])||i[t].push(e[t])})),i[t]=i[t].join(",")}));return n=Object.assign({},JSON.parse($(0)),i),JSON.stringify(n)},Q=()=>{let t=z.printParams.length;const e=async e=>{try{--t<=0&&R(e,"print")}catch(t){console.log("error",t)}};E.showLoading&&z.spinning||(z.spinning=!0,E.prevFn("print").then((()=>{const t={formatId:z.currentFormatId,templateId:A.value,authorizationKey:C.value,printdlgshow:E.printdlgshow,signature:E.signature};if("MULTI"===E.strategy)for(let n=0;n<z.printParams.length;n++)n>0&&(t.printdlgshow="0"),N.printDirect({...t,params:$(n)},e,_);else N.printDirect({...t,params:G()},(t=>{R(t,"print")}),_)})).catch((()=>{H("print"),z.spinning=!1})).finally((()=>{z.visible=!1})))},W=async(t,e)=>{var n,i;switch(t){case"printText":Q();break;case"previewText":(async()=>{E.showLoading&&z.spinning||(z.spinning=!0,E.prevFn("preview").then((()=>{const t="MULTI"===E.strategy?$():G(),e={formatId:z.currentFormatId,templateId:A.value,authorizationKey:C.value,params:t,btnprint:E.btnprint,signature:E.signature};N.preview(e,(t=>{R(t,"preview")}),_)})).catch((()=>{H("preview"),z.spinning=!1})).finally((()=>{z.visible=!1})))})();break;case"formatEditText":E.showLoading&&z.spinning||(z.spinning=!0,E.prevFn("edit").then((()=>{z.identityVerification.visible=!0})).catch((()=>{H("edit")})).finally((()=>{z.visible=!1,z.spinning=!1})));break;case"downloadPdf":(async()=>{E.showLoading&&z.spinning||(z.spinning=!0,E.prevFn("download").then((()=>{const t="MULTI"===E.strategy?$():G(),e={formatId:z.currentFormatId,templateId:A.value,authorizationKey:C.value,print:{print:"1",type:"1"},params:t,signature:E.signature};N.downloadPDF(e,(t=>R(t,"preview")),_)})).catch((()=>{H("download"),z.spinning=!1})).finally((()=>{z.visible=!1})))})();break;default:{z.visible=!1;const a=z.formatList.find((e=>e.id===t))||{};if(Object.keys(a).length>0){z.currentFormatId=t;const[e]=B;e.label=(null==a?void 0:a.name)||e.label,await S({formatForms:[{...a}],name:V.name||a.templateName,number:V.number||a.number,templateId:V.templateId||a.templateId,...V.id?{id:V.id}:{}},{token:E.token})}else null==(i=null==(n=E.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},X=()=>{z.visible=!1,O("clickoutside")},Y=()=>(z.isInited=!1,z.spinning=!1,setTimeout((()=>{z.visible=!1}),0),!1),Z=(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=x(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&a&&(i[e[n]]=a)})),i},tt=({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(Z(n,e,"fieldName"))}})),i=Object.assign({},i,Z(n,e,"key")),i})),et=async t=>{var e;if(z.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):[],z.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";const{data:i}=await L({templateId:t[0].templateId},{token:E.token});if("SUCCESS"===i.result){const{formatForms:e=[]}=i.map||{};Object.assign(V,i.map||{});const a=null==(n=null==e?void 0:e[0])?void 0:n.id;if(a&&t.map((t=>t.id)).includes(a))return a}const a=t.find((t=>1==t[e]));return(null==a?void 0:a.id)||t[0].id})(z.formatList,"defaultFlag"),!z.currentFormatId)return M.error("获取打印格式失败,请联系管理员!"),Y();(()=>{const t=z.formatList.map((t=>({label:t.name,key:t.id})));B.unshift({label:U.value,key:"format",children:t})})();let n=null==(e=await E.queryTemplateParams())?void 0:e.obj;if(!n||!A.value)return M.error("获取打印模板失败,请联系管理员!"),Y();z.templateParams=n,z.printParams=tt(z.templateParams,E.params)},nt=async()=>{var t;if(z.isInited)return!0;z.isInited=!0,z.spinning=!0,(()=>{if(N)return!1;N=new F})();const e=await E.queryPrintFormatByNumber();return await et(e),(null==(t=e.obj)?void 0:t.length)>0&&(C.value=e.obj[0].authorizationKey||""),z.spinning=!1,!0},it=async(t=!0)=>{var e,n;if(await E.clickPrevFn())if((null==(e=E.params)?void 0:e.length)||(null==(n=E.printParams)?void 0:n.length)){if(!z.visible){if(!await nt())return!1}t&&(z.visible=!z.visible)}else M.warning(E.noDataMsg)},at=()=>{z.watchPrintParamsReformatFn&&z.watchPrintParamsReformatFn(),z.isInited?z.printParams=tt(z.templateParams,E.params):z.watchPrintParamsReformatFn=()=>r((()=>z.isInited),(t=>{if(!t)return!1;at()}))},rt=t=>{if(z.identityVerification.visible=!1,k(z.currentFormatId))return R(null,"edit");const e={formatId:z.currentFormatId,templateId:A.value,params:$(),token:t};N.editPrintFormat(e,(t=>{R(t,"edit")}),_)};async function ot(){await it(!1),Q()}return a((()=>{z.isInited=!1})),r((()=>E.params),(t=>{if(!(null==t?void 0:t.length))return!1;at()}),{deep:!0}),j({directPrint:ot}),(e,n)=>(o(),s(l,null,[p(d(h),{class:"c-dropdown",placement:"bottom-start",trigger:"click",show:z.visible,onClickoutside:X,options:B,onSelect:W,"render-label":K},{default:m((()=>[u(e.$slots,"button",{handleClickPrintBtn:it,printSpinning:z.spinning,printbtnText:t.btnText,printVisible:z.visible},(()=>[p(d(I),{class:"dropdown-button",loading:t.showLoading&&z.spinning,onClick:n[1]||(n[1]=c((()=>q("button")),["stop"]))},{default:m((()=>[f(g(t.btnText)+" ",1),p(d(P),{component:d(w),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=c((()=>q("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["show","options"]),p(T,y(e.$attrs,{modelValue:z.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>z.identityVerification.visible=t),formatId:z.currentFormatId,templateId:d(A),onSuccess:rt}),null,16,["modelValue","formatId","templateId"])],64))}});export{j as default};
@@ -11,9 +11,17 @@ export declare class Print {
11
11
  private isRemote;
12
12
  private CMonitor;
13
13
  private queryServicesParams;
14
+ private isConnectHiPrint;
15
+ private clientInfo;
16
+ private printerList;
17
+ private hiPrintSocket;
18
+ private base64Fragment;
19
+ private _successCallbackFn;
20
+ private _errorCallbackFn;
14
21
  constructor();
15
22
  private readonly messageHandlerQueue;
16
23
  private messageHandler;
24
+ private _initDomesticSystem;
17
25
  getPicAndUpload(obj: any): Promise<void>;
18
26
  _uploadImageServices(uploadParams: AnyObject): Promise<any>;
19
27
  private postMessage;
@@ -47,15 +55,19 @@ export declare class Print {
47
55
  _handleEventEditFormat({ templateId, formatId, params, token, messageTimeout }: AnyObject): Promise<any>;
48
56
  _queryProxyOrigin(): Promise<void>;
49
57
  _queryPrintFile(formatId: string, params?: string): Promise<any>;
58
+ paramsSerializer(params: AnyObject): AnyObject;
59
+ _queryPrintForBase64(templateId: string, formatId: string, params: string | undefined, authorizationKey: String): Promise<any>;
60
+ _queryPrintForPdf(templateId: string, formatId: string, params: string | undefined, authorizationKey: String): Promise<any>;
50
61
  _browserPrint(result: AnyObject, mode: string): Promise<string | void>;
51
- preview({ templateId, formatId, params, signature, btnprint, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<any>;
62
+ _base64ToBlob(fileBase64: string, fileType: string): Blob;
63
+ preview({ templateId, formatId, params, authorizationKey, signature, btnprint, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<any>;
52
64
  printSync(data: AnyObject[], successCallbackFn: AnyFn, errorCallbackFn: AnyFn): Promise<void>;
53
- printDirect({ templateId, formatId, params, print, signature, printdlgshow, nobillnode, isDownloadFile, messageTimeout }: AnyObject, successCallbackFn: AnyFn, errorCallbackFn: AnyFn, mode?: string): Promise<any>;
65
+ printDirect({ templateId, formatId, params, authorizationKey, print, signature, printdlgshow, nobillnode, isDownloadFile, messageTimeout }: AnyObject, successCallbackFn: AnyFn, errorCallbackFn: AnyFn, mode?: string): Promise<any>;
54
66
  private _downloadPDF;
55
67
  /**
56
68
  * 下载pdf
57
69
  */
58
- downloadPDF(params: AnyObject, onResolve: AnyFn, onReject: AnyFn): void;
70
+ downloadPDF(params: AnyObject, onResolve: AnyFn, onReject: AnyFn): Promise<any>;
59
71
  print({ templateId, formatId, params, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<false | undefined>;
60
72
  queryPrintData({ templateId, formatId, params, messageTimeout }: AnyObject, successCallbackFn?: AnyFn, errorCallbackFn?: AnyFn): Promise<false | {
61
73
  file: any;
@@ -1 +1 @@
1
- import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as a,useBrowserPrint as r,isIReport as n}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as d}from"date-fns";const c=t.create({timeout:1e3,withCredentials:!1}),u=`${window.location.protocol}//${window.location.host}`,m=`${u}/fdp-api/print/assembly/printIReport`,h=`${u}/bi-api/reprot/print/open/client/getRemote`,p=`${u}/bi-api/reprot/print/open/client/uploadTemplate`,f=`${u}/printService/file`;let w=null;class g{constructor(){var t,e,a;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.messageHandlerQueue=[],w)return w;w=this;const r=window;this.CMonitor=r.$CMonitor;try{this.webview=r.top?null==(t=r.top.chrome)?void 0:t.webview:null==(e=r.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(a=r.chrome)?void 0:a.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:a}=e;try{s(i.res||"")}catch(t){a(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}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:2,callback:1};const i=await this._queryServicesPrint(this.queryServicesParams);if(i&&i.filebase64&&i.key){const t={templateId:this.queryServicesParams.templateId,formatId:this.queryServicesParams.formatId,fileBase64:i.filebase64,authorizationKey:i.key,params:this.queryServicesParams.params},e=await this._uploadImageServices(t);"success"===(null==e?void 0:e.result)&&console.log("图片上传成功")}}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async _uploadImageServices(t){const e=new FormData;Object.keys(t).forEach((i=>{e.append(i,t[i])}));const{data:i}=await c({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:p,data:e})||{};return i}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{c({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):c({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const i=t.message||t.Message;this._handleMonitorNotify(i);const s={type:"printError",message:i,result:t.result,errinfo:t.errinfo};return null==e||e(s),!1}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,a){const r={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},n=await this._queryServicesPrint(r);return this._handleQueryPrintDataResult(n,e,a)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,cmdid:s,print:a,signature:r,printdlgshow:n="0",nobillnode:o="1",btnprint:l="1",messageTimeout:c=0}){const u={templateId:t,formatId:e,params:i,cmdid:s,nobillnode:o,printdlgshow:n,btnprint:l,messageTimeout:c,...r?{signature:r}:{}};if(a){try{a=JSON.parse(a)}catch(t){}u.print=a}else if(this.isRemote){const t=d(new Date,"yyyyMMddHHmmss");u.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=u,await this._queryServicesPrint(u)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:a=0}){const r={};let n={};try{n=Object.assign({},r,JSON.parse(i))}catch(t){n=r}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(n),messageTimeout:a};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await c({method:"get",url:h})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=u+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await c({method:"post",url:m,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),n=s[s.length-2],o=s[s.length-1],l=await a(`${f}/${n}/${o}`),d=r(null,e,l);if("preview"===e)return d}}async preview({templateId:t,formatId:e,params:i="",signature:s,btnprint:a,messageTimeout:l=0},d,c){if(n(e)){const t=await this._queryPrintFile(e,i);if(!t)return null==c?void 0:c("获取文件失败!");const s=r(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,s),void(null==d||d({file:t}))}await this._queryProxyOrigin();const u=await this._testConnection();if(!this._handleResultTest(u,c))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:this.isRemote?"7":"8",signature:s,btnprint:a,messageTimeout:l}),n=this._handleResult(r,c);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==d||d(n)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==c||c(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(),a=await this.messageCollect(t,{exec:"printA",data:s});if(a&&Array.isArray(a)){a.some((t=>"success"===t.res.result))?null==e||e(a):(null==i||i(a),this._handleMonitorNotify(a))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(a||""),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="",print:s,signature:a,printdlgshow:o,nobillnode:l,isDownloadFile:d=!0,messageTimeout:c=0},u,m,h="printDirect"){if(n(e)){const t=await this._queryPrintFile(e,i);return t?(r(t,h),void(null==u||u({file:t}))):null==m?void 0:m("获取文件失败!")}await this._queryProxyOrigin();const p=await this._testConnection();if(!this._handleResultTest(p,m))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:"7",print:s,signature:a,printdlgshow:o,nobillnode:l,messageTimeout:c}),n=this._handleResult(r,m);if(!n)return!1;d&&["downloadPDF"].includes(h)&&await this._browserPrint(n,h),null==u||u(n)}catch(t){const e="printDirect"===h?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==m||m(i),this._handleMonitorNotify(i)}}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):c.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}downloadPDF(t,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=d(new Date,"yyyy-MM-dd"),i=l(),s=d(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}this.printDirect(t,(async a=>{if(a||s(null),n(t.formatId))return i(a);const r=this,o=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(a.filedir);i(o,a)}),(t=>s(t)),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},a,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,r);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,r);if(!l)return!1;a&&a(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},a,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,r);return!!o&&(a&&a(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,a){const r=await this._testConnection();if(!this._handleResultTest(r,a))return!1;const n=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(n,a);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:a=0},r,n){const o=await this._testConnection();if(!this._handleResultTest(o,n))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:a}),d=this._handleResult(l,n);if(!d)return!1;r&&r(d)}async addPrintFormat({templateId:t,params:e,token:i},s,a){const r=await this._testConnection();if(!this._handleResultTest(r,a))return!1;const n=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(n,a);if(!o)return!1;s&&s(o)}}export{g 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 d=t.create({timeout:6e4,withCredentials:!1}),m=`${window.location.protocol}//${window.location.host}`,u=`${m}/fdp-api/print/assembly/printIReport`,p=`${m}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${m}/bi-api/reprot/print/open/client/previewIReport`,w=`${m}/bi-api/reprot/print/open/client/getRemote`,y=`${m}/bi-api/reprot/print/open/client/uploadTemplate`,g=`${m}/printService/file`;let P=null;class v{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.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=[],P)return P;P=this,this._initDomesticSystem();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"].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{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(){try{this.hiPrintSocket=h("http://127.0.0.1:17521",{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.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(t=>{this.printerList=t,console.log("获取到打印机列表信息>>>>>",t)})),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(t){console.log("hiprint系统连接失败",t)}}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:2,callback:1};const i=await this._queryServicesPrint(this.queryServicesParams);if(i&&i.filebase64&&i.key){const t={templateId:this.queryServicesParams.templateId,formatId:this.queryServicesParams.formatId,fileBase64:i.filebase64,authorizationKey:i.key,params:this.queryServicesParams.params},e=await this._uploadImageServices(t);"success"===(null==e?void 0:e.result)&&console.log("图片上传成功")}}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async _uploadImageServices(t){const e=new FormData;Object.keys(t).forEach((i=>{e.append(i,t[i])}));const{data:i}=await d({method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},url:y,data:e})||{};return i}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{d({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):d({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const i=t.message||t.Message;this._handleMonitorNotify(i);const s={type:"printError",message:i,result:t.result,errinfo:t.errinfo};return null==e||e(s),!1}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,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,cmdid:s,print:r,signature:n,printdlgshow:a="0",nobillnode:o="1",btnprint:l="1",messageTimeout:h=0}){const d={templateId:t,formatId:e,params:i,cmdid:s,nobillnode:o,printdlgshow:a,btnprint:l,messageTimeout:h,...n?{signature:n}:{}};if(r){try{r=JSON.parse(r)}catch(t){}d.print=r}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 d({method:"get",url:w})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=m+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await d({method:"post",url:u,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 d({method:"post",url:p,params:{id:t,formatId:e.split("_")[1],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 d({method:"post",url:f,responseType:"blob",params:{id:t,formatId:e.split("_")[1],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(`${g}/${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="",authorizationKey:s,signature:r,btnprint:l,messageTimeout:c=0},h,d){if(a(e)){const r=await this._queryPrintForPdf(t,e,i,s);if(!r)return null==d?void 0:d("获取文件失败!");const a=n(r,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,a),null==h?void 0:h({file:r})}await this._queryProxyOrigin();const m=await this._testConnection();if(!this._handleResultTest(m,d))return!1;try{const s=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:this.isRemote?"7":"8",signature:r,btnprint:l,messageTimeout:c}),n=this._handleResult(s,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==h||h(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({templateId:t,formatId:e,params:i="",authorizationKey:s,print:r,signature:n,printdlgshow:o,nobillnode:l,isDownloadFile:c=!0,messageTimeout:h=0},d,m,u="printDirect"){if(a(e)){if(!this.isConnectHiPrint)return void m({message:"请连接hiPrint客户端"});const r=await this._queryPrintForBase64(t,e,i,s);if(!r.success)return m({message:r.resultMsg});const{base64:n,formatId:a}=r.map;return this.base64Fragment=n,this._successCallbackFn=d,this._errorCallbackFn=m,void this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:a,pdf_stream:this.base64Fragment})}await this._queryProxyOrigin();const p=await this._testConnection();if(!this._handleResultTest(p,m))return!1;try{const s=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:"7",print:r,signature:n,printdlgshow:o,nobillnode:l,messageTimeout:h}),a=this._handleResult(s,m);if(!a)return!1;c&&["downloadPDF"].includes(u)&&await this._browserPrint(a,u),null==d||d(a)}catch(t){const e="printDirect"===u?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==m||m(i),this._handleMonitorNotify(i)}}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):d.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,"/")}if(a(t.formatId)){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)),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
@@ -2,14 +2,14 @@
2
2
  import { SFCWithInstall } from '../../shared/types';
3
3
  export * from './src/types';
4
4
  declare const Calendar: SFCWithInstall<import("vue").DefineComponent<{
5
- date: {
6
- type: DateConstructor;
7
- default: Date;
8
- };
9
5
  showDateNavigation: {
10
6
  type: BooleanConstructor;
11
7
  default: boolean;
12
8
  };
9
+ date: {
10
+ type: DateConstructor;
11
+ default: Date;
12
+ };
13
13
  events: {
14
14
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
15
15
  default: () => never[];
@@ -36,14 +36,14 @@ declare const Calendar: SFCWithInstall<import("vue").DefineComponent<{
36
36
  dayNames: string[];
37
37
  cssVars: import("vue").ComputedRef<import("vue").CSSProperties>;
38
38
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
39
- date: {
40
- type: DateConstructor;
41
- default: Date;
42
- };
43
39
  showDateNavigation: {
44
40
  type: BooleanConstructor;
45
41
  default: boolean;
46
42
  };
43
+ date: {
44
+ type: DateConstructor;
45
+ default: Date;
46
+ };
47
47
  events: {
48
48
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
49
49
  default: () => never[];
@@ -224,20 +224,31 @@ declare const Calendar: SFCWithInstall<import("vue").DefineComponent<{
224
224
  [key: string]: any;
225
225
  }>;
226
226
  update: (before: () => void) => Promise<void>;
227
+ gotoDate: (date: Date) => void;
227
228
  NIcon: any;
228
229
  ChevronBackOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
229
230
  ChevronForwardOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
230
- FullCalendar: any;
231
+ FullCalendar: import("vue").DefineComponent<{
232
+ options: import("vue").PropType<import("@fullcalendar/core/internal-common").a>;
233
+ }, unknown, {
234
+ renderId: number;
235
+ customRenderingMap: Map<string, import("@fullcalendar/core/internal-common").eF<any>>;
236
+ }, {}, {
237
+ getApi(): import("@fullcalendar/core").Calendar;
238
+ buildOptions(suppliedOptions: import("@fullcalendar/core/internal-common").a | undefined): import("@fullcalendar/core/internal-common").a;
239
+ }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
240
+ options: import("vue").PropType<import("@fullcalendar/core/internal-common").a>;
241
+ }>>, {}>;
231
242
  isSameDay: typeof import("date-fns").isSameDay;
232
243
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "eventClick" | "eventDrag" | "eventResize" | "dateChange")[], "select" | "eventClick" | "eventDrag" | "eventResize" | "dateChange", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
233
- date: {
234
- type: DateConstructor;
235
- default: Date;
236
- };
237
244
  showDateNavigation: {
238
245
  type: BooleanConstructor;
239
246
  default: boolean;
240
247
  };
248
+ date: {
249
+ type: DateConstructor;
250
+ default: Date;
251
+ };
241
252
  events: {
242
253
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
243
254
  default: () => never[];
@@ -3,14 +3,14 @@ import { isSameDay } from 'date-fns';
3
3
  import { IDayItem } from './types';
4
4
  import { AnyObject } from '../../../shared/types';
5
5
  declare const _default: import("vue").DefineComponent<{
6
- date: {
7
- type: DateConstructor;
8
- default: Date;
9
- };
10
6
  showDateNavigation: {
11
7
  type: BooleanConstructor;
12
8
  default: boolean;
13
9
  };
10
+ date: {
11
+ type: DateConstructor;
12
+ default: Date;
13
+ };
14
14
  events: {
15
15
  type: PropType<AnyObject[]>;
16
16
  default: () => never[];
@@ -33,14 +33,14 @@ declare const _default: import("vue").DefineComponent<{
33
33
  dayNames: string[];
34
34
  cssVars: import("vue").ComputedRef<import("vue").CSSProperties>;
35
35
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
36
- date: {
37
- type: DateConstructor;
38
- default: Date;
39
- };
40
36
  showDateNavigation: {
41
37
  type: BooleanConstructor;
42
38
  default: boolean;
43
39
  };
40
+ date: {
41
+ type: DateConstructor;
42
+ default: Date;
43
+ };
44
44
  events: {
45
45
  type: PropType<AnyObject[]>;
46
46
  default: () => never[];
@@ -217,20 +217,31 @@ declare const _default: import("vue").DefineComponent<{
217
217
  [key: string]: any;
218
218
  }>;
219
219
  update: (before: () => void) => Promise<void>;
220
+ gotoDate: (date: Date) => void;
220
221
  NIcon: any;
221
222
  ChevronBackOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
222
223
  ChevronForwardOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
223
- FullCalendar: any;
224
+ FullCalendar: import("vue").DefineComponent<{
225
+ options: PropType<import("@fullcalendar/core/internal-common").a>;
226
+ }, unknown, {
227
+ renderId: number;
228
+ customRenderingMap: Map<string, import("@fullcalendar/core/internal-common").eF<any>>;
229
+ }, {}, {
230
+ getApi(): import("@fullcalendar/core").Calendar;
231
+ buildOptions(suppliedOptions: import("@fullcalendar/core/internal-common").a | undefined): import("@fullcalendar/core/internal-common").a;
232
+ }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
233
+ options: PropType<import("@fullcalendar/core/internal-common").a>;
234
+ }>>, {}>;
224
235
  isSameDay: typeof isSameDay;
225
236
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "eventClick" | "eventDrag" | "eventResize" | "dateChange")[], "select" | "eventClick" | "eventDrag" | "eventResize" | "dateChange", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
226
- date: {
227
- type: DateConstructor;
228
- default: Date;
229
- };
230
237
  showDateNavigation: {
231
238
  type: BooleanConstructor;
232
239
  default: boolean;
233
240
  };
241
+ date: {
242
+ type: DateConstructor;
243
+ default: Date;
244
+ };
234
245
  events: {
235
246
  type: PropType<AnyObject[]>;
236
247
  default: () => never[];
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,reactive as n,createVNode as a,createTextVNode as o,watch as r,openBlock as s,createElementBlock as i,normalizeStyle as l,unref as d,createElementVNode as c,Fragment as u,renderList as m,normalizeClass as p,toDisplayString as v,createCommentVNode as y,createBlock as f,nextTick as h}from"vue";import{NIcon as C}from"naive-ui";import{ChevronBackOutline as g,ChevronForwardOutline as M}from"@vicons/ionicons5";import D from"@fullcalendar/vue3";import k from"@fullcalendar/resource-timegrid";import w from"@fullcalendar/scrollgrid";import b from"@fullcalendar/interaction";import{useTheme as H}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import{format as R,isSameDay as x,toDate as L,startOfMonth as j,endOfMonth as N,eachDayOfInterval as z,getDay as O,isSameMonth as S,startOfDay as T,endOfDay as F}from"date-fns";import{isFunction as I,cloneDeep as _}from"lodash-es";import"@vue/shared";import"../../../shared/utils/index.js";import"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";const A={key:0,class:"select-day-wrapper"},E={class:"day-wrapper"},G=["onClick"];var P=e({__name:"Calendar",props:{date:{type:Date,default:new Date},showDateNavigation:{type:Boolean,default:!0},events:{type:Array,default:()=>[]},resources:{type:Array,default:()=>[]},eventContentRender:{type:Function},resourceLabelContentRender:{type:Function},options:{type:Object,default:()=>({})}},emits:["select","eventDrag","eventClick","eventResize","dateChange"],setup(e,{emit:P}){const B=e,K=["周一","周二","周三","周四","周五","周六","周日"],V=H(),W=t(),q=t(new Date),J=t([]),Q=t(!1),U=n({schedulerLicenseKey:"GPL-My-Project-Is-Open-Source",plugins:[k,w,b],initialView:"resourceTimeGridDay",initialDate:R(q.value,"yyyy-MM-dd"),headerToolbar:{left:"",center:"",right:""},allDaySlot:!1,slotLabelInterval:{minute:30},slotLabelFormat:{hour:"2-digit",minute:"2-digit",meridiem:!1,hour12:!1},slotLabelContent:e=>R(e.date,"HH:mm"),nowIndicator:!0,dayMaxEvents:!0,eventOverlap:!1,slotMinTime:{hour:0},slotMaxTime:{hour:24},dayMinWidth:100,expandRows:!0,droppable:!0,editable:!0,selectable:!0,refetchResourcesOnNavigate:!0,resources:[],events:[],dayCellClassNames:["custom-day-cell"],eventClassNames:["custom-event"],eventContent:function(e){const{start:t,end:n,title:r}=e.event;return I(B.eventContentRender)?B.eventContentRender(e):[a("p",{class:"text"},[R(t,"HH:mm"),o("-"),R(n,"HH:mm")]),a("p",{class:"text"},[r])]},resourceLabelContent:function(e){const{title:t}=e.resource;return I(B.resourceLabelContentRender)?B.resourceLabelContentRender(e):a("span",null,[t])},select:(...e)=>P("select",...e),eventDrop:(...e)=>P("eventDrag",...e),eventResize:(...e)=>P("eventResize",...e),eventClick:(...e)=>P("eventClick",...e)});function X(e){const t=L(q.value);"prev"===e?t.setMonth(t.getMonth()-1):t.setMonth(t.getMonth()+1),Y(t),P("dateChange",Z())}function Y(e){const t=j(e),n=N(e),a=z({start:t,end:n});J.value=a.map((e=>({date:e,formatDate:R(e,"yyyy-MM-dd HH:mm:ss"),day:e.getDate(),week:K[O(e)]}))),q.value=S(e,new Date)?new Date:J.value[0].date}function Z(){const e=T(q.value),t=F(q.value);return{start:e,end:t,startStr:R(e,"yyyy-MM-dd HH:mm:ss"),endStr:R(t,"yyyy-MM-dd HH:mm:ss")}}return r((()=>q.value),(e=>{!async function(e){Q.value=!1,await h(),e(),Q.value=!0}((()=>{U.initialDate=R(e,"yyyy-MM-dd")}))})),r((()=>B.date),(e=>{Y(e)}),{immediate:!0}),r((()=>B.events),(e=>{U.events=_(e).map((e=>({...e,resourceEditable:!1})))}),{deep:!0,immediate:!0}),r((()=>B.resources),(e=>{U.resources=_(e)}),{deep:!0,immediate:!0}),r((()=>B.options),(()=>{Object.assign(U,B.options)}),{deep:!0,immediate:!0}),(t,n)=>(s(),i("div",{class:"c-calendar",style:l({...d(V),"--nav-height":e.showDateNavigation?"70px":"0px"})},[e.showDateNavigation?(s(),i("div",A,[a(d(C),{size:"20",component:d(g),onClick:n[0]||(n[0]=()=>X("prev"))},null,8,["component"]),c("div",E,[(s(!0),i(u,null,m(J.value,((e,t)=>(s(),i("div",{class:p(["day",{"day--active":d(x)(e.date,q.value)}]),key:t,onClick:()=>async function(e){q.value=e.date,P("dateChange",Z())}(e)},[c("p",null,v(e.day),1),c("span",null,v(e.week),1)],10,G)))),128))]),a(d(C),{size:"20",component:d(M),onClick:n[1]||(n[1]=()=>X("next"))},null,8,["component"])])):y("v-if",!0),Q.value?(s(),f(d(D),{key:1,ref_key:"calendarRef",ref:W,options:U},null,8,["options"])):y("v-if",!0)],4))}});export{P as default};
1
+ import{defineComponent as e,ref as t,reactive as n,createVNode as a,createTextVNode as o,watch as r,openBlock as s,createElementBlock as i,normalizeStyle as l,unref as d,createElementVNode as u,Fragment as c,renderList as m,normalizeClass as p,toDisplayString as v,createCommentVNode as y,createBlock as f,nextTick as h}from"vue";import{NIcon as C}from"naive-ui";import{ChevronBackOutline as g,ChevronForwardOutline as M}from"@vicons/ionicons5";import D from"@fullcalendar/vue3";import k from"@fullcalendar/resource-timegrid";import w from"@fullcalendar/scrollgrid";import b from"@fullcalendar/interaction";import{useTheme as H}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import{format as R,isSameDay as x,toDate as L,startOfMonth as j,endOfMonth as N,eachDayOfInterval as z,getDay as O,isSameMonth as S,startOfDay as T,endOfDay as F}from"date-fns";import{isFunction as I,cloneDeep as _}from"lodash-es";import"@vue/shared";import"../../../shared/utils/index.js";import"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";const A={key:0,class:"select-day-wrapper"},E={class:"day-wrapper"},G=["onClick"];var P=e({__name:"Calendar",props:{showDateNavigation:{type:Boolean,default:!0},date:{type:Date,default:new Date},events:{type:Array,default:()=>[]},resources:{type:Array,default:()=>[]},eventContentRender:{type:Function},resourceLabelContentRender:{type:Function},options:{type:Object,default:()=>({})}},emits:["select","eventDrag","eventClick","eventResize","dateChange"],setup(e,{expose:P,emit:B}){const K=e,V=["周一","周二","周三","周四","周五","周六","周日"],W=H(),q=t(),J=t(new Date),Q=t([]),U=t(!1),X=n({schedulerLicenseKey:"GPL-My-Project-Is-Open-Source",plugins:[k,w,b],initialView:"resourceTimeGridDay",initialDate:R(J.value,"yyyy-MM-dd"),headerToolbar:{left:"",center:"",right:""},allDaySlot:!1,slotLabelInterval:{minute:30},slotLabelFormat:{hour:"2-digit",minute:"2-digit",meridiem:!1,hour12:!1},slotLabelContent:e=>R(e.date,"HH:mm"),nowIndicator:!0,dayMaxEvents:!0,eventOverlap:!1,slotMinTime:{hour:0},slotMaxTime:{hour:24},dayMinWidth:100,expandRows:!0,droppable:!0,editable:!0,selectable:!0,refetchResourcesOnNavigate:!0,resources:[],events:[],dayCellClassNames:["custom-day-cell"],eventClassNames:["custom-event"],eventContent:function(e){const{start:t,end:n,title:r}=e.event;return I(K.eventContentRender)?K.eventContentRender(e):[a("p",{class:"text"},[R(t,"HH:mm"),o("-"),R(n,"HH:mm")]),a("p",{class:"text"},[r])]},resourceLabelContent:function(e){const{title:t}=e.resource;return I(K.resourceLabelContentRender)?K.resourceLabelContentRender(e):a("span",null,[t])},select:(...e)=>B("select",...e),eventDrop:(...e)=>B("eventDrag",...e),eventResize:(...e)=>B("eventResize",...e),eventClick:(...e)=>B("eventClick",...e)});function Y(e){const t=L(J.value);"prev"===e?t.setMonth(t.getMonth()-1):t.setMonth(t.getMonth()+1),Z(t),B("dateChange",$())}function Z(e){const t=j(e),n=N(e),a=z({start:t,end:n});Q.value=a.map((e=>({date:e,formatDate:R(e,"yyyy-MM-dd HH:mm:ss"),day:e.getDate(),week:V[O(e)]}))),J.value=S(e,new Date)?new Date:Q.value[0].date}function $(){const e=T(J.value),t=F(J.value);return{start:e,end:t,startStr:R(e,"yyyy-MM-dd HH:mm:ss"),endStr:R(t,"yyyy-MM-dd HH:mm:ss")}}return r((()=>J.value),(e=>{!async function(e){U.value=!1,await h(),e(),U.value=!0}((()=>{X.initialDate=R(e,"yyyy-MM-dd")}))})),r((()=>K.date),(e=>{Z(e)}),{immediate:!0}),r((()=>K.events),(e=>{X.events=_(e).map((e=>({...e,resourceEditable:!1})))}),{deep:!0,immediate:!0}),r((()=>K.resources),(e=>{X.resources=_(e)}),{deep:!0,immediate:!0}),r((()=>K.options),(()=>{Object.assign(X,K.options)}),{deep:!0,immediate:!0}),P({gotoDate:function(e){J.value=e}}),(t,n)=>(s(),i("div",{class:"c-calendar",style:l({...d(W),"--nav-height":e.showDateNavigation?"70px":"0px"})},[e.showDateNavigation?(s(),i("div",A,[a(d(C),{size:"20",component:d(g),onClick:n[0]||(n[0]=()=>Y("prev"))},null,8,["component"]),u("div",E,[(s(!0),i(c,null,m(Q.value,((e,t)=>(s(),i("div",{class:p(["day",{"day--active":d(x)(e.date,J.value)}]),key:t,onClick:()=>async function(e){J.value=e.date,B("dateChange",$())}(e)},[u("p",null,v(e.day),1),u("span",null,v(e.week),1)],10,G)))),128))]),a(d(C),{size:"20",component:d(M),onClick:n[1]||(n[1]=()=>Y("next"))},null,8,["component"])])):y("v-if",!0),U.value?(s(),f(d(D),{key:1,ref_key:"calendarRef",ref:q,options:X},null,8,["options"])):y("v-if",!0)],4))}});export{P as default};