cnhis-design-vue 3.2.6-release.1 → 3.2.6-release.2
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/button-print/index.d.ts +4 -0
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +4 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +4 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
- package/es/components/button-print/src/utils/print.js +1 -1
- package/es/components/form-config/src/FormConfig.vue2.js +1 -1
- package/es/components/form-config/src/utils/index.d.ts +1 -0
- package/es/components/form-config/src/utils/index.js +1 -1
- package/es/components/iho-table/src/plugins/keyboardEventPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/renderer.js +1 -1
- package/es/shared/package.json.js +1 -1
- package/es/shared/utils/business.js +1 -1
- package/package.json +2 -2
@@ -309,6 +309,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
309
309
|
type: ObjectConstructor;
|
310
310
|
default: () => {
|
311
311
|
isShowPrintAll: boolean;
|
312
|
+
printAllType: number;
|
312
313
|
isShowOutSetting: boolean;
|
313
314
|
customProps: {};
|
314
315
|
outerPrintKeys: never[];
|
@@ -417,6 +418,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
417
418
|
type: ObjectConstructor;
|
418
419
|
default: () => {
|
419
420
|
isShowPrintAll: boolean;
|
421
|
+
printAllType: number;
|
420
422
|
isShowOutSetting: boolean;
|
421
423
|
customProps: {};
|
422
424
|
outerPrintKeys: never[];
|
@@ -466,6 +468,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
466
468
|
isShowOutSettingBtn: import("vue").ComputedRef<any>;
|
467
469
|
printCustomProps: import("vue").ComputedRef<any>;
|
468
470
|
defaultPrintFormatId: import("vue").ComputedRef<any>;
|
471
|
+
isPrintAllType: import("vue").ComputedRef<any>;
|
469
472
|
showSettingItems: import("vue").ComputedRef<import("../../shared/types").AnyObject[]>;
|
470
473
|
isSelectedAll: import("vue").WritableComputedRef<boolean>;
|
471
474
|
initShowDownList: () => Promise<void>;
|
@@ -797,6 +800,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
797
800
|
type: ObjectConstructor;
|
798
801
|
default: () => {
|
799
802
|
isShowPrintAll: boolean;
|
803
|
+
printAllType: number;
|
800
804
|
isShowOutSetting: boolean;
|
801
805
|
customProps: {};
|
802
806
|
outerPrintKeys: never[];
|
@@ -315,6 +315,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
315
315
|
type: ObjectConstructor;
|
316
316
|
default: () => {
|
317
317
|
isShowPrintAll: boolean;
|
318
|
+
printAllType: number;
|
318
319
|
isShowOutSetting: boolean;
|
319
320
|
customProps: {};
|
320
321
|
outerPrintKeys: never[];
|
@@ -423,6 +424,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
423
424
|
type: ObjectConstructor;
|
424
425
|
default: () => {
|
425
426
|
isShowPrintAll: boolean;
|
427
|
+
printAllType: number;
|
426
428
|
isShowOutSetting: boolean;
|
427
429
|
customProps: {};
|
428
430
|
outerPrintKeys: never[];
|
@@ -472,6 +474,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
472
474
|
isShowOutSettingBtn: import("vue").ComputedRef<any>;
|
473
475
|
printCustomProps: import("vue").ComputedRef<any>;
|
474
476
|
defaultPrintFormatId: import("vue").ComputedRef<any>;
|
477
|
+
isPrintAllType: import("vue").ComputedRef<any>;
|
475
478
|
showSettingItems: import("vue").ComputedRef<AnyObject[]>;
|
476
479
|
isSelectedAll: import("vue").WritableComputedRef<boolean>;
|
477
480
|
initShowDownList: () => Promise<void>;
|
@@ -803,6 +806,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
803
806
|
type: ObjectConstructor;
|
804
807
|
default: () => {
|
805
808
|
isShowPrintAll: boolean;
|
809
|
+
printAllType: number;
|
806
810
|
isShowOutSetting: boolean;
|
807
811
|
customProps: {};
|
808
812
|
outerPrintKeys: never[];
|
@@ -98,6 +98,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
98
98
|
type: ObjectConstructor;
|
99
99
|
default: () => {
|
100
100
|
isShowPrintAll: boolean;
|
101
|
+
printAllType: number;
|
101
102
|
isShowOutSetting: boolean;
|
102
103
|
customProps: {};
|
103
104
|
outerPrintKeys: never[];
|
@@ -209,6 +210,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
209
210
|
type: ObjectConstructor;
|
210
211
|
default: () => {
|
211
212
|
isShowPrintAll: boolean;
|
213
|
+
printAllType: number;
|
212
214
|
isShowOutSetting: boolean;
|
213
215
|
customProps: {};
|
214
216
|
outerPrintKeys: never[];
|
@@ -258,6 +260,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
258
260
|
isShowOutSettingBtn: import("vue").ComputedRef<any>;
|
259
261
|
printCustomProps: import("vue").ComputedRef<any>;
|
260
262
|
defaultPrintFormatId: import("vue").ComputedRef<any>;
|
263
|
+
isPrintAllType: import("vue").ComputedRef<any>;
|
261
264
|
showSettingItems: import("vue").ComputedRef<AnyObject[]>;
|
262
265
|
isSelectedAll: import("vue").WritableComputedRef<boolean>;
|
263
266
|
initShowDownList: () => Promise<void>;
|
@@ -592,6 +595,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
592
595
|
type: ObjectConstructor;
|
593
596
|
default: () => {
|
594
597
|
isShowPrintAll: boolean;
|
598
|
+
printAllType: number;
|
595
599
|
isShowOutSetting: boolean;
|
596
600
|
customProps: {};
|
597
601
|
outerPrintKeys: never[];
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as t,inject as e,ref as n,reactive as r,computed as i,onMounted as a,watch as l,openBlock as o,createElementBlock as s,Fragment as u,createElementVNode as c,createCommentVNode as d,createVNode as p,unref as m,withCtx as y,renderList as v,createBlock as f,createTextVNode as g,toDisplayString as k,isRef as h,renderSlot as b,withModifiers as w,normalizeClass as P,mergeProps as O}from"vue";import{isObject as S}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as F,NPopover as j,NCheckbox as M,NDivider as N}from"naive-ui";import{PrintOutline as x,SettingsOutline as E,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as z}from"../constants/index.js";import{Print as J}from"../utils/print.js";import{isIReport as U}from"../utils/browserPrint.js";import V from"./IdentityVerification.vue.js";import{format as A}from"date-fns";import"../api.js";const K={class:"newprint-button-outer"},B=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},H={class:"print-lite"},q={class:"label bold"},G={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},tt={class:"label bold"},et={class:"print-li"},nt={class:"print-lite"},rt=["onClick"],it={class:"newprint-button-poperOver"},at=["onMouseenter"],lt={class:"print-lite"},ot=["onClick"];var st=t({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:""})}},setup(t,{expose:st}){const ut=t,ct=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],dt=C();let pt;const mt=e(z),yt=n(""),vt=r({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[]});let ft=n([]),gt=n([{label:ut.previewText,key:"previewText"},{label:ut.pdfLoadText,key:"downloadPdf"},{label:ut.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const kt=r({oneMouseType:"",oneClickType:"",twoMouseType:""}),ht=r({oneShow:!1,isOperation:!1,isOutSetting:!1}),bt=n([]),wt=n([]),Pt=i((()=>{if(!vt.currentFormatId)return{};let t=vt.currentFormatId;return vt.formatList.find((e=>e.id===t))}));i((()=>{var t;return(null==(t=Pt.value)?void 0:t.name)||"格式选择"}));const Ot=i((()=>{let t=vt.formatList.find((t=>t.id===vt.currentFormatId));return null==t?void 0:t.templateId})),St=i((()=>{let t=vt.formatList.find((t=>t.id===vt.currentFormatId));return null==t?void 0:t.number})),Ct=i((()=>{var t;return null==(t=ut.newPrintSetting)?void 0:t.isShowPrintAll})),It=i((()=>{var t;return null==(t=ut.newPrintSetting)?void 0:t.isShowOutSetting})),Tt=i((()=>{var t;return(null==(t=ut.newPrintSetting)?void 0:t.customProps)||{}})),Lt=i((()=>{var t;return(null==(t=ut.newPrintSetting)?void 0:t.defaultFormatId)||""})),Ft=i((()=>{const t=ct.map((t=>t.key));return ft.value.filter((e=>!t.includes(e.key)))})),jt=i({get:()=>Ft.value.every((t=>t.selected)),set(t){Ft.value.forEach((e=>{e.selected=t}))}}),Mt=async()=>{var t,e;(null==(e=null==(t=ut.newPrintSetting)?void 0:t.outerPrintKeys)?void 0:e.length)||await re(),ht.oneShow=!0},Nt=async t=>{if(ut.directPrint){if(vt.spinning)return;return"button"===t?void(Ct.value?await ae():Lt.value?async function(t){await re(!1);const e=bt.value.find((e=>e.key==t));e&&Ht(e.templateCode,e.templateId,e.key,!1)}(Lt.value):Mt()):Mt()}return Mt()},xt=(t,e)=>{kt[t]=e},Et=()=>{bt.value=ft.value.filter((t=>!t.selected)),wt.value=Ft.value.filter((t=>t.selected)),Dt("oneShow"),Dt("isOutSetting"),mt("saveOuterPrint",wt.value)},_t=t=>{ht[t]=!0},Dt=t=>{kt.oneClickType="",ht[t]=!1,"isOutSetting"==t&&(ht.isOutSetting=!1)},zt=(t,e)=>{Bt(!1);let n={type:e,formatId:vt.currentFormatId,templateId:(null==t?void 0:t.templateId)||Ot.value,templateCode:(null==t?void 0:t.templateCode)||St.value};mt("success",t,n)},Jt=t=>{Bt(!1),mt("error",t),S(t)&&"notInstalledApp"===t.type&&dt.error(t.message)},Ut=t=>{Bt(!1),mt("cancel",t)},Vt=t=>{mt("error",{message:"前置条件执行错误",type:t,preExecution:!0})},At=()=>JSON.stringify({...ut.token?{token:ut.token}:{}}),Kt=(t=[],e)=>{var n,r;let i={},a={};if((null==(n=vt.templateParams[e].customizeDataset)?void 0:n.length)>0){const e=(null==(r=Object.keys(t[0].datasetData||{}))?void 0:r[0])||"",n=JSON.stringify(t.map((t=>JSON.parse(t.datasetData[e]))));a={datasetData:{}},a.datasetData[e]=n}else Object.keys(t[0]).forEach((e=>{a[e]=[],t.forEach((t=>{a[e].includes(t[e])||a[e].push(t[e])})),a[e]=a[e].join(",")}));return i=Object.assign({},JSON.parse(At()),Tt.value,a),JSON.stringify(i)},Bt=(t,e)=>{if(vt.isClickOuterPrint){if(t&&e){const n=wt.value.find((t=>t.key==e));return void(n&&(n.isLoading=t))}wt.value.forEach((t=>{t.isLoading=!1}))}else vt.spinning=t},Rt=()=>vt.isClickOuterPrint?wt.value.some((t=>t.isLoading)):vt.spinning,Ht=(t,e,n,r)=>{const i=vt.printParams[t];if(!i)return;vt.isClickOuterPrint=r,vt.currentFormatId=n;const a=vt.originParams[t]||[];qt(i,t,e,n,a)},qt=async(t=[],e,n,r,i=[],a)=>{let l=t.length;const o=async t=>{try{--l<=0&&zt(t,"print")}catch(t){console.log("error",t)}};ut.showLoading&&Rt()&&!a||(Bt(!0,r),ut.prevFn("print").then((()=>{vt.curPrintParamList=t;const a={formatId:r,templateId:n,authorizationKey:yt.value,printdlgshow:ut.printdlgshow,signature:ut.signature,copies:ut.printCopies};if("MULTI"===ut.strategy)for(let e=0;e<t.length;e++){e>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(At()),Tt.value,t[e]));pt.printDirect({...a,params:n},o,Jt,Ut)}else pt.printDirect({...a,params:Kt(t,e)},(t=>{t.params=i,t.templateCode=e,t.templateId=n,zt(t,"print")}),Jt,Ut)})).catch((()=>{Vt("print"),Bt(!1)})).finally((()=>{vt.visible=!1})))},Gt=async(t,{templateCode:e,templateId:n,key:r},i)=>{const a=vt.printParams[e];if(a)switch(vt.isClickOuterPrint=i,vt.currentFormatId=r,t){case"previewText":(async(t=[],e,n,r)=>{ut.showLoading&&Rt()||(Bt(!0,r),ut.prevFn("preview").then((()=>{vt.curPrintParamList=t;const i=JSON.stringify(Object.assign({},JSON.parse(At()),Tt.value,t[0])),a="MULTI"===ut.strategy?i:Kt(t,e),l={formatId:r,templateId:n,authorizationKey:yt.value,params:a,btnprint:ut.btnprint,signature:ut.signature};pt.preview(l,(t=>{zt(t,"preview")}),Jt)})).catch((()=>{Vt("preview"),Bt(!1)})).finally((()=>{vt.visible=!1})))})(a,e,n,r);break;case"formatEditText":((t=[],e,n,r)=>{ut.showLoading&&Rt()||(Bt(!0,r),ut.prevFn("edit").then((()=>{vt.curPrintParamList=t,vt.currentFormatId=r,vt.identityVerification.visible=!0})).catch((()=>{Vt("edit")})).finally((()=>{Bt(!1)})))})(a,0,0,r);break;case"downloadPdf":(async(t=[],e,n,r)=>{ut.showLoading&&Rt()||(Bt(!0,r),ut.prevFn("download").then((()=>{vt.curPrintParamList=t;const i=JSON.stringify(Object.assign({},JSON.parse(At()),Tt.value,t[0])),a="MULTI"===ut.strategy?i:Kt(t,e),l={formatId:r,templateId:n,authorizationKey:yt.value,print:{print:"1",type:"1"},params:a,signature:ut.signature};pt.downloadPDF(l,(t=>zt(t,"preview")),Jt)})).catch((()=>{Vt("download"),Bt(!1)})).finally((()=>{vt.visible=!1})))})(a,e,n,r);break;case"resetPrinter":(async(t=[],e,n,r)=>{if(!ut.showLoading||!Rt()){Bt(!0,r);try{const t=await pt.resetPrinter(r);if(Bt(!1),"success"==(null==t?void 0:t.result))return void dt.success(t.message||"重置打印机成功");dt.warning("重置打印机失败")}catch(t){Bt(!1),dt.warning((null==t?void 0:t.message)||"重置打印机失败")}}})(a,0,0,r)}},Yt=()=>{},$t=(t,e=[])=>{let n={};return(e=e||[]).forEach((e=>{n=Object.assign({},Zt(n,e,t))})),n},Qt=(t,e=[])=>{let n={};return(e=e||[]).forEach((e=>{n=Object.assign({},te(n,e,t))})),n},Wt=(t,e,n)=>{const r={};return e.forEach((e=>{let i=((t,e)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=e;return Object.keys(n).includes(t.type)&&e&&e instanceof Date&&(r=A(e,n[t.type])),(null==t?void 0:t.defaultValue)||r})(e,t[e[n]]);t[e[n]]&&i&&(r[e[n]]=i)})),r},Xt=({customizeDataset:t=[],param:e=[]},n={})=>{let r={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;r.datasetData||(r.datasetData={}),r.datasetData[t.name]=JSON.stringify(Wt(n,e,"fieldName"))})),r=Object.assign({},r,Wt(n,e,"key")),r},Zt=(t,e,n)=>{if(e.templateNumbers){for(let r=0;r<e.templateNumbers.length;r++){const i=e.templateNumbers[r],a=n[i];if(!a)return dt.error("当前勾选的数据没有匹配的模板"),t;t[i]||(t[i]=[]),t[i].push(Xt(a,e))}return t}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i],l=n[a];if(!l)return dt.error("当前勾选的数据没有匹配的模板"),t;t[a]||(t[a]=[]),t[a].push(Xt(l,e))}return t},te=(t,e,n)=>{if(e.templateNumbers){for(let r=0;r<e.templateNumbers.length;r++){const i=e.templateNumbers[r];if(!n[i])return dt.error("当前勾选的数据没有匹配的模板"),t;t[i]||(t[i]=[]),t[i].push(e)}return t}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i];if(!n[a])return dt.error("当前勾选的数据没有匹配的模板"),t;t[a]||(t[a]=[]),t[a].push(e)}return t},ee=async t=>{vt.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):[],(()=>{var t,e,n;const r=vt.formatList.map((t=>({templateCode:t.number,templateId:t.templateId,label:t.name,key:t.id,selected:!1,isLoading:!1})));ft.value.unshift(...r),It.value&&ft.value.push(...ct),(null==(e=null==(t=ut.newPrintSetting)?void 0:t.outerPrintKeys)?void 0:e.length)>0&&(ft.value.forEach((t=>{var e;(null==(e=ut.newPrintSetting)?void 0:e.outerPrintKeys.includes(t.key))&&(t.selected=!0)})),wt.value=ft.value.filter((t=>t.selected))),bt.value=ft.value.filter((t=>!t.selected)),ut.hideButtons.length>0&&(gt.value=gt.value.filter((t=>!ut.hideButtons.includes(t.key))));const i=sessionStorage.getItem("portal");if(i){const t=JSON.parse(i),e=(null==(n=null==t?void 0:t.user)?void 0:n.currentRoleResourceObj)||{},r=Object.keys(e);r.includes("RY7.2.21.1.M2.G94181E")||(gt.value=gt.value.filter((t=>"downloadPdf"!=t.key))),r.includes("RY7.2.21.1.M2.G33633A")||(gt.value=gt.value.filter((t=>"formatEditText"!=t.key)))}})(),vt.templateParams=(t=>{let e={};return t&&t.forEach((t=>{if(!t.templateConfig)return!1;e[t.number]=t.templateConfig})),e})(t.obj),vt.printParams=$t(vt.templateParams,ut.params),vt.originParams=Qt(vt.templateParams,ut.params)},ne=async()=>{var t;if(vt.isInited)return!0;vt.isInited=!0,vt.spinning=!0,(()=>{if(pt)return!1;pt=new J})();const e=await ut.queryPrintFormatByNumber();return await ee(e),(null==(t=e.obj)?void 0:t.length)>0&&(yt.value=e.obj[0].authorizationKey||""),vt.spinning=!1,!0},re=async(t=!0)=>{if(await ut.clickPrevFn()){if(!vt.visible){if(!await ne())return!1}t&&(vt.visible=!vt.visible)}},ie=t=>{if(vt.identityVerification.visible=!1,U(vt.currentFormatId))return zt(null,"edit");const e=JSON.stringify(Object.assign({},JSON.parse(At()),Tt.value,vt.curPrintParamList[0])),n="MULTI"===ut.strategy?e:Kt(vt.curPrintParamList,St.value),r={formatId:vt.currentFormatId,templateId:Ot.value,params:n,token:t};pt.editPrintFormat(r,(t=>{zt(t,"edit")}),Jt)};async function ae(){await re(!1),(()=>{const t=Object.keys(vt.printParams);vt.isClickOuterPrint=!1;const e=vt.originParams;for(let n=0;n<t.length;n++){const r=t[n],i=vt.printParams[r],a=e[r]||[],l=vt.formatList.filter((t=>t.number==r));l&&l.length>0&&l.forEach((t=>{vt.currentFormatId=t.id,qt(i,t.number,t.templateId,t.id,a,!0)}))}})()}return a((()=>{vt.isInited=!1})),l((()=>ut.params),(t=>{Object.keys(vt.templateParams).length>0&&(vt.printParams=$t(vt.templateParams,ut.params),vt.originParams=Qt(vt.templateParams,ut.params))}),{deep:!0}),l((()=>{var t;return null==(t=ut.newPrintSetting)?void 0:t.outerPrintKeys}),(async t=>{(null==t?void 0:t.length)>0&&await re(!1)}),{deep:!0,immediate:!0}),st({directPrint:ae}),(e,n)=>(o(),s(u,null,[c("div",K,[d(" 外显按钮集合 "),p(m(I),null,{default:y((()=>[(o(!0),s(u,null,v(wt.value,(e=>{return o(),f(m(T),{key:e.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:Yt,options:(n=m(gt),r=e,vt.printParams[r.templateCode]?n:[]),onSelect:t=>Gt(t,e,!0)},{default:y((()=>[p(m(L),{disabled:!vt.printParams[e.templateCode],loading:t.showLoading&&e.isLoading,onClick:t=>Ht(e.templateCode,e.templateId,e.key,!0)},{icon:y((()=>[p(m(F),{component:m(x),size:"18"},null,8,["component"])])),default:y((()=>[g(" "+k(e.label),1)])),_:2},1032,["disabled","loading","onClick"])])),_:2},1032,["options","onSelect"]);var n,r})),128))])),_:1}),d(' <n-button-group>\r\n\t\t\t<n-popover\r\n\t\t\t\tv-for="outer in outerPrintItems"\r\n :key="outer.key"\r\n\t\t\t\ttrigger="hover"\r\n\t\t\t\t:show-arrow="false"\r\n\t\t\t\t:show="downlistPopover.isOperation"\r\n\t\t\t\t@clickoutside="handleClickOutHide(\'isOperation\')"\r\n\t\t\t>\r\n\t\t\t\t<template #trigger>\r\n\t\t\t\t\t<n-button\r\n\t\t\t\t\t\t@mouseenter="delayShowPopover(\'isOperation\')"\r\n\t\t\t\t\t\t@mouseleave="handleClickOutHide(\'isOperation\')"\r\n\t\t\t\t\t\t@click="console.log(33)"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t<n-icon :component="PrintOutline" size="18"></n-icon>\r\n\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t<span class="label bold">{{ outer.label }}</span>\r\n\t\t\t\t\t</n-button>\r\n\t\t\t\t</template>\r\n\t\t\t\t<div class="newprint-button-poperOver">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tclass="print-li"\r\n\t\t\t\t\t\tv-for="operation in operations"\r\n\t\t\t\t\t\t:key="operation.key"\r\n\t\t\t\t\t\t:class="downlistOperation.twoMouseType==operation.key ? \'active\' : \'\' "\r\n\t\t\t\t\t\t@mouseenter="handleTypeChange(\'twoMouseType\', operation.key)"\r\n\t\t\t\t\t\t@mouseleave="handleTypeChange(\'twoMouseType\', \'\')"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<div class="print-lite">\r\n\t\t\t\t\t\t\t<span class="label"> {{ operation.label }} </span>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</n-popover>\r\n\t\t</n-button-group> '),d(" 外显设置按钮 "),wt.value.length>0&&wt.value.length==m(Ft).length&&m(It)?(o(),f(m(j),{key:0,trigger:"click","show-arrow":!1,show:ht.isOutSetting,onClickoutside:n[2]||(n[2]=t=>Dt("isOutSetting"))},{trigger:y((()=>[p(m(L),{onClick:n[0]||(n[0]=t=>_t("isOutSetting"))},{default:y((()=>[B,p(m(F),{style:{"margin-left":"8px"},component:m(E),size:"18"},null,8,["component"])])),_:1})])),default:y((()=>[c("div",R,[(o(!0),s(u,null,v(m(Ft),(t=>(o(),s("div",{class:"print-li",key:t.key},[c("div",H,[c("span",q,k(t.label),1),p(m(M),{checked:t.selected,"onUpdate:checked":e=>t.selected=e},{default:y((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",G,[p(m(N)),c("div",Y,[p(m(L),{type:"primary",size:"small",onClick:Et},{default:y((()=>[g("保存")])),_:1}),m(Ft)&&m(Ft).length>1?(o(),f(m(M),{key:0,checked:m(jt),"onUpdate:checked":n[1]||(n[1]=t=>h(jt)?jt.value=t:null)},{default:y((()=>[g("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:1},8,["show"])):(o(),s(u,{key:1},[d(" 打印全部按钮 "),p(m(j),{trigger:"click","show-arrow":!1,show:ht.oneShow,onClickoutside:n[10]||(n[10]=t=>Dt("oneShow"))},{trigger:y((()=>[b(e.$slots,"button",{handleClickPrintBtn:re,printSpinning:vt.spinning,printbtnText:t.btnText,printVisible:vt.visible},(()=>[p(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=w((()=>Nt("icon")),["stop"]))},{default:y((()=>[p(m(L),{loading:t.showLoading&&vt.spinning,onClick:n[3]||(n[3]=w((()=>Nt("button")),["stop"]))},{icon:y((()=>[p(m(F),{component:m(x),size:"18"},null,8,["component"])])),default:y((()=>[g(" "+k(m(Ct)?"打印全部":t.btnText),1)])),_:1},8,["loading"]),p(m(L),{class:"icon-select"},{icon:y((()=>[p(m(F),{component:m(_),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:y((()=>[c("div",$,[(o(!0),s(u,null,v(bt.value,(t=>(o(),s("div",{class:P(["print-li",kt.oneMouseType==t.key||kt.oneClickType==t.key?"active":""]),key:t.key,onMouseenter:e=>xt("oneMouseType",t.key),onMouseleave:n[9]||(n[9]=t=>xt("oneMouseType","")),onClick:e=>((t,e,n)=>{if(!vt.printParams[n.templateCode])return[];xt(t,e)})("oneClickType",t.key,t)},["divider"==t.key?(o(),f(m(N),{key:0})):"outSetting"==t.key?(o(),s(u,{key:1},[d(" 第二层外显设置 "),p(m(j),{trigger:"click","show-arrow":!1,placement:"right-start",show:ht.isOutSetting,onClickoutside:n[7]||(n[7]=t=>Dt("isOutSetting"))},{trigger:y((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=t=>_t("isOutSetting"))},[c("span",W,k(t.label),1),p(m(F),{color:wt.value.length>0?"#2563F4":"",component:m(E),size:"18"},null,8,["color","component"])])])),default:y((()=>[c("div",X,[(o(!0),s(u,null,v(m(Ft),(t=>(o(),s("div",{class:"print-li",key:t.key},[c("div",Z,[c("span",tt,k(t.label),1),p(m(M),{checked:t.selected,"onUpdate:checked":e=>t.selected=e},{default:y((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",et,[p(m(N)),c("div",nt,[p(m(L),{type:"primary",size:"small",onClick:Et},{default:y((()=>[g("保存")])),_:1}),m(Ft)&&m(Ft).length>1?(o(),f(m(M),{key:0,checked:m(jt),"onUpdate:checked":n[6]||(n[6]=t=>h(jt)?jt.value=t:null)},{default:y((()=>[g("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(o(),s(u,{key:2},[d(" 第二层功能操作 "),c("div",{class:P(["print-lite",vt.printParams[t.templateCode]?"":"isDisabled"])},[c("span",{class:"label bold",onClick:e=>Ht(t.templateCode,t.templateId,t.key,!1)},k(t.label),9,rt),vt.printParams[t.templateCode]?(o(),f(m(j),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:ht[t.key],onClickoutside:e=>Dt(t.key)},{trigger:y((()=>[p(m(F),{component:m(D),size:"18",onClick:e=>_t(t.key)},null,8,["component","onClick"])])),default:y((()=>[c("div",it,[(o(!0),s(u,null,v(m(gt),(e=>(o(),s("div",{class:P(["print-li",kt.twoMouseType==e.key?"active":""]),key:e.key,onMouseenter:t=>xt("twoMouseType",e.key),onMouseleave:n[8]||(n[8]=t=>xt("twoMouseType",""))},[c("div",lt,[c("span",{class:"label",onClick:n=>Gt(e.key,t,!1)},k(e.label),9,ot)])],42,at)))),128))])])),_:2},1032,["show","onClickoutside"])):d("v-if",!0)],2)],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),p(V,O(e.$attrs,{modelValue:vt.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=t=>vt.identityVerification.visible=t),formatId:vt.currentFormatId,templateId:m(Ot),onSuccess:ie}),null,16,["modelValue","formatId","templateId"])],64))}});export{st as default};
|
1
|
+
import{defineComponent as e,inject as t,ref as n,reactive as i,computed as r,onMounted as a,watch as l,openBlock as o,createElementBlock as s,Fragment as u,createElementVNode as c,createCommentVNode as d,createVNode as p,unref as m,withCtx as y,renderList as f,createBlock as v,createTextVNode as g,toDisplayString as k,isRef as h,renderSlot as b,withModifiers as P,normalizeClass as w,mergeProps as S}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as F,NPopover as j,NCheckbox as M,NDivider as N}from"naive-ui";import{PrintOutline as E,SettingsOutline as x,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}from"../constants/index.js";import{Print as z}from"../utils/print.js";import{isIReport as U}from"../utils/browserPrint.js";import A from"./IdentityVerification.vue.js";import{format as V}from"date-fns";import"../api.js";const K={class:"newprint-button-outer"},B=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},q={class:"print-lite"},G={class:"label bold"},H={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},ee={class:"label bold"},te={class:"print-li"},ne={class:"print-lite"},ie=["onClick"],re={class:"newprint-button-poperOver"},ae=["onMouseenter"],le={class:"print-lite"},oe=["onClick"];var se=e({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:""})}},setup(e,{expose:se}){const ue=e,ce=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],de=C();let pe;const me=t(J),ye=n(""),fe=i({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[]});let ve=n([]),ge=n([{label:ue.previewText,key:"previewText"},{label:ue.pdfLoadText,key:"downloadPdf"},{label:ue.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const ke=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),he=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),be=n([]),Pe=n([]),we=r((()=>{if(!fe.currentFormatId)return{};let e=fe.currentFormatId;return fe.formatList.find((t=>t.id===e))}));r((()=>{var e;return(null==(e=we.value)?void 0:e.name)||"格式选择"}));const Se=r((()=>{let e=fe.formatList.find((e=>e.id===fe.currentFormatId));return null==e?void 0:e.templateId})),Oe=r((()=>{let e=fe.formatList.find((e=>e.id===fe.currentFormatId));return null==e?void 0:e.number})),Ce=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowPrintAll})),Ie=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowOutSetting})),Te=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.customProps)||{}})),Le=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.defaultFormatId)||""})),Fe=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.printAllType)||1})),je=r((()=>{const e=ce.map((e=>e.key));return ve.value.filter((t=>!e.includes(t.key)))})),Me=r({get:()=>je.value.every((e=>e.selected)),set(e){je.value.forEach((t=>{t.selected=e}))}}),Ne=async()=>{var e,t;(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await rt(),he.oneShow=!0},Ee=async e=>{if(ue.directPrint){if(fe.spinning)return;return"button"===e?void(Ce.value?await lt():Le.value?async function(e){await rt(!1);const t=be.value.find((t=>t.key==e));t&&Ge(t.templateCode,t.templateId,t.key,!1)}(Le.value):Ne()):Ne()}return Ne()},xe=(e,t)=>{ke[e]=t},_e=()=>{be.value=ve.value.filter((e=>!e.selected)),Pe.value=je.value.filter((e=>e.selected)),Je("oneShow"),Je("isOutSetting"),me("saveOuterPrint",Pe.value)},De=e=>{he[e]=!0},Je=e=>{ke.oneClickType="",he[e]=!1,"isOutSetting"==e&&(he.isOutSetting=!1)},ze=(e,t)=>{Re(!1);let n={type:t,formatId:fe.currentFormatId,templateId:(null==e?void 0:e.templateId)||Se.value,templateCode:(null==e?void 0:e.templateCode)||Oe.value};me("success",e,n)},Ue=e=>{Re(!1),me("error",e),O(e)&&"notInstalledApp"===e.type&&de.error(e.message)},Ae=e=>{Re(!1),me("cancel",e)},Ve=e=>{me("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Ke=()=>JSON.stringify({...ue.token?{token:ue.token}:{}}),Be=(e=[],t)=>{var n,i;let r={},a={};if((null==(n=fe.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(i=Object.keys(e[0].datasetData||{}))?void 0:i[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return r=Object.assign({},JSON.parse(Ke()),Te.value,a),JSON.stringify(r)},Re=(e,t)=>{if(fe.isClickOuterPrint){if(e&&t){const n=Pe.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Pe.value.forEach((e=>{e.isLoading=!1}))}else fe.spinning=e},qe=()=>fe.isClickOuterPrint?Pe.value.some((e=>e.isLoading)):fe.spinning,Ge=(e,t,n,i)=>{const r=fe.printParams[e];if(!r)return;fe.isClickOuterPrint=i,fe.currentFormatId=n;const a=fe.originParams[e]||[];He(r,e,t,n,a)},He=async(e=[],t,n,i,r=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&ze(e,"print")}catch(e){console.log("error",e)}};ue.showLoading&&qe()&&!a||(Re(!0,i),ue.prevFn("print").then((()=>{fe.curPrintParamList=e;const a={formatId:i,templateId:n,authorizationKey:ye.value,printdlgshow:ue.printdlgshow,signature:ue.signature,copies:ue.printCopies};if("MULTI"===ue.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Ke()),Te.value,e[t]));pe.printDirect({...a,params:n},o,Ue,Ae)}else pe.printDirect({...a,params:Be(e,t)},(e=>{e.params=r,e.templateCode=t,e.templateId=n,ze(e,"print")}),Ue,Ae)})).catch((()=>{Ve("print"),Re(!1)})).finally((()=>{fe.visible=!1})))},Ye=async(e,{templateCode:t,templateId:n,key:i},r)=>{const a=fe.printParams[t];if(a)switch(fe.isClickOuterPrint=r,fe.currentFormatId=i,e){case"previewText":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("preview").then((()=>{fe.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Ke()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Be(e,t),l={formatId:i,templateId:n,authorizationKey:ye.value,params:a,btnprint:ue.btnprint,signature:ue.signature};pe.preview(l,(e=>{ze(e,"preview")}),Ue)})).catch((()=>{Ve("preview"),Re(!1)})).finally((()=>{fe.visible=!1})))})(a,t,n,i);break;case"formatEditText":((e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("edit").then((()=>{fe.curPrintParamList=e,fe.currentFormatId=i,fe.identityVerification.visible=!0})).catch((()=>{Ve("edit")})).finally((()=>{Re(!1)})))})(a,0,0,i);break;case"downloadPdf":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("download").then((()=>{fe.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Ke()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Be(e,t),l={formatId:i,templateId:n,authorizationKey:ye.value,print:{print:"1",type:"1"},params:a,signature:ue.signature};pe.downloadPDF(l,(e=>ze(e,"preview")),Ue)})).catch((()=>{Ve("download"),Re(!1)})).finally((()=>{fe.visible=!1})))})(a,t,n,i);break;case"resetPrinter":(async(e=[],t,n,i)=>{if(!ue.showLoading||!qe()){Re(!0,i);try{const e=await pe.resetPrinter(i);if(Re(!1),"success"==(null==e?void 0:e.result))return void de.success(e.message||"重置打印机成功");de.warning("重置打印机失败")}catch(e){Re(!1),de.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,i)}},$e=()=>{},Qe=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},et(n,t,e))})),n},We=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},tt(n,t,e))})),n},Xe=(e,t,n)=>{const i={};return t.forEach((t=>{let r=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(i=V(t,n[e.type])),(null==e?void 0:e.defaultValue)||i})(t,e[t[n]]);e[t[n]]&&r&&(i[t[n]]=r)})),i},Ze=({customizeDataset:e=[],param:t=[]},n={})=>{let i={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[e.name]=JSON.stringify(Xe(n,t,"fieldName"))})),i=Object.assign({},i,Xe(n,t,"key")),i},et=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i],a=n[r];if(!a)return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(Ze(a,t))}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(Ze(l,t))}return e},tt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i];if(!n[r])return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(t)}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r];if(!n[a])return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},nt=async e=>{fe.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],(()=>{var e,t,n;const i=fe.formatList.map((e=>({templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1})));ve.value.unshift(...i),Ie.value&&ve.value.push(...ce),(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(ve.value.forEach((e=>{var t;(null==(t=ue.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Pe.value=ve.value.filter((e=>e.selected))),be.value=ve.value.filter((e=>!e.selected)),ue.hideButtons.length>0&&(ge.value=ge.value.filter((e=>!ue.hideButtons.includes(e.key))));const r=sessionStorage.getItem("portal");if(r){const e=JSON.parse(r),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(t);i.includes("RY7.2.21.1.M2.G94181E")||(ge.value=ge.value.filter((e=>"downloadPdf"!=e.key))),i.includes("RY7.2.21.1.M2.G33633A")||(ge.value=ge.value.filter((e=>"formatEditText"!=e.key)))}})(),fe.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),fe.printParams=Qe(fe.templateParams,ue.params),fe.originParams=We(fe.templateParams,ue.params)},it=async()=>{var e;if(fe.isInited)return!0;fe.isInited=!0,fe.spinning=!0,(()=>{if(pe)return!1;pe=new z})();const t=await ue.queryPrintFormatByNumber();return await nt(t),(null==(e=t.obj)?void 0:e.length)>0&&(ye.value=t.obj[0].authorizationKey||""),fe.spinning=!1,!0},rt=async(e=!0)=>{if(await ue.clickPrevFn()){if(!fe.visible){if(!await it())return!1}e&&(fe.visible=!fe.visible)}},at=e=>{if(fe.identityVerification.visible=!1,U(fe.currentFormatId))return ze(null,"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Ke()),Te.value,fe.curPrintParamList[0])),n="MULTI"===ue.strategy?t:Be(fe.curPrintParamList,Oe.value),i={formatId:fe.currentFormatId,templateId:Se.value,params:n,token:e};pe.editPrintFormat(i,(e=>{ze(e,"edit")}),Ue)};async function lt(){await rt(!1),(()=>{const e=Object.keys(fe.printParams);fe.isClickOuterPrint=!1;const t=fe.originParams;if(1==Fe.value)for(let n=0;n<e.length;n++){const i=e[n],r=fe.printParams[i],a=t[i]||[],l=fe.formatList.filter((e=>e.number==i));l&&l.length>0&&l.forEach((e=>{fe.currentFormatId=e.id,He(r,e.number,e.templateId,e.id,a,!0)}))}2==Fe.value&&Pe.value.forEach((e=>{const n=fe.printParams[e.templateCode],i=t[e.templateCode]||[];fe.currentFormatId=e.key,He(n,e.templateCode,e.templateId,e.key,i,!0)}))})()}return a((()=>{fe.isInited=!1})),l((()=>ue.params),(e=>{Object.keys(fe.templateParams).length>0&&(fe.printParams=Qe(fe.templateParams,ue.params),fe.originParams=We(fe.templateParams,ue.params))}),{deep:!0}),l((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await rt(!1)}),{deep:!0,immediate:!0}),se({directPrint:lt}),(t,n)=>(o(),s(u,null,[c("div",K,[d(" 外显按钮集合 "),p(m(I),null,{default:y((()=>[(o(!0),s(u,null,f(Pe.value,(t=>{return o(),v(m(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:$e,options:(n=m(ge),i=t,fe.printParams[i.templateCode]?n:[]),onSelect:e=>Ye(e,t,!0)},{default:y((()=>[p(m(L),{disabled:!fe.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>Ge(t.templateCode,t.templateId,t.key,!0)},{icon:y((()=>[p(m(F),{component:m(E),size:"18"},null,8,["component"])])),default:y((()=>[g(" "+k(t.label),1)])),_:2},1032,["disabled","loading","onClick"])])),_:2},1032,["options","onSelect"]);var n,i})),128))])),_:1}),d(" 外显设置按钮 "),Pe.value.length>0&&Pe.value.length==m(je).length&&m(Ie)?(o(),v(m(j),{key:0,trigger:"click","show-arrow":!1,show:he.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Je("isOutSetting"))},{trigger:y((()=>[p(m(L),{onClick:n[0]||(n[0]=e=>De("isOutSetting"))},{default:y((()=>[B,p(m(F),{style:{"margin-left":"8px"},component:m(x),size:"18"},null,8,["component"])])),_:1})])),default:y((()=>[c("div",R,[(o(!0),s(u,null,f(m(je),(e=>(o(),s("div",{class:"print-li",key:e.key},[c("div",q,[c("span",G,k(e.label),1),p(m(M),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",H,[p(m(N)),c("div",Y,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:y((()=>[g("保存")])),_:1}),m(je)&&m(je).length>1?(o(),v(m(M),{key:0,checked:m(Me),"onUpdate:checked":n[1]||(n[1]=e=>h(Me)?Me.value=e:null)},{default:y((()=>[g("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:1},8,["show"])):(o(),s(u,{key:1},[d(" 打印全部按钮 "),p(m(j),{trigger:"click","show-arrow":!1,show:he.oneShow,onClickoutside:n[10]||(n[10]=e=>Je("oneShow"))},{trigger:y((()=>[b(t.$slots,"button",{handleClickPrintBtn:rt,printSpinning:fe.spinning,printbtnText:e.btnText,printVisible:fe.visible},(()=>[p(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=P((()=>Ee("icon")),["stop"]))},{default:y((()=>[p(m(L),{loading:e.showLoading&&fe.spinning,onClick:n[3]||(n[3]=P((()=>Ee("button")),["stop"]))},{icon:y((()=>[p(m(F),{component:m(E),size:"18"},null,8,["component"])])),default:y((()=>[g(" "+k(m(Ce)?"打印全部":e.btnText),1)])),_:1},8,["loading"]),p(m(L),{class:"icon-select"},{icon:y((()=>[p(m(F),{component:m(_),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:y((()=>[c("div",$,[(o(!0),s(u,null,f(be.value,(e=>(o(),s("div",{class:w(["print-li",ke.oneMouseType==e.key||ke.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>xe("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>xe("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!fe.printParams[n.templateCode])return[];xe(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(o(),v(m(N),{key:0})):"outSetting"==e.key?(o(),s(u,{key:1},[d(" 第二层外显设置 "),p(m(j),{trigger:"click","show-arrow":!1,placement:"right-start",show:he.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Je("isOutSetting"))},{trigger:y((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>De("isOutSetting"))},[c("span",W,k(e.label),1),p(m(F),{color:Pe.value.length>0?"#2563F4":"",component:m(x),size:"18"},null,8,["color","component"])])])),default:y((()=>[c("div",X,[(o(!0),s(u,null,f(m(je),(e=>(o(),s("div",{class:"print-li",key:e.key},[c("div",Z,[c("span",ee,k(e.label),1),p(m(M),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",te,[p(m(N)),c("div",ne,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:y((()=>[g("保存")])),_:1}),m(je)&&m(je).length>1?(o(),v(m(M),{key:0,checked:m(Me),"onUpdate:checked":n[6]||(n[6]=e=>h(Me)?Me.value=e:null)},{default:y((()=>[g("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(o(),s(u,{key:2},[d(" 第二层功能操作 "),c("div",{class:w(["print-lite",fe.printParams[e.templateCode]?"":"isDisabled"])},[c("span",{class:"label bold",onClick:t=>Ge(e.templateCode,e.templateId,e.key,!1)},k(e.label),9,ie),fe.printParams[e.templateCode]?(o(),v(m(j),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:he[e.key],onClickoutside:t=>Je(e.key)},{trigger:y((()=>[p(m(F),{component:m(D),size:"18",onClick:t=>De(e.key)},null,8,["component","onClick"])])),default:y((()=>[c("div",re,[(o(!0),s(u,null,f(m(ge),(t=>(o(),s("div",{class:w(["print-li",ke.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>xe("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>xe("twoMouseType",""))},[c("div",le,[c("span",{class:"label",onClick:n=>Ye(t.key,e,!1)},k(t.label),9,oe)])],42,ae)))),128))])])),_:2},1032,["show","onClickoutside"])):d("v-if",!0)],2)],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),p(A,S(t.$attrs,{modelValue:fe.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>fe.identityVerification.visible=e),formatId:fe.currentFormatId,templateId:m(Se),onSuccess:at}),null,16,["modelValue","formatId","templateId"])],64))}});export{se as default};
|
@@ -1 +1 @@
|
|
1
|
-
import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as r,useBrowserPrint as n,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as c}from"date-fns";import{io as h}from"socket.io-client";const d=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),p=`${window.location.protocol}//${window.location.host}`,u=`${p}/fdp-api/print/assembly/printIReport`,f=`${p}/bi-api/reprot/print/open/client/printIReportForBase64`,g=`${p}/bi-api/reprot/print/open/client/previewIReport`,w=`${p}/bi-api/reprot/print/open/client/getRemote`,y=`${p}/printService/file`;let v=null;class P{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.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._isHiprint=!1,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,v)return v;v=this,d&&this._isHiprint&&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","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else if("config"===(null==i?void 0:i.exec))this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"";else{const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执11",t,"没有可用的handler11");const{resolve:i,reject:s}=e;s({message:"不支持当前命令"})}}_initDomesticSystem(){try{this.hiPrintSocket=h("http://127.0.0.1:17521",{reconnectionAttempts:3,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(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:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}resetPrinter(t){return this.webview?this.postMessage({exec:"resetprint",data:{formatID:t}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:t}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o=1,printdlgshow:l="0",nobillnode:h="1",btnprint:d="1",messageTimeout:m=0}){const p={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:d,copies:o,messageTimeout:m,...a?{signature:a}:{}};if(s&&(p.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}p.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");p.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=p,await this._queryServicesPrint(p)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:r=0}){const n={};let a={};try{a=Object.assign({},n,JSON.parse(i))}catch(t){a=n}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:r};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:w})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=p+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({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 m({method:"post",url:f,params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _queryPrintForPdf(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:g,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await r(`${y}/${a}/${o}`),c=n(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let s=i.length;const r=new Uint8Array(s);for(;s--;)r[s]=i.charCodeAt(s);return new Blob([r],{type:e})}async preview({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,signature:l,btnprint:c,messageTimeout:h=0},m,p){const u=a(e);if(e=this.getIReportFormatId(u,e),u&&d&&this._isHiprint){const s=await this._queryPrintForPdf(t,e,i,r);if(!s)return null==p?void 0:p("获取文件失败!");const a=n(s,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,a),null==m?void 0:m({file:s})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,p))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:l,btnprint:c,messageTimeout:h}),n=this._handleResult(r,p);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==m||m(n)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==p||p(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h=1,isDownloadFile:m=!0,messageTimeout:p=0},u,f,g,w="printDirect"){const y=a(e);if(e=this.getIReportFormatId(y,e),y&&d&&this._isHiprint){if(!this.isConnectHiPrint)return void f({message:"请连接hiPrint客户端"});const s=await this._queryPrintForBase64(t,e,i,r);if(!s.success)return f({message:s.resultMsg});const{base64:n,formatId:a}=s.map;return this.base64Fragment=n,this._successCallbackFn=u,this._errorCallbackFn=f,void this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:a,pdf_stream:this.base64Fragment})}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,f))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:"7",print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h,messageTimeout:p}),a=this._handleResult(r,f,g);if(!a)return!1;m&&["downloadPDF"].includes(w)&&await this._browserPrint(a,w),null==u||u(a)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==f||f(i),this._handleMonitorNotify(i)}}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=c(new Date,"yyyy-MM-dd"),i=l(),s=c(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}const r=a(t.formatId);if(t.formatId=this.getIReportFormatId(r,t.formatId),r&&d&&this._isHiprint){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{P as Print};
|
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 p=String(navigator.platform).toLowerCase().includes("linux"),d=t.create({timeout:6e4,withCredentials:!1}),m=`${window.location.protocol}//${window.location.host}`,u=`${m}/fdp-api/print/assembly/printIReport`,f=`${m}/bi-api/reprot/print/open/client/printIReportForBase64`,g=`${m}/bi-api/reprot/print/open/client/previewIReport`,w=`${m}/bi-api/reprot/print/open/client/getRemote`,y=`${m}/printService/file`;let v=null;class P{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.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._isHiprint=!1,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,v)return v;v=this,p&&this._isHiprint&&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","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(){try{this.hiPrintSocket=h("http://127.0.0.1:17521",{reconnectionAttempts:3,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(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:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_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)}))}))}resetPrinter(t){return this.webview?this.postMessage({exec:"resetprint",data:{formatID:t}}):d({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:t}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):d({url:"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):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,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o=1,printdlgshow:l="0",nobillnode:h="1",btnprint:p="1",messageTimeout:d=0}){const m={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:p,copies:o,messageTimeout:d,...a?{signature:a}:{}};if(s&&(m.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}m.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");m.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=m,await this._queryServicesPrint(m)}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:f,params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _queryPrintForPdf(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await d({method:"post",url:g,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await r(`${y}/${a}/${o}`),c=n(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let s=i.length;const r=new Uint8Array(s);for(;s--;)r[s]=i.charCodeAt(s);return new Blob([r],{type:e})}async preview({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,signature:l,btnprint:c,messageTimeout:h=0},d,m){const u=a(e);if(e=this.getIReportFormatId(u,e),u&&p&&this._isHiprint){const s=await this._queryPrintForPdf(t,e,i,r);if(!s)return null==m?void 0:m("获取文件失败!");const a=n(s,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,a),null==d?void 0:d({file:s})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,m))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:l,btnprint:c,messageTimeout:h}),n=this._handleResult(r,m);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==m||m(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h=1,isDownloadFile:d=!0,messageTimeout:m=0},u,f,g,w="printDirect"){const y=a(e);if(e=this.getIReportFormatId(y,e),y&&p&&this._isHiprint){if(!this.isConnectHiPrint)return void f({message:"请连接hiPrint客户端"});const s=await this._queryPrintForBase64(t,e,i,r);if(!s.success)return f({message:s.resultMsg});const{base64:n,formatId:a}=s.map;return this.base64Fragment=n,this._successCallbackFn=u,this._errorCallbackFn=f,void this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:a,pdf_stream:this.base64Fragment})}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,f))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:"7",print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h,messageTimeout:m}),a=this._handleResult(r,f,g);if(!a)return!1;d&&["downloadPDF"].includes(w)&&await this._browserPrint(a,w),null==u||u(a)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==f||f(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,"/")}const r=a(t.formatId);if(t.formatId=this.getIReportFormatId(r,t.formatId),r&&p&&this._isHiprint){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{P as Print};
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,provide as o,ref as t,computed as r,toRaw as a,openBlock as i,createElementBlock as s,mergeProps as l,unref as n,createElementVNode as m,createVNode as u,isRef as f,withCtx as d,createBlock as c,createCommentVNode as p,createTextVNode as v}from"vue";import{useTheme as
|
1
|
+
import{defineComponent as e,provide as o,ref as t,computed as r,toRaw as a,openBlock as i,createElementBlock as s,mergeProps as l,unref as n,createElementVNode as m,createVNode as u,isRef as f,withCtx as d,createBlock as c,createCommentVNode as p,createTextVNode as v}from"vue";import{useTheme as g}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import"date-fns";import{isArray as h,cloneDeep as _,isFunction as y}from"lodash-es";import"@vue/shared";import{uuidGenerator as x,traverse as j}from"../../../shared/utils/index.js";import"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import{NSelect as C,NSpace as k}from"naive-ui";import{useVersion as F}from"../../../shared/hooks/useVersion.js";import L from"../../../shared/components/VueDraggable/src/vuedraggable.js";import V from"./components/FormConfigCreator.vue.js";import b from"./components/FormConfigDragDisplay.vue.js";import w from"./components/FormConfigEdit.vue.js";import M from"./components/FormConfigEventSetting.vue.js";import R from"./components/FormConfigMaterialItem.js";import{useDataNormalize as D}from"./hooks/useDataNormalize.js";import{InjectionFormConfigProps as E,InjectionFormConfigEmit as H,InjectionFieldList as S,InjectionMaterialList as I,InjectionLowCodeReactions as U,InjectionActiveFieldItem as O,FORM_CONFIG_GROUP as P}from"./constants/index.js";import{fieldItemNormalize as T}from"./utils/index.js";import{useSortableConfig as z}from"./hooks/useSortalbeConfig.js";import"./hooks/useConfigurationField.js";const A=["id"],B={class:"form-config__material"},N=m("header",{class:"form-config__materialHeader"},"物料区",-1),W={class:"form-config__displayWrapper"},q={class:"form-config__displayHeader"},G={class:"form-config__config"},J=m("header",{class:"form-config__configHeader"},"配置区",-1),K={class:"form-config__configContent"};var Q=e({__name:"FormConfig",props:{maxHeight:{type:String},fieldVisitor:{type:Object},textFormatter:{type:Function},formRenderRef:{type:Object},extraMaterialList:{type:[Array,Function]},showLowCodeReactions:Boolean,formProps:{type:Object},beforeMove:{type:Function}},emits:["addItem","removeItem","reactionsValidateFailure"],setup(e,{expose:Q,emit:X}){const Y=e;o(E,Y),o(H,X);const Z=x(),$=g(),ee=t([]);o(S,ee);const oe=t([]);o(I,oe);const te=t([]);function re(e){ee.value.some((o=>o.key===e.key))||ee.value.push(e)}o(U,te);const ae=(e,o)=>y(Y.textFormatter)?Y.textFormatter(e,o):o,ie=t();o(O,ie);const se=t(),{transform:le,inverseTransform:ne}=D(Y),me=r({get:()=>null,set(e){if(!e)return;const o=fe.value.find((o=>o.key===e));o&&(o.__extra=!0,T(o),oe.value.push(o),X("addItem",o))}}),ue=t([]),fe=r((()=>{if(!h(ue.value))return[];const e=[];return j([...oe.value,...ee.value],(o=>e.push(o.key))),ue.value.filter((o=>!e.find((e=>e===o.key))))}));async function de(){Y.extraMaterialList&&!ue.value.length&&(ue.value=y(Y.extraMaterialList)?await Y.extraMaterialList():Y.extraMaterialList)}return Q({loadData({fieldList:e,lowCodeReactions:o=[]}){let t=[],r=[];e.forEach((e=>{return!1===(o=_(a(e))).show?r.push(o):t.push(o),void T(o);var o})),ee.value=le(t),oe.value=r,te.value=o,ie.value=void 0},validate(){var e;return null==(e=se.value)?void 0:e.validate()},getData:(e=!1)=>({fieldList:ne(_(a(ee.value)),e,{show:!0}),materialList:ne(_(a(oe.value)),e,{show:!1}),lowCodeReactions:_(a(te.value))}),clearExtraList(){ue.value=[]}}),(o,t)=>(i(),s("section",l({class:"form-config",style:{"--max-height":e.maxHeight,...n($)},id:n(Z)},n(F)()),[m("section",B,[N,u(n(L),l(z({fieldList:ee,materialList:oe,hooks:{beforeMove:Y.beforeMove}}),{class:"form-config__materialContent",modelValue:n(oe),"onUpdate:modelValue":t[0]||(t[0]=e=>f(oe)?oe.value=e:null)}),{item:d((({element:e})=>[u(n(R),{"form-config-item":e,"text-formatter":ae,"material-List":n(oe)},null,8,["form-config-item","material-List"])])),_:1},16,["modelValue"]),e.extraMaterialList?(i(),c(n(C),{key:0,class:"form-config__materialExtraList",filterable:"",value:n(me),"onUpdate:value":t[1]||(t[1]=e=>f(me)?me.value=e:null),placeholder:"请选择额外物料",options:n(fe),"label-field":"name","value-field":"key",onFocus:de},null,8,["value","options"])):p("v-if",!0)]),m("section",W,[m("header",q,[v(" 布局区 "),u(n(k),null,{default:d((()=>[e.showLowCodeReactions?(i(),c(M,{key:0,modelValue:te.value,"onUpdate:modelValue":t[2]||(t[2]=e=>te.value=e),onValidateFailure:t[3]||(t[3]=e=>X("reactionsValidateFailure",e))},null,8,["modelValue"])):p("v-if",!0),u(V,{onSubmit:re})])),_:1})]),u(b,{class:"form-config__displayContent",group:n(P),"text-formatter":ae,modelValue:n(ee),"onUpdate:modelValue":t[4]||(t[4]=e=>f(ee)?ee.value=e:null)},null,8,["group","modelValue"])]),m("section",G,[J,m("section",K,[u(w,{ref_key:"formConfigEditRef",ref:se,uuid:n(Z),"bind-form-render-ref":e.formRenderRef,"form-props":e.formProps},null,8,["uuid","bind-form-render-ref","form-props"])])])],16,A))}});export{Q as default};
|
@@ -8,3 +8,4 @@ export declare function bindHover(formConfigItem: FormConfigItem): {
|
|
8
8
|
'is-hovering': boolean;
|
9
9
|
};
|
10
10
|
export declare function findFieldItemByKey(fieldList: Nullable<FieldItem[]>, key: string): FieldItem | undefined;
|
11
|
+
export declare function fieldItemNormalize(item: FormConfigItem): void;
|
@@ -1 +1 @@
|
|
1
|
-
import{traverse as e}from"../../../../shared/utils/index.js";import{isArray as
|
1
|
+
import{traverse as e}from"../../../../shared/utils/index.js";import{isArray as n}from"lodash-es";import{ref as r}from"vue";function i(e){return{ALL_LINE:24,HALF_LINE:12,FIVE_SIX:20,TWO_THREE:16,ONE_THREE:8,THREE_FOUR:18,ONE_FOUR:6,ONE_SIX:4,ONE_EIGHT:3}[e]||24}const o=r();function t(e){return{onMouseenter:()=>o.value=e,onMouseleave:()=>o.value=void 0,"is-hovering":o.value===e}}function l(r,i){if(!n(r)||!r.length)return;let o;return e(r,((e,n)=>{(null==e?void 0:e.val_key)===i&&(o=e,n())}),["children","properties"]),o}function u(e){"LINE_BAR"===e.type&&(e.children=[]),"COMBINATION"===e.type&&n(e.children)&&e.children.length&&e.children.forEach((e=>{e.__isCombinationChild=!0}))}export{t as bindHover,u as fieldItemNormalize,l as findFieldItemByKey,i as layoutWidthEnum2Column};
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import"../../index.js";import{defineTablePlugin as e}from"../hooks/useTablePlugin.js";function n(){const n="keyboardEventPlugin";return e({name:n,apply(e){e.eventHooks.onKeydown.tap({name:n,before:"forceArrowKeyPlugin"},(({$event:e,$table:n},o,{emits:t})=>{let{row:r,column:l}=n.getSelectedCell()||n.getEditRecord()||{};if(!r||!l)return;const a=e.key;function i(e){var o,t,r;const a=null!=(t=null==(o=n.getColumns())?void 0:o.findIndex((e=>e===l)))?t:-1;a<0||(l=null!=(r=n.getColumns()[a+("left"===e?-1:1)])?r:l)}function u(e){var o;const t=n.getTableData().fullData.findIndex((e=>e===r));t<0||(r=null!=(o=n.getTableData().fullData[t+("up"===e?-1:1)])?o:r)}if(function({keyboardConfig:e={}}){return e.isArrow&&e.forceArrowKey}(o))switch(a){case"ArrowUp":u("up");break;case"ArrowDown":u("down");break;case"ArrowLeft":i("left");break;case"ArrowRight":i("right")}t("keyboard",{$table:n,key:a,index:n.getRowIndex(r),value:r[l.field],row:r,column:l})}))}})}export{n as keyboardEventPlugin};
|
@@ -1 +1 @@
|
|
1
|
-
import{inject as e,createVNode as l,toRaw as n,computed as r,withModifiers as i}from"vue";import{property as o,isFunction as t,isEmpty as d,identity as c}from"lodash-es";import{NPopover as u,NCheckbox as a,NRadio as s}from"naive-ui";import{InjectionIhoTableUUID as f,WIDGET_TYPE as v,InjectionIhoTableEmits as h}from"../../../constants/index.js";import{IhoTableRenderHelper as x}from"../../../utils/index.js";import{isVerticalHeader as k,getHeaderDepthByField as m,getOriginBasePayload as w,getOriginRowFromRowData as p}from"./utils.js";const g={seq:e=>e.rowIndex+1,checkbox(n,o){const t=e(h),d=r({get:()=>n.row.checked,set(){var e,l;n.row.checked=!n.row.checked,null==t||t("checkboxChange",{...n,checked:n.row.checked,records:null!=(l=null==(e=o.originalData)?void 0:e.filter((e=>e.checked)))?l:[]})}});return l(a,{checked:d.value,"onUpdate:checked":e=>d.value=e,onClick:i(c,["stop"])},null)},radio(e,n){const o=r({get:()=>e.row===n.currentRow,set(){n.currentRow=e.row}});return l(s,{checked:o.value,"onUpdate:checked":e=>o.value=e,onClick:i(c,["stop"])},null)}};function b(n,i,c){return(s,p)=>{var b,D;const I=e(f),C=i(I),{row:$,column:H}=p;if(k(H.field)){const n=o("originalField")($);if("checkbox"===n.type)return function(n,i){var o,t;const c=e(h),u=r({get(){var e,l;return!d(i.originalData)&&null!=(l=null==(e=i.originalData)?void 0:e.every((e=>e.checked)))&&l},set(e){var l,r,o;null==(l=i.originalData)||l.forEach((l=>l.checked=e)),null==c||c("checkboxAll",{$table:n.$table,checked:u.value,records:null!=(o=null==(r=i.originalData)?void 0:r.filter((e=>e.checked)))?o:[]})}}),s=r((()=>{var e,l;return null!=(l=null==(e=i.originalData)?void 0:e.some((e=>e.checked)))&&l}));return l(a,{checked:u.value,"onUpdate:checked":e=>u.value=e,indeterminate:!u.value&&s.value,disabled:null==(t=null==(o=i.originalTableConfig)?void 0:o.checkboxConfig)?void 0:t.disableHeader},null)}(p,C);const i=$[H.field.replaceAll("_parent","")];return x.hasTitlePrefix(n)&&m(H.field)===C.headerDepth?[l(u,null,{trigger:()=>l("i",{class:"vxe-cell-help-icon vxe-icon-question-circle-fill"},null),default:()=>n.titlePrefix.useHTML?l("div",{innerHTML:n.titlePrefix.useHTML},null):l("div",null,[n.titlePrefix.content])}),i]:i}const y={$table:p.$table,columnIndex:p.rowIndex,$columnIndex:p.rowIndex,isHidden:p.isHidden,rowid:p.rowid,...w($,H)};if(!y.row)return null;const{originalField:{editRender:T={},slots:L={}}={}}=$;if(t(L[c]))return L[c](y);if(L.default&&!L.edit)return L.default(y);if(g[y.type])return g[y.type](y,C);const F=T.name||v.DEFAULT,P=n.renderer.get(F);return P?"default"===c?null==(b=P.renderCell)?void 0:b.call(P,T,y):null==(D=P.renderEdit)?void 0:D.call(P,T,y):
|
1
|
+
import{inject as e,createVNode as l,toRaw as n,computed as r,withModifiers as i}from"vue";import{property as o,isFunction as t,isEmpty as d,identity as c}from"lodash-es";import{NPopover as u,NCheckbox as a,NRadio as s}from"naive-ui";import{InjectionIhoTableUUID as f,WIDGET_TYPE as v,InjectionIhoTableEmits as h}from"../../../constants/index.js";import{IhoTableRenderHelper as x}from"../../../utils/index.js";import{isVerticalHeader as k,getHeaderDepthByField as m,getOriginBasePayload as w,getOriginRowFromRowData as p}from"./utils.js";const g={seq:e=>e.rowIndex+1,checkbox(n,o){const t=e(h),d=r({get:()=>n.row.checked,set(){var e,l;n.row.checked=!n.row.checked,null==t||t("checkboxChange",{...n,checked:n.row.checked,records:null!=(l=null==(e=o.originalData)?void 0:e.filter((e=>e.checked)))?l:[]})}});return l(a,{checked:d.value,"onUpdate:checked":e=>d.value=e,onClick:i(c,["stop"])},null)},radio(e,n){const o=r({get:()=>e.row===n.currentRow,set(){n.currentRow=e.row}});return l(s,{checked:o.value,"onUpdate:checked":e=>o.value=e,onClick:i(c,["stop"])},null)}};function b(n,i,c){return(s,p)=>{var b,D;const I=e(f),C=i(I),{row:$,column:H}=p;if(k(H.field)){const n=o("originalField")($);if("checkbox"===n.type)return function(n,i){var o,t;const c=e(h),u=r({get(){var e,l;return!d(i.originalData)&&null!=(l=null==(e=i.originalData)?void 0:e.every((e=>e.checked)))&&l},set(e){var l,r,o;null==(l=i.originalData)||l.forEach((l=>l.checked=e)),null==c||c("checkboxAll",{$table:n.$table,checked:u.value,records:null!=(o=null==(r=i.originalData)?void 0:r.filter((e=>e.checked)))?o:[]})}}),s=r((()=>{var e,l;return null!=(l=null==(e=i.originalData)?void 0:e.some((e=>e.checked)))&&l}));return l(a,{checked:u.value,"onUpdate:checked":e=>u.value=e,indeterminate:!u.value&&s.value,disabled:null==(t=null==(o=i.originalTableConfig)?void 0:o.checkboxConfig)?void 0:t.disableHeader},null)}(p,C);const i=$[H.field.replaceAll("_parent","")];return x.hasTitlePrefix(n)&&m(H.field)===C.headerDepth?[l(u,null,{trigger:()=>l("i",{class:"vxe-cell-help-icon vxe-icon-question-circle-fill"},null),default:()=>n.titlePrefix.useHTML?l("div",{innerHTML:n.titlePrefix.useHTML},null):l("div",null,[n.titlePrefix.content])}),i]:i}const y={$table:p.$table,columnIndex:p.rowIndex,$columnIndex:p.rowIndex,isHidden:p.isHidden,rowid:p.rowid,...w($,H)};if(!y.row)return null;const{originalField:{editRender:T={},slots:L={}}={}}=$;if(t(L[c]))return L[c](y);if(L.default&&!L.edit)return L.default(y);if(g[y.type])return g[y.type](y,C);const F=T.name||v.DEFAULT,P=n.renderer.get(F);return P?"default"===c?null==(b=P.renderCell)?void 0:b.call(P,T,y):null==(D=P.renderEdit)?void 0:D.call(P,T,y):null}}function D(l,r){return(i,t)=>{var d,c,u;const a=e(f),s=r(a),v=null==(d=s.fixedLeftVerticalData)?void 0:d[t.$rowIndex];if(!v)return null;const h=o("originalField")(v),x=p(v,m(t.column.field)),k=n(null==(c=s.editCell)?void 0:c.row)===n(x)&&n(null==(u=s.editCell)?void 0:u.column)===n(h);return b(l,r,k?"edit":"default")(null,{...t,row:v,rowIndex:t.$rowIndex,rowid:t.$rowIndex+"",fixed:t.column.fixed,isHidden:!t.column.visible,type:t.column.type})}}export{g as VerticalRenderMap,b as createCellRender,D as createHeaderCellRender};
|
@@ -1 +1 @@
|
|
1
|
-
var e="@cnhis-design-vue/shared",s="3.2.6-release.
|
1
|
+
var e="@cnhis-design-vue/shared",s="3.2.6-release.2",i="index.ts",n={"naive-ui":"^2.30.0",vue:"^3.2.0"},a={"@vicons/ionicons5":"^0.12.0","lodash-es":"^4.17.21",moment:"^2.29.1","video.js":"^7.19.2","videojs-contrib-hls":"^5.15.0",viewerjs:"^1.10.5","xe-utils":"^3.5.4"},d={name:e,version:"3.2.6-release.2",private:!0,main:"index.ts",peerDependencies:n,dependencies:a};export{d as default,a as dependencies,i as main,e as name,n as peerDependencies,s as version};
|
@@ -1 +1 @@
|
|
1
|
-
import{Path as e}from"@formily/path";import{isArray as n,isString as t,includes as r,negate as a,isNumber as
|
1
|
+
import{Path as e}from"@formily/path";import{isArray as n,isString as t,includes as r,negate as a,isNumber as i,gt as o,gte as l,lt as u,lte as c,identity as f,noop as s,isObject as p}from"lodash-es";import{unref as d}from"vue";import{add as m,differenceInMilliseconds as F}from"date-fns";function D(e){return null==e||""==e}function N(e){return(n,r)=>(t(n)&&(n=+n),t(r)&&(r=+r),!(!i(n)||Number.isNaN(n)||!i(r)||Number.isNaN(r))&&e(n,r))}const g={EQ:(e,n)=>`${e}`===n,NEQ:(e,n)=>`${e}`!==n,CL:(e,a)=>!(!n(e)&&!t(e))&&r(e,a),NC:(e,a)=>!n(e)&&!t(e)||!r(e,a),NULL:D,NOT_NULL:a(D),BIG:N(o),BIGEQ:N(l),LESS:N(u),LESSEQ:N(c)};function E(e,n,t={}){return(t[n.con]||g[n.con]||(()=>!1))(e,`${n.value}`)}function h(e,n){if(!n||!t(n))return e.every(f);try{return new Function("return "+n.replace(/OR/gi,"||").replace(/AND/gi,"&&").replace(/[a-z]/gi,"").replace(/\d+/g,(n=>e[+n-1]?"true":"false")))()}catch(e){return console.error("表达式错误=>",n),!1}}function v(t,r){if(!n(r.conObj))return!1;return h(r.conObj.map((n=>E(e.getIn(t,n.field_key),n,r.compareMap))),r.sqlExpression)}function b(t,r){if(!n(r.conditions))return!1;return h(r.conditions.map((n=>{const a=e.getIn(t,n.field);return"field"===n.valueType?E(a,{con:n.type,value:e.getIn(t,n.value)},r.compareMap):E(a,{con:n.type,value:n.value},r.compareMap)})),r.sqlExpression)}const A=Object.freeze({SET_VALUE:function(e,{getter:n,setter:r}){if(!p(e))return;const{results:a=[],params:i=[],compareMap:o={}}=e;if(!a.length)return;function l(e){var r;if(!t(e))return e;const a=e.trim().match(/^\$\{([a-zA-Z\d\s]+)}$/);return a?n(null==(r=a[1])?void 0:r.trim()):e}i.every((e=>e&&e.p_name&&E(n(e.p_name),{con:e.p_select,value:l(e.p_value)},o)))&&a.forEach((e=>r(e.p_name,l(e.p_value))))},REPEAT_VALIDATE:s,IS_SHOW_FIELD:s,SQLSAVE:s,API:s});function I(e){return A[e]||s}function L(e,r,a){function o(e){return n(e)&&!!e.length}function l(e,n=!0){e.forEach((e=>{if(!e.operationalResult||!n&&null!=r(e.operationalResult))return;const o=e.operationFormParam.reduce(((e,n)=>(e[n=n.replace(/^table\./,"")]=+r(n),e)),{}),l=e.operationalRule.replace(/\${(.+?)}/g,"$1");let u=new Function("table",`return ${l}`)(o);t(u)&&(u=+u),u=i(u)?isNaN(u)?"":u.toFixed(+e.operationalPrecision):"",a(e.operationalResult,u)}))}return{operationalFormHandler:function(n){if(!o(d(e)))return;const t=d(e).filter((e=>e.operationFormParam.includes(`table.${n}`)));t.length&&l(t)},triggerAllOperationalFormHandler:function(){o(d(e))&&l(d(e),!1)}}}function V(e,t,r){function a(e){return n(e)&&!!e.length}function o(e,n=!0){e.forEach((e=>{e.diffValField&&e.diffValUnit&&e.scene&&(n||null==t(e.diffValField))&&("DIFF"===e.scene?function({startDateField:e,endDateField:n,diffValField:a,diffValUnit:i,precision:o="0"}){const l=t(e),u=t(n);if(l&&u){const e=F(new Date(u),new Date(l))/1e3/60,n=e/60,t=n/24;let c="";switch(i){case"DAY":c=t.toFixed(+o);break;case"HOUR":c=n.toFixed(+o);break;case"MIN":c=e.toFixed(+o);break;case"DHM":c=`${Math.floor(t)}天${Math.floor(n%24)}小时${Math.floor(e%60)}分钟`;break}r(a,c)}else r(a,null)}(e):"CALC"===e.scene&&function(e){const n=+e.diffValField;if(!i(n)||Number.isNaN(n))return;const a=t(e.endDateField);if(a){const t=m(new Date(a),{days:"DAY"===e.diffValUnit?n:0,hours:"HOUR"===e.diffValUnit?n:0,minutes:"MIN"===e.diffValUnit?n:0});r(e.startDateField,t)}else r(e.startDateField,null)}(e))}))}return{dateOperationalFormHandler:function(n){if(!a(d(e)))return;const t=d(e).filter((e=>"DIFF"===e.scene&&e.startDateField===n||e.endDateField===n));t.length&&o(t)},triggerAllDateOperationalFormHandler:function(){a(d(e))&&o(d(e),!1)}}}export{I as getBindEventSettingTrigger,V as getDateOperationalFormHandler,L as getOperationalFormHandler,h as isConditionsMatchSqlExpression,E as isMatchLowCodeCondition,v as isMatchLowCodeConditionsWithSqlExpression,b as isMatchNewLowCodeConditionsWithSqlExpression};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cnhis-design-vue",
|
3
|
-
"version": "3.2.6-release.
|
3
|
+
"version": "3.2.6-release.2",
|
4
4
|
"license": "ISC",
|
5
5
|
"module": "./es/components/index.js",
|
6
6
|
"main": "./es/components/index.js",
|
@@ -72,5 +72,5 @@
|
|
72
72
|
"iOS 7",
|
73
73
|
"last 3 iOS versions"
|
74
74
|
],
|
75
|
-
"gitHead": "
|
75
|
+
"gitHead": "81a60383bd1a2cfff3a227552fcc9ebbf383dfba"
|
76
76
|
}
|