cnhis-design-vue 3.2.4-beta.31 → 3.2.4-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/button-print/index.d.ts +1 -1
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +1 -1
- package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +1 -1
- package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
- package/es/components/button-print/src/utils/print.d.ts +1 -0
- package/es/components/button-print/src/utils/print.js +1 -1
- package/es/components/field-set/src/FieldColor.vue.d.ts +26 -0
- package/es/components/field-set/src/FieldFilter.vue.d.ts +26 -0
- package/es/components/field-set/src/FieldSet.vue.d.ts +41 -0
- package/es/components/field-set/src/FieldSet.vue2.js +1 -1
- package/es/components/field-set/src/components/Row.vue.d.ts +26 -0
- package/es/components/field-set/src/components/Row.vue2.js +1 -1
- package/es/components/field-set/src/utils/index.js +1 -1
- package/es/components/iho-table/src/plugins/pagerScrollPlugin/pagerScroll.vue.d.ts +1 -0
- package/es/components/iho-table/src/plugins/pagerScrollPlugin/pagerScroll.vue2.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/editSelect.d.ts +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/editSelect.js +1 -1
- package/es/shared/package.json.js +1 -1
- package/package.json +2 -2
|
@@ -465,7 +465,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
465
465
|
handleClickPreview: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => Promise<void>;
|
|
466
466
|
handleClickPdf: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => Promise<void>;
|
|
467
467
|
handleClickEdit: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => void;
|
|
468
|
-
handleResetPrinter: () => void;
|
|
468
|
+
handleResetPrinter: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => void;
|
|
469
469
|
handleSelect: (type: string, { templateCode, templateId, key }: import("../../shared/types").AnyObject, isOuterClick: boolean) => Promise<void>;
|
|
470
470
|
handleClickOutside: () => void;
|
|
471
471
|
instantiatePrintSDK: () => false | undefined;
|
|
@@ -471,7 +471,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
471
471
|
handleClickPreview: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => Promise<void>;
|
|
472
472
|
handleClickPdf: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => Promise<void>;
|
|
473
473
|
handleClickEdit: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => void;
|
|
474
|
-
handleResetPrinter: () => void;
|
|
474
|
+
handleResetPrinter: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => void;
|
|
475
475
|
handleSelect: (type: string, { templateCode, templateId, key }: AnyObject, isOuterClick: boolean) => Promise<void>;
|
|
476
476
|
handleClickOutside: () => void;
|
|
477
477
|
instantiatePrintSDK: () => false | undefined;
|
|
@@ -276,7 +276,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
276
276
|
handleClickPreview: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => Promise<void>;
|
|
277
277
|
handleClickPdf: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => Promise<void>;
|
|
278
278
|
handleClickEdit: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => void;
|
|
279
|
-
handleResetPrinter: () => void;
|
|
279
|
+
handleResetPrinter: (curPrintParamList: any[] | undefined, templateCode: string, templateId: string, formatId: string) => void;
|
|
280
280
|
handleSelect: (type: string, { templateCode, templateId, key }: AnyObject, isOuterClick: boolean) => Promise<void>;
|
|
281
281
|
handleClickOutside: () => void;
|
|
282
282
|
instantiatePrintSDK: () => false | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as t,inject as e,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 p,createVNode as d,unref as m,withCtx as v,renderList as y,createBlock as f,createTextVNode as g,toDisplayString as k,isRef as h,renderSlot as b,withModifiers as w,normalizeClass as P,mergeProps as O}from"vue";import{isObject as S}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as M,NPopover as F,NCheckbox as j,NDivider as x}from"naive-ui";import{PrintOutline as E,SettingsOutline as N,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as z}from"../constants/index.js";import{Print as J}from"../utils/print.js";import{isIReport as U}from"../utils/browserPrint.js";import V from"./IdentityVerification.vue.js";import{format as A}from"date-fns";import"../api.js";const K={class:"newprint-button-outer"},B=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},H={class:"print-lite"},q={class:"label bold"},G={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},tt={class:"label bold"},et={class:"print-li"},nt={class:"print-lite"},it={class:"print-lite"},rt=["onClick"],at={class:"newprint-button-poperOver"},lt=["onMouseenter"],ot={class:"print-lite"},st=["onClick"];var ut=t({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,isShowOutSetting:!0,customProps:{},outerPrintKeys:[]})}},setup(t,{expose:ut}){const ct=t,pt=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],dt=C();let mt;const vt=e(z),yt=n(""),ft=i({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1});let gt=n([]),kt=n([{label:ct.pdfLoadText,key:"downloadPdf"},{label:ct.previewText,key:"previewText"},{label:ct.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const ht=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),bt=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),wt=n([]),Pt=n([]),Ot=r((()=>{if(!ft.currentFormatId)return{};let t=ft.currentFormatId;return ft.formatList.find((e=>e.id===t))}));r((()=>{var t;return(null==(t=Ot.value)?void 0:t.name)||"格式选择"}));const St=r((()=>{let t=ft.formatList.find((t=>t.id===ft.currentFormatId));return null==t?void 0:t.templateId})),Ct=r((()=>{var t;return null==(t=ct.newPrintSetting)?void 0:t.isShowPrintAll})),It=r((()=>{var t;return null==(t=ct.newPrintSetting)?void 0:t.isShowOutSetting})),Tt=r((()=>{var t;return(null==(t=ct.newPrintSetting)?void 0:t.customProps)||{}})),Lt=r((()=>{const t=pt.map((t=>t.key));return gt.value.filter((e=>!t.includes(e.key)))})),Mt=r({get:()=>Lt.value.every((t=>t.selected)),set(t){Lt.value.forEach((e=>{e.selected=t}))}}),Ft=async()=>{var t,e;(null==(e=null==(t=ct.newPrintSetting)?void 0:t.outerPrintKeys)?void 0:e.length)||await te(),bt.oneShow=!0},jt=async t=>{if(ct.directPrint){if(ft.spinning)return;return"button"===t?void(Ct.value?await ie():Ft()):Ft()}return Ft()},xt=(t,e)=>{ht[t]=e},Et=()=>{wt.value=gt.value.filter((t=>!t.selected)),Pt.value=Lt.value.filter((t=>t.selected)),_t("oneShow"),_t("isOutSetting"),vt("saveOuterPrint",Pt.value)},Nt=t=>{bt[t]=!0},_t=t=>{ht.oneClickType="",bt[t]=!1,"isOutSetting"==t&&(bt.isOutSetting=!1)},Dt=(t,e)=>{Kt(!1);let n={type:e,formatId:ft.currentFormatId,templateId:St.value};vt("success",t,n)},zt=t=>{Kt(!1),vt("error",t),S(t)&&"notInstalledApp"===t.type&&dt.error(t.message)},Jt=t=>{Kt(!1),vt("cancel",t)},Ut=t=>{vt("error",{message:"前置条件执行错误",type:t,preExecution:!0})},Vt=()=>JSON.stringify({...ct.token?{token:ct.token}:{}}),At=(t=[],e)=>{var n,i;let r={},a={};if((null==(n=ft.templateParams[e].customizeDataset)?void 0:n.length)>0){const e=(null==(i=Object.keys(t[0].datasetData||{}))?void 0:i[0])||"",n=JSON.stringify(t.map((t=>JSON.parse(t.datasetData[e]))));a={datasetData:{}},a.datasetData[e]=n}else Object.keys(t[0]).forEach((e=>{a[e]=[],t.forEach((t=>{a[e].includes(t[e])||a[e].push(t[e])})),a[e]=a[e].join(",")}));return r=Object.assign({},JSON.parse(Vt()),Tt.value,a),JSON.stringify(r)},Kt=(t,e)=>{if(ft.isClickOuterPrint){if(t&&e){const n=Pt.value.find((t=>t.key==e));return void(n&&(n.isLoading=t))}Pt.value.forEach((t=>{t.isLoading=!1}))}else ft.spinning=t},Bt=()=>ft.isClickOuterPrint?Pt.value.some((t=>t.isLoading)):ft.spinning,Rt=(t,e,n,i)=>{const r=ft.printParams[t];ft.isClickOuterPrint=i,Ht(r,t,e,n)},Ht=async(t=[],e,n,i,r)=>{let a=t.length;const l=async t=>{try{--a<=0&&Dt(t,"print")}catch(t){console.log("error",t)}};ct.showLoading&&Bt()&&!r||(Kt(!0,i),ct.prevFn("print").then((()=>{ft.curPrintParamList=t;const r={formatId:i,templateId:n,authorizationKey:yt.value,printdlgshow:ct.printdlgshow,signature:ct.signature,copies:ct.printCopies};if("MULTI"===ct.strategy)for(let e=0;e<t.length;e++)e>0&&(r.printdlgshow="0"),mt.printDirect({...r,params:Object.assign({},JSON.parse(Vt()),Tt.value,t[e])},l,zt,Jt);else mt.printDirect({...r,params:At(t,e)},(t=>{Dt(t,"print")}),zt,Jt)})).catch((()=>{Ut("print"),Kt(!1)})).finally((()=>{ft.visible=!1})))},qt=async(t,{templateCode:e,templateId:n,key:i},r)=>{const a=ft.printParams[e];switch(ft.isClickOuterPrint=r,t){case"previewText":(async(t=[],e,n,i)=>{ct.showLoading&&Bt()||(Kt(!0,i),ct.prevFn("preview").then((()=>{ft.curPrintParamList=t;const r="MULTI"===ct.strategy?Object.assign({},JSON.parse(Vt()),Tt.value,t[0]):At(t,e),a={formatId:i,templateId:n,authorizationKey:yt.value,params:r,btnprint:ct.btnprint,signature:ct.signature};mt.preview(a,(t=>{Dt(t,"preview")}),zt)})).catch((()=>{Ut("preview"),Kt(!1)})).finally((()=>{ft.visible=!1})))})(a,e,n,i);break;case"formatEditText":((t=[],e,n,i)=>{ct.showLoading&&Bt()||(Kt(!0,i),ct.prevFn("edit").then((()=>{ft.curPrintParamList=t,ft.currentFormatId=i,ft.identityVerification.visible=!0})).catch((()=>{Ut("edit")})).finally((()=>{Kt(!1)})))})(a,0,0,i);break;case"downloadPdf":(async(t=[],e,n,i)=>{ct.showLoading&&Bt()||(Kt(!0,i),ct.prevFn("download").then((()=>{ft.curPrintParamList=t;const r="MULTI"===ct.strategy?Object.assign({},JSON.parse(Vt()),Tt.value,t[0]):At(t,e),a={formatId:i,templateId:n,authorizationKey:yt.value,print:{print:"1",type:"1"},params:r,signature:ct.signature};mt.downloadPDF(a,(t=>Dt(t,"preview")),zt)})).catch((()=>{Ut("download"),Kt(!1)})).finally((()=>{ft.visible=!1})))})(a,e,n,i)}},Gt=()=>{},Yt=(t,e=[])=>{let n={};return e.forEach((e=>{n=Object.assign({},Wt(n,e,t))})),n},$t=(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=A(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},Qt=({customizeDataset:t=[],param:e=[]},n={})=>{let i={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[t.name]=JSON.stringify($t(n,e,"fieldName"))})),i=Object.assign({},i,$t(n,e,"key")),i},Wt=(t,e,n)=>{if(e.templateNumbers){for(let i=0;i<e.templateNumbers.length;i++){const r=e.templateNumbers[i],a=n[r];if(!a)return dt.error("当前勾选的数据没有匹配的模板"),t;t[r]||(t[r]=[]),t[r].push(Qt(a,e))}return t}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return dt.error("当前勾选的数据没有匹配的模板"),t;t[a]||(t[a]=[]),t[a].push(Qt(l,e))}return t},Xt=async t=>{ft.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],(()=>{var t,e,n;const i=ft.formatList.map((t=>({templateCode:t.number,templateId:t.templateId,label:t.name,key:t.id,selected:!1,isLoading:!1})));gt.value.unshift(...i),It.value&>.value.push(...pt),(null==(e=null==(t=ct.newPrintSetting)?void 0:t.outerPrintKeys)?void 0:e.length)>0&&(gt.value.forEach((t=>{var e;(null==(e=ct.newPrintSetting)?void 0:e.outerPrintKeys.includes(t.key))&&(t.selected=!0)})),Pt.value=gt.value.filter((t=>t.selected))),wt.value=gt.value.filter((t=>!t.selected)),ct.hideButtons.length>0&&(kt.value=kt.value.filter((t=>!ct.hideButtons.includes(t.key))));const r=sessionStorage.getItem("portal");if(r){const t=JSON.parse(r),e=(null==(n=null==t?void 0:t.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(e);i.includes("RY7.2.21.1.M2.G94181E")||(kt.value=kt.value.filter((t=>"downloadPdf"!=t.key))),i.includes("RY7.2.21.1.M2.G33633A")||(kt.value=kt.value.filter((t=>"formatEditText"!=t.key)))}})(),ft.templateParams=(t=>{let e={};return t&&t.forEach((t=>{if(!t.templateConfig)return!1;e[t.number]=t.templateConfig})),e})(t.obj),ft.printParams=Yt(ft.templateParams,ct.params)},Zt=async()=>{var t;if(ft.isInited)return!0;ft.isInited=!0,ft.spinning=!0,(()=>{if(mt)return!1;mt=new J})();const e=await ct.queryPrintFormatByNumber();return await Xt(e),(null==(t=e.obj)?void 0:t.length)>0&&(yt.value=e.obj[0].authorizationKey||""),ft.spinning=!1,!0},te=async(t=!0)=>{var e,n;if(await ct.clickPrevFn())if((null==(e=ct.params)?void 0:e.length)||(null==(n=ct.printParams)?void 0:n.length)){if(!ft.visible){if(!await Zt())return!1}t&&(ft.visible=!ft.visible)}else dt.warning(ct.noDataMsg)},ee=()=>{ft.watchPrintParamsReformatFn&&ft.watchPrintParamsReformatFn(),ft.isInited?ft.printParams=Yt(ft.templateParams,ct.params):ft.watchPrintParamsReformatFn=()=>l((()=>ft.isInited),(t=>{if(!t)return!1;ee()}))},ne=t=>{if(ft.identityVerification.visible=!1,U(ft.currentFormatId))return Dt(null,"edit");const e={formatId:ft.currentFormatId,templateId:St.value,params:Object.assign({},JSON.parse(Vt()),Tt.value,ft.curPrintParamList[0]),token:t};mt.editPrintFormat(e,(t=>{Dt(t,"edit")}),zt)};async function ie(){await te(!1),(()=>{const t=Object.keys(ft.printParams);ft.isClickOuterPrint=!1;for(let e=0;e<t.length;e++){const n=t[e],i=ft.printParams[n],r=ft.formatList.filter((t=>t.number==n));r&&r.length>0&&r.forEach((t=>{Ht(i,t.number,t.templateId,t.id,!0)}))}})()}return a((()=>{ft.isInited=!1})),l((()=>ct.params),(t=>{if(!(null==t?void 0:t.length))return!1;ee()}),{deep:!0}),l((()=>{var t;return null==(t=ct.newPrintSetting)?void 0:t.outerPrintKeys}),(async t=>{(null==t?void 0:t.length)>0&&await te(!1)}),{deep:!0,immediate:!0}),ut({directPrint:ie}),(e,n)=>(o(),s(u,null,[c("div",K,[p(" 外显按钮集合 "),d(m(I),null,{default:v((()=>[(o(!0),s(u,null,y(Pt.value,(e=>(o(),f(m(T),{key:e.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:Gt,options:m(kt),onSelect:t=>qt(t,e,!0)},{default:v((()=>[d(m(L),{loading:t.showLoading&&e.isLoading,onClick:t=>Rt(e.templateCode,e.templateId,e.key,!0)},{icon:v((()=>[d(m(M),{component:m(E),size:"18"},null,8,["component"])])),default:v((()=>[g(" "+k(e.label),1)])),_:2},1032,["loading","onClick"])])),_:2},1032,["options","onSelect"])))),128))])),_:1}),p(' <n-button-group>\r\n\t\t\t<n-popover\r\n\t\t\t\tv-for="outer in outerPrintItems"\r\n :key="outer.key"\r\n\t\t\t\ttrigger="hover"\r\n\t\t\t\t:show-arrow="false"\r\n\t\t\t\t:show="downlistPopover.isOperation"\r\n\t\t\t\t@clickoutside="handleClickOutHide(\'isOperation\')"\r\n\t\t\t>\r\n\t\t\t\t<template #trigger>\r\n\t\t\t\t\t<n-button\r\n\t\t\t\t\t\t@mouseenter="delayShowPopover(\'isOperation\')"\r\n\t\t\t\t\t\t@mouseleave="handleClickOutHide(\'isOperation\')"\r\n\t\t\t\t\t\t@click="console.log(33)"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t<n-icon :component="PrintOutline" size="18"></n-icon>\r\n\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t<span class="label bold">{{ outer.label }}</span>\r\n\t\t\t\t\t</n-button>\r\n\t\t\t\t</template>\r\n\t\t\t\t<div class="newprint-button-poperOver">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tclass="print-li"\r\n\t\t\t\t\t\tv-for="operation in operations"\r\n\t\t\t\t\t\t:key="operation.key"\r\n\t\t\t\t\t\t:class="downlistOperation.twoMouseType==operation.key ? \'active\' : \'\' "\r\n\t\t\t\t\t\t@mouseenter="handleTypeChange(\'twoMouseType\', operation.key)"\r\n\t\t\t\t\t\t@mouseleave="handleTypeChange(\'twoMouseType\', \'\')"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<div class="print-lite">\r\n\t\t\t\t\t\t\t<span class="label"> {{ operation.label }} </span>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</n-popover>\r\n\t\t</n-button-group> '),p(" 外显设置按钮 "),ft.isInited&&Pt.value.length>0&&Pt.value.length==m(Lt).length&&m(It)?(o(),f(m(F),{key:0,trigger:"click","show-arrow":!1,show:bt.isOutSetting,onClickoutside:n[2]||(n[2]=t=>_t("isOutSetting"))},{trigger:v((()=>[d(m(L),{onClick:n[0]||(n[0]=t=>Nt("isOutSetting"))},{default:v((()=>[B,d(m(M),{style:{"margin-left":"8px"},component:m(N),size:"18"},null,8,["component"])])),_:1})])),default:v((()=>[c("div",R,[(o(!0),s(u,null,y(m(Lt),(t=>(o(),s("div",{class:"print-li",key:t.key},[c("div",H,[c("span",q,k(t.label),1),d(m(j),{checked:t.selected,"onUpdate:checked":e=>t.selected=e},{default:v((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",G,[d(m(x)),c("div",Y,[d(m(L),{type:"primary",size:"small",onClick:Et},{default:v((()=>[g("保存")])),_:1}),d(m(j),{checked:m(Mt),"onUpdate:checked":n[1]||(n[1]=t=>h(Mt)?Mt.value=t:null)},{default:v((()=>[g("全选")])),_:1},8,["checked"])])])])])),_:1},8,["show"])):(o(),s(u,{key:1},[p(" 打印全部按钮 "),d(m(F),{trigger:"click","show-arrow":!1,show:bt.oneShow,onClickoutside:n[10]||(n[10]=t=>_t("oneShow"))},{trigger:v((()=>[b(e.$slots,"button",{handleClickPrintBtn:te,printSpinning:ft.spinning,printbtnText:t.btnText,printVisible:ft.visible},(()=>[d(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=w((()=>jt("icon")),["stop"]))},{default:v((()=>[d(m(L),{loading:t.showLoading&&ft.spinning,onClick:n[3]||(n[3]=w((()=>jt("button")),["stop"]))},{icon:v((()=>[d(m(M),{component:m(E),size:"18"},null,8,["component"])])),default:v((()=>[g(" "+k(m(Ct)?"打印全部":t.btnText),1)])),_:1},8,["loading"]),d(m(L),{class:"icon-select"},{icon:v((()=>[d(m(M),{component:m(_),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:v((()=>[c("div",$,[(o(!0),s(u,null,y(wt.value,(t=>(o(),s("div",{class:P(["print-li",ht.oneMouseType==t.key||ht.oneClickType==t.key?"active":""]),key:t.key,onMouseenter:e=>xt("oneMouseType",t.key),onMouseleave:n[9]||(n[9]=t=>xt("oneMouseType","")),onClick:e=>{return n="oneClickType",i=t.key,void xt(n,i);var n,i}},["divider"==t.key?(o(),f(m(x),{key:0})):"outSetting"==t.key?(o(),s(u,{key:1},[p(" 第二层外显设置 "),d(m(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:bt.isOutSetting,onClickoutside:n[7]||(n[7]=t=>_t("isOutSetting"))},{trigger:v((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=t=>Nt("isOutSetting"))},[c("span",W,k(t.label),1),d(m(M),{style:{background:"transparent"},component:m(N),size:"18"},null,8,["component"])])])),default:v((()=>[c("div",X,[(o(!0),s(u,null,y(m(Lt),(t=>(o(),s("div",{class:"print-li",key:t.key},[c("div",Z,[c("span",tt,k(t.label),1),d(m(j),{checked:t.selected,"onUpdate:checked":e=>t.selected=e},{default:v((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",et,[d(m(x)),c("div",nt,[d(m(L),{type:"primary",size:"small",onClick:Et},{default:v((()=>[g("保存")])),_:1}),d(m(j),{checked:m(Mt),"onUpdate:checked":n[6]||(n[6]=t=>h(Mt)?Mt.value=t:null)},{default:v((()=>[g("全选")])),_:1},8,["checked"])])])])])),_:2},1032,["show"])],2112)):(o(),s(u,{key:2},[p(" 第二层功能操作 "),c("div",it,[c("span",{class:"label bold",onClick:e=>Rt(t.templateCode,t.templateId,t.key,!1)},k(t.label),9,rt),d(m(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:bt[t.key],onClickoutside:e=>_t(t.key)},{trigger:v((()=>[d(m(M),{component:m(D),size:"18",onClick:e=>Nt(t.key)},null,8,["component","onClick"])])),default:v((()=>[c("div",at,[(o(!0),s(u,null,y(m(kt),(e=>(o(),s("div",{class:P(["print-li",ht.twoMouseType==e.key?"active":""]),key:e.key,onMouseenter:t=>xt("twoMouseType",e.key),onMouseleave:n[8]||(n[8]=t=>xt("twoMouseType",""))},[c("div",ot,[c("span",{class:"label",onClick:n=>qt(e.key,t,!1)},k(e.label),9,st)])],42,lt)))),128))])])),_:2},1032,["show","onClickoutside"])])],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),d(V,O(e.$attrs,{modelValue:ft.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=t=>ft.identityVerification.visible=t),formatId:ft.currentFormatId,templateId:m(St),onSuccess:ne}),null,16,["modelValue","formatId","templateId"])],64))}});export{ut as default};
|
|
1
|
+
import{defineComponent as t,inject as e,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,createTextVNode as g,toDisplayString as k,isRef as h,renderSlot as b,withModifiers as w,normalizeClass as P,mergeProps as O}from"vue";import{isObject as S}from"@vue/shared";import{useMessage as C,NButtonGroup as I,NDropdown as T,NButton as L,NIcon as M,NPopover as F,NCheckbox as j,NDivider as x}from"naive-ui";import{PrintOutline as E,SettingsOutline as N,ChevronDownSharp as _,ArrowForwardOutline as D}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as z}from"../constants/index.js";import{Print as J}from"../utils/print.js";import{isIReport as U}from"../utils/browserPrint.js";import V from"./IdentityVerification.vue.js";import{format as A}from"date-fns";import"../api.js";const K={class:"newprint-button-outer"},B=c("span",{class:"label bold"},"外显设置",-1),R={class:"newprint-button-poperOver"},H={class:"print-lite"},q={class:"label bold"},G={class:"print-li"},Y={class:"print-lite"},$={class:"newprint-button-poperOver"},Q=["onMouseenter","onClick"],W={class:"label bold"},X={class:"newprint-button-poperOver"},Z={class:"print-lite"},tt={class:"label bold"},et={class:"print-li"},nt={class:"print-lite"},it={class:"print-lite"},rt=["onClick"],at={class:"newprint-button-poperOver"},lt=["onMouseenter"],ot={class:"print-lite"},st=["onClick"];var ut=t({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number,default:1},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,isShowOutSetting:!0,customProps:{},outerPrintKeys:[]})}},setup(t,{expose:ut}){const ct=t,dt=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],pt=C();let mt;const vt=e(z),yt=n(""),ft=i({spinning:!1,visible:!1,formatList:[],templateParams:{},printParams:[],currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1});let gt=n([]),kt=n([{label:ct.pdfLoadText,key:"downloadPdf"},{label:ct.previewText,key:"previewText"},{label:ct.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const ht=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),bt=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),wt=n([]),Pt=n([]),Ot=r((()=>{if(!ft.currentFormatId)return{};let t=ft.currentFormatId;return ft.formatList.find((e=>e.id===t))}));r((()=>{var t;return(null==(t=Ot.value)?void 0:t.name)||"格式选择"}));const St=r((()=>{let t=ft.formatList.find((t=>t.id===ft.currentFormatId));return null==t?void 0:t.templateId})),Ct=r((()=>{var t;return null==(t=ct.newPrintSetting)?void 0:t.isShowPrintAll})),It=r((()=>{var t;return null==(t=ct.newPrintSetting)?void 0:t.isShowOutSetting})),Tt=r((()=>{var t;return(null==(t=ct.newPrintSetting)?void 0:t.customProps)||{}})),Lt=r((()=>{const t=dt.map((t=>t.key));return gt.value.filter((e=>!t.includes(e.key)))})),Mt=r({get:()=>Lt.value.every((t=>t.selected)),set(t){Lt.value.forEach((e=>{e.selected=t}))}}),Ft=async()=>{var t,e;(null==(e=null==(t=ct.newPrintSetting)?void 0:t.outerPrintKeys)?void 0:e.length)||await te(),bt.oneShow=!0},jt=async t=>{if(ct.directPrint){if(ft.spinning)return;return"button"===t?void(Ct.value?await ie():Ft()):Ft()}return Ft()},xt=(t,e)=>{ht[t]=e},Et=()=>{wt.value=gt.value.filter((t=>!t.selected)),Pt.value=Lt.value.filter((t=>t.selected)),_t("oneShow"),_t("isOutSetting"),vt("saveOuterPrint",Pt.value)},Nt=t=>{bt[t]=!0},_t=t=>{ht.oneClickType="",bt[t]=!1,"isOutSetting"==t&&(bt.isOutSetting=!1)},Dt=(t,e)=>{Kt(!1);let n={type:e,formatId:ft.currentFormatId,templateId:St.value};vt("success",t,n)},zt=t=>{Kt(!1),vt("error",t),S(t)&&"notInstalledApp"===t.type&&pt.error(t.message)},Jt=t=>{Kt(!1),vt("cancel",t)},Ut=t=>{vt("error",{message:"前置条件执行错误",type:t,preExecution:!0})},Vt=()=>JSON.stringify({...ct.token?{token:ct.token}:{}}),At=(t=[],e)=>{var n,i;let r={},a={};if((null==(n=ft.templateParams[e].customizeDataset)?void 0:n.length)>0){const e=(null==(i=Object.keys(t[0].datasetData||{}))?void 0:i[0])||"",n=JSON.stringify(t.map((t=>JSON.parse(t.datasetData[e]))));a={datasetData:{}},a.datasetData[e]=n}else Object.keys(t[0]).forEach((e=>{a[e]=[],t.forEach((t=>{a[e].includes(t[e])||a[e].push(t[e])})),a[e]=a[e].join(",")}));return r=Object.assign({},JSON.parse(Vt()),Tt.value,a),JSON.stringify(r)},Kt=(t,e)=>{if(ft.isClickOuterPrint){if(t&&e){const n=Pt.value.find((t=>t.key==e));return void(n&&(n.isLoading=t))}Pt.value.forEach((t=>{t.isLoading=!1}))}else ft.spinning=t},Bt=()=>ft.isClickOuterPrint?Pt.value.some((t=>t.isLoading)):ft.spinning,Rt=(t,e,n,i)=>{const r=ft.printParams[t];ft.isClickOuterPrint=i,Ht(r,t,e,n)},Ht=async(t=[],e,n,i,r)=>{let a=t.length;const l=async t=>{try{--a<=0&&Dt(t,"print")}catch(t){console.log("error",t)}};ct.showLoading&&Bt()&&!r||(Kt(!0,i),ct.prevFn("print").then((()=>{ft.curPrintParamList=t;const r={formatId:i,templateId:n,authorizationKey:yt.value,printdlgshow:ct.printdlgshow,signature:ct.signature,copies:ct.printCopies};if("MULTI"===ct.strategy)for(let e=0;e<t.length;e++)e>0&&(r.printdlgshow="0"),mt.printDirect({...r,params:Object.assign({},JSON.parse(Vt()),Tt.value,t[e])},l,zt,Jt);else mt.printDirect({...r,params:At(t,e)},(t=>{Dt(t,"print")}),zt,Jt)})).catch((()=>{Ut("print"),Kt(!1)})).finally((()=>{ft.visible=!1})))},qt=async(t,{templateCode:e,templateId:n,key:i},r)=>{const a=ft.printParams[e];switch(ft.isClickOuterPrint=r,t){case"previewText":(async(t=[],e,n,i)=>{ct.showLoading&&Bt()||(Kt(!0,i),ct.prevFn("preview").then((()=>{ft.curPrintParamList=t;const r="MULTI"===ct.strategy?Object.assign({},JSON.parse(Vt()),Tt.value,t[0]):At(t,e),a={formatId:i,templateId:n,authorizationKey:yt.value,params:r,btnprint:ct.btnprint,signature:ct.signature};mt.preview(a,(t=>{Dt(t,"preview")}),zt)})).catch((()=>{Ut("preview"),Kt(!1)})).finally((()=>{ft.visible=!1})))})(a,e,n,i);break;case"formatEditText":((t=[],e,n,i)=>{ct.showLoading&&Bt()||(Kt(!0,i),ct.prevFn("edit").then((()=>{ft.curPrintParamList=t,ft.currentFormatId=i,ft.identityVerification.visible=!0})).catch((()=>{Ut("edit")})).finally((()=>{Kt(!1)})))})(a,0,0,i);break;case"downloadPdf":(async(t=[],e,n,i)=>{ct.showLoading&&Bt()||(Kt(!0,i),ct.prevFn("download").then((()=>{ft.curPrintParamList=t;const r="MULTI"===ct.strategy?Object.assign({},JSON.parse(Vt()),Tt.value,t[0]):At(t,e),a={formatId:i,templateId:n,authorizationKey:yt.value,print:{print:"1",type:"1"},params:r,signature:ct.signature};mt.downloadPDF(a,(t=>Dt(t,"preview")),zt)})).catch((()=>{Ut("download"),Kt(!1)})).finally((()=>{ft.visible=!1})))})(a,e,n,i);break;case"resetPrinter":l=i,ct.showLoading&&Bt()||(Kt(!0,l),mt.resetPrinter(l).then((t=>{Kt(!1),t?pt.success("重置打印机成功"):pt.warning("重置打印机失败")})))}var l},Gt=()=>{},Yt=(t,e=[])=>{let n={};return e.forEach((e=>{n=Object.assign({},Wt(n,e,t))})),n},$t=(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=A(e,n[t.type])),(null==t?void 0:t.defaultValue)||i})(e,t[e[n]]);t[e[n]]&&r&&(i[e[n]]=r)})),i},Qt=({customizeDataset:t=[],param:e=[]},n={})=>{let i={};return t.forEach((t=>{const e=t.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[t.name]=JSON.stringify($t(n,e,"fieldName"))})),i=Object.assign({},i,$t(n,e,"key")),i},Wt=(t,e,n)=>{if(e.templateNumbers){for(let i=0;i<e.templateNumbers.length;i++){const r=e.templateNumbers[i],a=n[r];if(!a)return pt.error("当前勾选的数据没有匹配的模板"),t;t[r]||(t[r]=[]),t[r].push(Qt(a,e))}return t}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return pt.error("当前勾选的数据没有匹配的模板"),t;t[a]||(t[a]=[]),t[a].push(Qt(l,e))}return t},Xt=async t=>{ft.formatList=t?(t=>{let e=[];return t&&t.forEach((t=>{if(!t.format)return!1;e.push(...t.format.map((e=>Object.assign({},e,{templateName:t.name}))))})),e})(t.obj):[],(()=>{var t,e,n;const i=ft.formatList.map((t=>({templateCode:t.number,templateId:t.templateId,label:t.name,key:t.id,selected:!1,isLoading:!1})));gt.value.unshift(...i),It.value&>.value.push(...dt),(null==(e=null==(t=ct.newPrintSetting)?void 0:t.outerPrintKeys)?void 0:e.length)>0&&(gt.value.forEach((t=>{var e;(null==(e=ct.newPrintSetting)?void 0:e.outerPrintKeys.includes(t.key))&&(t.selected=!0)})),Pt.value=gt.value.filter((t=>t.selected))),wt.value=gt.value.filter((t=>!t.selected)),ct.hideButtons.length>0&&(kt.value=kt.value.filter((t=>!ct.hideButtons.includes(t.key))));const r=sessionStorage.getItem("portal");if(r){const t=JSON.parse(r),e=(null==(n=null==t?void 0:t.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(e);i.includes("RY7.2.21.1.M2.G94181E")||(kt.value=kt.value.filter((t=>"downloadPdf"!=t.key))),i.includes("RY7.2.21.1.M2.G33633A")||(kt.value=kt.value.filter((t=>"formatEditText"!=t.key)))}})(),ft.templateParams=(t=>{let e={};return t&&t.forEach((t=>{if(!t.templateConfig)return!1;e[t.number]=t.templateConfig})),e})(t.obj),ft.printParams=Yt(ft.templateParams,ct.params)},Zt=async()=>{var t;if(ft.isInited)return!0;ft.isInited=!0,ft.spinning=!0,(()=>{if(mt)return!1;mt=new J})();const e=await ct.queryPrintFormatByNumber();return await Xt(e),(null==(t=e.obj)?void 0:t.length)>0&&(yt.value=e.obj[0].authorizationKey||""),ft.spinning=!1,!0},te=async(t=!0)=>{var e,n;if(await ct.clickPrevFn())if((null==(e=ct.params)?void 0:e.length)||(null==(n=ct.printParams)?void 0:n.length)){if(!ft.visible){if(!await Zt())return!1}t&&(ft.visible=!ft.visible)}else pt.warning(ct.noDataMsg)},ee=()=>{ft.watchPrintParamsReformatFn&&ft.watchPrintParamsReformatFn(),ft.isInited?ft.printParams=Yt(ft.templateParams,ct.params):ft.watchPrintParamsReformatFn=()=>l((()=>ft.isInited),(t=>{if(!t)return!1;ee()}))},ne=t=>{if(ft.identityVerification.visible=!1,U(ft.currentFormatId))return Dt(null,"edit");const e={formatId:ft.currentFormatId,templateId:St.value,params:Object.assign({},JSON.parse(Vt()),Tt.value,ft.curPrintParamList[0]),token:t};mt.editPrintFormat(e,(t=>{Dt(t,"edit")}),zt)};async function ie(){await te(!1),(()=>{const t=Object.keys(ft.printParams);ft.isClickOuterPrint=!1;for(let e=0;e<t.length;e++){const n=t[e],i=ft.printParams[n],r=ft.formatList.filter((t=>t.number==n));r&&r.length>0&&r.forEach((t=>{Ht(i,t.number,t.templateId,t.id,!0)}))}})()}return a((()=>{ft.isInited=!1})),l((()=>ct.params),(t=>{if(!(null==t?void 0:t.length))return!1;ee()}),{deep:!0}),l((()=>{var t;return null==(t=ct.newPrintSetting)?void 0:t.outerPrintKeys}),(async t=>{(null==t?void 0:t.length)>0&&await te(!1)}),{deep:!0,immediate:!0}),ut({directPrint:ie}),(e,n)=>(o(),s(u,null,[c("div",K,[d(" 外显按钮集合 "),p(m(I),null,{default:v((()=>[(o(!0),s(u,null,y(Pt.value,(e=>(o(),f(m(T),{key:e.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:Gt,options:m(kt),onSelect:t=>qt(t,e,!0)},{default:v((()=>[p(m(L),{loading:t.showLoading&&e.isLoading,onClick:t=>Rt(e.templateCode,e.templateId,e.key,!0)},{icon:v((()=>[p(m(M),{component:m(E),size:"18"},null,8,["component"])])),default:v((()=>[g(" "+k(e.label),1)])),_:2},1032,["loading","onClick"])])),_:2},1032,["options","onSelect"])))),128))])),_:1}),d(' <n-button-group>\r\n\t\t\t<n-popover\r\n\t\t\t\tv-for="outer in outerPrintItems"\r\n :key="outer.key"\r\n\t\t\t\ttrigger="hover"\r\n\t\t\t\t:show-arrow="false"\r\n\t\t\t\t:show="downlistPopover.isOperation"\r\n\t\t\t\t@clickoutside="handleClickOutHide(\'isOperation\')"\r\n\t\t\t>\r\n\t\t\t\t<template #trigger>\r\n\t\t\t\t\t<n-button\r\n\t\t\t\t\t\t@mouseenter="delayShowPopover(\'isOperation\')"\r\n\t\t\t\t\t\t@mouseleave="handleClickOutHide(\'isOperation\')"\r\n\t\t\t\t\t\t@click="console.log(33)"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t<n-icon :component="PrintOutline" size="18"></n-icon>\r\n\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t<span class="label bold">{{ outer.label }}</span>\r\n\t\t\t\t\t</n-button>\r\n\t\t\t\t</template>\r\n\t\t\t\t<div class="newprint-button-poperOver">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tclass="print-li"\r\n\t\t\t\t\t\tv-for="operation in operations"\r\n\t\t\t\t\t\t:key="operation.key"\r\n\t\t\t\t\t\t:class="downlistOperation.twoMouseType==operation.key ? \'active\' : \'\' "\r\n\t\t\t\t\t\t@mouseenter="handleTypeChange(\'twoMouseType\', operation.key)"\r\n\t\t\t\t\t\t@mouseleave="handleTypeChange(\'twoMouseType\', \'\')"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<div class="print-lite">\r\n\t\t\t\t\t\t\t<span class="label"> {{ operation.label }} </span>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</n-popover>\r\n\t\t</n-button-group> '),d(" 外显设置按钮 "),ft.isInited&&Pt.value.length>0&&Pt.value.length==m(Lt).length&&m(It)?(o(),f(m(F),{key:0,trigger:"click","show-arrow":!1,show:bt.isOutSetting,onClickoutside:n[2]||(n[2]=t=>_t("isOutSetting"))},{trigger:v((()=>[p(m(L),{onClick:n[0]||(n[0]=t=>Nt("isOutSetting"))},{default:v((()=>[B,p(m(M),{style:{"margin-left":"8px"},component:m(N),size:"18"},null,8,["component"])])),_:1})])),default:v((()=>[c("div",R,[(o(!0),s(u,null,y(m(Lt),(t=>(o(),s("div",{class:"print-li",key:t.key},[c("div",H,[c("span",q,k(t.label),1),p(m(j),{checked:t.selected,"onUpdate:checked":e=>t.selected=e},{default:v((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",G,[p(m(x)),c("div",Y,[p(m(L),{type:"primary",size:"small",onClick:Et},{default:v((()=>[g("保存")])),_:1}),p(m(j),{checked:m(Mt),"onUpdate:checked":n[1]||(n[1]=t=>h(Mt)?Mt.value=t:null)},{default:v((()=>[g("全选")])),_:1},8,["checked"])])])])])),_:1},8,["show"])):(o(),s(u,{key:1},[d(" 打印全部按钮 "),p(m(F),{trigger:"click","show-arrow":!1,show:bt.oneShow,onClickoutside:n[10]||(n[10]=t=>_t("oneShow"))},{trigger:v((()=>[b(e.$slots,"button",{handleClickPrintBtn:te,printSpinning:ft.spinning,printbtnText:t.btnText,printVisible:ft.visible},(()=>[p(m(I),{class:"newprint-button-component",onClick:n[4]||(n[4]=w((()=>jt("icon")),["stop"]))},{default:v((()=>[p(m(L),{loading:t.showLoading&&ft.spinning,onClick:n[3]||(n[3]=w((()=>jt("button")),["stop"]))},{icon:v((()=>[p(m(M),{component:m(E),size:"18"},null,8,["component"])])),default:v((()=>[g(" "+k(m(Ct)?"打印全部":t.btnText),1)])),_:1},8,["loading"]),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(wt.value,(t=>(o(),s("div",{class:P(["print-li",ht.oneMouseType==t.key||ht.oneClickType==t.key?"active":""]),key:t.key,onMouseenter:e=>xt("oneMouseType",t.key),onMouseleave:n[9]||(n[9]=t=>xt("oneMouseType","")),onClick:e=>{return n="oneClickType",i=t.key,void xt(n,i);var n,i}},["divider"==t.key?(o(),f(m(x),{key:0})):"outSetting"==t.key?(o(),s(u,{key:1},[d(" 第二层外显设置 "),p(m(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:bt.isOutSetting,onClickoutside:n[7]||(n[7]=t=>_t("isOutSetting"))},{trigger:v((()=>[c("div",{class:"print-lite",onClick:n[5]||(n[5]=t=>Nt("isOutSetting"))},[c("span",W,k(t.label),1),p(m(M),{style:{background:"transparent"},component:m(N),size:"18"},null,8,["component"])])])),default:v((()=>[c("div",X,[(o(!0),s(u,null,y(m(Lt),(t=>(o(),s("div",{class:"print-li",key:t.key},[c("div",Z,[c("span",tt,k(t.label),1),p(m(j),{checked:t.selected,"onUpdate:checked":e=>t.selected=e},{default:v((()=>[g("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),c("div",et,[p(m(x)),c("div",nt,[p(m(L),{type:"primary",size:"small",onClick:Et},{default:v((()=>[g("保存")])),_:1}),p(m(j),{checked:m(Mt),"onUpdate:checked":n[6]||(n[6]=t=>h(Mt)?Mt.value=t:null)},{default:v((()=>[g("全选")])),_:1},8,["checked"])])])])])),_:2},1032,["show"])],2112)):(o(),s(u,{key:2},[d(" 第二层功能操作 "),c("div",it,[c("span",{class:"label bold",onClick:e=>Rt(t.templateCode,t.templateId,t.key,!1)},k(t.label),9,rt),p(m(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:bt[t.key],onClickoutside:e=>_t(t.key)},{trigger:v((()=>[p(m(M),{component:m(D),size:"18",onClick:e=>Nt(t.key)},null,8,["component","onClick"])])),default:v((()=>[c("div",at,[(o(!0),s(u,null,y(m(kt),(e=>(o(),s("div",{class:P(["print-li",ht.twoMouseType==e.key?"active":""]),key:e.key,onMouseenter:t=>xt("twoMouseType",e.key),onMouseleave:n[8]||(n[8]=t=>xt("twoMouseType",""))},[c("div",ot,[c("span",{class:"label",onClick:n=>qt(e.key,t,!1)},k(e.label),9,st)])],42,lt)))),128))])])),_:2},1032,["show","onClickoutside"])])],2112))],42,Q)))),128))])])),_:3},8,["show"])],2112))]),p(V,O(e.$attrs,{modelValue:ft.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=t=>ft.identityVerification.visible=t),formatId:ft.currentFormatId,templateId:m(St),onSuccess:ne}),null,16,["modelValue","formatId","templateId"])],64))}});export{ut as default};
|
|
@@ -34,6 +34,7 @@ export declare class Print {
|
|
|
34
34
|
show(...args: Parameters<IdentityVerificationDialog['show']>): Promise<string>;
|
|
35
35
|
showPreview(...args: Parameters<PreviewDialog['show']>): Promise<string>;
|
|
36
36
|
_testConnection(): Promise<unknown>;
|
|
37
|
+
resetPrinter(formatId: string): Promise<unknown>;
|
|
37
38
|
_queryServicesPrint(params: AnyObject): Promise<any>;
|
|
38
39
|
_queryBase64ServicesPrint(params: AnyObject): Promise<any>;
|
|
39
40
|
_callPrintWithFile(queryParams: AnyObject): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as 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.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._isHiprint=!1,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this,m&&this._isHiprint&&this._initDomesticSystem();const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(){try{this.hiPrintSocket=h("http://127.0.0.1:17521",{reconnectionAttempts:3,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(t=>{this.printerList=t,console.log("获取到打印机列表信息>>>>>",t)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="",this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(t){console.log("hiprint系统连接失败",t)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{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)}))}))}_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({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,signature:l,btnprint:c,messageTimeout:h=0},p,d){const u=a(e);if(e=this.getIReportFormatId(u,e),u&&m&&this._isHiprint){const s=await this._queryPrintForPdf(t,e,i,r);if(!s)return null==d?void 0:d("获取文件失败!");const a=n(s,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,a),null==p?void 0:p({file:s})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:l,btnprint:c,messageTimeout:h}),n=this._handleResult(r,d);if(!n)return!1;if(this.isRemote){const t=await this._browserPrint(n,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}await this.getPicAndUpload(n),null==p||p(n)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h=1,isDownloadFile:p=!0,messageTimeout:d=0},u,f,g,w="printDirect"){const y=a(e);if(e=this.getIReportFormatId(y,e),y&&m&&this._isHiprint){if(!this.isConnectHiPrint)return void f({message:"请连接hiPrint客户端"});const s=await this._queryPrintForBase64(t,e,i,r);if(!s.success)return f({message:s.resultMsg});const{base64:n,formatId:a}=s.map;return this.base64Fragment=n,this._successCallbackFn=u,this._errorCallbackFn=f,void this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:a,pdf_stream:this.base64Fragment})}await this._queryProxyOrigin();const P=await this._testConnection();if(!this._handleResultTest(P,f))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:"7",print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h,messageTimeout:d}),a=this._handleResult(r,f,g);if(!a)return!1;p&&["downloadPDF"].includes(w)&&await this._browserPrint(a,w),null==u||u(a)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==f||f(i),this._handleMonitorNotify(i)}}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):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&&this._isHiprint){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{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`,g=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${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.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._isHiprint=!1,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this,m&&this._isHiprint&&this._initDomesticSystem();const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(){try{this.hiPrintSocket=h("http://127.0.0.1:17521",{reconnectionAttempts:3,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(t=>{this.printerList=t,console.log("获取到打印机列表信息>>>>>",t)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="",this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(t){console.log("hiprint系统连接失败",t)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{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 new Promise((e=>{p({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:t}}).then((({data:t})=>{"success"===t.result?e(!0):e(!1)})).catch((t=>{e(!1)}))}))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_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:g,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:f,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await r(`${y}/${a}/${o}`),c=n(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let s=i.length;const r=new Uint8Array(s);for(;s--;)r[s]=i.charCodeAt(s);return new Blob([r],{type:e})}async preview({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,signature:l,btnprint:c,messageTimeout:h=0},p,d){const u=a(e);if(e=this.getIReportFormatId(u,e),u&&m&&this._isHiprint){const s=await this._queryPrintForPdf(t,e,i,r);if(!s)return null==d?void 0:d("获取文件失败!");const a=n(s,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,a),null==p?void 0:p({file:s})}await this._queryProxyOrigin();const g=await this._testConnection();if(!this._handleResultTest(g,d))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:l,btnprint:c,messageTimeout:h}),n=this._handleResult(r,d);if(!n)return!1;if(this.isRemote){const t=await this._browserPrint(n,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}await this.getPicAndUpload(n),null==p||p(n)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:!1,errinfo:t})}}catch(t){const e={error:t,message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({templateId:t,formatId:e,params:i="",paramsArr:s,authorizationKey:r,print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h=1,isDownloadFile:p=!0,messageTimeout:d=0},u,g,f,w="printDirect"){const y=a(e);if(e=this.getIReportFormatId(y,e),y&&m&&this._isHiprint){if(!this.isConnectHiPrint)return void g({message:"请连接hiPrint客户端"});const s=await this._queryPrintForBase64(t,e,i,r);if(!s.success)return g({message:s.resultMsg});const{base64:n,formatId:a}=s.map;return this.base64Fragment=n,this._successCallbackFn=u,this._errorCallbackFn=g,void this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:a,pdf_stream:this.base64Fragment})}await this._queryProxyOrigin();const P=await this._testConnection();if(!this._handleResultTest(P,g))return!1;try{const r=await this._handleEventDirect({templateId:t,formatId:e,params:i,paramsArr:s,cmdid:"7",print:n,signature:o,printdlgshow:l,nobillnode:c,copies:h,messageTimeout:d}),a=this._handleResult(r,g,f);if(!a)return!1;p&&["downloadPDF"].includes(w)&&await this._browserPrint(a,w),null==u||u(a)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e}:{message:e};null==g||g(i),this._handleMonitorNotify(i)}}_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&&this._isHiprint){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e})):null==s?void 0:s("获取文件失败!")}this.printDirect(t,(async t=>{t||s(null);const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
|
|
@@ -222,6 +222,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
222
222
|
type: BooleanConstructor;
|
|
223
223
|
default: boolean;
|
|
224
224
|
};
|
|
225
|
+
draggable: {
|
|
226
|
+
type: BooleanConstructor;
|
|
227
|
+
default: boolean;
|
|
228
|
+
};
|
|
229
|
+
isFieldSet: {
|
|
230
|
+
type: BooleanConstructor;
|
|
231
|
+
default: boolean;
|
|
232
|
+
};
|
|
225
233
|
}, {
|
|
226
234
|
fixedWayOptions: {
|
|
227
235
|
label: string;
|
|
@@ -298,6 +306,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
298
306
|
type: BooleanConstructor;
|
|
299
307
|
default: boolean;
|
|
300
308
|
};
|
|
309
|
+
draggable: {
|
|
310
|
+
type: BooleanConstructor;
|
|
311
|
+
default: boolean;
|
|
312
|
+
};
|
|
313
|
+
isFieldSet: {
|
|
314
|
+
type: BooleanConstructor;
|
|
315
|
+
default: boolean;
|
|
316
|
+
};
|
|
301
317
|
}>> & {
|
|
302
318
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
303
319
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -395,6 +411,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
395
411
|
type: BooleanConstructor;
|
|
396
412
|
default: boolean;
|
|
397
413
|
};
|
|
414
|
+
draggable: {
|
|
415
|
+
type: BooleanConstructor;
|
|
416
|
+
default: boolean;
|
|
417
|
+
};
|
|
418
|
+
isFieldSet: {
|
|
419
|
+
type: BooleanConstructor;
|
|
420
|
+
default: boolean;
|
|
421
|
+
};
|
|
398
422
|
}>> & {
|
|
399
423
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
400
424
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -437,9 +461,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
437
461
|
requiredDisable: boolean;
|
|
438
462
|
hide: boolean;
|
|
439
463
|
}>;
|
|
464
|
+
draggable: boolean;
|
|
440
465
|
isHighlightRow: boolean;
|
|
441
466
|
idx: number;
|
|
442
467
|
isHighlight: boolean;
|
|
468
|
+
isFieldSet: boolean;
|
|
443
469
|
}>;
|
|
444
470
|
EditDialog: import("vue").DefineComponent<{
|
|
445
471
|
visible: {
|
|
@@ -243,6 +243,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
243
243
|
type: BooleanConstructor;
|
|
244
244
|
default: boolean;
|
|
245
245
|
};
|
|
246
|
+
draggable: {
|
|
247
|
+
type: BooleanConstructor;
|
|
248
|
+
default: boolean;
|
|
249
|
+
};
|
|
250
|
+
isFieldSet: {
|
|
251
|
+
type: BooleanConstructor;
|
|
252
|
+
default: boolean;
|
|
253
|
+
};
|
|
246
254
|
}, {
|
|
247
255
|
fixedWayOptions: {
|
|
248
256
|
label: string;
|
|
@@ -319,6 +327,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
319
327
|
type: BooleanConstructor;
|
|
320
328
|
default: boolean;
|
|
321
329
|
};
|
|
330
|
+
draggable: {
|
|
331
|
+
type: BooleanConstructor;
|
|
332
|
+
default: boolean;
|
|
333
|
+
};
|
|
334
|
+
isFieldSet: {
|
|
335
|
+
type: BooleanConstructor;
|
|
336
|
+
default: boolean;
|
|
337
|
+
};
|
|
322
338
|
}>> & {
|
|
323
339
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
324
340
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -416,6 +432,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
416
432
|
type: BooleanConstructor;
|
|
417
433
|
default: boolean;
|
|
418
434
|
};
|
|
435
|
+
draggable: {
|
|
436
|
+
type: BooleanConstructor;
|
|
437
|
+
default: boolean;
|
|
438
|
+
};
|
|
439
|
+
isFieldSet: {
|
|
440
|
+
type: BooleanConstructor;
|
|
441
|
+
default: boolean;
|
|
442
|
+
};
|
|
419
443
|
}>> & {
|
|
420
444
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
421
445
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -458,9 +482,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
458
482
|
requiredDisable: boolean;
|
|
459
483
|
hide: boolean;
|
|
460
484
|
}>;
|
|
485
|
+
draggable: boolean;
|
|
461
486
|
isHighlightRow: boolean;
|
|
462
487
|
idx: number;
|
|
463
488
|
isHighlight: boolean;
|
|
489
|
+
isFieldSet: boolean;
|
|
464
490
|
}>;
|
|
465
491
|
setStyle: typeof setStyle;
|
|
466
492
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "save" | "reset")[], "close" | "save" | "reset", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -66,6 +66,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
66
66
|
fieldShowMaxValue: {
|
|
67
67
|
type: NumberConstructor;
|
|
68
68
|
};
|
|
69
|
+
rowDraggable: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
69
73
|
}, {
|
|
70
74
|
fieldsMapping: Record<string, string>;
|
|
71
75
|
attrs: {
|
|
@@ -134,6 +138,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
134
138
|
fieldShowMaxValue: {
|
|
135
139
|
type: NumberConstructor;
|
|
136
140
|
};
|
|
141
|
+
rowDraggable: {
|
|
142
|
+
type: BooleanConstructor;
|
|
143
|
+
default: boolean;
|
|
144
|
+
};
|
|
137
145
|
}>> & {
|
|
138
146
|
onReset?: ((...args: any[]) => any) | undefined;
|
|
139
147
|
onSave?: ((...args: any[]) => any) | undefined;
|
|
@@ -176,6 +184,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
176
184
|
checked: boolean;
|
|
177
185
|
column: AnyObject;
|
|
178
186
|
}) => void;
|
|
187
|
+
draggable: boolean;
|
|
188
|
+
isFieldSet: boolean;
|
|
179
189
|
};
|
|
180
190
|
searchData: {
|
|
181
191
|
keyword: string;
|
|
@@ -340,6 +350,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
340
350
|
type: BooleanConstructor;
|
|
341
351
|
default: boolean;
|
|
342
352
|
};
|
|
353
|
+
draggable: {
|
|
354
|
+
type: BooleanConstructor;
|
|
355
|
+
default: boolean;
|
|
356
|
+
};
|
|
357
|
+
isFieldSet: {
|
|
358
|
+
type: BooleanConstructor;
|
|
359
|
+
default: boolean;
|
|
360
|
+
};
|
|
343
361
|
}, {
|
|
344
362
|
fixedWayOptions: {
|
|
345
363
|
label: string;
|
|
@@ -416,6 +434,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
416
434
|
type: BooleanConstructor;
|
|
417
435
|
default: boolean;
|
|
418
436
|
};
|
|
437
|
+
draggable: {
|
|
438
|
+
type: BooleanConstructor;
|
|
439
|
+
default: boolean;
|
|
440
|
+
};
|
|
441
|
+
isFieldSet: {
|
|
442
|
+
type: BooleanConstructor;
|
|
443
|
+
default: boolean;
|
|
444
|
+
};
|
|
419
445
|
}>> & {
|
|
420
446
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
421
447
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -513,6 +539,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
513
539
|
type: BooleanConstructor;
|
|
514
540
|
default: boolean;
|
|
515
541
|
};
|
|
542
|
+
draggable: {
|
|
543
|
+
type: BooleanConstructor;
|
|
544
|
+
default: boolean;
|
|
545
|
+
};
|
|
546
|
+
isFieldSet: {
|
|
547
|
+
type: BooleanConstructor;
|
|
548
|
+
default: boolean;
|
|
549
|
+
};
|
|
516
550
|
}>> & {
|
|
517
551
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
518
552
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -555,9 +589,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
555
589
|
requiredDisable: boolean;
|
|
556
590
|
hide: boolean;
|
|
557
591
|
}>;
|
|
592
|
+
draggable: boolean;
|
|
558
593
|
isHighlightRow: boolean;
|
|
559
594
|
idx: number;
|
|
560
595
|
isHighlight: boolean;
|
|
596
|
+
isFieldSet: boolean;
|
|
561
597
|
}>;
|
|
562
598
|
isArray: {
|
|
563
599
|
(value?: any): value is any[];
|
|
@@ -629,6 +665,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
629
665
|
fieldShowMaxValue: {
|
|
630
666
|
type: NumberConstructor;
|
|
631
667
|
};
|
|
668
|
+
rowDraggable: {
|
|
669
|
+
type: BooleanConstructor;
|
|
670
|
+
default: boolean;
|
|
671
|
+
};
|
|
632
672
|
}>> & {
|
|
633
673
|
onReset?: ((...args: any[]) => any) | undefined;
|
|
634
674
|
onSave?: ((...args: any[]) => any) | undefined;
|
|
@@ -654,6 +694,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
654
694
|
hide: boolean;
|
|
655
695
|
}>[];
|
|
656
696
|
isEdit: boolean;
|
|
697
|
+
rowDraggable: boolean;
|
|
657
698
|
showSeq: boolean;
|
|
658
699
|
footerFlag: boolean;
|
|
659
700
|
customColumns: FieldSetColumnItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,useAttrs as l,ref as t,computed as i,reactive as o,watch as
|
|
1
|
+
import{defineComponent as e,useAttrs as l,ref as t,computed as i,reactive as o,watch as a,openBlock as d,createElementBlock as r,createBlock as s,unref as n,withKeys as u,withModifiers as c,createCommentVNode as f,createElementVNode as h,Fragment as p,renderList as m,normalizeStyle as y,withCtx as v,createTextVNode as b,toDisplayString as g,createVNode as k,normalizeClass as x,mergeProps as w,renderSlot as S}from"vue";import{NInput as A,NCheckbox as _,NTooltip as C,NIcon as F,NPopconfirm as W,NButton as E}from"naive-ui";import H from"../../../shared/components/VueDraggable/src/vuedraggable.js";import N from"./components/Row.vue.js";import{isArray as P,cloneDeep as q,isString as B,omit as R}from"lodash-es";import{isDisable as V,setStyle as j,isDraggableItem as D,isDraggable as I,getGroupTree as M}from"./utils/index.js";import{uuidGenerator as U}from"../../../shared/utils/index.js";import{HelpCircleSharp as O}from"@vicons/ionicons5";const T={class:"main-wrapper"},K={class:"main-wrapper__table-header"},G=h("span",null,"数值越小,优先级越高",-1),L=["tabindex"],$={key:1,class:"main-wrapper__table-footer"};var z=e({__name:"FieldSet",props:{fields:{type:Array,default:()=>[]},footerFlag:{type:Boolean,default:!0},type:{type:String,default:"old"},isEdit:{type:Boolean,default:!1},showColumnNames:{type:Array},groupSetting:{type:Object},customColumns:{type:Array,default:()=>[]},showSeq:{type:Boolean,default:!1},showSearch:{type:Boolean,default:!1},showSortPriority:{type:Boolean,default:!1},showHeadFilter:{type:Boolean,default:!1},fieldShowMaxValue:{type:Number},rowDraggable:{type:Boolean,default:!0}},emits:["save","close","reset"],setup(e,{expose:z,emit:J}){const Q=e,X={sid:"id",columnName:"name",isShow:"show",isSort:"sort",isFixed:"fixedWay",colWidth:"columnWidth"},Y=l(),Z=t(""),ee=t(),le=t([]),te=t([{title:"所有字段",type:"text",field:"title"},{title:"显示",type:"checkbox",checkedAll:!1,disabledAll:!!Q.fieldShowMaxValue,field:"show",fieldShowMaxValue:Q.fieldShowMaxValue},{title:"编辑",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"editable"},{title:"必填",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"required"},{title:"排序",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"sort"},{title:"加粗",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"bold"},{title:"默认排序",type:"select",field:"sortDirection"},{title:"排序优先级",type:"select",field:"sortPriority"},{title:"固定",type:"select",field:"fixedWay"},{title:"自定义标题",type:"input",field:"alias"},{title:"列宽",type:"inputNumber",field:"columnWidth"},{title:"表头筛选",type:"checkbox",isHeadCheckHide:!0,field:"isShowHeaderFilter"}]),ie=i((()=>le.value.flat())),oe=o({columns:te,data:ie,onUpdateChecked:function({checked:e,column:l}){const t=!e||he(l.field);l.checkedAll=!t},draggable:Q.rowDraggable,isFieldSet:!0}),ae={keyword:Z.value,idx:0,startIdx:0},de=()=>{J("save")},re=()=>{J("close")};function se(){le.value=ne(),fe(),J("reset")}function ne(){const e=q(Q.fields).map((e=>({...e,uuid:U()})));return Object.keys(X).forEach((l=>{e.forEach((e=>{"old"==Q.type&&Reflect.has(e,l)&&("isFixed"==l?e.fixedWay=1==e[l]?"LEFT":2==e[l]?"RIGHT":"NONE":["isShow","isSort"].includes(l)&&"boolean"!=typeof l?e[X[l]]=1==e[l]:e[X[l]]=e[l],Reflect.deleteProperty(e,l)),e.columnWidth=+e.columnWidth||null,Reflect.has(e,"alias")||(e.alias=""),Reflect.has(e,"bold")||(e.bold=!1),e.draggable=!!I(e)}))})),function(e){if(Q.groupSetting){return M(Q.groupSetting,e).reduce(((t,i)=>{const o=B(i)?e.find((e=>e.name===i)):l(i.children);return o&&t.push(o),t}),[])}return e;function l(t){const i=[];return t.forEach((t=>{if(t.children)i.push(...l(t.children));else{const l=e.find((e=>e.name===t));l&&i.push(l)}})),i}}(e)}function ue(){const e=ae.keyword!==Z.value;let l=Z.value?ie.value.findIndex(((l,t)=>{var i;if(null==(i=l.title)?void 0:i.includes(Z.value))return!!e||t>ae.idx})):0;-1!==l||e||(l=ae.startIdx),ee.value.scrollTop=Y.rowHeight*l,Object.assign(ae,{keyword:Z.value,idx:l},e?{startIdx:l}:{})}function ce(e){var l;return!!Z.value&&(null==(l=e.title)?void 0:l.includes(Z.value))}function fe(){var e,l;(null==(e=Q.showColumnNames)?void 0:e.length)&&(te.value=te.value.filter((e=>{var l,t;return"title"===e.field||(null==(t=null==(l=Q.showColumnNames)?void 0:l.includes)?void 0:t.call(l,e.field))}))),(null==(l=Q.customColumns)?void 0:l.length)&&te.value.push(...Q.customColumns),Q.showSeq&&te.value.splice(1,0,{title:"排序",type:"text",field:"seq"}),te.value.forEach((e=>{if(e.isShow=function(e){return!(["editable","required"].includes(e.field)&&!Q.isEdit||"sortPriority"===e.field&&!Q.showSortPriority||"isShowHeaderFilter"===e.field&&!Q.showHeadFilter)}(e),"checkbox"===e.type){const l=le.value.flat().every((l=>!Reflect.has(l,e.field)));e.checkedAll=!he(e.field)&&!l}}))}function he(e){return le.value.flat().some((l=>!V(l,e)&&!l[e]&&"0001"!=l.id))}function pe(e){return!!D(e.relatedContext.element)}return a([()=>Q.fields,()=>{var e;return null==(e=Q.showColumnNames)?void 0:e.length}],(([e,l])=>{e.length>0&&(le.value=ne(),fe())}),{immediate:!0,deep:!0}),z({getTableFields:function(){let e=[];return e="old"==Q.type?ie.value.map(((e,l)=>({id:e.id,field:e.name,visible:e.show,sequence:l,sortable:e.sort,title:e.alias,fixed:e.fixedWay,minWidth:e.columnWidth,bold:e.bold,sortDirection:e.sortDirection,sortPriority:e.sortPriority,...Q.isEdit?{required:e.required,editable:e.editable}:{}}))):ie.value,e.map((e=>R(e,["uuid"])))}}),(l,t)=>(d(),r("div",T,[e.showSearch?(d(),s(n(A),{key:0,class:"main-wrapper__search-wrapper",value:Z.value,"onUpdate:value":t[0]||(t[0]=e=>Z.value=e),valueModifiers:{trim:!0},placeholder:"请输入字段标题",onKeydown:u(c(ue,["prevent"]),["enter"])},null,8,["value","onKeydown"])):f("v-if",!0),h("div",K,[(d(!0),r(p,null,m(te.value,((e,l)=>(d(),r(p,{key:l},[e.isShow?(d(),r("span",{key:0,class:"table-cell",style:y(n(j)(e,l))},["checkbox"!==e.type||e.isHeadCheckHide?(d(),r(p,{key:1},[b(g(e.title),1)],64)):(d(),s(n(_),{key:0,checked:e.checkedAll,"onUpdate:checked":[l=>e.checkedAll=l,l=>{return t=l,i=e.field,void ie.value.forEach((e=>{V(e,i)||(e[i]=t)}));var t,i}],disabled:e.disabledAll},{default:v((()=>[b(g(e.title),1)])),_:2},1032,["checked","onUpdate:checked","disabled"])),"sortPriority"===e.field?(d(),s(n(C),{key:2,trigger:"hover"},{trigger:v((()=>[k(n(F),{component:n(O),style:{top:"2px"}},null,8,["component"])])),default:v((()=>[G])),_:1})):f("v-if",!0)],4)):f("v-if",!0)],64)))),128))]),h("div",{class:"main-wrapper__table-body",ref_key:"tableBodyRef",ref:ee},[k(n(H),{modelValue:le.value,"onUpdate:modelValue":t[1]||(t[1]=e=>le.value=e),animation:"150","item-key":"id",filter:".disabled",draggable:".item",move:pe,disabled:!e.rowDraggable},{item:v((({element:e,index:l})=>[e.hide?f("v-if",!0):(d(),r("div",{key:0,class:x(["item",n(D)(e)?"":"disabled"]),tabindex:l},[n(P)(e)?(d(!0),r(p,{key:0},m(e,((e,t)=>(d(),s(N,w(oe,{key:t,element:e,idx:l+1,"is-highlight":ce(e)}),null,16,["element","idx","is-highlight"])))),128)):(d(),s(N,w({key:1},oe,{element:e,idx:l+1,"is-highlight":ce(e)}),null,16,["element","idx","is-highlight"]))],10,L))])),_:1},8,["modelValue","disabled"])],512),e.footerFlag?(d(),r("div",$,[f(" 底部按钮插槽 "),S(l.$slots,"footer",{},(()=>[k(n(W),{onPositiveClick:se},{trigger:v((()=>[k(n(E),{style:{"margin-right":"8px"}},{default:v((()=>[b("恢复默认设置")])),_:1})])),default:v((()=>[b(" 确认要恢复系统默认设置吗? ")])),_:1}),k(n(E),{style:{"margin-right":"8px"},onClick:re},{default:v((()=>[b("取消")])),_:1}),k(n(E),{type:"primary",onClick:de},{default:v((()=>[b("保存")])),_:1})]))])):f("v-if",!0)]))}});export{z as default};
|
|
@@ -64,6 +64,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
64
64
|
type: BooleanConstructor;
|
|
65
65
|
default: boolean;
|
|
66
66
|
};
|
|
67
|
+
draggable: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: boolean;
|
|
70
|
+
};
|
|
71
|
+
isFieldSet: {
|
|
72
|
+
type: BooleanConstructor;
|
|
73
|
+
default: boolean;
|
|
74
|
+
};
|
|
67
75
|
}, {
|
|
68
76
|
fixedWayOptions: {
|
|
69
77
|
label: string;
|
|
@@ -140,6 +148,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
140
148
|
type: BooleanConstructor;
|
|
141
149
|
default: boolean;
|
|
142
150
|
};
|
|
151
|
+
draggable: {
|
|
152
|
+
type: BooleanConstructor;
|
|
153
|
+
default: boolean;
|
|
154
|
+
};
|
|
155
|
+
isFieldSet: {
|
|
156
|
+
type: BooleanConstructor;
|
|
157
|
+
default: boolean;
|
|
158
|
+
};
|
|
143
159
|
}>> & {
|
|
144
160
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
145
161
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -237,6 +253,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
237
253
|
type: BooleanConstructor;
|
|
238
254
|
default: boolean;
|
|
239
255
|
};
|
|
256
|
+
draggable: {
|
|
257
|
+
type: BooleanConstructor;
|
|
258
|
+
default: boolean;
|
|
259
|
+
};
|
|
260
|
+
isFieldSet: {
|
|
261
|
+
type: BooleanConstructor;
|
|
262
|
+
default: boolean;
|
|
263
|
+
};
|
|
240
264
|
}>> & {
|
|
241
265
|
onUpdateChecked?: ((...args: any[]) => any) | undefined;
|
|
242
266
|
onEdit?: ((...args: any[]) => any) | undefined;
|
|
@@ -279,8 +303,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
279
303
|
requiredDisable: boolean;
|
|
280
304
|
hide: boolean;
|
|
281
305
|
}>;
|
|
306
|
+
draggable: boolean;
|
|
282
307
|
isHighlightRow: boolean;
|
|
283
308
|
idx: number;
|
|
284
309
|
isHighlight: boolean;
|
|
310
|
+
isFieldSet: boolean;
|
|
285
311
|
}>;
|
|
286
312
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,openBlock as t,createElementBlock as l,Fragment as i,renderList as n,normalizeStyle as a,unref as
|
|
1
|
+
import{defineComponent as e,openBlock as t,createElementBlock as l,Fragment as i,renderList as n,normalizeStyle as a,unref as o,createBlock as r,withCtx as u,createVNode as d,createCommentVNode as s,createElementVNode as c,toDisplayString as f,normalizeClass as p,withDirectives as m,vShow as v,resolveDynamicComponent as y,createTextVNode as g}from"vue";import{NTooltip as h,NIcon as b,NCheckbox as k,NSelect as x,NColorPicker as E,NInput as S,NInputNumber as T,NPopconfirm as w}from"naive-ui";import{setStyle as C,setColorInfo as N,isShowExplicitRequired as U,isDisable as D}from"../utils/index.js";import{ReorderTwoOutline as _,HelpCircleOutline as O,CreateOutline as j,TrashOutline as R}from"@vicons/ionicons5";import{isFunction as A,isArray as H,range as L}from"lodash-es";import{COLOR_MAP as M}from"../constants/index.js";import{WIDGET_TYPE as P,SELECT_MAP as F,WIDGET_MAP as V,SELECT_TYPE as I,SELECT_DEFAULT_MAP as B,DATE_MAP as q,DATETIME_MAP as W}from"../constants/filter.js";const G={class:"row"},z=["title"],J=c("span",null,"拖拽调整顺序",-1);var K=e({__name:"Row",props:{element:{type:Object,default:()=>({})},columns:{type:Array,default:()=>[]},idx:{type:Number,default:1},data:{type:Array,default:()=>[]},isHighlight:{type:Boolean},index:{type:Number,default:0},isHighlightRow:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},isFieldSet:{type:Boolean,default:!1}},emits:["updateChecked","edit"],setup(e,{emit:K}){const Q=e,X=[{label:"不固定",value:"NONE"},{label:"左固定",value:"LEFT"},{label:"右固定",value:"RIGHT"}],Y=[{label:"不排序",value:"NONE"},{label:"升序",value:"ASC"},{label:"降序",value:"DESC"}],Z=[{label:"字体",value:"font"},{label:"背景",value:"background"}],$=Object.entries(M).map((([e])=>e));function ee(){Q.data.splice(Q.index,1)}function te(){K("edit",Q.element)}function le(e){if("defaultValue"===e){const{optionType:e}=Q.element;return e===I.SELECT_MULTIPLE}return!1}function ie(e){if("0001"==Q.element.id&&"fixedWay"!=e)return!1;const{isConfiguredHeaderFilter:t}=Q.element;return"isShowHeaderFilter"===e?!!t:!(["explicitRequired","defaultValue"].includes(e)&&![P.DATE,P.DATETIME,P.SELECT].includes(Q.element.type))}function ne(e){return!["explicitRequired","defaultValue"].includes(e)||U(Q.element)}function ae(e){switch(e.field){case"fixedWay":return X;case"sortDirection":return Y;case"sortPriority":return function(){const e=L(1,Q.data.length+1).map((e=>({label:e.toString(),value:e}))),t=Q.data.filter((e=>!!e.sortPriority&&e.uuid!==Q.element.uuid)).map((e=>e.sortPriority));return e.filter((e=>!t.includes(e.value)))}();case"colorScope":return Z;case"defaultValue":{const{type:e,optionInfo:t}=Q.element;return e===P.SELECT?H(null==t?void 0:t.list)&&t.list.length>0?t.list.map((e=>({...e,label:e.name}))):Object.entries(B).map((([e,t])=>({value:e,label:t}))):e===P.DATE?Object.entries(q).map((([e,t])=>({value:e,label:t}))):e===P.DATETIME?Object.entries(W).map((([e,t])=>({value:e,label:t}))):[]}default:return[]}}function oe(e){var t;if(1==Q.element.defaultMark||"color"===e.type&&Q.isHighlightRow)return!0;if("checkbox"===e.type)return"show"===e.field&&e.fieldShowMaxValue?!Q.element[e.field]&&(null==(t=Q.data.filter((t=>t[e.field])))?void 0:t.length)===e.fieldShowMaxValue:D(Q.element,e.field);if("sortPriority"!==e.field)return!1;const{sortDirection:l}=Q.element;return!l||"NONE"===l}function re(e){return["title","result"].includes(e.field)&&Q.element.style||{}}return(U,D)=>(t(),l("div",G,[(t(!0),l(i,null,n(e.columns,((n,U)=>{return t(),l(i,{key:U},[n.isShow?(t(),l("span",{key:0,class:"table-cell",title:e.element[n.field],style:a(o(C)(n,U))},["text"===n.type?(t(),l(i,{key:0},[0===U?(t(),l(i,{key:0},[!e.isFieldSet||e.draggable&&e.isFieldSet?(t(),r(o(h),{key:0,trigger:"hover"},{trigger:u((()=>[d(o(b),{style:{"margin-right":"5px",top:"2px"},component:o(_)},null,8,["component"])])),default:u((()=>[J])),_:1})):s("v-if",!0),"title"===n.field&&e.element.feildDescribe?(t(),r(o(h),{key:1,trigger:"hover"},{trigger:u((()=>[d(o(b),{style:{"margin-right":"5px",top:"2px"},component:o(O)},null,8,["component"])])),default:u((()=>[c("span",null,f(e.element.feildDescribe),1)])),_:1})):s("v-if",!0)],64)):s("v-if",!0),c("span",{class:p([e.isHighlight&&"title"===n.field?"highlight":""]),style:a(re(n))},f((H=n.field,"seq"===H?Q.idx:"optionType"===H?Q.element[H]&&Q.element.type===P.SELECT?F[Q.element[H]]:"":"type"===H?V[Q.element[H]]:Q.element[H])),7)],64)):s("v-if",!0),"checkbox"===n.type&&ie(n.field)?m((t(),r(o(k),{key:1,disabled:oe(n),checked:e.element[n.field],"onUpdate:checked":[t=>e.element[n.field]=t,e=>function(e,t){K("updateChecked",{checked:e,column:t})}(e,n)]},null,8,["disabled","checked","onUpdate:checked"])),[[v,ne(n.field)]]):s("v-if",!0),"select"===n.type&&ie(n.field)?m((t(),r(o(x),{key:2,clearable:"",multiple:le(n.field),disabled:oe(n),value:e.element[n.field],"onUpdate:value":[t=>e.element[n.field]=t,e=>function(e,t){"sortDirection"===t.field&&"NONE"===e&&(Q.element.sortPriority=null),"colorScope"===t.field&&N(Q.element)}(e,n)],options:ae(n)},null,8,["multiple","disabled","value","onUpdate:value","options"])),[[v,ne(n.field)]]):s("v-if",!0),"color"===n.type?(t(),r(o(E),{key:3,class:"c-field-set__color-picker",clearable:"",disabled:oe(n),value:e.element[n.field],"onUpdate:value":[t=>e.element[n.field]=t,D[0]||(D[0]=t=>o(N)(e.element))],"show-preview":"",modes:["hex"],swatches:o($)},null,8,["disabled","value","onUpdate:value","swatches"])):s("v-if",!0),"input"===n.type?m((t(),r(o(S),{key:4,value:e.element[n.field],"onUpdate:value":t=>e.element[n.field]=t,clearable:""},null,8,["value","onUpdate:value"])),[[v,"0001"!=e.element.id]]):s("v-if",!0),"inputNumber"===n.type?(t(),r(o(T),{key:5,value:e.element[n.field],"onUpdate:value":t=>e.element[n.field]=t},null,8,["value","onUpdate:value"])):s("v-if",!0),"custom"===n.type&&o(A)(n.contentRender)?(t(),r(y((()=>n.contentRender(n,e.element))),{key:6})):s("v-if",!0),"custom"===n.type&&"opt"===n.field&&1!=e.element.defaultMark?(t(),l(i,{key:7},[d(o(h),{trigger:"hover"},{trigger:u((()=>[d(o(b),{component:o(j),onClick:te},null,8,["component"])])),default:u((()=>[g(" 编辑 ")])),_:1}),d(o(w),{onPositiveClick:ee},{trigger:u((()=>[d(o(h),{trigger:"hover"},{trigger:u((()=>[d(o(b),{component:o(R)},null,8,["component"])])),default:u((()=>[g(" 删除 ")])),_:1})])),default:u((()=>[g(" 是否确认删除? ")])),_:1})],64)):s("v-if",!0)],12,z)):s("v-if",!0)],64);var H})),128))]))}});export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as e,isObject as t}from"lodash-es";import{IhoTableRowGroupSequence as o}from"../../../iho-table/src/constants/index.js";import{COLOR_MAP as n}from"../constants/index.js";import{WIDGET_TYPE as r}from"../constants/filter.js";function i(e,t){const o={flex:"1 1 90px"};switch(e.type){case"text":0===t&&["title","name"].includes(e.field)&&Object.assign(o,{flex:"
|
|
1
|
+
import{isArray as e,isObject as t}from"lodash-es";import{IhoTableRowGroupSequence as o}from"../../../iho-table/src/constants/index.js";import{COLOR_MAP as n}from"../constants/index.js";import{WIDGET_TYPE as r}from"../constants/filter.js";function i(e,t){const o={flex:"1 1 90px"};switch(e.type){case"text":0===t&&["title","name"].includes(e.field)&&Object.assign(o,{flex:"1 1 120px",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"}),"seq"===e.field&&(o.flex="1 1 40px");break;case"checkbox":o.flex="1 1 60px";break;case"select":o.flex="1 1 80px";break;case"input":o.flex="1 1 100px"}return o}function l(e,t){return["editable","required","show"].includes(t)&&(e[`${t}Disable`]||e[`${t}Disabled`])||["sort"].includes(t)&&(1==e.notParticipatingSort||e.sortDisabled)}function s(n,r,i=(e=>e.name)){const l=r.map((e=>i(e)));return o.some((o=>{const r=n[o];if(!e(r))return!0;r.forEach((o=>{if(!e(o.list)||!o.list.length)return;const n=[];let r=null;o.list.forEach(((e,i)=>{const s=function(e,o,n){return o.findIndex((o=>o!==n&&(t(o)?o.fieldName:o)===e))}(e,l,r);~s&&(n.push(l[s]),0===i?l.splice(s,1,r={fieldName:o.title,children:n}):l.splice(s,1))}))}))})),l}function c(e){return void 0===e.draggable||e.draggable}function a(t){return e(t)?!t.some((e=>!e.draggable)):t.draggable}function f(e){e.style="font"===e.colorScope?{color:e.color}:{background:e.color,color:"#fff"},e.result=n[e.color]}function u(e){const{isShowSearch:t,filterExplicit:o,type:n}=e;return t&&o&&[r.DATE,r.DATETIME,r.SELECT].includes(n)}export{s as getGroupTree,l as isDisable,c as isDraggable,a as isDraggableItem,u as isShowExplicitRequired,f as setColorInfo,i as setStyle};
|
|
@@ -17,6 +17,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
17
17
|
tBodyHeight: import("vue").Ref<number>;
|
|
18
18
|
tHeaderHeight: import("vue").Ref<number>;
|
|
19
19
|
calcRectInfo: () => void;
|
|
20
|
+
isWheeling: boolean;
|
|
20
21
|
onWheel: () => Promise<void>;
|
|
21
22
|
isDragging: boolean;
|
|
22
23
|
onScroll: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,inject as l,computed as t,ref as r,onMounted as a,nextTick as n,unref as o,openBlock as u,createElementBlock as c,normalizeStyle as i,createElementVNode as s,createCommentVNode as v}from"vue";import{widthAppend as p}from"../../../../../shared/utils/index.js";import{useElementSize as d,useThrottleFn as f,useEventListener as g}from"@vueuse/core";import{InjectionIhoTableGlobProps as h}from"../../constants/index.js";import{useTableContext as m}from"../../hooks/useTableContext.js";import{isPagerScrollEnable as y,isTreeTable as w,scrollStateMap as I}from"./utils.js";var b=e({__name:"pagerScroll",setup(e){const{configRef:b,$table:x,eventListener:
|
|
1
|
+
import{defineComponent as e,inject as l,computed as t,ref as r,onMounted as a,nextTick as n,unref as o,openBlock as u,createElementBlock as c,normalizeStyle as i,createElementVNode as s,createCommentVNode as v}from"vue";import{widthAppend as p}from"../../../../../shared/utils/index.js";import{useElementSize as d,useThrottleFn as f,useEventListener as g}from"@vueuse/core";import{InjectionIhoTableGlobProps as h}from"../../constants/index.js";import{useTableContext as m}from"../../hooks/useTableContext.js";import{isPagerScrollEnable as y,isTreeTable as w,scrollStateMap as I}from"./utils.js";var b=e({__name:"pagerScroll",setup(e){const{configRef:b,$table:x,eventListener:T}=m(),D=l(h),S=t((()=>y(b.value))),_=r(),P=t((()=>{var e,l,t,r,a,n;const o=null!=(l=null==(e=b.value.rowConfig)?void 0:e.height)?l:36;if(w(b.value)){const e=null!=(t=b.value.treeConfig.children)?t:"children";return o*(null!=(r=D.tableData.reduce(((l,t)=>{var r;return l+((null==(r=t[e])?void 0:r.length)||0)+1}),0))?r:0)}return o*(null!=(n=null==(a=D.tableData)?void 0:a.length)?n:0)})),j=r(null),U=r(null),{height:k}=d(j),{height:q}=d(U);a((()=>{S.value&&b.value.uuid&&function(){const e=document.querySelector(`#${b.value.uuid} .vxe-table--main-wrapper`);if(!e)return;j.value=e.querySelector(".vxe-table--body-wrapper"),U.value=e.querySelector(".vxe-table--header-wrapper")}()})),T.addEventListener("scroll",f((({scrollTop:e})=>{var l,t;if(E||C)return;const r=I.getItemFromUUID(b.value.uuid);if(!r.capacityInfo||!k.value)return;const a=(r.capacityInfo[r.currentPage||0].percent||0)*(e/k.value);if(r.currentPage){const e=r.capacityInfo.slice(0,r.currentPage).reduce(((e,l)=>e+l.percent),0)+a;null==(l=_.value)||l.scrollTo({top:e*P.value})}else null==(t=_.value)||t.scrollTo({top:a*P.value})}),100));let C=!1;const W=f((async function(){var e,l,t,r,a,o;C=!0,setTimeout((()=>{C=!1}),100);const u=_.value;if(!u||!b.value.uuid)return;const c=u.scrollTop/u.scrollHeight,i=I.getItemFromUUID(b.value.uuid);let s=0,v=0;const p=null==(e=i.capacityInfo)?void 0:e.findIndex((e=>{if(s+=e.percent,s>=c)return v=1-(s-c)/e.percent,!0}));if(-1===p)return;p!==i.currentPage&&(i.currentPage=p,(null==(l=i.capacityInfo)?void 0:l[p])&&(await x.value.loadData([]),await x.value.loadData(i.capacityInfo[p].pageData),null==(t=x.value)||t.setAllTreeExpand(!0),await n()));const d=(null!=(a=null==(r=j.value)?void 0:r.scrollHeight)?a:0)*v;null==(o=x.value)||o.scrollTo(null,d)}),50);let E=!1;g(window,"mousedown",(()=>{E=!0})),g(window,"mouseup",(()=>{E=!1}));const F=function(){E&&W()};return(e,l)=>o(S)?(u(),c("div",{key:0,class:"iho-table__pagerScrollWrapper",style:i({height:o(p)(o(k)),top:o(p)(o(q))}),ref_key:"scrollWrapper",ref:_,onWheel:l[0]||(l[0]=(...e)=>o(W)&&o(W)(...e)),onScroll:F},[s("div",{class:"iho-table__pagerScrollPlaceholder",style:i({height:o(p)(o(P))})},null,4)],36)):v("v-if",!0)}});export{b as default};
|
|
@@ -4,7 +4,7 @@ import { VxeTableDefines } from 'vxe-table';
|
|
|
4
4
|
import { IhoTableLowCodeField } from '../../../../../../../components/iho-table';
|
|
5
5
|
declare const _default: import("vue").DefineComponent<{
|
|
6
6
|
value: {
|
|
7
|
-
type: PropType<string | number | (string | number)[]>;
|
|
7
|
+
type: PropType<string | number | (string | number)[] | null>;
|
|
8
8
|
};
|
|
9
9
|
column: {
|
|
10
10
|
type: PropType<VxeTableDefines.ColumnInfo>;
|
|
@@ -75,7 +75,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
75
75
|
};
|
|
76
76
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:value"[], "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
77
77
|
value: {
|
|
78
|
-
type: PropType<string | number | (string | number)[]>;
|
|
78
|
+
type: PropType<string | number | (string | number)[] | null>;
|
|
79
79
|
};
|
|
80
80
|
column: {
|
|
81
81
|
type: PropType<VxeTableDefines.ColumnInfo>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,inject as l,ref as o,computed as t,onBeforeUnmount as n,nextTick as
|
|
1
|
+
import{defineComponent as e,inject as l,ref as o,computed as t,onBeforeUnmount as n,nextTick as a,createVNode as r,toRaw as u}from"vue";import{arrayed as i}from"../../../../../../../shared/utils/index.js";import{isFunction as s,isEmpty as d,isArray as c,isObject as p,omit as v,cloneDeep as f,xor as y}from"lodash-es";import{NSelect as m}from"naive-ui";import{useVModel as h,useDebounceFn as w}from"@vueuse/core";import"date-fns";import"@vue/shared";import{useSelectAllowModify as b}from"../../../../../../../shared/hooks/selectHooks/useSelectAllowModify.js";import{useOptionFiltered as g}from"../../../../../../../shared/hooks/selectHooks/useOptionFiltered.js";import"../../../../../../../shared/hooks/selectHooks/useSearchContent.js";import{useSelectRenders as F}from"../../../../../../../shared/hooks/selectHooks/useSelectRenders.js";import{InjectionIhoTableUUID as S,InjectionIhoTableConfig as O}from"../../../../constants/index.js";import{useIhoTableFormEvent as k}from"../../../../utils/index.js";import{getSelectOptions as A,selectOptionsMap as B}from"../hooks/useSelectOption.js";var j=e({name:"EditSelect",props:{value:{type:[Array,String,Number]},column:{type:Object,required:!0},row:{type:Object,required:!0},rowIndex:{type:Number,required:!0},options:{type:Array,default:()=>[]},queryOptions:{type:Function},placeholder:{type:String,default:"请选择"},allowModify:{type:Boolean},allowCreate:{type:Boolean},shouldSave:{type:Boolean},consistentMenuWidth:{type:Boolean,default:!0},labelField:{type:String,default:"label"},valueField:{type:String,default:"value"},searchField:{type:Array},aliasField:{type:String},menuProps:{type:Object},multiple:{type:Boolean},deletable:{type:Boolean,default:!0},selectAll:{type:Boolean,default:!0},searchByValue:{type:Boolean}},emits:["update:value"],setup(e,{emit:j}){const x=l("$xetable"),C=h(e,"value",j),K=o(null),{emitFormChangeWithParams:$}=k({...e,$table:x}),q=t((()=>e.labelField)),R=t((()=>e.valueField)),M=t((()=>e.aliasField)),D=t((()=>e.searchField)),{fullOptions:P,filterOptions:_,searchContent:E,remoteOptions:H}=g(e,{labelKey:q,valueKey:R,searchKey:D}),{modifyEvent:T,modifyAbleRef:V,getOptionsWithCreated:W}=b(e,{searchContent:E,labelKey:q,valueKey:R,valueRef:C,fullOptions:P}),L=t((()=>W(V.value?P.value:_.value))),I=o(!1),U=w((async function(l=""){E.value=l;try{if(I.value=!0,!s(e.queryOptions)||!d(e.options))return;H.value=await e.queryOptions({keyword:l,row:e.row,column:e.column,rowIndex:e.rowIndex})}catch(l){console.log(`获取${e.column.field}options错误`)}finally{I.value=!1}}),400),N=l(S);n((()=>J(!0)));const z=o(!1);function G(e){z.value=e,J(),U()}async function J(l=!1){var o,t,n;if(!e.multiple)return;await a();const{refTableLeftBody:r,refTableBody:u}=x.getRefMaps(),i=null==(o=null==r?void 0:r.value)?void 0:o.$el;if(!i)return;const s=null==(t=null==u?void 0:u.value)?void 0:t.$el,d=x.getRowid(e.row),c=null==(n=s.querySelector(`.vxe-body--row[rowid="${d}"]`))?void 0:n.clientHeight;i.querySelector(`.vxe-body--row[rowid="${d}"]`).style.height=l?"unset":c+"px"}async function Q(l,o){var t,n;const a=e.value;await T.updateValue(l,o);const r=A(N,e.column.field,e.row,x);N&&c(r)&&i(o).forEach((e=>{if(!p(e))return;const l=e;l.created&&l.shouldSave&&r.push(v(u(l),["created","shouldSave"]))}));const s=null==(t=e.column.editRender)?void 0:t.props;if(N&&(null==s?void 0:s.connectField)){const o=null==(n=s.connectField)?void 0:n.split(","),t=B.get(N);o.forEach((async o=>{var n;const{tableColumn:a}=x.reactData,r=a.find((e=>e.field===o)),u=null==(n=null==r?void 0:r.editRender)?void 0:n.props;if(null==u?void 0:u.queryOptions){const n=l?`${o}__${e.column.field}-${l}`:o;if(t[n])return;t[n]=await u.queryOptions({row:e.row,column:r,isFullData:!0,connectColumn:e.column})}}))}return $({oldValue:a,option:f(o)}),J()}const X=l(O);function Y(){var e,l;return null==(l=null==(e=X.value)?void 0:e.keyboardConfig)?void 0:l.forceArrowKey}function Z(e){var l,o,t;if(K.value)if("Tab"===e.code||Y()&&(t=e.key,["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(t)))z.value?null==(o=(l=K.value).handleKeydown)||o.call(l,{...e,key:"Enter",preventDefault:e.preventDefault.bind(e)}):x.internalData.isActivated=!0;else if("Backspace"===e.code&&Y()){""===K.value.pattern&&(C.value=null)}}const{renderTag:ee,renderLabel:le,renderSelectAll:oe}=F(e,{labelKey:q,valueKey:R,valueRef:C,showKey:M,searchContent:E});function te(l){if(!e.multiple)return;const o=l?L.value.map((e=>e[R.value])):[];if(!y(o,C.value).length)return;const t=C.value;C.value=o,$({oldValue:t,option:l?L.value:[]})}const ne=()=>({class:"iho-table__selectOption"}),ae=t((()=>{var l,o;return{...e.menuProps,class:`iho-table__selectMenu ${null!=(o=null==(l=e.menuProps)?void 0:l.class)?o:""}`}}));return()=>{const l={};return e.multiple&&e.selectAll&&(l.action=()=>oe(te)),r(m,{ref:K,consistentMenuWidth:e.consistentMenuWidth,placeholder:e.placeholder,labelField:e.labelField,valueField:e.valueField,loading:I.value,options:L.value,multiple:e.multiple,value:e.value,remote:!0,onSearch:U,clearable:!0,filterable:!0,nodeProps:ne,menuProps:ae.value,renderTag:ee,renderLabel:le,show:z.value,onUpdateShow:G,onUpdateValue:Q,onKeydownCapture:Z,onFocus:T.focus,onBlur:T.blur},l)}}});export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e="@cnhis-design-vue/shared",i="3.2.4-beta.
|
|
1
|
+
var e="@cnhis-design-vue/shared",i="3.2.4-beta.32",s="index.ts",n={"naive-ui":"^2.30.0",vue:"^3.2.0"},a={"@vicons/ionicons5":"^0.12.0","lodash-es":"^4.17.21",moment:"^2.29.1","video.js":"^7.19.2","videojs-contrib-hls":"^5.15.0",viewerjs:"^1.10.5","xe-utils":"^3.5.4"},d={name:e,version:"3.2.4-beta.32",private:!0,main:"index.ts",peerDependencies:n,dependencies:a};export{d as default,a as dependencies,s as main,e as name,n as peerDependencies,i as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cnhis-design-vue",
|
|
3
|
-
"version": "3.2.4-beta.
|
|
3
|
+
"version": "3.2.4-beta.32",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"module": "./es/components/index.js",
|
|
6
6
|
"main": "./es/components/index.js",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"iOS 7",
|
|
72
72
|
"last 3 iOS versions"
|
|
73
73
|
],
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "244d859ba5bca0428134eaa2053a79bb0edfe82d"
|
|
75
75
|
}
|