cnhis-design-vue 3.2.8-release.1 → 3.2.8-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/ai-chat/index.d.ts +75 -0
- package/es/components/ai-chat/index.js +1 -0
- package/es/components/ai-chat/src/Index.vue.d.ts +77 -0
- package/es/components/ai-chat/src/Index.vue.js +1 -0
- package/es/components/ai-chat/src/Index.vue2.js +1 -0
- package/es/components/ai-chat/src/components/ChatFooter.vue.d.ts +14 -0
- package/es/components/ai-chat/src/components/ChatFooter.vue.js +1 -0
- package/es/components/ai-chat/src/components/ChatFooter.vue2.js +1 -0
- package/es/components/ai-chat/src/components/ChatMain.d.ts +8 -0
- package/es/components/ai-chat/src/components/ChatMain.js +1 -0
- package/es/components/ai-chat/src/types/index.d.ts +20 -0
- package/es/components/ai-chat/src/types/index.js +1 -0
- package/es/components/ai-chat/style/index.css +1 -0
- package/es/components/annotation-edit/src/AnnotationEdit.js +1 -1
- package/es/components/audio-sdk/src/components/recordingDialog.vue2.js +1 -1
- package/es/components/button-print/index.d.ts +38 -0
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +38 -0
- package/es/components/button-print/src/ButtonPrint.vue2.js +1 -1
- package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +17 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
- package/es/components/button-print/src/components/OldPrintComponent.vue.d.ts +9 -0
- package/es/components/button-print/src/components/OldPrintComponent.vue2.js +1 -1
- package/es/components/button-print/src/utils/print.js +1 -1
- package/es/components/button-print/style/index.css +1 -1
- package/es/components/calendar/src/Calendar.vue2.js +1 -1
- package/es/components/callback/src/components/render/popupMaps.d.ts +3 -2
- package/es/components/date-picker/src/DatePicker.vue2.js +1 -1
- package/es/components/field-set/src/FieldColor.vue.d.ts +10 -1
- package/es/components/field-set/src/FieldFilter.vue.d.ts +10 -1
- package/es/components/field-set/src/FieldSet.vue.d.ts +21 -2
- package/es/components/field-set/src/FieldSet.vue2.js +1 -1
- package/es/components/field-set/src/components/condition.vue2.js +1 -1
- package/es/components/field-set/src/components/edit-dialog.vue2.js +1 -1
- package/es/components/field-set/src/components/table-row.vue.d.ts +10 -1
- package/es/components/field-set/src/components/table-row.vue2.js +1 -1
- package/es/components/field-set/src/utils/index.d.ts +1 -1
- package/es/components/field-set/src/utils/index.js +1 -1
- package/es/components/form-config/index.d.ts +6 -4
- package/es/components/form-config/src/FormConfig.vue.d.ts +6 -4
- package/es/components/form-config/src/FormConfig.vue2.js +1 -1
- package/es/components/form-config/src/components/FormConfigCreator.vue.d.ts +3 -2
- package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +3 -2
- package/es/components/form-config/src/components/FormConfigEventSetting.vue2.js +1 -1
- package/es/components/form-render/index.d.ts +3 -2
- package/es/components/form-render/src/FormRender.vue.d.ts +2 -1
- package/es/components/form-render/src/FormRender.vue2.js +1 -1
- package/es/components/form-render/src/FormRenderWrapper.vue.d.ts +3 -2
- package/es/components/form-render/src/FormRenderWrapper.vue2.js +1 -1
- package/es/components/form-render/src/components/renderer/formItem.js +1 -1
- package/es/components/form-render/src/components/renderer/levelSearchCascader/index.js +1 -1
- package/es/components/form-render/src/components/renderer/searchCascade.js +1 -1
- package/es/components/form-render/src/components/renderer/select.js +1 -1
- package/es/components/form-render/src/hooks/useFormContext.js +1 -1
- package/es/components/form-render/src/hooks/useFormEvent.d.ts +1 -1
- package/es/components/form-render/src/hooks/useFormRenderOptions.js +1 -1
- package/es/components/form-render/src/types/index.d.ts +1 -0
- package/es/components/guide/src/renderer.js +1 -1
- package/es/components/iho-chat/index.d.ts +3 -0
- package/es/components/iho-chat/src/Index.vue.d.ts +3 -0
- package/es/components/iho-chat/src/Index.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatAdd.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatFile.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +4 -0
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatRecord.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatSearch.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatSet.vue2.js +1 -1
- package/es/components/iho-chat/src/hooks/useSearchUserList.js +1 -1
- package/es/components/iho-chat/style/index.css +1 -1
- package/es/components/iho-table/src/IhoTable.vue2.js +1 -1
- package/es/components/iho-table/src/plugins/lowCodeFieldAdaptorPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/levelSearchCascadePlugin/levelSearchCascade.vue2.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/editSelect.js +1 -1
- package/es/components/index.css +1 -1
- package/es/components/index.d.ts +2 -1
- package/es/components/index.js +1 -1
- package/es/components/info-header/index.d.ts +6 -4
- package/es/components/info-header/src/InfoHeader.vue.d.ts +6 -4
- package/es/components/info-header/src/InfoHeader.vue2.js +1 -1
- package/es/components/info-header/src/components/infoDescription/index.vue.d.ts +3 -2
- package/es/components/info-header/src/components/patientInfo/index.vue.d.ts +3 -2
- package/es/components/keyboard/src/Keyboard.vue2.js +1 -1
- package/es/components/search-cascader/src/SearchCascader.vue2.js +1 -1
- package/es/components/shortcut-provider/src/ShortcutProvider.vue2.js +1 -1
- package/es/components/shortcut-setter/index.d.ts +3 -2
- package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +3 -2
- package/es/components/shortcut-setter/src/ShortcutSetter.vue2.js +1 -1
- package/es/components/step-notice/src/StepNotice.vue2.js +1 -1
- package/es/components/step-notice/src/hooks/useTheme.js +1 -1
- package/es/components/steps-wheel/src/StepsWheel.vue2.js +1 -1
- package/es/components/time-picker/src/TimePicker.vue2.js +1 -1
- package/es/components/tooth-bitmap/src/ToothBitmap.vue2.js +1 -1
- package/es/shared/assets/img/ai__avatar.png.js +1 -0
- package/es/shared/hooks/index.d.ts +1 -0
- package/es/shared/hooks/index.js +1 -1
- package/es/shared/hooks/selectHooks/useOptionFiltered.js +1 -1
- package/es/shared/hooks/selectHooks/useSearchContent.js +1 -1
- package/es/shared/hooks/selectHooks/useSelectRenders.js +1 -1
- package/es/shared/hooks/useFormRequest/index.js +1 -1
- package/es/shared/hooks/useLevelSearchCascader.js +1 -1
- package/es/shared/package.json.js +1 -1
- package/package.json +2 -2
- /package/es/{components/iho-chat/src → shared}/hooks/useScrollLoading.d.ts +0 -0
- /package/es/{components/iho-chat/src → shared}/hooks/useScrollLoading.js +0 -0
@@ -94,6 +94,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
94
94
|
type: NumberConstructor;
|
95
95
|
default: number;
|
96
96
|
};
|
97
|
+
resolution: {
|
98
|
+
type: NumberConstructor;
|
99
|
+
};
|
97
100
|
newPrintSetting: {
|
98
101
|
type: ObjectConstructor;
|
99
102
|
default: () => {
|
@@ -103,6 +106,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
103
106
|
customProps: {};
|
104
107
|
outerPrintKeys: never[];
|
105
108
|
defaultFormatId: string;
|
109
|
+
shortcut: {};
|
106
110
|
};
|
107
111
|
};
|
108
112
|
}, {
|
@@ -114,6 +118,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
114
118
|
printInstance: Print | null;
|
115
119
|
downloadPdfCode: string;
|
116
120
|
formatEditTextCode: string;
|
121
|
+
resetPrintButtonCode: string;
|
117
122
|
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
118
123
|
printParams: {
|
119
124
|
type: PropType<AnyObject[]>;
|
@@ -206,6 +211,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
206
211
|
type: NumberConstructor;
|
207
212
|
default: number;
|
208
213
|
};
|
214
|
+
resolution: {
|
215
|
+
type: NumberConstructor;
|
216
|
+
};
|
209
217
|
newPrintSetting: {
|
210
218
|
type: ObjectConstructor;
|
211
219
|
default: () => {
|
@@ -215,6 +223,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
215
223
|
customProps: {};
|
216
224
|
outerPrintKeys: never[];
|
217
225
|
defaultFormatId: string;
|
226
|
+
shortcut: {};
|
218
227
|
};
|
219
228
|
};
|
220
229
|
}>> & {}>>;
|
@@ -239,6 +248,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
239
248
|
curPrintParamList: never[];
|
240
249
|
ireportExecuteMode: number;
|
241
250
|
};
|
251
|
+
shortcutFn: any;
|
242
252
|
options: import("vue").Ref<AnyObject[]>;
|
243
253
|
operations: import("vue").Ref<AnyObject[]>;
|
244
254
|
downlistOperation: {
|
@@ -262,6 +272,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
262
272
|
printCustomProps: import("vue").ComputedRef<any>;
|
263
273
|
defaultPrintFormatId: import("vue").ComputedRef<any>;
|
264
274
|
isPrintAllType: import("vue").ComputedRef<any>;
|
275
|
+
shortcutSettings: import("vue").ComputedRef<any>;
|
276
|
+
printAllShortcut: import("vue").ComputedRef<any>;
|
265
277
|
showSettingItems: import("vue").ComputedRef<AnyObject[]>;
|
266
278
|
isSelectedAll: import("vue").WritableComputedRef<boolean>;
|
267
279
|
initShowDownList: () => Promise<void>;
|
@@ -307,6 +319,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
307
319
|
mergeTemplateList: (list: any[]) => any;
|
308
320
|
initCRM: (formatListResult: any) => Promise<void>;
|
309
321
|
init: () => Promise<boolean>;
|
322
|
+
registerShort: () => Promise<void>;
|
310
323
|
handleClickBtn: (visible?: boolean) => Promise<false | undefined>;
|
311
324
|
reformatPrintParams: () => void;
|
312
325
|
verifiySuccess: (token: string) => void;
|
@@ -593,6 +606,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
593
606
|
type: NumberConstructor;
|
594
607
|
default: number;
|
595
608
|
};
|
609
|
+
resolution: {
|
610
|
+
type: NumberConstructor;
|
611
|
+
};
|
596
612
|
newPrintSetting: {
|
597
613
|
type: ObjectConstructor;
|
598
614
|
default: () => {
|
@@ -602,6 +618,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
602
618
|
customProps: {};
|
603
619
|
outerPrintKeys: never[];
|
604
620
|
defaultFormatId: string;
|
621
|
+
shortcut: {};
|
605
622
|
};
|
606
623
|
};
|
607
624
|
}>>, {
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,inject as t,ref as n,reactive as i,computed as r,onMounted as a,watch as l,openBlock as o,createElementBlock as s,Fragment as u,createElementVNode as c,createCommentVNode as d,createVNode as p,unref as m,withCtx as v,renderList as y,createBlock as f,normalizeClass as g,createTextVNode as k,toDisplayString as h,isRef as b,renderSlot as P,withModifiers as w,mergeProps as S}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as M,NPopover as F,NCheckbox as j,NDivider as E}from"naive-ui";import{PrintOutline as x,SettingsOutline as N,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}from"../constants/index.js";import{Print as z}from"../utils/print.js";import{isIReport as A}from"../utils/browserPrint.js";import U from"./IdentityVerification.vue.js";import{format as V}from"date-fns";import"../api.js";const B={class:"newprint-button-outer"},K=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},q={class:"print-lite"},G={class:"label bold"},H={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},ee={class:"label bold"},te={class:"print-li"},ne={class:"print-lite"},ie=["onClick"],re={class:"newprint-button-poperOver"},ae=["onMouseenter"],le={class:"print-lite"},oe=["onClick"];var se=e({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:""})}},setup(e,{expose:se}){const ue=e,ce=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],de=C();let pe;const me=t(J),ve=n(""),ye=i({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],ireportExecuteMode:1});let fe=n([]),ge=n([{label:ue.previewText,key:"previewText"},{label:ue.pdfLoadText,key:"downloadPdf"},{label:ue.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const ke=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),he=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),be=n([]),Pe=n([]),we=r((()=>{if(!ye.currentFormatId)return{};let e=ye.currentFormatId;return ye.formatList.find((t=>t.id===e))}));r((()=>{var e;return(null==(e=we.value)?void 0:e.name)||"格式选择"}));const Se=r((()=>{let e=ye.formatList.find((e=>e.id===ye.currentFormatId));return null==e?void 0:e.templateId})),Oe=r((()=>{let e=ye.formatList.find((e=>e.id===ye.currentFormatId));return null==e?void 0:e.number})),Ce=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowPrintAll})),Ie=r((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.isShowOutSetting})),Te=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.customProps)||{}})),Le=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.defaultFormatId)||""})),Me=r((()=>{var e;return(null==(e=ue.newPrintSetting)?void 0:e.printAllType)||1})),Fe=r((()=>{const e=ce.map((e=>e.key));return fe.value.filter((t=>!e.includes(t.key)))})),je=r({get:()=>Fe.value.every((e=>e.selected)),set(e){Fe.value.forEach((t=>{t.selected=e}))}}),Ee=async()=>{var e,t;(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await rt(),he.oneShow=!0},xe=async e=>{if(ue.directPrint){if(ye.spinning)return;return"button"===e?void(Ce.value?await ot():Le.value?async function(e){await rt(!1);const t=be.value.find((t=>t.key==e));t&&Ge(t.templateCode,t.templateId,t.key,!1)}(Le.value):Ee()):Ee()}return Ee()},Ne=(e,t)=>{ke[e]=t},_e=()=>{be.value=fe.value.filter((e=>!e.selected)),Pe.value=Fe.value.filter((e=>e.selected)),Je("oneShow"),Je("isOutSetting"),me("saveOuterPrint",Pe.value)},De=e=>{he[e]=!0},Je=e=>{ke.oneClickType="",he[e]=!1,"isOutSetting"==e&&(he.isOutSetting=!1)},ze=(e,t)=>{Re(!1);let n={type:t,formatId:ye.currentFormatId,templateId:(null==e?void 0:e.templateId)||Se.value,templateCode:(null==e?void 0:e.templateCode)||Oe.value};me("success",e,n)},Ae=e=>{Re(!1),me("error",e),O(e)&&"notInstalledApp"===e.type&&de.error(e.message)},Ue=e=>{Re(!1),me("cancel",e)},Ve=e=>{me("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Be=()=>JSON.stringify({...ue.token?{token:ue.token}:{}}),Ke=(e=[],t)=>{var n,i;let r={},a={};if((null==(n=ye.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(i=Object.keys(e[0].datasetData||{}))?void 0:i[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return r=Object.assign({},JSON.parse(Be()),Te.value,a),JSON.stringify(r)},Re=(e,t)=>{if(ye.isClickOuterPrint){if(e&&t){const n=Pe.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Pe.value.forEach((e=>{e.isLoading=!1}))}else ye.spinning=e},qe=()=>ye.isClickOuterPrint?Pe.value.some((e=>e.isLoading)):ye.spinning,Ge=(e,t,n,i)=>{const r=ye.printParams[e];if(!r)return;ye.isClickOuterPrint=i,ye.currentFormatId=n;const a=ye.originParams[e]||[];He(r,e,t,n,a)},He=async(e=[],t,n,i,r=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&ze(e,"print")}catch(e){console.log("error",e)}};ue.showLoading&&qe()&&!a||(Re(!0,i),ue.prevFn("print").then((()=>{ye.curPrintParamList=e;const a={formatId:i,ireportExecuteMode:ye.ireportExecuteMode,templateId:n,authorizationKey:ve.value,printdlgshow:ue.printdlgshow,signature:ue.signature,copies:ue.printCopies};if("MULTI"===ue.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[t]));pe.printDirect({...a,params:n},o,Ae,Ue)}else pe.printDirect({...a,params:Ke(e,t)},(e=>{e.params=r,e.templateCode=t,e.templateId=n,ze(e,"print")}),Ae,Ue)})).catch((()=>{Ve("print"),Re(!1)})).finally((()=>{ye.visible=!1})))},Ye=async(e,{templateCode:t,templateId:n,key:i},r)=>{const a=ye.printParams[t];if(a)switch(ye.isClickOuterPrint=r,ye.currentFormatId=i,e){case"previewText":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("preview").then((()=>{ye.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Ke(e,t),l={formatId:i,templateId:n,ireportExecuteMode:ye.ireportExecuteMode,authorizationKey:ve.value,params:a,btnprint:ue.btnprint,signature:ue.signature};pe.preview(l,(e=>{ze(e,"preview")}),Ae)})).catch((()=>{Ve("preview"),Re(!1)})).finally((()=>{ye.visible=!1})))})(a,t,n,i);break;case"formatEditText":((e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("edit").then((()=>{ye.curPrintParamList=e,ye.currentFormatId=i,ye.identityVerification.visible=!0})).catch((()=>{Ve("edit")})).finally((()=>{Re(!1)})))})(a,0,0,i);break;case"downloadPdf":(async(e=[],t,n,i)=>{ue.showLoading&&qe()||(Re(!0,i),ue.prevFn("download").then((()=>{ye.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,e[0])),a="MULTI"===ue.strategy?r:Ke(e,t),l={formatId:i,templateId:n,ireportExecuteMode:ye.ireportExecuteMode,authorizationKey:ve.value,print:{print:"1",type:"1"},params:a,signature:ue.signature};pe.downloadPDF(l,(e=>ze(e,"preview")),Ae)})).catch((()=>{Ve("download"),Re(!1)})).finally((()=>{ye.visible=!1})))})(a,t,n,i);break;case"resetPrinter":(async(e=[],t,n,i)=>{if(!ue.showLoading||!qe()){Re(!0,i);try{const e=await pe.resetPrinter(i);if(Re(!1),"success"==(null==e?void 0:e.result))return void de.success(e.message||"重置打印机成功");de.warning("重置打印机失败")}catch(e){Re(!1),de.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,i)}},$e=()=>{},Qe=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},et(n,t,e))})),n},We=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},tt(n,t,e))})),n},Xe=(e,t,n)=>{const i={};return t.forEach((t=>{let r=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(i=V(t,n[e.type])),(null==e?void 0:e.defaultValue)||i})(t,e[t[n]]);e[t[n]]&&r&&(i[t[n]]=r)})),i},Ze=({customizeDataset:e=[],param:t=[]},n={})=>{let i={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[e.name]=JSON.stringify(Xe(n,t,"fieldName"))})),i=Object.assign({},i,Xe(n,t,"key")),i},et=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i],a=n[r];if(!a)return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(Ze(a,t))}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(Ze(l,t))}return e},tt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i];if(!n[r])return de.error("当前勾选的数据没有匹配的模板"),e;e[r]||(e[r]=[]),e[r].push(t)}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r];if(!n[a])return de.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},nt=async e=>{var t;ye.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],ye.ireportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].ireportExecuteMode||1,(()=>{var e,t,n;const i=ye.formatList.map((e=>({templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1})));fe.value.unshift(...i),Ie.value&&fe.value.push(...ce),(null==(t=null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(fe.value.forEach((e=>{var t;(null==(t=ue.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Pe.value=fe.value.filter((e=>e.selected))),be.value=fe.value.filter((e=>!e.selected)),ue.hideButtons.length>0&&(ge.value=ge.value.filter((e=>!ue.hideButtons.includes(e.key))));const r=sessionStorage.getItem("portal");if(r){const e=JSON.parse(r),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(t);i.includes("RY7.2.21.1.M2.G94181E")||(ge.value=ge.value.filter((e=>"downloadPdf"!=e.key))),i.includes("RY7.2.21.1.M2.G33633A")||(ge.value=ge.value.filter((e=>"formatEditText"!=e.key)))}})(),ye.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),ye.printParams=Qe(ye.templateParams,ue.params),ye.originParams=We(ye.templateParams,ue.params)},it=async()=>{var e;if(ye.isInited)return!0;ye.isInited=!0,ye.spinning=!0,(()=>{if(pe)return!1;pe=new z})();const t=await ue.queryPrintFormatByNumber();return await nt(t),(null==(e=t.obj)?void 0:e.length)>0&&(ve.value=t.obj[0].authorizationKey||""),ye.spinning=!1,!0},rt=async(e=!0)=>{if(await ue.clickPrevFn()){if(!ye.visible){if(!await it())return!1}e&&(ye.visible=!ye.visible)}},at=e=>{if(ye.identityVerification.visible=!1,A(ye.currentFormatId))return ze(null,"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Be()),Te.value,ye.curPrintParamList[0])),n="MULTI"===ue.strategy?t:Ke(ye.curPrintParamList,Oe.value),i={formatId:ye.currentFormatId,templateId:Se.value,params:n,token:e};pe.editPrintFormat(i,(e=>{ze(e,"edit")}),Ae)},lt=(e,t)=>{const n=Pe.value[t+1];return t<Pe.value.length-1&&!ye.printParams[e.templateCode]&&ye.printParams[n.templateCode]};async function ot(){await rt(!1),(()=>{const e=Object.keys(ye.printParams);ye.isClickOuterPrint=!1;const t=ye.originParams;if(1==Me.value)for(let n=0;n<e.length;n++){const i=e[n],r=ye.printParams[i],a=t[i]||[],l=ye.formatList.filter((e=>e.number==i));l&&l.length>0&&l.forEach((e=>{ye.currentFormatId=e.id,He(r,e.number,e.templateId,e.id,a,!0)}))}2==Me.value&&Pe.value.forEach((e=>{const n=ye.printParams[e.templateCode],i=t[e.templateCode]||[];ye.currentFormatId=e.key,He(n,e.templateCode,e.templateId,e.key,i,!0)}))})()}return a((()=>{ye.isInited=!1})),l((()=>ue.params),(e=>{Object.keys(ye.templateParams).length>0&&(ye.printParams=Qe(ye.templateParams,ue.params),ye.originParams=We(ye.templateParams,ue.params))}),{deep:!0}),l((()=>{var e;return null==(e=ue.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await rt(!1)}),{deep:!0,immediate:!0}),se({directPrint:ot}),(t,n)=>(o(),s(u,null,[c("div",B,[d(" 外显按钮集合 "),p(m(I),{class:"outButtonGroup"},{default:v((()=>[(o(!0),s(u,null,y(Pe.value,((t,n)=>{return o(),f(m(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:$e,options:(i=m(ge),r=t,ye.printParams[r.templateCode]?i:[]),onSelect:e=>Ye(e,t,!0)},{default:v((()=>[p(m(L),{disabled:!ye.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>Ge(t.templateCode,t.templateId,t.key,!0),class:g(n==Pe.value.length-1?"outerLastButton":lt(t,n)?"isPrintDisabled":"")},{icon:v((()=>[p(m(M),{component:m(x),size:"18"},null,8,["component"])])),default:v((()=>[k(" "+h(t.label),1)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var i,r})),128))])),_:1}),d(" 外显设置按钮 "),Pe.value.length>0&&Pe.value.length==m(Fe).length&&m(Ie)&&2!=m(Me)?(o(),f(m(F),{key:0,trigger:"click","show-arrow":!1,show:he.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Je("isOutSetting"))},{trigger:v((()=>[p(m(L),{class:g(Pe.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>De("isOutSetting"))},{default:v((()=>[K,p(m(M),{style:{"margin-left":"8px"},component:m(N),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:v((()=>[c("div",R,[(o(!0),s(u,null,y(m(Fe),(e=>(o(),s("div",{class:"print-li",key:e.key},[c("div",q,[c("span",G,h(e.label),1),p(m(j),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:v((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",H,[p(m(E)),c("div",Y,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:v((()=>[k("保存")])),_:1}),m(Fe)&&m(Fe).length>1?(o(),f(m(j),{key:0,checked:m(je),"onUpdate:checked":n[1]||(n[1]=e=>b(je)?je.value=e:null)},{default:v((()=>[k("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:1},8,["show"])):(o(),s(u,{key:1},[d(" 打印全部按钮 "),p(m(F),{trigger:"click","show-arrow":!1,show:he.oneShow,onClickoutside:n[10]||(n[10]=e=>Je("oneShow"))},{trigger:v((()=>[P(t.$slots,"button",{handleClickPrintBtn:rt,printSpinning:ye.spinning,printbtnText:e.btnText,printVisible:ye.visible},(()=>[p(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=w((()=>xe("icon")),["stop"]))},{default:v((()=>[p(m(L),{loading:e.showLoading&&ye.spinning,onClick:n[3]||(n[3]=w((()=>xe("button")),["stop"])),class:g(Pe.value.length>0?"printAllLeftCls":"")},{icon:v((()=>[p(m(M),{component:m(x),size:"18"},null,8,["component"])])),default:v((()=>[k(" "+h(m(Ce)?"打印全部":e.btnText),1)])),_:1},8,["loading","class"]),p(m(L),{class:"icon-select"},{icon:v((()=>[p(m(M),{component:m(_),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:v((()=>[c("div",$,[(o(!0),s(u,null,y(be.value,(e=>(o(),s("div",{class:g(["print-li",ke.oneMouseType==e.key||ke.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ne("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ne("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!ye.printParams[n.templateCode])return[];Ne(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(o(),f(m(E),{key:0})):"outSetting"==e.key?(o(),s(u,{key:1},[d(" 第二层外显设置 "),p(m(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:he.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Je("isOutSetting"))},{trigger:v((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>De("isOutSetting"))},[c("span",W,h(e.label),1),p(m(M),{color:Pe.value.length>0?"#2563F4":"",component:m(N),size:"18"},null,8,["color","component"])])])),default:v((()=>[c("div",X,[(o(!0),s(u,null,y(m(Fe),(e=>(o(),s("div",{class:"print-li",key:e.key},[c("div",Z,[c("span",ee,h(e.label),1),p(m(j),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:v((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",te,[p(m(E)),c("div",ne,[p(m(L),{type:"primary",size:"small",onClick:_e},{default:v((()=>[k("保存")])),_:1}),m(Fe)&&m(Fe).length>1?(o(),f(m(j),{key:0,checked:m(je),"onUpdate:checked":n[6]||(n[6]=e=>b(je)?je.value=e:null)},{default:v((()=>[k("全选")])),_:1},8,["checked"])):d("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(o(),s(u,{key:2},[d(" 第二层功能操作 "),c("div",{class:g(["print-lite",ye.printParams[e.templateCode]?"":"isDisabled"])},[c("span",{class:"label bold",onClick:t=>Ge(e.templateCode,e.templateId,e.key,!1)},h(e.label),9,ie),ye.printParams[e.templateCode]?(o(),f(m(F),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:he[e.key],onClickoutside:t=>Je(e.key)},{trigger:v((()=>[p(m(M),{component:m(D),size:"18",onClick:t=>De(e.key)},null,8,["component","onClick"])])),default:v((()=>[c("div",re,[(o(!0),s(u,null,y(m(ge),(t=>(o(),s("div",{class:g(["print-li",ke.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ne("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ne("twoMouseType",""))},[c("div",le,[c("span",{class:"label",onClick:n=>Ye(t.key,e,!1)},h(t.label),9,oe)])],42,ae)))),128))])])),_:2},1032,["show","onClickoutside"])):d("v-if",!0)],2)],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),p(U,S(t.$attrs,{modelValue:ye.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>ye.identityVerification.visible=e),formatId:ye.currentFormatId,templateId:m(Se),onSuccess:at}),null,16,["modelValue","formatId","templateId"])],64))}});export{se as default};
|
1
|
+
import{defineComponent as e,inject as t,ref as n,reactive as r,computed as i,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as y,renderList as f,createBlock as g,normalizeClass as h,createTextVNode as k,toDisplayString as b,isRef as P,renderSlot as w,withModifiers as S,mergeProps as O}from"vue";import{isObject as C}from"@vue/shared";import{useMessage as I,NButtonGroup as L,NDropdown as T,NButton as j,NIcon as M,NPopover as F,NCheckbox as E,NDivider as x}from"naive-ui";import{PrintOutline as N,SettingsOutline as _,ChevronDownSharp as D,ArrowForwardOutline as J}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as z}from"../constants/index.js";import{Print as A}from"../utils/print.js";import{isIReport as U}from"../utils/browserPrint.js";import V from"./IdentityVerification.vue.js";import{format as B}from"date-fns";import"../api.js";import"../../../shortcut-provider/index.js";import{useShortcuts as K}from"../../../shortcut-provider/src/hooks/useShortcuts.js";const R={class:"newprint-button-outer"},G={key:0,class:"newprint-button-outer__shortcut"},q=d("span",{class:"label bold"},"外显设置",-1),Y={class:"newprint-button-poperOver"},H={class:"print-lite"},$={class:"label bold"},Q={class:"print-li"},W={class:"print-lite"},X={key:0,class:"newprint-button-outer__shortcut"},Z={class:"newprint-button-poperOver"},ee=["onMouseenter","onClick"],te={class:"label bold"},ne={class:"newprint-button-poperOver"},re={class:"print-lite"},ie={class:"label bold"},ae={class:"print-li"},le={class:"print-lite"},oe=["onClick"],se={key:0,class:"newprint-button-outer__shortcut"},ue={class:"newprint-button-poperOver"},ce=["onMouseenter"],de={class:"print-lite"},pe=["onClick"];var me=e({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},resolution:{type:Number},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:"",shortcut:{}})}},setup(e,{expose:me}){const ve=e,ye=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],fe=I();let ge;const he=t(z),ke=n(""),be=r({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],ireportExecuteMode:1}),Pe=n({});let we=n([]),Se=n([{label:ve.previewText,key:"previewText"},{label:ve.pdfLoadText,key:"downloadPdf"},{label:ve.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Oe=r({oneMouseType:"",oneClickType:"",twoMouseType:""}),Ce=r({oneShow:!1,isOperation:!1,isOutSetting:!1}),Ie=n([]),Le=n([]),Te=i((()=>{if(!be.currentFormatId)return{};let e=be.currentFormatId;return be.formatList.find((t=>t.id===e))}));i((()=>{var e;return(null==(e=Te.value)?void 0:e.name)||"格式选择"}));const je=i((()=>{let e=be.formatList.find((e=>e.id===be.currentFormatId));return null==e?void 0:e.templateId})),Me=i((()=>{let e=be.formatList.find((e=>e.id===be.currentFormatId));return null==e?void 0:e.number})),Fe=i((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.isShowPrintAll})),Ee=i((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.isShowOutSetting})),xe=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.customProps)||{}})),Ne=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.defaultFormatId)||""})),_e=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.printAllType)||1})),De=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.shortcut)||{}})),Je=i((()=>{var e,t;const n=Object.keys(De.value);if(n.length>0){if(Ne.value&&n.includes(Ne.value))return(null==(e=De.value[Ne.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=De.value.all)?void 0:t.shortcutLabel)||""}return""})),ze=i((()=>{const e=ye.map((e=>e.key));return we.value.filter((t=>!e.includes(t.key)))})),Ae=i({get:()=>ze.value.every((e=>e.selected)),set(e){ze.value.forEach((t=>{t.selected=e}))}}),Ue=async()=>{var e,t;(null==(t=null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await mt(),Ce.oneShow=!0},Ve=async e=>{if(ve.directPrint){if(be.spinning)return;return"button"===e?void(Fe.value?await ft():Ne.value?async function(e){await mt(!1);const t=Ie.value.find((t=>t.key==e));t&&et(t.templateCode,t.templateId,t.key,!1)}(Ne.value):Ue()):Ue()}return Ue()},Be=(e,t)=>{Oe[e]=t},Ke=()=>{Ie.value=we.value.filter((e=>!e.selected)),Le.value=ze.value.filter((e=>e.selected)),Ge("oneShow"),Ge("isOutSetting"),he("saveOuterPrint",Le.value)},Re=e=>{Ce[e]=!0},Ge=e=>{Oe.oneClickType="",Ce[e]=!1,"isOutSetting"==e&&(Ce.isOutSetting=!1)},qe=(e,t)=>{Xe(!1);let n={type:t,formatId:be.currentFormatId,templateId:(null==e?void 0:e.templateId)||je.value,templateCode:(null==e?void 0:e.templateCode)||Me.value};he("success",e,n)},Ye=e=>{Xe(!1),he("error",e),C(e)&&"notInstalledApp"===e.type&&fe.error(e.message)},He=e=>{Xe(!1),he("cancel",e)},$e=e=>{he("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Qe=()=>JSON.stringify({...ve.token?{token:ve.token}:{}}),We=(e=[],t)=>{var n,r;let i={},a={};if((null==(n=be.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(r=Object.keys(e[0].datasetData||{}))?void 0:r[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return i=Object.assign({},JSON.parse(Qe()),xe.value,a),JSON.stringify(i)},Xe=(e,t)=>{if(be.isClickOuterPrint){if(e&&t){const n=Le.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Le.value.forEach((e=>{e.isLoading=!1}))}else be.spinning=e},Ze=()=>be.isClickOuterPrint?Le.value.some((e=>e.isLoading)):be.spinning,et=(e,t,n,r)=>{const i=be.printParams[e];if(!i)return;be.isClickOuterPrint=r,be.currentFormatId=n;const a=be.originParams[e]||[];tt(i,e,t,n,a)},tt=async(e=[],t,n,r,i=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&qe(e,"print")}catch(e){console.log("error",e)}};ve.showLoading&&Ze()&&!a||(Xe(!0,r),ve.prevFn("print").then((()=>{be.curPrintParamList=e;const a={formatId:r,ireportExecuteMode:be.ireportExecuteMode,templateId:n,authorizationKey:ke.value,printdlgshow:ve.printdlgshow,signature:ve.signature,copies:ve.printCopies};if("MULTI"===ve.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[t]));ge.printDirect({...a,params:n},o,Ye,He)}else ge.printDirect({...a,params:We(e,t)},(e=>{e.params=i,e.templateCode=t,e.templateId=n,qe(e,"print")}),Ye,He)})).catch((()=>{$e("print"),Xe(!1)})).finally((()=>{be.visible=!1})))},nt=async(e,{templateCode:t,templateId:n,key:r},i)=>{const a=be.printParams[t];if(a)switch(be.isClickOuterPrint=i,be.currentFormatId=r,e){case"previewText":(async(e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("preview").then((()=>{be.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[0])),a="MULTI"===ve.strategy?i:We(e,t),l={formatId:r,templateId:n,ireportExecuteMode:be.ireportExecuteMode,authorizationKey:ke.value,params:a,btnprint:ve.btnprint,signature:ve.signature};ge.preview(l,(e=>{qe(e,"preview")}),Ye)})).catch((()=>{$e("preview"),Xe(!1)})).finally((()=>{be.visible=!1})))})(a,t,n,r);break;case"formatEditText":((e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("edit").then((()=>{be.curPrintParamList=e,be.currentFormatId=r,be.identityVerification.visible=!0})).catch((()=>{$e("edit")})).finally((()=>{Xe(!1)})))})(a,0,0,r);break;case"downloadPdf":(async(e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("download").then((()=>{be.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[0])),a="MULTI"===ve.strategy?i:We(e,t),l={formatId:r,templateId:n,ireportExecuteMode:be.ireportExecuteMode,authorizationKey:ke.value,print:{print:"1",type:"1",resolution:null==ve?void 0:ve.resolution},params:a,signature:ve.signature};ge.downloadPDF(l,(e=>qe(e,"preview")),Ye)})).catch((()=>{$e("download"),Xe(!1)})).finally((()=>{be.visible=!1})))})(a,t,n,r);break;case"resetPrinter":(async(e=[],t,n,r)=>{if(!ve.showLoading||!Ze()){Xe(!0,r);try{const e=await ge.resetPrinter(r);if(Xe(!1),"success"==(null==e?void 0:e.result))return void fe.success(e.message||"重置打印机成功");fe.warning("重置打印机失败")}catch(e){Xe(!1),fe.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,r)}},rt=()=>{},it=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},st(n,t,e))})),n},at=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ut(n,t,e))})),n},lt=(e,t,n)=>{const r={};return t.forEach((t=>{let i=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(r=B(t,n[e.type])),(null==e?void 0:e.defaultValue)||r})(t,e[t[n]]);e[t[n]]&&i&&(r[t[n]]=i)})),r},ot=({customizeDataset:e=[],param:t=[]},n={})=>{let r={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;r.datasetData||(r.datasetData={}),r.datasetData[e.name]=JSON.stringify(lt(n,t,"fieldName"))})),r=Object.assign({},r,lt(n,t,"key")),r},st=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r],a=n[i];if(!a)return fe.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(ot(a,t))}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i],l=n[a];if(!l)return fe.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(ot(l,t))}return e},ut=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r];if(!n[i])return fe.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(t)}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i];if(!n[a])return fe.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},ct=async e=>{var t;be.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],be.ireportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].ireportExecuteMode||1,(()=>{var e,t,n;const r=Object.keys(De.value),i=be.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(r.includes(e.id)){const n=De.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));we.value.unshift(...i),Ee.value&&we.value.push(...ye),(null==(t=null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(we.value.forEach((e=>{var t;(null==(t=ve.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Le.value=we.value.filter((e=>e.selected))),Ie.value=we.value.filter((e=>!e.selected)),ve.hideButtons.length>0&&(Se.value=Se.value.filter((e=>!ve.hideButtons.includes(e.key))));const a=sessionStorage.getItem("portal");if(a){const e=JSON.parse(a),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},r=Object.keys(t);r.includes("RY7.2.21.1.M2.G94181E")||(Se.value=Se.value.filter((e=>"downloadPdf"!=e.key))),r.includes("RY7.2.21.1.M2.G33633A")||(Se.value=Se.value.filter((e=>"formatEditText"!=e.key))),r.includes("RY7.2.21.1.M2.G99314S")||(Se.value=Se.value.filter((e=>"resetPrinter"!=e.key)))}})(),be.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),be.printParams=it(be.templateParams,ve.params),be.originParams=at(be.templateParams,ve.params),pt()},dt=async()=>{var e;if(be.isInited)return!0;be.isInited=!0,be.spinning=!0,(()=>{if(ge)return!1;ge=new A})();const t=await ve.queryPrintFormatByNumber();return await ct(t),(null==(e=t.obj)?void 0:e.length)>0&&(ke.value=t.obj[0].authorizationKey||""),be.spinning=!1,!0},pt=async()=>{const e=Object.keys(De.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],r=De.value[n],{stop:i,signature:a}=K().register({label:r.code,shortcutSignature:r.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ve("button");const e=ze.value.map((e=>e.key)),t=be.originParams;if(e.includes(n)){const e=ze.value.find((e=>e.key==n));if(e){const n=be.printParams[null==e?void 0:e.templateCode],r=t[null==e?void 0:e.templateCode]||[];tt(n,e.templateCode,e.templateId,e.key,r)}}}});Pe.value[n]=i}},mt=async(e=!0)=>{if(await ve.clickPrevFn()){if(!be.visible){if(!await dt())return!1}e&&(be.visible=!be.visible)}},vt=e=>{if(be.identityVerification.visible=!1,U(be.currentFormatId))return qe(null,"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,be.curPrintParamList[0])),n="MULTI"===ve.strategy?t:We(be.curPrintParamList,Me.value),r={formatId:be.currentFormatId,templateId:je.value,params:n,token:e};ge.editPrintFormat(r,(e=>{qe(e,"edit")}),Ye)},yt=(e,t)=>{const n=Le.value[t+1];return t<Le.value.length-1&&!be.printParams[e.templateCode]&&be.printParams[n.templateCode]};async function ft(){await mt(!1),(()=>{const e=Object.keys(be.printParams);be.isClickOuterPrint=!1;const t=be.originParams;if(1==_e.value)for(let n=0;n<e.length;n++){const r=e[n],i=be.printParams[r],a=t[r]||[],l=be.formatList.filter((e=>e.number==r));l&&l.length>0&&l.forEach((e=>{be.currentFormatId=e.id,tt(i,e.number,e.templateId,e.id,a,!0)}))}2==_e.value&&Le.value.forEach((e=>{const n=be.printParams[e.templateCode],r=t[e.templateCode]||[];be.currentFormatId=e.key,tt(n,e.templateCode,e.templateId,e.key,r,!0)}))})()}return a((()=>{be.isInited=!1,mt()})),l((()=>{const e=Object.keys(Pe.value);e.length>0&&e.forEach((e=>{Pe.value[e]&&Pe.value[e]()}))})),o((()=>ve.params),(e=>{Object.keys(be.templateParams).length>0&&(be.printParams=it(be.templateParams,ve.params),be.originParams=at(be.templateParams,ve.params))}),{deep:!0}),o((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await mt(!1)}),{deep:!0,immediate:!0}),me({directPrint:ft}),(t,n)=>(s(),u(c,null,[d("div",R,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:y((()=>[(s(!0),u(c,null,f(Le.value,((t,n)=>{return s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:rt,options:(r=v(Se),i=t,be.printParams[i.templateCode]?r:[]),onSelect:e=>nt(e,t,!0)},{default:y((()=>[m(v(j),{disabled:!be.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>et(t.templateCode,t.templateId,t.key,!0),class:h(n==Le.value.length-1?"outerLastButton":yt(t,n)?"isPrintDisabled":"")},{icon:y((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:y((()=>[k(" "+b(t.label)+" ",1),t.shortcutLabel?(s(),u("span",G,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var r,i})),128))])),_:1}),p(" 外显设置按钮 "),Le.value.length>0&&Le.value.length==v(ze).length&&v(Ee)&&2!=v(_e)?(s(),g(v(F),{key:0,trigger:"click","show-arrow":!1,show:Ce.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Ge("isOutSetting"))},{trigger:y((()=>[m(v(j),{class:h(Le.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>Re("isOutSetting"))},{default:y((()=>[q,m(v(M),{style:{"margin-left":"8px"},component:v(_),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:y((()=>[d("div",Y,[(s(!0),u(c,null,f(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",H,[d("span",$,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",Q,[m(v(x)),d("div",W,[m(v(j),{type:"primary",size:"small",onClick:Ke},{default:y((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ae),"onUpdate:checked":n[1]||(n[1]=e=>P(Ae)?Ae.value=e:null)},{default:y((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:1},8,["show"])):(s(),u(c,{key:1},[p(" 打印全部按钮 "),m(v(F),{trigger:"click","show-arrow":!1,show:Ce.oneShow,onClickoutside:n[10]||(n[10]=e=>Ge("oneShow"))},{trigger:y((()=>[w(t.$slots,"button",{handleClickPrintBtn:mt,printSpinning:be.spinning,printbtnText:e.btnText,printVisible:be.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ve("icon")),["stop"]))},{default:y((()=>[m(v(j),{loading:e.showLoading&&be.spinning,onClick:n[3]||(n[3]=S((()=>Ve("button")),["stop"])),class:h(Le.value.length>0?"printAllLeftCls":"")},{icon:y((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:y((()=>[k(" "+b(v(Fe)?"打印全部":e.btnText)+" ",1),v(Je)?(s(),u("span",X,b(v(Je)),1)):p("v-if",!0)])),_:1},8,["loading","class"]),m(v(j),{class:"icon-select"},{icon:y((()=>[m(v(M),{component:v(D),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:y((()=>[d("div",Z,[(s(!0),u(c,null,f(Ie.value,(e=>(s(),u("div",{class:h(["print-li",Oe.oneMouseType==e.key||Oe.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Be("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Be("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!be.printParams[n.templateCode])return[];Be(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),g(v(x),{key:0})):"outSetting"==e.key?(s(),u(c,{key:1},[p(" 第二层外显设置 "),m(v(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:Ce.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Ge("isOutSetting"))},{trigger:y((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>Re("isOutSetting"))},[d("span",te,b(e.label),1),m(v(M),{color:Le.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:y((()=>[d("div",ne,[(s(!0),u(c,null,f(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",re,[d("span",ie,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:y((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",ae,[m(v(x)),d("div",le,[m(v(j),{type:"primary",size:"small",onClick:Ke},{default:y((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ae),"onUpdate:checked":n[6]||(n[6]=e=>P(Ae)?Ae.value=e:null)},{default:y((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(s(),u(c,{key:2},[p(" 第二层功能操作 "),d("div",{class:h(["print-lite",be.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>et(e.templateCode,e.templateId,e.key,!1)},[k(b(e.label)+" ",1),e.shortcutLabel?(s(),u("span",se,b(e.shortcutLabel),1)):p("v-if",!0)],8,oe),be.printParams[e.templateCode]?(s(),g(v(F),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Ce[e.key],onClickoutside:t=>Ge(e.key)},{trigger:y((()=>[m(v(M),{component:v(J),size:"18",onClick:t=>Re(e.key)},null,8,["component","onClick"])])),default:y((()=>[d("div",ue,[(s(!0),u(c,null,f(v(Se),(t=>(s(),u("div",{class:h(["print-li",Oe.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Be("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Be("twoMouseType",""))},[d("div",de,[d("span",{class:"label",onClick:n=>nt(t.key,e,!1)},b(t.label),9,pe)])],42,ce)))),128))])])),_:2},1032,["show","onClickoutside"])):p("v-if",!0)],2)],2112))],42,ee)))),128))])])),_:3},8,["show"])],2112))]),m(V,O(t.$attrs,{modelValue:be.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>be.identityVerification.visible=e),formatId:be.currentFormatId,templateId:v(je),onSuccess:vt}),null,16,["modelValue","formatId","templateId"])],64))}});export{me as default};
|
@@ -98,6 +98,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
98
98
|
type: NumberConstructor;
|
99
99
|
default: number;
|
100
100
|
};
|
101
|
+
resolution: {
|
102
|
+
type: NumberConstructor;
|
103
|
+
};
|
101
104
|
printCustomProps: {
|
102
105
|
type: ObjectConstructor;
|
103
106
|
default: () => {};
|
@@ -209,6 +212,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
209
212
|
type: NumberConstructor;
|
210
213
|
default: number;
|
211
214
|
};
|
215
|
+
resolution: {
|
216
|
+
type: NumberConstructor;
|
217
|
+
};
|
212
218
|
printCustomProps: {
|
213
219
|
type: ObjectConstructor;
|
214
220
|
default: () => {};
|
@@ -549,6 +555,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
549
555
|
type: NumberConstructor;
|
550
556
|
default: number;
|
551
557
|
};
|
558
|
+
resolution: {
|
559
|
+
type: NumberConstructor;
|
560
|
+
};
|
552
561
|
printCustomProps: {
|
553
562
|
type: ObjectConstructor;
|
554
563
|
default: () => {};
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as t,useAttrs as e,inject as n,ref as i,reactive as r,computed as a,onMounted as o,watch as l,openBlock as s,createElementBlock as p,Fragment as d,createVNode as u,unref as m,withCtx as c,renderSlot as f,withModifiers as y,createTextVNode as v,toDisplayString as g,mergeProps as b}from"vue";import{isObject as h}from"@vue/shared";import{useMessage as I,NDropdown as P,NButton as w,NIcon as F}from"naive-ui";import{ChevronDown as k}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as x}from"../constants/index.js";import{Print as T}from"../utils/print.js";import{isIReport as S}from"../utils/browserPrint.js";import E from"./IdentityVerification.vue.js";import{format as j}from"date-fns";import{savePrivateFormatApi as M,getPrivateFormatApi as O}from"../api.js";var L=t({__name:"OldPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},noDefaultFormatMsg:{default:"获取打印格式失败,请联系管理员!",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},printCustomProps:{type:Object,default:()=>({})},placement:{type:String}},setup(t,{expose:L}){var D;const C=t,N=e(),V=I();let B;const R=n(x),z={},A=i(""),J=r({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,ireportExecuteMode:1});let U=i([{label:C.printText,key:"printText"},{label:C.previewText,key:"previewText"},{label:C.pdfLoadText,key:"downloadPdf"},{label:C.formatEditText,key:"formatEditText"},...(null==(D=C.externalOptionConfig)?void 0:D.options)||[]]);const q=a((()=>{if(!J.currentFormatId)return{};let t=J.currentFormatId;return J.formatList.find((e=>e.id===t))})),K=a((()=>{var t;return(null==(t=q.value)?void 0:t.name)||"格式选择"})),_=a((()=>{let t=J.formatList.find((t=>t.id===J.currentFormatId));return null==t?void 0:t.templateId})),G=async t=>{if(C.directPrint){if(J.spinning)return;return"button"===t?void await ut():st()}return st()},H=t=>u("span",{class:{active:t.key===J.currentFormatId}},[t.label]),Y=(t,e)=>{J.spinning=!1;let n={type:e,formatId:J.currentFormatId,templateId:_.value};R("success",t,n)},$=t=>{J.spinning=!1,R("error",t),h(t)&&"notInstalledApp"===t.type&&V.error(t.message)},Q=t=>{J.spinning=!1,R("cancel",t)},W=t=>{R("error",{message:"前置条件执行错误",type:t,preExecution:!0})},X=(t=0)=>{var e;const n=(null==(e=C.printParams)?void 0:e.length)?C.printParams[t]:J.printParams[t];return JSON.stringify({...n||{},...C.token?{token:C.token}:{},...C.printCustomProps||{}})},Z=()=>{var t,e;let n={},i={};if(null==(t=J.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(J.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(J.printParams.map((e=>JSON.parse(e.datasetData[t]))));i={datasetData:{}},i.datasetData[t]=n}else Object.keys(J.printParams[0]).forEach((t=>{i[t]=[],J.printParams.forEach((e=>{i[t].includes(e[t])||i[t].push(e[t])})),i[t]=i[t].join(",")}));return n=Object.assign({},JSON.parse(X(0)),i),JSON.stringify(n)},tt=((t,e,n=!0)=>{let i=null;return function(...r){i&&clearTimeout(i),n&&!i&&t.apply(null,r),i=setTimeout((()=>{i=null,!n&&t.apply(null,r)}),e)}})((()=>{let t=J.printParams.length;const e=async e=>{try{--t<=0&&Y(e,"print")}catch(t){console.log("error",t)}};C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("print").then((()=>{const t={ireportExecuteMode:J.ireportExecuteMode,formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,printdlgshow:C.printdlgshow,signature:C.signature,copies:C.printCopies};if("MULTI"===C.strategy)for(let n=0;n<J.printParams.length;n++)n>0&&(t.printdlgshow="0"),B.printDirect({...t,params:X(n)},e,$,Q);else B.printDirect({...t,params:Z()},(t=>{Y(t,"print")}),$,Q)})).catch((()=>{W("print"),J.spinning=!1})).finally((()=>{J.visible=!1})))}),800,!0),et=async(t,e)=>{var n,i;switch(t){case"printText":tt();break;case"previewText":(async()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("preview").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,ireportExecuteMode:J.ireportExecuteMode,templateId:_.value,authorizationKey:A.value,params:t,btnprint:C.btnprint,signature:C.signature};B.preview(e,(t=>{Y(t,"preview")}),$)})).catch((()=>{W("preview"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;case"formatEditText":C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("edit").then((()=>{J.identityVerification.visible=!0})).catch((()=>{W("edit")})).finally((()=>{J.visible=!1,J.spinning=!1})));break;case"downloadPdf":(async()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("download").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,ireportExecuteMode:J.ireportExecuteMode,templateId:_.value,authorizationKey:A.value,print:{print:"1",type:"1"},params:t,signature:C.signature};B.downloadPDF(e,(t=>Y(t,"preview")),$)})).catch((()=>{W("download"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;default:{J.visible=!1;const r=J.formatList.find((e=>e.id===t))||{};if(Object.keys(r).length>0){J.currentFormatId=t;const[e]=U.value;e.label=(null==r?void 0:r.name)||e.label,await M({formatForms:[{...r}],name:z.name||r.templateName,number:z.number||r.number,templateId:z.templateId||r.templateId,...z.id?{id:z.id}:{}},{token:C.token})}else null==(i=null==(n=C.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},nt=()=>{J.visible=!1,R("clickoutside")},it=()=>(J.isInited=!1,J.spinning=!1,setTimeout((()=>{J.visible=!1}),0),!1),rt=(t,e,n)=>{const i={};return e.forEach((e=>{let r=((t,e)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=e;return Object.keys(n).includes(t.type)&&e&&e instanceof Date&&(i=j(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},at=({customizeDataset:t=[],param:e=[]},n=[])=>n.map((n=>{let i={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;i.datasetData={[t.name]:JSON.stringify(rt(n,e,"fieldName"))}})),i=Object.assign({},i,rt(n,e,"key")),i})),ot=async t=>{var e,n;if(J.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],J.ireportExecuteMode=(null==(e=null==t?void 0:t.obj)?void 0:e.length)>0&&t.obj[0].ireportExecuteMode||1,J.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";if(!N.isDoc){const{data:e}=await O({templateId:t[0].templateId},{token:C.token});if("SUCCESS"===e.result){const{formatForms:i=[]}=e.map||{};Object.assign(z,e.map||{});const r=null==(n=null==i?void 0:i[0])?void 0:n.id;if(r&&t.map((t=>t.id)).includes(r))return r}}const i=t.find((t=>1==t[e]));return(null==i?void 0:i.id)||t[0].id})(J.formatList,"defaultFlag"),!J.currentFormatId)return U.value=[],V.error(C.noDefaultFormatMsg),it();(()=>{var t;const e=J.formatList.map((t=>({label:t.name,key:t.id})));U.value.unshift({label:K.value,key:"format",children:e}),C.hideButtons.length>0&&(U.value=U.value.filter((t=>!C.hideButtons.includes(t.key))));const n=sessionStorage.getItem("portal");if(n){const e=JSON.parse(n),i=(null==(t=null==e?void 0:e.user)?void 0:t.currentRoleResourceObj)||{},r=Object.keys(i);r.includes("RY7.2.21.1.M2.G94181E")||(U.value=U.value.filter((t=>"downloadPdf"!=t.key))),r.includes("RY7.2.21.1.M2.G33633A")||(U.value=U.value.filter((t=>"formatEditText"!=t.key)))}})();let i=null==(n=await C.queryTemplateParams())?void 0:n.obj;if(!i||!_.value)return V.error("获取打印模板失败,请联系管理员!"),it();J.templateParams=i,J.printParams=at(J.templateParams,C.params)},lt=async()=>{var t;if(J.isInited)return!0;J.isInited=!0,J.spinning=!0,(()=>{if(B)return!1;B=new T})();const e=await C.queryPrintFormatByNumber();return await ot(e),(null==(t=e.obj)?void 0:t.length)>0&&(A.value=e.obj[0].authorizationKey||""),J.spinning=!1,!0},st=async(t=!0)=>{var e,n;if(await C.clickPrevFn())if((null==(e=C.params)?void 0:e.length)||(null==(n=C.printParams)?void 0:n.length)){if(!J.visible){if(!await lt())return!1}t&&(J.visible=!J.visible)}else V.warning(C.noDataMsg)},pt=()=>{J.watchPrintParamsReformatFn&&J.watchPrintParamsReformatFn(),J.isInited?J.printParams=at(J.templateParams,C.params):J.watchPrintParamsReformatFn=()=>l((()=>J.isInited),(t=>{if(!t)return!1;pt()}))},dt=t=>{if(J.identityVerification.visible=!1,S(J.currentFormatId))return Y(null,"edit");const e={formatId:J.currentFormatId,templateId:_.value,params:X(),token:t};B.editPrintFormat(e,(t=>{Y(t,"edit")}),$)};async function ut(){await st(!1),tt()}return o((()=>{J.isInited=!1})),l((()=>C.params),(t=>{if(!(null==t?void 0:t.length))return!1;pt()}),{deep:!0}),L({directPrint:ut}),(e,n)=>(s(),p(d,null,[u(m(P),{class:"c-dropdown",placement:t.placement,trigger:"click",show:J.visible,onClickoutside:nt,options:m(U),onSelect:et,"render-label":H},{default:c((()=>[f(e.$slots,"button",{handleClickPrintBtn:st,printSpinning:J.spinning,printbtnText:t.btnText,printVisible:J.visible},(()=>[u(m(w),{class:"dropdown-button",loading:t.showLoading&&J.spinning,onClick:n[1]||(n[1]=y((()=>G("button")),["stop"]))},{default:c((()=>[v(g(t.btnText)+" ",1),u(m(F),{component:m(k),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=y((()=>G("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["placement","show","options"]),u(E,b(m(N),{modelValue:J.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>J.identityVerification.visible=t),formatId:J.currentFormatId,templateId:m(_),onSuccess:dt}),null,16,["modelValue","formatId","templateId"])],64))}});export{L as default};
|
1
|
+
import{defineComponent as t,useAttrs as e,inject as n,ref as i,reactive as r,computed as a,onMounted as o,watch as l,openBlock as s,createElementBlock as p,Fragment as u,createVNode as d,unref as m,withCtx as c,renderSlot as f,withModifiers as y,createTextVNode as v,toDisplayString as g,mergeProps as b}from"vue";import{isObject as h}from"@vue/shared";import{useMessage as I,NDropdown as P,NButton as w,NIcon as F}from"naive-ui";import{ChevronDown as k}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as x}from"../constants/index.js";import{Print as T}from"../utils/print.js";import{isIReport as S}from"../utils/browserPrint.js";import E from"./IdentityVerification.vue.js";import{format as j}from"date-fns";import{savePrivateFormatApi as M,getPrivateFormatApi as O}from"../api.js";var L=t({__name:"OldPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},noDefaultFormatMsg:{default:"获取打印格式失败,请联系管理员!",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},resolution:{type:Number},printCustomProps:{type:Object,default:()=>({})},placement:{type:String}},setup(t,{expose:L}){var D;const C=t,N=e(),V=I();let B;const R=n(x),z={},A=i(""),J=r({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,ireportExecuteMode:1});let U=i([{label:C.printText,key:"printText"},{label:C.previewText,key:"previewText"},{label:C.pdfLoadText,key:"downloadPdf"},{label:C.formatEditText,key:"formatEditText"},...(null==(D=C.externalOptionConfig)?void 0:D.options)||[]]);const q=a((()=>{if(!J.currentFormatId)return{};let t=J.currentFormatId;return J.formatList.find((e=>e.id===t))})),K=a((()=>{var t;return(null==(t=q.value)?void 0:t.name)||"格式选择"})),_=a((()=>{let t=J.formatList.find((t=>t.id===J.currentFormatId));return null==t?void 0:t.templateId})),G=async t=>{if(C.directPrint){if(J.spinning)return;return"button"===t?void await dt():st()}return st()},H=t=>d("span",{class:{active:t.key===J.currentFormatId}},[t.label]),Y=(t,e)=>{J.spinning=!1;let n={type:e,formatId:J.currentFormatId,templateId:_.value};R("success",t,n)},$=t=>{J.spinning=!1,R("error",t),h(t)&&"notInstalledApp"===t.type&&V.error(t.message)},Q=t=>{J.spinning=!1,R("cancel",t)},W=t=>{R("error",{message:"前置条件执行错误",type:t,preExecution:!0})},X=(t=0)=>{var e;const n=(null==(e=C.printParams)?void 0:e.length)?C.printParams[t]:J.printParams[t];return JSON.stringify({...n||{},...C.token?{token:C.token}:{},...C.printCustomProps||{}})},Z=()=>{var t,e;let n={},i={};if(null==(t=J.templateParams.customizeDataset)?void 0:t.length){const t=(null==(e=Object.keys(J.printParams[0].datasetData||{}))?void 0:e[0])||"",n=JSON.stringify(J.printParams.map((e=>JSON.parse(e.datasetData[t]))));i={datasetData:{}},i.datasetData[t]=n}else Object.keys(J.printParams[0]).forEach((t=>{i[t]=[],J.printParams.forEach((e=>{i[t].includes(e[t])||i[t].push(e[t])})),i[t]=i[t].join(",")}));return n=Object.assign({},JSON.parse(X(0)),i),JSON.stringify(n)},tt=((t,e,n=!0)=>{let i=null;return function(...r){i&&clearTimeout(i),n&&!i&&t.apply(null,r),i=setTimeout((()=>{i=null,!n&&t.apply(null,r)}),e)}})((()=>{let t=J.printParams.length;const e=async e=>{try{--t<=0&&Y(e,"print")}catch(t){console.log("error",t)}};C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("print").then((()=>{const t={ireportExecuteMode:J.ireportExecuteMode,formatId:J.currentFormatId,templateId:_.value,authorizationKey:A.value,printdlgshow:C.printdlgshow,signature:C.signature,copies:C.printCopies};if("MULTI"===C.strategy)for(let n=0;n<J.printParams.length;n++)n>0&&(t.printdlgshow="0"),B.printDirect({...t,params:X(n)},e,$,Q);else B.printDirect({...t,params:Z()},(t=>{Y(t,"print")}),$,Q)})).catch((()=>{W("print"),J.spinning=!1})).finally((()=>{J.visible=!1})))}),800,!0),et=async(t,e)=>{var n,i;switch(t){case"printText":tt();break;case"previewText":(async()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("preview").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,ireportExecuteMode:J.ireportExecuteMode,templateId:_.value,authorizationKey:A.value,params:t,btnprint:C.btnprint,signature:C.signature};B.preview(e,(t=>{Y(t,"preview")}),$)})).catch((()=>{W("preview"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;case"formatEditText":C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("edit").then((()=>{J.identityVerification.visible=!0})).catch((()=>{W("edit")})).finally((()=>{J.visible=!1,J.spinning=!1})));break;case"downloadPdf":(async()=>{C.showLoading&&J.spinning||(J.spinning=!0,C.prevFn("download").then((()=>{const t="MULTI"===C.strategy?X():Z(),e={formatId:J.currentFormatId,ireportExecuteMode:J.ireportExecuteMode,templateId:_.value,authorizationKey:A.value,print:{print:"1",type:"1",resolution:null==C?void 0:C.resolution},params:t,signature:C.signature};B.downloadPDF(e,(t=>Y(t,"preview")),$)})).catch((()=>{W("download"),J.spinning=!1})).finally((()=>{J.visible=!1})))})();break;default:{J.visible=!1;const r=J.formatList.find((e=>e.id===t))||{};if(Object.keys(r).length>0){J.currentFormatId=t;const[e]=U.value;e.label=(null==r?void 0:r.name)||e.label,await M({formatForms:[{...r}],name:z.name||r.templateName,number:z.number||r.number,templateId:z.templateId||r.templateId,...z.id?{id:z.id}:{}},{token:C.token})}else null==(i=null==(n=C.externalOptionConfig)?void 0:n.onSelect)||i.call(n,t,e);break}}},nt=()=>{J.visible=!1,R("clickoutside")},it=()=>(J.isInited=!1,J.spinning=!1,setTimeout((()=>{J.visible=!1}),0),!1),rt=(t,e,n)=>{const i={};return e.forEach((e=>{let r=((t,e)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=e;return Object.keys(n).includes(t.type)&&e&&e instanceof Date&&(i=j(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},at=({customizeDataset:t=[],param:e=[]},n=[])=>n.map((n=>{let i={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;i.datasetData={[t.name]:JSON.stringify(rt(n,e,"fieldName"))}})),i=Object.assign({},i,rt(n,e,"key")),i})),ot=async t=>{var e,n;if(J.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],J.ireportExecuteMode=(null==(e=null==t?void 0:t.obj)?void 0:e.length)>0&&t.obj[0].ireportExecuteMode||1,J.currentFormatId=await(async(t,e)=>{var n;if(!(null==t?void 0:t.length))return"";if(!N.isDoc){const{data:e}=await O({templateId:t[0].templateId},{token:C.token});if("SUCCESS"===e.result){const{formatForms:i=[]}=e.map||{};Object.assign(z,e.map||{});const r=null==(n=null==i?void 0:i[0])?void 0:n.id;if(r&&t.map((t=>t.id)).includes(r))return r}}const i=t.find((t=>1==t[e]));return(null==i?void 0:i.id)||t[0].id})(J.formatList,"defaultFlag"),!J.currentFormatId)return U.value=[],V.error(C.noDefaultFormatMsg),it();(()=>{var t;const e=J.formatList.map((t=>({label:t.name,key:t.id})));U.value.unshift({label:K.value,key:"format",children:e}),C.hideButtons.length>0&&(U.value=U.value.filter((t=>!C.hideButtons.includes(t.key))));const n=sessionStorage.getItem("portal");if(n){const e=JSON.parse(n),i=(null==(t=null==e?void 0:e.user)?void 0:t.currentRoleResourceObj)||{},r=Object.keys(i);r.includes("RY7.2.21.1.M2.G94181E")||(U.value=U.value.filter((t=>"downloadPdf"!=t.key))),r.includes("RY7.2.21.1.M2.G33633A")||(U.value=U.value.filter((t=>"formatEditText"!=t.key)))}})();let i=null==(n=await C.queryTemplateParams())?void 0:n.obj;if(!i||!_.value)return V.error("获取打印模板失败,请联系管理员!"),it();J.templateParams=i,J.printParams=at(J.templateParams,C.params)},lt=async()=>{var t;if(J.isInited)return!0;J.isInited=!0,J.spinning=!0,(()=>{if(B)return!1;B=new T})();const e=await C.queryPrintFormatByNumber();return await ot(e),(null==(t=e.obj)?void 0:t.length)>0&&(A.value=e.obj[0].authorizationKey||""),J.spinning=!1,!0},st=async(t=!0)=>{var e,n;if(await C.clickPrevFn())if((null==(e=C.params)?void 0:e.length)||(null==(n=C.printParams)?void 0:n.length)){if(!J.visible){if(!await lt())return!1}t&&(J.visible=!J.visible)}else V.warning(C.noDataMsg)},pt=()=>{J.watchPrintParamsReformatFn&&J.watchPrintParamsReformatFn(),J.isInited?J.printParams=at(J.templateParams,C.params):J.watchPrintParamsReformatFn=()=>l((()=>J.isInited),(t=>{if(!t)return!1;pt()}))},ut=t=>{if(J.identityVerification.visible=!1,S(J.currentFormatId))return Y(null,"edit");const e={formatId:J.currentFormatId,templateId:_.value,params:X(),token:t};B.editPrintFormat(e,(t=>{Y(t,"edit")}),$)};async function dt(){await st(!1),tt()}return o((()=>{J.isInited=!1})),l((()=>C.params),(t=>{if(!(null==t?void 0:t.length))return!1;pt()}),{deep:!0}),L({directPrint:dt}),(e,n)=>(s(),p(u,null,[d(m(P),{class:"c-dropdown",placement:t.placement,trigger:"click",show:J.visible,onClickoutside:nt,options:m(U),onSelect:et,"render-label":H},{default:c((()=>[f(e.$slots,"button",{handleClickPrintBtn:st,printSpinning:J.spinning,printbtnText:t.btnText,printVisible:J.visible},(()=>[d(m(w),{class:"dropdown-button",loading:t.showLoading&&J.spinning,onClick:n[1]||(n[1]=y((()=>G("button")),["stop"]))},{default:c((()=>[v(g(t.btnText)+" ",1),d(m(F),{component:m(k),size:"18",style:{"margin-left":"5px"},onClick:n[0]||(n[0]=y((()=>G("icon")),["stop"]))},null,8,["component"])])),_:1},8,["loading"])]))])),_:3},8,["placement","show","options"]),d(E,b(m(N),{modelValue:J.identityVerification.visible,"onUpdate:modelValue":n[2]||(n[2]=t=>J.identityVerification.visible=t),formatId:J.currentFormatId,templateId:m(_),onSuccess:ut}),null,16,["modelValue","formatId","templateId"])],64))}});export{L 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 m=String(navigator.platform).toLowerCase().includes("linux"),p=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,u=`${d}/fdp-api/print/assembly/printIReport`,f=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,g=`${d}/bi-api/reprot/print/open/client/previewIReport`,w=`${d}/bi-api/reprot/print/open/client/getRemote`,y=`${d}/printService/file`;let P=null;class v{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this;const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=h(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="",this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("hiprint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{p({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{p({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}}):p({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}}):p({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)}):p({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o=1,printdlgshow:l="0",nobillnode:h="1",btnprint:m="1",messageTimeout:p=0}){const d={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:m,copies:o,messageTimeout:p,...a?{signature:a}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=d,await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:r=0}){const n={};let a={};try{a=Object.assign({},n,JSON.parse(i))}catch(t){a=n}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:r};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await p({method:"get",url:w})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await p({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 p({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 p({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({ireportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:l,signature:c,btnprint:h,messageTimeout:p=0},d,u){const f=a(i);if(i=this.getIReportFormatId(f,i),f&&m||2==t){const t=await this._queryPrintForPdf(e,i,s,l);if(!t)return null==u?void 0:u("获取文件失败!");const r=n(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,r),null==d?void 0:d({file:t})}await this._queryProxyOrigin();const g=await this._testConnection();if(!this._handleResultTest(g,u))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),n=this._handleResult(t,u);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==u||u(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({ireportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p=1,isDownloadFile:d=!0,messageTimeout:u=0},f,g,w,y="printDirect"){const P=a(i);if(i=this.getIReportFormatId(P,i),P&&m||2==t){if(!await this._testDomesticSystemConnection())return void g({type:"notOpenedApp",result:"error",message:"请开启hiPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},f,g):g({type:"connectAppFail",result:"error",message:"连接hiPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},f,g))}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,g))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,messageTimeout:u}),n=this._handleResult(t,g,w);if(!n)return!1;d&&["downloadPDF"].includes(y)&&await this._browserPrint(n,y),null==f||f(n)}catch(t){const e="printDirect"===y?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==g||g(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:s},r,n){const a=await this._queryPrintForBase64(t,e,i,s);if(!a.success)return n({message:a.resultMsg});const{base64:o,formatId:l}=a.map;this.base64Fragment=o,this._successCallbackFn=r,this._errorCallbackFn=n,this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:l,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):p.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&&m||2==t.ireportExecuteMode){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
|
1
|
+
import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as r,useBrowserPrint as n,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as c}from"date-fns";import{io as h}from"socket.io-client";const m=String(navigator.platform).toLowerCase().includes("linux"),p=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,u=`${d}/fdp-api/print/assembly/printIReport`,f=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,g=`${d}/bi-api/reprot/print/open/client/previewIReport`,w=`${d}/bi-api/reprot/print/open/client/getRemote`,y=`${d}/printService/file`;let P=null;class v{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this;const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=h(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="",this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("hiprint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{p({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{p({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}}):p({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}}):p({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)}):p({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:!1,errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o=1,printdlgshow:l="0",nobillnode:h="1",btnprint:m="1",messageTimeout:p=0}){const d={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:m,copies:o,messageTimeout:p,...a?{signature:a}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=d,await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:r=0}){const n={};let a={};try{a=Object.assign({},n,JSON.parse(i))}catch(t){a=n}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:r};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await p({method:"get",url:w})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await p({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 p({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 p({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({ireportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:l,signature:c,btnprint:h,messageTimeout:p=0},d,u){const f=a(i);if(i=this.getIReportFormatId(f,i),f&&(m||2==t)){const t=await this._queryPrintForPdf(e,i,s,l);if(!t)return null==u?void 0:u("获取文件失败!");const r=n(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,r),null==d?void 0:d({file:t})}await this._queryProxyOrigin();const g=await this._testConnection();if(!this._handleResultTest(g,u))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),n=this._handleResult(t,u);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==u||u(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({ireportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p=1,isDownloadFile:d=!0,messageTimeout:u=0},f,g,w,y="printDirect"){const P=a(i);if(i=this.getIReportFormatId(P,i),P&&(m||2==t)){if(!await this._testDomesticSystemConnection())return void g({type:"notOpenedApp",result:"error",message:"请开启hiPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},f,g):g({type:"connectAppFail",result:"error",message:"连接hiPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},f,g))}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,g))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,messageTimeout:u}),n=this._handleResult(t,g,w);if(!n)return!1;d&&["downloadPDF"].includes(y)&&await this._browserPrint(n,y),null==f||f(n)}catch(t){const e="printDirect"===y?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==g||g(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:s},r,n){const a=await this._queryPrintForBase64(t,e,i,s);if(!a.success)return n({message:a.resultMsg});const{base64:o,formatId:l}=a.map;this.base64Fragment=o,this._successCallbackFn=r,this._errorCallbackFn=n,this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:l,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):p.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&&(m||2==t.ireportExecuteMode)){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
|
@@ -1 +1 @@
|
|
1
|
-
.dropdown-button{border-color:#d5d5d5!important;color:#212121;padding-right:0}.dropdown-button .n-button__content{height:100%}.dropdown-button .n-button__content .n-icon{align-items:center;display:flex;height:100%;justify-content:center;padding-right:10px;width:30px}.c-dropdown .n-dropdown-menu-wrapper span.active{color:#5585f5}.login-form-button{border-radius:24px;color:#fff;font-size:16px;height:50px;width:100%}.login-form-button-print{padding-top:15px}.login-form-button-print .n-input{border-radius:6px;color:#757575;font-size:14px;height:50px;line-height:50px}.c-button-print-modal .n-form-item-feedback-wrapper{display:none}.c-button-preview-modal{max-width:none!important}.c-button-preview-modal .n-dialog__content{height:98%}.newprint-button-component .icon-select{padding:0 8px!important}.newprint-button-poperOver{border-radius:3px}.newprint-button-poperOver .bold{font-weight:700}.newprint-button-poperOver .isDisabled{color:#999;cursor:default}.newprint-button-poperOver .print-li{overflow:hidden}.newprint-button-poperOver .print-li .n-divider{margin-bottom:6px;margin-top:6px}.newprint-button-poperOver .print-li .print-lite{align-items:center;border-radius:3px;cursor:pointer;display:flex;height:32px;justify-content:space-between;margin:3px 0}.newprint-button-poperOver .print-li .print-lite .label{padding:0 8px;white-space:nowrap}.newprint-button-poperOver .print-li .print-lite .n-icon{align-items:center;border-radius:0 3px 3px 0;display:flex;height:100%;justify-content:center;width:30px}.newprint-button-poperOver .print-li .print-lite .n-checkbox{white-space:nowrap}.newprint-button-poperOver .print-li.active{color:#2563f4}.newprint-button-poperOver .print-li.active .print-lite{background:rgba(37,99,244,.1)}.newprint-button-poperOver .print-li.active .n-icon{background:rgba(37,99,244,.15)}.newprint-button-outer{align-items:center;display:flex}.newprint-button-outer .outButtonGroup .isPrintDisabled .n-button__border{border-right-width:0!important}.newprint-button-outer .outButtonGroup .n-button.n-button--disabled+.n-button.n-button--default-type:not(.n-button--disabled) .n-button__border{border-left-width:1px!important}.newprint-button-outer .outerLastButton .n-button__border{border-bottom-right-radius:0;border-right:none;border-top-right-radius:0}.newprint-button-outer .outerLastButton:hover .n-button__state-border{border-bottom-right-radius:0;border-top-right-radius:0}.newprint-button-outer .printAllLeftCls .n-button__border,.newprint-button-outer .printAllLeftCls:hover .n-button__state-border{border-bottom-left-radius:0;border-top-left-radius:0}
|
1
|
+
.dropdown-button{border-color:#d5d5d5!important;color:#212121;padding-right:0}.dropdown-button .n-button__content{height:100%}.dropdown-button .n-button__content .n-icon{align-items:center;display:flex;height:100%;justify-content:center;padding-right:10px;width:30px}.c-dropdown .n-dropdown-menu-wrapper span.active{color:#5585f5}.login-form-button{border-radius:24px;color:#fff;font-size:16px;height:50px;width:100%}.login-form-button-print{padding-top:15px}.login-form-button-print .n-input{border-radius:6px;color:#757575;font-size:14px;height:50px;line-height:50px}.c-button-print-modal .n-form-item-feedback-wrapper{display:none}.c-button-preview-modal{max-width:none!important}.c-button-preview-modal .n-dialog__content{height:98%}.newprint-button-component .icon-select{padding:0 8px!important}.newprint-button-poperOver{border-radius:3px}.newprint-button-poperOver .bold{font-weight:700}.newprint-button-poperOver .isDisabled{color:#999;cursor:default}.newprint-button-poperOver .print-li{overflow:hidden}.newprint-button-poperOver .print-li .n-divider{margin-bottom:6px;margin-top:6px}.newprint-button-poperOver .print-li .print-lite{align-items:center;border-radius:3px;cursor:pointer;display:flex;height:32px;justify-content:space-between;margin:3px 0}.newprint-button-poperOver .print-li .print-lite .label{padding:0 8px;white-space:nowrap}.newprint-button-poperOver .print-li .print-lite .n-icon{align-items:center;border-radius:0 3px 3px 0;display:flex;height:100%;justify-content:center;width:30px}.newprint-button-poperOver .print-li .print-lite .n-checkbox{white-space:nowrap}.newprint-button-poperOver .print-li.active{color:#2563f4}.newprint-button-poperOver .print-li.active .print-lite{background:rgba(37,99,244,.1)}.newprint-button-poperOver .print-li.active .n-icon{background:rgba(37,99,244,.15)}.newprint-button-outer{align-items:center;display:flex}.newprint-button-outer .outButtonGroup .isPrintDisabled .n-button__border{border-right-width:0!important}.newprint-button-outer .outButtonGroup .n-button.n-button--disabled+.n-button.n-button--default-type:not(.n-button--disabled) .n-button__border{border-left-width:1px!important}.newprint-button-outer .outerLastButton .n-button__border{border-bottom-right-radius:0;border-right:none;border-top-right-radius:0}.newprint-button-outer .outerLastButton:hover .n-button__state-border{border-bottom-right-radius:0;border-top-right-radius:0}.newprint-button-outer .printAllLeftCls .n-button__border,.newprint-button-outer .printAllLeftCls:hover .n-button__state-border{border-bottom-left-radius:0;border-top-left-radius:0}.newprint-button-outer__shortcut{color:#76797f}
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as t,reactive as n,createVNode as a,createTextVNode as o,watch as r,openBlock as s,createElementBlock as i,normalizeStyle as l,unref as d,createElementVNode as u,Fragment as c,renderList as m,normalizeClass as p,toDisplayString as v,createCommentVNode as y,createBlock as f,nextTick as h}from"vue";import{NIcon as C}from"naive-ui";import{ChevronBackOutline as g,ChevronForwardOutline as M}from"@vicons/ionicons5";import D from"@fullcalendar/vue3";import k from"@fullcalendar/resource-timegrid";import w from"@fullcalendar/scrollgrid";import b from"@fullcalendar/interaction";import{useTheme as H}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import{format as R,isSameDay as x,toDate as L,startOfMonth as j,endOfMonth as N,eachDayOfInterval as
|
1
|
+
import{defineComponent as e,ref as t,reactive as n,createVNode as a,createTextVNode as o,watch as r,openBlock as s,createElementBlock as i,normalizeStyle as l,unref as d,createElementVNode as u,Fragment as c,renderList as m,normalizeClass as p,toDisplayString as v,createCommentVNode as y,createBlock as f,nextTick as h}from"vue";import{NIcon as C}from"naive-ui";import{ChevronBackOutline as g,ChevronForwardOutline as M}from"@vicons/ionicons5";import D from"@fullcalendar/vue3";import k from"@fullcalendar/resource-timegrid";import w from"@fullcalendar/scrollgrid";import b from"@fullcalendar/interaction";import{useTheme as H}from"../../../shared/hooks/useTheme.js";import"@vueuse/core";import{format as R,isSameDay as x,toDate as L,startOfMonth as j,endOfMonth as N,eachDayOfInterval as S,getDay as z,isSameMonth as O,startOfDay as T,endOfDay as F}from"date-fns";import{isFunction as I,cloneDeep as _}from"lodash-es";import"@vue/shared";import"../../../shared/utils/index.js";import"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";import"../../../shared/hooks/useScrollLoading.js";const A={key:0,class:"select-day-wrapper"},E={class:"day-wrapper"},G=["onClick"];var P=e({__name:"Calendar",props:{showDateNavigation:{type:Boolean,default:!0},date:{type:Date,default:new Date},events:{type:Array,default:()=>[]},resources:{type:Array,default:()=>[]},eventContentRender:{type:Function},resourceLabelContentRender:{type:Function},options:{type:Object,default:()=>({})}},emits:["select","eventDrag","eventClick","eventResize","dateChange"],setup(e,{expose:P,emit:B}){const K=e,V=["周一","周二","周三","周四","周五","周六","周日"],W=H(),q=t(),J=t(new Date),Q=t([]),U=t(!1),X=n({schedulerLicenseKey:"GPL-My-Project-Is-Open-Source",plugins:[k,w,b],initialView:"resourceTimeGridDay",initialDate:R(J.value,"yyyy-MM-dd"),headerToolbar:{left:"",center:"",right:""},allDaySlot:!1,slotLabelInterval:{minute:30},slotLabelFormat:{hour:"2-digit",minute:"2-digit",meridiem:!1,hour12:!1},slotLabelContent:e=>R(e.date,"HH:mm"),nowIndicator:!0,dayMaxEvents:!0,eventOverlap:!1,slotMinTime:{hour:0},slotMaxTime:{hour:24},dayMinWidth:100,expandRows:!0,droppable:!0,editable:!0,selectable:!0,refetchResourcesOnNavigate:!0,resources:[],events:[],dayCellClassNames:["custom-day-cell"],eventClassNames:["custom-event"],eventContent:function(e){const{start:t,end:n,title:r}=e.event;return I(K.eventContentRender)?K.eventContentRender(e):[a("p",{class:"text"},[R(t,"HH:mm"),o("-"),R(n,"HH:mm")]),a("p",{class:"text"},[r])]},resourceLabelContent:function(e){const{title:t}=e.resource;return I(K.resourceLabelContentRender)?K.resourceLabelContentRender(e):a("span",null,[t])},select:(...e)=>B("select",...e),eventDrop:(...e)=>B("eventDrag",...e),eventResize:(...e)=>B("eventResize",...e),eventClick:(...e)=>B("eventClick",...e)});function Y(e){const t=L(J.value);"prev"===e?t.setMonth(t.getMonth()-1):t.setMonth(t.getMonth()+1),Z(t),B("dateChange",$())}function Z(e){const t=j(e),n=N(e),a=S({start:t,end:n});Q.value=a.map((e=>({date:e,formatDate:R(e,"yyyy-MM-dd HH:mm:ss"),day:e.getDate(),week:V[z(e)]}))),J.value=O(e,new Date)?new Date:Q.value[0].date}function $(){const e=T(J.value),t=F(J.value);return{start:e,end:t,startStr:R(e,"yyyy-MM-dd HH:mm:ss"),endStr:R(t,"yyyy-MM-dd HH:mm:ss")}}return r((()=>J.value),(e=>{!async function(e){U.value=!1,await h(),e(),U.value=!0}((()=>{X.initialDate=R(e,"yyyy-MM-dd")}))})),r((()=>K.date),(e=>{Z(e)}),{immediate:!0}),r((()=>K.events),(e=>{X.events=_(e).map((e=>({...e,resourceEditable:!1})))}),{deep:!0,immediate:!0}),r((()=>K.resources),(e=>{X.resources=_(e)}),{deep:!0,immediate:!0}),r((()=>K.options),(()=>{Object.assign(X,K.options)}),{deep:!0,immediate:!0}),P({gotoDate:function(e){J.value=e}}),(t,n)=>(s(),i("div",{class:"c-calendar",style:l({...d(W),"--nav-height":e.showDateNavigation?"70px":"0px"})},[e.showDateNavigation?(s(),i("div",A,[a(d(C),{size:"20",component:d(g),onClick:n[0]||(n[0]=()=>Y("prev"))},null,8,["component"]),u("div",E,[(s(!0),i(c,null,m(Q.value,((e,t)=>(s(),i("div",{class:p(["day",{"day--active":d(x)(e.date,J.value)}]),key:t,onClick:()=>async function(e){J.value=e.date,B("dateChange",$())}(e)},[u("p",null,v(e.day),1),u("span",null,v(e.week),1)],10,G)))),128))]),a(d(C),{size:"20",component:d(M),onClick:n[1]||(n[1]=()=>Y("next"))},null,8,["component"])])):y("v-if",!0),U.value?(s(),f(d(D),{key:1,ref_key:"calendarRef",ref:q,options:X},null,8,["options"])):y("v-if",!0)],4))}});export{P as default};
|
@@ -3,7 +3,7 @@ export declare const CallbackMaps: Map<string, {
|
|
3
3
|
formRenderRef: import("vue").Ref<import("../../../../../components/form-render").FormRenderExpose | undefined>;
|
4
4
|
key: import("vue").Ref<number>;
|
5
5
|
reload: () => Promise<void>;
|
6
|
-
formRenderExposeKeyList: readonly ["validate", "getFormValues", "setFormValues", "setFieldState", "resetFields", "queryWidget", "getFieldList", "applySelectedSetting", "getTextFormValues", "optionInited"];
|
6
|
+
formRenderExposeKeyList: readonly ["validate", "getFormValues", "setFormValues", "setFieldState", "resetFields", "queryWidget", "getFieldList", "applySelectedSetting", "getTextFormValues", "optionInited", "updateAnchor"];
|
7
7
|
exposed: Partial<import("../../../../../components/form-render").FormRenderExpose>;
|
8
8
|
FormRender: import("vue").DefineComponent<{
|
9
9
|
fieldList: {
|
@@ -436,6 +436,7 @@ export declare const CallbackMaps: Map<string, {
|
|
436
436
|
index: number;
|
437
437
|
}[]>;
|
438
438
|
onScroll: (scrollEvent: Event) => void;
|
439
|
+
generateAnchorList: (formModel: import("@formily/core").Form<any>) => Promise<void>;
|
439
440
|
callLifeCycle: <T extends "onSetup" | "beforeSetValue" | "beforeRequest" | "afterRequest" | "afterOptionInit">(lifeCycleName: T, payload?: Parameters<Required<Partial<{
|
440
441
|
onSetup(): void;
|
441
442
|
beforeSetValue(fieldKey: string, value: unknown, payload: {
|
@@ -750,7 +751,7 @@ export declare const CallbackMaps: Map<string, {
|
|
750
751
|
startIncrementalRender: () => void;
|
751
752
|
onKeydown: (event: KeyboardEvent) => Promise<void>;
|
752
753
|
clearSpan: (uuid: string) => void;
|
753
|
-
exposeEvent: Omit<import("../../../../../components/form-render").FormRenderExpose, "getFieldList" | "optionInited" | "formModel" | "reload">;
|
754
|
+
exposeEvent: Omit<import("../../../../../components/form-render").FormRenderExpose, "updateAnchor" | "getFieldList" | "optionInited" | "formModel" | "reload">;
|
754
755
|
useVersion: typeof import("../../../../../shared/hooks").useVersion;
|
755
756
|
FormConsumer: import("vue").DefineComponent<{}, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
756
757
|
FormProvider: import("vue").DefineComponent<Record<"form", any>, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<Record<"form", any>>>, {
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,useAttrs as t,ref as a,computed as l,watch as
|
1
|
+
import{defineComponent as e,useAttrs as t,ref as a,computed as l,watch as o,openBlock as n,createBlock as u,unref as r,isRef as i,createSlots as s,renderList as d,withCtx as c,renderSlot as f,nextTick as m}from"vue";import{NDatePicker as p}from"naive-ui";import"../../../shared/utils/index.js";import{useDateTime as v,handleInputEvent as y}from"../../../shared/hooks/useDateTime.js";import{isArray as h,isEqual as g,isString as w}from"lodash-es";import"@vue/shared";import"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import"../../../shared/hooks/useScrollLoading.js";import{format as V,sub as k,startOfDay as R,endOfDay as S}from"date-fns";var D=e({__name:"DatePicker",props:{updateUnchangedValue:{type:Boolean},onConfirm:{type:Function},formattedValue:{type:[String,Array]},placeholder:{type:String},allowedInvalidValue:{type:String},to:{type:[Object,String,Boolean],default:"body"}},emits:["update:formatted-value"],setup(e,{expose:D,emit:I}){const C=e,M=t(),_=a(null),b=a(null),j=a();let $="";const P=l({get:()=>O(C.formattedValue)?null:C.formattedValue,set(e){h(e)&&h($)&&g($,e)||$===e||(I("update:formatted-value",e,w(e)?Date.parse(e):h(e)?[Date.parse(e[0]),Date.parse(e[1])]:null),$=e)}}),U=l((()=>{const e=Reflect.get(M,"type")||"";return["datetime","datetimerange"].includes(e)})),x=l((()=>{if(Reflect.get(M,"format"))return M.format;const e=M.type||"";return U.value?"yyyy-MM-dd HH:mm:ss":"month"===e?"yyyy-MM":"year"===e?"yyyy":"yyyy-MM-dd"})),H=l((()=>U.value?x.value.split(" "):"")),{focus:q,blur:A,handleConfirm:B}=v(_,{formatRef:x,attrs:M,emit:I,allowedInvalidValue:C.allowedInvalidValue});async function F(e){e&&U.value&&(await m(),async function e(t=0){var a;t>2||(b.value=null==(a=_.value)?void 0:a.panelInstRef,b.value?v(b,{formatRef:H,attrs:M,isPanel:!0}):(await m(),e(++t)))}())}async function L(...e){var t,a,l,o,n,u;const r=Reflect.get(M,"type")||"",i=null==(o=null==(l=null==(a=null==(t=_.value)?void 0:t.inputInstRef)?void 0:a.$el)?void 0:l.querySelector)?void 0:o.call(l,"input");if(r.includes("range")?null==(n=C.onConfirm)||n.call(C,...e):(await m(),i.focus(),B(i),i.blur(),null==(u=C.onConfirm)||u.call(C,Date.parse(i.value),i.value)),!(null==i?void 0:i.value)||!C.updateUnchangedValue||r.includes("range"))return;const s=i.value;y(i,V(new Date,x.value)),y(i,s)}function O(e){return C.allowedInvalidValue&&C.allowedInvalidValue===e}return o((()=>C.formattedValue),(e=>{j.value=O(e)?e:C.placeholder?C.placeholder:"选择日期时间",O(e)||($=e)}),{immediate:!0}),D({$datePicker:_,focus:q,blur:A,setShortcutValue:async function(e){const t=Reflect.get(M,"type")||"";if(!t||!t.includes("range")||!_.value)return;const a=_.value.$el.querySelectorAll(".n-input__input-el");let l,o;const n=new Date;if("week"===e){const e=k(n,{weeks:1});l=V(R(e),x.value)}else{const e=k(n,{months:1});l=V(R(e),x.value)}o=V(S(n),x.value),y(a[0],l),await m(),y(a[1],o)}}),(t,a)=>(n(),u(r(p),{ref_key:"datePickerRef",ref:_,"onUpdate:show":F,onConfirm:L,placeholder:j.value,to:e.to,"formatted-value":r(P),"onUpdate:formatted-value":a[0]||(a[0]=e=>i(P)?P.value=e:null)},s({_:2},[d(t.$slots,((e,a)=>({name:a,fn:c((()=>[f(t.$slots,a)]))})))]),1032,["placeholder","to","formatted-value"]))}});export{D as default};
|
@@ -228,6 +228,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
228
228
|
developMode: {
|
229
229
|
type: BooleanConstructor;
|
230
230
|
};
|
231
|
+
columnWidthProps: {
|
232
|
+
type: ObjectConstructor;
|
233
|
+
};
|
231
234
|
}, {
|
232
235
|
fixedWayOptions: {
|
233
236
|
label: string;
|
@@ -319,6 +322,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
319
322
|
developMode: {
|
320
323
|
type: BooleanConstructor;
|
321
324
|
};
|
325
|
+
columnWidthProps: {
|
326
|
+
type: ObjectConstructor;
|
327
|
+
};
|
322
328
|
}>> & {
|
323
329
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
324
330
|
onEdit?: ((...args: any[]) => any) | undefined;
|
@@ -433,6 +439,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
433
439
|
developMode: {
|
434
440
|
type: BooleanConstructor;
|
435
441
|
};
|
442
|
+
columnWidthProps: {
|
443
|
+
type: ObjectConstructor;
|
444
|
+
};
|
436
445
|
}>> & {
|
437
446
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
438
447
|
onEdit?: ((...args: any[]) => any) | undefined;
|
@@ -477,9 +486,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
477
486
|
}>;
|
478
487
|
developMode: boolean;
|
479
488
|
draggable: boolean;
|
480
|
-
isHighlightRow: boolean;
|
481
489
|
idx: number;
|
482
490
|
isHighlight: boolean;
|
491
|
+
isHighlightRow: boolean;
|
483
492
|
isFieldSet: boolean;
|
484
493
|
fieldDescribeMode: "column" | "tooltip";
|
485
494
|
}>;
|
@@ -250,6 +250,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
250
250
|
developMode: {
|
251
251
|
type: BooleanConstructor;
|
252
252
|
};
|
253
|
+
columnWidthProps: {
|
254
|
+
type: ObjectConstructor;
|
255
|
+
};
|
253
256
|
}, {
|
254
257
|
fixedWayOptions: {
|
255
258
|
label: string;
|
@@ -341,6 +344,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
341
344
|
developMode: {
|
342
345
|
type: BooleanConstructor;
|
343
346
|
};
|
347
|
+
columnWidthProps: {
|
348
|
+
type: ObjectConstructor;
|
349
|
+
};
|
344
350
|
}>> & {
|
345
351
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
346
352
|
onEdit?: ((...args: any[]) => any) | undefined;
|
@@ -455,6 +461,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
455
461
|
developMode: {
|
456
462
|
type: BooleanConstructor;
|
457
463
|
};
|
464
|
+
columnWidthProps: {
|
465
|
+
type: ObjectConstructor;
|
466
|
+
};
|
458
467
|
}>> & {
|
459
468
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
460
469
|
onEdit?: ((...args: any[]) => any) | undefined;
|
@@ -499,9 +508,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
499
508
|
}>;
|
500
509
|
developMode: boolean;
|
501
510
|
draggable: boolean;
|
502
|
-
isHighlightRow: boolean;
|
503
511
|
idx: number;
|
504
512
|
isHighlight: boolean;
|
513
|
+
isHighlightRow: boolean;
|
505
514
|
isFieldSet: boolean;
|
506
515
|
fieldDescribeMode: "column" | "tooltip";
|
507
516
|
}>;
|