cnhis-design-vue 3.2.13-beta.0 → 3.2.13-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/es/components/ai-chat/index.d.ts +76 -3
  2. package/es/components/ai-chat/src/Index.vue.d.ts +76 -3
  3. package/es/components/ai-chat/src/Index.vue2.js +1 -1
  4. package/es/components/ai-chat/src/components/ChatCard.js +1 -1
  5. package/es/components/ai-chat/src/components/ChatFooter.vue.d.ts +58 -0
  6. package/es/components/ai-chat/src/components/ChatFooter.vue2.js +1 -1
  7. package/es/components/ai-chat/src/components/ChatPatient.vue.d.ts +58 -0
  8. package/es/components/ai-chat/src/components/ChatPatient.vue.js +1 -0
  9. package/es/components/ai-chat/src/components/ChatPatient.vue2.js +1 -0
  10. package/es/components/ai-chat/src/types/index.d.ts +2 -2
  11. package/es/components/ai-chat/style/index.css +1 -1
  12. package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
  13. package/es/components/button-print/src/utils/print.js +1 -1
  14. package/es/components/callback/src/components/render/popupMaps.d.ts +8 -6
  15. package/es/components/fabric-chart/src/hooks/temperature/useCenter.js +1 -1
  16. package/es/components/fabric-chart/src/hooks/useCommon.js +1 -1
  17. package/es/components/iho-table/index.d.ts +8 -6
  18. package/es/components/iho-table/src/IhoTable.vue.d.ts +8 -6
  19. package/es/components/iho-table/src/IhoTable.vue2.js +1 -1
  20. package/es/components/iho-table/src/plugins/crossHeaderPlugin.js +1 -1
  21. package/es/components/iho-table/src/plugins/headerPlugin/index.js +1 -1
  22. package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue2.js +1 -1
  23. package/es/components/iho-table/src/plugins/rendererPlugins/widgets/defaultRendererPlugin.js +1 -1
  24. package/es/components/iho-table/src/types/index.d.ts +3 -2
  25. package/es/components/iho-table/style/index.css +1 -1
  26. package/es/components/index.css +1 -1
  27. package/es/components/template-render/src/components/Button.vue.d.ts +1 -0
  28. package/es/components/template-render/src/components/Button.vue2.js +1 -1
  29. package/es/components/template-render/src/components/Field.vue.d.ts +1 -1
  30. package/es/components/template-render/src/components/Field.vue2.js +1 -1
  31. package/es/components/template-render/src/components/index.d.ts +3 -2
  32. package/es/shared/package.json.js +1 -1
  33. package/package.json +2 -2
