cnhis-design-vue 3.1.41 → 3.1.42-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.
- package/es/components/annotation-edit/src/AnnotationEdit.js +1 -1
- package/es/components/annotation-edit/style/index.css +1 -1
- package/es/components/base-search/index.d.ts +293 -0
- package/es/components/base-search/index.js +1 -0
- package/es/components/{table-filter/src/base-search-com/BaseSearch.vue.d.ts → base-search/src/index.vue.d.ts} +26 -91
- package/es/components/base-search/src/index.vue.js +1 -0
- package/es/components/base-search/style/iconfont.ttf +0 -0
- package/es/components/base-search/style/index.css +1 -0
- package/es/components/big-table/index.d.ts +4 -3
- package/es/components/big-table/src/BigTable.vue.d.ts +4 -3
- package/es/components/big-table/src/BigTable.vue2.js +1 -1
- package/es/components/big-table/style/index.css +1 -1
- package/es/components/button-print/index.d.ts +7 -6
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +7 -6
- package/es/components/button-print/src/ButtonPrint.vue2.js +1 -1
- package/es/components/button-print/src/api.d.ts +3 -0
- package/es/components/button-print/src/api.js +1 -0
- package/es/components/button-print/src/components/EditFormat.vue.d.ts +4 -4
- package/es/components/button-print/src/components/IdentityVerification.vue.d.ts +4 -4
- package/es/components/button-print/src/utils/print.js +1 -1
- package/es/components/classification/index.d.ts +995 -0
- package/es/components/classification/index.js +1 -0
- package/es/components/{table-filter → classification}/src/components/search-filter/index.vue.d.ts +10 -93
- package/es/components/classification/src/components/search-filter/index.vue.js +1 -0
- package/es/components/{table-filter → classification}/src/components/set-classification/index.vue.d.ts +5 -130
- package/es/components/classification/src/components/set-classification/index.vue.js +1 -0
- package/es/components/{table-filter → classification}/src/components/table-modal/index.vue.d.ts +0 -42
- package/es/components/classification/src/components/table-modal/index.vue.js +1 -0
- package/es/components/classification/src/const/index.d.ts +2 -0
- package/es/components/classification/src/const/index.js +1 -0
- package/es/components/{table-filter/src/classification/Classification-com.vue.d.ts → classification/src/index.vue.d.ts} +57 -291
- package/es/components/classification/src/index.vue.js +1 -0
- package/es/components/classification/style/iconfont.ttf +0 -0
- package/es/components/classification/style/index.css +1 -0
- package/es/components/config-provider/index.d.ts +14 -0
- package/es/components/config-provider/index.js +1 -0
- package/es/components/config-provider/src/ConfigProvider.d.ts +14 -0
- package/es/components/config-provider/src/ConfigProvider.js +1 -0
- package/es/components/config-provider/src/interface.d.ts +19 -0
- package/es/components/config-provider/src/interface.js +1 -0
- package/es/components/config-provider/src/utils/index.d.ts +2 -0
- package/es/components/config-provider/src/utils/index.js +1 -0
- package/es/components/date-picker/index.d.ts +20 -0
- package/es/components/date-picker/index.js +1 -0
- package/es/components/date-picker/src/DatePicker.vue.d.ts +20 -0
- package/es/components/date-picker/src/DatePicker.vue.js +1 -0
- package/es/components/fabric-chart/index.d.ts +2 -2
- package/es/components/fabric-chart/src/FabricChart.vue.d.ts +2 -2
- package/es/components/fabric-chart/src/hooks/useBirthProcess.js +1 -1
- package/es/components/fabric-chart/src/hooks/useBirthProcessChart.js +1 -1
- package/es/components/fabric-chart/src/hooks/useLeft.js +1 -1
- package/es/components/field-set/index.d.ts +2 -2
- package/es/components/field-set/src/FieldSet.vue.d.ts +2 -2
- package/es/components/form-config/index.d.ts +46 -37
- package/es/components/form-config/src/FormConfig.vue.d.ts +46 -37
- package/es/components/form-config/src/FormConfig.vue.js +1 -1
- package/es/components/form-config/src/components/FormConfigCreator.vue.d.ts +16 -16
- package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +19 -19
- package/es/components/form-config/src/components/FormConfigMaterialItem.d.ts +9 -1
- package/es/components/form-config/src/components/FormConfigMaterialItem.js +1 -1
- package/es/components/form-config/src/components/renderer/DefaultNode.vue.d.ts +33 -6
- package/es/components/form-config/src/components/renderer/DefaultNode.vue.js +1 -1
- package/es/components/form-config/style/index.css +1 -1
- package/es/components/form-render/index.d.ts +16 -16
- package/es/components/form-render/src/FormRender.vue.d.ts +16 -16
- package/es/components/form-render/src/FormRenderWrapper.vue.d.ts +16 -16
- package/es/components/form-render/src/FormRenderWrapper.vue.js +1 -1
- package/es/components/form-render/src/components/renderer/complex.d.ts +1 -1
- package/es/components/form-render/src/components/renderer/lineBar/FormCollapse.vue.d.ts +1 -1
- package/es/components/form-render/src/components/renderer/lineBar/index.d.ts +1 -1
- package/es/components/form-render/src/components/renderer/radio&checkbox.d.ts +2 -2
- package/es/components/form-render/src/components/renderer/radio_checkbox.js +1 -1
- package/es/components/form-render/src/components/renderer/select.js +1 -1
- package/es/components/form-render/src/hooks/useFieldListAdaptor.d.ts +1 -1
- package/es/components/form-render/src/hooks/useFieldListAdaptor.js +1 -1
- package/es/components/form-render/src/hooks/useFormRenderOptions.d.ts +4 -2
- package/es/components/form-render/src/hooks/useFormRenderOptions.js +1 -1
- package/es/components/form-render/style/index.css +1 -1
- package/es/components/iho-table/index.d.ts +3 -0
- package/es/components/iho-table/src/IhoTable.vue.d.ts +3 -0
- package/es/components/iho-table/src/IhoTable.vue.js +1 -1
- package/es/components/iho-table/src/constants/index.d.ts +4 -4
- package/es/components/iho-table/src/constants/index.js +1 -1
- package/es/components/iho-table/src/plugins/defaultConfigPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/editDate.vue.d.ts +20 -7
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/editDate.vue.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue.d.ts +18 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/widgets/labelRendererPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/widgets/pictureRendererPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/widgets/seqRendererPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/virtualTreePlugin/index.js +1 -1
- package/es/components/iho-table/src/types/index.d.ts +1 -0
- package/es/components/iho-table/src/utils/index.d.ts +1 -0
- package/es/components/iho-table/src/utils/index.js +1 -1
- package/es/components/iho-table/style/index.css +1 -1
- package/es/components/index.css +1 -1
- package/es/components/index.d.ts +8 -2
- package/es/components/index.js +1 -1
- package/es/components/info-header/index.d.ts +3799 -156
- package/es/components/info-header/src/InfoHeader.vue.d.ts +3800 -156
- package/es/components/info-header/src/InfoHeader.vue.js +1 -1
- package/es/components/info-header/src/components/infoDescription/DescriptionItem.vue.d.ts +1842 -0
- package/es/components/info-header/src/components/infoDescription/DescriptionItem.vue.js +1 -0
- package/es/components/info-header/src/components/infoDescription/DescriptionList.vue.d.ts +1972 -0
- package/es/components/info-header/src/components/infoDescription/DescriptionList.vue.js +1 -0
- package/es/components/info-header/src/components/infoDescription/HiddenContent.vue.d.ts +2 -2
- package/es/components/info-header/src/components/infoDescription/InfoEllipsis.vue.d.ts +1 -1
- package/es/components/info-header/src/components/infoDescription/InfoEllipsis.vue.js +1 -1
- package/es/components/info-header/src/components/infoDescription/index.vue.d.ts +2669 -139
- package/es/components/info-header/src/components/infoDescription/index.vue.js +1 -1
- package/es/components/info-header/src/components/patientInfo/index.vue.d.ts +745 -0
- package/es/components/info-header/src/components/patientInfo/index.vue.js +1 -1
- package/es/components/info-header/src/constants/index.d.ts +4 -0
- package/es/components/info-header/src/constants/index.js +1 -0
- package/es/components/info-header/src/hooks/useThemeOverrides.d.ts +4 -0
- package/es/components/info-header/src/hooks/useThemeOverrides.js +1 -0
- package/es/components/info-header/src/types/index.d.ts +17 -3
- package/es/components/info-header/style/index.css +1 -1
- package/es/components/keyboard/index.d.ts +4 -2
- package/es/components/keyboard/src/Keyboard.vue.d.ts +4 -2
- package/es/components/keyboard/src/Keyboard.vue.js +1 -1
- package/es/components/keyboard/src/constants/index.d.ts +2 -0
- package/es/components/keyboard/src/constants/index.js +1 -0
- package/es/components/keyboard/style/index.css +1 -1
- package/es/components/quick-search/index.d.ts +713 -0
- package/es/components/quick-search/index.js +1 -0
- package/es/components/{table-filter/src/quick-search/QuickSearch.vue.d.ts → quick-search/src/index.vue.d.ts} +31 -120
- package/es/components/quick-search/src/index.vue.js +1 -0
- package/es/components/quick-search/style/index.css +1 -0
- package/es/components/recommend-search/index.d.ts +2 -2
- package/es/components/recommend-search/src/RecommendSearch.vue.d.ts +2 -2
- package/es/components/recommend-search/src/components/RecommendSelect.vue.d.ts +1 -1
- package/es/components/scale-view/src/components/formitem/sign-com.d.ts +1 -1
- package/es/components/scale-view/src/components/formitem/standard-modal.d.ts +1 -1
- package/es/components/scale-view/src/hooks/use-component.d.ts +69 -116
- package/es/components/search-cascader/index.d.ts +2 -2
- package/es/components/search-cascader/src/SearchCascader.vue.d.ts +2 -2
- package/es/components/search-cascader/src/components/SearchMenu.d.ts +1 -1
- package/es/components/select-label/index.d.ts +70 -169
- package/es/components/select-label/src/LabelFormContent.vue.d.ts +1 -53
- package/es/components/select-label/src/LabelFormContent.vue.js +1 -1
- package/es/components/select-label/src/SelectLabel.vue.d.ts +70 -116
- package/es/components/select-label/src/SelectLabel.vue2.js +1 -1
- package/es/components/select-label/src/components/label-classify.vue.js +1 -1
- package/es/components/select-label/style/iconfont.ttf +0 -0
- package/es/components/select-label/style/index.css +1 -1
- package/es/components/select-person/index.d.ts +1 -1
- package/es/components/select-person/src/SelectPerson.vue.d.ts +1 -1
- package/es/components/shortcut-setter/index.d.ts +17 -17
- package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +17 -17
- package/es/components/steps-wheel/index.d.ts +1 -0
- package/es/components/steps-wheel/src/StepsWheel.vue.d.ts +1 -0
- package/es/components/steps-wheel/src/StepsWheel.vue.js +1 -1
- package/es/components/steps-wheel/src/constants/index.d.ts +2 -0
- package/es/components/steps-wheel/src/constants/index.js +1 -0
- package/es/components/steps-wheel/style/index.css +1 -1
- package/es/components/table-filter/index.d.ts +0 -2385
- package/es/components/table-filter/index.js +1 -1
- package/es/components/table-filter/src/components/classify-filter/ValueCfg.vue.d.ts +1 -0
- package/es/components/table-filter/src/components/classify-filter/ValueCfg.vue.js +1 -1
- package/es/components/table-filter/src/components/classify-filter/index.vue.d.ts +1 -42
- package/es/components/table-filter/src/components/classify-filter/index.vue.js +1 -1
- package/es/components/table-filter/src/components/render-widget/components/CheckboxGroup.vue.d.ts +1 -1
- package/es/components/table-filter/src/components/render-widget/enums.d.ts +0 -8
- package/es/components/table-filter/src/components/render-widget/enums.js +1 -1
- package/es/components/table-filter/src/components/render-widget/index.vue.d.ts +2 -1
- package/es/components/table-filter/src/components/render-widget/index.vue.js +1 -1
- package/es/components/table-filter/src/components/render-widget/widgetCfgMaps.d.ts +1 -1
- package/es/components/table-filter/src/components/render-widget/widgetCfgMaps.js +1 -1
- package/es/components/table-filter/src/hooks/useAdvanced.d.ts +4 -1
- package/es/components/table-filter/src/hooks/useAdvanced.js +1 -1
- package/es/components/table-filter/src/hooks/useMixins.d.ts +1 -54
- package/es/components/table-filter/src/hooks/useMixins.js +1 -1
- package/es/components/table-filter/src/hooks/useRenderWidget.js +1 -1
- package/es/components/table-filter/src/tool/generateDefOptions.js +1 -1
- package/es/components/table-filter/src/tool/transformData.d.ts +1 -37
- package/es/components/table-filter/src/tool/transformData.js +1 -1
- package/es/components/table-filter/src/types/enums.d.ts +1 -0
- package/es/components/table-filter/src/types/enums.js +1 -1
- package/es/components/table-filter/src/types/index.d.ts +13 -169
- package/es/components/time-picker/index.d.ts +18 -0
- package/es/components/time-picker/index.js +1 -0
- package/es/components/time-picker/src/TimePicker.vue.d.ts +18 -0
- package/es/components/time-picker/src/TimePicker.vue.js +1 -0
- package/es/shared/mixins/index.d.ts +1 -0
- package/es/shared/mixins/index.js +1 -0
- package/es/shared/mixins/useTheme.d.ts +3 -0
- package/es/shared/mixins/useTheme.js +1 -0
- package/es/shared/utils/index.d.ts +1 -0
- package/es/shared/utils/index.js +1 -1
- package/package.json +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/timeUtils.d.ts +0 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/timeUtils.js +0 -1
- package/es/components/table-filter/src/base-search-com/BaseSearch.vue.js +0 -1
- package/es/components/table-filter/src/classification/Classification-com.vue.js +0 -1
- package/es/components/table-filter/src/components/search-filter/index.vue.js +0 -1
- package/es/components/table-filter/src/components/set-classification/index.vue.js +0 -1
- package/es/components/table-filter/src/components/table-modal/index.vue.js +0 -1
- package/es/components/table-filter/src/const/index.d.ts +0 -5
- package/es/components/table-filter/src/const/index.js +0 -1
- package/es/components/table-filter/src/hooks/useTableSearchCon.d.ts +0 -8
- package/es/components/table-filter/src/hooks/useTableSearchCon.js +0 -1
- package/es/components/table-filter/src/hooks/useWordBookutils.d.ts +0 -12
- package/es/components/table-filter/src/hooks/useWordBookutils.js +0 -1
- package/es/components/table-filter/src/quick-search/QuickSearch.vue.js +0 -1
- package/es/components/table-filter/src/tool/time-domain.d.ts +0 -39
- package/es/components/table-filter/src/tool/time-domain.js +0 -1
- package/es/components/table-filter/src/tool/utils.d.ts +0 -4
- package/es/components/table-filter/src/tool/utils.js +0 -1
- package/es/components/table-filter/style/index.css +0 -1
- /package/es/components/{table-filter → base-search}/src/directive/resize.d.ts +0 -0
- /package/es/components/{table-filter → base-search}/src/directive/resize.js +0 -0
- /package/es/components/{table-filter → base-search}/src/tool/resizeSensor.d.ts +0 -0
- /package/es/components/{table-filter → base-search}/src/tool/resizeSensor.js +0 -0
- /package/es/components/{table-filter → classification}/src/directive/flexibleResize.d.ts +0 -0
- /package/es/components/{table-filter → classification}/src/directive/flexibleResize.js +0 -0
- /package/es/components/table-filter/src/tool/{options.d.ts → baseOptions.d.ts} +0 -0
- /package/es/components/table-filter/src/tool/{options.js → baseOptions.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as n}from"./dialog.js";import{getFileUrl as s,useBrowserPrint as r,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{format as l}from"date-fns";const d=t.create({timeout:1e3,withCredentials:!1}),h=`${window.location.protocol}//${window.location.host}`,c=`${h}/fdp-api/print/assembly/printIReport`,p=`${h}/bi-api/reprot/print/open/client/getRemote`,u=`${h}/printService/file`;let m=null;class w{constructor(){var t;if(this.webview=null,this.dialog=new i,this.dialogPreview=new n,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.isRemote=!1,this.messageHandlerQueue=[],m)return m;m=this;const e=window;this.webview=null==(t=e.chrome)?void 0:t.webview,this.webview&&(this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler),this.postMessage({exec:"config",data:""}))}messageHandler(t){var e;const i=this.messageHandlerQueue.shift();if(!i)return console.log("当前回执",t,"没有可用的handler");const{resolve:n,reject:s}=i;try{const{exec:i}=JSON.parse(t.data);"config"===i&&(this.downloadPath=(null==(e=JSON.parse(t.data).res)?void 0:e.downloadpath)||""),console.log(t),n(JSON.parse(t.data).res)}catch(t){s(t)}}async postMessage(t){return this.webview?new Promise(((e,i)=>{this.messageHandlerQueue.push({resolve:e,reject:i}),this.webview.postMessage(t)})):Promise.reject()}destroy(){this.webview&&this.currentMessageHandler&&(this.webview.removeEventListener("message",this.currentMessageHandler),this.currentMessageHandler=void 0)}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(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):d({url:this.printOrigin+"/services/print",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:n(i)}):d({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[n]}).then((({data:t})=>t));function n(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleResult(t,e){if("success"!==t.result){const i={type:"printError",message:t.message||t.Message,result:t.result,errinfo:t.errinfo};return null==e||e(i),!1}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,n){const s={templateId:t,formatId:e,params:i,cmdid:"7"},r=await this._queryServicesPrint(s);return this._handleQueryPrintDataResult(r,e,n)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,cmdid:n,print:s,printdlgshow:r="1",nobillnode:a="1",btnprint:o="1"}){const d={templateId:t,formatId:e,params:i,cmdid:n,nobillnode:a,printdlgshow:r,btnprint:o};if(s){try{s=JSON.parse(s)}catch(t){}d.print=s}else if(this.isRemote){const t=l(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:n}){const s={};let r={};try{r=Object.assign({},s,JSON.parse(i))}catch(t){r=s}const a={templateId:t,formatId:e,cmdid:"9",token:n,params:JSON.stringify(r)};return await this._queryServicesPrint(a)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await d({method:"get",url:p})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=h+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await d({method:"post",url:c,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,n=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=n[n.length-2],o=n[n.length-1],l=await s(`${u}/${a}/${o}`),d=r(null,e,l);if("preview"===e)return d}}async preview({templateId:t,formatId:e,params:i="",btnprint:n},s,l){if(a(e)){const t=await this._queryPrintFile(e,i);if(!t)return null==l?void 0:l("获取文件失败!");const n=r(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,n),void(null==s||s({file:t}))}await this._queryProxyOrigin();const d=await this._testConnection();if(!this._handleResultTest(d,l))return!1;const h=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:this.isRemote?"7":"8",btnprint:n});if(!h)return!1;const c=this._handleResult(h,l);if(!c)return!1;if(this.isRemote){const t=await this._browserPrint(c,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}s&&s(c)}async printDirect({templateId:t,formatId:e,params:i="",print:n,printdlgshow:s,nobillnode:o,isDownloadFile:l=!0},d,h,c="printDirect"){if(a(e)){const t=await this._queryPrintFile(e,i);return t?(r(t,c),void(null==d||d({file:t}))):null==h?void 0:h("获取文件失败!")}await this._queryProxyOrigin();const p=await this._testConnection();if(!this._handleResultTest(p,h))return!1;const u=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:"7",print:n,printdlgshow:s,nobillnode:o});if(!u)return!1;const m=this._handleResult(u,h);if(!m)return!1;l&&["downloadPDF"].includes(c)&&await this._browserPrint(m,c),d
|
|
1
|
+
import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as n}from"./dialog.js";import{getFileUrl as s,useBrowserPrint as r,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{format as l}from"date-fns";const d=t.create({timeout:1e3,withCredentials:!1}),h=`${window.location.protocol}//${window.location.host}`,c=`${h}/fdp-api/print/assembly/printIReport`,p=`${h}/bi-api/reprot/print/open/client/getRemote`,u=`${h}/printService/file`;let m=null;class w{constructor(){var t;if(this.webview=null,this.dialog=new i,this.dialogPreview=new n,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.isRemote=!1,this.messageHandlerQueue=[],m)return m;m=this;const e=window;this.webview=null==(t=e.chrome)?void 0:t.webview,this.webview&&(this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler),this.postMessage({exec:"config",data:""}))}messageHandler(t){var e;const i=this.messageHandlerQueue.shift();if(!i)return console.log("当前回执",t,"没有可用的handler");const{resolve:n,reject:s}=i;try{const{exec:i}=JSON.parse(t.data);"config"===i&&(this.downloadPath=(null==(e=JSON.parse(t.data).res)?void 0:e.downloadpath)||""),console.log(t),n(JSON.parse(t.data).res)}catch(t){s(t)}}async postMessage(t){return this.webview?new Promise(((e,i)=>{this.messageHandlerQueue.push({resolve:e,reject:i}),this.webview.postMessage(t)})):Promise.reject()}destroy(){this.webview&&this.currentMessageHandler&&(this.webview.removeEventListener("message",this.currentMessageHandler),this.currentMessageHandler=void 0)}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(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):d({url:this.printOrigin+"/services/print",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:n(i)}):d({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[n]}).then((({data:t})=>t));function n(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleResult(t,e){if("success"!==t.result){const i={type:"printError",message:t.message||t.Message,result:t.result,errinfo:t.errinfo};return null==e||e(i),!1}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,n){const s={templateId:t,formatId:e,params:i,cmdid:"7"},r=await this._queryServicesPrint(s);return this._handleQueryPrintDataResult(r,e,n)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,cmdid:n,print:s,printdlgshow:r="1",nobillnode:a="1",btnprint:o="1"}){const d={templateId:t,formatId:e,params:i,cmdid:n,nobillnode:a,printdlgshow:r,btnprint:o};if(s){try{s=JSON.parse(s)}catch(t){}d.print=s}else if(this.isRemote){const t=l(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:n}){const s={};let r={};try{r=Object.assign({},s,JSON.parse(i))}catch(t){r=s}const a={templateId:t,formatId:e,cmdid:"9",token:n,params:JSON.stringify(r)};return await this._queryServicesPrint(a)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await d({method:"get",url:p})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=h+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await d({method:"post",url:c,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,n=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=n[n.length-2],o=n[n.length-1],l=await s(`${u}/${a}/${o}`),d=r(null,e,l);if("preview"===e)return d}}async preview({templateId:t,formatId:e,params:i="",btnprint:n},s,l){if(a(e)){const t=await this._queryPrintFile(e,i);if(!t)return null==l?void 0:l("获取文件失败!");const n=r(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,n),void(null==s||s({file:t}))}await this._queryProxyOrigin();const d=await this._testConnection();if(!this._handleResultTest(d,l))return!1;const h=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:this.isRemote?"7":"8",btnprint:n});if(!h)return!1;const c=this._handleResult(h,l);if(!c)return!1;if(this.isRemote){const t=await this._browserPrint(c,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}s&&s(c)}async printDirect({templateId:t,formatId:e,params:i="",print:n,printdlgshow:s,nobillnode:o,isDownloadFile:l=!0},d,h,c="printDirect"){if(a(e)){const t=await this._queryPrintFile(e,i);return t?(r(t,c),void(null==d||d({file:t}))):null==h?void 0:h("获取文件失败!")}await this._queryProxyOrigin();const p=await this._testConnection();if(!this._handleResultTest(p,h))return!1;const u=await this._handleEventDirect({templateId:t,formatId:e,params:i,cmdid:"7",print:n,printdlgshow:s,nobillnode:o});if(!u)return!1;const m=this._handleResult(u,h);if(!m)return!1;l&&["downloadPDF"].includes(c)&&await this._browserPrint(m,c),null==d||d(m)}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):d.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}downloadPDF(t,i,n){this.webview&&this.downloadPath&&(t.print.filename=this.downloadPath.replace(/\\/g,"/")),this.printDirect(t,(async s=>{if(s||n(null),a(t.formatId))return i(s);const r=this,o=await async function(t){const i=[],n=JSON.parse(t);if(!e(n))return await r._downloadPDF("");if(1===n.length)return await r._downloadPDF(n[0]||"");for(let t=0,e=n.length;t<e;t++)i.push(await r._downloadPDF(n[t]||""));return i}(s.filedir);i(o,s)}),(t=>n(t)),"downloadPDF")}async print({templateId:t,formatId:e,params:i=""},n,s){const r=await this._testConnection();if(!this._handleResultTest(r,s))return!1;const a=await this.queryPrintData({templateId:t,formatId:e,params:i},void 0,s);if(!a)return!1;const o=this.printFileData({formatId:e,file:a.file,printerName:a.printerName},void 0,s);if(!o)return!1;n&&n(o)}async queryPrintData({templateId:t,formatId:e,params:i=""},n,s){const r=await this._testConnection();if(!this._handleResultTest(r,s))return!1;const a=await this._handleEventQueryPrintData(t,e,i,s);return!!a&&(n&&n(a),a)}async printFileData({formatId:t,file:e,printerName:i="Default"},n,s){const r=await this._testConnection();if(!this._handleResultTest(r,s))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,s);return!!o&&(n&&n(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:n},s,r){const a=await this._testConnection();if(!this._handleResultTest(a,r))return!1;const o=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:n}),l=this._handleResult(o,r);if(!l)return!1;s&&s(l)}async addPrintFormat({templateId:t,params:e,token:i},n,s){const r=await this._testConnection();if(!this._handleResultTest(r,s))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,s);if(!o)return!1;n&&n(o)}}export{w as Print};
|