1 |
- var e=Object.defineProperty,t=(t,r,o)=>(((t,r,o)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o})(t,"symbol"!=typeof r?r+"":r,o),o);import{R as r,r as o,p as n,b as s,c as a,L as i,d as l,A as u}from"../../assets/index.9d3f0ed9.js";import{c}from"../vue-como-image/vue-como-image.1f08e6a4.js";import{d as g}from"../como-ts-utils/como-ts-utils.52443996.js";const h={router:r,request:o,pxToRem:n,comoImage:c};class m{constructor(){t(this,"dialogFn"),t(this,"dialogIns")}get Extend(){return null}async Dialog(){const e=await s().GetAppProThemeColor();return this.dialogFn({titleBgColor:e,titleColor:"#ffffff"})}get Request(){return h.request}get Router(){return h.router}get Utils(){return g.ComoTsUtils.Ins}get ImageHandle(){return h.comoImage}get CurrentPage(){return 1}get PageSize(){return 20}async GetImageCompressOptions(){try{return await s().GetImageZipOptions()}catch(e){return console.log(e),{width:1e3,height:1e3,quality:.8}}}async Exception(e,t={title:"操作失败提醒"}){(await this.Dialog()).Alert(e,Object.assign({icon:"error",title:"操作失败提醒"},t))}DeleteHandle(e,t="您确定要删除"){return new Promise((async(r,o)=>{var n,s,a;(await this.Dialog()).Confirm(`${t}${null!=(n=e.name)?n:"数据"}吗?${null!=(s=e.content)?s:'数据删除后将无法恢复,<span style="color:#ff0000;font-weight:800;">请谨慎操作!!</span>'}`,{title:null!=(a=e.title)?a:"数据删除操作提醒",icon:"ask",width:"480px",callback:e=>r(e)})}))}GetAllParentList(e,t,r="pid",o="id",n="children"){if(!e||0==e.length||!t)return[];const s=[],a=function(t,i=0){for(let l=0,u=t.length;l<u;l+=1){const u=t[l];if(u[o]==i){s.unshift(u),a(e,Number(u[r]));break}u[n]&&u[n].length>0&&a(u[n],i)}};return a(e,t),s}RouteActionAuth(e){if(!this.Router.hasRoute(e))throw new Error("您未获取操作权限,如有需要,请联系管理员授权")}async SwitchStatusChange(e,t,r,o="状态操作成功操作"){try{const n=await this.Request.Put(t,e);if(!1!==n.error)throw new Error(n.message);(await this.Dialog()).Message(o,{icon:"SUCCESS"},r)}catch(n){return void this.Exception(null==n?void 0:n.message)}}SetDialogIns(e){return this.dialogFn=e,this}async ProxyRequest(e,t,...r){var o;const n=this;try{const o=await e.call(n,t,...r);if(0!=o.error)throw new Error(o.message);return o.data}catch(s){return n.Exception(null!=(o=s.message)?o:"未知错误"),null}}async TablePrinterToHtml(e,t,r="45px"){var o;let n=`<table style="width:100%;border-bottom:solid 1px #e6e6e6;"><tr style="height:${r};">`,s=`height:${r};border:solid 1px #e6e6e6;border-right:none;border-bottom:none;`,a=s;e.forEach(((t,r)=>{r==e.length-1&&(a+="border-right:solid 1px #e6e6e6;"),n+=`<th align="center" style="${a}">${t.name}</th>`})),n+="</tr>";for(let i=0;i<t.length;i++){const r=t[i];let a=[],l=s;for(let t=0;t<e.length;t++){const n=e[t];t==e.length-1&&(l+="border-right:solid 1px #e6e6e6;"),a.push(`<td align="center" style="${l}">${null!=(o=r[n.key])?o:""}</td>`)}const u=`<tr>${a.join("")}</tr>`;n+=u}return n+="</table>",n}SleepTime(e=1e3){return new Promise(((t,r)=>{setTimeout((()=>{t(!0)}),e)}))}async GetUserMenus(){const e=this,t=await a().GetAdminMenus();console.log(t);return i(t).forEach((t=>e.Router.addRoute("AdminManagers",t))),t}async LoginHandle(e){l().SetAdminToken(e.token).SetData(e.info),await this.GetUserMenus(),(await this.Dialog()).Message(`登录成功,欢迎使用${u.Ins.GetAppTitle()},正在初始化管理员数据管理功能,请稍候`,{icon:"SUCCESS"},(()=>{this.Router.push({name:"AdminBashboard",replace:!0})}))}}export{m as B};
|