cnhis-design-vue 3.2.9-beta.14 → 3.2.9-beta.17

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 (26) hide show
  1. package/es/components/button-print/src/components/NewPrintComponent.vue2.js +1 -1
  2. package/es/components/button-print/src/utils/print.d.ts +1 -1
  3. package/es/components/button-print/src/utils/print.js +1 -1
  4. package/es/components/classification/src/components/table-modal/index.vue.d.ts +0 -3
  5. package/es/components/field-set/src/FieldColor.vue.d.ts +1 -1
  6. package/es/components/field-set/src/FieldFilter.vue.d.ts +1 -1
  7. package/es/components/field-set/src/FieldSet.vue.d.ts +2 -2
  8. package/es/components/field-set/src/FieldSet.vue2.js +1 -1
  9. package/es/components/field-set/src/components/table-row.vue.d.ts +1 -1
  10. package/es/components/iho-chat/index.d.ts +20 -0
  11. package/es/components/iho-chat/src/Index.vue.d.ts +20 -0
  12. package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +4 -0
  13. package/es/components/iho-chat/src/components/ChatAdd.vue2.js +1 -1
  14. package/es/components/iho-chat/src/components/ChatFile.vue2.js +1 -1
  15. package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +4 -0
  16. package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +8 -0
  17. package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
  18. package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +4 -0
  19. package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +4 -0
  20. package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
  21. package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
  22. package/es/env.d.ts +25 -25
  23. package/es/shared/package.json.js +1 -1
  24. package/es/shared/utils/index.d.ts +1 -0
  25. package/es/shared/utils/index.js +1 -1
  26. package/package.json +2 -2