@@ -1 +1 @@
1
- import{defineComponent as e,inject as t,ref as n,reactive as i,computed as r,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as f,renderList as y,createBlock as g,normalizeClass as h,createTextVNode as k,toDisplayString as b,isRef as P,renderSlot as w,withModifiers as S,mergeProps as I}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as L,NDropdown as T,NButton as j,NIcon as M,NPopover as x,NCheckbox as E,NDivider as F}from"naive-ui";import{PrintOutline as N,SettingsOutline as _,ChevronDownSharp as D,ArrowForwardOutline as R}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}from"../constants/index.js";import{Print as U}from"../utils/print.js";import{isIReport as z}from"../utils/browserPrint.js";import A from"./IdentityVerification.vue.js";import{format as K}from"date-fns";import"../api.js";import"../../../shortcut-provider/index.js";import{encapBrowserLog as V}from"../../../../shared/utils/index.js";import{useShortcuts as B}from"../../../shortcut-provider/src/hooks/useShortcuts.js";const G={class:"newprint-button-outer"},q={key:0,class:"newprint-button-outer__shortcut"},Y=d("span",{class:"label bold"},"外显设置",-1),H={class:"newprint-button-poperOver"},$={class:"print-lite"},Q={class:"label bold"},W={class:"print-li"},X={class:"print-lite"},Z={key:0,class:"newprint-button-outer__shortcut"},ee={class:"newprint-button-poperOver"},te=["onMouseenter","onClick"],ne={class:"label bold"},ie={class:"newprint-button-poperOver"},re={class:"print-lite"},ae={class:"label bold"},le={class:"print-li"},oe={class:"print-lite"},se=["onClick"],ue={key:0,class:"newprint-button-outer__shortcut"},ce={class:"newprint-button-poperOver"},de=["onMouseenter"],pe={class:"print-lite"},me=["onClick"];var ve=e({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:"",shortcut:{}})},svrUpdateIp:{type:String}},setup(e,{expose:ve}){const fe=e,ye=String(navigator.platform).toLowerCase().includes("linux"),ge=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],he=C();let ke;const be=t(J),Pe=n(""),we=i({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],iReportExecuteMode:1}),Se=n({});let Ie=n([]),Oe=n([{label:fe.previewText,key:"previewText"},{label:fe.pdfLoadText,key:"downloadPdf"},{label:fe.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Ce=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),Le=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),Te=n([]),je=n([]),Me=r((()=>{if(!we.currentFormatId)return{};let e=we.currentFormatId;return we.formatList.find((t=>t.id===e))}));r((()=>{var e;return(null==(e=Me.value)?void 0:e.name)||"格式选择"}));const xe=r((()=>{let e=we.formatList.find((e=>e.id===we.currentFormatId));return null==e?void 0:e.templateId})),Ee=r((()=>{let e=we.formatList.find((e=>e.id===we.currentFormatId));return null==e?void 0:e.number})),Fe=r((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.isShowPrintAll})),Ne=r((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.isShowOutSetting})),_e=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.customProps)||{}})),De=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.defaultFormatId)||""})),Re=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.printAllType)||1})),Je=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.shortcut)||{}})),Ue=r((()=>{var e,t;const n=Object.keys(Je.value);if(n.length>0){if(De.value&&n.includes(De.value))return(null==(e=Je.value[De.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=Je.value.all)?void 0:t.shortcutLabel)||""}return""})),ze=r((()=>{const e=ge.map((e=>e.key));return Ie.value.filter((t=>!e.includes(t.key)))})),Ae=r({get:()=>ze.value.every((e=>e.selected)),set(e){ze.value.forEach((t=>{t.selected=e}))}}),Ke=async()=>{var e,t;(null==(t=null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await yt(),Le.oneShow=!0},Ve=async e=>{if(fe.directPrint){if(we.spinning)return;return"button"===e?void(Fe.value?await kt():De.value?async function(e){await yt(!1);const t=Te.value.find((t=>t.key==e));t&&it(t.templateCode,t.templateId,t.key,!1)}(De.value):Ke()):Ke()}return Ke()},Be=(e,t)=>we.printParams[t.templateCode]?z(t.key)&&(ye||2==we.iReportExecuteMode)?e.filter((e=>"formatEditText"!=e.key)):e:[],Ge=(e,t)=>{Ce[e]=t},qe=()=>{Te.value=Ie.value.filter((e=>!e.selected)),je.value=ze.value.filter((e=>e.selected)),He("oneShow"),He("isOutSetting"),be("saveOuterPrint",je.value)},Ye=e=>{Le[e]=!0},He=e=>{Ce.oneClickType="",Le[e]=!1,"isOutSetting"==e&&(Le.isOutSetting=!1)},$e=(e,t)=>{tt(!1);let n={type:t,formatId:we.currentFormatId,templateId:(null==e?void 0:e.templateId)||xe.value,templateCode:(null==e?void 0:e.templateCode)||Ee.value};V({type:"进入成功的回调",info:n},"PRINT-SDK"),be("success",e,n)},Qe=e=>{tt(!1),V({type:"进入失败的回调",res:e},"PRINT-SDK"),be("error",e),O(e)&&"notInstalledApp"===e.type&&he.error(e.message)},We=e=>{tt(!1),be("cancel",e)},Xe=e=>{be("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Ze=()=>JSON.stringify({...fe.token?{token:fe.token}:{}}),et=(e=[],t)=>{var n,i;let r={},a={};if((null==(n=we.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(i=Object.keys(e[0].datasetData||{}))?void 0:i[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return r=Object.assign({},JSON.parse(Ze()),_e.value,a),JSON.stringify(r)},tt=(e,t)=>{if(we.isClickOuterPrint){if(e&&t){const n=je.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}je.value.forEach((e=>{e.isLoading=!1}))}else we.spinning=e},nt=()=>we.isClickOuterPrint?je.value.some((e=>e.isLoading)):we.spinning,it=(e,t,n,i)=>{const r=we.printParams[e];if(!r)return;we.isClickOuterPrint=i,we.currentFormatId=n;const a=we.originParams[e]||[];rt(r,e,t,n,a)},rt=async(e=[],t,n,i,r=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&$e(e,"print")}catch(e){console.log("error",e)}};fe.showLoading&&nt()&&!a||(tt(!0,i),fe.prevFn("print",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e;const a={formatId:i,iReportExecuteMode:we.iReportExecuteMode,templateId:n,authorizationKey:Pe.value,printdlgshow:fe.printdlgshow,signature:fe.signature,copies:fe.printCopies,svrUpdateIp:fe.svrUpdateIp};if("MULTI"===fe.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,e[t]));ke.printDirect({...a,params:n},o,Qe,We)}else ke.printDirect({...a,params:et(e,t)},(e=>{e.params=r,e.templateCode=t,e.templateId=n,$e(e,"print")}),Qe,We)})).catch((()=>{Xe("print"),tt(!1)})).finally((()=>{we.visible=!1})))},at=async(e,{templateCode:t,templateId:n,key:i},r)=>{const a=we.printParams[t];if(a)switch(we.isClickOuterPrint=r,we.currentFormatId=i,e){case"previewText":(async(e=[],t,n,i)=>{fe.showLoading&&nt()||(tt(!0,i),fe.prevFn("preview",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,e[0])),a="MULTI"===fe.strategy?r:et(e,t),l={formatId:i,templateId:n,iReportExecuteMode:we.iReportExecuteMode,authorizationKey:Pe.value,params:a,btnprint:fe.btnprint,signature:fe.signature};ke.preview(l,(e=>{$e(e,"preview")}),Qe)})).catch((()=>{Xe("preview"),tt(!1)})).finally((()=>{we.visible=!1})))})(a,t,n,i);break;case"formatEditText":((e=[],t,n,i)=>{fe.showLoading&&nt()||(tt(!0,i),fe.prevFn("edit",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e,we.currentFormatId=i,we.identityVerification.visible=!0})).catch((()=>{Xe("edit")})).finally((()=>{tt(!1)})))})(a,0,n,i);break;case"downloadPdf":(async(e=[],t,n,i)=>{fe.showLoading&&nt()||(tt(!0,i),fe.prevFn("download",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,e[0])),a="MULTI"===fe.strategy?r:et(e,t),l={formatId:i,templateId:n,iReportExecuteMode:we.iReportExecuteMode,authorizationKey:Pe.value,print:{print:"1",type:"1",resolution:null==fe?void 0:fe.resolution},params:a,signature:fe.signature};ke.downloadPDF(l,(e=>$e(e,"preview")),Qe)})).catch((()=>{Xe("download"),tt(!1)})).finally((()=>{we.visible=!1})))})(a,t,n,i);break;case"resetPrinter":(async(e=[],t,n,i)=>{if(!fe.showLoading||!nt()){tt(!0,i);try{const e=await ke.resetPrinter(i,we.iReportExecuteMode);if(tt(!1),"success"==(null==e?void 0:e.result))return void he.success(e.message||"重置打印机成功");he.warning("重置打印机失败")}catch(e){tt(!1),he.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,i)}},lt=()=>{},ot=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},dt(n,t,e))})),n},st=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},pt(n,t,e))})),n},ut=(e,t,n)=>{const i={};return t.forEach((t=>{let r=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(i=K(t,n[e.type])),(null==e?void 0:e.defaultValue)||i})(t,e[t[n]]);e[t[n]]&&r&&(i[t[n]]=r)})),i},ct=({customizeDataset:e=[],param:t=[]},n={})=>{let i={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[e.name]=JSON.stringify(ut(n,t,"fieldName"))})),i=Object.assign({},i,ut(n,t,"key")),i},dt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i],a=n[r];if(!a)return e;e[r]||(e[r]=[]),e[r].push(ct(a,t))}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return e;e[a]||(e[a]=[]),e[a].push(ct(l,t))}return e},pt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i];if(!n[r])return e;e[r]||(e[r]=[]),e[r].push(t)}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r];if(!n[a])return e;e[a]||(e[a]=[]),e[a].push(t)}return e},mt=async e=>{var t;we.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],we.iReportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].iReportExecuteMode||1,(()=>{var e,t,n;const i=Object.keys(Je.value),r=we.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(i.includes(e.id)){const n=Je.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));Ie.value.unshift(...r),Ne.value&&Ie.value.push(...ge),(null==(t=null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(Ie.value.forEach((e=>{var t;(null==(t=fe.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),je.value=Ie.value.filter((e=>e.selected))),Te.value=Ie.value.filter((e=>!e.selected)),fe.hideButtons.length>0&&(Oe.value=Oe.value.filter((e=>!fe.hideButtons.includes(e.key))));const a=sessionStorage.getItem("portal");if(a){const e=JSON.parse(a),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(t);i.includes("RY7.2.21.1.M2.G94181E")||(Oe.value=Oe.value.filter((e=>"downloadPdf"!=e.key))),i.includes("RY7.2.21.1.M2.G33633A")||(Oe.value=Oe.value.filter((e=>"formatEditText"!=e.key))),i.includes("RY7.2.21.1.M2.G99314S")||(Oe.value=Oe.value.filter((e=>"resetPrinter"!=e.key)))}})(),we.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),we.printParams=ot(we.templateParams,fe.params),we.originParams=st(we.templateParams,fe.params),ft()},vt=async()=>{var e;if(we.isInited)return!0;we.isInited=!0,we.spinning=!0,(()=>{if(ke)return!1;ke=new U})();const t=await fe.queryPrintFormatByNumber();return await mt(t),(null==(e=t.obj)?void 0:e.length)>0&&(Pe.value=t.obj[0].authorizationKey||""),we.spinning=!1,!0},ft=async()=>{const e=Object.keys(Je.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],i=Je.value[n],{stop:r,signature:a}=B().register({label:i.code,shortcutSignature:i.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ve("button");const e=ze.value.map((e=>e.key)),t=we.originParams;if(e.includes(n)){const e=ze.value.find((e=>e.key==n));if(e){const n=we.printParams[null==e?void 0:e.templateCode],i=t[null==e?void 0:e.templateCode]||[];rt(n,e.templateCode,e.templateId,e.key,i)}}}});Se.value[n]=r}},yt=async(e=!0)=>{if(await fe.clickPrevFn()){if(!we.visible){if(!await vt())return!1}e&&(we.visible=!we.visible)}},gt=e=>{if(we.identityVerification.visible=!1,z(we.currentFormatId))return $e({result:"success",message:""},"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,we.curPrintParamList[0])),n="MULTI"===fe.strategy?t:et(we.curPrintParamList,Ee.value),i={formatId:we.currentFormatId,templateId:xe.value,params:n,token:e};ke.editPrintFormat(i,(e=>{$e(e,"edit")}),Qe)},ht=(e,t)=>{const n=je.value[t+1];return t<je.value.length-1&&!we.printParams[e.templateCode]&&we.printParams[n.templateCode]};async function kt(){await yt(!1),(()=>{const e=Object.keys(we.printParams);we.isClickOuterPrint=!1;const t=we.originParams;if(1==Re.value)for(let n=0;n<e.length;n++){const i=e[n],r=we.printParams[i],a=t[i]||[],l=we.formatList.filter((e=>e.number==i));l&&l.length>0&&l.forEach((e=>{we.currentFormatId=e.id,rt(r,e.number,e.templateId,e.id,a,!0)}))}2==Re.value&&je.value.forEach((e=>{const n=we.printParams[e.templateCode],i=t[e.templateCode]||[];we.currentFormatId=e.key,rt(n,e.templateCode,e.templateId,e.key,i,!0)}))})()}return a((()=>{we.isInited=!1,yt()})),l((()=>{const e=Object.keys(Se.value);e.length>0&&e.forEach((e=>{Se.value[e]&&Se.value[e]()}))})),o((()=>fe.params),(e=>{Object.keys(we.templateParams).length>0&&(we.printParams=ot(we.templateParams,fe.params),we.originParams=st(we.templateParams,fe.params))}),{deep:!0}),o((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await yt(!1)}),{deep:!0,immediate:!0}),ve({directPrint:kt}),(t,n)=>(s(),u(c,null,[d("div",G,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:f((()=>[(s(!0),u(c,null,y(je.value,((t,n)=>(s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:lt,options:Be(v(Oe),t),onSelect:e=>at(e,t,!0)},{default:f((()=>[m(v(j),{disabled:!we.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>it(t.templateCode,t.templateId,t.key,!0),class:h(n==je.value.length-1?"outerLastButton":ht(t,n)?"isPrintDisabled":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(t.label)+" ",1),t.shortcutLabel?(s(),u("span",q,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"])))),128))])),_:1}),p(" 外显设置按钮 "),je.value.length>0&&je.value.length==v(ze).length&&v(Ne)&&2!=v(Re)?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,show:Le.isOutSetting,onClickoutside:n[2]||(n[2]=e=>He("isOutSetting"))},{trigger:f((()=>[m(v(j),{class:h(je.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>Ye("isOutSetting"))},{default:f((()=>[Y,m(v(M),{style:{"margin-left":"8px"},component:v(_),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:f((()=>[d("div",H,[(s(!0),u(c,null,y(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",$,[d("span",Q,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",W,[m(v(F)),d("div",X,[m(v(j),{type:"primary",size:"small",onClick:qe},{default:f((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ae),"onUpdate:checked":n[1]||(n[1]=e=>P(Ae)?Ae.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:1},8,["show"])):(s(),u(c,{key:1},[p(" 打印全部按钮 "),m(v(x),{trigger:"click","show-arrow":!1,show:Le.oneShow,onClickoutside:n[10]||(n[10]=e=>He("oneShow"))},{trigger:f((()=>[w(t.$slots,"button",{handleClickPrintBtn:yt,printSpinning:we.spinning,printbtnText:e.btnText,printVisible:we.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ve("icon")),["stop"]))},{default:f((()=>[m(v(j),{loading:e.showLoading&&we.spinning,onClick:n[3]||(n[3]=S((()=>Ve("button")),["stop"])),class:h(je.value.length>0?"printAllLeftCls":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(v(Fe)?"打印全部":e.btnText)+" ",1),v(Ue)?(s(),u("span",Z,b(v(Ue)),1)):p("v-if",!0)])),_:1},8,["loading","class"]),m(v(j),{class:"icon-select"},{icon:f((()=>[m(v(M),{component:v(D),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:f((()=>[d("div",ee,[(s(!0),u(c,null,y(Te.value,(e=>(s(),u("div",{class:h(["print-li",Ce.oneMouseType==e.key||Ce.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ge("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ge("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!we.printParams[n.templateCode])return[];Ge(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),g(v(F),{key:0})):"outSetting"==e.key?(s(),u(c,{key:1},[p(" 第二层外显设置 "),m(v(x),{trigger:"click","show-arrow":!1,placement:"right-start",show:Le.isOutSetting,onClickoutside:n[7]||(n[7]=e=>He("isOutSetting"))},{trigger:f((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>Ye("isOutSetting"))},[d("span",ne,b(e.label),1),m(v(M),{color:je.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:f((()=>[d("div",ie,[(s(!0),u(c,null,y(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",re,[d("span",ae,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",le,[m(v(F)),d("div",oe,[m(v(j),{type:"primary",size:"small",onClick:qe},{default:f((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ae),"onUpdate:checked":n[6]||(n[6]=e=>P(Ae)?Ae.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(s(),u(c,{key:2},[p(" 第二层功能操作 "),d("div",{class:h(["print-lite",we.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>it(e.templateCode,e.templateId,e.key,!1)},[k(b(e.label)+" ",1),e.shortcutLabel?(s(),u("span",ue,b(e.shortcutLabel),1)):p("v-if",!0)],8,se),we.printParams[e.templateCode]?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Le[e.key],onClickoutside:t=>He(e.key)},{trigger:f((()=>[m(v(M),{component:v(R),size:"18",onClick:t=>Ye(e.key)},null,8,["component","onClick"])])),default:f((()=>[d("div",ce,[(s(!0),u(c,null,y(Be(v(Oe),e),(t=>(s(),u("div",{class:h(["print-li",Ce.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ge("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ge("twoMouseType",""))},[d("div",pe,[d("span",{class:"label",onClick:n=>at(t.key,e,!1)},b(t.label),9,me)])],42,de)))),128))])])),_:2},1032,["show","onClickoutside"])):p("v-if",!0)],2)],2112))],42,te)))),128))])])),_:3},8,["show"])],2112))]),m(A,I(t.$attrs,{modelValue:we.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>we.identityVerification.visible=e),formatId:we.currentFormatId,templateId:v(xe),onSuccess:gt}),null,16,["modelValue","formatId","templateId"])],64))}});export{ve as default};
1
+ import{defineComponent as e,inject as t,ref as n,reactive as i,computed as r,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as f,renderList as y,createBlock as g,normalizeClass as h,createTextVNode as k,toDisplayString as b,isRef as P,renderSlot as w,withModifiers as S,mergeProps as I}from"vue";import{isObject as O}from"@vue/shared";import{useMessage as C,NButtonGroup as L,NDropdown as T,NButton as j,NIcon as M,NPopover as x,NCheckbox as E,NDivider as F}from"naive-ui";import{PrintOutline as N,SettingsOutline as _,ChevronDownSharp as D,ArrowForwardOutline as R}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as J}from"../constants/index.js";import{Print as U}from"../utils/print.js";import{isIReport as z}from"../utils/browserPrint.js";import A from"./IdentityVerification.vue.js";import{format as K}from"date-fns";import"../api.js";import"../../../shortcut-provider/index.js";import{encapBrowserLog as V}from"../../../../shared/utils/index.js";import{useShortcuts as B}from"../../../shortcut-provider/src/hooks/useShortcuts.js";const G={class:"newprint-button-outer"},q={key:0,class:"newprint-button-outer__shortcut"},Y=d("span",{class:"label bold"},"外显设置",-1),H={class:"newprint-button-poperOver"},$={class:"print-lite"},Q={class:"label bold"},W={class:"print-li"},X={class:"print-lite"},Z={key:0,class:"newprint-button-outer__shortcut"},ee={class:"newprint-button-poperOver"},te=["onMouseenter","onClick"],ne={class:"label bold"},ie={class:"newprint-button-poperOver"},re={class:"print-lite"},ae={class:"label bold"},le={class:"print-li"},oe={class:"print-lite"},se=["onClick"],ue={key:0,class:"newprint-button-outer__shortcut"},ce={class:"newprint-button-poperOver"},de=["onMouseenter"],pe={class:"print-lite"},me=["onClick"];var ve=e({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:"",shortcut:{}})},svrUpdateIp:{type:String}},setup(e,{expose:ve}){const fe=e,ye=String(navigator.platform).toLowerCase().includes("linux"),ge=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],he=C();let ke;const be=t(J),Pe=n(""),we=i({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],iReportExecuteMode:1}),Se=n({});let Ie=n([]),Oe=n([{label:fe.previewText,key:"previewText"},{label:fe.pdfLoadText,key:"downloadPdf"},{label:fe.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Ce=i({oneMouseType:"",oneClickType:"",twoMouseType:""}),Le=i({oneShow:!1,isOperation:!1,isOutSetting:!1}),Te=n([]),je=n([]),Me=r((()=>{if(!we.currentFormatId)return{};let e=we.currentFormatId;return we.formatList.find((t=>t.id===e))}));r((()=>{var e;return(null==(e=Me.value)?void 0:e.name)||"格式选择"}));const xe=r((()=>{let e=we.formatList.find((e=>e.id===we.currentFormatId));return null==e?void 0:e.templateId})),Ee=r((()=>{let e=we.formatList.find((e=>e.id===we.currentFormatId));return null==e?void 0:e.number})),Fe=r((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.isShowPrintAll})),Ne=r((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.isShowOutSetting})),_e=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.customProps)||{}})),De=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.defaultFormatId)||""})),Re=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.printAllType)||1})),Je=r((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.shortcut)||{}})),Ue=r((()=>{var e,t;const n=Object.keys(Je.value);if(n.length>0){if(De.value&&n.includes(De.value))return(null==(e=Je.value[De.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=Je.value.all)?void 0:t.shortcutLabel)||""}return""})),ze=r((()=>{const e=ge.map((e=>e.key));return Ie.value.filter((t=>!e.includes(t.key)))})),Ae=r({get:()=>ze.value.every((e=>e.selected)),set(e){ze.value.forEach((t=>{t.selected=e}))}}),Ke=async()=>{var e,t;(null==(t=null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await yt(),Le.oneShow=!0},Ve=async e=>{if(fe.directPrint){if(we.spinning)return;return"button"===e?void(Fe.value?await kt():De.value?async function(e){await yt(!1);const t=Te.value.find((t=>t.key==e));t&&it(t.templateCode,t.templateId,t.key,!1)}(De.value):Ke()):Ke()}return Ke()},Be=(e,t)=>we.printParams[t.templateCode]?z(t.key)&&(ye||2==we.iReportExecuteMode)?e.filter((e=>"formatEditText"!=e.key)):e:[],Ge=(e,t)=>{Ce[e]=t},qe=()=>{Te.value=Ie.value.filter((e=>!e.selected)),je.value=ze.value.filter((e=>e.selected)),He("oneShow"),He("isOutSetting"),be("saveOuterPrint",je.value)},Ye=e=>{Le[e]=!0},He=e=>{Ce.oneClickType="",Le[e]=!1,"isOutSetting"==e&&(Le.isOutSetting=!1)},$e=(e,t)=>{tt(!1);let n={type:t,formatId:we.currentFormatId,templateId:(null==e?void 0:e.templateId)||xe.value,templateCode:(null==e?void 0:e.templateCode)||Ee.value};V({type:"进入成功的回调",info:n},"PRINT-SDK"),be("success",e,n)},Qe=e=>{tt(!1),V({type:"进入失败的回调",res:e},"PRINT-SDK"),be("error",e),O(e)&&"notInstalledApp"===e.type&&he.error(e.message)},We=e=>{tt(!1),be("cancel",e)},Xe=e=>{be("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Ze=()=>JSON.stringify({...fe.token?{token:fe.token}:{}}),et=(e=[],t)=>{var n,i;let r={},a={};if((null==(n=we.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(i=Object.keys(e[0].datasetData||{}))?void 0:i[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return r=Object.assign({},JSON.parse(Ze()),_e.value,a),JSON.stringify(r)},tt=(e,t)=>{if(we.isClickOuterPrint){if(e&&t){const n=je.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}je.value.forEach((e=>{e.isLoading=!1}))}else we.spinning=e},nt=()=>we.isClickOuterPrint?je.value.some((e=>e.isLoading)):we.spinning,it=(e,t,n,i)=>{const r=we.printParams[e];if(!r)return;we.isClickOuterPrint=i,we.currentFormatId=n;const a=we.originParams[e]||[];rt(r,e,t,n,a)},rt=async(e=[],t,n,i,r=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&$e(e,"print")}catch(e){console.log("error",e)}};fe.showLoading&&nt()&&!a||(tt(!0,i),fe.prevFn("print",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e;const a={formatId:i,iReportExecuteMode:we.iReportExecuteMode,templateId:n,authorizationKey:Pe.value,printdlgshow:fe.printdlgshow,signature:fe.signature,copies:fe.printCopies,svrUpdateIp:fe.svrUpdateIp};if("MULTI"===fe.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,e[t]));ke.printDirect({...a,params:n},o,Qe,We)}else ke.printDirect({...a,params:et(e,t)},(e=>{e.params=r,e.templateCode=t,e.templateId=n,$e(e,"print")}),Qe,We)})).catch((()=>{Xe("print"),tt(!1)})).finally((()=>{we.visible=!1})))},at=async(e,{templateCode:t,templateId:n,key:i},r)=>{const a=we.printParams[t];if(a)switch(we.isClickOuterPrint=r,we.currentFormatId=i,e){case"previewText":(async(e=[],t,n,i)=>{fe.showLoading&&nt()||(tt(!0,i),fe.prevFn("preview",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,e[0])),a="MULTI"===fe.strategy?r:et(e,t),l={formatId:i,templateId:n,iReportExecuteMode:we.iReportExecuteMode,authorizationKey:Pe.value,params:a,btnprint:fe.btnprint,signature:fe.signature};ke.preview(l,(e=>{$e(e,"preview")}),Qe)})).catch((()=>{Xe("preview"),tt(!1)})).finally((()=>{we.visible=!1})))})(a,t,n,i);break;case"formatEditText":((e=[],t,n,i)=>{fe.showLoading&&nt()||(tt(!0,i),fe.prevFn("edit",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e,we.currentFormatId=i,we.identityVerification.visible=!0})).catch((()=>{Xe("edit")})).finally((()=>{tt(!1)})))})(a,0,n,i);break;case"downloadPdf":(async(e=[],t,n,i)=>{fe.showLoading&&nt()||(tt(!0,i),fe.prevFn("download",{formatId:i,templateId:n}).then((()=>{we.curPrintParamList=e;const r=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,e[0])),a="MULTI"===fe.strategy?r:et(e,t),l={formatId:i,templateId:n,iReportExecuteMode:we.iReportExecuteMode,authorizationKey:Pe.value,print:{print:"1",type:"1",resolution:null==fe?void 0:fe.resolution},params:a,signature:fe.signature};ke.downloadPDF(l,(e=>$e(e,"preview")),Qe)})).catch((()=>{Xe("download"),tt(!1)})).finally((()=>{we.visible=!1})))})(a,t,n,i);break;case"resetPrinter":(async(e=[],t,n,i)=>{if(!fe.showLoading||!nt()){tt(!0,i);try{const e=await ke.resetPrinter(i,we.iReportExecuteMode);if(tt(!1),"success"==(null==e?void 0:e.result))return void he.success((null==e?void 0:e.message)||"重置打印机成功");he.warning((null==e?void 0:e.message)||"重置打印机失败")}catch(e){tt(!1),he.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,i)}},lt=()=>{},ot=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},dt(n,t,e))})),n},st=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},pt(n,t,e))})),n},ut=(e,t,n)=>{const i={};return t.forEach((t=>{let r=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let i=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(i=K(t,n[e.type])),(null==e?void 0:e.defaultValue)||i})(t,e[t[n]]);e[t[n]]&&r&&(i[t[n]]=r)})),i},ct=({customizeDataset:e=[],param:t=[]},n={})=>{let i={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;i.datasetData||(i.datasetData={}),i.datasetData[e.name]=JSON.stringify(ut(n,t,"fieldName"))})),i=Object.assign({},i,ut(n,t,"key")),i},dt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i],a=n[r];if(!a)return e;e[r]||(e[r]=[]),e[r].push(ct(a,t))}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],l=n[a];if(!l)return e;e[a]||(e[a]=[]),e[a].push(ct(l,t))}return e},pt=(e,t,n)=>{if(t.templateNumbers){for(let i=0;i<t.templateNumbers.length;i++){const r=t.templateNumbers[i];if(!n[r])return e;e[r]||(e[r]=[]),e[r].push(t)}return e}const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r];if(!n[a])return e;e[a]||(e[a]=[]),e[a].push(t)}return e},mt=async e=>{var t;we.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],we.iReportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].iReportExecuteMode||1,(()=>{var e,t,n;const i=Object.keys(Je.value),r=we.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(i.includes(e.id)){const n=Je.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));Ie.value.unshift(...r),Ne.value&&Ie.value.push(...ge),(null==(t=null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(Ie.value.forEach((e=>{var t;(null==(t=fe.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),je.value=Ie.value.filter((e=>e.selected))),Te.value=Ie.value.filter((e=>!e.selected)),fe.hideButtons.length>0&&(Oe.value=Oe.value.filter((e=>!fe.hideButtons.includes(e.key))));const a=sessionStorage.getItem("portal");if(a){const e=JSON.parse(a),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},i=Object.keys(t);i.includes("RY7.2.21.1.M2.G94181E")||(Oe.value=Oe.value.filter((e=>"downloadPdf"!=e.key))),i.includes("RY7.2.21.1.M2.G33633A")||(Oe.value=Oe.value.filter((e=>"formatEditText"!=e.key))),i.includes("RY7.2.21.1.M2.G99314S")||(Oe.value=Oe.value.filter((e=>"resetPrinter"!=e.key)))}})(),we.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),we.printParams=ot(we.templateParams,fe.params),we.originParams=st(we.templateParams,fe.params),ft()},vt=async()=>{var e;if(we.isInited)return!0;we.isInited=!0,we.spinning=!0,(()=>{if(ke)return!1;ke=new U})();const t=await fe.queryPrintFormatByNumber();return await mt(t),(null==(e=t.obj)?void 0:e.length)>0&&(Pe.value=t.obj[0].authorizationKey||""),we.spinning=!1,!0},ft=async()=>{const e=Object.keys(Je.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],i=Je.value[n],{stop:r,signature:a}=B().register({label:i.code,shortcutSignature:i.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ve("button");const e=ze.value.map((e=>e.key)),t=we.originParams;if(e.includes(n)){const e=ze.value.find((e=>e.key==n));if(e){const n=we.printParams[null==e?void 0:e.templateCode],i=t[null==e?void 0:e.templateCode]||[];rt(n,e.templateCode,e.templateId,e.key,i)}}}});Se.value[n]=r}},yt=async(e=!0)=>{if(await fe.clickPrevFn()){if(!we.visible){if(!await vt())return!1}e&&(we.visible=!we.visible)}},gt=e=>{if(we.identityVerification.visible=!1,z(we.currentFormatId))return $e({result:"success",message:""},"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Ze()),_e.value,we.curPrintParamList[0])),n="MULTI"===fe.strategy?t:et(we.curPrintParamList,Ee.value),i={formatId:we.currentFormatId,templateId:xe.value,params:n,token:e};ke.editPrintFormat(i,(e=>{$e(e,"edit")}),Qe)},ht=(e,t)=>{const n=je.value[t+1];return t<je.value.length-1&&!we.printParams[e.templateCode]&&we.printParams[n.templateCode]};async function kt(){await yt(!1),(()=>{const e=Object.keys(we.printParams);we.isClickOuterPrint=!1;const t=we.originParams;if(1==Re.value)for(let n=0;n<e.length;n++){const i=e[n],r=we.printParams[i],a=t[i]||[],l=we.formatList.filter((e=>e.number==i));l&&l.length>0&&l.forEach((e=>{we.currentFormatId=e.id,rt(r,e.number,e.templateId,e.id,a,!0)}))}2==Re.value&&je.value.forEach((e=>{const n=we.printParams[e.templateCode],i=t[e.templateCode]||[];we.currentFormatId=e.key,rt(n,e.templateCode,e.templateId,e.key,i,!0)}))})()}return a((()=>{we.isInited=!1,yt()})),l((()=>{const e=Object.keys(Se.value);e.length>0&&e.forEach((e=>{Se.value[e]&&Se.value[e]()}))})),o((()=>fe.params),(e=>{Object.keys(we.templateParams).length>0&&(we.printParams=ot(we.templateParams,fe.params),we.originParams=st(we.templateParams,fe.params))}),{deep:!0}),o((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await yt(!1)}),{deep:!0,immediate:!0}),ve({directPrint:kt}),(t,n)=>(s(),u(c,null,[d("div",G,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:f((()=>[(s(!0),u(c,null,y(je.value,((t,n)=>(s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:lt,options:Be(v(Oe),t),onSelect:e=>at(e,t,!0)},{default:f((()=>[m(v(j),{disabled:!we.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>it(t.templateCode,t.templateId,t.key,!0),class:h(n==je.value.length-1?"outerLastButton":ht(t,n)?"isPrintDisabled":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(t.label)+" ",1),t.shortcutLabel?(s(),u("span",q,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"])))),128))])),_:1}),p(" 外显设置按钮 "),je.value.length>0&&je.value.length==v(ze).length&&v(Ne)&&2!=v(Re)?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,show:Le.isOutSetting,onClickoutside:n[2]||(n[2]=e=>He("isOutSetting"))},{trigger:f((()=>[m(v(j),{class:h(je.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>Ye("isOutSetting"))},{default:f((()=>[Y,m(v(M),{style:{"margin-left":"8px"},component:v(_),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:f((()=>[d("div",H,[(s(!0),u(c,null,y(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",$,[d("span",Q,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",W,[m(v(F)),d("div",X,[m(v(j),{type:"primary",size:"small",onClick:qe},{default:f((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ae),"onUpdate:checked":n[1]||(n[1]=e=>P(Ae)?Ae.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:1},8,["show"])):(s(),u(c,{key:1},[p(" 打印全部按钮 "),m(v(x),{trigger:"click","show-arrow":!1,show:Le.oneShow,onClickoutside:n[10]||(n[10]=e=>He("oneShow"))},{trigger:f((()=>[w(t.$slots,"button",{handleClickPrintBtn:yt,printSpinning:we.spinning,printbtnText:e.btnText,printVisible:we.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ve("icon")),["stop"]))},{default:f((()=>[m(v(j),{loading:e.showLoading&&we.spinning,onClick:n[3]||(n[3]=S((()=>Ve("button")),["stop"])),class:h(je.value.length>0?"printAllLeftCls":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(v(Fe)?"打印全部":e.btnText)+" ",1),v(Ue)?(s(),u("span",Z,b(v(Ue)),1)):p("v-if",!0)])),_:1},8,["loading","class"]),m(v(j),{class:"icon-select"},{icon:f((()=>[m(v(M),{component:v(D),size:"18"},null,8,["component"])])),_:1})])),_:1})]))])),default:f((()=>[d("div",ee,[(s(!0),u(c,null,y(Te.value,(e=>(s(),u("div",{class:h(["print-li",Ce.oneMouseType==e.key||Ce.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ge("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ge("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!we.printParams[n.templateCode])return[];Ge(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),g(v(F),{key:0})):"outSetting"==e.key?(s(),u(c,{key:1},[p(" 第二层外显设置 "),m(v(x),{trigger:"click","show-arrow":!1,placement:"right-start",show:Le.isOutSetting,onClickoutside:n[7]||(n[7]=e=>He("isOutSetting"))},{trigger:f((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>Ye("isOutSetting"))},[d("span",ne,b(e.label),1),m(v(M),{color:je.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:f((()=>[d("div",ie,[(s(!0),u(c,null,y(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",re,[d("span",ae,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",le,[m(v(F)),d("div",oe,[m(v(j),{type:"primary",size:"small",onClick:qe},{default:f((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ae),"onUpdate:checked":n[6]||(n[6]=e=>P(Ae)?Ae.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:2},1032,["show"])],2112)):(s(),u(c,{key:2},[p(" 第二层功能操作 "),d("div",{class:h(["print-lite",we.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>it(e.templateCode,e.templateId,e.key,!1)},[k(b(e.label)+" ",1),e.shortcutLabel?(s(),u("span",ue,b(e.shortcutLabel),1)):p("v-if",!0)],8,se),we.printParams[e.templateCode]?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Le[e.key],onClickoutside:t=>He(e.key)},{trigger:f((()=>[m(v(M),{component:v(R),size:"18",onClick:t=>Ye(e.key)},null,8,["component","onClick"])])),default:f((()=>[d("div",ce,[(s(!0),u(c,null,y(Be(v(Oe),e),(t=>(s(),u("div",{class:h(["print-li",Ce.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ge("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ge("twoMouseType",""))},[d("div",pe,[d("span",{class:"label",onClick:n=>at(t.key,e,!1)},b(t.label),9,me)])],42,de)))),128))])])),_:2},1032,["show","onClickoutside"])):p("v-if",!0)],2)],2112))],42,te)))),128))])])),_:3},8,["show"])],2112))]),m(A,I(t.$attrs,{modelValue:we.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>we.identityVerification.visible=e),formatId:we.currentFormatId,templateId:v(xe),onSuccess:gt}),null,16,["modelValue","formatId","templateId"])],64))}});export{ve as default};
@@ -1 +1 @@
1
- import t from"axios";import{cloneDeep as e,isArray as i}from"lodash-es";import{IdentityVerificationDialog as r,PreviewDialog as s}from"./dialog.js";import{isIReport as a,getFileUrl as n,useBrowserPrint as o}from"./browserPrint.js";import{getCurrentInstance as l}from"vue";import{uuidGenerator as c}from"../../../../shared/utils/index.js";import{format as h}from"date-fns";import{io as p}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,g=`${d}/fdp-api/print/assembly/printIReport`,y=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${d}/bi-api/reprot/print/open/client/printIReportForHex`,w=`${d}/bi-api/reprot/print/open/client/previewIReport`,v=`${d}/bi-api/reprot/print/open/client/getRemote`,P=`${d}/printService/file`;let _=null;class I{constructor(){var t,e,i;if(this.webview=null,this.dialog=new r,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,_)return _;_=this;const a=window;this.CMonitor=a.$CMonitor;try{this.webview=a.top?null==(t=a.top.chrome)?void 0:t.webview:null==(e=a.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(i=a.chrome)?void 0:i.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:r,reject:s}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void r({result:(null==i?void 0:i.res)?"success":"fail"});r(i.res||"")}catch(t){s(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=p(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","cancel"==(null==t?void 0:t.result)?this._cancelCallbackFn&&this._cancelCallbackFn(t):this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("ihoPrint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=c();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)})),new Promise(((e,r)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),r({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{m({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}async resetPrinter(t,e){const i=a(t),r=this.getIReportFormatId(i,t);if(i&&(u||2==e)){return await this._testDomesticSystemConnection()?m({url:`${this.printDomesticOrigin}/resetPrint`,method:"get",withCredentials:!1,params:{formatId:r}}).then((({data:t})=>t.status?{type:"resetSuccess",result:"success",message:null==t?void 0:t.message}:{type:"resetError",result:"error",message:null==t?void 0:t.message})).catch((t=>({type:"resetError",result:"error",message:"重置打印机错误"}))):{type:"notInstalledApp",result:"error",message:"请开启ihoPrint客户端"}}return this.webview?this.postMessage({exec:"resetprint",data:{formatID:r}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:r}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:this.printOrigin+"/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:r(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[r]}).then((({data:t})=>t));function r(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:"error",errinfo:t}),!1}if("success"!==t.result){const r=t.message||t.Message;this._handleMonitorNotify(r);const s={type:"printError",message:r,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:r,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(s),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,r,s){const a={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:r},n=await this._queryServicesPrint(a);return this._handleQueryPrintDataResult(n,e,s)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({result:"error",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,svrUpdateIp:i,params:r,paramsArr:s,cmdid:a,print:n,signature:o,copies:l,printdlgshow:c="0",nobillnode:p="1",btnprint:u="1",messageTimeout:m=0}){const d={templateId:t,formatId:e,svrUpdateIp:i,params:r,cmdid:a,nobillnode:p,printdlgshow:c,btnprint:u,copies:l,messageTimeout:m,...o?{signature:o}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=h(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:r,messageTimeout:s=0}){const a={};let n={};try{n=Object.assign({},a,JSON.parse(i))}catch(t){n=a}const o={templateId:t,formatId:e,cmdid:"9",token:r,params:JSON.stringify(n),messageTimeout:s};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:v})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:g,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="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:y,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForBase16(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:f,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForPdf(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:w,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,r=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),s=r[r.length-2],a=r[r.length-1],l=await n(`${P}/${s}/${a}`),c=o(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let r=i.length;const s=new Uint8Array(r);for(;r--;)s[r]=i.charCodeAt(r);return new Blob([s],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,signature:c,btnprint:h,messageTimeout:p=0},m,d){const g=a(i),y=this.getIReportFormatId(g,i);if(g&&(u||2==t)){const t=await this._queryPrintForPdf(e,y,r,n);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const i=o(t,"preview");return this.instance||(this.instance=l()),this.showPreview(this.instance,i),null==m?void 0:m({result:"success",message:"",file:t})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:y,params:r,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),i=this._handleResult(t,d);if(!i)return!1;if(this.isRemote){const t=await this._browserPrint(i,"preview");this.instance||(this.instance=l()),this.showPreview(this.instance,t)}await this.getPicAndUpload(i),null==m||m(i)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const r=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=c(),s=await this.messageCollect(t,{exec:"printA",data:r});if(s&&Array.isArray(s)){s.some((t=>"success"===t.res.result))?null==e||e(s):(null==i||i(s),this._handleMonitorNotify(s))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(s||""),null==i||i({type:"printError",message:t,result:"error",errinfo:t})}}catch(t){const e={error:t,result:"error",message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,isDownloadFile:d=!0,messageTimeout:g=0},y,f,w,v="printDirect"){const P=a(i),_=this.getIReportFormatId(P,i);if(P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notInstalledApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w):f({type:"notInstalledApp",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w))}await this._queryProxyOrigin();const I=await this._testConnection();if(!this._handleResultTest(I,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:_,params:r,paramsArr:s,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,messageTimeout:g}),i=this._handleResult(t,f,w);if(!i)return!1;d&&["downloadPDF"].includes(v)&&await this._browserPrint(i,v),null==y||y(i)}catch(t){const e="printDirect"===v?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:r},s,a,n){const o=await this._queryPrintForBase64(t,e,i,r);if(!o.success)return a({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=s,this._errorCallbackFn=a,n&&(this._cancelCallbackFn=n),this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:c,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,r,s){var n;const o=e(t);if(this.webview&&this.downloadPath&&(Reflect.has(o,"print")||Reflect.set(o,"print",{print:"1",type:"1"}),!o.print.filename)){const t=h(new Date,"yyyy-MM-dd"),e=c(),i=h(new Date,"yyyyMMddHHmmss")+e;o.print.filename=`${this.downloadPath}/${t}/${i}/${i}`.replace(/\\/g,"/")}const l=a(o.formatId);if(o.formatId=this.getIReportFormatId(l,o.formatId),l&&(u||2==o.iReportExecuteMode)){const t=await this._queryPrintForBase16(o.templateId||"",o.formatId,o.params||"",o.authorizationKey);return(null==t?void 0:t.success)?r({filebase64:null==(n=null==t?void 0:t.map)?void 0:n.hex,isIreport:!0}):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(o,(async t=>{t||s({result:"error",message:""});const e=this,a=await async function(t){const r=[],s=JSON.parse(t);if(!i(s))return await e._downloadPDF("");if(1===s.length)return await e._downloadPDF(s[0]||"");for(let t=0,i=s.length;t<i;t++)r.push(await e._downloadPDF(s[t]||""));return r}(t.filedir);r(a,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:r},void 0,a);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,a);if(!l)return!1;s&&s(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this._handleEventQueryPrintData(t,e,i,r,a);return!!o&&(s&&s(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(n,s);return!!o&&(r&&r(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s=0},a,n){const o=await this._testConnection();if(!this._handleResultTest(o,n))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s}),c=this._handleResult(l,n);if(!c)return!1;a&&a(c)}async addPrintFormat({templateId:t,params:e,token:i},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(n,s);if(!o)return!1;r&&r(o)}}export{I as Print};
1
+ import t from"axios";import{cloneDeep as e,isArray as i}from"lodash-es";import{IdentityVerificationDialog as r,PreviewDialog as s}from"./dialog.js";import{isIReport as a,getFileUrl as n,useBrowserPrint as o}from"./browserPrint.js";import{getCurrentInstance as l}from"vue";import{uuidGenerator as c}from"../../../../shared/utils/index.js";import{format as h}from"date-fns";import{io as p}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,g=`${d}/fdp-api/print/assembly/printIReport`,y=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${d}/bi-api/reprot/print/open/client/printIReportForHex`,w=`${d}/bi-api/reprot/print/open/client/previewIReport`,v=`${d}/bi-api/reprot/print/open/client/getRemote`,P=`${d}/printService/file`;let _=null;class I{constructor(){var t,e,i;if(this.webview=null,this.dialog=new r,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,_)return _;_=this;const a=window;this.CMonitor=a.$CMonitor;try{this.webview=a.top?null==(t=a.top.chrome)?void 0:t.webview:null==(e=a.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(i=a.chrome)?void 0:i.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:r,reject:s}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void r({result:(null==i?void 0:i.res)?"success":"fail",message:(null==i?void 0:i.error)||""});r(i.res||"")}catch(t){s(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=p(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","cancel"==(null==t?void 0:t.result)?this._cancelCallbackFn&&this._cancelCallbackFn(t):this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("ihoPrint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=c();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)})),new Promise(((e,r)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),r({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{m({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}async resetPrinter(t,e){const i=a(t),r=this.getIReportFormatId(i,t);if(i&&(u||2==e)){return await this._testDomesticSystemConnection()?m({url:`${this.printDomesticOrigin}/resetPrint`,method:"get",withCredentials:!1,params:{formatId:r}}).then((({data:t})=>t.status?{type:"resetSuccess",result:"success",message:null==t?void 0:t.message}:{type:"resetError",result:"error",message:null==t?void 0:t.message})).catch((t=>({type:"resetError",result:"error",message:"重置打印机错误"}))):{type:"notInstalledApp",result:"error",message:"请开启ihoPrint客户端"}}return this.webview?this.postMessage({exec:"resetprint",data:{formatID:r}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:r}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:this.printOrigin+"/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:r(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[r]}).then((({data:t})=>t));function r(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:"error",errinfo:t}),!1}if("success"!==t.result){const r=t.message||t.Message;this._handleMonitorNotify(r);const s={type:"printError",message:r,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:r,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(s),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,r,s){const a={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:r},n=await this._queryServicesPrint(a);return this._handleQueryPrintDataResult(n,e,s)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({result:"error",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,svrUpdateIp:i,params:r,paramsArr:s,cmdid:a,print:n,signature:o,copies:l,printdlgshow:c="0",nobillnode:p="1",btnprint:u="1",messageTimeout:m=0}){const d={templateId:t,formatId:e,svrUpdateIp:i,params:r,cmdid:a,nobillnode:p,printdlgshow:c,btnprint:u,copies:l,messageTimeout:m,...o?{signature:o}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=h(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:r,messageTimeout:s=0}){const a={};let n={};try{n=Object.assign({},a,JSON.parse(i))}catch(t){n=a}const o={templateId:t,formatId:e,cmdid:"9",token:r,params:JSON.stringify(n),messageTimeout:s};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:v})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:g,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="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:y,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForBase16(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:f,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForPdf(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:w,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,r=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),s=r[r.length-2],a=r[r.length-1],l=await n(`${P}/${s}/${a}`),c=o(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let r=i.length;const s=new Uint8Array(r);for(;r--;)s[r]=i.charCodeAt(r);return new Blob([s],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,signature:c,btnprint:h,messageTimeout:p=0},m,d){const g=a(i),y=this.getIReportFormatId(g,i);if(g&&(u||2==t)){const t=await this._queryPrintForPdf(e,y,r,n);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const i=o(t,"preview");return this.instance||(this.instance=l()),this.showPreview(this.instance,i),null==m?void 0:m({result:"success",message:"",file:t})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:y,params:r,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),i=this._handleResult(t,d);if(!i)return!1;if(this.isRemote){const t=await this._browserPrint(i,"preview");this.instance||(this.instance=l()),this.showPreview(this.instance,t)}await this.getPicAndUpload(i),null==m||m(i)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const r=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=c(),s=await this.messageCollect(t,{exec:"printA",data:r});if(s&&Array.isArray(s)){s.some((t=>"success"===t.res.result))?null==e||e(s):(null==i||i(s),this._handleMonitorNotify(s))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(s||""),null==i||i({type:"printError",message:t,result:"error",errinfo:t})}}catch(t){const e={error:t,result:"error",message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,isDownloadFile:d=!0,messageTimeout:g=0},y,f,w,v="printDirect"){const P=a(i),_=this.getIReportFormatId(P,i);if(P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notInstalledApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w):f({type:"notInstalledApp",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w))}await this._queryProxyOrigin();const I=await this._testConnection();if(!this._handleResultTest(I,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:_,params:r,paramsArr:s,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,messageTimeout:g}),i=this._handleResult(t,f,w);if(!i)return!1;d&&["downloadPDF"].includes(v)&&await this._browserPrint(i,v),null==y||y(i)}catch(t){const e="printDirect"===v?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:r},s,a,n){const o=await this._queryPrintForBase64(t,e,i,r);if(!o.success)return a({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=s,this._errorCallbackFn=a,n&&(this._cancelCallbackFn=n),this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:c,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,r,s){var n;const o=e(t);if(this.webview&&this.downloadPath&&(Reflect.has(o,"print")||Reflect.set(o,"print",{print:"1",type:"1"}),!o.print.filename)){const t=h(new Date,"yyyy-MM-dd"),e=c(),i=h(new Date,"yyyyMMddHHmmss")+e;o.print.filename=`${this.downloadPath}/${t}/${i}/${i}`.replace(/\\/g,"/")}const l=a(o.formatId);if(o.formatId=this.getIReportFormatId(l,o.formatId),l&&(u||2==o.iReportExecuteMode)){const t=await this._queryPrintForBase16(o.templateId||"",o.formatId,o.params||"",o.authorizationKey);return(null==t?void 0:t.success)?r({filebase64:null==(n=null==t?void 0:t.map)?void 0:n.hex,isIreport:!0}):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(o,(async t=>{t||s({result:"error",message:""});const e=this,a=await async function(t){const r=[],s=JSON.parse(t);if(!i(s))return await e._downloadPDF("");if(1===s.length)return await e._downloadPDF(s[0]||"");for(let t=0,i=s.length;t<i;t++)r.push(await e._downloadPDF(s[t]||""));return r}(t.filedir);r(a,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:r},void 0,a);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,a);if(!l)return!1;s&&s(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this._handleEventQueryPrintData(t,e,i,r,a);return!!o&&(s&&s(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(n,s);return!!o&&(r&&r(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s=0},a,n){const o=await this._testConnection();if(!this._handleResultTest(o,n))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s}),c=this._handleResult(l,n);if(!c)return!1;a&&a(c)}async addPrintFormat({templateId:t,params:e,token:i},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(n,s);if(!o)return!1;r&&r(o)}}export{I as Print};
@@ -4243,11 +4243,12 @@ export declare const CallbackMaps: Map<string, {
4243
4243
  rowHeight?: number | undefined;
4244
4244
  fixedColumnList?: {
4245
4245
  setting: {
4246
- name: string;
4247
- option: {
4246
+ alias?: string | undefined;
4247
+ name?: string | undefined;
4248
+ option?: {
4248
4249
  text: string;
4249
4250
  value?: string | undefined;
4250
- }[];
4251
+ }[] | undefined;
4251
4252
  };
4252
4253
  columnWidth?: number | undefined;
4253
4254
  }[] | undefined;
@@ -7836,11 +7837,12 @@ export declare const CallbackMaps: Map<string, {
7836
7837
  rowHeight?: number | undefined;
7837
7838
  fixedColumnList?: {
7838
7839
  setting: {
7839
- name: string;
7840
- option: {
7840
+ alias?: string | undefined;
7841
+ name?: string | undefined;
7842
+ option?: {
7841
7843
  text: string;
7842
7844
  value?: string | undefined;
7843
- }[];
7845
+ }[] | undefined;
7844
7846
  };
7845
7847
  columnWidth?: number | undefined;
7846
7848
  }[] | undefined;
@@ -1 +1 @@
1
- import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useShadow as t}from"./useShadow.js";import{drawLine as i,defaultStyle as n,drawPoint as o,drawText as l,drawArrow as r}from"../useDraw.js";import{useGrid as s}from"../useGrid.js";import{format as u}from"date-fns";import{getType as a,getTime as c,isOneLine as d,isOverlapPoint as p,getFloorNumber as f,isValidValue as h,setOtherType as v,isEffectiveNode as g,deleteProperty as m,getIndex as y}from"../../utils/index.js";import{cloneDeep as x,flatten as b,last as j}from"lodash-es";import"../useEvent.js";import{useCommon as w}from"../useCommon.js";import"vue";import"naive-ui";import"@vueuse/core";import{TEMPERATURE_MENU as L,PAIN_MENU as k,OVERLAP as S}from"../../constants/index.js";import{promiseTimeout as Y}from"@vueuse/shared";function E(E,O,$,T,V,P,R,C,A,I){s(E,O);const{getEqualXTypes:X,handleAddPrevent:D,getPointEventProps:H}=w(E,$,O),{createShadowLines:W}=t(),{left:z,xScaleList:F,xCellWidth:_,yCellHeight:q,originX:G,endX:N,originY:B,endY:J,itemList:K,event:Q,vitalSignsOriginY:U,painOriginY:Z,hospitalizationDate:ee,config:te,canvasHeight:ie,painSurplusCell:ne,iconsWidth:oe,canvasWidth:le,borderStyle:re}=O,se=new Set,ue=["xinmai","mai"],ae=new Map,ce=new Set,de=new Set,pe=new Set,fe=x(z.yScaleValue),he=new Set;function ve(t){var o;const l=fe.find((e=>e.show&&"pulse"===e.type));if(l&&(null==(o=l.dataList)?void 0:o.length)&&(se.size&&E.value.remove(...se),se.clear(),ae.size>1)){if(t){const{type:e,key:i}=t.origin||{};if("pulse"===e){const e=ae.get(i),n=null==e?void 0:e.findIndex((e=>e[0]===t.left));e.splice(n,1,[t.left,t.top])}}const o=function(){const e=[],t=[],i=[];for(const e of ae)t.push(e[1]),e[0]===ue[0]&&e[1].forEach((e=>{(ae.get(ue[1])||[]).findIndex((t=>t[0]===e[0]))>-1&&i.push(e[0])}));const[n,o]=t;let l=[],r=[];return i.forEach((t=>{const i=n.findIndex((e=>e[0]===t)),s=o.findIndex((e=>e[0]===t)),u=n[i],a=o[s],c=n[i-1],d=n[i+1],p=o[s-1],f=o[s+1];if(c&&p){if(c[0]!==p[0]){const e=Math.max(c[0],p[0]);l.push([c,p].find((t=>t[0]===e)))}}else c?l.push(c):p&&r.push(p);const h=Math.min(u[1],a[1]);l.push([u,a].find((e=>e[1]===h)));const v=Math.max(u[1],a[1]);r.push([u,a].find((e=>e[1]===v)));const g=()=>{const t=[...l,...r.reverse()],[i]=t,n=j(t);i[0]===n[0]&&i[1]===n[1]&&t.splice(-1,1),e.push(t),l=[],r=[]};if(d&&f){if(d[0]!==f[0]){const e=Math.min(d[0],f[0]);l.push([d,f].find((t=>t[0]===e))),g()}}else d?(l.push(d),g()):f?(r.push(f),g()):g()})),e}();o.length>0&&function(e){Y(0).then((()=>{e.forEach((e=>{const t=[],i=[];Array.from(pe).forEach((n=>{var o,l;"pulse"===(null==(o=null==n?void 0:n.origin)?void 0:o.type)&&e.find((e=>Math.abs(n.left-e[0])<=1&&Math.abs(n.top-e[1])<=1))&&((null==(l=null==n?void 0:n.origin)?void 0:l.key)===ue[0]?t.push(n):i.push(n))})),[t,i].forEach((e=>{1!==(null==e?void 0:e.length)&&e.sort(((e,t)=>e.left-t.left)).forEach(((e,t)=>{0==t?e.rightLine&&E.value.remove(e.rightLine):e.leftLine&&E.value.remove(e.leftLine)}))}))}))}))}(o);const{mode:r,style:s={}}=l.shadow||{};o.forEach((t=>{const o=t.map((e=>({x:e[0],y:e[1]}))),l=new e.Polygon(o,{...n,...s,strokeWidth:1});if(["slash","line"].includes(r)){l.set({fill:"transparent",stroke:s.stroke||"#f00"});const e=[];if(["slash"].includes(r))e.push(...W(t,s._angle,s.space)),e.forEach((e=>{Object.assign(e,{...n,...s}),se.add(e)}));else{const n=function(e){const t=e.reduce(((e,t)=>{const i=Math.trunc(t[0]);return e[i]=e[i]?e[i].concat([t]):[t],e}),{}),i=Object.values(t).filter((e=>2===e.length&&Math.trunc(e[0][1])!==Math.trunc(e[1][1])));return i}(t);n.forEach((t=>{const n=i([...b(t)],{...s,originX:"center"});e.push(n),se.add(n)}))}E.value.add(...e)}se.add(l),E.value.add(l)}))}}function ge(e,t,s){var u;const{type:a,riseStyle:c={},noRiseStyle:p={},verifiedStyle:g={},reduceStyle:m={},pacemaker:y={},upArrowStyle:b={},limitValueStyle:j={},nonePainPointStyle:w={},belowMinValueStyle:L={},respiratorStyle:k={},dataList:S=[],list:Y=[]}=s,{type:O,textStyle:P}=w,C=[],I=[],X=[];let D=null;const W=e=>"breathe"==a&&e.respirator&&k.type&&k.fixedValue&&!e.value&&ye(e.time),z=d(s);if(null==(u=e.list)||u.forEach(((u,d)=>{const w=z?S.find((e=>e.key===u.key)):e,F=xe(W(u)?{...u,value:k.fixedValue}:u,s),G=e.list[d+1],N=G?xe(W(G)?{...G,value:k.fixedValue}:G,s):void 0,B=G?z?S.find((e=>e.key===G.key)):e:{},{title:J=""}=w;if("脉搏"===J&&"脉搏"!==B.title||"脉搏"!==J&&"脉搏"===B.title||!F||!N||f(F[0],1)!==f(N[0],1))F&&D&&(F[0]=D),D=null;else{const e=F[0]-_/2;F[0]=e+_/4,N[0]=D=F[0]+_/2}const K={};K.value=function(e,t,i){if(!(null==e?void 0:e.length)||!te.showValue)return;const{lineAttr:n={}}=i,o=e[1]<=U.originY+q?e[1]+q:e[1]-q,r=l([e[0],o],{value:W(t)?k.fixedValue:t.value,originX:"center",originY:"center",fill:n.stroke||"#000"});return X.push(r),{obj:r,top:-q}}(F,u,w),function(e,t,s,u){var d,f;if(!["temperature","pain","breathe"].includes(a))return;if(!(null==e?void 0:e.length)&&"temperature"===a&&!ye(t.time))return;if(!(null==e?void 0:e.length)&&"pain"===a)return;if(!t.value&&"breathe"===a)return;const{lineAttr:v={}}=s,{value:y}=u,x=T(t.time);let b,j,w,L,S,Y;if(t.noRise&&p.show){const i=M(p,t)?V(a,35):(null==e?void 0:e[1])||0;if(p.text)w=l([x,M(p,t)?i:i+5],{value:p.text.split("").join("\n"),originY:"top",...p.style}),t.value||pe.add(w);else if(t.value){w=r([x,i,i+2*q],{...p.style})}w&&X.push(w),w&&M(p,t)&&he.add(w)}if(null==e?void 0:e[1]){if(t.rise&&c.show&&c.text&&(L=l([x,e[1]-(y?q:0)-5],{value:c.text.split("").join("\n"),originY:"bottom",...c.style}),X.push(L)),t.verified&&(S=l([x,e[1]-(y?q:0)-5],{value:"v",originX:"center",originY:"bottom",...g}),X.push(S)),h(t.physicsReduce)||h(t.drugReduce)){const l=V(a,null!=(d=t.physicsReduce)?d:t.drugReduce),r=l<e[1]&&(null==te?void 0:te.hypothermyViewCustom)?x+_/2:x;b=i([...e,r,l],{...v,...m.line,...n}),j=o((null==(f=null==m?void 0:m.point)?void 0:f.type)||"circle",{left:r,top:l,...m.point,...n,originY:l===ie?"bottom":"center"}),b&&X.push(b),j&&X.push(j)}t.respirator&&(Y=o(k.type,{left:x,top:e[1]-(y?q:0)-5,originX:"center",originY:"bottom",...k.style}),X.push(Y))}Object.assign(u,{reduceLine:{obj:b,type:"line"},noRiseText:{obj:w,top:p.text?5:2*q,isFixed:M(p,t)},riseText:{obj:L,top:(y?-q:0)-5},verifiedText:{obj:S,top:(y?-q:0)-5},reducePoint:{obj:j,type:"reduce"},respirator:{obj:Y,top:(y?-q:0)-5}})}(F,u,w,K),function(e,t,i,n){if(!(null==e?void 0:e.length)||!["pulse"].includes(a))return;const o=Math.max(...Y),s=Math.min(...Y);let u,c,d;const{upArrowShow:p=!1,limitValueShow:f=!1}=i;if(p&&+t.value>180){let t=e[1]-2.5*q,i=[e[1]-q/2,t];t<U.originY&&(t=e[1]+2.5*q,i=[t,e[1]+q/2]),u=r([e[0],i[0],i[1]],b,"up"),X.push(u)}if(f){const i={value:t.value,originX:"center",originY:"center",...j};if(+t.value>o){const t=u?e[1]+q/2+u.height:e[1]+q;c=l([e[0],t],i),X.push(c)}+t.value<s&&(c=l([e[0],e[1]-q],i),X.push(c))}if(L.show&&+t.value<s){const t=e[1];if(L.text)d=l([e[0],e[1]+5],{value:L.text.split("").join("\n"),originY:"top",...L.style});else{const i=t+2*q;d=r([e[0],t,i],{...L.style})}X.push(d)}Object.assign(n,{upArrow:{obj:u},limitValue:{obj:c,top:-q},belowMinValue:{obj:d,top:L.text?5:2*q,moveHide:!0}})}(F,u,w,K),function(n,l,r,u,c,d){let f,h;const{pointAttr:g={},lineAttr:m={},title:b="",key:j,type:w="circle"}=c,L=e.list[u+1];let S=x(n),Y=x(l);const M=function(e,t){return"pain"===e&&0==t}(a,e.list[u].value),D=()=>"pulse"==a&&r.pacemakerShow?y.value:W(r)?k.type:M&&"number"===O?0:w,F=e=>e&&p.show&&p.fixed&&ye(e.time)&&e.noRise&&!e.value&&0!==e.value;if((()=>{if(r.breakpoint)return!1;if("temperature"===a&&(n||F(r))&&(l||F(L))){const e=V(a,35);return n||(S=[T(r.time),e]),l||(Y=[T(L.time),e]),!0}return!!n&&!!l})()){S&&Y&&M&&"icon"===O&&(S[1]=S[1]-1,Y[1]=Y[1]-1),h=i([...S,...Y],{...m});const{obj:e}=(null==d?void 0:d.reducePoint)||{};if(n&&l&&(null==e?void 0:e.top)<n[1]&&(null==te?void 0:te.hypothermyViewCustom)){const t=i([e.left,e.top,...l],{...m});X.unshift(t),Object.assign(d,{reduceRightLine:{obj:t,type:"reduce"}}),h.set("stroke","transparent")}}const _=D(),q=I[u-1],G={origin:{data:W(r)?{...r,value:k.fixedValue}:r,title:b,key:j||"",unit:s.unit,type:a,_type:v(b,a),dataIndex:t,index:u,isOneLine:z},leftLine:q,rightLine:h,otherObj:d,...r.pacemakerShow&&"pulse"==a?y.style:W(r)?k.style:g,lockMovementX:!0,...H(),...M?{selectable:!1,evented:!1,..."number"===O?P:{}}:{}};n&&(q?G.leftLine.set("x2",n[0]):G.leftLine=null,f=o(_,{left:n[0],top:M&&!ne[1]?n[1]-5:n[1],...G}));I.push(h),f&&(j===ue[1]?ce.add(f):W(r)||de.add(f),function(e){Q.hovered&&(e.on("mouseover",(()=>{me(e,"hover")})),e.on("mouseout",(()=>{A.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{!function(e){e.setCoords();const t="pain"===e.origin.type?Z:U;e.top<t.originY&&e.set("top",t.originY);e.top>t.endY&&e.set("top",t.endY)}(e),function(e){var t,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(i=e.rightLine)||i.setCoords().set({x1:e.left,y1:e.top}),Object.values(e.otherObj).forEach((t=>{const{obj:i,type:n="",top:o=0,isFixed:l,moveHide:r=!1}=t||{};"reduce"!==n&&i&&("line"===n?i.setCoords().set({x1:e.left,y1:e.top}):(l||i.setCoords().set({left:e.left,top:e.top+o}),r&&(E.value.remove(i),delete e.otherObj.obj)))})),ve(e)}(e),Q.hovered&&me(e)})),e.on("mouseup",(t=>{if(A.show=!1,1===t.button){const{type:t}=e.origin,i=R(t,e.top),n={...e.origin,data:{...e.origin.data,value:i}};E.value.discardActiveObject(),$("change",n),je(n,"change")}}))}(f),C.push(f),pe.add(f))}(F,N,u,d,w,K)})),"pulse"===a){let t=null;const i=e=>e.map(((e,i,n)=>{var o,l;const r=n[i+1];if(r&&f(e.left,1)===f(r.left,1)){const i=e.left-_/2;e.set("left",i+_/4),null==(o=e.rightLine)||o.set("x1",e.left),t=e.left+_/2,r.set("left",t)}else t&&(null==(l=e.leftLine)||l.set("x2",t),e.set("left",t)),t=null;return[e.left,e.top]}));if(z){const e={};ue.forEach((t=>{e[t]=C.filter((e=>{var i;return(null==(i=e.origin)?void 0:i.key)===t})),ae.set(t,i(e[t]))}))}else{const{key:t}=e;ae.set(t,i(C))}}const F=I.filter((e=>e));E.value.add(...F,...C,...X)}function me(e,t="moving"){const{title:i,unit:n,type:o,data:l}=e.origin;A.point={x:e.left,y:e.top};let r=`时间 ${((null==l?void 0:l.time)||P(e.left)).slice(-5)}`;A.list=[function(){const{drugReduce:s,physicsReduce:u}=l||{},a="hover"===t?l.value:R(o,e.top);if(h(s))return r+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`药物降${"pain"==o?"痛":"温"} ${a}—>${s}${n||""}`;if(h(u))return r+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`物理降${"pain"==o?"痛":"温"} ${a}—>${u}${n||""}`;return`${i} ${a}${n||""}`}(),r],A.show=!0}function ye(e){const[t]=F,i=j(F),n=t.start,o=i.end,l=c(e);return l>=n&&l<=o}function xe(e,t){const i="pain"===t.type?Z:U;if(!g(e)||!ye(e.time))return;const n=T(e.time),o=V(t.type,e.value);return[n,o<i.originY?i.originY:o>i.endY?i.endY:o]}function be(e){const t=new Date,i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=c(`${t.getFullYear()}-${i}-${n} 23:59:59`),l=c(`${P(e)}:00`);return ee&&l<c(ee)?(D("exceedMin"),!1):!(l>o)||(D("exceedMax"),!1)}function je(e,t="add"){const{type:i,dataIndex:n,index:o,data:l,key:r}=e,s=fe.find((e=>e.type===i));if("add"===t){const e=d(s)?s.dataList.find((e=>e.enable)):s.dataList[n],t=y(l.time,e.list);e.list.splice(t,0,l)}else s.dataList[n].list[o]=l;we()}function we(){var e;pe.size&&(null==(e=E.value)||e.remove(...function(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine),Object.values((null==e?void 0:e.otherObj)||{}).forEach((e=>{(null==e?void 0:e.obj)&&t.push(null==e?void 0:e.obj)}))})),t}([...pe]))),pe.clear(),Le()}function Le(e){ae.clear(),pe.clear(),ce.clear(),he.clear(),de.clear(),fe.forEach((t=>{t.show&&(null==e||e(t),t.dataList.forEach(((e,i)=>{!e.show||d(t)&&!e.enable||ge(e,i,t)})))})),ve(),[...pe].forEach((e=>{null==e||e.bringToFront()})),function(){var e;const t=fe.find((e=>e.show&&"pulse"===e.type));if(!t||!(null==(e=t.dataList)?void 0:e.length))return;if(!t.dataList.some((e=>e.title.includes("脉搏"))))return;const i=Object.assign({},S,z.overlap||{}),l=[];ce.size&&[...ce].forEach((e=>{[...de].forEach((t=>{if(t.origin&&p(e,t)){const e=t.origin.key;if(e){const r={left:t.left,top:t.top,...n,hoverCursor:"default"};let s="koumai";"yemai"===e&&(s=e),l.push(o(s,{...i[e],...r}))}}}))})),setTimeout((()=>{E.value.add(...l),l.forEach((e=>{null==e||e.bringToFront(),pe.add(e)}))}))}()}return function(){const t=new e.Rect({left:oe,top:0,width:le-oe-re.strokeWidth,height:ie-re.strokeWidth,fill:"transparent",...re});E.value.add(t)}(),Le((e=>function(e){if("temperature"!==e.type||!e.positionLine)return;const t=V(e.type,e.positionLine.value),n=i([G,t,N,t],e.positionLine);E.value.add(n)}(e))),E.value.on("mouse:up",(e=>{const{button:t,target:i,pointer:n={}}=e;if(3===t){if(!O.event.evented)return;const{x:e=0,y:t=0}=n;if(e>=G&&e<=N&&t>=B&&t<=J){I.point={x:e,y:t},I.show=!0;const{type:o}=(null==i?void 0:i.origin)||{};if(i&&["temperature","pain"].includes(o))"temperature"===o&&(I.list=[...L]),"pain"===o&&(I.list=[...k]),I.target=i;else{I.target=null,I.list=["新增节点"],K.forEach((i=>{if(!X([...pe],e,"_type").includes(i.bigType)){const e=["pain"].includes(i.bigType)?Z:U;t>=e.originY&&t<=e.endY&&I.list.push({renderItem:C?C(i):()=>i.title,origin:{title:i.title,unit:i.unit,type:a(i.bigType),dataIndex:i.dataIndex,key:i.key,isOneLine:i.isOneLine},pointer:n})}}));const i=be(e);i&&1!==I.list.length||(I.show=!1,1===I.list.length&&i&&D("repeat"))}}}if(1===t){if(i)return;const{x:e=0,y:t=0}=n;e>=G&&e<=N&&t>0&&t<ie&&$("click:grid",{x:e,y:t,time:P(e)})}})),{clickMenu:function({item:e,target:t}){if(t){const{data:i,type:n,isOneLine:o,dataIndex:l,index:r}=t.origin,s=m(i,[...L,...k]);s[`${e.type}`]=e.value,s.changeTime=u(new Date,"yyyy-MM-dd HH:mm"),o&&(s.key=t.origin.key);const a={...t.origin,data:s};$("change",a),je(a,"change")}else{const t={data:{time:P(e.pointer.x),value:R(e.origin.type,e.pointer.y),...e.origin.isOneLine?{key:e.origin.key}:{}},...e.origin};$("add",t),je(t)}},setPopup:me,isAddPoint:be,updateData:je,redrawPoints:we,gridPoints:pe,fixedNoRisePoints:he}}function M(e,t){return e.fixed||!t.value&&0!==t.value}export{E as useCenter};
1
+ import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useShadow as t}from"./useShadow.js";import{drawLine as i,defaultStyle as n,drawPoint as o,drawText as l,drawArrow as s}from"../useDraw.js";import{useGrid as r}from"../useGrid.js";import{format as u}from"date-fns";import{getType as a,getTime as c,isOneLine as d,isOverlapPoint as p,getFloorNumber as f,isValidValue as h,setOtherType as v,isEffectiveNode as g,deleteProperty as m,getIndex as y}from"../../utils/index.js";import{cloneDeep as x,flatten as b,last as j}from"lodash-es";import"../useEvent.js";import{useCommon as w}from"../useCommon.js";import"vue";import"naive-ui";import"@vueuse/core";import{TEMPERATURE_MENU as L,PAIN_MENU as k,OVERLAP as S}from"../../constants/index.js";import{promiseTimeout as Y}from"@vueuse/shared";function E(E,O,$,T,V,P,R,C,A,I){r(E,O);const{getEqualXTypes:X,handleAddPrevent:D,getPointEventProps:H}=w(E,$,O),{createShadowLines:W}=t(),{left:z,xScaleList:F,xCellWidth:_,yCellHeight:q,originX:G,endX:N,originY:B,endY:J,itemList:K,event:Q,vitalSignsOriginY:U,painOriginY:Z,hospitalizationDate:ee,config:te,canvasHeight:ie,painSurplusCell:ne,iconsWidth:oe,canvasWidth:le,borderStyle:se}=O,re=new Set,ue=["xinmai","mai"],ae=new Map,ce=new Set,de=new Set,pe=new Set,fe=x(z.yScaleValue),he=new Set;function ve(t){var o;const l=fe.find((e=>e.show&&"pulse"===e.type));if(l&&(null==(o=l.dataList)?void 0:o.length)&&(re.size&&E.value.remove(...re),re.clear(),ae.size>1)){if(t){const{type:e,key:i}=t.origin||{};if("pulse"===e){const e=ae.get(i),n=null==e?void 0:e.findIndex((e=>e[0]===t.left));e.splice(n,1,[t.left,t.top])}}const o=function(){const e=[],t=[],i=[];for(const e of ae)t.push(e[1]),e[0]===ue[0]&&e[1].forEach((e=>{(ae.get(ue[1])||[]).findIndex((t=>t[0]===e[0]))>-1&&i.push(e[0])}));const[n,o]=t;let l=[],s=[];return i.forEach((t=>{const i=n.findIndex((e=>e[0]===t)),r=o.findIndex((e=>e[0]===t)),u=n[i],a=o[r],c=n[i-1],d=n[i+1],p=o[r-1],f=o[r+1];if(c&&p){if(c[0]!==p[0]){const e=Math.max(c[0],p[0]);l.push([c,p].find((t=>t[0]===e)))}}else c?l.push(c):p&&s.push(p);const h=Math.min(u[1],a[1]);l.push([u,a].find((e=>e[1]===h)));const v=Math.max(u[1],a[1]);s.push([u,a].find((e=>e[1]===v)));const g=()=>{const t=[...l,...s.reverse()],[i]=t,n=j(t);i[0]===n[0]&&i[1]===n[1]&&t.splice(-1,1),e.push(t),l=[],s=[]};if(d&&f){if(d[0]!==f[0]){const e=Math.min(d[0],f[0]);l.push([d,f].find((t=>t[0]===e))),g()}}else d?(l.push(d),g()):f?(s.push(f),g()):g()})),e}();o.length>0&&function(e){Y(0).then((()=>{e.forEach((e=>{const t=[],i=[];Array.from(pe).forEach((n=>{var o,l;"pulse"===(null==(o=null==n?void 0:n.origin)?void 0:o.type)&&e.find((e=>Math.abs(n.left-e[0])<=1&&Math.abs(n.top-e[1])<=1))&&((null==(l=null==n?void 0:n.origin)?void 0:l.key)===ue[0]?t.push(n):i.push(n))})),[t,i].forEach((e=>{1!==(null==e?void 0:e.length)&&e.sort(((e,t)=>e.left-t.left)).forEach(((e,t)=>{0==t?e.rightLine&&E.value.remove(e.rightLine):e.leftLine&&E.value.remove(e.leftLine)}))}))}))}))}(o);const{mode:s,style:r={}}=l.shadow||{};o.forEach((t=>{const o=t.map((e=>({x:e[0],y:e[1]}))),l=new e.Polygon(o,{...n,...r,strokeWidth:1});if(["slash","line"].includes(s)){l.set({fill:"transparent",stroke:r.stroke||"#f00"});const e=[];if(["slash"].includes(s))e.push(...W(t,r._angle,r.space)),e.forEach((e=>{Object.assign(e,{...n,...r}),re.add(e)}));else{const n=function(e){const t=e.reduce(((e,t)=>{const i=Math.trunc(t[0]);return e[i]=e[i]?e[i].concat([t]):[t],e}),{}),i=Object.values(t).filter((e=>2===e.length&&Math.trunc(e[0][1])!==Math.trunc(e[1][1])));return i}(t);n.forEach((t=>{const n=i([...b(t)],{...r,originX:"center"});e.push(n),re.add(n)}))}E.value.add(...e)}re.add(l),E.value.add(l)}))}}function ge(e,t,r){var u;const{type:a,riseStyle:c={},noRiseStyle:p={},verifiedStyle:g={},reduceStyle:m={},pacemaker:y={},upArrowStyle:b={},limitValueStyle:j={},nonePainPointStyle:w={},belowMinValueStyle:L={},respiratorStyle:k={},dataList:S=[],list:Y=[]}=r,{type:O,textStyle:P}=w,C=[],I=[],X=[];let D=null;const W=e=>"breathe"==a&&e.respirator&&k.type&&k.fixedValue&&!e.value&&xe(e.time),z=d(r);if(null==(u=e.list)||u.forEach(((u,d)=>{const w=z?S.find((e=>e.key===u.key)):e,F=be(W(u)?{...u,value:k.fixedValue}:u,r),G=e.list[d+1],N=G?be(W(G)?{...G,value:k.fixedValue}:G,r):void 0,B=G?z?S.find((e=>e.key===G.key)):e:{},{title:J=""}=w;if("脉搏"===J&&"脉搏"!==B.title||"脉搏"!==J&&"脉搏"===B.title||!F||!N||f(F[0],1)!==f(N[0],1))F&&D&&(F[0]=D),D=null;else{const e=F[0]-_/2;F[0]=e+_/4,N[0]=D=F[0]+_/2}const K={};K.value=function(e,t,i){if(!(null==e?void 0:e.length)||!te.showValue)return;const{lineAttr:n={}}=i,o=e[1]<=U.originY+q?e[1]+q:e[1]-q,s=l([e[0],o],{value:W(t)?k.fixedValue:t.value,originX:"center",originY:"center",fill:n.stroke||"#000"});return X.push(s),{obj:s,top:-q}}(F,u,w),function(e,t,r,u){var d,f,v;if(!["temperature","pain","breathe"].includes(a))return;if(!(null==e?void 0:e.length)&&"temperature"===a&&!xe(t.time))return;if(!(null==e?void 0:e.length)&&"pain"===a)return;if(!t.value&&"breathe"===a)return;const{lineAttr:y={},key:x}=r,{value:b}=u,j=T(t.time);let w,L,S,Y,E,O;if(t.noRise&&p.show){const i=M(p,t)?V(a,35):(null==e?void 0:e[1])||0;if(p.text)S=l([j,M(p,t)?i:i+5],{value:p.text.split("").join("\n"),originY:"top",...p.style}),t.value||pe.add(S);else if(t.value){S=s([j,i,i+2*q],{...p.style})}S&&X.push(S),S&&M(p,t)&&he.add(S)}if(null==e?void 0:e[1]){if(t.rise&&c.show&&c.text&&(Y=l([j,e[1]-(b?q:0)-5],{value:c.text.split("").join("\n"),originY:"bottom",...c.style}),X.push(Y)),t.verified){const t=(null==(d=null==g?void 0:g.position)?void 0:d[x])||"top";E=l(["top-right"===t?j+_/2:j,e[1]-(b?q:0)-5],{value:"v",originX:"center",originY:"bottom",...g}),X.push(E)}if(h(t.physicsReduce)||h(t.drugReduce)){const l=V(a,null!=(f=t.physicsReduce)?f:t.drugReduce),s=l<e[1]&&(null==te?void 0:te.hypothermyViewCustom)?j+_/2:j;w=i([...e,s,l],{...y,...m.line,...n}),L=o((null==(v=null==m?void 0:m.point)?void 0:v.type)||"circle",{left:s,top:l,...m.point,...n,originY:l===ie?"bottom":"center"}),w&&X.push(w),L&&X.push(L)}t.respirator&&(O=o(k.type,{left:j,top:e[1]-(b?q:0)-5,originX:"center",originY:"bottom",...k.style}),X.push(O))}Object.assign(u,{reduceLine:{obj:w,type:"line"},noRiseText:{obj:S,top:p.text?5:2*q,isFixed:M(p,t)},riseText:{obj:Y,top:(b?-q:0)-5},verifiedText:{obj:E,left:_/2,top:(b?-q:0)-5},reducePoint:{obj:L,type:"reduce"},respirator:{obj:O,top:(b?-q:0)-5}})}(F,u,w,K),function(e,t,i,n){if(!(null==e?void 0:e.length)||!["pulse"].includes(a))return;const o=Math.max(...Y),r=Math.min(...Y);let u,c,d;const{upArrowShow:p=!1,limitValueShow:f=!1}=i;if(p&&+t.value>180){let t=e[1]-2.5*q,i=[e[1]-q/2,t];t<U.originY&&(t=e[1]+2.5*q,i=[t,e[1]+q/2]),u=s([e[0],i[0],i[1]],b,"up"),X.push(u)}if(f){const i={value:t.value,originX:"center",originY:"center",...j};if(+t.value>o){const t=u?e[1]+q/2+u.height:e[1]+q;c=l([e[0],t],i),X.push(c)}+t.value<r&&(c=l([e[0],e[1]-q],i),X.push(c))}if(L.show&&+t.value<r){const t=e[1];if(L.text)d=l([e[0],e[1]+5],{value:L.text.split("").join("\n"),originY:"top",...L.style});else{const i=t+2*q;d=s([e[0],t,i],{...L.style})}X.push(d)}Object.assign(n,{upArrow:{obj:u},limitValue:{obj:c,top:-q},belowMinValue:{obj:d,top:L.text?5:2*q,moveHide:!0}})}(F,u,w,K),function(n,l,s,u,c,d){let f,h;const{pointAttr:g={},lineAttr:m={},title:b="",key:j,type:w="circle"}=c,L=g.height?g.height/2:5,S=e.list[u+1];let Y=x(n),M=x(l);const D=me(a,e.list[u].value),F=()=>"pulse"==a&&s.pacemakerShow?y.value:W(s)?k.type:D&&"number"===O?0:w,_=e=>e&&p.show&&p.fixed&&xe(e.time)&&e.noRise&&!e.value&&0!==e.value;if((()=>{if(s.breakpoint)return!1;if("temperature"===a&&(n||_(s))&&(l||_(S))){const e=V(a,35);return n||(Y=[T(s.time),e]),l||(M=[T(S.time),e]),!0}return!!n&&!!l})()){Y&&M&&D&&me(a,S.value)&&!ne[1]&&"icon"===O&&(Y[1]=Y[1]-L,M[1]=M[1]-L),h=i([...Y,...M],{...m});const{obj:e}=(null==d?void 0:d.reducePoint)||{};if(n&&l&&(null==e?void 0:e.top)<n[1]&&(null==te?void 0:te.hypothermyViewCustom)){const t=i([e.left,e.top,...l],{...m});X.unshift(t),Object.assign(d,{reduceRightLine:{obj:t,type:"reduce"}}),h.set("stroke","transparent")}}const q=F(),G=I[u-1],N={origin:{data:W(s)?{...s,value:k.fixedValue}:s,title:b,key:j||"",unit:r.unit,type:a,_type:v(b,a),dataIndex:t,index:u,isOneLine:z},leftLine:G,rightLine:h,otherObj:d,...s.pacemakerShow&&"pulse"==a?y.style:W(s)?k.style:g,...H(),lockMovementX:!0,...D?{selectable:!1,evented:!1,..."number"===O?P:{}}:{}};n&&(G?N.leftLine.set("x2",n[0]):N.leftLine=null,f=o(q,{left:n[0],top:D&&!ne[1]?n[1]-L:n[1],...N}));I.push(h),f&&(j===ue[1]?ce.add(f):W(s)||de.add(f),function(e){Q.hovered&&(e.on("mouseover",(()=>{ye(e,"hover")})),e.on("mouseout",(()=>{A.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{!function(e){e.setCoords();const t="pain"===e.origin.type?Z:U;e.top<t.originY&&e.set("top",t.originY);e.top>t.endY&&e.set("top",t.endY)}(e),function(e){var t,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(i=e.rightLine)||i.setCoords().set({x1:e.left,y1:e.top}),Object.values(e.otherObj).forEach((t=>{const{obj:i,type:n="",top:o=0,isFixed:l,moveHide:s=!1,left:r=0}=t||{};"reduce"!==n&&i&&("line"===n?i.setCoords().set({x1:e.left,y1:e.top}):(l||i.setCoords().set({left:e.left+r,top:e.top+o}),s&&(E.value.remove(i),delete e.otherObj.obj)))})),ve(e)}(e),Q.hovered&&ye(e)})),e.on("mouseup",(t=>{if(A.show=!1,1===t.button){const{type:t}=e.origin,i=R(t,e.top),n={...e.origin,data:{...e.origin.data,value:i}};E.value.discardActiveObject(),$("change",n),we(n,"change")}}))}(f),C.push(f),pe.add(f))}(F,N,u,d,w,K)})),"pulse"===a){let t=null;const i=e=>e.map(((e,i,n)=>{var o,l;const s=n[i+1];if(s&&f(e.left,1)===f(s.left,1)){const i=e.left-_/2;e.set("left",i+_/4),null==(o=e.rightLine)||o.set("x1",e.left),t=e.left+_/2,s.set("left",t)}else t&&(null==(l=e.leftLine)||l.set("x2",t),e.set("left",t)),t=null;return[e.left,e.top]}));if(z){const e={};ue.forEach((t=>{e[t]=C.filter((e=>{var i;return(null==(i=e.origin)?void 0:i.key)===t})),ae.set(t,i(e[t]))}))}else{const{key:t}=e;ae.set(t,i(C))}}const F=I.filter((e=>e));E.value.add(...F,...C,...X)}function me(e,t){return"pain"===e&&0==t}function ye(e,t="moving"){const{title:i,unit:n,type:o,data:l}=e.origin;A.point={x:e.left,y:e.top};let s=`时间 ${((null==l?void 0:l.time)||P(e.left)).slice(-5)}`;A.list=[function(){const{drugReduce:r,physicsReduce:u}=l||{},a="hover"===t?l.value:R(o,e.top);if(h(r))return s+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`药物降${"pain"==o?"痛":"温"} ${a}—>${r}${n||""}`;if(h(u))return s+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`物理降${"pain"==o?"痛":"温"} ${a}—>${u}${n||""}`;return`${i} ${a}${n||""}`}(),s],A.show=!0}function xe(e){const[t]=F,i=j(F),n=t.start,o=i.end,l=c(e);return l>=n&&l<=o}function be(e,t){const i="pain"===t.type?Z:U;if(!g(e)||!xe(e.time))return;const n=T(e.time),o=V(t.type,e.value);return[n,o<i.originY?i.originY:o>i.endY?i.endY:o]}function je(e){const t=new Date,i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=c(`${t.getFullYear()}-${i}-${n} 23:59:59`),l=c(`${P(e)}:00`);return ee&&l<c(ee)?(D("exceedMin"),!1):!(l>o)||(D("exceedMax"),!1)}function we(e,t="add"){const{type:i,dataIndex:n,index:o,data:l,key:s}=e,r=fe.find((e=>e.type===i));if("add"===t){const e=d(r)?r.dataList.find((e=>e.enable)):r.dataList[n],t=y(l.time,e.list);e.list.splice(t,0,l)}else r.dataList[n].list[o]=l;Le()}function Le(){var e;pe.size&&(null==(e=E.value)||e.remove(...function(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine),Object.values((null==e?void 0:e.otherObj)||{}).forEach((e=>{(null==e?void 0:e.obj)&&t.push(null==e?void 0:e.obj)}))})),t}([...pe]))),pe.clear(),ke()}function ke(e){ae.clear(),pe.clear(),ce.clear(),he.clear(),de.clear(),fe.forEach((t=>{t.show&&(null==e||e(t),t.dataList.forEach(((e,i)=>{!e.show||d(t)&&!e.enable||ge(e,i,t)})))})),ve(),[...pe].forEach((e=>{null==e||e.bringToFront()})),function(){var e;const t=fe.find((e=>e.show&&"pulse"===e.type));if(!t||!(null==(e=t.dataList)?void 0:e.length))return;if(!t.dataList.some((e=>e.title.includes("脉搏"))))return;const i=Object.assign({},S,z.overlap||{}),l=[];ce.size&&[...ce].forEach((e=>{[...de].forEach((t=>{if(t.origin&&p(e,t)){const e=t.origin.key;if(e){const s={left:t.left,top:t.top,...n,hoverCursor:"default"};let r="koumai";"yemai"===e&&(r=e),l.push(o(r,{...i[e],...s}))}}}))})),setTimeout((()=>{E.value.add(...l),l.forEach((e=>{null==e||e.bringToFront(),pe.add(e)}))}))}()}return function(){const t=new e.Rect({left:oe,top:0,width:le-oe-se.strokeWidth,height:ie-se.strokeWidth,fill:"transparent",...se});E.value.add(t)}(),ke((e=>function(e){if("temperature"!==e.type||!e.positionLine)return;const t=V(e.type,e.positionLine.value),n=i([G,t,N,t],e.positionLine);E.value.add(n)}(e))),E.value.on("mouse:up",(e=>{const{button:t,target:i,pointer:n={}}=e;if(3===t){if(!O.event.evented)return;const{x:e=0,y:t=0}=n;if(e>=G&&e<=N&&t>=B&&t<=J){I.point={x:e,y:t},I.show=!0;const{type:o}=(null==i?void 0:i.origin)||{};if(i&&["temperature","pain"].includes(o))"temperature"===o&&(I.list=[...L]),"pain"===o&&(I.list=[...k]),I.target=i;else{I.target=null,I.list=["新增节点"],K.forEach((i=>{if(!X([...pe],e,"_type").includes(i.bigType)){const e=["pain"].includes(i.bigType)?Z:U;t>=e.originY&&t<=e.endY&&I.list.push({renderItem:C?C(i):()=>i.title,origin:{title:i.title,unit:i.unit,type:a(i.bigType),dataIndex:i.dataIndex,key:i.key,isOneLine:i.isOneLine},pointer:n})}}));const i=je(e);i&&1!==I.list.length||(I.show=!1,1===I.list.length&&i&&D("repeat"))}}}if(1===t){if(i)return;const{x:e=0,y:t=0}=n;e>=G&&e<=N&&t>0&&t<ie&&$("click:grid",{x:e,y:t,time:P(e)})}})),{clickMenu:function({item:e,target:t}){if(t){const{data:i,type:n,isOneLine:o,dataIndex:l,index:s}=t.origin,r=m(i,[...L,...k]);r[`${e.type}`]=e.value,r.changeTime=u(new Date,"yyyy-MM-dd HH:mm"),o&&(r.key=t.origin.key);const a={...t.origin,data:r};$("change",a),we(a,"change")}else{const t={data:{time:P(e.pointer.x),value:R(e.origin.type,e.pointer.y),...e.origin.isOneLine?{key:e.origin.key}:{}},...e.origin};$("add",t),we(t)}},setPopup:ye,isAddPoint:je,updateData:we,redrawPoints:Le,gridPoints:pe,fixedNoRisePoints:he}}function M(e,t){return e.fixed||!t.value&&0!==t.value}export{E as useCenter};
@@ -1 +1 @@
1
- const e={repeat:"该时段已存在数值不能新增",exceedMax:"未来时间不允许录入",exceedMin:"不允许小于入院时间"};function n(n,t,i){return{getEqualXTypes:function(e,n,t,o=i.xCellWidth){const r=[],l=o/2;return e.forEach((e=>{e.origin&&!e.origin.isMenu&&Math.abs(n-e.left)<=l&&r.push(e.origin[t])})),[...new Set(r)]},handleAddPrevent:function(n){t("add:prevent",{type:n,message:e[n]})},isGridLimit:function(e){const{left:n,top:t}=e,{originX:o,endX:r,originY:l,endY:c}=i;return n>=o&&n<=r&&t>=l&&t<=c},setPrevAndNextPoint:function(e){e.reduce(((e,n)=>e&&n?(n.prevPoint=e,e.nextPoint=n,n):n||e),null)},getPointEventProps:function(){var e,n;return(null==(e=i.event)?void 0:e.hovered)?(null==(n=i.event)?void 0:n.evented)?{selectable:!0}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:i.event}}}export{n as useCommon};
1
+ const e={repeat:"该时段已存在数值不能新增",exceedMax:"未来时间不允许录入",exceedMin:"不允许小于入院时间"};function n(n,t,o){return{getEqualXTypes:function(e,n,t,i=o.xCellWidth){const r=[],c=i/2;return e.forEach((e=>{e.origin&&!e.origin.isMenu&&Math.abs(n-e.left)<=c&&r.push(e.origin[t])})),[...new Set(r)]},handleAddPrevent:function(n){t("add:prevent",{type:n,message:e[n]})},isGridLimit:function(e){const{left:n,top:t}=e,{originX:i,endX:r,originY:c,endY:l}=o;return n>=i&&n<=r&&t>=c&&t<=l},setPrevAndNextPoint:function(e){e.reduce(((e,n)=>e&&n?(n.prevPoint=e,e.nextPoint=n,n):n||e),null)},getPointEventProps:function(){const{hovered:e,evented:n}=o.event;return e?n?{selectable:!0,lockMovementX:!!Reflect.has(o.event,"lockMovementX")&&o.event.lockMovementX}:{selectable:!0,lockMovementX:!0,lockMovementY:!0}:o.event}}}export{n as useCommon};
@@ -3243,11 +3243,12 @@ declare const IhoTable: SFCWithInstall<import("vue").DefineComponent<{
3243
3243
  rowHeight?: number | undefined;
3244
3244
  fixedColumnList?: {
3245
3245
  setting: {
3246
- name: string;
3247
- option: {
3246
+ alias?: string | undefined;
3247
+ name?: string | undefined;
3248
+ option?: {
3248
3249
  text: string;
3249
3250
  value?: string | undefined;
3250
- }[];
3251
+ }[] | undefined;
3251
3252
  };
3252
3253
  columnWidth?: number | undefined;
3253
3254
  }[] | undefined;
@@ -6836,11 +6837,12 @@ declare const IhoTable: SFCWithInstall<import("vue").DefineComponent<{
6836
6837
  rowHeight?: number | undefined;
6837
6838
  fixedColumnList?: {
6838
6839
  setting: {
6839
- name: string;
6840
- option: {
6840
+ alias?: string | undefined;
6841
+ name?: string | undefined;
6842
+ option?: {
6841
6843
  text: string;
6842
6844
  value?: string | undefined;
6843
- }[];
6845
+ }[] | undefined;
6844
6846
  };
6845
6847
  columnWidth?: number | undefined;
6846
6848
  }[] | undefined;
@@ -3245,11 +3245,12 @@ declare const _default: import("vue").DefineComponent<{
3245
3245
  rowHeight?: number | undefined;
3246
3246
  fixedColumnList?: {
3247
3247
  setting: {
3248
- name: string;
3249
- option: {
3248
+ alias?: string | undefined;
3249
+ name?: string | undefined;
3250
+ option?: {
3250
3251
  text: string;
3251
3252
  value?: string | undefined;
3252
- }[];
3253
+ }[] | undefined;
3253
3254
  };
3254
3255
  columnWidth?: number | undefined;
3255
3256
  }[] | undefined;
@@ -6838,11 +6839,12 @@ declare const _default: import("vue").DefineComponent<{
6838
6839
  rowHeight?: number | undefined;
6839
6840
  fixedColumnList?: {
6840
6841
  setting: {
6841
- name: string;
6842
- option: {
6842
+ alias?: string | undefined;
6843
+ name?: string | undefined;
6844
+ option?: {
6843
6845
  text: string;
6844
6846
  value?: string | undefined;
6845
- }[];
6847
+ }[] | undefined;
6846
6848
  };
6847
6849
  columnWidth?: number | undefined;
6848
6850
  }[] | undefined;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,provide as o,computed as a,toRaw as l,watch as n,resolveComponent as r,openBlock as i,createElementBlock as s,mergeProps as u,unref as d,createBlock as c,resolveDynamicComponent as f,createElementVNode as m,normalizeStyle as v,createVNode as h,withCtx as p,createSlots as g,renderList as b,createCommentVNode as x,renderSlot as y,normalizeProps as k,guardReactiveProps as C,nextTick as D}from"vue";import{useTheme as $,createOpacityColor as j}from"../../../shared/hooks/useTheme.js";import{useDebounceFn as w}from"@vueuse/core";import"date-fns";import{isString as T,isEqualWith as I,isFunction as R,pick as S}from"lodash-es";import{useFormAsyncQueue as q,presetRequestHandler as H}from"../../../shared/hooks/useFormRequest/index.js";import{hex2rgba as L,widthAppend as P,uuidGenerator as _}from"../../../shared/utils/index.js";import{promiseTimeout as A}from"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import{NConfigProvider as B}from"naive-ui";import{useVersion as F}from"../../../shared/hooks/useVersion.js";import"../../../shared/hooks/useScrollLoading.js";import{VxeTableEventNameList as M,InjectionIhoTableXeInstance as O,InjectionIhoTableLoading as E,InjectionIhoTableEmits as W,InjectionTableAsyncQueue as N,InjectionIhoTableAnnotation as V,InjectionIhoTableUUID as z,InjectionIhoTableInstance as G,InjectionIhoTableConfig as J,InjectionIhoTableFieldList as K,InjectionIhoTableHandler as Q,InjectionIhoTableGlobProps as U}from"./constants/index.js";import{createTableHooks as X,applyTableConfigHooks as Y,applyTableFieldHooks as Z,createTableEventHandlers as ee,createDomInsertComponent as te,createDataTransfer as oe}from"./hooks/tapHooks/index.js";import{provideIhoTableEventListener as ae}from"./hooks/tapHooks/useEventHooks.js";import{eventName2EventListener as le}from"./utils/index.js";const ne=["id"];var re=e({__name:"IhoTable",props:{tableConfig:{type:Object,default:()=>({})},fieldList:{type:Array,default:()=>[]},tableData:{type:Array,default:()=>[]},annotation:{type:Object},requestInstance:{type:Object},uniqueCacheData:{type:Boolean,default:!1},parallelism:{type:Number,default:3},developMode:{type:Boolean,default:!1}},emits:["formChange","settingClick","formClick","keyboard","rowDrag",...M],setup(e,{expose:M,emit:re}){var ie,se;const ue=e,de=t();o(O,de);const ce=t(!1),fe=a((()=>{var e;return(null==(e=ue.tableConfig)?void 0:e.loading)||ce.value}));o(E,ce);const me=$({"--c-border-color":"#d0d0d0","--c-head-bg-color":"#f2f2f2","--c-hover-color":"#e6e6e6","--c-stripe-color":"#f6f6f6"}),ve=a((()=>{var e,t,o;const a={...me.value};return a["--c-primary-color-opacity3"]=j(...L(a["--c-primary-color"]+""),.3),a["--c-scrollbar-width"]=P(null!=(o=null==(t=null==(e=de.value)?void 0:e.reactData)?void 0:t.scrollbarWidth)?o:0),a})),he=a((()=>{var e,t;const o=null!=(t=null==(e=ue.tableConfig)?void 0:e.height)?t:"100%";return{height:"auto"===o?"100%":T(o)&&(o.includes("calc")||o.endsWith("%"))?o:P(o)}})),pe=ae(),ge=function(e,...t){re(e,...t);const o=d(Ce)[le(e)];R(o)&&o(...t),pe.trigger(e,...t)};o(W,ge);const be=q(a((()=>ue.requestInstance)),a((()=>!!ue.uniqueCacheData))).create(ue.parallelism,{beforeRequest:(e,t)=>t,afterRequest:(e,t)=>H(t)});o(N,be);const xe=X();o(V,a((()=>ue.annotation)));const ye=_();o(z,ye);const ke=t();o(G,ke);const Ce=t({uuid:null!=(se=null==(ie=ue.tableConfig)?void 0:ie.uuid)?se:ye});o(J,Ce);const De=w($e,10);function $e(){var e,t;Ce.value=Y(xe,{...ue.tableConfig,uuid:null!=(t=null==(e=ue.tableConfig)?void 0:e.uuid)?t:ye},{$table:ke,emits:ge,globProps:ue,loading:ce,$xeTable:de})}const je=a((()=>{if(!Ce.value.tableRowHeight)return{};const e=P(Ce.value.rowConfig.height);return{Input:{heightLarge:e,heightMedium:e,heightSmall:e,heightTiny:e},InternalSelection:{heightLarge:e,heightMedium:e,heightSmall:e,heightTiny:e}}})),we=t([]);o(K,we);const Te=w(Ie,10);function Ie(){const e=Z(xe,ue.fieldList,Ce.value,{$table:ke,emits:ge,loading:ce,globProps:ue,$xeTable:de});I(e,l(we.value),((e,t)=>{if(R(e)&&R(t))return e.toString()===t.toString()}))||(we.value=e)}const Re=oe(xe,Ce,ke);let Se=null;function qe(e){Se=e}async function He(){await D(),null==Se||Se(),Se=null}const Le=t([]);async function Pe(){var e,t;const o=await Re(ue.tableData),a=null==(e=ke.value)?void 0:e.getTableData().fullData;if(a){let e=0;if(!(a.some((t=>{var a;if(!(null==(a=ke.value)?void 0:a.isInsertByRow(t))){if(t!==o[e])return!0;e++}}))||e!==o.length))return void He()}Le.value=o,null==(t=ke.value)||t.recalculate(!0),He()}const _e={updateTableDataRef:w(Pe,10),updateConfigRef:De,updateFieldListRef:Te};o(Q,_e),o(U,ue);const Ae=ee({hooks:xe,config:Ce,$table:ke,context:_e,emits:ge,globProps:ue,loading:ce,$xeTable:de}),Be=a((()=>({...Ce.value,...Ae})));let Fe=!1,Me=!1,Oe=!1;const Ee=w((()=>{Fe&&$e(),Me&&Ie(),Oe&&Pe(),Fe=!1,Me=!1,Oe=!1}),10);n((()=>ue.tableConfig),(()=>{Fe=!0,Me=!0,Oe=!0,Ee()}),{deep:!0}),n((()=>ue.fieldList),(()=>{Me=!0,Oe=!0,Ee()}),{deep:!0}),n([()=>[...ue.tableData],()=>{var e;return null==(e=ue.tableData)?void 0:e.length}],(()=>{Oe=!0,Ee()})),n([()=>ue.tableData,()=>{var e;return null==(e=ue.tableData)?void 0:e.length}],(async()=>{var e,t;(null==(e=Ce.value.treeConfig)?void 0:e.expandAll)&&(await A(11),null==(t=ke.value)||t.setAllTreeExpand(!0))})),$e(),Ie(),Pe();const{header:We,footer:Ne}=te(xe);function Ve(e){return S(e,["row","rowIndex","$rowIndex","column","columnIndex","$columnIndex","_columnIndex","checked","disabled","indeterminate"])}return M({$table:ke,async loadData(e){var t;null==(t=ke.value)||t.loadData(await Re(e))},setSort:(e,t)=>({field:e,value:t}),setFilter:(e,t)=>({field:e,value:t}),tableDataResolved:()=>new Promise(qe),reload(){var e,t;null==(e=ke.value)||e.loadColumn([]),null==(t=ke.value)||t.loadData([]),$e(),Ie(),Pe()},verticalTable:{update:()=>{}},...xe.exposeHooks.expose.call({},Ce,{$table:ke,emits:ge,globProps:ue,loading:ce,$xeTable:de,..._e})}),xe.setupHooks.setup.call(Ce,we,{$table:ke,emits:ge,globProps:ue,loading:ce,$xeTable:de}),(e,t)=>{const o=r("vxe-grid");return i(),s("section",u({class:"iho-table",id:d(ye),style:d(ve)},d(F)()),[(i(),c(f(d(We)))),m("section",{style:v(d(he))},[h(d(B),{abstract:"",namespace:"vxe-table--ignore-clear","theme-overrides":d(je)},{default:p((()=>[h(o,u({ref_key:"$table",ref:ke},d(Be),{columns:we.value,data:Le.value,loading:d(fe)}),g({_:2},[b(e.$slots,((t,o)=>({name:o,fn:p((t=>[x(" 实际上所有的vxe-grid插槽都支持 "),y(e.$slots,o,k(C(Ve(t))))]))})))]),1040,["columns","data","loading"])])),_:3},8,["theme-overrides"])],4),(i(),c(f(d(Ne))))],16,ne)}}});export{re as default};
1
+ import{defineComponent as e,ref as t,provide as o,computed as a,toRaw as l,nextTick as n,watch as i,resolveComponent as r,openBlock as s,createElementBlock as u,mergeProps as d,unref as c,createBlock as f,resolveDynamicComponent as m,createElementVNode as v,normalizeStyle as p,createVNode as h,withCtx as g,createSlots as b,renderList as x,createCommentVNode as y,renderSlot as k,normalizeProps as C,guardReactiveProps as $}from"vue";import{useTheme as D,createOpacityColor as j}from"../../../shared/hooks/useTheme.js";import{useDebounceFn as w}from"@vueuse/core";import"date-fns";import{isString as T,isEqualWith as I,isFunction as R,pick as S}from"lodash-es";import{useFormAsyncQueue as q,presetRequestHandler as H}from"../../../shared/hooks/useFormRequest/index.js";import{hex2rgba as L,widthAppend as P,uuidGenerator as _}from"../../../shared/utils/index.js";import"@vueuse/shared";import"../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import{NConfigProvider as A}from"naive-ui";import{useVersion as B}from"../../../shared/hooks/useVersion.js";import"../../../shared/hooks/useScrollLoading.js";import{VxeTableEventNameList as F,InjectionIhoTableXeInstance as M,InjectionIhoTableLoading as O,InjectionIhoTableEmits as E,InjectionTableAsyncQueue as W,InjectionIhoTableAnnotation as N,InjectionIhoTableUUID as V,InjectionIhoTableInstance as z,InjectionIhoTableConfig as G,InjectionIhoTableFieldList as J,InjectionIhoTableHandler as K,InjectionIhoTableGlobProps as Q}from"./constants/index.js";import{createTableHooks as U,applyTableConfigHooks as X,applyTableFieldHooks as Y,createTableEventHandlers as Z,createDomInsertComponent as ee,createDataTransfer as te}from"./hooks/tapHooks/index.js";import{provideIhoTableEventListener as oe}from"./hooks/tapHooks/useEventHooks.js";import{eventName2EventListener as ae}from"./utils/index.js";const le=["id"];var ne=e({__name:"IhoTable",props:{tableConfig:{type:Object,default:()=>({})},fieldList:{type:Array,default:()=>[]},tableData:{type:Array,default:()=>[]},annotation:{type:Object},requestInstance:{type:Object},uniqueCacheData:{type:Boolean,default:!1},parallelism:{type:Number,default:3},developMode:{type:Boolean,default:!1}},emits:["formChange","settingClick","formClick","keyboard","rowDrag",...F],setup(e,{expose:F,emit:ne}){var ie,re;const se=e,ue=t();o(M,ue);const de=t(!1),ce=a((()=>{var e;return(null==(e=se.tableConfig)?void 0:e.loading)||de.value}));o(O,de);const fe=D({"--c-border-color":"#d0d0d0","--c-head-bg-color":"#f2f2f2","--c-hover-color":"#e6e6e6","--c-stripe-color":"#f6f6f6"}),me=a((()=>{var e,t,o;const a={...fe.value};return a["--c-primary-color-opacity3"]=j(...L(a["--c-primary-color"]+""),.3),a["--c-scrollbar-width"]=P(null!=(o=null==(t=null==(e=ue.value)?void 0:e.reactData)?void 0:t.scrollbarWidth)?o:0),a})),ve=a((()=>{var e,t;const o=null!=(t=null==(e=se.tableConfig)?void 0:e.height)?t:"100%";return{height:"auto"===o?"100%":T(o)&&(o.includes("calc")||o.endsWith("%"))?o:P(o)}})),pe=oe(),he=function(e,...t){ne(e,...t);const o=c(ke)[ae(e)];R(o)&&o(...t),pe.trigger(e,...t)};o(E,he);const ge=q(a((()=>se.requestInstance)),a((()=>!!se.uniqueCacheData))).create(se.parallelism,{beforeRequest:(e,t)=>t,afterRequest:(e,t)=>H(t)});o(W,ge);const be=U();o(N,a((()=>se.annotation)));const xe=_();o(V,xe);const ye=t();o(z,ye);const ke=t({uuid:null!=(re=null==(ie=se.tableConfig)?void 0:ie.uuid)?re:xe});o(G,ke);const Ce=w($e,10);function $e(){var e,t;ke.value=X(be,{...se.tableConfig,uuid:null!=(t=null==(e=se.tableConfig)?void 0:e.uuid)?t:xe},{$table:ye,emits:he,globProps:se,loading:de,$xeTable:ue})}const De=a((()=>{if(!ke.value.tableRowHeight)return{};const e=P(ke.value.rowConfig.height);return{Input:{heightLarge:e,heightMedium:e,heightSmall:e,heightTiny:e},InternalSelection:{heightLarge:e,heightMedium:e,heightSmall:e,heightTiny:e}}})),je=t([]);o(J,je);const we=w(Te,10);function Te(){const e=Y(be,se.fieldList,ke.value,{$table:ye,emits:he,loading:de,globProps:se,$xeTable:ue});I(e,l(je.value),((e,t)=>{if(R(e)&&R(t))return e.toString()===t.toString()}))||(je.value=e)}const Ie=te(be,ke,ye);let Re=null;function Se(e){Re=e}async function qe(){await n(),null==Re||Re(),Re=null}const He=t([]);async function Le(){var e,t,o,a;const l=await Ie(se.tableData),i=null==(e=ye.value)?void 0:e.getTableData().fullData;if(i){let e=0;if(!(i.some((t=>{var o;if(!(null==(o=ye.value)?void 0:o.isInsertByRow(t))){if(t!==l[e])return!0;e++}}))||e!==l.length))return void qe()}He.value=l,(null==(t=ke.value.treeConfig)?void 0:t.expandAll)?(await n(),null==(o=ye.value)||o.setAllTreeExpand(!0)):null==(a=ye.value)||a.recalculate(!0),qe()}const Pe={updateTableDataRef:w(Le,10),updateConfigRef:Ce,updateFieldListRef:we};o(K,Pe),o(Q,se);const _e=Z({hooks:be,config:ke,$table:ye,context:Pe,emits:he,globProps:se,loading:de,$xeTable:ue}),Ae=a((()=>({...ke.value,..._e})));let Be=!1,Fe=!1,Me=!1;const Oe=w((()=>{Be&&$e(),Fe&&Te(),Me&&Le(),Be=!1,Fe=!1,Me=!1}),10);i((()=>se.tableConfig),(()=>{Be=!0,Fe=!0,Me=!0,Oe()}),{deep:!0}),i((()=>se.fieldList),(()=>{Fe=!0,Me=!0,Oe()}),{deep:!0}),i([()=>[...se.tableData],()=>{var e;return null==(e=se.tableData)?void 0:e.length}],(()=>{Me=!0,Oe()})),$e(),Te(),Le();const{header:Ee,footer:We}=ee(be);function Ne(e){return S(e,["row","rowIndex","$rowIndex","column","columnIndex","$columnIndex","_columnIndex","checked","disabled","indeterminate"])}return F({$table:ye,async loadData(e){var t;null==(t=ye.value)||t.loadData(await Ie(e))},setSort:(e,t)=>({field:e,value:t}),setFilter:(e,t)=>({field:e,value:t}),tableDataResolved:()=>new Promise(Se),reload(){var e,t;null==(e=ye.value)||e.loadColumn([]),null==(t=ye.value)||t.loadData([]),$e(),Te(),Le()},verticalTable:{update:()=>{}},...be.exposeHooks.expose.call({},ke,{$table:ye,emits:he,globProps:se,loading:de,$xeTable:ue,...Pe})}),be.setupHooks.setup.call(ke,je,{$table:ye,emits:he,globProps:se,loading:de,$xeTable:ue}),(e,t)=>{const o=r("vxe-grid");return s(),u("section",d({class:"iho-table",id:c(xe),style:c(me)},c(B)()),[(s(),f(m(c(Ee)))),v("section",{style:p(c(ve))},[h(c(A),{abstract:"",namespace:"vxe-table--ignore-clear","theme-overrides":c(De)},{default:g((()=>[h(o,d({ref_key:"$table",ref:ye},c(Ae),{columns:je.value,data:He.value,loading:c(ce)}),b({_:2},[x(e.$slots,((t,o)=>({name:o,fn:g((t=>[y(" 实际上所有的vxe-grid插槽都支持 "),k(e.$slots,o,C($(Ne(t))))]))})))]),1040,["columns","data","loading"])])),_:3},8,["theme-overrides"])],4),(s(),f(m(c(We))))],16,le)}}});export{ne as default};
@@ -1 +1 @@
1
- import{isEmpty as t,isObject as e,range as n,isArray as o}from"lodash-es";import{onBeforeUnmount as i}from"vue";import"../../index.js";import{useUUIDMap as r}from"../utils/index.js";import{defineTablePlugin as s}from"../hooks/useTablePlugin.js";function u(){const u="crossHeaderPlugin";return s({name:u,apply(s){const{getItemFromUUID:l,removeItemFromUUID:a,setItemFromUUID:d}=r((()=>[])),m=new WeakMap;s.fieldHooks.fieldList.tap(u,((n,i)=>{if(!i.uuid||!i.crossColumnSetting)return n;const{fixedColumnList:r,columnWidth:s,rowHeight:u}=i.crossColumnSetting;if(t(r))return n;const l=r.reduce(((t,n)=>(n&&e(n.setting)&&t.push({title:n.setting.name,field:n.setting.name,option:n.setting.option,fixed:"left",width:s||80,slots:{default({row:t,column:e}){var n;return t[e.field]||(null==(n=m.get(t))?void 0:n[e.field])||""}}}),t)),[]);if(0===l.length)return n;const a=function(t){const e=[];function n(i,r){var s;i!==t.length?o(null==(s=t[i])?void 0:s.option)&&t[i].option.forEach((e=>{n(i+1,{...r,[t[i].field]:e.text})})):e.push(r)}return n(0,{}),e}(l);d(i.uuid,a);const f=i.spanMethod;return i.spanMethod=t=>{const{column:e,rowIndex:n,columnIndex:o}=t,i={rowspan:1,colspan:1};return o<l.length?i.rowspan=function(t,e,n){var o;const i=t[n];if(i[e]&&(null==(o=t[n-1])?void 0:o[e])===i[e])return 0;let r=1;for(let o=n+1;o<t.length&&t[o][e]===i[e];o++)r++;return r}(a,e.field,n):f&&Object.assign(i,f(t)),i},u&&(i.rowConfig.height=u),[...l,...n]})),s.dataHooks.dataList.tap(u,((t,{uuid:e})=>{if(!e)return t;const o=l(e);return o?n(Math.max(t.length,o.length)).map((e=>(t[e]&&m.set(t[e],o[e]),t[e]||o[e]||{}))):t})),s.setupHooks.setup.tap(u,(t=>{i((()=>{t.value.uuid&&a(t.value.uuid)}))}))}})}export{u as crossHeaderPlugin};
1
+ import{isEmpty as t,isObject as e,range as n,isArray as o}from"lodash-es";import{onBeforeUnmount as i}from"vue";import"../../index.js";import{useUUIDMap as r}from"../utils/index.js";import{defineTablePlugin as u}from"../hooks/useTablePlugin.js";function s(){const s="crossHeaderPlugin";return u({name:s,apply(u){const{getItemFromUUID:l,removeItemFromUUID:a,setItemFromUUID:d}=r((()=>[])),f=new WeakMap;u.fieldHooks.fieldList.tap(s,((n,i)=>{if(!i.uuid||!i.crossColumnSetting)return n;const{fixedColumnList:r,columnWidth:u,rowHeight:s}=i.crossColumnSetting;if(t(r))return n;const l=r.reduce(((t,n)=>{if(n&&e(n.setting)){const{name:e,alias:o,option:i}=n.setting,r=o||e;t.push({title:r,field:r,option:i,fixed:"left",width:u||80,slots:{default({row:t,column:e}){var n;return t[e.field]||(null==(n=f.get(t))?void 0:n[e.field])||""}}})}return t}),[]);if(0===l.length)return n;const a=function(t){const e=[];function n(i,r){var u;i!==t.length?o(null==(u=t[i])?void 0:u.option)&&t[i].option.forEach((e=>{n(i+1,{...r,[t[i].field]:e.text})})):e.push(r)}return n(0,{}),e}(l);d(i.uuid,a);const m=i.spanMethod;return i.spanMethod=t=>{const{column:e,rowIndex:n,columnIndex:o}=t,i={rowspan:1,colspan:1};return o<l.length?i.rowspan=function(t,e,n){var o;const i=t[n];if(i[e]&&(null==(o=t[n-1])?void 0:o[e])===i[e])return 0;let r=1;for(let o=n+1;o<t.length&&t[o][e]===i[e];o++)r++;return r}(a,e.field,n):m&&Object.assign(i,m(t)),i},s&&(i.rowConfig.height=s),[...l,...n]})),u.dataHooks.dataList.tap(s,((t,{uuid:e})=>{if(!e)return t;const o=l(e);return o?n(Math.max(t.length,o.length)).map((e=>(t[e]&&f.set(t[e],o[e]),t[e]||o[e]||{}))):t})),u.setupHooks.setup.tap(s,(t=>{i((()=>{t.value.uuid&&a(t.value.uuid)}))}))}})}export{s as crossHeaderPlugin};
@@ -1 +1 @@
1
- import{useAttrs as e,onBeforeUnmount as t,inject as l,createVNode as o,mergeProps as n}from"vue";import{arrayed as i,widthAppend as s}from"../../../../../shared/utils/index.js";import{CodeSlash as r}from"@vicons/ionicons5";import{isObject as a,isString as u,isFunction as d}from"lodash-es";import c from"../../../../annotation-edit/index.js";import"../../../index.js";import{InjectionIhoTableAnnotation as m,InjectionIhoTableConfig as p,InjectionIhoTableXeInstance as f,InjectionIhoTableGlobProps as v}from"../../constants/index.js";import{getLowCodeFieldFromField as h,IhoTableRenderHelper as b}from"../../utils/index.js";import x from"./tooltipMessage.vue.js";import{defineTablePlugin as g}from"../../hooks/useTablePlugin.js";function j(){const j="headerPlugin";return g({name:j,apply(g){let w=null;g.setupHooks.setup.tap(j,(()=>{w=e(),t((()=>{w=null}))})),g.fieldHooks.field.tap(j,((e,t,g)=>{var j;const D=null==(j=e.slots)?void 0:j.header;return e.slots={...e.slots,header:t=>function(e,t,h){var g;const j=l(m),D=l(p),M=l("$xetable"),y=l(f);y&&!(null==y?void 0:y.value)&&(y.value=M);const W=e.column||{},k=a(null==j?void 0:j.value)&&!1!==t.annotation,O=b.isEditableColumn(D.value,W),P=b.hasFilter(t),$=b.hasTitlePrefix(e.column),C=u(h)?h:d(h)?h(e):null;let H=null==(g=t.settingObj)?void 0:g.fieldDescDev;if(u(H)&&H){const e=l(v);H=(null==e?void 0:e.developMode)?H:""}let R=!1;if(D.value){const e=D.value.editRules&&D.value.editRules[W.field];e&&(R=i(e).some((e=>e.required)))}const S=D.value.border?Math.max(2,Math.ceil(M.reactData.scrollbarWidth/M.reactData.tableColumn.length)):1,T=s(Math.max(0,W.renderWidth-20-S-(R?14:0)-(k?18:0)-(P?23:0)-(O?22:0)-($?20:0)-(W.sortable?23:0)-(H?20:0)));return o("section",{class:"iho-table__headerWrapper"},[o("section",{style:{width:T}},[null!=C?C:o("div",n({style:{maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},function(){var e;const l=null==(e=t.settingObj)?void 0:e.fieldDescribe;return l?{title:`${W.title}\n${l}`}:{}}()),[function(){const e=W.title,t=/\\n|\n|\r/g;if(!t.test(e))return e;const l=e.replace(t,"<br>").split("<br>");return l.map(((e,t)=>[e,t===l.length-1?null:o("br",null,null)]))}()])]),H?o(x,{message:H},{trigger:()=>o(r,{style:"width:14px"},null)}):null,k?o(c,{modelValue:j.value[W.field],"onUpdate:modelValue":e=>j.value[W.field]=e,shortcuts:w&&(w["annotation-shortcuts"]||w.annotationShortcuts)||[]},null):null])}(t,h(e),D)},e}))}})}export{j as default};
1
+ import{useAttrs as e,onBeforeUnmount as l,inject as t,createVNode as o,mergeProps as n}from"vue";import{arrayed as i,widthAppend as r}from"../../../../../shared/utils/index.js";import{CodeSlash as s}from"@vicons/ionicons5";import{isObject as a,isString as u,isFunction as d}from"lodash-es";import c from"../../../../annotation-edit/index.js";import"../../../index.js";import{InjectionIhoTableAnnotation as m,InjectionIhoTableConfig as v,InjectionIhoTableXeInstance as f,InjectionIhoTableGlobProps as h}from"../../constants/index.js";import{getLowCodeFieldFromField as p,IhoTableRenderHelper as b}from"../../utils/index.js";import x from"./tooltipMessage.vue.js";import{defineTablePlugin as w}from"../../hooks/useTablePlugin.js";function g(){const g="headerPlugin";return w({name:g,apply(w){let j=null;w.setupHooks.setup.tap(g,(()=>{j=e(),l((()=>{j=null}))})),w.fieldHooks.field.tap(g,((e,l,w)=>{var g;const O=null==(g=e.slots)?void 0:g.header;return e.slots={...e.slots,header:l=>function(e,l,p){var w;const g=t(m),O=t(v),D=t("$xetable"),H=t(f);H&&!(null==H?void 0:H.value)&&(H.value=D);const M=null!=e.column.showHeaderOverflow?0!=e.column.showHeaderOverflow:0!=O.value.showHeaderOverflow,W=e.column||{},y=a(null==g?void 0:g.value)&&!1!==l.annotation,k=b.isEditableColumn(O.value,W),P=b.hasFilter(l),$=b.hasTitlePrefix(e.column),C=u(p)?p:d(p)?p(e):null;let R=null==(w=l.settingObj)?void 0:w.fieldDescDev;if(u(R)&&R){const e=t(h);R=(null==e?void 0:e.developMode)?R:""}let S=!1;if(O.value){const e=O.value.editRules&&O.value.editRules[W.field];e&&(S=i(e).some((e=>e.required)))}const T=O.value.border?Math.max(2,Math.ceil(D.reactData.scrollbarWidth/D.reactData.tableColumn.length)):1,V=r(Math.max(0,W.renderWidth-20-T-(S?14:0)-(y?18:0)-(P?23:0)-(k?22:0)-($?20:0)-(W.sortable?23:0)-(R?20:0)));return o("section",{class:"iho-table__headerWrapper"},[o("section",{style:{width:V}},[null!=C?C:o("div",n({style:M?{maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:{maxWidth:"100%"}},function(){var e;const t=null==(e=l.settingObj)?void 0:e.fieldDescribe;return t?{title:`${W.title}\n${t}`}:{}}()),[function(){const e=W.title,l=/\\n|\n|\r/g;if(!l.test(e))return e;const t=e.replace(l,"<br>").split("<br>");return t.map(((e,l)=>[e,l===t.length-1?null:o("br",null,null)]))}()])]),R?o(x,{message:R},{trigger:()=>o(s,{style:"width:14px"},null)}):null,y?o(c,{modelValue:g.value[W.field],"onUpdate:modelValue":e=>g.value[W.field]=e,shortcuts:j&&(j["annotation-shortcuts"]||j.annotationShortcuts)||[]},null):null])}(l,p(e),O)},e}))}})}export{g as default};
@@ -1 +1 @@
1
- import{defineComponent as e,useAttrs as t,inject as l,ref as a,computed as o,reactive as r,watch as u,nextTick as n,onBeforeUnmount as i,openBlock as m,createBlock as d,unref as v,withCtx as c,createVNode as s,mergeProps as f,isRef as p,createElementBlock as h,Fragment as b,renderList as y,createTextVNode as g,toDisplayString as w,createCommentVNode as k}from"vue";import{noop as _}from"lodash-es";import{NPopover as V,NInput as F,NSpace as S,NScrollbar as $,NButton as H}from"naive-ui";import{useIhoTableFormEvent as x}from"../../../../utils/index.js";import D from"../../../../../../time-picker/index.js";import{parse as C,isValid as O,format as j,getHours as E,getMinutes as A,getSeconds as I}from"date-fns";var P=e({__name:"editTime",props:{formattedValue:{type:String},column:{type:Object},row:{type:Object},rowIndex:{type:Number},shortcutOptions:{type:Array,default:()=>[]},ignoreGlobEmit:{type:Boolean,default:!1}},emits:["update:formattedValue","click"],setup(e,{emit:P}){const R=e,U=t(),{emitFormChangeWithParams:q=_}=R.ignoreGlobEmit?{}:x({...R,$table:l("$xetable")}),G=a(null),M=a(!1),N=a(),W=a();let z=R.formattedValue;const B=o((()=>W.value&&X(W.value)?{style:"text-decoration: line-through"}:{})),K=o({get(){if(!W.value)return null;const e=C(W.value,L.valueFormat,new Date);return O(e)?j(e,L.valueFormat):R.formattedValue?ee(R.formattedValue):null},set(e){Q(e)}}),{placeholder:T="请选择",valueFormat:J="HH:mm"}=U,L=r({...U,placeholder:T,valueFormat:J,format:J});function Q(e){if(W.value=e||"",e&&X(e))return;R.formattedValue!==e&&(z=e)}function X(e){var t,l,a;const o=C(e,L.format,new Date),r=E(o),u=A(o),n=I(o),i=null==(t=L.isHourDisabled)?void 0:t.call(L,r),m=null==(l=L.isMinuteDisabled)?void 0:l.call(L,u,r),d=null==(a=L.isSecondDisabled)?void 0:a.call(L,n,u,r);return i||m||d}function Y(){[L.valueFormat.replace(/[^\w]/g,""),L.valueFormat].some((e=>{const t=C(W.value,e,new Date);if(!W.value||O(t)){return Q(W.value?j(t,L.valueFormat):null),!0}return!1}))}function Z(e){var t;const{key:l}=e;"Enter"===l&&(null==(t=G.value)||t.blur(),M.value=!1)}function ee(e){var t;const l=L.valueFormat.match(/\W/)[0]||":",a=e.split(l).map(Number),o=`${a[0].toString().padStart(2,"0")}${l}${a[1].toString().padStart(2,"0")}`;return"HH:mm"===L.valueFormat?o:"HH:mm:ss"===L.valueFormat?`${o}${l}${(null!=(t=a[2])?t:0).toString().padStart(2,"0")}`:e}function te(){z&&X(z)||R.formattedValue!==z&&(P("update:formattedValue",z),q({oldValue:R.formattedValue}))}return u((()=>R.formattedValue),(e=>{z=e,e&&(W.value=ee(e))}),{immediate:!0}),u((()=>M.value),(async e=>{var t,l,a,o,r;e?(z=K.value,await n(),null==(r=null==(o=null==(a=null==(l=null==(t=N.value)?void 0:t.$timePicker)?void 0:l.panelInstRef)?void 0:a.$el)?void 0:o.querySelectorAll(".n-time-picker-col"))||r.forEach((e=>{var t,l;return null==(l=null==(t=null==e?void 0:e.querySelector)?void 0:t.call(e,".n-time-picker-col__item--active"))?void 0:l.scrollIntoView()}))):te()})),i((()=>{te()})),(t,l)=>(m(),d(v(V),{show:M.value,"onUpdate:show":l[3]||(l[3]=e=>M.value=e),trigger:"click",showArrow:!1,placement:"bottom-start",style:{padding:"0"}},{trigger:c((()=>[s(v(F),{ref_key:"formRef",ref:G,clearable:"",placeholder:v(T),value:W.value,"onUpdate:value":l[0]||(l[0]=e=>W.value=e),valueModifiers:{trim:!0},"input-props":v(B),onChange:Y,onKeydown:Z},null,8,["placeholder","value","input-props"])])),default:c((()=>[s(v(S),null,{default:c((()=>[s(v(D),f({ref_key:"timePickerRef",ref:N,show:""},v(L),{class:"iho-table__time-picker",to:!1,"formatted-value":v(K),"onUpdate:formatted-value":l[1]||(l[1]=e=>p(K)?K.value=e:null),onConfirm:l[2]||(l[2]=()=>M.value=!1)}),null,16,["formatted-value"]),s(v($),{class:"iho-table__scrollbar"},{default:c((()=>[e.shortcutOptions.length?(m(),d(v(S),{key:0,vertical:"",wrap:!1},{default:c((()=>[(m(!0),h(b,null,y(e.shortcutOptions,(e=>(m(),d(v(H),{size:"tiny",key:e,disabled:X(e),onClick:t=>function(e){Q(ee(e)),M.value=!1}(e)},{default:c((()=>[g(w(e),1)])),_:2},1032,["disabled","onClick"])))),128))])),_:1})):k("v-if",!0)])),_:1})])),_:1})])),_:1},8,["show"]))}});export{P as default};
1
+ import{defineComponent as e,useAttrs as t,inject as l,ref as a,computed as o,reactive as r,watch as u,nextTick as n,onBeforeUnmount as i,openBlock as m,createBlock as d,unref as v,withCtx as c,createVNode as s,mergeProps as f,isRef as p,createElementBlock as h,Fragment as b,renderList as y,createTextVNode as g,toDisplayString as w,createCommentVNode as k}from"vue";import{noop as _}from"lodash-es";import{NPopover as F,NInput as V,NSpace as S,NScrollbar as $,NButton as H}from"naive-ui";import{useIhoTableFormEvent as x}from"../../../../utils/index.js";import D from"../../../../../../time-picker/index.js";import{parse as C,isValid as O,format as j,getHours as E,getMinutes as A,getSeconds as I}from"date-fns";var P=e({__name:"editTime",props:{formattedValue:{type:String},column:{type:Object},row:{type:Object},rowIndex:{type:Number},shortcutOptions:{type:Array,default:()=>[]},ignoreGlobEmit:{type:Boolean,default:!1}},emits:["update:formattedValue","click"],setup(e,{emit:P}){const R=e,U=t(),{emitFormChangeWithParams:q=_}=R.ignoreGlobEmit?{}:x({...R,$table:l("$xetable")}),G=a(null),M=a(!1),N=a(),W=a();let z=R.formattedValue;const B=o((()=>W.value&&X(W.value)?{style:"text-decoration: line-through"}:{})),K=o({get(){if(!W.value)return null;const e=C(W.value,L.valueFormat,new Date);return O(e)?j(e,L.valueFormat):R.formattedValue?ee(R.formattedValue):null},set(e){Q(e)}}),{placeholder:T="请选择",valueFormat:J="HH:mm"}=U,L=r({...U,placeholder:T,valueFormat:J,format:J});function Q(e){W.value=e||"",e&&X(e)||(z=e)}function X(e){var t,l,a;const o=C(e,L.format,new Date),r=E(o),u=A(o),n=I(o),i=null==(t=L.isHourDisabled)?void 0:t.call(L,r),m=null==(l=L.isMinuteDisabled)?void 0:l.call(L,u,r),d=null==(a=L.isSecondDisabled)?void 0:a.call(L,n,u,r);return i||m||d}function Y(){[L.valueFormat.replace(/[^\w]/g,""),L.valueFormat].some((e=>{const t=C(W.value,e,new Date);if(!W.value||O(t)){return Q(W.value?j(t,L.valueFormat):null),!0}return!1}))}function Z(e){var t;const{key:l}=e;"Enter"===l&&(null==(t=G.value)||t.blur(),M.value=!1)}function ee(e){var t;const l=L.valueFormat.match(/\W/)[0]||":",a=e.split(l).map(Number),o=`${a[0].toString().padStart(2,"0")}${l}${a[1].toString().padStart(2,"0")}`;return"HH:mm"===L.valueFormat?o:"HH:mm:ss"===L.valueFormat?`${o}${l}${(null!=(t=a[2])?t:0).toString().padStart(2,"0")}`:e}function te(){z&&X(z)||R.formattedValue!==z&&(P("update:formattedValue",z),q({oldValue:R.formattedValue}))}return u((()=>R.formattedValue),(e=>{z=e,e&&(W.value=ee(e))}),{immediate:!0}),u((()=>M.value),(async e=>{var t,l,a,o,r;e?(z=K.value,await n(),null==(r=null==(o=null==(a=null==(l=null==(t=N.value)?void 0:t.$timePicker)?void 0:l.panelInstRef)?void 0:a.$el)?void 0:o.querySelectorAll(".n-time-picker-col"))||r.forEach((e=>{var t,l;return null==(l=null==(t=null==e?void 0:e.querySelector)?void 0:t.call(e,".n-time-picker-col__item--active"))?void 0:l.scrollIntoView()}))):te()})),i((()=>{te()})),(t,l)=>(m(),d(v(F),{show:M.value,"onUpdate:show":l[3]||(l[3]=e=>M.value=e),trigger:"click",showArrow:!1,placement:"bottom-start",style:{padding:"0"}},{trigger:c((()=>[s(v(V),{ref_key:"formRef",ref:G,clearable:"",placeholder:v(T),value:W.value,"onUpdate:value":l[0]||(l[0]=e=>W.value=e),valueModifiers:{trim:!0},"input-props":v(B),onChange:Y,onKeydown:Z},null,8,["placeholder","value","input-props"])])),default:c((()=>[s(v(S),null,{default:c((()=>[s(v(D),f({ref_key:"timePickerRef",ref:N,show:""},v(L),{class:"iho-table__time-picker",to:!1,"formatted-value":v(K),"onUpdate:formatted-value":l[1]||(l[1]=e=>p(K)?K.value=e:null),onConfirm:l[2]||(l[2]=()=>M.value=!1)}),null,16,["formatted-value"]),s(v($),{class:"iho-table__scrollbar"},{default:c((()=>[e.shortcutOptions.length?(m(),d(v(S),{key:0,vertical:"",wrap:!1},{default:c((()=>[(m(!0),h(b,null,y(e.shortcutOptions,(e=>(m(),d(v(H),{size:"tiny",key:e,disabled:X(e),onClick:t=>function(e){Q(ee(e)),M.value=!1}(e)},{default:c((()=>[g(w(e),1)])),_:2},1032,["disabled","onClick"])))),128))])),_:1})):k("v-if",!0)])),_:1})])),_:1})])),_:1},8,["show"]))}});export{P as default};
@@ -1 +1 @@
1
- import{createVNode as n}from"vue";import"../../../../index.js";import{WIDGET_TYPE as e}from"../../../constants/index.js";import{parseMergeField as r,getTitle as t,isRichContent as o,parseRichContent as i}from"../../../utils/index.js";import{defineTablePlugin as l}from"../../../hooks/useTablePlugin.js";function c(){return l({name:"defaultRendererPlugin",vxe(o){o.renderer.add(e.DEFAULT,{renderCell(e,{row:o,column:i}){const l=r(o,i);return n("span",{title:String(t(i,l)),class:"iho-table__colorAndIcon"},[c(l,i)])}}),o.renderer.add(e.STATUS,o.renderer.get(e.DEFAULT))}});function c(e,r){if(!o(e))return e;const l=i(e),c=l.background||l.icon;return[n("span",{title:t(r,l.change_text)},[function(e){if(!e)return null;if(e.match(/#[\da-f]{6}|[\da-f]{3}/i))return n("i",{class:"icon-dot",style:{"--table-icon-color":e,"--table-icon-shadow":e}},null);return n("i",{class:l.icon},null)}(l.icon),n("i",{style:{color:c,fontWeight:"bold"}},[l.change_text])])]}}export{c as defaultRendererPlugin};
1
+ import{createVNode as n}from"vue";import"../../../../index.js";import{WIDGET_TYPE as e}from"../../../constants/index.js";import{parseMergeField as r,getTitle as t,isRichContent as o,parseRichContent as i}from"../../../utils/index.js";import{defineTablePlugin as l}from"../../../hooks/useTablePlugin.js";function c(){return l({name:"defaultRendererPlugin",vxe(o){o.renderer.add(e.DEFAULT,{renderCell(e,{row:o,column:i}){const l=r(o,i);return n("span",{title:String(t(i,l)),class:"iho-table__colorAndIcon"},[c(l,i)])}}),o.renderer.add(e.STATUS,o.renderer.get(e.DEFAULT))}});function c(e,r){if(!o(e))return e;const l=i(e),c=l.background||l.icon,a=c&&"#000"!==c&&"#000000"!==c&&"black"!==c&&"rgb(0, 0, 0)"!==c;return[n("span",{title:t(r,l.change_text)},[function(e){if(!e)return null;if(e.match(/#[\da-f]{6}|[\da-f]{3}/i))return n("i",{class:"icon-dot",style:{"--table-icon-color":e,"--table-icon-shadow":e}},null);return n("i",{class:l.icon},null)}(l.icon),n("i",{style:{color:c,fontWeight:a?"bold":"normal"}},[l.change_text])])]}}export{c as defaultRendererPlugin};
@@ -115,13 +115,14 @@ export type IhoTableConfig = VxeTableProps & Partial<{
115
115
  columnWidth: number;
116
116
  rowHeight: number;
117
117
  fixedColumnList: Array<{
118
- setting: {
118
+ setting: Partial<{
119
+ alias: string;
119
120
  name: string;
120
121
  option: {
121
122
  text: string;
122
123
  value?: string;
123
124
  }[];
124
- };
125
+ }>;
125
126
  columnWidth?: number;
126
127
  }>;
127
128
  }>;