@@ -1 +1 @@
1
- import{defineComponent as e,inject as t,ref as n,reactive as r,computed as i,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as 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 O}from"vue";import{isObject as I}from"@vue/shared";import{useMessage as C,NButtonGroup as L,NDropdown as T,NButton as j,NIcon as M,NPopover as F,NCheckbox as E,NDivider as x}from"naive-ui";import{PrintOutline as N,SettingsOutline as _,ChevronDownSharp as D,ArrowForwardOutline as J}from"@vicons/ionicons5";import{InjectionButtonPrintEmits as R}from"../constants/index.js";import{Print as z}from"../utils/print.js";import{isIReport as A}from"../utils/browserPrint.js";import U from"./IdentityVerification.vue.js";import{format as V}from"date-fns";import"../api.js";import"../../../shortcut-provider/index.js";import{useShortcuts as B}from"../../../shortcut-provider/src/hooks/useShortcuts.js";const K={class:"newprint-button-outer"},G={key:0,class:"newprint-button-outer__shortcut"},q=d("span",{class:"label bold"},"外显设置",-1),Y={class:"newprint-button-poperOver"},H={class:"print-lite"},$={class:"label bold"},Q={class:"print-li"},W={class:"print-lite"},X={key:0,class:"newprint-button-outer__shortcut"},Z={class:"newprint-button-poperOver"},ee=["onMouseenter","onClick"],te={class:"label bold"},ne={class:"newprint-button-poperOver"},re={class:"print-lite"},ie={class:"label bold"},ae={class:"print-li"},le={class:"print-lite"},oe=["onClick"],se={key:0,class:"newprint-button-outer__shortcut"},ue={class:"newprint-button-poperOver"},ce=["onMouseenter"],de={class:"print-lite"},pe=["onClick"];var me=e({__name:"NewPrintComponent",props:{printParams:{type:Array},params:{default:()=>[],type:Array},btnText:{default:"打印",type:String},printText:{default:"直接打印",type:String},previewText:{default:"打印预览",type:String},pdfLoadText:{default:"下载pdf",type:String},formatEditText:{default:"格式编辑",type:String},prevFn:{default:()=>Promise.resolve(),type:Function},queryPrintFormatByNumber:{default:()=>Promise.resolve({}),type:Function},queryTemplateParams:{default:()=>Promise.resolve({}),type:Function},strategy:{default:"MULTI",type:String},clickPrevFn:{default:()=>Promise.resolve(!0),type:Function},noDataMsg:{default:"请选中需要打印的数据",type:String},token:{type:String},printdlgshow:{default:"0",type:String},btnprint:{type:String,default:"1"},directPrint:{type:Boolean,default:!1},externalOptionConfig:{type:Object,default:()=>({})},signature:{type:String},showLoading:{type:Boolean,default:!0},hideButtons:{type:Array,default:()=>[]},printCopies:{type:Number},resolution:{type:Number},newPrintSetting:{type:Object,default:()=>({isShowPrintAll:!0,printAllType:1,isShowOutSetting:!0,customProps:{},outerPrintKeys:[],defaultFormatId:"",shortcut:{}})}},setup(e,{expose:me}){const ve=e,fe=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],ye=C();let ge;const he=t(R),ke=n(""),be=r({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],iReportExecuteMode:1}),Pe=n({});let we=n([]),Se=n([{label:ve.previewText,key:"previewText"},{label:ve.pdfLoadText,key:"downloadPdf"},{label:ve.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Oe=r({oneMouseType:"",oneClickType:"",twoMouseType:""}),Ie=r({oneShow:!1,isOperation:!1,isOutSetting:!1}),Ce=n([]),Le=n([]),Te=i((()=>{if(!be.currentFormatId)return{};let e=be.currentFormatId;return be.formatList.find((t=>t.id===e))}));i((()=>{var e;return(null==(e=Te.value)?void 0:e.name)||"格式选择"}));const je=i((()=>{let e=be.formatList.find((e=>e.id===be.currentFormatId));return null==e?void 0:e.templateId})),Me=i((()=>{let e=be.formatList.find((e=>e.id===be.currentFormatId));return null==e?void 0:e.number})),Fe=i((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.isShowPrintAll})),Ee=i((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.isShowOutSetting})),xe=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.customProps)||{}})),Ne=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.defaultFormatId)||""})),_e=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.printAllType)||1})),De=i((()=>{var e;return(null==(e=ve.newPrintSetting)?void 0:e.shortcut)||{}})),Je=i((()=>{var e,t;const n=Object.keys(De.value);if(n.length>0){if(Ne.value&&n.includes(Ne.value))return(null==(e=De.value[Ne.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=De.value.all)?void 0:t.shortcutLabel)||""}return""})),Re=i((()=>{const e=fe.map((e=>e.key));return we.value.filter((t=>!e.includes(t.key)))})),ze=i({get:()=>Re.value.every((e=>e.selected)),set(e){Re.value.forEach((t=>{t.selected=e}))}}),Ae=async()=>{var e,t;(null==(t=null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await mt(),Ie.oneShow=!0},Ue=async e=>{if(ve.directPrint){if(be.spinning)return;return"button"===e?void(Fe.value?await yt():Ne.value?async function(e){await mt(!1);const t=Ce.value.find((t=>t.key==e));t&&et(t.templateCode,t.templateId,t.key,!1)}(Ne.value):Ae()):Ae()}return Ae()},Ve=(e,t)=>{Oe[e]=t},Be=()=>{Ce.value=we.value.filter((e=>!e.selected)),Le.value=Re.value.filter((e=>e.selected)),Ge("oneShow"),Ge("isOutSetting"),he("saveOuterPrint",Le.value)},Ke=e=>{Ie[e]=!0},Ge=e=>{Oe.oneClickType="",Ie[e]=!1,"isOutSetting"==e&&(Ie.isOutSetting=!1)},qe=(e,t)=>{Xe(!1);let n={type:t,formatId:be.currentFormatId,templateId:(null==e?void 0:e.templateId)||je.value,templateCode:(null==e?void 0:e.templateCode)||Me.value};he("success",e,n)},Ye=e=>{Xe(!1),he("error",e),I(e)&&"notInstalledApp"===e.type&&ye.error(e.message)},He=e=>{Xe(!1),he("cancel",e)},$e=e=>{he("error",{message:"前置条件执行错误",type:e,preExecution:!0})},Qe=()=>JSON.stringify({...ve.token?{token:ve.token}:{}}),We=(e=[],t)=>{var n,r;let i={},a={};if((null==(n=be.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(r=Object.keys(e[0].datasetData||{}))?void 0:r[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return i=Object.assign({},JSON.parse(Qe()),xe.value,a),JSON.stringify(i)},Xe=(e,t)=>{if(be.isClickOuterPrint){if(e&&t){const n=Le.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Le.value.forEach((e=>{e.isLoading=!1}))}else be.spinning=e},Ze=()=>be.isClickOuterPrint?Le.value.some((e=>e.isLoading)):be.spinning,et=(e,t,n,r)=>{const i=be.printParams[e];if(!i)return;be.isClickOuterPrint=r,be.currentFormatId=n;const a=be.originParams[e]||[];tt(i,e,t,n,a)},tt=async(e=[],t,n,r,i=[],a)=>{let l=e.length;const o=async e=>{try{--l<=0&&qe(e,"print")}catch(e){console.log("error",e)}};ve.showLoading&&Ze()&&!a||(Xe(!0,r),ve.prevFn("print",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e;const a={formatId:r,iReportExecuteMode:be.iReportExecuteMode,templateId:n,authorizationKey:ke.value,printdlgshow:ve.printdlgshow,signature:ve.signature,copies:ve.printCopies};if("MULTI"===ve.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[t]));ge.printDirect({...a,params:n},o,Ye,He)}else ge.printDirect({...a,params:We(e,t)},(e=>{e.params=i,e.templateCode=t,e.templateId=n,qe(e,"print")}),Ye,He)})).catch((()=>{$e("print"),Xe(!1)})).finally((()=>{be.visible=!1})))},nt=async(e,{templateCode:t,templateId:n,key:r},i)=>{const a=be.printParams[t];if(a)switch(be.isClickOuterPrint=i,be.currentFormatId=r,e){case"previewText":(async(e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("preview",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[0])),a="MULTI"===ve.strategy?i:We(e,t),l={formatId:r,templateId:n,iReportExecuteMode:be.iReportExecuteMode,authorizationKey:ke.value,params:a,btnprint:ve.btnprint,signature:ve.signature};ge.preview(l,(e=>{qe(e,"preview")}),Ye)})).catch((()=>{$e("preview"),Xe(!1)})).finally((()=>{be.visible=!1})))})(a,t,n,r);break;case"formatEditText":((e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("edit",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e,be.currentFormatId=r,be.identityVerification.visible=!0})).catch((()=>{$e("edit")})).finally((()=>{Xe(!1)})))})(a,0,n,r);break;case"downloadPdf":(async(e=[],t,n,r)=>{ve.showLoading&&Ze()||(Xe(!0,r),ve.prevFn("download",{formatId:r,templateId:n}).then((()=>{be.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,e[0])),a="MULTI"===ve.strategy?i:We(e,t),l={formatId:r,templateId:n,iReportExecuteMode:be.iReportExecuteMode,authorizationKey:ke.value,print:{print:"1",type:"1",resolution:null==ve?void 0:ve.resolution},params:a,signature:ve.signature};ge.downloadPDF(l,(e=>qe(e,"preview")),Ye)})).catch((()=>{$e("download"),Xe(!1)})).finally((()=>{be.visible=!1})))})(a,t,n,r);break;case"resetPrinter":(async(e=[],t,n,r)=>{if(!ve.showLoading||!Ze()){Xe(!0,r);try{const e=await ge.resetPrinter(r);if(Xe(!1),"success"==(null==e?void 0:e.result))return void ye.success(e.message||"重置打印机成功");ye.warning("重置打印机失败")}catch(e){Xe(!1),ye.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,r)}},rt=()=>{},it=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},st(n,t,e))})),n},at=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ut(n,t,e))})),n},lt=(e,t,n)=>{const r={};return t.forEach((t=>{let i=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(r=V(t,n[e.type])),(null==e?void 0:e.defaultValue)||r})(t,e[t[n]]);e[t[n]]&&i&&(r[t[n]]=i)})),r},ot=({customizeDataset:e=[],param:t=[]},n={})=>{let r={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;r.datasetData||(r.datasetData={}),r.datasetData[e.name]=JSON.stringify(lt(n,t,"fieldName"))})),r=Object.assign({},r,lt(n,t,"key")),r},st=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r],a=n[i];if(!a)return ye.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(ot(a,t))}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i],l=n[a];if(!l)return ye.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(ot(l,t))}return e},ut=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r];if(!n[i])return ye.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(t)}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i];if(!n[a])return ye.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},ct=async e=>{var t;be.formatList=e?(e=>{let t=[];return e&&e.forEach((e=>{if(!e.format)return!1;t.push(...e.format.map((t=>Object.assign({},t,{templateName:e.name}))))})),t})(e.obj):[],be.iReportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].iReportExecuteMode||1,(()=>{var e,t,n;const r=Object.keys(De.value),i=be.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(r.includes(e.id)){const n=De.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));we.value.unshift(...i),Ee.value&&we.value.push(...fe),(null==(t=null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(we.value.forEach((e=>{var t;(null==(t=ve.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Le.value=we.value.filter((e=>e.selected))),Ce.value=we.value.filter((e=>!e.selected)),ve.hideButtons.length>0&&(Se.value=Se.value.filter((e=>!ve.hideButtons.includes(e.key))));const a=sessionStorage.getItem("portal");if(a){const e=JSON.parse(a),t=(null==(n=null==e?void 0:e.user)?void 0:n.currentRoleResourceObj)||{},r=Object.keys(t);r.includes("RY7.2.21.1.M2.G94181E")||(Se.value=Se.value.filter((e=>"downloadPdf"!=e.key))),r.includes("RY7.2.21.1.M2.G33633A")||(Se.value=Se.value.filter((e=>"formatEditText"!=e.key))),r.includes("RY7.2.21.1.M2.G99314S")||(Se.value=Se.value.filter((e=>"resetPrinter"!=e.key)))}})(),be.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),be.printParams=it(be.templateParams,ve.params),be.originParams=at(be.templateParams,ve.params),pt()},dt=async()=>{var e;if(be.isInited)return!0;be.isInited=!0,be.spinning=!0,(()=>{if(ge)return!1;ge=new z})();const t=await ve.queryPrintFormatByNumber();return await ct(t),(null==(e=t.obj)?void 0:e.length)>0&&(ke.value=t.obj[0].authorizationKey||""),be.spinning=!1,!0},pt=async()=>{const e=Object.keys(De.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],r=De.value[n],{stop:i,signature:a}=B().register({label:r.code,shortcutSignature:r.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ue("button");const e=Re.value.map((e=>e.key)),t=be.originParams;if(e.includes(n)){const e=Re.value.find((e=>e.key==n));if(e){const n=be.printParams[null==e?void 0:e.templateCode],r=t[null==e?void 0:e.templateCode]||[];tt(n,e.templateCode,e.templateId,e.key,r)}}}});Pe.value[n]=i}},mt=async(e=!0)=>{if(await ve.clickPrevFn()){if(!be.visible){if(!await dt())return!1}e&&(be.visible=!be.visible)}},vt=e=>{if(be.identityVerification.visible=!1,A(be.currentFormatId))return qe({result:"success",message:""},"edit");const t=JSON.stringify(Object.assign({},JSON.parse(Qe()),xe.value,be.curPrintParamList[0])),n="MULTI"===ve.strategy?t:We(be.curPrintParamList,Me.value),r={formatId:be.currentFormatId,templateId:je.value,params:n,token:e};ge.editPrintFormat(r,(e=>{qe(e,"edit")}),Ye)},ft=(e,t)=>{const n=Le.value[t+1];return t<Le.value.length-1&&!be.printParams[e.templateCode]&&be.printParams[n.templateCode]};async function yt(){await mt(!1),(()=>{const e=Object.keys(be.printParams);be.isClickOuterPrint=!1;const t=be.originParams;if(1==_e.value)for(let n=0;n<e.length;n++){const r=e[n],i=be.printParams[r],a=t[r]||[],l=be.formatList.filter((e=>e.number==r));l&&l.length>0&&l.forEach((e=>{be.currentFormatId=e.id,tt(i,e.number,e.templateId,e.id,a,!0)}))}2==_e.value&&Le.value.forEach((e=>{const n=be.printParams[e.templateCode],r=t[e.templateCode]||[];be.currentFormatId=e.key,tt(n,e.templateCode,e.templateId,e.key,r,!0)}))})()}return a((()=>{be.isInited=!1,mt()})),l((()=>{const e=Object.keys(Pe.value);e.length>0&&e.forEach((e=>{Pe.value[e]&&Pe.value[e]()}))})),o((()=>ve.params),(e=>{Object.keys(be.templateParams).length>0&&(be.printParams=it(be.templateParams,ve.params),be.originParams=at(be.templateParams,ve.params))}),{deep:!0}),o((()=>{var e;return null==(e=ve.newPrintSetting)?void 0:e.outerPrintKeys}),(async e=>{(null==e?void 0:e.length)>0&&await mt(!1)}),{deep:!0,immediate:!0}),me({directPrint:yt}),(t,n)=>(s(),u(c,null,[d("div",K,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:f((()=>[(s(!0),u(c,null,y(Le.value,((t,n)=>{return s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:rt,options:(r=v(Se),i=t,be.printParams[i.templateCode]?r:[]),onSelect:e=>nt(e,t,!0)},{default:f((()=>[m(v(j),{disabled:!be.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>et(t.templateCode,t.templateId,t.key,!0),class:h(n==Le.value.length-1?"outerLastButton":ft(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",G,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var r,i})),128))])),_:1}),p(" 外显设置按钮 "),Le.value.length>0&&Le.value.length==v(Re).length&&v(Ee)&&2!=v(_e)?(s(),g(v(F),{key:0,trigger:"click","show-arrow":!1,show:Ie.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Ge("isOutSetting"))},{trigger:f((()=>[m(v(j),{class:h(Le.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>Ke("isOutSetting"))},{default:f((()=>[q,m(v(M),{style:{"margin-left":"8px"},component:v(_),size:"18"},null,8,["component"])])),_:1},8,["class"])])),default:f((()=>[d("div",Y,[(s(!0),u(c,null,y(v(Re),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",H,[d("span",$,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",Q,[m(v(x)),d("div",W,[m(v(j),{type:"primary",size:"small",onClick:Be},{default:f((()=>[k("保存")])),_:1}),v(Re)&&v(Re).length>1?(s(),g(v(E),{key:0,checked:v(ze),"onUpdate:checked":n[1]||(n[1]=e=>P(ze)?ze.value=e:null)},{default:f((()=>[k("全选")])),_:1},8,["checked"])):p("v-if",!0)])])])])),_:1},8,["show"])):(s(),u(c,{key:1},[p(" 打印全部按钮 "),m(v(F),{trigger:"click","show-arrow":!1,show:Ie.oneShow,onClickoutside:n[10]||(n[10]=e=>Ge("oneShow"))},{trigger:f((()=>[w(t.$slots,"button",{handleClickPrintBtn:mt,printSpinning:be.spinning,printbtnText:e.btnText,printVisible:be.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ue("icon")),["stop"]))},{default:f((()=>[m(v(j),{loading:e.showLoading&&be.spinning,onClick:n[3]||(n[3]=S((()=>Ue("button")),["stop"])),class:h(Le.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(Je)?(s(),u("span",X,b(v(Je)),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",Z,[(s(!0),u(c,null,y(Ce.value,(e=>(s(),u("div",{class:h(["print-li",Oe.oneMouseType==e.key||Oe.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ve("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ve("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!be.printParams[n.templateCode])return[];Ve(e,t)})("oneClickType",e.key,e)},["divider"==e.key?(s(),g(v(x),{key:0})):"outSetting"==e.key?(s(),u(c,{key:1},[p(" 第二层外显设置 "),m(v(F),{trigger:"click","show-arrow":!1,placement:"right-start",show:Ie.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Ge("isOutSetting"))},{trigger:f((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>Ke("isOutSetting"))},[d("span",te,b(e.label),1),m(v(M),{color:Le.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:f((()=>[d("div",ne,[(s(!0),u(c,null,y(v(Re),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",re,[d("span",ie,b(e.label),1),m(v(E),{checked:e.selected,"onUpdate:checked":t=>e.selected=t},{default:f((()=>[k("外显")])),_:2},1032,["checked","onUpdate:checked"])])])))),128)),d("div",ae,[m(v(x)),d("div",le,[m(v(j),{type:"primary",size:"small",onClick:Be},{default:f((()=>[k("保存")])),_:1}),v(Re)&&v(Re).length>1?(s(),g(v(E),{key:0,checked:v(ze),"onUpdate:checked":n[6]||(n[6]=e=>P(ze)?ze.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",be.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>et(e.templateCode,e.templateId,e.key,!1)},[k(b(e.label)+" ",1),e.shortcutLabel?(s(),u("span",se,b(e.shortcutLabel),1)):p("v-if",!0)],8,oe),be.printParams[e.templateCode]?(s(),g(v(F),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Ie[e.key],onClickoutside:t=>Ge(e.key)},{trigger:f((()=>[m(v(M),{component:v(J),size:"18",onClick:t=>Ke(e.key)},null,8,["component","onClick"])])),default:f((()=>[d("div",ue,[(s(!0),u(c,null,y(v(Se),(t=>(s(),u("div",{class:h(["print-li",Oe.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ve("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ve("twoMouseType",""))},[d("div",de,[d("span",{class:"label",onClick:n=>nt(t.key,e,!1)},b(t.label),9,pe)])],42,ce)))),128))])])),_:2},1032,["show","onClickoutside"])):p("v-if",!0)],2)],2112))],42,ee)))),128))])])),_:3},8,["show"])],2112))]),m(U,O(t.$attrs,{modelValue:be.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>be.identityVerification.visible=e),formatId:be.currentFormatId,templateId:v(je),onSuccess:vt}),null,16,["modelValue","formatId","templateId"])],64))}});export{me as default};
1
+ import{defineComponent as e,inject as t,ref as n,reactive as r,computed as i,onMounted as a,onBeforeUnmount as l,watch as o,openBlock as s,createElementBlock as u,Fragment as c,createElementVNode as d,createCommentVNode as p,createVNode as m,unref as v,withCtx as 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 z}from"../utils/print.js";import{isIReport as K}from"../utils/browserPrint.js";import A from"./IdentityVerification.vue.js";import{format as U}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 q={class:"newprint-button-outer"},G={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"},re={class:"newprint-button-poperOver"},ie={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:{}})}},setup(e,{expose:ve}){const fe=e,ye=[{label:"分割线",key:"divider"},{label:"外显设置",key:"outSetting"}],ge=C();let he;const ke=t(J),be=n(""),Pe=r({spinning:!1,visible:!1,formatList:[],templateParams:[],printParams:[],originParams:{},currentFormatId:"",identityVerification:{visible:!1},isInited:!1,watchPrintParamsReformatFn:null,spinTimer:null,isClickOuterPrint:!1,curPrintParamList:[],iReportExecuteMode:1}),we=n({});let Se=n([]),Ie=n([{label:fe.previewText,key:"previewText"},{label:fe.pdfLoadText,key:"downloadPdf"},{label:fe.formatEditText,key:"formatEditText"},{label:"重置打印机",key:"resetPrinter"}]);const Oe=r({oneMouseType:"",oneClickType:"",twoMouseType:""}),Ce=r({oneShow:!1,isOperation:!1,isOutSetting:!1}),Le=n([]),Te=n([]),je=i((()=>{if(!Pe.currentFormatId)return{};let e=Pe.currentFormatId;return Pe.formatList.find((t=>t.id===e))}));i((()=>{var e;return(null==(e=je.value)?void 0:e.name)||"格式选择"}));const Me=i((()=>{let e=Pe.formatList.find((e=>e.id===Pe.currentFormatId));return null==e?void 0:e.templateId})),xe=i((()=>{let e=Pe.formatList.find((e=>e.id===Pe.currentFormatId));return null==e?void 0:e.number})),Ee=i((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.isShowPrintAll})),Fe=i((()=>{var e;return null==(e=fe.newPrintSetting)?void 0:e.isShowOutSetting})),Ne=i((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.customProps)||{}})),_e=i((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.defaultFormatId)||""})),De=i((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.printAllType)||1})),Re=i((()=>{var e;return(null==(e=fe.newPrintSetting)?void 0:e.shortcut)||{}})),Je=i((()=>{var e,t;const n=Object.keys(Re.value);if(n.length>0){if(_e.value&&n.includes(_e.value))return(null==(e=Re.value[_e.value])?void 0:e.shortcutLabel)||"";if(n.includes("all"))return(null==(t=Re.value.all)?void 0:t.shortcutLabel)||""}return""})),ze=i((()=>{const e=ye.map((e=>e.key));return Se.value.filter((t=>!e.includes(t.key)))})),Ke=i({get:()=>ze.value.every((e=>e.selected)),set(e){ze.value.forEach((t=>{t.selected=e}))}}),Ae=async()=>{var e,t;(null==(t=null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)||await vt(),Ce.oneShow=!0},Ue=async e=>{if(fe.directPrint){if(Pe.spinning)return;return"button"===e?void(Ee.value?await gt():_e.value?async function(e){await vt(!1);const t=Le.value.find((t=>t.key==e));t&&tt(t.templateCode,t.templateId,t.key,!1)}(_e.value):Ae()):Ae()}return Ae()},Ve=(e,t)=>{Oe[e]=t},Be=()=>{Le.value=Se.value.filter((e=>!e.selected)),Te.value=ze.value.filter((e=>e.selected)),Ge("oneShow"),Ge("isOutSetting"),ke("saveOuterPrint",Te.value)},qe=e=>{Ce[e]=!0},Ge=e=>{Oe.oneClickType="",Ce[e]=!1,"isOutSetting"==e&&(Ce.isOutSetting=!1)},Ye=(e,t)=>{Ze(!1);let n={type:t,formatId:Pe.currentFormatId,templateId:(null==e?void 0:e.templateId)||Me.value,templateCode:(null==e?void 0:e.templateCode)||xe.value};V({type:"进入成功的回调",res:e,info:n},"PRINT-SDK"),ke("success",e,n)},He=e=>{Ze(!1),V({type:"进入失败的回调",res:e},"PRINT-SDK"),ke("error",e),O(e)&&"notInstalledApp"===e.type&&ge.error(e.message)},$e=e=>{Ze(!1),ke("cancel",e)},Qe=e=>{ke("error",{message:"前置条件执行错误",type:e,preExecution:!0})},We=()=>JSON.stringify({...fe.token?{token:fe.token}:{}}),Xe=(e=[],t)=>{var n,r;let i={},a={};if((null==(n=Pe.templateParams[t].customizeDataset)?void 0:n.length)>0){const t=(null==(r=Object.keys(e[0].datasetData||{}))?void 0:r[0])||"",n=JSON.stringify(e.map((e=>JSON.parse(e.datasetData[t]))));a={datasetData:{}},a.datasetData[t]=n}else Object.keys(e[0]).forEach((t=>{a[t]=[],e.forEach((e=>{a[t].includes(e[t])||a[t].push(e[t])})),a[t]=a[t].join(",")}));return i=Object.assign({},JSON.parse(We()),Ne.value,a),JSON.stringify(i)},Ze=(e,t)=>{if(Pe.isClickOuterPrint){if(e&&t){const n=Te.value.find((e=>e.key==t));return void(n&&(n.isLoading=e))}Te.value.forEach((e=>{e.isLoading=!1}))}else Pe.spinning=e},et=()=>Pe.isClickOuterPrint?Te.value.some((e=>e.isLoading)):Pe.spinning,tt=(e,t,n,r)=>{const i=Pe.printParams[e];if(!i)return;Pe.isClickOuterPrint=r,Pe.currentFormatId=n;const a=Pe.originParams[e]||[];nt(i,e,t,n,a)},nt=async(e=[],t,n,r,i=[],a)=>{V({type:"点击打印的入参",templateCode:t,templateId:n,formatId:r,printToParam:i},"PRINT-SDK");let l=e.length;const o=async e=>{try{--l<=0&&Ye(e,"print")}catch(e){console.log("error",e)}};fe.showLoading&&et()&&!a||(Ze(!0,r),fe.prevFn("print",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e;const a={formatId:r,iReportExecuteMode:Pe.iReportExecuteMode,templateId:n,authorizationKey:be.value,printdlgshow:fe.printdlgshow,signature:fe.signature,copies:fe.printCopies};if(V({type:"准备开始打印",queryParams:a,printToParam:i},"PRINT-SDK"),"MULTI"===fe.strategy)for(let t=0;t<e.length;t++){t>0&&(a.printdlgshow="0");const n=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,e[t]));he.printDirect({...a,params:n},o,He,$e)}else he.printDirect({...a,params:Xe(e,t)},(e=>{e.params=i,e.templateCode=t,e.templateId=n,Ye(e,"print")}),He,$e)})).catch((()=>{Qe("print"),Ze(!1)})).finally((()=>{Pe.visible=!1})))},rt=async(e,{templateCode:t,templateId:n,key:r},i)=>{const a=Pe.printParams[t];if(a)switch(Pe.isClickOuterPrint=i,Pe.currentFormatId=r,e){case"previewText":(async(e=[],t,n,r)=>{fe.showLoading&&et()||(Ze(!0,r),fe.prevFn("preview",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,e[0])),a="MULTI"===fe.strategy?i:Xe(e,t),l={formatId:r,templateId:n,iReportExecuteMode:Pe.iReportExecuteMode,authorizationKey:be.value,params:a,btnprint:fe.btnprint,signature:fe.signature};he.preview(l,(e=>{Ye(e,"preview")}),He)})).catch((()=>{Qe("preview"),Ze(!1)})).finally((()=>{Pe.visible=!1})))})(a,t,n,r);break;case"formatEditText":((e=[],t,n,r)=>{fe.showLoading&&et()||(Ze(!0,r),fe.prevFn("edit",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e,Pe.currentFormatId=r,Pe.identityVerification.visible=!0})).catch((()=>{Qe("edit")})).finally((()=>{Ze(!1)})))})(a,0,n,r);break;case"downloadPdf":(async(e=[],t,n,r)=>{fe.showLoading&&et()||(Ze(!0,r),fe.prevFn("download",{formatId:r,templateId:n}).then((()=>{Pe.curPrintParamList=e;const i=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,e[0])),a="MULTI"===fe.strategy?i:Xe(e,t),l={formatId:r,templateId:n,iReportExecuteMode:Pe.iReportExecuteMode,authorizationKey:be.value,print:{print:"1",type:"1",resolution:null==fe?void 0:fe.resolution},params:a,signature:fe.signature};he.downloadPDF(l,(e=>Ye(e,"preview")),He)})).catch((()=>{Qe("download"),Ze(!1)})).finally((()=>{Pe.visible=!1})))})(a,t,n,r);break;case"resetPrinter":(async(e=[],t,n,r)=>{if(!fe.showLoading||!et()){Ze(!0,r);try{const e=await he.resetPrinter(r,Pe.iReportExecuteMode);if(Ze(!1),"success"==(null==e?void 0:e.result))return void ge.success(e.message||"重置打印机成功");ge.warning("重置打印机失败")}catch(e){Ze(!1),ge.warning((null==e?void 0:e.message)||"重置打印机失败")}}})(a,0,0,r)}},it=()=>{},at=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ut(n,t,e))})),n},lt=(e,t=[])=>{let n={};return(t=t||[]).forEach((t=>{n=Object.assign({},ct(n,t,e))})),n},ot=(e,t,n)=>{const r={};return t.forEach((t=>{let i=((e,t)=>{const n={DATE:"yyyy-MM-dd",DATETIME:"yyyy-MM-dd HH:mm:ss"};let r=t;return Object.keys(n).includes(e.type)&&t&&t instanceof Date&&(r=U(t,n[e.type])),(null==e?void 0:e.defaultValue)||r})(t,e[t[n]]);e[t[n]]&&i&&(r[t[n]]=i)})),r},st=({customizeDataset:e=[],param:t=[]},n={})=>{let r={};return e.forEach((e=>{const t=e.dataSetting[0].selectFieldList;r.datasetData||(r.datasetData={}),r.datasetData[e.name]=JSON.stringify(ot(n,t,"fieldName"))})),r=Object.assign({},r,ot(n,t,"key")),r},ut=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r],a=n[i];if(!a)return ge.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(st(a,t))}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i],l=n[a];if(!l)return ge.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(st(l,t))}return e},ct=(e,t,n)=>{if(t.templateNumbers){for(let r=0;r<t.templateNumbers.length;r++){const i=t.templateNumbers[r];if(!n[i])return ge.error("当前勾选的数据没有匹配的模板"),e;e[i]||(e[i]=[]),e[i].push(t)}return e}const r=Object.keys(n);for(let i=0;i<r.length;i++){const a=r[i];if(!n[a])return ge.error("当前勾选的数据没有匹配的模板"),e;e[a]||(e[a]=[]),e[a].push(t)}return e},dt=async e=>{var t;Pe.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):[],Pe.iReportExecuteMode=(null==(t=null==e?void 0:e.obj)?void 0:t.length)>0&&e.obj[0].iReportExecuteMode||1,(()=>{var e,t,n;const r=Object.keys(Re.value),i=Pe.formatList.map((e=>{const t={templateCode:e.number,templateId:e.templateId,label:e.name,key:e.id,selected:!1,isLoading:!1};if(r.includes(e.id)){const n=Re.value[e.id];n&&(t.shortcutLabel=n.shortcutLabel)}return t}));Se.value.unshift(...i),Fe.value&&Se.value.push(...ye),(null==(t=null==(e=fe.newPrintSetting)?void 0:e.outerPrintKeys)?void 0:t.length)>0&&(Se.value.forEach((e=>{var t;(null==(t=fe.newPrintSetting)?void 0:t.outerPrintKeys.includes(e.key))&&(e.selected=!0)})),Te.value=Se.value.filter((e=>e.selected))),Le.value=Se.value.filter((e=>!e.selected)),fe.hideButtons.length>0&&(Ie.value=Ie.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)||{},r=Object.keys(t);r.includes("RY7.2.21.1.M2.G94181E")||(Ie.value=Ie.value.filter((e=>"downloadPdf"!=e.key))),r.includes("RY7.2.21.1.M2.G33633A")||(Ie.value=Ie.value.filter((e=>"formatEditText"!=e.key))),r.includes("RY7.2.21.1.M2.G99314S")||(Ie.value=Ie.value.filter((e=>"resetPrinter"!=e.key)))}})(),Pe.templateParams=(e=>{let t={};return e&&e.forEach((e=>{if(!e.templateConfig)return!1;t[e.number]=e.templateConfig})),t})(e.obj),Pe.printParams=at(Pe.templateParams,fe.params),Pe.originParams=lt(Pe.templateParams,fe.params),mt()},pt=async()=>{var e;if(Pe.isInited)return!0;Pe.isInited=!0,Pe.spinning=!0,(()=>{if(he)return!1;he=new z})();const t=await fe.queryPrintFormatByNumber();return await dt(t),(null==(e=t.obj)?void 0:e.length)>0&&(be.value=t.obj[0].authorizationKey||""),Pe.spinning=!1,!0},mt=async()=>{const e=Object.keys(Re.value);if(e.length>0)for(let t=0;t<e.length;t++){const n=e[t],r=Re.value[n],{stop:i,signature:a}=B().register({label:r.code,shortcutSignature:r.shortcutKey,operation:["state","reset"],callback(){"all"==n&&Ue("button");const e=ze.value.map((e=>e.key)),t=Pe.originParams;if(e.includes(n)){const e=ze.value.find((e=>e.key==n));if(e){const n=Pe.printParams[null==e?void 0:e.templateCode],r=t[null==e?void 0:e.templateCode]||[];nt(n,e.templateCode,e.templateId,e.key,r)}}}});we.value[n]=i}},vt=async(e=!0)=>{if(await fe.clickPrevFn()){if(!Pe.visible){if(!await pt())return!1}e&&(Pe.visible=!Pe.visible)}},ft=e=>{if(Pe.identityVerification.visible=!1,K(Pe.currentFormatId))return Ye({result:"success",message:""},"edit");const t=JSON.stringify(Object.assign({},JSON.parse(We()),Ne.value,Pe.curPrintParamList[0])),n="MULTI"===fe.strategy?t:Xe(Pe.curPrintParamList,xe.value),r={formatId:Pe.currentFormatId,templateId:Me.value,params:n,token:e};he.editPrintFormat(r,(e=>{Ye(e,"edit")}),He)},yt=(e,t)=>{const n=Te.value[t+1];return t<Te.value.length-1&&!Pe.printParams[e.templateCode]&&Pe.printParams[n.templateCode]};async function gt(){await vt(!1),(()=>{const e=Object.keys(Pe.printParams);Pe.isClickOuterPrint=!1;const t=Pe.originParams;if(1==De.value)for(let n=0;n<e.length;n++){const r=e[n],i=Pe.printParams[r],a=t[r]||[],l=Pe.formatList.filter((e=>e.number==r));l&&l.length>0&&l.forEach((e=>{Pe.currentFormatId=e.id,nt(i,e.number,e.templateId,e.id,a,!0)}))}2==De.value&&Te.value.forEach((e=>{const n=Pe.printParams[e.templateCode],r=t[e.templateCode]||[];Pe.currentFormatId=e.key,nt(n,e.templateCode,e.templateId,e.key,r,!0)}))})()}return a((()=>{Pe.isInited=!1,vt()})),l((()=>{const e=Object.keys(we.value);e.length>0&&e.forEach((e=>{we.value[e]&&we.value[e]()}))})),o((()=>fe.params),(e=>{Object.keys(Pe.templateParams).length>0&&(Pe.printParams=at(Pe.templateParams,fe.params),Pe.originParams=lt(Pe.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 vt(!1)}),{deep:!0,immediate:!0}),ve({directPrint:gt}),(t,n)=>(s(),u(c,null,[d("div",q,[p(" 外显按钮集合 "),m(v(L),{class:"outButtonGroup"},{default:f((()=>[(s(!0),u(c,null,y(Te.value,((t,n)=>{return s(),g(v(T),{key:t.key,class:"c-dropdown",placement:"bottom-start",trigger:"hover",onClickoutside:it,options:(r=v(Ie),i=t,Pe.printParams[i.templateCode]?r:[]),onSelect:e=>rt(e,t,!0)},{default:f((()=>[m(v(j),{disabled:!Pe.printParams[t.templateCode],loading:e.showLoading&&t.isLoading,onClick:e=>tt(t.templateCode,t.templateId,t.key,!0),class:h(n==Te.value.length-1?"outerLastButton":yt(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",G,b(t.shortcutLabel),1)):p("v-if",!0)])),_:2},1032,["disabled","loading","onClick","class"])])),_:2},1032,["options","onSelect"]);var r,i})),128))])),_:1}),p(" 外显设置按钮 "),Te.value.length>0&&Te.value.length==v(ze).length&&v(Fe)&&2!=v(De)?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,show:Ce.isOutSetting,onClickoutside:n[2]||(n[2]=e=>Ge("isOutSetting"))},{trigger:f((()=>[m(v(j),{class:h(Te.value.length>0?"printAllLeftCls":""),onClick:n[0]||(n[0]=e=>qe("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:Be},{default:f((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ke),"onUpdate:checked":n[1]||(n[1]=e=>P(Ke)?Ke.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:Ce.oneShow,onClickoutside:n[10]||(n[10]=e=>Ge("oneShow"))},{trigger:f((()=>[w(t.$slots,"button",{handleClickPrintBtn:vt,printSpinning:Pe.spinning,printbtnText:e.btnText,printVisible:Pe.visible},(()=>[m(v(L),{class:"newprint-button-component",onClick:n[4]||(n[4]=S((()=>Ue("icon")),["stop"]))},{default:f((()=>[m(v(j),{loading:e.showLoading&&Pe.spinning,onClick:n[3]||(n[3]=S((()=>Ue("button")),["stop"])),class:h(Te.value.length>0?"printAllLeftCls":"")},{icon:f((()=>[m(v(M),{component:v(N),size:"18"},null,8,["component"])])),default:f((()=>[k(" "+b(v(Ee)?"打印全部":e.btnText)+" ",1),v(Je)?(s(),u("span",Z,b(v(Je)),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(Le.value,(e=>(s(),u("div",{class:h(["print-li",Oe.oneMouseType==e.key||Oe.oneClickType==e.key?"active":""]),key:e.key,onMouseenter:t=>Ve("oneMouseType",e.key),onMouseleave:n[9]||(n[9]=e=>Ve("oneMouseType","")),onClick:t=>((e,t,n)=>{if(!Pe.printParams[n.templateCode])return[];Ve(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:Ce.isOutSetting,onClickoutside:n[7]||(n[7]=e=>Ge("isOutSetting"))},{trigger:f((()=>[d("div",{class:"print-lite",onClick:n[5]||(n[5]=e=>qe("isOutSetting"))},[d("span",ne,b(e.label),1),m(v(M),{color:Te.value.length>0?"#2563F4":"",component:v(_),size:"18"},null,8,["color","component"])])])),default:f((()=>[d("div",re,[(s(!0),u(c,null,y(v(ze),(e=>(s(),u("div",{class:"print-li",key:e.key},[d("div",ie,[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:Be},{default:f((()=>[k("保存")])),_:1}),v(ze)&&v(ze).length>1?(s(),g(v(E),{key:0,checked:v(Ke),"onUpdate:checked":n[6]||(n[6]=e=>P(Ke)?Ke.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",Pe.printParams[e.templateCode]?"":"isDisabled"])},[d("span",{class:"label bold",onClick:t=>tt(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),Pe.printParams[e.templateCode]?(s(),g(v(x),{key:0,trigger:"click","show-arrow":!1,placement:"right-start",show:Ce[e.key],onClickoutside:t=>Ge(e.key)},{trigger:f((()=>[m(v(M),{component:v(R),size:"18",onClick:t=>qe(e.key)},null,8,["component","onClick"])])),default:f((()=>[d("div",ce,[(s(!0),u(c,null,y(v(Ie),(t=>(s(),u("div",{class:h(["print-li",Oe.twoMouseType==t.key?"active":""]),key:t.key,onMouseenter:e=>Ve("twoMouseType",t.key),onMouseleave:n[8]||(n[8]=e=>Ve("twoMouseType",""))},[d("div",pe,[d("span",{class:"label",onClick:n=>rt(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:Pe.identityVerification.visible,"onUpdate:modelValue":n[11]||(n[11]=e=>Pe.identityVerification.visible=e),formatId:Pe.currentFormatId,templateId:v(Me),onSuccess:ft}),null,16,["modelValue","formatId","templateId"])],64))}});export{ve as default};
@@ -36,7 +36,7 @@ export declare class Print {
36
36
  showPreview(...args: Parameters<PreviewDialog['show']>): Promise<string>;
37
37
  _testDomesticSystemConnection(): Promise<unknown>;
38
38
  _testConnection(): Promise<unknown>;
39
- resetPrinter(formatId: string): Promise<any>;
39
+ resetPrinter(formatId: string, iReportExecuteMode: number): Promise<any>;
40
40
  _queryServicesPrint(params: AnyObject): Promise<any>;
41
41
  _queryBase64ServicesPrint(params: AnyObject): Promise<any>;
42
42
  _callPrintWithFile(queryParams: AnyObject): Promise<any>;
@@ -1 +1 @@
1
- import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{getFileUrl as r,useBrowserPrint as n,isIReport as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as c}from"date-fns";import{io as h}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),p=`${window.location.protocol}//${window.location.host}`,d=`${p}/fdp-api/print/assembly/printIReport`,g=`${p}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${p}/bi-api/reprot/print/open/client/previewIReport`,y=`${p}/bi-api/reprot/print/open/client/getRemote`,w=`${p}/printService/file`;let P=null;class v{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this;const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=h(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","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=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{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)}))}))}resetPrinter(t){return this.webview?this.postMessage({exec:"resetprint",data:{formatID:t}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:t}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:"error",errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({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,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o,printdlgshow:l="0",nobillnode:h="1",btnprint:u="1",messageTimeout:m=0}){const p={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:u,copies:o,messageTimeout:m,...a?{signature:a}:{}};if(s&&(p.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}p.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");p.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=p,await this._queryServicesPrint(p)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:r=0}){const n={};let a={};try{a=Object.assign({},n,JSON.parse(i))}catch(t){a=n}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:r};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:y})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=p+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:d,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}paramsSerializer(t){return Object.keys(t).forEach((e=>{const i=t[e];t[e]=i,"biParams"==e&&(t[e]=encodeURIComponent(i))})),t}async _queryPrintForBase64(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:g,params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _queryPrintForPdf(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:f,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),a=s[s.length-2],o=s[s.length-1],l=await r(`${w}/${a}/${o}`),c=n(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let s=i.length;const r=new Uint8Array(s);for(;s--;)r[s]=i.charCodeAt(s);return new Blob([r],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:r,authorizationKey:l,signature:c,btnprint:h,messageTimeout:m=0},p,d){const g=a(i);if(i=this.getIReportFormatId(g,i),g&&(u||2==t)){const t=await this._queryPrintForPdf(e,i,s,l);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const r=n(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,r),null==p?void 0:p({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:i,params:s,paramsArr:r,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:m}),n=this._handleResult(t,d);if(!n)return!1;if(this.isRemote){const t=await this._browserPrint(n,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}await this.getPicAndUpload(n),null==p||p(n)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:"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:s="",paramsArr:r,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:m,isDownloadFile:p=!0,messageTimeout:d=0},g,f,y,w="printDirect"){const P=a(i);if(i=this.getIReportFormatId(P,i),P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},g,f,y):f({type:"connectAppFail",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:n},g,f,y))}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:r,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:m,messageTimeout:d}),n=this._handleResult(t,f,y);if(!n)return!1;p&&["downloadPDF"].includes(w)&&await this._browserPrint(n,w),null==g||g(n)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",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:s},r,n,a){const o=await this._queryPrintForBase64(t,e,i,s);if(!o.success)return n({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=r,this._errorCallbackFn=n,a&&(this._cancelCallbackFn=a),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,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=c(new Date,"yyyy-MM-dd"),i=l(),s=c(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}const r=a(t.formatId);if(t.formatId=this.getIReportFormatId(r,t.formatId),r&&(u||2==t.iReportExecuteMode)){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(n(e,"downloadPDF"),i({file:e,result:"success",message:""})):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(t,(async t=>{t||s({result:"error",message:""});const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
1
+ import t from"axios";import{isArray as e}from"lodash-es";import{IdentityVerificationDialog as i,PreviewDialog as s}from"./dialog.js";import{isIReport as r,getFileUrl as n,useBrowserPrint as a}from"./browserPrint.js";import{getCurrentInstance as o}from"vue";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{format as c}from"date-fns";import{io as h}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),p=`${window.location.protocol}//${window.location.host}`,d=`${p}/fdp-api/print/assembly/printIReport`,g=`${p}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${p}/bi-api/reprot/print/open/client/previewIReport`,y=`${p}/bi-api/reprot/print/open/client/getRemote`,w=`${p}/printService/file`;let P=null;class v{constructor(){var t,e,r;if(this.webview=null,this.dialog=new i,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,P)return P;P=this;const n=window;this.CMonitor=n.$CMonitor;try{this.webview=n.top?null==(t=n.top.chrome)?void 0:t.webview:null==(e=n.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(r=n.chrome)?void 0:r.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:s,reject:r}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void s({result:(null==i?void 0:i.res)?"success":"fail"});s(i.res||"")}catch(t){r(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=h(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","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=l();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,s)=>{this.messageHandlerQueue.push({resolve:i,reject:s,id:t}),this.webview.postMessage(e)})),new Promise(((e,s)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),s({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{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=r(t);if(t=this.getIReportFormatId(i,t),i&&(u||2==e)){return await this._testDomesticSystemConnection()?m({url:`${this.printDomesticOrigin}/resetPrint`,method:"get",withCredentials:!1,params:{formatId:t}}).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:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"}}return this.webview?this.postMessage({exec:"resetprint",data:{formatID:t}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:t}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:s(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[s]}).then((({data:t})=>t));function s(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:"error",errinfo:t}),!1}if("success"!==t.result){const s=t.message||t.Message;this._handleMonitorNotify(s);const r={type:"printError",message:s,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:s,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(r),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,s,r){const n={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:s},a=await this._queryServicesPrint(n);return this._handleQueryPrintDataResult(a,e,r)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({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,params:i,paramsArr:s,cmdid:r,print:n,signature:a,copies:o,printdlgshow:l="0",nobillnode:h="1",btnprint:u="1",messageTimeout:m=0}){const p={templateId:t,formatId:e,params:i,cmdid:r,nobillnode:h,printdlgshow:l,btnprint:u,copies:o,messageTimeout:m,...a?{signature:a}:{}};if(s&&(p.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}p.print=n}else if(this.isRemote){const t=c(new Date,"yyyyMMddHHmmss");p.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=p,await this._queryServicesPrint(p)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:s,messageTimeout:r=0}){const n={};let a={};try{a=Object.assign({},n,JSON.parse(i))}catch(t){a=n}const o={templateId:t,formatId:e,cmdid:"9",token:s,params:JSON.stringify(a),messageTimeout:r};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:y})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=p+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:d,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}paramsSerializer(t){return Object.keys(t).forEach((e=>{const i=t[e];t[e]=i,"biParams"==e&&(t[e]=encodeURIComponent(i))})),t}async _queryPrintForBase64(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:g,params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _queryPrintForPdf(t,e,i="",s){const r="object"==typeof i?i:JSON.parse(i),{data:n}=await m({method:"post",url:f,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(r),authorizationKey:s}})||{};return n}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,s=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),r=s[s.length-2],o=s[s.length-1],l=await n(`${w}/${r}/${o}`),c=a(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let s=i.length;const r=new Uint8Array(s);for(;s--;)r[s]=i.charCodeAt(s);return new Blob([r],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:s="",paramsArr:n,authorizationKey:l,signature:c,btnprint:h,messageTimeout:m=0},p,d){const g=r(i);if(i=this.getIReportFormatId(g,i),g&&(u||2==t)){const t=await this._queryPrintForPdf(e,i,s,l);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const r=a(t,"preview");return this.instance||(this.instance=o()),this.showPreview(this.instance,r),null==p?void 0:p({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:i,params:s,paramsArr:n,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:m}),r=this._handleResult(t,d);if(!r)return!1;if(this.isRemote){const t=await this._browserPrint(r,"preview");this.instance||(this.instance=o()),this.showPreview(this.instance,t)}await this.getPicAndUpload(r),null==p||p(r)}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 s=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=l(),r=await this.messageCollect(t,{exec:"printA",data:s});if(r&&Array.isArray(r)){r.some((t=>"success"===t.res.result))?null==e||e(r):(null==i||i(r),this._handleMonitorNotify(r))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(r||""),null==i||i({type:"printError",message:t,result:"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:s="",paramsArr:n,authorizationKey:a,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:m,isDownloadFile:p=!0,messageTimeout:d=0},g,f,y,w="printDirect"){const P=r(i);if(i=this.getIReportFormatId(P,i),P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:a},g,f,y):f({type:"connectAppFail",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:i,params:s,authorizationKey:a},g,f,y))}await this._queryProxyOrigin();const v=await this._testConnection();if(!this._handleResultTest(v,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:i,params:s,paramsArr:n,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:m,messageTimeout:d}),r=this._handleResult(t,f,y);if(!r)return!1;p&&["downloadPDF"].includes(w)&&await this._browserPrint(r,w),null==g||g(r)}catch(t){const e="printDirect"===w?"打印失败":"下载失败",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:s},r,n,a){const o=await this._queryPrintForBase64(t,e,i,s);if(!o.success)return n({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=r,this._errorCallbackFn=n,a&&(this._cancelCallbackFn=a),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,i,s){if(this.webview&&this.downloadPath&&(Reflect.has(t,"print")||Reflect.set(t,"print",{print:"1",type:"1"}),!t.print.filename)){const e=c(new Date,"yyyy-MM-dd"),i=l(),s=c(new Date,"yyyyMMddHHmmss")+i;t.print.filename=`${this.downloadPath}/${e}/${s}/${s}`.replace(/\\/g,"/")}const n=r(t.formatId);if(t.formatId=this.getIReportFormatId(n,t.formatId),n&&(u||2==t.iReportExecuteMode)){const e=await this._queryPrintForPdf(t.templateId||"",t.formatId,t.params||"",t.authorizationKey);return e?(a(e,"downloadPDF"),i({file:e,result:"success",message:""})):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(t,(async t=>{t||s({result:"error",message:""});const r=this,n=await async function(t){const i=[],s=JSON.parse(t);if(!e(s))return await r._downloadPDF("");if(1===s.length)return await r._downloadPDF(s[0]||"");for(let t=0,e=s.length;t<e;t++)i.push(await r._downloadPDF(s[t]||""));return i}(t.filedir);i(n,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:s},void 0,n);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,n);if(!l)return!1;r&&r(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:s=0},r,n){const a=await this._testConnection();if(!this._handleResultTest(a,n))return!1;const o=await this._handleEventQueryPrintData(t,e,i,s,n);return!!o&&(r&&r(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(a,r);return!!o&&(s&&s(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r=0},n,a){const o=await this._testConnection();if(!this._handleResultTest(o,a))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:s,messageTimeout:r}),c=this._handleResult(l,a);if(!c)return!1;n&&n(c)}async addPrintFormat({templateId:t,params:e,token:i},s,r){const n=await this._testConnection();if(!this._handleResultTest(n,r))return!1;const a=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(a,r);if(!o)return!1;s&&s(o)}}export{v as Print};
@@ -175,9 +175,6 @@ declare const _default: import("vue").DefineComponent<{
175
175
  modelValue: unknown[];
176
176
  componentData: Record<string, any>;
177
177
  } & {
178
- /**
179
- * 改变弹窗大小
180
- */
181
178
  itemKey?: string | Function | undefined;
182
179
  }>, {
183
180
  move: Function;
@@ -521,9 +521,9 @@ declare const _default: import("vue").DefineComponent<{
521
521
  }>;
522
522
  developMode: boolean;
523
523
  draggable: boolean;
524
- isHighlightRow: boolean;
525
524
  idx: number;
526
525
  isHighlight: boolean;
526
+ isHighlightRow: boolean;
527
527
  isFieldSet: boolean;
528
528
  fieldDescribeMode: "column" | "tooltip";
529
529
  hideExpressionOption: AnyObject[];
@@ -543,9 +543,9 @@ declare const _default: import("vue").DefineComponent<{
543
543
  }>;
544
544
  developMode: boolean;
545
545
  draggable: boolean;
546
- isHighlightRow: boolean;
547
546
  idx: number;
548
547
  isHighlight: boolean;
548
+ isHighlightRow: boolean;
549
549
  isFieldSet: boolean;
550
550
  fieldDescribeMode: "column" | "tooltip";
551
551
  hideExpressionOption: AnyObject[];
@@ -710,9 +710,9 @@ declare const _default: import("vue").DefineComponent<{
710
710
  }>;
711
711
  developMode: boolean;
712
712
  draggable: boolean;
713
- isHighlightRow: boolean;
714
713
  idx: number;
715
714
  isHighlight: boolean;
715
+ isHighlightRow: boolean;
716
716
  isFieldSet: boolean;
717
717
  fieldDescribeMode: "column" | "tooltip";
718
718
  hideExpressionOption: AnyObject[];
@@ -845,8 +845,8 @@ declare const _default: import("vue").DefineComponent<{
845
845
  developMode: boolean;
846
846
  footerFlag: boolean;
847
847
  fieldDescribeMode: "column" | "tooltip";
848
- customColumns: FieldSetColumnItem[];
849
848
  showSearch: boolean;
849
+ customColumns: FieldSetColumnItem[];
850
850
  showSortPriority: boolean;
851
851
  showHeadFilter: boolean;
852
852
  }>;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as l,computed as t,reactive as i,toRef as o,watch as d,openBlock as a,createElementBlock as r,createBlock as s,unref as n,withKeys as u,withModifiers as c,createCommentVNode as f,createElementVNode as p,Fragment as h,renderList as m,normalizeStyle as y,withCtx as v,createTextVNode as b,toDisplayString as g,createVNode as x,normalizeClass as k,mergeProps as w,renderSlot as S}from"vue";import{NInput as C,NCheckbox as A,NTooltip as _,NIcon as W,NPopconfirm as E,NButton as H}from"naive-ui";import D from"../../../shared/components/VueDraggable/src/vuedraggable.js";import F from"./components/table-row.vue.js";import{isArray as M,cloneDeep as P,isString as R,omit as j}from"lodash-es";import{isDisable as B,setStyle as N,isDraggableItem as V,isDraggable as O,getGroupTree as q}from"./utils/index.js";import{uuidGenerator as I}from"../../../shared/utils/index.js";import{HelpCircleSharp as K}from"@vicons/ionicons5";const U={class:"main-wrapper"},T={class:"main-wrapper__table-header"},G=p("span",null,"数值越小,优先级越高",-1),L=["tabindex"],$={key:1,class:"main-wrapper__table-footer"};var z=e({__name:"FieldSet",props:{fields:{type:Array,default:()=>[]},footerFlag:{type:Boolean,default:!0},type:{type:String,default:"old"},isEdit:{type:Boolean,default:!1},showColumnNames:{type:Array},groupSetting:{type:Object},customColumns:{type:Array,default:()=>[]},showSeq:{type:Boolean,default:!1},showSearch:{type:Boolean,default:!1},showSortPriority:{type:Boolean,default:!1},showHeadFilter:{type:Boolean,default:!1},fieldShowMaxValue:{type:Number},rowDraggable:{type:Boolean,default:!0},fieldDescribeMode:{type:String,default:"tooltip"},developMode:{type:Boolean},columnWidthProps:{type:Object},hideExpressionConfig:{type:Object},primaryKey:{type:String,default:"id"},titleRender:{type:Function}},emits:["save","close","reset"],setup(e,{expose:z,emit:J}){const Q=e,X={sid:"id",columnName:"name",isShow:"show",isSort:"sort",isFixed:"fixedWay",colWidth:"columnWidth"},Y=l(Date.now()),Z=l(""),ee=l(),le=l([]),te=[{title:"所有字段",type:"text",field:"title"},{title:"显示",type:"checkbox",checkedAll:!1,disabledAll:!!Q.fieldShowMaxValue,field:"show",fieldShowMaxValue:Q.fieldShowMaxValue},{title:"编辑",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"editable"},{title:"必填",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"required"},{title:"排序",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"sort"},{title:"加粗",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"bold"},{title:"默认排序",type:"select",field:"sortDirection"},{title:"排序优先级",type:"select",field:"sortPriority"},{title:"固定",type:"select",field:"fixedWay"},{title:"自定义标题",type:"input",field:"alias"},{title:"列宽",type:"inputNumber",field:"columnWidth"},{title:"表头筛选",type:"checkbox",isHeadCheckHide:!0,field:"isShowHeaderFilter"},{title:"脱敏配置",type:"select",field:"hideExpression"}],ie=[{title:"搜素",type:"checkbox",isHeadCheckHide:!0,field:"isSearch"},{title:"求和",type:"checkbox",isHeadCheckHide:!0,field:"isSum"},{title:"平均值",type:"checkbox",isHeadCheckHide:!0,field:"isAvg"}],oe=l([]),de=t((()=>le.value.flat())),ae=t((()=>de.value.some((e=>e.feildDescribe)))),re=i({columns:oe,data:de,onUpdateChecked:function({checked:e,column:l}){const t=!e||ye(l.field);l.checkedAll=!t},draggable:Q.rowDraggable,isFieldSet:!0,fieldDescribeMode:Q.fieldDescribeMode,developMode:Q.developMode,columnWidthProps:Q.columnWidthProps,hideExpressionOption:o(Q.hideExpressionConfig||{option:[]},"option"),primaryKey:o(Q,"primaryKey"),titleRender:Q.titleRender}),se={keyword:Z.value,idx:0,startIdx:0},ne=()=>{J("save")},ue=()=>{J("close")};function ce(){le.value=fe(),me(),Y.value=Date.now(),J("reset")}function fe(){const e=P(Q.fields).map((e=>({...e,uuid:I()})));return Object.keys(X).forEach((l=>{e.forEach((e=>{"old"==Q.type&&Reflect.has(e,l)&&("isFixed"==l?e.fixedWay=1==e[l]?"LEFT":2==e[l]?"RIGHT":"NONE":["isShow","isSort"].includes(l)&&"boolean"!=typeof l?e[X[l]]=1==e[l]:e[X[l]]=e[l],Reflect.deleteProperty(e,l)),e.columnWidth=+e.columnWidth||null,Reflect.has(e,"alias")||(e.alias=""),Reflect.has(e,"bold")||(e.bold=!1),e.draggable=!!O(e)}))})),function(e){if(Q.groupSetting){return q(Q.groupSetting,e).reduce(((t,i)=>{const o=R(i)?e.find((e=>e.name===i)):l(i.children);return o&&t.push(o),t}),[])}return e;function l(t){const i=[];return t.forEach((t=>{if(t.children)i.push(...l(t.children));else{const l=e.find((e=>e.name===t));l&&i.push(l)}})),i}}(e)}function pe(){const e=se.keyword!==Z.value;let l=Z.value?de.value.findIndex(((l,t)=>{var i;if(null==(i=l.title)?void 0:i.includes(Z.value))return!!e||t>se.idx})):0;-1!==l||e||(l=se.startIdx),ee.value.scrollTop=52*l,Object.assign(se,{keyword:Z.value,idx:l},e?{startIdx:l}:{})}function he(e){var l;return!!Z.value&&(null==(l=e.title)?void 0:l.includes(Z.value))}function me(){var e,l;oe.value=P(te),(null==(e=Q.showColumnNames)?void 0:e.length)&&(oe.value=te.concat(ie).filter((e=>{var l,t;return"title"===e.field||(null==(t=null==(l=Q.showColumnNames)?void 0:l.includes)?void 0:t.call(l,e.field))}))),(null==(l=Q.customColumns)?void 0:l.length)&&oe.value.push(...Q.customColumns),"column"===Q.fieldDescribeMode&&ae.value&&oe.value.push({title:"字段描述",type:"text",field:"feildDescribe"}),Q.showSeq&&oe.value.splice(1,0,{title:"排序",type:"text",field:"seq"}),oe.value.forEach((e=>{if(e.isShow=function(e){var l;return!(["editable","required"].includes(e.field)&&!Q.isEdit||"sortPriority"===e.field&&!Q.showSortPriority||"isShowHeaderFilter"===e.field&&!Q.showHeadFilter||"hideExpression"===e.field&&!(null==(l=Q.hideExpressionConfig)?void 0:l.show))}(e),"checkbox"===e.type){const l=le.value.flat().every((l=>!Reflect.has(l,e.field)));e.checkedAll=!ye(e.field)&&!l}}))}function ye(e){return le.value.flat().some((l=>!B(l,e)&&!l[e]&&"0001"!=l.id))}function ve(e){return!!V(e.relatedContext.element)}return d([()=>Q.fields,()=>{var e;return null==(e=Q.showColumnNames)?void 0:e.length}],(([e,l])=>{e.length>0&&(le.value=fe(),me())}),{immediate:!0,deep:!0}),z({getTableFields:function(){let e=[];return e="old"==Q.type?de.value.map(((e,l)=>j({...e,field:e.name,visible:e.show,sequence:l,sortable:e.sort,title:e.alias,fixed:e.fixedWay,minWidth:e.columnWidth},["name","show","sort","alias","fixedWay","columnWidth"]))):de.value,e.map((e=>j(e,["uuid"])))}}),(l,t)=>(a(),r("div",U,[e.showSearch?(a(),s(n(C),{key:0,class:"main-wrapper__search-wrapper",value:Z.value,"onUpdate:value":t[0]||(t[0]=e=>Z.value=e),valueModifiers:{trim:!0},placeholder:"请输入字段标题",onKeydown:u(c(pe,["prevent"]),["enter"])},null,8,["value","onKeydown"])):f("v-if",!0),p("div",T,[(a(!0),r(h,null,m(oe.value,((l,t)=>(a(),r(h,{key:t},[l.isShow?(a(),r("span",{key:0,class:"table-cell",style:y(n(N)(l,t,e.columnWidthProps))},["checkbox"!==l.type||l.isHeadCheckHide?(a(),r(h,{key:1},[b(g(l.title),1)],64)):(a(),s(n(A),{key:0,checked:l.checkedAll,"onUpdate:checked":[e=>l.checkedAll=e,e=>{return t=e,i=l.field,void de.value.forEach((e=>{B(e,i)||(e[i]=t)}));var t,i}],disabled:l.disabledAll},{default:v((()=>[b(g(l.title),1)])),_:2},1032,["checked","onUpdate:checked","disabled"])),"sortPriority"===l.field?(a(),s(n(_),{key:2,trigger:"hover"},{trigger:v((()=>[x(n(W),{component:n(K),style:{top:"2px"}},null,8,["component"])])),default:v((()=>[G])),_:1})):f("v-if",!0)],4)):f("v-if",!0)],64)))),128))]),p("div",{class:"main-wrapper__table-body",ref_key:"tableBodyRef",ref:ee},[(a(),s(n(D),{modelValue:le.value,"onUpdate:modelValue":t[1]||(t[1]=e=>le.value=e),animation:"150","item-key":"id",filter:".disabled",draggable:".item",move:ve,disabled:!e.rowDraggable,key:Y.value},{item:v((({element:e,index:l})=>[e.hide?f("v-if",!0):(a(),r("div",{key:0,class:k(["item",n(V)(e)?"":"disabled"]),tabindex:l},[n(M)(e)?(a(!0),r(h,{key:0},m(e,((e,t)=>(a(),s(F,w(re,{key:t,element:e,idx:l+1,"is-highlight":he(e)}),null,16,["element","idx","is-highlight"])))),128)):(a(),s(F,w({key:1},re,{element:e,idx:l+1,"is-highlight":he(e)}),null,16,["element","idx","is-highlight"]))],10,L))])),_:1},8,["modelValue","disabled"]))],512),e.footerFlag?(a(),r("div",$,[f(" 底部按钮插槽 "),S(l.$slots,"footer",{},(()=>[x(n(E),{onPositiveClick:ce},{trigger:v((()=>[x(n(H),{style:{"margin-right":"8px"}},{default:v((()=>[b("恢复默认设置")])),_:1})])),default:v((()=>[b(" 确认要恢复系统默认设置吗? ")])),_:1}),x(n(H),{style:{"margin-right":"8px"},onClick:ue},{default:v((()=>[b("取消")])),_:1}),x(n(H),{type:"primary",onClick:ne},{default:v((()=>[b("保存")])),_:1})]))])):f("v-if",!0)]))}});export{z as default};
1
+ import{defineComponent as e,ref as l,computed as t,reactive as i,toRef as o,watch as d,openBlock as a,createElementBlock as r,createBlock as n,unref as s,withKeys as u,withModifiers as c,createCommentVNode as f,createElementVNode as h,Fragment as p,renderList as m,normalizeStyle as y,withCtx as v,createTextVNode as b,toDisplayString as g,createVNode as x,normalizeClass as k,mergeProps as w,renderSlot as S}from"vue";import{NInput as C,NCheckbox as A,NTooltip as _,NIcon as W,NPopconfirm as E,NButton as H}from"naive-ui";import D from"../../../shared/components/VueDraggable/src/vuedraggable.js";import F from"./components/table-row.vue.js";import{isArray as M,cloneDeep as P,isString as N,omit as R}from"lodash-es";import{isDisable as j,setStyle as B,isDraggableItem as V,isDraggable as O,getGroupTree as q}from"./utils/index.js";import{uuidGenerator as I}from"../../../shared/utils/index.js";import{HelpCircleSharp as K}from"@vicons/ionicons5";const U={class:"main-wrapper"},T={class:"main-wrapper__table-header"},G=h("span",null,"数值越小,优先级越高",-1),L=["tabindex"],$={key:1,class:"main-wrapper__table-footer"};var z=e({__name:"FieldSet",props:{fields:{type:Array,default:()=>[]},footerFlag:{type:Boolean,default:!0},type:{type:String,default:"old"},isEdit:{type:Boolean,default:!1},showColumnNames:{type:Array},groupSetting:{type:Object},customColumns:{type:Array,default:()=>[]},showSeq:{type:Boolean,default:!1},showSearch:{type:Boolean,default:!1},showSortPriority:{type:Boolean,default:!1},showHeadFilter:{type:Boolean,default:!1},fieldShowMaxValue:{type:Number},rowDraggable:{type:Boolean,default:!0},fieldDescribeMode:{type:String,default:"tooltip"},developMode:{type:Boolean},columnWidthProps:{type:Object},hideExpressionConfig:{type:Object},primaryKey:{type:String,default:"id"},titleRender:{type:Function}},emits:["save","close","reset"],setup(e,{expose:z,emit:J}){const Q=e,X={sid:"id",columnName:"name",isShow:"show",isSort:"sort",isFixed:"fixedWay",colWidth:"columnWidth"},Y=l(Date.now()),Z=l(""),ee=l(),le=l([]),te=[{title:"所有字段",type:"text",field:"title"},{title:"显示",type:"checkbox",checkedAll:!1,disabledAll:!!Q.fieldShowMaxValue,field:"show",fieldShowMaxValue:Q.fieldShowMaxValue},{title:"编辑",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"editable"},{title:"必填",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"required"},{title:"排序",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"sort"},{title:"加粗",type:"checkbox",checkedAll:!1,disabledAll:!1,field:"bold"},{title:"默认排序",type:"select",field:"sortDirection"},{title:"排序优先级",type:"select",field:"sortPriority"},{title:"固定",type:"select",field:"fixedWay"},{title:"自定义标题",type:"input",field:"alias"},{title:"列宽",type:"inputNumber",field:"columnWidth"},{title:"表头筛选",type:"checkbox",isHeadCheckHide:!0,field:"isShowHeaderFilter"},{title:"脱敏配置",type:"select",field:"hideExpression"}],ie=[{title:"搜索",type:"checkbox",isHeadCheckHide:!0,field:"isSearch"},{title:"求和",type:"checkbox",isHeadCheckHide:!0,field:"isSum"},{title:"平均值",type:"checkbox",isHeadCheckHide:!0,field:"isAvg"}],oe=l([]),de=t((()=>le.value.flat())),ae=t((()=>de.value.some((e=>e.feildDescribe)))),re=i({columns:oe,data:de,onUpdateChecked:function({checked:e,column:l}){const t=!e||ye(l.field);l.checkedAll=!t},draggable:Q.rowDraggable,isFieldSet:!0,fieldDescribeMode:Q.fieldDescribeMode,developMode:Q.developMode,columnWidthProps:Q.columnWidthProps,hideExpressionOption:o(Q.hideExpressionConfig||{option:[]},"option"),primaryKey:o(Q,"primaryKey"),titleRender:Q.titleRender}),ne={keyword:Z.value,idx:0,startIdx:0},se=()=>{J("save")},ue=()=>{J("close")};function ce(){le.value=fe(),me(),Y.value=Date.now(),J("reset")}function fe(){const e=P(Q.fields).map((e=>({...e,uuid:I()})));return Object.keys(X).forEach((l=>{e.forEach((e=>{"old"==Q.type&&Reflect.has(e,l)&&("isFixed"==l?e.fixedWay=1==e[l]?"LEFT":2==e[l]?"RIGHT":"NONE":["isShow","isSort"].includes(l)&&"boolean"!=typeof l?e[X[l]]=1==e[l]:e[X[l]]=e[l],Reflect.deleteProperty(e,l)),e.columnWidth=+e.columnWidth||null,Reflect.has(e,"alias")||(e.alias=""),Reflect.has(e,"bold")||(e.bold=!1),e.draggable=!!O(e)}))})),function(e){if(Q.groupSetting){return q(Q.groupSetting,e).reduce(((t,i)=>{const o=N(i)?e.find((e=>e.name===i)):l(i.children);return o&&t.push(o),t}),[])}return e;function l(t){const i=[];return t.forEach((t=>{if(t.children)i.push(...l(t.children));else{const l=e.find((e=>e.name===t));l&&i.push(l)}})),i}}(e)}function he(){const e=ne.keyword!==Z.value;let l=Z.value?de.value.findIndex(((l,t)=>{var i;if(null==(i=l.title)?void 0:i.includes(Z.value))return!!e||t>ne.idx})):0;-1!==l||e||(l=ne.startIdx),ee.value.scrollTop=52*l,Object.assign(ne,{keyword:Z.value,idx:l},e?{startIdx:l}:{})}function pe(e){var l;return!!Z.value&&(null==(l=e.title)?void 0:l.includes(Z.value))}function me(){var e,l;oe.value=P(te),(null==(e=Q.showColumnNames)?void 0:e.length)&&(oe.value=te.concat(ie).filter((e=>{var l,t;return"title"===e.field||(null==(t=null==(l=Q.showColumnNames)?void 0:l.includes)?void 0:t.call(l,e.field))}))),(null==(l=Q.customColumns)?void 0:l.length)&&oe.value.push(...Q.customColumns),"column"===Q.fieldDescribeMode&&ae.value&&oe.value.push({title:"字段描述",type:"text",field:"feildDescribe"}),Q.showSeq&&oe.value.splice(1,0,{title:"排序",type:"text",field:"seq"}),oe.value.forEach((e=>{if(e.isShow=function(e){var l,t;if(!(null==(l=Q.showColumnNames)?void 0:l.length)&&(["editable","required"].includes(e.field)&&!Q.isEdit||"sortPriority"===e.field&&!Q.showSortPriority||"isShowHeaderFilter"===e.field&&!Q.showHeadFilter||"hideExpression"===e.field&&!(null==(t=Q.hideExpressionConfig)?void 0:t.show)))return!1;return!0}(e),"checkbox"===e.type){const l=le.value.flat().every((l=>!Reflect.has(l,e.field)));e.checkedAll=!ye(e.field)&&!l}}))}function ye(e){return le.value.flat().some((l=>!j(l,e)&&!l[e]&&"0001"!=l.id))}function ve(e){return!!V(e.relatedContext.element)}return d([()=>Q.fields,()=>{var e;return null==(e=Q.showColumnNames)?void 0:e.length}],(([e,l])=>{e.length>0&&(le.value=fe(),me())}),{immediate:!0,deep:!0}),z({getTableFields:function(){let e=[];return e="old"==Q.type?de.value.map(((e,l)=>R({...e,field:e.name,visible:e.show,sequence:l,sortable:e.sort,title:e.alias,fixed:e.fixedWay,minWidth:e.columnWidth},["name","show","sort","alias","fixedWay","columnWidth"]))):de.value,e.map((e=>R(e,["uuid"])))}}),(l,t)=>(a(),r("div",U,[e.showSearch?(a(),n(s(C),{key:0,class:"main-wrapper__search-wrapper",value:Z.value,"onUpdate:value":t[0]||(t[0]=e=>Z.value=e),valueModifiers:{trim:!0},placeholder:"请输入字段标题",onKeydown:u(c(he,["prevent"]),["enter"])},null,8,["value","onKeydown"])):f("v-if",!0),h("div",T,[(a(!0),r(p,null,m(oe.value,((l,t)=>(a(),r(p,{key:t},[l.isShow?(a(),r("span",{key:0,class:"table-cell",style:y(s(B)(l,t,e.columnWidthProps))},["checkbox"!==l.type||l.isHeadCheckHide?(a(),r(p,{key:1},[b(g(l.title),1)],64)):(a(),n(s(A),{key:0,checked:l.checkedAll,"onUpdate:checked":[e=>l.checkedAll=e,e=>{return t=e,i=l.field,void de.value.forEach((e=>{j(e,i)||(e[i]=t)}));var t,i}],disabled:l.disabledAll},{default:v((()=>[b(g(l.title),1)])),_:2},1032,["checked","onUpdate:checked","disabled"])),"sortPriority"===l.field?(a(),n(s(_),{key:2,trigger:"hover"},{trigger:v((()=>[x(s(W),{component:s(K),style:{top:"2px"}},null,8,["component"])])),default:v((()=>[G])),_:1})):f("v-if",!0)],4)):f("v-if",!0)],64)))),128))]),h("div",{class:"main-wrapper__table-body",ref_key:"tableBodyRef",ref:ee},[(a(),n(s(D),{modelValue:le.value,"onUpdate:modelValue":t[1]||(t[1]=e=>le.value=e),animation:"150","item-key":"id",filter:".disabled",draggable:".item",move:ve,disabled:!e.rowDraggable,key:Y.value},{item:v((({element:e,index:l})=>[e.hide?f("v-if",!0):(a(),r("div",{key:0,class:k(["item",s(V)(e)?"":"disabled"]),tabindex:l},[s(M)(e)?(a(!0),r(p,{key:0},m(e,((e,t)=>(a(),n(F,w(re,{key:t,element:e,idx:l+1,"is-highlight":pe(e)}),null,16,["element","idx","is-highlight"])))),128)):(a(),n(F,w({key:1},re,{element:e,idx:l+1,"is-highlight":pe(e)}),null,16,["element","idx","is-highlight"]))],10,L))])),_:1},8,["modelValue","disabled"]))],512),e.footerFlag?(a(),r("div",$,[f(" 底部按钮插槽 "),S(l.$slots,"footer",{},(()=>[x(s(E),{onPositiveClick:ce},{trigger:v((()=>[x(s(H),{style:{"margin-right":"8px"}},{default:v((()=>[b("恢复默认设置")])),_:1})])),default:v((()=>[b(" 确认要恢复系统默认设置吗? ")])),_:1}),x(s(H),{style:{"margin-right":"8px"},onClick:ue},{default:v((()=>[b("取消")])),_:1}),x(s(H),{type:"primary",onClick:se},{default:v((()=>[b("保存")])),_:1})]))])):f("v-if",!0)]))}});export{z as default};
@@ -376,9 +376,9 @@ declare const _default: import("vue").DefineComponent<{
376
376
  }>;
377
377
  developMode: boolean;
378
378
  draggable: boolean;
379
- isHighlightRow: boolean;
380
379
  idx: number;
381
380
  isHighlight: boolean;
381
+ isHighlightRow: boolean;
382
382
  isFieldSet: boolean;
383
383
  fieldDescribeMode: "column" | "tooltip";
384
384
  hideExpressionOption: AnyObject[];
@@ -343,6 +343,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
343
343
  };
344
344
  defaultValue: {
345
345
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
346
+ default: () => never[];
346
347
  };
347
348
  }, {
348
349
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -363,6 +364,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
363
364
  };
364
365
  defaultValue: {
365
366
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
367
+ default: () => never[];
366
368
  };
367
369
  }>> & {
368
370
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -425,10 +427,12 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
425
427
  };
426
428
  defaultValue: {
427
429
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
430
+ default: () => never[];
428
431
  };
429
432
  }>> & {
430
433
  onComfirm?: ((...args: any[]) => any) | undefined;
431
434
  }, {
435
+ defaultValue: import("../../shared/types").AnyObject[];
432
436
  mode: string;
433
437
  title: string;
434
438
  disabledIds: string[];
@@ -659,6 +663,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
659
663
  };
660
664
  defaultValue: {
661
665
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
666
+ default: () => never[];
662
667
  };
663
668
  }, {
664
669
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -679,6 +684,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
679
684
  };
680
685
  defaultValue: {
681
686
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
687
+ default: () => never[];
682
688
  };
683
689
  }>> & {
684
690
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -741,10 +747,12 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
741
747
  };
742
748
  defaultValue: {
743
749
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
750
+ default: () => never[];
744
751
  };
745
752
  }>> & {
746
753
  onComfirm?: ((...args: any[]) => any) | undefined;
747
754
  }, {
755
+ defaultValue: import("../../shared/types").AnyObject[];
748
756
  mode: string;
749
757
  title: string;
750
758
  disabledIds: string[];
@@ -1033,6 +1041,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1033
1041
  };
1034
1042
  defaultValue: {
1035
1043
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1044
+ default: () => never[];
1036
1045
  };
1037
1046
  }, {
1038
1047
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -1053,6 +1062,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1053
1062
  };
1054
1063
  defaultValue: {
1055
1064
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1065
+ default: () => never[];
1056
1066
  };
1057
1067
  }>> & {
1058
1068
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -1115,10 +1125,12 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1115
1125
  };
1116
1126
  defaultValue: {
1117
1127
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1128
+ default: () => never[];
1118
1129
  };
1119
1130
  }>> & {
1120
1131
  onComfirm?: ((...args: any[]) => any) | undefined;
1121
1132
  }, {
1133
+ defaultValue: import("../../shared/types").AnyObject[];
1122
1134
  mode: string;
1123
1135
  title: string;
1124
1136
  disabledIds: string[];
@@ -1225,6 +1237,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1225
1237
  };
1226
1238
  defaultValue: {
1227
1239
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1240
+ default: () => never[];
1228
1241
  };
1229
1242
  }, {
1230
1243
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -1245,6 +1258,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1245
1258
  };
1246
1259
  defaultValue: {
1247
1260
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1261
+ default: () => never[];
1248
1262
  };
1249
1263
  }>> & {
1250
1264
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -1307,10 +1321,12 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1307
1321
  };
1308
1322
  defaultValue: {
1309
1323
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1324
+ default: () => never[];
1310
1325
  };
1311
1326
  }>> & {
1312
1327
  onComfirm?: ((...args: any[]) => any) | undefined;
1313
1328
  }, {
1329
+ defaultValue: import("../../shared/types").AnyObject[];
1314
1330
  mode: string;
1315
1331
  title: string;
1316
1332
  disabledIds: string[];
@@ -1448,6 +1464,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1448
1464
  };
1449
1465
  defaultValue: {
1450
1466
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1467
+ default: () => never[];
1451
1468
  };
1452
1469
  }, {
1453
1470
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -1468,6 +1485,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1468
1485
  };
1469
1486
  defaultValue: {
1470
1487
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1488
+ default: () => never[];
1471
1489
  };
1472
1490
  }>> & {
1473
1491
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -1530,10 +1548,12 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
1530
1548
  };
1531
1549
  defaultValue: {
1532
1550
  type: import("vue").PropType<import("../../shared/types").AnyObject[]>;
1551
+ default: () => never[];
1533
1552
  };
1534
1553
  }>> & {
1535
1554
  onComfirm?: ((...args: any[]) => any) | undefined;
1536
1555
  }, {
1556
+ defaultValue: import("../../shared/types").AnyObject[];
1537
1557
  mode: string;
1538
1558
  title: string;
1539
1559
  disabledIds: string[];
@@ -348,6 +348,7 @@ declare const _default: import("vue").DefineComponent<{
348
348
  };
349
349
  defaultValue: {
350
350
  type: PropType<AnyObject[]>;
351
+ default: () => never[];
351
352
  };
352
353
  }, {
353
354
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -368,6 +369,7 @@ declare const _default: import("vue").DefineComponent<{
368
369
  };
369
370
  defaultValue: {
370
371
  type: PropType<AnyObject[]>;
372
+ default: () => never[];
371
373
  };
372
374
  }>> & {
373
375
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -430,10 +432,12 @@ declare const _default: import("vue").DefineComponent<{
430
432
  };
431
433
  defaultValue: {
432
434
  type: PropType<AnyObject[]>;
435
+ default: () => never[];
433
436
  };
434
437
  }>> & {
435
438
  onComfirm?: ((...args: any[]) => any) | undefined;
436
439
  }, {
440
+ defaultValue: AnyObject[];
437
441
  mode: string;
438
442
  title: string;
439
443
  disabledIds: string[];
@@ -664,6 +668,7 @@ declare const _default: import("vue").DefineComponent<{
664
668
  };
665
669
  defaultValue: {
666
670
  type: PropType<AnyObject[]>;
671
+ default: () => never[];
667
672
  };
668
673
  }, {
669
674
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -684,6 +689,7 @@ declare const _default: import("vue").DefineComponent<{
684
689
  };
685
690
  defaultValue: {
686
691
  type: PropType<AnyObject[]>;
692
+ default: () => never[];
687
693
  };
688
694
  }>> & {
689
695
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -746,10 +752,12 @@ declare const _default: import("vue").DefineComponent<{
746
752
  };
747
753
  defaultValue: {
748
754
  type: PropType<AnyObject[]>;
755
+ default: () => never[];
749
756
  };
750
757
  }>> & {
751
758
  onComfirm?: ((...args: any[]) => any) | undefined;
752
759
  }, {
760
+ defaultValue: AnyObject[];
753
761
  mode: string;
754
762
  title: string;
755
763
  disabledIds: string[];
@@ -1038,6 +1046,7 @@ declare const _default: import("vue").DefineComponent<{
1038
1046
  };
1039
1047
  defaultValue: {
1040
1048
  type: PropType<AnyObject[]>;
1049
+ default: () => never[];
1041
1050
  };
1042
1051
  }, {
1043
1052
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -1058,6 +1067,7 @@ declare const _default: import("vue").DefineComponent<{
1058
1067
  };
1059
1068
  defaultValue: {
1060
1069
  type: PropType<AnyObject[]>;
1070
+ default: () => never[];
1061
1071
  };
1062
1072
  }>> & {
1063
1073
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -1120,10 +1130,12 @@ declare const _default: import("vue").DefineComponent<{
1120
1130
  };
1121
1131
  defaultValue: {
1122
1132
  type: PropType<AnyObject[]>;
1133
+ default: () => never[];
1123
1134
  };
1124
1135
  }>> & {
1125
1136
  onComfirm?: ((...args: any[]) => any) | undefined;
1126
1137
  }, {
1138
+ defaultValue: AnyObject[];
1127
1139
  mode: string;
1128
1140
  title: string;
1129
1141
  disabledIds: string[];
@@ -1230,6 +1242,7 @@ declare const _default: import("vue").DefineComponent<{
1230
1242
  };
1231
1243
  defaultValue: {
1232
1244
  type: PropType<AnyObject[]>;
1245
+ default: () => never[];
1233
1246
  };
1234
1247
  }, {
1235
1248
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -1250,6 +1263,7 @@ declare const _default: import("vue").DefineComponent<{
1250
1263
  };
1251
1264
  defaultValue: {
1252
1265
  type: PropType<AnyObject[]>;
1266
+ default: () => never[];
1253
1267
  };
1254
1268
  }>> & {
1255
1269
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -1312,10 +1326,12 @@ declare const _default: import("vue").DefineComponent<{
1312
1326
  };
1313
1327
  defaultValue: {
1314
1328
  type: PropType<AnyObject[]>;
1329
+ default: () => never[];
1315
1330
  };
1316
1331
  }>> & {
1317
1332
  onComfirm?: ((...args: any[]) => any) | undefined;
1318
1333
  }, {
1334
+ defaultValue: AnyObject[];
1319
1335
  mode: string;
1320
1336
  title: string;
1321
1337
  disabledIds: string[];
@@ -1453,6 +1469,7 @@ declare const _default: import("vue").DefineComponent<{
1453
1469
  };
1454
1470
  defaultValue: {
1455
1471
  type: PropType<AnyObject[]>;
1472
+ default: () => never[];
1456
1473
  };
1457
1474
  }, {
1458
1475
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -1473,6 +1490,7 @@ declare const _default: import("vue").DefineComponent<{
1473
1490
  };
1474
1491
  defaultValue: {
1475
1492
  type: PropType<AnyObject[]>;
1493
+ default: () => never[];
1476
1494
  };
1477
1495
  }>> & {
1478
1496
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -1535,10 +1553,12 @@ declare const _default: import("vue").DefineComponent<{
1535
1553
  };
1536
1554
  defaultValue: {
1537
1555
  type: PropType<AnyObject[]>;
1556
+ default: () => never[];
1538
1557
  };
1539
1558
  }>> & {
1540
1559
  onComfirm?: ((...args: any[]) => any) | undefined;
1541
1560
  }, {
1561
+ defaultValue: AnyObject[];
1542
1562
  mode: string;
1543
1563
  title: string;
1544
1564
  disabledIds: string[];
@@ -18,6 +18,7 @@ declare const _default: import("vue").DefineComponent<{
18
18
  };
19
19
  defaultValue: {
20
20
  type: PropType<AnyObject[]>;
21
+ default: () => never[];
21
22
  };
22
23
  }, {
23
24
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -38,6 +39,7 @@ declare const _default: import("vue").DefineComponent<{
38
39
  };
39
40
  defaultValue: {
40
41
  type: PropType<AnyObject[]>;
42
+ default: () => never[];
41
43
  };
42
44
  }>> & {
43
45
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -100,10 +102,12 @@ declare const _default: import("vue").DefineComponent<{
100
102
  };
101
103
  defaultValue: {
102
104
  type: PropType<AnyObject[]>;
105
+ default: () => never[];
103
106
  };
104
107
  }>> & {
105
108
  onComfirm?: ((...args: any[]) => any) | undefined;
106
109
  }, {
110
+ defaultValue: AnyObject[];
107
111
  mode: string;
108
112
  title: string;
109
113
  disabledIds: string[];
@@ -1 +1 @@
1
- import{defineComponent as e,ref as a,computed as l,watch as t,openBlock as i,createElementBlock as o,Fragment as r,createVNode as s,unref as u,withCtx as n,createElementVNode as d,createCommentVNode as v,isRef as c,renderList as p,createBlock as m,toDisplayString as f,createTextVNode as h,renderSlot as b}from"vue";import{NModal as g,NInput as I,NIcon as k,NCheckbox as y,NCheckboxGroup as w,NSpace as _,NAvatar as S,NTag as x,NTooltip as j,NButton as U}from"naive-ui";import{SearchOutline as C,AddOutline as L}from"@vicons/ionicons5";import{useState as A}from"../hooks/useState.js";import{useSession as R}from"../hooks/useSession.js";import{CHAT_TYPE as V}from"../constants/index.js";import"trtc-sdk-v5";import{listSort as E}from"../utils/index.js";import{groupLeaveApi as G,groupJoinApi as N,groupCreateApi as $}from"../api/index.js";import{cloneDeep as M,union as T,unionBy as z,remove as D,isArray as P,uniqBy as q,trim as B}from"lodash-es";import{useSearchUserList as F}from"../hooks/useSearchUserList.js";const H={class:"iho-chat-dialog__content iho-chat-add-wrapper"},J={key:0,class:"input-box"},K=d("span",null,"群名称:",-1),O={class:"transfer-box"},Q={class:"transfer-box__left"},W={class:"user-list-box"},X={key:1,class:"no-data"},Y={class:"transfer-box__right"},Z={class:"checked-tag-box"};var ee=e({__name:"ChatAdd",props:{title:{type:String,default:"添加新成员"},mode:{type:String,default:"select"},options:{type:Array},disabledIds:{type:Array,default:()=>[]},defaultValue:{type:Array}},emits:["comfirm"],setup(e,{emit:ee}){const ae=e,{state:le}=A(),{setCurrentSessionItem:te}=R(le),ie=a(),oe=a(""),re=a(!1),se=a([]),ue=a([]),ne=a(""),de=a([]),{userList:ve,handleInput:ce}=F({wrapperRef:ie,keywordRef:oe,before:()=>{ve.value=M(ue.value),Ie()},after:()=>{ve.value.forEach((e=>{var a;e.disabled=null==(a=pe.value)?void 0:a.includes(e.id)})),Ie()}}),pe=l((()=>T(ae.disabledIds,[le.userInfo.id]))),me=l((()=>{var e,a;return(null==(e=le.sessionList)?void 0:e.length)?null==(a=E(le.sessionList).filter((e=>e.chatType===V.SINGLE)))?void 0:a.map((e=>({id:e.receiver,name:e.name,avatar:e.avatar}))):[]})),fe=l((()=>se.value.length?se.value.map((e=>e.id)):[])),he=l((()=>"create"===ae.mode?fe.value.length<3:fe.value.length<1)),be=l({get:()=>de.value.length===ve.value.filter((e=>!e.disabled)).length,set(e){const a=ve.value.filter((e=>!e.disabled));de.value=e?a.map((e=>e.id)):[],e?se.value=z(se.value,a,"id"):D(se.value,(e=>a.map((e=>e.id)).includes(e.id)))}});async function ge(){switch(ae.mode){case"create":await $({creator:le.userInfo.id,memberIdSet:fe.value,name:B(ne.value),orgId:le.orgId});break;case"join":if(await N({groupId:le.currentSessionItem.receiver,operator:le.userInfo.id,memberIdSet:fe.value}),!le.currentSessionItem.defaultName){const e=se.value.map((e=>e.name)).join(",");te({name:`${le.currentSessionItem.name},${e}`})}le.currentGroupUser.push(...ve.value.filter((e=>fe.value.includes(e.id))));break;case"remove":if(await G({dissolution:!1,groupId:le.currentSessionItem.receiver,operator:le.userInfo.id,memberIdSet:fe.value}),!le.currentSessionItem.defaultName){const e=se.value.map((e=>e.name)).join(","),a=new RegExp(e,"g");te({name:le.currentSessionItem.name.replace(a,"")})}D(le.currentGroupUser,(e=>fe.value.includes(e.id)));break;default:ee("comfirm",fe.value)}re.value=!1}function Ie(){var e,a;de.value=null!=(a=null==(e=ve.value.filter((e=>fe.value.includes(e.id))))?void 0:e.map((e=>e.id)))?a:[]}function ke(e,a){if("check"===a.actionType){const e=ve.value.find((e=>e.id===a.value));se.value.push(e)}else D(se.value,(e=>e.id===a.value))}return t((()=>re.value),(e=>{if(!e)return;oe.value="",ne.value="";const a=P(ae.options)&&ae.options.length?ae.options:me.value;ue.value=q(a,"id").map((e=>{var a;return{...e,disabled:null==(a=pe.value)?void 0:a.includes(e.id)}})),ve.value=M(ue.value),P(ae.defaultValue)&&ae.defaultValue.length?(se.value=M(ae.defaultValue),Ie()):(se.value=[],de.value=[])})),(a,l)=>(i(),o(r,null,[s(u(g),{preset:"dialog",title:e.title,"show-icon":!1,"auto-focus":!1,"trap-focus":!1,class:"iho-chat-dialog",show:re.value,"onUpdate:show":l[4]||(l[4]=e=>re.value=e),"negative-text":"取消","positive-text":"确定","display-directive":"show","positive-button-props":{disabled:u(he)},onPositiveClick:ge},{default:n((()=>[d("div",H,["create"===e.mode?(i(),o("div",J,[K,s(u(I),{clearable:"",placeholder:"取个群名称方便后续搜索",value:ne.value,"onUpdate:value":l[0]||(l[0]=e=>ne.value=e),valueModifiers:{trim:!0}},null,8,["value"])])):v("v-if",!0),d("div",O,[d("div",Q,[s(u(I),{placeholder:"搜索",clearable:"",value:oe.value,"onUpdate:value":[l[1]||(l[1]=e=>oe.value=e),u(ce)],valueModifiers:{trim:!0}},{prefix:n((()=>[s(u(k),{component:u(C)},null,8,["component"])])),_:1},8,["value","onUpdate:value"]),d("div",W,[u(ve).length>0?(i(),o(r,{key:0},[s(u(y),{label:"全选",checked:u(be),"onUpdate:checked":l[2]||(l[2]=e=>c(be)?be.value=e:null)},null,8,["checked"]),s(u(w),{ref_key:"listRef",ref:ie,value:de.value,"onUpdate:value":[l[3]||(l[3]=e=>de.value=e),ke]},{default:n((()=>[(i(!0),o(r,null,p(u(ve),(e=>(i(),m(u(y),{key:e.id,value:e.id,disabled:e.disabled},{default:n((()=>[s(u(_),{align:"center","wrap-item":!1},{default:n((()=>[s(u(S),{src:e.avatar,round:"",size:32},null,8,["src"]),d("span",null,f(e.name),1)])),_:2},1024)])),_:2},1032,["value","disabled"])))),128))])),_:1},8,["value"])],64)):(i(),o("div",X,"找不到相关结果"))])]),d("div",Y,[d("span",null,"已选择 "+f(u(fe).length)+" 人",1),d("div",Z,[(i(!0),o(r,null,p(se.value,(e=>(i(),m(u(x),{key:e.id,bordered:!1,closable:e.id!==u(le).userInfo.id,disabled:u(pe).includes(e.id),onClose:()=>{return a=e.id,D(se.value,(e=>e.id===a)),void D(de.value,(e=>e===a));var a}},{avatar:n((()=>[s(u(S),{round:"",src:e.avatar},null,8,["src"])])),default:n((()=>[h(" "+f(e.name),1)])),_:2},1032,["closable","disabled","onClose"])))),128))])])])])])),_:1},8,["title","show","positive-button-props"]),d("span",{class:"btn-wrapper",onClick:l[5]||(l[5]=e=>re.value=!0)},[b(a.$slots,"trigger",{},(()=>[s(u(j),{"show-arrow":!1,placement:"bottom"},{trigger:n((()=>[s(u(U),{color:"#ffffff4D",class:"add-btn"},{icon:n((()=>[s(u(k),{component:u(L),color:"#fff"},null,8,["component"])])),_:1})])),default:n((()=>[h(" "+f(e.title),1)])),_:1})]))])],64))}});export{ee as default};
1
+ import{defineComponent as e,ref as a,computed as l,watch as t,openBlock as i,createElementBlock as u,Fragment as o,createVNode as r,unref as s,withCtx as n,createElementVNode as d,createCommentVNode as v,isRef as c,renderList as p,createBlock as m,toDisplayString as f,createTextVNode as h,renderSlot as b}from"vue";import{NModal as g,NInput as I,NIcon as k,NCheckbox as y,NCheckboxGroup as w,NSpace as _,NAvatar as S,NTag as x,NTooltip as j,NButton as U}from"naive-ui";import{SearchOutline as C,AddOutline as L}from"@vicons/ionicons5";import{useState as V}from"../hooks/useState.js";import{useSession as A}from"../hooks/useSession.js";import{CHAT_TYPE as R}from"../constants/index.js";import"trtc-sdk-v5";import{listSort as E}from"../utils/index.js";import{groupLeaveApi as G,groupJoinApi as N,groupCreateApi as $}from"../api/index.js";import{cloneDeep as M,union as T,intersection as z,unionBy as D,remove as P,isArray as q,uniqBy as B,trim as F}from"lodash-es";import{useSearchUserList as H}from"../hooks/useSearchUserList.js";const J={class:"iho-chat-dialog__content iho-chat-add-wrapper"},K={key:0,class:"input-box"},O=d("span",null,"群名称:",-1),Q={class:"transfer-box"},W={class:"transfer-box__left"},X={class:"user-list-box"},Y={key:1,class:"no-data"},Z={class:"transfer-box__right"},ee={class:"checked-tag-box"};var ae=e({__name:"ChatAdd",props:{title:{type:String,default:"添加新成员"},mode:{type:String,default:"select"},options:{type:Array},disabledIds:{type:Array,default:()=>[]},defaultValue:{type:Array,default:()=>[]}},emits:["comfirm"],setup(e,{emit:ae}){const le=e,{state:te}=V(),{setCurrentSessionItem:ie}=A(te),ue=a(),oe=a(""),re=a(!1),se=a([]),ne=a([]),de=a(""),ve=a([]),{userList:ce,handleInput:pe}=H({wrapperRef:ue,keywordRef:oe,before:()=>{ce.value=M(ne.value),ke()},after:()=>{ce.value.forEach((e=>{var a;e.disabled=null==(a=me.value)?void 0:a.includes(e.id)})),ke()}}),me=l((()=>T(le.disabledIds,[te.userInfo.id]))),fe=l((()=>{var e,a;return(null==(e=te.sessionList)?void 0:e.length)?null==(a=E(te.sessionList).filter((e=>e.chatType===R.SINGLE)))?void 0:a.map((e=>({id:e.receiver,name:e.name,avatar:e.avatar}))):[]})),he=l((()=>se.value.length?se.value.map((e=>e.id)):[])),be=l((()=>"create"===le.mode?he.value.length<3:he.value.length<1)),ge=l({get:()=>ve.value.filter((e=>!me.value.includes(e))).length===ce.value.filter((e=>!e.disabled)).length,set(e){const a=le.defaultValue.map((e=>e.id)),l=z(a,me.value,ce.value.map((e=>e.id))),t=ce.value.filter((e=>!e.disabled));ve.value=l.concat(e?t.map((e=>e.id)):[]),e?se.value=D(se.value,t,"id"):P(se.value,(e=>t.map((e=>e.id)).includes(e.id)))}});async function Ie(){switch(le.mode){case"create":await $({creator:te.userInfo.id,memberIdSet:he.value,name:F(de.value),orgId:te.orgId});break;case"join":if(await N({groupId:te.currentSessionItem.receiver,operator:te.userInfo.id,memberIdSet:he.value}),!te.currentSessionItem.defaultName){const e=se.value.map((e=>e.name)).join(",");ie({name:`${te.currentSessionItem.name},${e}`})}te.currentGroupUser.push(...ce.value.filter((e=>he.value.includes(e.id))));break;case"remove":if(await G({dissolution:!1,groupId:te.currentSessionItem.receiver,operator:te.userInfo.id,memberIdSet:he.value}),!te.currentSessionItem.defaultName){const e=se.value.map((e=>e.name)).join(","),a=new RegExp(e,"g");ie({name:te.currentSessionItem.name.replace(a,"")})}P(te.currentGroupUser,(e=>he.value.includes(e.id)));break;default:ae("comfirm",he.value)}re.value=!1}function ke(){var e,a;ve.value=null!=(a=null==(e=ce.value.filter((e=>he.value.includes(e.id))))?void 0:e.map((e=>e.id)))?a:[]}function ye(e,a){if("check"===a.actionType){const e=ce.value.find((e=>e.id===a.value));se.value.push(e)}else P(se.value,(e=>e.id===a.value))}return t((()=>re.value),(e=>{if(!e)return;oe.value="",de.value="";const a=q(le.options)&&le.options.length?le.options:fe.value;ne.value=B(a,"id").map((e=>{var a;return{...e,disabled:null==(a=me.value)?void 0:a.includes(e.id)}})),ce.value=M(ne.value),q(le.defaultValue)&&le.defaultValue.length?(se.value=M(le.defaultValue),ke()):(se.value=[],ve.value=[])})),(a,l)=>(i(),u(o,null,[r(s(g),{preset:"dialog",title:e.title,"show-icon":!1,"auto-focus":!1,"trap-focus":!1,class:"iho-chat-dialog",show:re.value,"onUpdate:show":l[4]||(l[4]=e=>re.value=e),"negative-text":"取消","positive-text":"确定","display-directive":"show","positive-button-props":{disabled:s(be)},onPositiveClick:Ie},{default:n((()=>[d("div",J,["create"===e.mode?(i(),u("div",K,[O,r(s(I),{clearable:"",placeholder:"取个群名称方便后续搜索",value:de.value,"onUpdate:value":l[0]||(l[0]=e=>de.value=e),valueModifiers:{trim:!0}},null,8,["value"])])):v("v-if",!0),d("div",Q,[d("div",W,[r(s(I),{placeholder:"搜索",clearable:"",value:oe.value,"onUpdate:value":[l[1]||(l[1]=e=>oe.value=e),s(pe)],valueModifiers:{trim:!0}},{prefix:n((()=>[r(s(k),{component:s(C)},null,8,["component"])])),_:1},8,["value","onUpdate:value"]),d("div",X,[s(ce).length>0?(i(),u(o,{key:0},[r(s(y),{label:"全选",checked:s(ge),"onUpdate:checked":l[2]||(l[2]=e=>c(ge)?ge.value=e:null)},null,8,["checked"]),r(s(w),{ref_key:"listRef",ref:ue,value:ve.value,"onUpdate:value":[l[3]||(l[3]=e=>ve.value=e),ye]},{default:n((()=>[(i(!0),u(o,null,p(s(ce),(e=>(i(),m(s(y),{key:e.id,value:e.id,disabled:e.disabled},{default:n((()=>[r(s(_),{align:"center","wrap-item":!1},{default:n((()=>[r(s(S),{src:e.avatar,round:"",size:32},null,8,["src"]),d("span",null,f(e.name),1)])),_:2},1024)])),_:2},1032,["value","disabled"])))),128))])),_:1},8,["value"])],64)):(i(),u("div",Y,"找不到相关结果"))])]),d("div",Z,[d("span",null,"已选择 "+f(s(he).length)+" 人",1),d("div",ee,[(i(!0),u(o,null,p(se.value,(e=>(i(),m(s(x),{key:e.id,bordered:!1,closable:e.id!==s(te).userInfo.id,disabled:s(me).includes(e.id),onClose:()=>{return a=e.id,P(se.value,(e=>e.id===a)),void P(ve.value,(e=>e===a));var a}},{avatar:n((()=>[r(s(S),{round:"",src:e.avatar},null,8,["src"])])),default:n((()=>[h(" "+f(e.name),1)])),_:2},1032,["closable","disabled","onClose"])))),128))])])])])])),_:1},8,["title","show","positive-button-props"]),d("span",{class:"btn-wrapper",onClick:l[5]||(l[5]=e=>re.value=!0)},[b(a.$slots,"trigger",{},(()=>[r(s(j),{"show-arrow":!1,placement:"bottom"},{trigger:n((()=>[r(s(U),{color:"#ffffff4D",class:"add-btn"},{icon:n((()=>[r(s(k),{component:s(L),color:"#fff"},null,8,["component"])])),_:1})])),default:n((()=>[h(" "+f(e.title),1)])),_:1})]))])],64))}});export{ae as default};
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,computed as a,watch as o,openBlock as s,createBlock as i,unref as r,withCtx as n,withDirectives as l,createElementVNode as c,createVNode as m,createElementBlock as p,Fragment as d,renderList as u,toDisplayString as f,vShow as h,normalizeStyle as y,createCommentVNode as v,createTextVNode as g}from"vue";import{NModal as w,NImageGroup as b,NImage as k,NInput as M,NIcon as T,NTooltip as _}from"naive-ui";import{SearchOutline as I,DownloadOutline as S}from"@vicons/ionicons5";import{searchChatRecordApi as x}from"../api/index.js";import{useTheme as j}from"../../../../shared/hooks/useTheme.js";import{useDebounceFn as A}from"@vueuse/core";import{format as H,isSameWeek as D,isSameMonth as C}from"date-fns";import{last as O}from"lodash-es";import"@vue/shared";import"../../../../shared/utils/index.js";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{useScrollLoading as z}from"../../../../shared/hooks/useScrollLoading.js";import{useState as L}from"../hooks/useState.js";import{getFileSize as U,downloadFile as E}from"../utils/index.js";import"trtc-sdk-v5";const $={class:"label"},F={class:"image-box"},P={class:"file-type"},R={class:"text"},B={class:"name"},G={class:"detail"},N={class:"opt-box"};var q=e({__name:"ChatFile",props:{type:{type:String,default:"image"},visible:{type:Boolean}},setup(e){const q=e,J=j(),{state:K}=L(),Q=t([]),V=t([]),W=t(),X=t(),Y=t(),Z=A(ae,500),ee={page:0,hasMore:!0,lastSendTime:H(new Date,"yyyy-MM-dd HH:mm:ss")};async function te(){var e;try{if(!ee.hasMore)return;ee.page++;const t=await x({orgId:K.orgId,keyword:Y.value,endTime:"",startTime:"",lastSendTime:ee.lastSendTime,memberIdSet:[],page:ee.page,recordType:"image"===q.type?"IMAGE":"FILE",receiver:K.currentSessionItem.receiver,userId:K.userInfo.id});Array.isArray(t)&&0!==t.length&&Array.isArray(t[0].recordList)||(ee.hasMore=!1);let a=t||[];if(Array.isArray(t)&&t.length>0&&(a=t[0].recordList),ee.lastSendTime=null==(e=O(a))?void 0:e.sendTime,"image"===q.type){const e=function(e){const t={};e.forEach((e=>{const a=new Date(e.sendTime);let o=H(a,"yyyy年MM月");D(a,new Date)?o="本周":C(a,new Date)&&(o="本月"),t[o]||(t[o]=[]),t[o].push(e.content.msg)}));return Object.entries(t).map((([e,t])=>({label:e,list:t})))}(a);Q.value=ee.page>1?Q.value.concat(e):e}else{const e=a.map((e=>new Promise((async t=>{const a=await U(e.content.fileUrl);t({...e,size:a})})))),t=await Promise.all(e);V.value=ee.page>1?V.value.concat(t):t}}catch(e){}}function ae(){Object.assign(ee,{page:0,hasMore:!0,lastSendTime:H(new Date,"yyyy-MM-dd HH:mm:ss")}),te()}z(W,(()=>{te()})),z(X,(()=>{te()}));const oe=a((()=>"image"===q.type?"聊天图片":"聊天文件"));function se(e){const{size:t,sendTime:a,senderName:o}=e;return`${t} · ${H(new Date(a),"yyyy/MM/dd HH:mm")} ${o}`}function ie(e){var t;const a=(null==(t=e.content)?void 0:t.msg)||"",o=a.lastIndexOf(".");if(-1!==o){return a.charAt(o+1).toUpperCase()}return"?"}return o((()=>q.visible),(e=>{e?ae():Y.value=""})),(t,a)=>(s(),i(r(w),{preset:"dialog",title:r(oe),"show-icon":!1,"auto-focus":!1,class:"iho-chat-dialog"},{default:n((()=>[l(c("div",{class:"iho-chat-dialog__content iho-chat-image-wrapper",ref_key:"imageRef",ref:W},[m(r(b),{"show-toolbar-tooltip":""},{default:n((()=>[(s(!0),p(d,null,u(Q.value,(e=>(s(),p("div",{class:"image-item",key:e.label},[c("span",$,f(e.label),1),c("div",F,[(s(!0),p(d,null,u(e.list,(e=>(s(),i(r(k),{key:e,width:"80",height:"80",src:e},null,8,["src"])))),128))])])))),128))])),_:1})],512),[[h,"image"===e.type]]),l(c("div",{class:"iho-chat-dialog__content iho-chat-file-wrapper",style:y(r(J))},[m(r(M),{clearable:"",placeholder:"搜索文件",value:Y.value,"onUpdate:value":a[0]||(a[0]=e=>Y.value=e),valueModifiers:{trim:!0},onInput:r(Z)},{prefix:n((()=>[m(r(T),{component:r(I)},null,8,["component"])])),_:1},8,["value","onInput"]),c("div",{class:"file-list-box",ref_key:"fileRef",ref:X},[(s(!0),p(d,null,u(V.value,((e,t)=>(s(),p("div",{class:"file-item",key:t},[c("span",P,f(ie(e)),1),c("div",R,[c("span",B,f(e.content.msg),1),c("span",G,f(se(e)),1)]),c("div",N,[v(' <n-tooltip :show-arrow="false">\r\n\t\t\t\t\t\t\t<template #trigger>\r\n\t\t\t\t\t\t\t\t<n-icon :size="16" :component="OpenOutline" />\r\n\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t转发\r\n\t\t\t\t\t\t</n-tooltip> '),m(r(_),{"show-arrow":!1},{trigger:n((()=>[m(r(T),{size:16,component:r(S),onClick:()=>r(E)(e.content.fileUr,e.content.msg)},null,8,["component","onClick"])])),default:n((()=>[g(" 下载 ")])),_:2},1024)])])))),128))],512)],4),[[h,"image"!==e.type]])])),_:1},8,["title"]))}});export{q as default};
1
+ import{defineComponent as e,ref as t,computed as a,watch as o,openBlock as s,createBlock as i,unref as n,withCtx as r,withDirectives as l,createElementVNode as c,createVNode as m,createElementBlock as p,Fragment as d,renderList as u,toDisplayString as f,vShow as h,normalizeStyle as y,createCommentVNode as v,createTextVNode as g}from"vue";import{NModal as w,NImageGroup as b,NImage as k,NInput as M,NIcon as T,NTooltip as _}from"naive-ui";import{SearchOutline as I,DownloadOutline as S}from"@vicons/ionicons5";import{searchChatRecordApi as x}from"../api/index.js";import{useTheme as j}from"../../../../shared/hooks/useTheme.js";import{useDebounceFn as A}from"@vueuse/core";import{format as H,isSameWeek as D,isSameMonth as C}from"date-fns";import{last as O}from"lodash-es";import"@vue/shared";import"../../../../shared/utils/index.js";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{useScrollLoading as z}from"../../../../shared/hooks/useScrollLoading.js";import{useState as L}from"../hooks/useState.js";import{getFileSize as U,downloadFile as E}from"../utils/index.js";import"trtc-sdk-v5";const $={class:"label"},F={class:"image-box"},P={class:"file-type"},R={class:"text"},B={class:"name"},G={class:"detail"},N={class:"opt-box"};var q=e({__name:"ChatFile",props:{type:{type:String,default:"image"},visible:{type:Boolean}},setup(e){const q=e,J=j(),{state:K}=L(),Q=t([]),V=t([]),W=t(),X=t(),Y=t(),Z=A(ae,500),ee={page:0,hasMore:!0,lastSendTime:H(new Date,"yyyy-MM-dd HH:mm:ss")};async function te(){var e;try{if(!ee.hasMore)return;ee.page++;const t=await x({orgId:K.orgId,keyword:Y.value,endTime:"",startTime:"",lastSendTime:ee.lastSendTime,memberIdSet:[],page:ee.page,recordType:"image"===q.type?"IMAGE":"FILE",receiver:K.currentSessionItem.receiver,userId:K.userInfo.id});Array.isArray(t)&&0!==t.length&&Array.isArray(t[0].recordList)||(ee.hasMore=!1);let a=t||[];if(Array.isArray(t)&&t.length>0&&(a=t[0].recordList),ee.lastSendTime=null==(e=O(a))?void 0:e.sendTime,"image"===q.type){const e=function(e){const t={};e.forEach((e=>{const a=new Date(e.sendTime);let o=H(a,"yyyy年MM月");D(a,new Date)?o="本周":C(a,new Date)&&(o="本月"),t[o]||(t[o]=[]),t[o].push(e.content.msg)}));return Object.entries(t).map((([e,t])=>({label:e,list:t})))}(a);Q.value=ee.page>1?Q.value.concat(e):e}else{const e=a.map((e=>new Promise((async t=>{const a=await U(e.content.fileUrl);t({...e,size:a})})))),t=await Promise.all(e);V.value=ee.page>1?V.value.concat(t):t}}catch(e){}}function ae(){Object.assign(ee,{page:0,hasMore:!0,lastSendTime:H(new Date,"yyyy-MM-dd HH:mm:ss")}),te()}z(W,(()=>{te()})),z(X,(()=>{te()}));const oe=a((()=>"image"===q.type?"聊天图片":"聊天文件"));function se(e){const{size:t,sendTime:a,senderName:o}=e;return`${t} · ${H(new Date(a),"yyyy/MM/dd HH:mm")} ${o}`}function ie(e){var t;const a=(null==(t=e.content)?void 0:t.msg)||"",o=a.lastIndexOf(".");if(-1!==o){return a.charAt(o+1).toUpperCase()}return"?"}return o((()=>q.visible),(e=>{e?ae():Y.value=""})),(t,a)=>(s(),i(n(w),{preset:"dialog",title:n(oe),"show-icon":!1,"auto-focus":!1,class:"iho-chat-dialog"},{default:r((()=>[l(c("div",{class:"iho-chat-dialog__content iho-chat-image-wrapper",ref_key:"imageRef",ref:W},[m(n(b),{"show-toolbar-tooltip":""},{default:r((()=>[(s(!0),p(d,null,u(Q.value,(e=>(s(),p("div",{class:"image-item",key:e.label},[c("span",$,f(e.label),1),c("div",F,[(s(!0),p(d,null,u(e.list,(e=>(s(),i(n(k),{key:e,width:"80",height:"80",src:e},null,8,["src"])))),128))])])))),128))])),_:1})],512),[[h,"image"===e.type]]),l(c("div",{class:"iho-chat-dialog__content iho-chat-file-wrapper",style:y(n(J))},[m(n(M),{clearable:"",placeholder:"搜索文件",value:Y.value,"onUpdate:value":a[0]||(a[0]=e=>Y.value=e),valueModifiers:{trim:!0},onInput:n(Z)},{prefix:r((()=>[m(n(T),{component:n(I)},null,8,["component"])])),_:1},8,["value","onInput"]),c("div",{class:"file-list-box",ref_key:"fileRef",ref:X},[(s(!0),p(d,null,u(V.value,((e,t)=>(s(),p("div",{class:"file-item",key:t},[c("span",P,f(ie(e)),1),c("div",R,[c("span",B,f(e.content.msg),1),c("span",G,f(se(e)),1)]),c("div",N,[v(' <n-tooltip :show-arrow="false">\n\t\t\t\t\t\t\t<template #trigger>\n\t\t\t\t\t\t\t\t<n-icon :size="16" :component="OpenOutline" />\n\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t转发\n\t\t\t\t\t\t</n-tooltip> '),m(n(_),{"show-arrow":!1},{trigger:r((()=>[m(n(T),{size:16,component:n(S),onClick:()=>n(E)(e.content.fileUr,e.content.msg)},null,8,["component","onClick"])])),default:r((()=>[g(" 下载 ")])),_:2},1024)])])))),128))],512)],4),[[h,"image"!==e.type]])])),_:1},8,["title"]))}});export{q as default};
@@ -54,6 +54,7 @@ declare const _default: import("vue").DefineComponent<{}, {
54
54
  };
55
55
  defaultValue: {
56
56
  type: import("vue").PropType<AnyObject[]>;
57
+ default: () => never[];
57
58
  };
58
59
  }, {
59
60
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -74,6 +75,7 @@ declare const _default: import("vue").DefineComponent<{}, {
74
75
  };
75
76
  defaultValue: {
76
77
  type: import("vue").PropType<AnyObject[]>;
78
+ default: () => never[];
77
79
  };
78
80
  }>> & {
79
81
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -136,10 +138,12 @@ declare const _default: import("vue").DefineComponent<{}, {
136
138
  };
137
139
  defaultValue: {
138
140
  type: import("vue").PropType<AnyObject[]>;
141
+ default: () => never[];
139
142
  };
140
143
  }>> & {
141
144
  onComfirm?: ((...args: any[]) => any) | undefined;
142
145
  }, {
146
+ defaultValue: AnyObject[];
143
147
  mode: string;
144
148
  title: string;
145
149
  disabledIds: string[];
@@ -209,6 +209,7 @@ declare const _default: import("vue").DefineComponent<{}, {
209
209
  };
210
210
  defaultValue: {
211
211
  type: import("vue").PropType<AnyObject[]>;
212
+ default: () => never[];
212
213
  };
213
214
  }, {
214
215
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -229,6 +230,7 @@ declare const _default: import("vue").DefineComponent<{}, {
229
230
  };
230
231
  defaultValue: {
231
232
  type: import("vue").PropType<AnyObject[]>;
233
+ default: () => never[];
232
234
  };
233
235
  }>> & {
234
236
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -291,10 +293,12 @@ declare const _default: import("vue").DefineComponent<{}, {
291
293
  };
292
294
  defaultValue: {
293
295
  type: import("vue").PropType<AnyObject[]>;
296
+ default: () => never[];
294
297
  };
295
298
  }>> & {
296
299
  onComfirm?: ((...args: any[]) => any) | undefined;
297
300
  }, {
301
+ defaultValue: AnyObject[];
298
302
  mode: string;
299
303
  title: string;
300
304
  disabledIds: string[];
@@ -525,6 +529,7 @@ declare const _default: import("vue").DefineComponent<{}, {
525
529
  };
526
530
  defaultValue: {
527
531
  type: import("vue").PropType<AnyObject[]>;
532
+ default: () => never[];
528
533
  };
529
534
  }, {
530
535
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -545,6 +550,7 @@ declare const _default: import("vue").DefineComponent<{}, {
545
550
  };
546
551
  defaultValue: {
547
552
  type: import("vue").PropType<AnyObject[]>;
553
+ default: () => never[];
548
554
  };
549
555
  }>> & {
550
556
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -607,10 +613,12 @@ declare const _default: import("vue").DefineComponent<{}, {
607
613
  };
608
614
  defaultValue: {
609
615
  type: import("vue").PropType<AnyObject[]>;
616
+ default: () => never[];
610
617
  };
611
618
  }>> & {
612
619
  onComfirm?: ((...args: any[]) => any) | undefined;
613
620
  }, {
621
+ defaultValue: AnyObject[];
614
622
  mode: string;
615
623
  title: string;
616
624
  disabledIds: string[];
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as r,unref as a,normalizeStyle as c,createVNode as l,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as g,createElementVNode as v,createTextVNode as y,withModifiers as h,nextTick as T}from"vue";import{NImageGroup as M,NButton as k,NAvatar as _,NImage as x,NIcon as I,NSpace as w,NButtonGroup as C,NTooltip as S}from"naive-ui";import{format as E}from"date-fns";import{getHistoryRecordApi as j,readMessageApi as L}from"../api/index.js";import{useState as b}from"../hooks/useState.js";import{useSession as z}from"../hooks/useSession.js";import{MESSAGE_TYPE as A}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as H,simplifyMessage as D,getAVTime as R,downloadFile as N}from"../utils/index.js";import{first as O,last as P}from"lodash-es";import q from"./PersonProfile.vue.js";import B from"./MessageTemplate.vue.js";import{emojis as J}from"../utils/emoji.js";import W from"./ContextMenu.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as U,VideocamOutline as X,DocumentSharp as F,ChatbubbleEllipsesOutline as G,EllipsisHorizontal as K,ArrowDownSharp as Y}from"@vicons/ionicons5";import{useScrollLoading as $}from"../../../../shared/hooks/useScrollLoading.js";const Q={key:0,class:"tip-text"},V={key:1,class:"tip-text"},Z={key:2,class:"message-box"},ee={key:0,class:"content-box"},te={class:"name-box"},ne=["data-time"],se=["onContextmenu"],oe={key:0,class:"reference-content"},ie=["innerHTML"],re=["src"],ae=["innerHTML"],ce=["innerHTML"],le={style:{"margin-left":"8px"}},ue={class:"size"};var me=e({__name:"ChatMain",setup(e){const me=t(),{state:pe,setMsgList:de}=b(),{setCurrentSessionItem:fe,isGroupChat:ge}=z(pe),ve=t(),ye=t(!1),he=t({left:0,top:0}),Te=t(),Me={page:0,hasMore:!0,lastSendTime:E(new Date,"yyyy-MM-dd HH:mm:ss")},ke=n((()=>({"--c-tip-top":ge.value?"1px":"-20px","--c-tip-gap":ge.value?"10px":"0px"})));function _e({nodes:e}){var t,n;const{_ctx:s}=null==(t=e.download)?void 0:t.children,o=s?null==(n=null==s?void 0:s.proxy)?void 0:n.previewSrc:"";return[e.prev,e.next,e.rotateCounterclockwise,e.rotateClockwise,e.resizeToOriginalSize,e.zoomOut,e.zoomIn,l(S,null,{trigger:()=>l(I,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:Y,onClick:()=>o&&N(o,"img")},null),default:()=>"下载"}),e.close]}async function xe(){try{if(!Me.hasMore)return;Me.page++;const e=await j({sessionKey:pe.currentSessionItem.sessionKey,page:Me.page,lastSendTime:Me.lastSendTime});if(!Array.isArray(e)||0===e.length)return Me.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=O(e).id;Me.lastSendTime=P(e).sendTime,de(Me.page>1?[...e,...pe.msgList]:e),1===Me.page&&pe.currentSessionItem.unreadNum&&(await L({chatType:pe.currentSessionItem.chatType,messageIdSet:[t],receiver:pe.userInfo.id,sender:pe.currentSessionItem.receiver}),fe({unreadNum:0}))}catch(e){console.log(e)}}async function Ie(e,t){Te.value=t,async function(e){var t,n,s,o,i,r;ye.value=!0,await T();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=me.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=ve.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,f=null!=(r=null==(i=me.value)?void 0:i.scrollTop)?r:0,g=5,v={};a<=m+l/2?v.left=a-m+g+"px":v.right=m+l-a-g+"px";c-p<d/2?v.top=f+g+"px":p+u-c<=d/2?v.bottom=Math.abs(f)+g+"px":v.top=f+c-p-d/2+"px";he.value=v}(e)}function we(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==A.TEMPLATE||!!n}function Ce(e){const{chatMessageType:t}=e.content;return e.sender===pe.userInfo.id&&Date.now()-new Date(e.sendTime).getTime()<864e5&&[A.TEXT,A.EMOJI].includes(t)}function Se(e){const{chatMessageType:t,msg:n=""}=e.content;if(t===A.BLEND){const e=n.match(/<img[^>]*>/gi);return!e||!e.length}return t&&[A.TEXT,A.EMOJI].includes(t)}function Ee(e){const{chatMessageType:t,msg:n=""}=e.content,s=n.match(/<img[^>]*>/gi);return t===A.BLEND&&s&&s.length}function je(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===A.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function Le(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===A.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function be(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=pe.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function ze(e){pe.currentReferenceMsg=e,pe.currentReferenceMsg.content.referenceContent=null,Object.assign(pe.currentReferenceMsg,{chatType:pe.currentSessionItem.chatType,receiver:pe.currentSessionItem.receiver,receiverAvatar:pe.currentSessionItem.avatar,receiverName:pe.currentSessionItem.name})}function Ae(e,t){"reply"===e&&ze(t)}return $(me,(()=>{xe()}),"top",(()=>{ye.value=!1})),s((()=>pe.id),(e=>{e&&(pe.currentReferenceMsg=null,Object.assign(Me,{page:0,hasMore:!0,lastSendTime:E(new Date,"yyyy-MM-dd HH:mm:ss")}),xe())}),{immediate:!0}),s((()=>pe.isAppendMsg),(e=>{e&&(de([...pe.msgList,pe.currentMsg]),async function(){var e,t,n;await T();const s=null!=(t=null==(e=me.value)?void 0:e.scrollHeight)?t:0;null==(n=me.value)||n.scrollTo({top:s,behavior:"auto"})}(),pe.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(pe).id}]),ref_key:"chatMainRef",ref:me,style:c(a(ke))},[l(a(M),{"show-toolbar-tooltip":"","render-toolbar":_e},{default:u((()=>[(o(!0),i(m,null,p(a(pe).msgList,((e,t)=>(o(),i(m,{key:e.id},[we(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(pe).userInfo.id}])},[be(e,t)?(o(),i("p",Q,d(e.__sendTime),1)):f("v-if",!0),je(e,"system")||"WITHDRAWN"===e.status?(o(),i(m,{key:1},[je(e,"system")?(o(),g(B,{key:0,data:e},null,8,["data"])):f("v-if",!0),"WITHDRAWN"===e.status?(o(),i("p",V,[v("span",null,d(e.sender==a(pe).userInfo.id?"你":e.senderName)+"撤回了一条消息",1),Ce(e)?(o(),g(a(k),{key:0,size:"tiny",style:{color:"var(--c-primary-color)","margin-left":"5px"},text:"",onClick:()=>function(e){pe.currentReEditMsg=e}(e)},{default:u((()=>[y(" 重新编辑 ")])),_:2},1032,["onClick"])):f("v-if",!0)])):f("v-if",!0)],64)):(o(),i("div",Z,[l(q,{"user-id":e.sender,placement:e.sender==a(pe).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(_),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",ee,[v("div",te,[v("span",{class:"name","data-time":e.__time},d(a(ge)?e.senderName:""),9,ne)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(A).EMOJI,template:e.content.chatMessageType===a(A).TEMPLATE,"template--3":Le(e.content),"audio-video":a(H)(e.content),file:e.content.chatMessageType===a(A).FILE}]),onContextmenu:h((t=>Ie(t,e.id)),["prevent"])},[Se(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",oe,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(D)(e.content.referenceContent.content)},null,8,ie)])):f("v-if",!0),e.content.chatMessageType===a(A).EMOJI?(o(),i("img",{key:1,class:r([e.content.referenceContent?"emoji--min":"emoji--big"]),src:a(J).findEmoji(e.__content)},null,10,re)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,ae))],64)):f("v-if",!0),Ee(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,ce)):f("v-if",!0),je(e,"template")?(o(),g(B,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===a(A).IMAGE?(o(),g(a(x),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),a(H)(e.content)?(o(),i(m,{key:4},[l(a(I),{class:r({"is-audio":e.content.chatMessageType===a(A).AUDIO}),component:e.content.chatMessageType===a(A).AUDIO?a(U):a(X)},null,8,["class","component"]),v("span",le,d(a(R)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===a(A).FILE?(o(),g(a(w),{key:5,"wrap-item":!1},{default:u((()=>[l(a(I),{class:"icon-file",size:"40",component:a(F)},null,8,["component"]),l(a(w),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",ue,d(e.__size),1)])),_:2},1024)])),_:2},1024)):f("v-if",!0),l(a(C),{class:"quick-menu"},{default:u((()=>[a(H)(e.content)?f("v-if",!0):(o(),i(m,{key:0},[f(' <n-button quaternary size="tiny">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\r\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t\t\t\t</n-button> '),l(a(k),{quaternary:"",size:"tiny",onClick:()=>ze(e)},{icon:u((()=>[l(a(I),{size:"17",component:a(G)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(k),{quaternary:"",size:"tiny",onClick:t=>Ie(t,e.id)},{icon:u((()=>[l(a(I),{size:"14",component:a(K)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,se)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(a(W),{ref_key:"contextmenuRef",ref:ve,show:ye.value,"onUpdate:show":t[0]||(t[0]=e=>ye.value=e),position:he.value,"msg-id":Te.value,onSelect:Ae},null,8,["show","position","msg-id"])],6))}});export{me as default};
1
+ import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as r,unref as a,normalizeStyle as c,createVNode as l,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as g,createElementVNode as v,createTextVNode as y,withModifiers as h,nextTick as T}from"vue";import{NImageGroup as M,NButton as k,NAvatar as _,NImage as x,NIcon as I,NSpace as w,NButtonGroup as C,NTooltip as S}from"naive-ui";import{format as E}from"date-fns";import{getHistoryRecordApi as j,readMessageApi as L}from"../api/index.js";import{useState as b}from"../hooks/useState.js";import{useSession as z}from"../hooks/useSession.js";import{MESSAGE_TYPE as A}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as H,simplifyMessage as D,getAVTime as R,downloadFile as N}from"../utils/index.js";import{first as O,last as P}from"lodash-es";import q from"./PersonProfile.vue.js";import B from"./MessageTemplate.vue.js";import{emojis as J}from"../utils/emoji.js";import W from"./ContextMenu.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as U,VideocamOutline as X,DocumentSharp as F,ChatbubbleEllipsesOutline as G,EllipsisHorizontal as K,ArrowDownSharp as Y}from"@vicons/ionicons5";import{useScrollLoading as $}from"../../../../shared/hooks/useScrollLoading.js";const Q={key:0,class:"tip-text"},V={key:1,class:"tip-text"},Z={key:2,class:"message-box"},ee={key:0,class:"content-box"},te={class:"name-box"},ne=["data-time"],se=["onContextmenu"],oe={key:0,class:"reference-content"},ie=["innerHTML"],re=["src"],ae=["innerHTML"],ce=["innerHTML"],le={style:{"margin-left":"8px"}},ue={class:"size"};var me=e({__name:"ChatMain",setup(e){const me=t(),{state:pe,setMsgList:de}=b(),{setCurrentSessionItem:fe,isGroupChat:ge}=z(pe),ve=t(),ye=t(!1),he=t({left:0,top:0}),Te=t(),Me={page:0,hasMore:!0,lastSendTime:E(new Date,"yyyy-MM-dd HH:mm:ss")},ke=n((()=>({"--c-tip-top":ge.value?"1px":"-20px","--c-tip-gap":ge.value?"10px":"0px"})));function _e({nodes:e}){var t,n;const{_ctx:s}=null==(t=e.download)?void 0:t.children,o=s?null==(n=null==s?void 0:s.proxy)?void 0:n.previewSrc:"";return[e.prev,e.next,e.rotateCounterclockwise,e.rotateClockwise,e.resizeToOriginalSize,e.zoomOut,e.zoomIn,l(S,null,{trigger:()=>l(I,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:Y,onClick:()=>o&&N(o,"img")},null),default:()=>"下载"}),e.close]}async function xe(){try{if(!Me.hasMore)return;Me.page++;const e=await j({sessionKey:pe.currentSessionItem.sessionKey,page:Me.page,lastSendTime:Me.lastSendTime});if(!Array.isArray(e)||0===e.length)return Me.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=O(e).id;Me.lastSendTime=P(e).sendTime,de(Me.page>1?[...e,...pe.msgList]:e),1===Me.page&&pe.currentSessionItem.unreadNum&&(await L({chatType:pe.currentSessionItem.chatType,messageIdSet:[t],receiver:pe.userInfo.id,sender:pe.currentSessionItem.receiver}),fe({unreadNum:0}))}catch(e){console.log(e)}}async function Ie(e,t){Te.value=t,async function(e){var t,n,s,o,i,r;ye.value=!0,await T();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=me.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=ve.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,f=null!=(r=null==(i=me.value)?void 0:i.scrollTop)?r:0,g=5,v={};a<=m+l/2?v.left=a-m+g+"px":v.right=m+l-a-g+"px";c-p<d/2?v.top=f+g+"px":p+u-c<=d/2?v.bottom=Math.abs(f)+g+"px":v.top=f+c-p-d/2+"px";he.value=v}(e)}function we(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==A.TEMPLATE||!!n}function Ce(e){const{chatMessageType:t}=e.content;return e.sender===pe.userInfo.id&&Date.now()-new Date(e.sendTime).getTime()<864e5&&[A.TEXT,A.EMOJI].includes(t)}function Se(e){const{chatMessageType:t,msg:n=""}=e.content;if(t===A.BLEND){const e=n.match(/<img[^>]*>/gi);return!e||!e.length}return t&&[A.TEXT,A.EMOJI].includes(t)}function Ee(e){const{chatMessageType:t,msg:n=""}=e.content,s=n.match(/<img[^>]*>/gi);return t===A.BLEND&&s&&s.length}function je(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===A.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function Le(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===A.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function be(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=pe.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function ze(e){pe.currentReferenceMsg=e,pe.currentReferenceMsg.content.referenceContent=null,Object.assign(pe.currentReferenceMsg,{chatType:pe.currentSessionItem.chatType,receiver:pe.currentSessionItem.receiver,receiverAvatar:pe.currentSessionItem.avatar,receiverName:pe.currentSessionItem.name})}function Ae(e,t){"reply"===e&&ze(t)}return $(me,(()=>{xe()}),"top",(()=>{ye.value=!1})),s((()=>pe.id),(e=>{e&&(pe.currentReferenceMsg=null,Object.assign(Me,{page:0,hasMore:!0,lastSendTime:E(new Date,"yyyy-MM-dd HH:mm:ss")}),xe())}),{immediate:!0}),s((()=>pe.isAppendMsg),(e=>{e&&(de([...pe.msgList,pe.currentMsg]),async function(){var e,t,n;await T();const s=null!=(t=null==(e=me.value)?void 0:e.scrollHeight)?t:0;null==(n=me.value)||n.scrollTo({top:s,behavior:"auto"})}(),pe.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(pe).id}]),ref_key:"chatMainRef",ref:me,style:c(a(ke))},[l(a(M),{"show-toolbar-tooltip":"","render-toolbar":_e},{default:u((()=>[(o(!0),i(m,null,p(a(pe).msgList,((e,t)=>(o(),i(m,{key:e.id},[we(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(pe).userInfo.id}])},[be(e,t)?(o(),i("p",Q,d(e.__sendTime),1)):f("v-if",!0),je(e,"system")||"WITHDRAWN"===e.status?(o(),i(m,{key:1},[je(e,"system")?(o(),g(B,{key:0,data:e},null,8,["data"])):f("v-if",!0),"WITHDRAWN"===e.status?(o(),i("p",V,[v("span",null,d(e.sender==a(pe).userInfo.id?"你":e.senderName)+"撤回了一条消息",1),Ce(e)?(o(),g(a(k),{key:0,size:"tiny",style:{color:"var(--c-primary-color)","margin-left":"5px"},text:"",onClick:()=>function(e){pe.currentReEditMsg=e}(e)},{default:u((()=>[y(" 重新编辑 ")])),_:2},1032,["onClick"])):f("v-if",!0)])):f("v-if",!0)],64)):(o(),i("div",Z,[l(q,{"user-id":e.sender,placement:e.sender==a(pe).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(_),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",ee,[v("div",te,[v("span",{class:"name","data-time":e.__time},d(a(ge)?e.senderName:""),9,ne)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(A).EMOJI,template:e.content.chatMessageType===a(A).TEMPLATE,"template--3":Le(e.content),"audio-video":a(H)(e.content),file:e.content.chatMessageType===a(A).FILE}]),onContextmenu:h((t=>Ie(t,e.id)),["prevent"])},[Se(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",oe,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(D)(e.content.referenceContent.content)},null,8,ie)])):f("v-if",!0),e.content.chatMessageType===a(A).EMOJI?(o(),i("img",{key:1,class:r([e.content.referenceContent?"emoji--min":"emoji--big"]),src:a(J).findEmoji(e.__content)},null,10,re)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,ae))],64)):f("v-if",!0),Ee(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,ce)):f("v-if",!0),je(e,"template")?(o(),g(B,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===a(A).IMAGE?(o(),g(a(x),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),a(H)(e.content)?(o(),i(m,{key:4},[l(a(I),{class:r({"is-audio":e.content.chatMessageType===a(A).AUDIO}),component:e.content.chatMessageType===a(A).AUDIO?a(U):a(X)},null,8,["class","component"]),v("span",le,d(a(R)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===a(A).FILE?(o(),g(a(w),{key:5,"wrap-item":!1},{default:u((()=>[l(a(I),{class:"icon-file",size:"40",component:a(F)},null,8,["component"]),l(a(w),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",ue,d(e.__size),1)])),_:2},1024)])),_:2},1024)):f("v-if",!0),l(a(C),{class:"quick-menu"},{default:u((()=>[a(H)(e.content)?f("v-if",!0):(o(),i(m,{key:0},[f(' <n-button quaternary size="tiny">\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t\t\t\t</n-button> '),l(a(k),{quaternary:"",size:"tiny",onClick:()=>ze(e)},{icon:u((()=>[l(a(I),{size:"17",component:a(G)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(k),{quaternary:"",size:"tiny",onClick:t=>Ie(t,e.id)},{icon:u((()=>[l(a(I),{size:"14",component:a(K)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,se)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(a(W),{ref_key:"contextmenuRef",ref:ve,show:ye.value,"onUpdate:show":t[0]||(t[0]=e=>ye.value=e),position:he.value,"msg-id":Te.value,onSelect:Ae},null,8,["show","position","msg-id"])],6))}});export{me as default};
@@ -122,6 +122,7 @@ declare const _default: import("vue").DefineComponent<{}, {
122
122
  };
123
123
  defaultValue: {
124
124
  type: import("vue").PropType<AnyObject[]>;
125
+ default: () => never[];
125
126
  };
126
127
  }, {
127
128
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -142,6 +143,7 @@ declare const _default: import("vue").DefineComponent<{}, {
142
143
  };
143
144
  defaultValue: {
144
145
  type: import("vue").PropType<AnyObject[]>;
146
+ default: () => never[];
145
147
  };
146
148
  }>> & {
147
149
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -204,10 +206,12 @@ declare const _default: import("vue").DefineComponent<{}, {
204
206
  };
205
207
  defaultValue: {
206
208
  type: import("vue").PropType<AnyObject[]>;
209
+ default: () => never[];
207
210
  };
208
211
  }>> & {
209
212
  onComfirm?: ((...args: any[]) => any) | undefined;
210
213
  }, {
214
+ defaultValue: AnyObject[];
211
215
  mode: string;
212
216
  title: string;
213
217
  disabledIds: string[];
@@ -70,6 +70,7 @@ declare const _default: import("vue").DefineComponent<{}, {
70
70
  };
71
71
  defaultValue: {
72
72
  type: import("vue").PropType<AnyObject[]>;
73
+ default: () => never[];
73
74
  };
74
75
  }, {
75
76
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
@@ -90,6 +91,7 @@ declare const _default: import("vue").DefineComponent<{}, {
90
91
  };
91
92
  defaultValue: {
92
93
  type: import("vue").PropType<AnyObject[]>;
94
+ default: () => never[];
93
95
  };
94
96
  }>> & {
95
97
  onComfirm?: ((...args: any[]) => any) | undefined;
@@ -152,10 +154,12 @@ declare const _default: import("vue").DefineComponent<{}, {
152
154
  };
153
155
  defaultValue: {
154
156
  type: import("vue").PropType<AnyObject[]>;
157
+ default: () => never[];
155
158
  };
156
159
  }>> & {
157
160
  onComfirm?: ((...args: any[]) => any) | undefined;
158
161
  }, {
162
+ defaultValue: AnyObject[];
159
163
  mode: string;
160
164
  title: string;
161
165
  disabledIds: string[];
@@ -1 +1 @@
1
- import{defineComponent as t,ref as e,reactive as a,computed as l,openBlock as n,createBlock as o,unref as r,withCtx as s,renderSlot as i,createElementBlock as c,Fragment as u,withDirectives as d,createElementVNode as p,createVNode as m,createCommentVNode as v,toDisplayString as f,createTextVNode as g,renderList as y,vShow as k}from"vue";import{NPopover as h,NAvatar as b,NButton as w,NIcon as C}from"naive-ui";import{ChatbubbleEllipses as _,EyeOffOutline as j,EyeOutline as I,Close as z}from"@vicons/ionicons5";import{useState as x}from"../hooks/useState.js";import{useSession as N}from"../hooks/useSession.js";import"trtc-sdk-v5";import"date-fns";import"lodash-es";import"../utils/emoji.js";import"../../../../shared/utils/index.js";import{openSessionApi as S,getUserDetailApi as $}from"../api/index.js";const D={class:"person-profile-main"},P={class:"left"},T={class:"profile"},q={class:"profile__text"},B={class:"right"},E={class:"right__content"},O={class:"label"},U={class:"content"};var A=t({__name:"PersonProfile",props:{userId:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:A}){const F=t,{state:G}=x(),{openSession:H}=N(G),J=e(!1),K=e(!1),L=e(!1),M=a({}),Q=[{label:"机构",value:"",key:"orgName"},{label:"姓名",value:"",key:"name"},{label:"归属科室",value:"",key:"deptName"},{label:"业务科室",value:"",key:"businessDeptNames"},{label:"手机号",value:"",key:"phone"},{label:"岗位",value:"",key:"post"},{label:"工号",value:"",key:"jobId"},{label:"性别",value:"",key:"orgName"}],R=l((()=>(M.id&&Q.forEach((t=>{const{key:e}=t;t.value=M[e]})),Q)));async function V(){J.value=!1;const t=await S({chatType:G.currentSessionItem.chatType,receiver:F.userId,sender:G.userInfo.id});H(t),A("close")}async function W(t){if(!t)return;const e=await $({userId:F.userId});(null==e?void 0:e.id)?Object.assign(M,e):M.id=""}function X(t){const{key:e,value:a}=t;return"phone"!==e||L.value?a:(a||"").replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}return(e,a)=>(n(),o(r(h),{raw:"",class:"person-profile-wrapper",show:J.value,"onUpdate:show":[a[3]||(a[3]=t=>J.value=t),W],trigger:t.disabled?"manual":"click","show-arrow":!1,to:"body",shift:""},{trigger:s((()=>[i(e.$slots,"trigger")])),default:s((()=>[M.id?(n(),c(u,{key:0},[d(p("div",D,[p("div",P,[p("div",T,[m(r(b),{src:M.avatar,bordered:"",round:"",size:100,onClickCapture:a[0]||(a[0]=t=>K.value=!0)},null,8,["src"]),v(' <n-upload abstract accept="image/*" @change="onChange">\r\n\t\t\t\t\t\t\t<n-upload-trigger #="{ handleClick }" abstract>\r\n\t\t\t\t\t\t\t\t<n-button\r\n\t\t\t\t\t\t\t\t\tcircle\r\n\t\t\t\t\t\t\t\t\tsecondary\r\n\t\t\t\t\t\t\t\t\tclass="edit-avatar"\r\n\t\t\t\t\t\t\t\t\tv-show="userDetail.id === state.userInfo.id"\r\n\t\t\t\t\t\t\t\t\t@click="handleClick"\r\n\t\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t<n-icon size="16" color="#666666" :component="Camera" />\r\n\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t</n-button>\r\n\t\t\t\t\t\t\t</n-upload-trigger>\r\n\t\t\t\t\t\t</n-upload> '),p("div",q,[p("h4",null,f(M.name),1),p("p",null,f(M.orgName),1)]),m(r(w),{strong:"",secondary:"",onClick:V},{default:s((()=>[m(r(C),{size:"13",color:"#666666",component:r(_),style:{"margin-right":"6px"}},null,8,["component"]),g(" 发消息 ")])),_:1})])]),p("div",B,[p("div",E,[(n(!0),c(u,null,y(r(R),((t,e)=>(n(),c("div",{class:"info-item",key:e},[p("span",O,f(t.label),1),p("div",U,[p("span",null,f(X(t)),1),"phone"===t.key&&X(t)?(n(),o(r(C),{key:0,size:"16",color:"#666666",component:L.value?r(j):r(I),style:{"margin-left":"10px"},onClick:a[1]||(a[1]=t=>L.value=!L.value)},null,8,["component"])):v("v-if",!0)])])))),128))])])],512),[[k,!K.value]]),d(p("div",{class:"large-avatar",onClick:a[2]||(a[2]=t=>K.value=!1)},[m(r(w),{circle:"",size:"small",secondary:""},{icon:s((()=>[m(r(C),{size:24,component:r(z),color:"#fff"},null,8,["component"])])),_:1}),m(r(b),{size:310,round:"",src:M.avatar},null,8,["src"])],512),[[k,K.value]])],64)):v("v-if",!0)])),_:3},8,["show","trigger"]))}});export{A as default};
1
+ import{defineComponent as t,ref as e,reactive as a,computed as l,openBlock as n,createBlock as o,unref as s,withCtx as r,renderSlot as i,createElementBlock as c,Fragment as u,withDirectives as d,createElementVNode as p,createVNode as m,createCommentVNode as v,toDisplayString as f,createTextVNode as g,renderList as y,vShow as k}from"vue";import{NPopover as h,NAvatar as b,NButton as w,NIcon as C}from"naive-ui";import{ChatbubbleEllipses as _,EyeOffOutline as j,EyeOutline as I,Close as z}from"@vicons/ionicons5";import{useState as x}from"../hooks/useState.js";import{useSession as N}from"../hooks/useSession.js";import"trtc-sdk-v5";import"date-fns";import"lodash-es";import"../utils/emoji.js";import"../../../../shared/utils/index.js";import{openSessionApi as S,getUserDetailApi as $}from"../api/index.js";const D={class:"person-profile-main"},P={class:"left"},T={class:"profile"},q={class:"profile__text"},B={class:"right"},E={class:"right__content"},O={class:"label"},U={class:"content"};var A=t({__name:"PersonProfile",props:{userId:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:A}){const F=t,{state:G}=x(),{openSession:H}=N(G),J=e(!1),K=e(!1),L=e(!1),M=a({}),Q=[{label:"机构",value:"",key:"orgName"},{label:"姓名",value:"",key:"name"},{label:"归属科室",value:"",key:"deptName"},{label:"业务科室",value:"",key:"businessDeptNames"},{label:"手机号",value:"",key:"phone"},{label:"岗位",value:"",key:"post"},{label:"工号",value:"",key:"jobId"},{label:"性别",value:"",key:"orgName"}],R=l((()=>(M.id&&Q.forEach((t=>{const{key:e}=t;t.value=M[e]})),Q)));async function V(){J.value=!1;const t=await S({chatType:G.currentSessionItem.chatType,receiver:F.userId,sender:G.userInfo.id});H(t),A("close")}async function W(t){if(!t)return;const e=await $({userId:F.userId});(null==e?void 0:e.id)?Object.assign(M,e):M.id=""}function X(t){const{key:e,value:a}=t;return"phone"!==e||L.value?a:(a||"").replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}return(e,a)=>(n(),o(s(h),{raw:"",class:"person-profile-wrapper",show:J.value,"onUpdate:show":[a[3]||(a[3]=t=>J.value=t),W],trigger:t.disabled?"manual":"click","show-arrow":!1,to:"body",shift:""},{trigger:r((()=>[i(e.$slots,"trigger")])),default:r((()=>[M.id?(n(),c(u,{key:0},[d(p("div",D,[p("div",P,[p("div",T,[m(s(b),{src:M.avatar,bordered:"",round:"",size:100,onClickCapture:a[0]||(a[0]=t=>K.value=!0)},null,8,["src"]),v(' <n-upload abstract accept="image/*" @change="onChange">\n\t\t\t\t\t\t\t<n-upload-trigger #="{ handleClick }" abstract>\n\t\t\t\t\t\t\t\t<n-button\n\t\t\t\t\t\t\t\t\tcircle\n\t\t\t\t\t\t\t\t\tsecondary\n\t\t\t\t\t\t\t\t\tclass="edit-avatar"\n\t\t\t\t\t\t\t\t\tv-show="userDetail.id === state.userInfo.id"\n\t\t\t\t\t\t\t\t\t@click="handleClick"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t<n-icon size="16" color="#666666" :component="Camera" />\n\t\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t</n-button>\n\t\t\t\t\t\t\t</n-upload-trigger>\n\t\t\t\t\t\t</n-upload> '),p("div",q,[p("h4",null,f(M.name),1),p("p",null,f(M.orgName),1)]),m(s(w),{strong:"",secondary:"",onClick:V},{default:r((()=>[m(s(C),{size:"13",color:"#666666",component:s(_),style:{"margin-right":"6px"}},null,8,["component"]),g(" 发消息 ")])),_:1})])]),p("div",B,[p("div",E,[(n(!0),c(u,null,y(s(R),((t,e)=>(n(),c("div",{class:"info-item",key:e},[p("span",O,f(t.label),1),p("div",U,[p("span",null,f(X(t)),1),"phone"===t.key&&X(t)?(n(),o(s(C),{key:0,size:"16",color:"#666666",component:L.value?s(j):s(I),style:{"margin-left":"10px"},onClick:a[1]||(a[1]=t=>L.value=!L.value)},null,8,["component"])):v("v-if",!0)])])))),128))])])],512),[[k,!K.value]]),d(p("div",{class:"large-avatar",onClick:a[2]||(a[2]=t=>K.value=!1)},[m(s(w),{circle:"",size:"small",secondary:""},{icon:r((()=>[m(s(C),{size:24,component:s(z),color:"#fff"},null,8,["component"])])),_:1}),m(s(b),{size:310,round:"",src:M.avatar},null,8,["src"])],512),[[k,K.value]])],64)):v("v-if",!0)])),_:3},8,["show","trigger"]))}});export{A as default};
@@ -1 +1 @@
1
- import{defineComponent as e,reactive as o,ref as t,watch as a,nextTick as n,openBlock as s,createElementBlock as i,normalizeClass as l,unref as r,createCommentVNode as m,Fragment as c,createBlock as u,mergeProps as d,createElementVNode as p,normalizeStyle as f,createVNode as v,withCtx as g,renderList as h,toDisplayString as k,createTextVNode as y,resolveDynamicComponent as w,renderSlot as S}from"vue";import b from"./hooks/use-noData.js";import{ScaleViewProps as C}from"./hooks/scaleview-props.js";import{getScaleViewState as D}from"./hooks/scaleview-state.js";import{ScaleViewComputed as E}from"./hooks/scaleview-computed.js";import{ScaleViewInit as j}from"./hooks/scaleview-init.js";import{ScaleViewSubmit as _}from"./hooks/scaleview-submit.js";import{ScaleViewMethods as x}from"./hooks/scaleview-methods.js";import{handleQueryParams as F,isCollection as P}from"./utils/judge-types.js";import{useEvent as q}from"./hooks/use-event.js";import"xe-utils";import"moment";import L from"../../../shared/utils/vexutilsExpand.js";import N from"./components/NoData.vue.js";import R from"./components/EvaluateCountdown.vue.js";import A from"./components/EvaluatePage.vue.js";import M from"./components/AnswerParse.vue.js";import O from"./components/ScaleScore.js";import T from"./components/DescribeContent.vue.js";import{NForm as V,NFormItem as I,NButton as B}from"naive-ui";const J=["innerHTML"],G={key:0,class:"required-text"},W={key:1,class:"evalute-label"},H=["onClick"],Q=p("i",{class:"scale-view-iconfont icon-scale-view-dengpao"},null,-1),$={key:1,class:"footer"};var z=e({__name:"ScaleView",props:C,emits:["onCloseSetting","submitNoRequest","onSubmit","startWriteScale"],setup(e,{expose:C,emit:z}){const K=e,{ScaleViewState:U}=D(),X=o(U),Y=t(null),Z=t(null),ee=t(null),{noDataState:oe,setNoData:te,resetNodata:ae}=b(),ne=F(),{showEvatip:se,isFormBoldOpen:ie,scaleStyle:le,handlePageClass:re,isShowItem:me,handleShowQuestionNumber:ce,hasScore:ue,isPreviewScale:de,showEvaluateEntry:pe,showEvaluateCoundownPage:fe,showScaleFooter:ve,isCancelBtn:ge,isSaveBtn:he,showEvaluateLabel:ke,showAnswerParse:ye,propsConfig:we,evaluatePageProps:Se,evaluateCountdownProps:be,isEvaluetaResSituation:Ce,disableEdit:De,desStart:Ee,desEnd:je,desContent:_e}=E(K,X,{query:ne,scaleViewDom:Y}),{initForm:xe}=j(K,X,z,{query:ne}),{submitMethod:Fe,onSubmitData:Pe,onSubmitForm:qe,handleScoreJson:Le}=_(K,X,z,{query:ne,formRef:ee,countdownDom:Z}),{nextLogicEvent:Ne,handleDynamicDataRelation:Re}=q(K,X),{scaleChange:Ae,labelChange:Me,vodFileList:Oe,writeGuage:Te,closeEvaluateCountdown:Ve,showEvaTipModal:Ie}=x(K,X,z,{nextLogicEvent:Ne,handleDynamicDataRelation:Re,isPreviewScale:de,submitMethod:Fe,isEvaluetaResSituation:Ce,handleScoreJson:Le,disableEdit:De});(()=>{let{id:e}=ne;e&&(X.shareId=e)})();const Be=e=>{try{ae(),xe(e)}catch(e){console.log(e,"--error"),X.spinning=!1,X.hasFrontAddress=!1,te(!0,null==e?void 0:e.resultMsg,null==e?void 0:e.result)}};a((()=>K.ids),((e,o)=>{o?e.guage_id&&e.guage_id!=o.guage_id&&Be(e):e.guage_id&&Be(e)}),{immediate:!0}),a((()=>K.guageData),(e=>{if(!e||!Object.keys(e||{}).length)return;X.form={},X.formArray=[];const o=JSON.parse(JSON.stringify(e));n((()=>{xe(o)}))}),{immediate:!0});const Je=L.debounce(Pe,300),Ge=()=>{z("onCloseSetting")};return C({getScaleData:()=>({...X}),onSubmitForm:qe,cancel:Ge}),(e,o)=>(s(),i("div",{class:l(["c-scale-view-block",{"c-scale-view-block-hasfooter":r(ve)}]),ref_key:"scaleViewDom",ref:Y},[m(' <template v-if="state.spinning">\r\n <n-spin :show="state.spinning" description="加载中"></n-spin>\r\n </template> '),X.spinning||X.hasFrontAddress?m("v-if",!0):(s(),i(c,{key:0},[r(oe).noData?(s(),u(N,{key:0,noDataImg:r(oe).noDataImg,noDataTip:r(oe).noDataTip},null,8,["noDataImg","noDataTip"])):(s(),i(c,{key:1},[r(pe)?(s(),u(A,d({key:0},r(Se),{onWriteGuage:r(Te)}),null,16,["onWriteGuage"])):(s(),i(c,{key:1},[r(fe)?(s(),u(R,d({key:0,ref_key:"countdownDom",ref:Z},r(be),{onCloseEvaluateCountdown:r(Ve)}),null,16,["onCloseEvaluateCountdown"])):m("v-if",!0),p("div",{class:l(["scale-container",{"scale-container-nopadding":r(re),"scale-container-hasfooter":r(ve)}]),style:f(r(le))},[r(ue)?(s(),u(r(O),{key:0,config:X.config,maxScore:X.maxScore},null,8,["config","maxScore"])):m("v-if",!0),r(Ee)?(s(),u(T,{key:1,content:r(_e)},null,8,["content"])):m("v-if",!0),v(r(V),{ref_key:"formRef",ref:ee,model:X.form,rules:X.rules,"require-mark-placement":"left",class:"main"},{default:g((()=>[(s(!0),i(c,null,h(X.formArray,((e,o)=>(s(),i(c,{key:(e.id||e.seq)+o},[r(me)(e)?(s(),u(r(I),{key:0,path:e.val_key,"show-label":!r(P)(e.type),class:"c-scle-form-item"},{label:g((()=>[p("span",{class:l({"scale-label-required":r(ie)(e)}),innerHTML:r(ce)(e)},null,10,J),r(ie)(e)?(s(),i("span",G,"(必填)")):m("v-if",!0),r(ke)(e)?(s(),i("span",W,k(r(ke)(e)),1)):m("v-if",!0),r(se)(e)?(s(),i("span",{key:2,class:"evalute-tip",onClick:o=>r(Ie)(e)},[Q,y(" 查看提示 ")],8,H)):m("v-if",!0)])),default:g((()=>[(s(),u(w(e.renderCom),d(r(we)(e,o),{key:(e.id||e.seq)+o,onScaleChange:r(Ae),onOnChange:o=>r(Me)(o,e),onVodFileList:r(Oe)}),null,16,["onScaleChange","onOnChange","onVodFileList"])),r(ye)(e)?(s(),u(M,{key:0,item:e},null,8,["item"])):m("v-if",!0)])),_:2},1032,["path","show-label"])):m("v-if",!0)],64)))),128))])),_:1},8,["model","rules"]),r(je)?(s(),u(T,{key:2,content:r(_e)},null,8,["content"])):m("v-if",!0)],6),r(ve)?(s(),i("div",$,[m(" 分享的链接 隐藏取消按钮 "),r(ge)?(s(),u(r(B),{key:0,onClick:Ge},{default:g((()=>[y("取消")])),_:1})):m("v-if",!0),r(he)?(s(),u(r(B),{key:1,onClick:r(Je),disabled:X.banSubmit,type:"primary"},{default:g((()=>[y(" 保存 ")])),_:1},8,["onClick","disabled"])):m("v-if",!0),S(e.$slots,"extendBtn")])):m("v-if",!0)],64))],64))],64))],2))}});export{z as default};
1
+ import{defineComponent as e,reactive as o,ref as t,watch as a,nextTick as n,openBlock as s,createElementBlock as i,normalizeClass as l,unref as r,createCommentVNode as m,Fragment as c,createBlock as u,mergeProps as d,createElementVNode as p,normalizeStyle as f,createVNode as v,withCtx as g,renderList as h,toDisplayString as k,createTextVNode as y,resolveDynamicComponent as w,renderSlot as S}from"vue";import b from"./hooks/use-noData.js";import{ScaleViewProps as C}from"./hooks/scaleview-props.js";import{getScaleViewState as D}from"./hooks/scaleview-state.js";import{ScaleViewComputed as E}from"./hooks/scaleview-computed.js";import{ScaleViewInit as j}from"./hooks/scaleview-init.js";import{ScaleViewSubmit as _}from"./hooks/scaleview-submit.js";import{ScaleViewMethods as x}from"./hooks/scaleview-methods.js";import{handleQueryParams as F,isCollection as P}from"./utils/judge-types.js";import{useEvent as q}from"./hooks/use-event.js";import"xe-utils";import"moment";import L from"../../../shared/utils/vexutilsExpand.js";import N from"./components/NoData.vue.js";import R from"./components/EvaluateCountdown.vue.js";import A from"./components/EvaluatePage.vue.js";import M from"./components/AnswerParse.vue.js";import O from"./components/ScaleScore.js";import T from"./components/DescribeContent.vue.js";import{NForm as V,NFormItem as I,NButton as B}from"naive-ui";const J=["innerHTML"],G={key:0,class:"required-text"},W={key:1,class:"evalute-label"},H=["onClick"],Q=p("i",{class:"scale-view-iconfont icon-scale-view-dengpao"},null,-1),$={key:1,class:"footer"};var z=e({__name:"ScaleView",props:C,emits:["onCloseSetting","submitNoRequest","onSubmit","startWriteScale"],setup(e,{expose:C,emit:z}){const K=e,{ScaleViewState:U}=D(),X=o(U),Y=t(null),Z=t(null),ee=t(null),{noDataState:oe,setNoData:te,resetNodata:ae}=b(),ne=F(),{showEvatip:se,isFormBoldOpen:ie,scaleStyle:le,handlePageClass:re,isShowItem:me,handleShowQuestionNumber:ce,hasScore:ue,isPreviewScale:de,showEvaluateEntry:pe,showEvaluateCoundownPage:fe,showScaleFooter:ve,isCancelBtn:ge,isSaveBtn:he,showEvaluateLabel:ke,showAnswerParse:ye,propsConfig:we,evaluatePageProps:Se,evaluateCountdownProps:be,isEvaluetaResSituation:Ce,disableEdit:De,desStart:Ee,desEnd:je,desContent:_e}=E(K,X,{query:ne,scaleViewDom:Y}),{initForm:xe}=j(K,X,z,{query:ne}),{submitMethod:Fe,onSubmitData:Pe,onSubmitForm:qe,handleScoreJson:Le}=_(K,X,z,{query:ne,formRef:ee,countdownDom:Z}),{nextLogicEvent:Ne,handleDynamicDataRelation:Re}=q(K,X),{scaleChange:Ae,labelChange:Me,vodFileList:Oe,writeGuage:Te,closeEvaluateCountdown:Ve,showEvaTipModal:Ie}=x(K,X,z,{nextLogicEvent:Ne,handleDynamicDataRelation:Re,isPreviewScale:de,submitMethod:Fe,isEvaluetaResSituation:Ce,handleScoreJson:Le,disableEdit:De});(()=>{let{id:e}=ne;e&&(X.shareId=e)})();const Be=e=>{try{ae(),xe(e)}catch(e){console.log(e,"--error"),X.spinning=!1,X.hasFrontAddress=!1,te(!0,null==e?void 0:e.resultMsg,null==e?void 0:e.result)}};a((()=>K.ids),((e,o)=>{o?e.guage_id&&e.guage_id!=o.guage_id&&Be(e):e.guage_id&&Be(e)}),{immediate:!0}),a((()=>K.guageData),(e=>{if(!e||!Object.keys(e||{}).length)return;X.form={},X.formArray=[];const o=JSON.parse(JSON.stringify(e));n((()=>{xe(o)}))}),{immediate:!0});const Je=L.debounce(Pe,300),Ge=()=>{z("onCloseSetting")};return C({getScaleData:()=>({...X}),onSubmitForm:qe,cancel:Ge}),(e,o)=>(s(),i("div",{class:l(["c-scale-view-block",{"c-scale-view-block-hasfooter":r(ve)}]),ref_key:"scaleViewDom",ref:Y},[m(' <template v-if="state.spinning">\n <n-spin :show="state.spinning" description="加载中"></n-spin>\n </template> '),X.spinning||X.hasFrontAddress?m("v-if",!0):(s(),i(c,{key:0},[r(oe).noData?(s(),u(N,{key:0,noDataImg:r(oe).noDataImg,noDataTip:r(oe).noDataTip},null,8,["noDataImg","noDataTip"])):(s(),i(c,{key:1},[r(pe)?(s(),u(A,d({key:0},r(Se),{onWriteGuage:r(Te)}),null,16,["onWriteGuage"])):(s(),i(c,{key:1},[r(fe)?(s(),u(R,d({key:0,ref_key:"countdownDom",ref:Z},r(be),{onCloseEvaluateCountdown:r(Ve)}),null,16,["onCloseEvaluateCountdown"])):m("v-if",!0),p("div",{class:l(["scale-container",{"scale-container-nopadding":r(re),"scale-container-hasfooter":r(ve)}]),style:f(r(le))},[r(ue)?(s(),u(r(O),{key:0,config:X.config,maxScore:X.maxScore},null,8,["config","maxScore"])):m("v-if",!0),r(Ee)?(s(),u(T,{key:1,content:r(_e)},null,8,["content"])):m("v-if",!0),v(r(V),{ref_key:"formRef",ref:ee,model:X.form,rules:X.rules,"require-mark-placement":"left",class:"main"},{default:g((()=>[(s(!0),i(c,null,h(X.formArray,((e,o)=>(s(),i(c,{key:(e.id||e.seq)+o},[r(me)(e)?(s(),u(r(I),{key:0,path:e.val_key,"show-label":!r(P)(e.type),class:"c-scle-form-item"},{label:g((()=>[p("span",{class:l({"scale-label-required":r(ie)(e)}),innerHTML:r(ce)(e)},null,10,J),r(ie)(e)?(s(),i("span",G,"(必填)")):m("v-if",!0),r(ke)(e)?(s(),i("span",W,k(r(ke)(e)),1)):m("v-if",!0),r(se)(e)?(s(),i("span",{key:2,class:"evalute-tip",onClick:o=>r(Ie)(e)},[Q,y(" 查看提示 ")],8,H)):m("v-if",!0)])),default:g((()=>[(s(),u(w(e.renderCom),d(r(we)(e,o),{key:(e.id||e.seq)+o,onScaleChange:r(Ae),onOnChange:o=>r(Me)(o,e),onVodFileList:r(Oe)}),null,16,["onScaleChange","onOnChange","onVodFileList"])),r(ye)(e)?(s(),u(M,{key:0,item:e},null,8,["item"])):m("v-if",!0)])),_:2},1032,["path","show-label"])):m("v-if",!0)],64)))),128))])),_:1},8,["model","rules"]),r(je)?(s(),u(T,{key:2,content:r(_e)},null,8,["content"])):m("v-if",!0)],6),r(ve)?(s(),i("div",$,[m(" 分享的链接 隐藏取消按钮 "),r(ge)?(s(),u(r(B),{key:0,onClick:Ge},{default:g((()=>[y("取消")])),_:1})):m("v-if",!0),r(he)?(s(),u(r(B),{key:1,onClick:r(Je),disabled:X.banSubmit,type:"primary"},{default:g((()=>[y(" 保存 ")])),_:1},8,["onClick","disabled"])):m("v-if",!0),S(e.$slots,"extendBtn")])):m("v-if",!0)],64))],64))],64))],2))}});export{z as default};
package/es/env.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_APP_TYPE: string;
5
- // 更多环境变量...
6
- }
7
-
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv;
10
- }
11
-
12
- declare module '*.vue' {
13
- // @ts-ignore
14
- import type { App, defineComponent } from 'vue';
15
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
16
- // // const component: DefineComponent<{}, {}, any>
17
- const component: ReturnType<typeof defineComponent> & {
18
- install(app: App): void;
19
- };
20
- // @ts-ignore
21
- export default component;
22
- }
23
-
24
- declare module '*.js';
25
-
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_TYPE: string;
5
+ // 更多环境变量...
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv;
10
+ }
11
+
12
+ declare module '*.vue' {
13
+ // @ts-ignore
14
+ import type { App, defineComponent } from 'vue';
15
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
16
+ // // const component: DefineComponent<{}, {}, any>
17
+ const component: ReturnType<typeof defineComponent> & {
18
+ install(app: App): void;
19
+ };
20
+ // @ts-ignore
21
+ export default component;
22
+ }
23
+
24
+ declare module '*.js';
25
+
@@ -1 +1 @@
1
- var e="@cnhis-design-vue/shared",i="3.2.9-beta.14",s="index.ts",n={"naive-ui":"^2.30.0",vue:"^3.2.0"},a={"@vicons/ionicons5":"^0.12.0","lodash-es":"^4.17.21",moment:"^2.29.1","video.js":"^7.19.2","videojs-contrib-hls":"^5.15.0",viewerjs:"^1.10.5","xe-utils":"^3.5.4"},d={name:e,version:"3.2.9-beta.14",private:!0,main:"index.ts",peerDependencies:n,dependencies:a};export{d as default,a as dependencies,s as main,e as name,n as peerDependencies,i as version};
1
+ var e="@cnhis-design-vue/shared",i="3.2.9-beta.17",s="index.ts",n={"naive-ui":"^2.30.0",vue:"^3.2.0"},a={"@vicons/ionicons5":"^0.12.0","lodash-es":"^4.17.21",moment:"^2.29.1","video.js":"^7.19.2","videojs-contrib-hls":"^5.15.0",viewerjs:"^1.10.5","xe-utils":"^3.5.4"},d={name:e,version:"3.2.9-beta.17",private:!0,main:"index.ts",peerDependencies:n,dependencies:a};export{d as default,a as dependencies,s as main,e as name,n as peerDependencies,i as version};
@@ -24,3 +24,4 @@ export declare function isHTMLElement(target: unknown): target is HTMLElement;
24
24
  export declare function getArrDepth<T extends {
25
25
  children?: T[];
26
26
  }>(fieldList: T[]): number;
27
+ export declare function encapBrowserLog(data: any, businessName: string): void;
@@ -1 +1 @@
1
- import{getCurrentInstance as t,defineComponent as e,provide as n,createVNode as r}from"vue";import{isObject as o}from"@vue/shared";import{useMemoize as i}from"@vueuse/core";import{isString as u,isNumber as c,isArray as s,isFunction as f}from"lodash-es";import a from"../package.json.js";export{getBindEventSettingTrigger,getDateOperationalFormHandler,getOperationalFormHandler,isConditionsMatchSqlExpression,isMatchLowCodeCondition,isMatchLowCodeConditionsWithSqlExpression,isMatchNewLowCodeConditionsWithSqlExpression}from"./business.js";function l(t,e,n="children",r){let o=!1;function i(){o=!0}!function t(e,n,r="children",u,c=0){r=h(r),e=h(e);for(let s=0;s<e.length;s++){if(n(e[s],i,u,c),o)return;for(let i=0;i<r.length;i++){const u=e[s][r[i]];if(Array.isArray(u)&&t(u,n,r,e[s],c+1),o)return}}}(t,e,n,r,0)}function d(t,e,n=e.name,r){if(!n)throw new Error(`[CUI]: invalid component name for ${e}`);const{components:i={}}=t._context;i[n]||(!Reflect.get(t,"__cnhis_version")&&o(a)&&Reflect.set(t,"__cnhis_version",a.version),r?r():t.component(n,e))}function p(t){if(!u(t))return;const e=t.match(/[Hms:]+/);return e?e[0]:void 0}function h(t){return Array.isArray(t)?t:[t]}function m(){return`key${"xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))}`}const x={a:7.7,b:8.6,c:7.7,d:8.6,e:7.7,f:5,g:8.6,h:8.2,i:3.3,j:3.3,k:7.6,l:3.5,m:12.1,n:8.2,o:8.2,p:8.6,q:8.6,r:5.4,s:7.1,t:5,u:8.2,v:7.6,w:10.9,x:7.3,y:7.6,z:7.6,A:9.43,B:9.33,C:9.93,D:10,E:8.27,F:8.1,G:10.4,H:10.4,I:3.7,J:7.5,K:9.2,L:7.9,M:12.4,N:10.4,O:10.8,P:8.9,Q:10.8,R:9.1,S:8.8,T:8.9,U:10.4,V:9.4,W:13.5,X:9.4,Y:9.1,Z:9.1,".":4.03,",":4.03,"(":5.17,")":5.17,"-":7.51,"+":7.51,"/":4.11,"\\":4.11,"%":12.68,"‰":17.75,";":13.95,"、":13.95,",":13.95,"。":13.95},g=/\d/,v=/[\u4e00-\u9fa5():,。]/;function y(t){return x[t]?x[t]:g.test(t)?8.9:v.test(t)?13.95:void 0}const w=i((function(t){if(!t)return 0;let e="";return[...t].reduce(((t,n)=>{const r=e;return e=n," "===n?" "===r?t:t+4:t+(y(n)||6)}),0)})),E=Object.seal(Object.create(null));function O(t,e){return function t(e,n){return o(e)?s(e)?e.map((e=>t(e,n))):Object.entries(e).reduce(((e,[r,i])=>(n.includes(r)||(o(i)&&!f(i)?e[r]=t(i,n):e[r]=i),e)),{}):e}(t,e)}function b(t){return Object.values(t).reduce(((t,e)=>Object.assign(t,e)),{})}function j(t,e){if(!t)return t;if(e(t))return t;let n=t.parentElement;for(;n&&!e(n);)n=n.parentElement;return n}function C(t,e="px"){if(c(t))return`${t}${e}`;if(!t)return"";if(u(t))return t.endsWith(e)?t:`${t}${e}`;throw new Error(`invalid width value ${t}, it need to be a string or number!`)}function S(t,e){return t.some((t=>e.includes(t)))}const M=i((t=>{try{return JSON.parse(t)}catch(t){return{}}}),{getKey:t=>t});function $(t,e){if(!o(t))return t;const n={...t};for(let t=0;t<e.length;t++)Reflect.deleteProperty(n,e[t]);return n}function _(e){if(!t())throw new Error(e||"can't use this hook out of setup environment")}function I(t,e=1){const[n,r,o,i,u]=t.match(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i)||[];if(!n)return[255,255,255,e];const s=u&&parseInt(u,16)/255;return[parseInt(r,16),parseInt(o,16),parseInt(i,16),+(c(s)?s.toFixed(2):e)]}function A(t){return e({setup(e,{slots:o}){let i=(null==t?void 0:t.parent)&&Reflect.get(t.parent,"provides");const u=[];for(;i;)Object.entries(i).forEach((([t,e])=>{u.includes(t)||(u.push(t),n(t,e))})),i=Object.getPrototypeOf(i);return()=>{var t;return r("div",null,[null==(t=o.default)?void 0:t.call(o)])}}})}const H=i((function(t,e){return!(!u(e)||!u(t))&&e.split(",").some((e=>e.trim().includes(t)))}),{getKey:(...t)=>t.reduce(((t,e)=>String(t)+"_"+String(e)),"")});function L(t){try{return t instanceof HTMLElement}catch(e){return o(t)&&1===t.nodeType&&o(t.style)&&o(t.ownerDocument)}}function R(t){let e=0;return function t(n,r=0){n.forEach((n=>{n.children?t(n.children,r+1):e=Math.max(e,r)}))}(t),e}export{E as DMZ,h as arrayed,_ as checkInSetupEnv,A as createProviderWrapper,O as deepOmit,j as findAncestor,p as generateTimeFormat,R as getArrDepth,y as getCharWidth,w as getStringWidth,I as hex2rgba,L as isHTMLElement,M as jsonParse,H as keywordMatcher,d as safeComponentRegister,b as separateMetaModule,$ as shallowOmit,S as targetStringIncludes,l as traverse,m as uuidGenerator,C as widthAppend};
1
+ import{getCurrentInstance as n,defineComponent as t,provide as e,createVNode as r}from"vue";import{isObject as o}from"@vue/shared";import{useMemoize as i}from"@vueuse/core";import{isString as u,isNumber as c,isArray as s,isFunction as f}from"lodash-es";import a from"../package.json.js";export{getBindEventSettingTrigger,getDateOperationalFormHandler,getOperationalFormHandler,isConditionsMatchSqlExpression,isMatchLowCodeCondition,isMatchLowCodeConditionsWithSqlExpression,isMatchNewLowCodeConditionsWithSqlExpression}from"./business.js";function l(n,t,e="children",r){let o=!1;function i(){o=!0}!function n(t,e,r="children",u,c=0){r=m(r),t=m(t);for(let s=0;s<t.length;s++){if(e(t[s],i,u,c),o)return;for(let i=0;i<r.length;i++){const u=t[s][r[i]];if(Array.isArray(u)&&n(u,e,r,t[s],c+1),o)return}}}(n,t,e,r,0)}function d(n,t,e=t.name,r){if(!e)throw new Error(`[CUI]: invalid component name for ${t}`);const{components:i={}}=n._context;i[e]||(!Reflect.get(n,"__cnhis_version")&&o(a)&&Reflect.set(n,"__cnhis_version",a.version),r?r():n.component(e,t))}function p(n){if(!u(n))return;const t=n.match(/[Hms:]+/);return t?t[0]:void 0}function m(n){return Array.isArray(n)?n:[n]}function h(){return`key${"xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){const t=16*Math.random()|0;return("x"==n?t:3&t|8).toString(16)}))}`}const x={a:7.7,b:8.6,c:7.7,d:8.6,e:7.7,f:5,g:8.6,h:8.2,i:3.3,j:3.3,k:7.6,l:3.5,m:12.1,n:8.2,o:8.2,p:8.6,q:8.6,r:5.4,s:7.1,t:5,u:8.2,v:7.6,w:10.9,x:7.3,y:7.6,z:7.6,A:9.43,B:9.33,C:9.93,D:10,E:8.27,F:8.1,G:10.4,H:10.4,I:3.7,J:7.5,K:9.2,L:7.9,M:12.4,N:10.4,O:10.8,P:8.9,Q:10.8,R:9.1,S:8.8,T:8.9,U:10.4,V:9.4,W:13.5,X:9.4,Y:9.1,Z:9.1,".":4.03,",":4.03,"(":5.17,")":5.17,"-":7.51,"+":7.51,"/":4.11,"\\":4.11,"%":12.68,"‰":17.75,";":13.95,"、":13.95,",":13.95,"。":13.95},g=/\d/,v=/[\u4e00-\u9fa5():,。]/;function w(n){return x[n]?x[n]:g.test(n)?8.9:v.test(n)?13.95:void 0}const y=i((function(n){if(!n)return 0;let t="";return[...n].reduce(((n,e)=>{const r=t;return t=e," "===e?" "===r?n:n+4:n+(w(e)||6)}),0)})),E=Object.seal(Object.create(null));function O(n,t){return function n(t,e){return o(t)?s(t)?t.map((t=>n(t,e))):Object.entries(t).reduce(((t,[r,i])=>(e.includes(r)||(o(i)&&!f(i)?t[r]=n(i,e):t[r]=i),t)),{}):t}(n,t)}function b(n){return Object.values(n).reduce(((n,t)=>Object.assign(n,t)),{})}function j(n,t){if(!n)return n;if(t(n))return n;let e=n.parentElement;for(;e&&!t(e);)e=e.parentElement;return e}function C(n,t="px"){if(c(n))return`${n}${t}`;if(!n)return"";if(u(n))return n.endsWith(t)?n:`${n}${t}`;throw new Error(`invalid width value ${n}, it need to be a string or number!`)}function S(n,t){return n.some((n=>t.includes(n)))}const M=i((n=>{try{return JSON.parse(n)}catch(n){return{}}}),{getKey:n=>n});function $(n,t){if(!o(n))return n;const e={...n};for(let n=0;n<t.length;n++)Reflect.deleteProperty(e,t[n]);return e}function _(t){if(!n())throw new Error(t||"can't use this hook out of setup environment")}function I(n,t=1){const[e,r,o,i,u]=n.match(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i)||[];if(!e)return[255,255,255,t];const s=u&&parseInt(u,16)/255;return[parseInt(r,16),parseInt(o,16),parseInt(i,16),+(c(s)?s.toFixed(2):t)]}function A(n){return t({setup(t,{slots:o}){let i=(null==n?void 0:n.parent)&&Reflect.get(n.parent,"provides");const u=[];for(;i;)Object.entries(i).forEach((([n,t])=>{u.includes(n)||(u.push(n),e(n,t))})),i=Object.getPrototypeOf(i);return()=>{var n;return r("div",null,[null==(n=o.default)?void 0:n.call(o)])}}})}const H=i((function(n,t){return!(!u(t)||!u(n))&&t.split(",").some((t=>t.trim().includes(n)))}),{getKey:(...n)=>n.reduce(((n,t)=>String(n)+"_"+String(t)),"")});function L(n){try{return n instanceof HTMLElement}catch(t){return o(n)&&1===n.nodeType&&o(n.style)&&o(n.ownerDocument)}}function N(n){let t=0;return function n(e,r=0){e.forEach((e=>{e.children?n(e.children,r+1):t=Math.max(t,r)}))}(n),t}function R(n,t){var e;(null==(e=null==window?void 0:window.$CMonitor)?void 0:e.notify)&&window.$CMonitor.notify({message:JSON.stringify(n),businessName:t||"SDK"})}export{E as DMZ,m as arrayed,_ as checkInSetupEnv,A as createProviderWrapper,O as deepOmit,R as encapBrowserLog,j as findAncestor,p as generateTimeFormat,N as getArrDepth,w as getCharWidth,y as getStringWidth,I as hex2rgba,L as isHTMLElement,M as jsonParse,H as keywordMatcher,d as safeComponentRegister,b as separateMetaModule,$ as shallowOmit,S as targetStringIncludes,l as traverse,h as uuidGenerator,C as widthAppend};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "3.2.9-beta.14",
3
+ "version": "3.2.9-beta.17",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -72,5 +72,5 @@
72
72
  "iOS 7",
73
73
  "last 3 iOS versions"
74
74
  ],
75
- "gitHead": "1bcc395dad3f1e0dff1cb2177952cff9b1e7fdee"
75
+ "gitHead": "1d2656246893da0bd407d19af5e6fe011ebb88ae"
76
76
  }