@chewel611/naive-ui-plus 0.0.49 → 0.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +789 -764
- package/dist/index.umd.cjs +1 -1
- package/es/table/PTable.vue.js +175 -164
- package/es/table/typing.d.ts +5 -0
- package/es/utils/helper.d.ts +9 -0
- package/es/utils/helper.js +20 -0
- package/lib/table/PTable.vue.cjs +1 -1
- package/lib/table/typing.d.ts +5 -0
- package/lib/utils/helper.cjs +1 -0
- package/lib/utils/helper.d.ts +9 -0
- package/package.json +103 -102
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(N,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("naive-ui"),require("vue"),require("@vicons/antd"),require("pinia"),require("vue-router"),require("element-resize-detector"),require("vuedraggable")):typeof define=="function"&&define.amd?define(["exports","naive-ui","vue","@vicons/antd","pinia","vue-router","element-resize-detector","vuedraggable"],n):(N=typeof globalThis<"u"?globalThis:N||self,n(N.naiveplus={},N.naiveUi,N.Vue,N.antd,N.pinia,N.vueRouter,N.elementResizeDetectorMaker,N.Draggable))})(this,(function(N,n,e,T,Y,M,he,_e){"use strict";const ye={class:"text-lg font-medium"},be={id:"data-content"},ke={key:0,class:"rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"},we=e.defineComponent({__name:"PTable",props:{title:{},idField:{default:"id"},columns:{},onLoad:{},onDelete:{},onAdd:{},onEdit:{}},setup(t,{expose:a}){const l=e.ref(null),p=n.useDialog(),g=n.useMessage(),i=e.ref(!1),_=e.ref([]),c=e.ref([]),B=e.ref({page:1,itemCount:0,pageSize:10,pageSizes:[10,20,30,50],showSizePicker:!0,onChange:async b=>{B.value.page=b,await u()},onUpdatePageSize:async b=>{B.value.pageSize=b,await u()}}),y=t,r=b=>{const k=P=>{const S=[];return b&&b.forEach(O=>{O.key!=="edit"&&O.key!=="delete"&&S.push({label:O.name,key:O.key,icon:O.icon&&(()=>e.h(n.NIcon,null,{default:()=>e.h(O.icon)})),props:{onClick:()=>O.action(P)}})}),S};return{title:"操作",key:"actions",width:100,fixed:"right",render:P=>{let S=[];if(y.onEdit&&S.push({label:"编辑",key:"edit",icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.EditOutlined)}),props:{onClick:async()=>await y.onEdit(P)}}),y.onDelete&&S.push({label:"删除",key:"delete",icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.DeleteOutlined)}),props:{onClick:()=>C(P)}}),S=[...S,...k(P)],!(S.length<=0))return e.h(n.NDropdown,{options:S,placement:"bottom-start"},{default:()=>e.h(n.NButton,{size:"small",type:"primary"},{default:()=>["操作",e.h(n.NIcon,()=>e.h(T.MoreOutlined))]})})}}},V=e.computed(()=>{const b=y.columns.filter(P=>P.key!="action").map(P=>({title:P.title,key:P.key,width:P.width,fixed:P.fixed??!1,render:P.render,ellipsis:P.ellipsis?{tooltip:!0}:!1})),k=y.columns.reduce((P,S)=>S.key==="action"?S:P,void 0)?.action;return k&&k?.length>0||y.onEdit||y.onDelete?[{type:"selection",fixed:"left"},...b,r(k)]:[{type:"selection",fixed:"left"},...b]}),d=async()=>await u(),C=b=>x([b]),L=()=>{const b=w();x(b)},x=b=>{b&&b.length>0&&p.warning({title:"警告",content:"删除数据不可恢复, 确认删除吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(y.onDelete)try{await y.onDelete(b)?(u(),g.success("删除成功")):g.error("删除失败")}catch(k){g.error(k.message)}}})},w=()=>_.value?c.value.filter(k=>_.value.includes(k.id)).map(k=>e.toRaw(k)):[],E=()=>w()[0],m=()=>e.toRaw(c.value),u=async()=>{if(!i.value){i.value=!0;try{if(y.onLoad){var{items:b,totalCount:k}=await y.onLoad(B.value.page,B.value.pageSize);c.value=b,B.value.itemCount=k}}catch(P){g.error(P.message)}finally{i.value=!1}}},s=e.computed(()=>{const b=e.unref(l);if(!b)return;const k=b?.$el,P=k.querySelector(".n-data-table-thead "),{bottomIncludeBody:S}=F(P),O=48;let R=12,W=25;const z=k.querySelector(".n-data-table__pagination");if(z){const q=z.offsetHeight;R+=q||0}else R+=28;return S-(O+R+W)}),I=b=>!b||!b.getBoundingClientRect?0:b.getBoundingClientRect(),F=b=>{const k=document.documentElement,P=k.scrollLeft,S=k.scrollTop,O=k.clientLeft,R=k.clientTop,W=window.pageXOffset,z=window.pageYOffset,K=I(b),{left:q,top:X,width:J,height:o}=K,f=(W||P)-(O||0),h=(z||S)-(R||0),$=q+W,j=X+z,Z=$-f,G=j-h,ue=window.document.documentElement.clientWidth,ge=window.document.documentElement.clientHeight;return{left:Z,top:G,right:ue-J-Z,bottom:ge-o-G,rightIncludeBody:ue-Z,bottomIncludeBody:ge-G}};return e.onMounted(async()=>await u()),a({getData:m,getSelectedRow:E,getSelectedRows:w,refreshData:u,resetPage:()=>{B.value.page=1}}),(b,k)=>{const P=n.NTooltip,S=n.NSpace,O=n.NDataTable;return e.openBlock(),e.createBlock(e.unref(n.NCard),{bordered:!1},{header:e.withCtx(()=>[e.createVNode(S,{justify:"space-between",align:"center",class:"w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",ye,e.toDisplayString(t.title),1),e.createVNode(S,null,{default:e.withCtx(()=>[y.onAdd?(e.openBlock(),e.createBlock(P,{key:0,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:y.onAdd},{default:e.withCtx(()=>[e.createVNode(e.unref(T.PlusSquareOutlined))]),_:1},8,["onClick"])]),default:e.withCtx(()=>[k[1]||(k[1]=e.createElementVNode("span",null,"新增",-1))]),_:1})):e.createCommentVNode("",!0),y.onDelete?(e.openBlock(),e.createBlock(P,{key:1,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:L},{default:e.withCtx(()=>[e.createVNode(e.unref(T.DeleteOutlined))]),_:1})]),default:e.withCtx(()=>[k[2]||(k[2]=e.createElementVNode("span",null,"删除",-1))]),_:1})):e.createCommentVNode("",!0),e.createVNode(P,{trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",class:"cursor-pointer hover:text-blue-600",onClick:d},{default:e.withCtx(()=>[e.createVNode(e.unref(T.ReloadOutlined))]),_:1})]),default:e.withCtx(()=>[k[3]||(k[3]=e.createElementVNode("span",null,"刷新",-1))]),_:1})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",be,[b.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",ke,[e.renderSlot(b.$slots,"toolbar")])):e.createCommentVNode("",!0),e.createVNode(O,{remote:"",ref_key:"$table",ref:l,"checked-row-keys":_.value,"onUpdate:checkedRowKeys":k[0]||(k[0]=R=>_.value=R),"max-height":s.value,loading:i.value,bordered:!1,"single-line":!1,columns:V.value,data:c.value,pagination:B.value,"row-key":R=>R[t.idField]},null,8,["checked-row-keys","max-height","loading","columns","data","pagination","row-key"])])]),_:3})}}}),D=(t,a)=>{const l=a;return l.install=function(p){p.component(t,a)},a},Q=D("PTable",we),Ne=["Redirect","RedirectSon","login"],H=Y.defineStore("p-layout",()=>{const t=e.reactive({collapsed:!1,title:"输入项目名称",logo:"https://picsum.photos/id/1/100/100",avatar:"",uid:"",uname:"",tabs:[],menus:[],cacheTabs:!1,enableLanguage:!1});return{state:t,initMenus:m=>{m.sort((u,s)=>u.affix&&!s.affix?-1:!u.affix&&s.affix?1:Number(s.sort??0)-Number(u.sort??0)),t.menus=m},getMenus:()=>t.menus,initTabs:m=>{m.sort((u,s)=>u.meta.affix&&!s.meta.affix?-1:!u.meta.affix&&s.meta.affix?1:Number(s.meta.sort??0)-Number(u.meta.sort??0)),t.tabs=m},addTab:m=>Ne.includes(m.name)?!1:(t.tabs?.some(s=>s.fullPath==m.fullPath)||t.tabs?.push(m),!0),getCurrentTab:()=>{const m=M.useRoute();return t.tabs.find(u=>u.fullPath==m.fullPath)},closeCurrentTab:m=>{const u=t.tabs.findIndex(s=>s.fullPath==m.fullPath);t.tabs.splice(u,1)},closeAllTabs:()=>{t.tabs=t.tabs.filter(m=>m?.meta?.affix??!1)},closeOtherTabs:m=>{t.tabs=t.tabs.filter(u=>u.fullPath==m.fullPath||(u?.meta?.affix??!1))},closeLeftTabs:m=>{const u=t.tabs.findIndex(s=>s.fullPath==m.fullPath);t.tabs=t.tabs.filter((s,I)=>I>=u||(s?.meta?.affix??!1))},closeRightTabs:m=>{const u=t.tabs.findIndex(s=>s.fullPath==m.fullPath);t.tabs=t.tabs.filter((s,I)=>I<=u||(s?.meta?.affix??!1))},collapse:()=>{t.collapsed=!t.collapsed},setTitle:m=>{t.title=m},setLogo:m=>{t.logo=m},setUser:(m,u)=>{t.uid=m,t.uname=u},setSettingPages:m=>{t.settingPages=m},setLogout:m=>{t.logout=m},enableLanguage:m=>{t.enableLanguage=m}}}),Ce={class:"logo"},xe=e.defineComponent({__name:"PLogo",setup(t){const a=H();return(l,p)=>(e.openBlock(),e.createElementBlock("div",Ce,[e.createVNode(e.unref(n.NAvatar),{color:"var(--color-logo)",size:32,src:e.unref(a).state.logo,class:e.normalizeClass({"mr-2":!e.unref(a).state.collapsed})},null,8,["src","class"]),e.withDirectives(e.createElementVNode("h1",{class:"font-bold ease-in-out ml-2 logo-size"},e.toDisplayString(e.unref(a).state.title),513),[[e.vShow,!e.unref(a).state.collapsed]])]))}}),A=(t,a)=>{const l=t.__vccOpts||t;for(const[p,g]of a)l[p]=g;return l},Pe=A(xe,[["__scopeId","data-v-e48aeefa"]]),Ve={translationApiUrl:"https://translate.zvo.cn/api",defaultLanguage:"chinese",currentLanguage:"",options:[],initLanguages:async()=>[],selectLanguage:async t=>{}},U=Y.defineStore("language",()=>{const t=e.ref(Ve),a=async()=>(t.value.options.length===0&&(t.value.options=await t.value.initLanguages()),t.value.options);return{select:async r=>{if(t.value.currentLanguage===r)return;const V=(await a()).find(d=>d.key===r);V&&(t.value.currentLanguage=V.key,t.value.selectLanguage(V))},selectLanguageCallback:async r=>{t.value.selectLanguage=r},initLanguagesCallback:async r=>{t.value.initLanguages=r},getLanguages:a,getCurrentLanguage:async()=>{if(t.value.currentLanguage)return(await a()).find(r=>r.key===t.value.currentLanguage)},setTranslationApiUrl:r=>{t.value.translationApiUrl=r},getTranslationApiUrl:()=>t.value.translationApiUrl,getDefaultLanguage:()=>t.value.defaultLanguage?t.value.defaultLanguage:"chinese_simplified",setDefaultLanguage:r=>{(r==="Chinese"||r==="chinese")&&(r="chinese_simplified"),t.value.defaultLanguage=r}}}),Be={key:1},v=e.defineComponent({__name:"PLanguage",setup(t){const{select:a,getLanguages:l,getCurrentLanguage:p,getDefaultLanguage:g,getTranslationApiUrl:i}=U(),_=e.ref(),c=e.ref([]),B=async r=>await a(r),y=async()=>{const r=window.translate;r&&(r.selectLanguageTag.show=!1,r.selectLanguageTag.languages=(await l()).map(V=>V.key).join(","),r.ignore.class.push("ignore-translate-flag"),r.ignore.id.push("ignore-translation"),r.language.setLocal(g()),r.request.api.translate="api/v1/translation",r.request.api.connectTest="api/v1/translation/connect-test",r.request.api.init="api/v1/translation/init",r.request.api.language="api/v1/translation/language",r.request.setHost(i()),r.request.listener.start(),r.listener.start(),r.whole.enableAll(),r.execute())};return e.onMounted(async()=>{await e.nextTick(),await y(),_.value=await p(),c.value=await l()}),(r,V)=>{const d=n.NIcon,C=n.NButton;return c.value.length>0?(e.openBlock(),e.createBlock(e.unref(n.NDropdown),{key:0,id:"ignore-translation",placement:"bottom-start",trigger:"hover",class:"flex flex-col justify-center h-full ignore",onSelect:B,options:c.value},{default:e.withCtx(()=>[e.createVNode(C,{quaternary:"",type:"info"},{default:e.withCtx(()=>[_.value?(e.openBlock(),e.createElementBlock("label",Be,e.toDisplayString(_.value?.label),1)):(e.openBlock(),e.createBlock(d,{key:0,size:"18"},{default:e.withCtx(()=>[...V[0]||(V[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},[e.createElementVNode("path",{d:"M478.33 433.6l-90-218a22 22 0 0 0-40.67 0l-90 218a22 22 0 1 0 40.67 16.79L316.66 406h102.67l18.33 44.39A22 22 0 0 0 458 464a22 22 0 0 0 20.32-30.4zM334.83 362L368 281.65L401.17 362z",fill:"currentColor"}),e.createElementVNode("path",{d:"M267.84 342.92a22 22 0 0 0-4.89-30.7c-.2-.15-15-11.13-36.49-34.73c39.65-53.68 62.11-114.75 71.27-143.49H330a22 22 0 0 0 0-44H214V70a22 22 0 0 0-44 0v20H54a22 22 0 0 0 0 44h197.25c-9.52 26.95-27.05 69.5-53.79 108.36c-31.41-41.68-43.08-68.65-43.17-68.87a22 22 0 0 0-40.58 17c.58 1.38 14.55 34.23 52.86 83.93c.92 1.19 1.83 2.35 2.74 3.51c-39.24 44.35-77.74 71.86-93.85 80.74a22 22 0 1 0 21.07 38.63c2.16-1.18 48.6-26.89 101.63-85.59c22.52 24.08 38 35.44 38.93 36.1a22 22 0 0 0 30.75-4.9z",fill:"currentColor"})],-1)])]),_:1}))]),_:1})]),_:1},8,["options"])):e.createCommentVNode("",!0)}}}),Le={class:"layout-header"},Se={class:"layout-header-left"},Ee={class:"link-text"},Te={key:1,class:"link-text"},$e={class:"layout-header-right"},Oe={key:0,class:"layout-header-trigger-min"},De={class:"layout-header-trigger layout-header-trigger-min"},Ie={class:"layout-header-trigger layout-header-trigger-min"},Me={class:"avatar"},Re=A(e.defineComponent({__name:"PHeader",setup(t){const a=n.useMessage(),l=n.useDialog(),p=H(),g=M.useRouter(),i=M.useRoute(),_=e.inject("reloadPage"),c=x=>g.push({name:x}),B=e.computed(()=>y(i.matched)),y=x=>x.map(w=>{const E={key:w.name,label:w.meta.title,icon:w.meta.icon,meta:w.meta,disabled:w.path==="/",children:void 0};return w.children&&w.children.length>0&&(E.children=y(w.children)),E}),r=e.ref(!1),V=()=>{document.fullscreenElement?document.exitFullscreen&&(document.exitFullscreen(),r.value=!1):(document.documentElement.requestFullscreen(),r.value=!0)},d=e.computed(()=>{const x=[];return x.push({label:"退出登录",key:"logout"}),p.state.settingPages&&p.state.settingPages.length>0&&p.state.settingPages.forEach(w=>{x.push({label:w.title,key:w.route})}),x}),C=x=>{x==="logout"?L():g.push({name:x})},L=()=>{l.info({title:"提示",content:"您确定要退出登录吗",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(p.state.logout)try{await p.state.logout(),localStorage.removeItem("TABS-ROUTES"),a.error("退出成功")}catch(x){console.error(x),a.error("退出登录失败")}finally{location.reload()}else a.error("没有配置登出接口, 请配置[usePLayoutStore.logout]方法")},onNegativeClick:()=>{}})};return(x,w)=>{const E=n.NTooltip,m=n.NDivider,u=n.NAvatar;return e.openBlock(),e.createElementBlock("div",Le,[e.createElementVNode("div",Se,[e.createElementVNode("div",{class:"ml-1 layout-header-trigger layout-header-trigger-min",onClick:w[0]||(w[0]=(...s)=>e.unref(p).collapse&&e.unref(p).collapse(...s))},[e.unref(p).state.collapsed?(e.openBlock(),e.createBlock(e.unref(n.NIcon),{key:0,size:"18"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.MenuUnfoldOutlined))]),_:1})):(e.openBlock(),e.createBlock(e.unref(n.NIcon),{key:1,size:"18"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.MenuFoldOutlined))]),_:1}))]),e.createElementVNode("div",{class:"mr-1 layout-header-trigger layout-header-trigger-min",onClick:w[1]||(w[1]=(...s)=>e.unref(_)&&e.unref(_)(...s))},[e.createVNode(e.unref(n.NIcon),{size:"18"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.ReloadOutlined))]),_:1})]),e.createVNode(e.unref(n.NBreadcrumb),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,s=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s.label},[s.label?(e.openBlock(),e.createBlock(e.unref(n.NBreadcrumbItem),{key:0},{default:e.withCtx(()=>[s.children&&s.children.length?(e.openBlock(),e.createBlock(e.unref(n.NDropdown),{key:0,options:s.children,onSelect:c},{default:e.withCtx(()=>[e.createElementVNode("span",Ee,[s.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.icon),{key:0})):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(s.label),1)])]),_:2},1032,["options"])):(e.openBlock(),e.createElementBlock("span",Te,[s.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.icon),{key:0})):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(s.label),1)]))]),_:2},1024)):e.createCommentVNode("",!0)],64))),128))]),_:1})]),e.createElementVNode("div",$e,[e.unref(p).state.enableLanguage?(e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(v)])):e.createCommentVNode("",!0),e.createElementVNode("div",De,[e.createVNode(E,{placement:"bottom"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",onClick:e.withModifiers(V,["stop"])},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(T.FullscreenExitOutlined),{key:1})):(e.openBlock(),e.createBlock(e.unref(T.FullscreenOutlined),{key:0}))]),_:1})]),default:e.withCtx(()=>[w[2]||(w[2]=e.createElementVNode("span",null,"全屏",-1))]),_:1})]),e.createElementVNode("div",Ie,[e.createVNode(e.unref(n.NDropdown),{trigger:"hover",onSelect:C,options:d.value},{default:e.withCtx(()=>[e.createElementVNode("div",Me,[e.createElementVNode("span",null,e.toDisplayString(e.unref(p).state.uname),1),e.createVNode(m,{vertical:""}),e.createVNode(u,{round:"",src:e.unref(p).state.avatar},null,8,["src"])])]),_:1},8,["options"])])])])}}}),[["__scopeId","data-v-563e4e55"]]),Ae={class:"mt-1"},ze=e.defineComponent({__name:"PContent",props:{loading:{type:Boolean,default:!1}},setup(t){return(a,l)=>{const p=e.resolveComponent("RouterView");return e.openBlock(),e.createElementBlock("div",Ae,[t.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(p,{key:0},{default:e.withCtx(({Component:g,route:i})=>[(e.openBlock(),e.createBlock(e.KeepAlive,null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g),{key:i.fullPath}))],1024))]),_:1}))])}}}),qe={class:"tabs-view-main"},je=["id","onClick","onContextmenu"],He={class:"tabs-close"},We={class:"tabs-close-btn"},Fe=A(e.defineComponent({__name:"PTabs",setup(t){e.useCssVars(o=>({v4f917f8c:l.value,v1c2fb72a:p.value}));const a=n.useThemeVars(),l=e.computed(()=>a.value.cardColor),p=e.computed(()=>a.value.textColor1),g=n.useMessage(),i=M.useRoute(),_=M.useRouter(),c=e.ref(null),B=e.ref(null),y=e.ref(!1),r=H(),V=e.computed(()=>r.state.tabs),d=e.reactive({activeKey:i.fullPath,scrollable:!0,dropdownX:0,dropdownY:0,showDropdown:!1,isMultiHeaderFixed:!0,multiTabsSetting:!0}),C=["Login","Redirect","ErrorPage"],L=o=>({meta:o.meta,name:o.name,fullPath:o.fullPath??o.path,path:o.path,hash:o.hash??"",query:o.query??{},params:o.params??{}}),x=e.computed(()=>{const h=r.state.collapsed?"64px":"272px";return{left:h,width:`calc(100% - ${h})`}}),w=e.computed(()=>{const o=V.value.length<=1;return[{label:"刷新当前",key:"1",icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.ReloadOutlined)})},{label:"关闭当前",key:"2",disabled:y.value||o,icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.CloseOutlined)})},{label:"关闭其他",key:"3",disabled:o,icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.ColumnWidthOutlined)})},{label:"关闭全部",key:"4",disabled:o,icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.MinusOutlined)})}]}),E=()=>{let o=[L(i)];_.getRoutes().filter(f=>f.meta.affix).forEach(f=>{const h=L(f);o.every($=>$.name!==h.name)&&o.push(h)});try{if(r.state.cacheTabs){const f=localStorage.getItem("TABS_ROUTES");o=f?JSON.parse(f):o}}finally{return o}},m=o=>{const f=_.getRoutes();o.forEach(h=>{const $=f.find(j=>j.path===h.path);$&&(h.meta=$.meta||h.meta,h.name=$.name||h.name)}),r.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(o))},u=()=>{const o=E();m(o),r.initTabs(o)},s=async o=>{if(await e.nextTick(),!c.value)return;const f=c.value.offsetWidth,h=c.value.scrollWidth;f<h?(d.scrollable=!0,o&&[...c.value.querySelectorAll(".tabs-card-scroll-item")||[]].forEach(j=>{j.id===`tag${d.activeKey.split("/").join("/")}`&&j.scrollIntoView&&j.scrollIntoView()})):d.scrollable=!1},I=o=>!(o.draggedContext.element.meta.affix||o.relatedContext.element.meta.affix),F=()=>{let o;o=he(),o.listenTo(B.value,()=>s(!0))},b=o=>{if(!o||o.fullPath===i.fullPath)return;if(d.activeKey=o.fullPath,toString.call(o)==="[object String]"){_.replace(o).catch(console.error);return}const f=o;_.replace(f).catch(console.error)},k=(o,f)=>{o.preventDefault(),y.value=f.path==="/home",d.showDropdown=!1,e.nextTick().then(()=>{d.showDropdown=!0,d.dropdownX=o.clientX,d.dropdownY=o.clientY})},P=()=>{if(i.meta.keepAlive){var o=_.currentRoute.value.matched.find(f=>f.name==i.name);o&&o.components?.default?.name}},S=o=>{if(V.value.length===1)return g.warning("这已经是最后一页,不能再关闭了!");if(P(),r.closeCurrentTab(o),d.activeKey===o.fullPath){const f=V.value[Math.max(0,V.value.length-1)];d.activeKey=f.fullPath,_.push(f)}s()},O=o=>{const f=V.value.find(h=>h.fullPath==o.fullPath);f&&S(f)},R=o=>{r.closeOtherTabs(o),d.activeKey=o.fullPath,s()},W=()=>{r.closeAllTabs(),s()},z=e.inject("reloadPage"),K=o=>{switch(o){case"1":z();break;case"2":S(i);break;case"3":R(i);break;case"4":W();break}s(),d.showDropdown=!1},q=(o,f)=>{const h=c.value.scrollLeft,$=f>0&&h+f>=o||f<0&&h+f<=o?o:h+f;if(c.value&&c.value.scrollTo($,0),$!==o)return window.requestAnimationFrame(()=>q(o,f))},X=()=>{const o=c.value.offsetWidth,f=c.value.scrollLeft;if(!f)return;const h=f>o?f-o:0;q(h,(h-f)/20)},J=()=>{const o=c.value.offsetWidth,f=c.value.scrollWidth,h=c.value.scrollLeft;if(f-h<=o)return;const $=f-h>o*2?h+o:f-o;q($,($-h)/20)};return window.addEventListener("beforeunload",()=>{r.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(V.value))}),window.addEventListener("scroll",o=>{let f=o.target.scrollTop||document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;d.isMultiHeaderFixed=f>=64},!0),e.watch(()=>i.fullPath,o=>{C.includes(i.name)||(d.activeKey=o,r.addTab(L(i)),s(!0))},{immediate:!0}),u(),e.onMounted(()=>F()),(o,f)=>(e.openBlock(),e.createElementBlock("div",{class:"box-border tabs-view tabs-view-fix tabs-view-default-background",style:e.normalizeStyle(x.value)},[e.createElementVNode("div",qe,[e.createElementVNode("div",{ref_key:"navWrap",ref:B,class:e.normalizeClass(["tabs-card",{"tabs-card-scrollable":d.scrollable}])},[e.createElementVNode("span",{class:e.normalizeClass(["tabs-card-prev",{"tabs-card-prev-hide":!d.scrollable}]),onClick:X},[e.createVNode(e.unref(n.NIcon),{size:"16",color:"#515a6e"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.LeftOutlined))]),_:1})],2),e.createElementVNode("span",{class:e.normalizeClass(["tabs-card-next",{"tabs-card-next-hide":!d.scrollable}]),onClick:J},[e.createVNode(e.unref(n.NIcon),{size:"16",color:"#515a6e"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.RightOutlined))]),_:1})],2),e.createElementVNode("div",{ref_key:"navScroll",ref:c,class:"tabs-card-scroll"},[e.createVNode(e.unref(_e),{animation:"300","item-key":"fullPath",class:"flex",list:V.value,move:I},{item:e.withCtx(({element:h})=>[e.createElementVNode("div",{class:e.normalizeClass(["tabs-card-scroll-item",{"active-item":d.activeKey===h.fullPath}]),id:`tag${h.fullPath.split("/").join("/")}`,onClick:e.withModifiers($=>b(h),["stop"]),onContextmenu:$=>k($,h)},[e.createElementVNode("span",null,e.toDisplayString(h.meta.title),1),h.meta.affix?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(n.NIcon),{key:0,size:"14",onClick:e.withModifiers($=>O(h),["stop"])},{default:e.withCtx(()=>[e.createVNode(e.unref(T.CloseOutlined))]),_:1},8,["onClick"]))],42,je)]),_:1},8,["list"])],512)],2),e.createElementVNode("div",He,[e.createVNode(e.unref(n.NDropdown),{trigger:"hover",placement:"bottom-end",options:w.value,onSelect:K},{default:e.withCtx(()=>[e.createElementVNode("div",We,[e.createVNode(e.unref(n.NIcon),{size:"16",color:"#515a6e"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.DownOutlined))]),_:1})])]),_:1},8,["options"])]),e.createVNode(e.unref(n.NDropdown),{placement:"bottom-start",show:d.showDropdown,x:d.dropdownX,y:d.dropdownY,options:w.value,onClickoutside:f[0]||(f[0]=h=>d.showDropdown=!1),onSelect:K},null,8,["show","x","y","options"])])],4))}}),[["__scopeId","data-v-50f5202c"]]),Ke=e.defineComponent({__name:"PMenus",setup(t){const a=e.ref([]),l=M.useRoute(),p=M.useRouter(),g=H(),i=e.ref(l.name),_=e.ref(l.matched&&l.matched.length?l.matched.map(C=>C.name):[]),c=C=>{l.name!==C&&(/http(s)?:/.test(C)?window.open(C):p.push({name:C}))},B=C=>{if(!C)return;const L=C.find(x=>_.value.indexOf(x)===-1);_.value=L?[L]:[]},y=()=>{const C=l.matched;_.value=C.map(x=>x.name);const L=l.meta?.activeMenu||"";i.value=L||l.name},r=["/:path(.*)*","/redirect","/redirect/:path(.*)","/login","/oidc-callback"],V=(C,L=[],x=!1)=>{const w=[];if(!C||C.length===0)return w;C=C.sort((E,m)=>{let u=(m.children?.length?1:0)-(E.children?.length?1:0);return u===0&&(u=Number(E.meta?.sort??0)-Number(m.meta?.sort??0)),u});for(const E of C){if(x||E.meta?.hidden||r.includes(E.path.toLowerCase())){L.push(E.name),V(E.children||[],L,!0);continue}const m=E.children?.filter(F=>!F.meta?.hidden)||[],u=m.length===1,s=u?m[0]:E,I={key:s.name,label:s.meta?.title,affix:s.meta?.affix,sort:Number(u?E.meta?.sort??0:s.meta?.sort??0),path:s.path,redirect:s.redirect,icon:u?E.meta?.icon:s.meta?.icon,permission:s.meta?.permission,meta:s.meta,children:void 0};if(s.children&&s.children.length>0&&(I.children=V(s.children,L,x),!u&&(!I.children||I.children.length===0))){L.push(s.name);continue}L.includes(s.name)||(w.push(I),L.push(s.name))}return w},d=()=>{const C=p.getRoutes();a.value=V(C)};return e.watch(()=>l.fullPath,()=>{y()}),e.onMounted(()=>{d(),y()}),(C,L)=>(e.openBlock(),e.createBlock(e.unref(n.NMenu),{class:"h-full",inverted:"",mode:"vertical",options:a.value,collapsed:e.unref(g).state.collapsed,"collapsed-width":64,"collapsed-icon-size":20,indent:24,"expanded-keys":_.value,value:i.value,"onUpdate:value":c,"onUpdate:expandedKeys":B},null,8,["options","collapsed","expanded-keys","value"]))}}),Ye={class:"layout-content-main layout-content-main-fix"},Xe={class:"main-view main-view-fix"},Je=A(e.defineComponent({__name:"PLayout",setup(t){const a=H(),l=e.ref(!1),p=()=>{l.value=!0,e.nextTick(()=>l.value=!1)};return e.provide("reloadPage",p),(g,i)=>{const _=n.NBackTop;return e.openBlock(),e.createBlock(e.unref(n.NLayout),{"has-sider":"",class:"layout",position:"absolute"},{default:e.withCtx(()=>[e.createVNode(e.unref(n.NLayoutSider),{class:"layout-sider",inverted:"","show-trigger":"bar",position:"absolute","collapse-mode":"width","trigger-class":"!-right-5","collapsed-trigger-class":"!-right-5",collapsed:e.unref(a).state.collapsed,"native-scrollbar":!1,"collapsed-width":64,onCollapse:e.unref(a).collapse,onExpand:e.unref(a).collapse},{default:e.withCtx(()=>[e.createVNode(e.unref(n.NFlex),{vertical:""},{default:e.withCtx(()=>[e.createVNode(Pe),e.createVNode(Ke)]),_:1})]),_:1},8,["collapsed","onCollapse","onExpand"]),e.createVNode(e.unref(n.NLayout),null,{default:e.withCtx(()=>[e.createVNode(e.unref(n.NLayoutHeader),{position:"absolute"},{default:e.withCtx(()=>[e.createVNode(Re)]),_:1}),e.createVNode(e.unref(n.NLayoutContent),{class:"layout-content layout-default-background"},{default:e.withCtx(()=>[e.createElementVNode("div",Ye,[e.createVNode(Fe),e.createElementVNode("div",Xe,[e.createVNode(ze,{loading:l.value},null,8,["loading"])])])]),_:1}),e.createVNode(_,{right:20,class:"z-50"})]),_:1})]),_:1})}}}),[["__scopeId","data-v-0bac2e7d"]]),Ze={};function Ge(t,a){const l=e.resolveComponent("router-view");return e.openBlock(),e.createBlock(l)}const ee=D("PEmptyLayout",A(Ze,[["render",Ge]])),te=D("PLayout",Je),oe=D("PApplication",e.defineComponent({__name:"PApplication",props:{theme:{},themeOverrides:{default:{common:{primaryColor:"#2d8cf0",primaryColorHover:"#3c9bff",primaryColorPressed:"#3c9bff",primaryColorSuppl:"#2d8cf0"},LoadingBar:{colorLoading:"#2d8cf0"}}}},setup(t){return(a,l)=>{const p=n.NConfigProvider;return e.openBlock(),e.createBlock(p,{locale:e.unref(n.zhCN),theme:t.theme,"theme-overrides":t.themeOverrides,"date-locale":e.unref(n.dateZhCN)},{default:e.withCtx(()=>[e.createVNode(e.unref(n.NDialogProvider),null,{default:e.withCtx(()=>[e.createVNode(e.unref(n.NNotificationProvider),null,{default:e.withCtx(()=>[e.createVNode(e.unref(n.NMessageProvider),null,{default:e.withCtx(()=>[e.renderSlot(a.$slots,"default")]),_:3})]),_:3})]),_:3})]),_:3},8,["locale","theme","theme-overrides","date-locale"])}}})),ne=D("PModal",e.defineComponent({__name:"PModal",props:{saveBtnText:{default:"保存"},cancelBtnText:{default:"取消"},hideCancelBtn:{type:Boolean,default:!1},hideSaveBtn:{type:Boolean,default:!1},title:{},width:{default:800},height:{default:500},visible:{type:Boolean},onSave:{},onClose:{},onAfterEnter:{},onAfterLeave:{},onUpdateVisible:{}},emits:["update:visible","update:loading"],setup(t,{expose:a,emit:l}){const p=n.useMessage(),g=e.ref(!1),i=e.ref(!1),_=l,c=t,B=async()=>{try{g.value=!0,c.onSave&&await c.onSave()&&y()}catch(d){d instanceof Error&&p.error(d.message),console.error(d)}finally{g.value=!1}},y=()=>{g.value=!1,i.value=!1,_("update:visible",!1)},r=async()=>{try{i.value=!0,c.onClose?await c.onClose()&&y():y()}catch(d){p.error(d.message)}finally{i.value=!1}};return a({open:()=>{g.value=!1,i.value=!1,_("update:visible",!0)},close:y}),(d,C)=>{const L=n.NText,x=n.NButton,w=n.NSpace;return e.openBlock(),e.createBlock(e.unref(n.NModal),e.mergeProps({ref:"$modal",preset:"card"},d.$attrs,{"header-class":"bg-gray-50",show:c.visible,draggable:!0,closable:!1,"close-on-esc":!1,"mask-closable":!1,bordered:!1,style:{width:`${c.width}px`},onClose:y,onAfterEnter:c.onAfterEnter,onAfterLeave:c.onAfterLeave,onUpdateVisible:c.onUpdateVisible}),{header:e.withCtx(()=>[d.$slots.header?e.renderSlot(d.$slots,"header",{key:0}):c.title?(e.openBlock(),e.createBlock(L,{key:1},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:1})):e.createCommentVNode("",!0)]),"header-extra":e.withCtx(()=>[e.renderSlot(d.$slots,"header-extra")]),default:e.withCtx(()=>[e.createElementVNode("div",{class:"overflow-y-auto overflow-hidden mt-5",style:e.normalizeStyle({maxHeight:`${c.height}px`})},[e.renderSlot(d.$slots,"default")],4)]),footer:e.withCtx(()=>[e.renderSlot(d.$slots,"footer")]),action:e.withCtx(()=>[e.createVNode(w,{justify:"end"},{default:e.withCtx(()=>[c.hideSaveBtn?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(x,{key:0,type:"primary",loading:g.value,onClick:B},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.saveBtnText),1)]),_:1},8,["loading"])),e.renderSlot(d.$slots,"action-extra"),c.hideCancelBtn?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(x,{key:1,loading:i.value,onClick:r},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.cancelBtnText),1)]),_:1},8,["loading"]))]),_:3})]),_:3},16,["show","style","onAfterEnter","onAfterLeave","onUpdateVisible"])}}})),ae=D("PLanguage",v),Qe=e.defineComponent({name:"Redirect",setup(){const t=M.useRoute(),a=M.useRouter();return e.onBeforeMount(()=>{const{params:l,query:p}=t,{path:g}=l;a.replace({path:"/"+(Array.isArray(g)?g.join("/"):g),query:p})}),()=>React.createElement(n.NEmpty,null)}}),le=D("PRedirect",Qe),Ue={class:"frame"},ve=["src"],se=D("PIframe",A(e.defineComponent({__name:"PIframe",setup(t){const a=M.useRoute(),l=e.ref(!1),p=e.ref(null),g=e.ref("");e.unref(a.meta)?.frameSrc&&(g.value=e.unref(a.meta)?.frameSrc);function i(){l.value=!1}function _(){e.nextTick(()=>{const c=e.unref(p);if(!c)return;const B=c;B.attachEvent?B.attachEvent("onload",()=>{i()}):c.onload=()=>{i()}})}return e.onMounted(()=>{l.value=!0,_()}),(c,B)=>{const y=n.NSpin;return e.openBlock(),e.createBlock(y,{show:l.value},{default:e.withCtx(()=>[e.createElementVNode("div",Ue,[e.createElementVNode("iframe",{src:g.value,class:"frame-iframe",ref_key:"frameRef",ref:p},null,8,ve)])]),_:1},8,["show"])}}}),[["__scopeId","data-v-161a378e"]])),et={class:"border border-gray-100 rounded-lg"},tt={class:"text-xl font-semibold text-gray-800"},ot={class:"text-sm text-gray-500 mt-1"},re=D("PPage",e.defineComponent({__name:"PPage",props:{icon:{type:Object,required:!1,default:()=>T.AlertOutlined},title:{type:String,required:!0},subtitle:{type:String,required:!1}},setup(t){const a=t;return(l,p)=>{const g=n.NIcon,i=n.NAvatar,_=n.NSpace,c=n.NCard;return e.openBlock(),e.createElementBlock("div",et,[a.title?(e.openBlock(),e.createBlock(c,{key:0,class:"mb-4",bordered:!1,"content-class":"py-4"},{default:e.withCtx(()=>[e.createVNode(_,{align:"center",justify:"space-between"},{default:e.withCtx(()=>[e.createVNode(_,{align:"center",size:16},{default:e.withCtx(()=>[a.icon?(e.openBlock(),e.createBlock(i,{key:0,size:48,class:"bg-linear-to-br from-blue-500 to-indigo-600"},{default:e.withCtx(()=>[e.createVNode(g,{size:24,component:a.icon,color:"#fff"},null,8,["component"])]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",null,[e.createElementVNode("div",tt,e.toDisplayString(a.title),1),e.createElementVNode("div",ot,e.toDisplayString(a.subtitle??a.title+"主页"),1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),l.$slots.search?(e.openBlock(),e.createBlock(c,{key:1,class:"mb-4","content-class":"flex flex-row gap-2",bordered:!1},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"search")]),_:3})):e.createCommentVNode("",!0),l.$slots.default?(e.openBlock(),e.createBlock(c,{key:2,"content-class":"flex flex-row gap-2 p-0!",bordered:!1},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3})):e.createCommentVNode("",!0)])}}})),nt={},at={class:"flex flex-col justify-center page-container"};function lt(t,a){const l=n.NResult;return e.openBlock(),e.createElementBlock("div",at,[e.createVNode(l,{status:"500",title:"服务器错误",description:"抱歉,服务器出错了"})])}const st=A(nt,[["render",lt],["__scopeId","data-v-89cb65c7"]]),rt={},ct={class:"flex flex-col justify-center page-container"};function it(t,a){const l=n.NResult;return e.openBlock(),e.createElementBlock("div",ct,[e.createVNode(l,{status:"404",title:"资源不存在",description:"抱歉,你访问的页面不存在"})])}const dt=A(rt,[["render",it],["__scopeId","data-v-99232671"]]),ft={},pt={class:"flex flex-col justify-center page-container"};function mt(t,a){const l=n.NResult;return e.openBlock(),e.createElementBlock("div",pt,[e.createVNode(l,{status:"403",title:"禁止访问",description:"抱歉,你无权访问该页面"})])}const ut=A(ft,[["render",mt],["__scopeId","data-v-3baa9c16"]]),ce=D("P500",st),ie=D("P404",dt),de=D("P403",ut),fe=Y.defineStore("app-oidc",()=>{const t=e.reactive({});return{setCallback:i=>t.callback=i,callCallback:async i=>await t.callback?.(i),setError:i=>t.error=i,callError:async(i,_)=>await t.error?.(i,_)}}),gt={class:"view-auth-callback"},pe=D("POidc",A(e.defineComponent({__name:"POidc",setup(t){const a=M.useRouter(),{callCallback:l,callError:p}=fe();return e.onMounted(async()=>{try{await l(a)}catch(g){await p(a,g)}}),(g,i)=>(e.openBlock(),e.createElementBlock("div",gt,[...i[0]||(i[0]=[e.createElementVNode("div",{class:"view-auth-callback-content"},[e.createElementVNode("div",{class:"view-auth-callback-spinner"},[e.createElementVNode("span",null,"正在处理登录回调...")])],-1)])]))}}),[["__scopeId","data-v-167395ae"]])),ht=Object.freeze(Object.defineProperty({__proto__:null,P403:de,P404:ie,P500:ce,PApplication:oe,PEmptyLayout:ee,PIframe:se,PLanguage:ae,PLayout:te,PModal:ne,POidc:pe,PPage:re,PRedirect:le,PTable:Q},Symbol.toStringTag,{value:"Module"})),me=(t,a)=>(Object.values(ht).forEach(l=>{l.install&&t.use(l)}),a?.(),t),_t={install:me};N.P403=de,N.P404=ie,N.P500=ce,N.PApplication=oe,N.PEmptyLayout=ee,N.PIframe=se,N.PLanguage=ae,N.PLayout=te,N.PModal=ne,N.POidc=pe,N.PPage=re,N.PRedirect=le,N.PTable=Q,N.default=_t,N.install=me,N.useLanguageStore=U,N.useLayoutStore=H,N.useOidcStore=fe,Object.defineProperties(N,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(C,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("naive-ui"),require("vue"),require("@vicons/antd"),require("pinia"),require("vue-router"),require("element-resize-detector"),require("vuedraggable")):typeof define=="function"&&define.amd?define(["exports","naive-ui","vue","@vicons/antd","pinia","vue-router","element-resize-detector","vuedraggable"],n):(C=typeof globalThis<"u"?globalThis:C||self,n(C.naiveplus={},C.naiveUi,C.Vue,C.antd,C.pinia,C.vueRouter,C.elementResizeDetectorMaker,C.Draggable))})(this,(function(C,n,e,T,K,I,me,ue){"use strict";const pe=t=>!t||!t.getBoundingClientRect?0:t.getBoundingClientRect(),he=t=>{const a=document.documentElement,s=a.scrollLeft,u=a.scrollTop,h=a.clientLeft,d=a.clientTop,_=window.pageXOffset,c=window.pageYOffset,E=pe(t),{left:V,top:r,width:N,height:i}=E,m=(_||s)-(h||0),x=(c||u)-(d||0),P=V+_,b=r+c,L=P-m,f=b-x,y=window.document.documentElement.clientWidth,l=window.document.documentElement.clientHeight;return{left:L,top:f,right:y-N-L,bottom:l-i-f,rightIncludeBody:y-L,bottomIncludeBody:l-f}},ge={class:"text-lg font-medium"},_e={id:"data-content"},ye={key:0,class:"rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"},be=e.defineComponent({__name:"PTable",props:{title:{},idField:{default:"id"},addPermission:{},editPermission:{},deletePermission:{},columns:{},onLoad:{},onDelete:{},onAdd:{},onEdit:{},onCheckPermission:{}},setup(t,{expose:a}){const s=e.ref(null),u=n.useDialog(),h=n.useMessage(),d=e.ref(!1),_=e.ref([]),c=e.ref([]),E=e.ref(!1),V=e.ref(!1),r=e.ref(!1),N=e.ref({}),i=e.computed(()=>V.value||r.value||Object.keys(N.value).length>0),m=t,x=async g=>!g||!m.onCheckPermission?!0:await m.onCheckPermission(g)??!1;e.watch(m,async()=>{E.value=!!m.onAdd&&await x(m.addPermission),V.value=!!m.onEdit&&await x(m.editPermission),r.value=!!m.onDelete&&await x(m.deletePermission);const g=m.columns.find(w=>w.key==="action");if(g&&g.action)for(const w of g.action){if(!w.permission)continue;const B=await x(w.permission.toLowerCase());B&&(N.value[w.permission]=B)}},{immediate:!0});const P=e.computed(()=>{const g=[{type:"selection",fixed:"left"}],w=[];return m.columns.forEach(B=>{if(B.key!=="action"){g.push({title:B.title,key:B.key,width:B.width,fixed:B.fixed??!1,render:B.render,ellipsis:B.ellipsis?{tooltip:!0}:!1});return}!B.action||B.action.length<=0||!i.value||w.push({title:"操作",key:"actions",width:100,fixed:"right",render:S=>{const M=[];if(f(M,S),y(M,S),l(M,S,B.action),!(M.length<=0))return e.h(n.NDropdown,{options:M,placement:"bottom-start"},{default:()=>e.h(n.NButton,{size:"small",type:"primary"},{default:()=>["操作",e.h(n.NIcon,()=>e.h(T.MoreOutlined))]})})}})}),[...g,...i.value?w:[]]}),b=e.ref({page:1,itemCount:0,pageSize:10,pageSizes:[10,20,30,50],showSizePicker:!0,onChange:async g=>{b.value.page=g,await z()},onUpdatePageSize:async g=>{b.value.pageSize=g,await z()}}),L=e.computed(()=>{const g=e.unref(s);if(!g)return;const w=g?.$el,B=w.querySelector(".n-data-table-thead "),{bottomIncludeBody:S}=he(B),M=48;let A=12,o=25;const p=w.querySelector(".n-data-table__pagination");if(p){const $=p.offsetHeight;A+=$||0}else A+=28;return S-(M+A+o)}),f=async(g,w)=>{V.value&&g.push({label:"编辑",key:"edit",icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.EditOutlined)}),props:{onClick:async()=>await m.onEdit(w)}})},y=async(g,w)=>{r.value&&g.push({label:"删除",key:"delete",icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.DeleteOutlined)}),props:{onClick:()=>H(w)}})},l=(g,w,B)=>{if(B)for(const S of B){if(S.key==="edit"||S.key==="delete"||!S.permission||!N.value[S.permission])return;g.push({label:S.name,key:S.key,icon:S.icon&&(()=>e.h(n.NIcon,null,{default:()=>e.h(S.icon)})),props:{onClick:()=>S.action(w)}})}},D=async()=>await z(),H=g=>F([g]),Y=()=>{const g=j();F(g)},F=g=>{!g||g.length===0||u.warning({title:"警告",content:"删除数据不可恢复, 确认删除吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(m.onDelete)try{await m.onDelete(g)?(z(),h.success("删除成功")):h.error("删除失败")}catch(w){h.error(w.message)}}})},z=async()=>{if(m.onLoad&&!d.value){d.value=!0;try{var{items:g,totalCount:w}=await m.onLoad(b.value.page,b.value.pageSize);c.value=g,b.value.itemCount=w}catch(B){h.error(B.message)}finally{d.value=!1}}},j=()=>_.value?c.value.filter(g=>_.value.includes(g.id)).map(g=>e.toRaw(g)):[],X=()=>j()[0],J=()=>e.toRaw(c.value);return e.onMounted(async()=>await z()),a({getData:J,getSelectedRow:X,getSelectedRows:j,refreshData:z,resetPage:()=>{b.value.page=1}}),(g,w)=>{const B=n.NTooltip,S=n.NSpace,M=n.NDataTable;return e.openBlock(),e.createBlock(e.unref(n.NCard),{bordered:!1},{header:e.withCtx(()=>[e.createVNode(S,{justify:"space-between",align:"center",class:"w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",ge,e.toDisplayString(t.title),1),e.createVNode(S,null,{default:e.withCtx(()=>[E.value?(e.openBlock(),e.createBlock(B,{key:0,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:m.onAdd},{default:e.withCtx(()=>[e.createVNode(e.unref(T.PlusSquareOutlined))]),_:1},8,["onClick"])]),default:e.withCtx(()=>[w[1]||(w[1]=e.createElementVNode("span",null,"新增",-1))]),_:1})):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createBlock(B,{key:1,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:Y},{default:e.withCtx(()=>[e.createVNode(e.unref(T.DeleteOutlined))]),_:1})]),default:e.withCtx(()=>[w[2]||(w[2]=e.createElementVNode("span",null,"删除",-1))]),_:1})):e.createCommentVNode("",!0),e.createVNode(B,{trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",class:"cursor-pointer hover:text-blue-600",onClick:D},{default:e.withCtx(()=>[e.createVNode(e.unref(T.ReloadOutlined))]),_:1})]),default:e.withCtx(()=>[w[3]||(w[3]=e.createElementVNode("span",null,"刷新",-1))]),_:1})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",_e,[g.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",ye,[e.renderSlot(g.$slots,"toolbar")])):e.createCommentVNode("",!0),e.createVNode(M,{remote:"",ref_key:"$table",ref:s,"checked-row-keys":_.value,"onUpdate:checkedRowKeys":w[0]||(w[0]=A=>_.value=A),"max-height":L.value,loading:d.value,bordered:!1,"single-line":!1,columns:P.value,data:c.value,pagination:b.value,"row-key":A=>A[t.idField]},null,8,["checked-row-keys","max-height","loading","columns","data","pagination","row-key"])])]),_:3})}}}),O=(t,a)=>{const s=a;return s.install=function(u){u.component(t,a)},a},Z=O("PTable",be),ke=["Redirect","RedirectSon","login"],q=K.defineStore("p-layout",()=>{const t=e.reactive({collapsed:!1,title:"输入项目名称",logo:"https://picsum.photos/id/1/100/100",avatar:"",uid:"",uname:"",tabs:[],menus:[],cacheTabs:!1,enableLanguage:!1});return{state:t,initMenus:f=>{f.sort((y,l)=>y.affix&&!l.affix?-1:!y.affix&&l.affix?1:Number(l.sort??0)-Number(y.sort??0)),t.menus=f},getMenus:()=>t.menus,initTabs:f=>{f.sort((y,l)=>y.meta.affix&&!l.meta.affix?-1:!y.meta.affix&&l.meta.affix?1:Number(l.meta.sort??0)-Number(y.meta.sort??0)),t.tabs=f},addTab:f=>ke.includes(f.name)?!1:(t.tabs?.some(l=>l.fullPath==f.fullPath)||t.tabs?.push(f),!0),getCurrentTab:()=>{const f=I.useRoute();return t.tabs.find(y=>y.fullPath==f.fullPath)},closeCurrentTab:f=>{const y=t.tabs.findIndex(l=>l.fullPath==f.fullPath);t.tabs.splice(y,1)},closeAllTabs:()=>{t.tabs=t.tabs.filter(f=>f?.meta?.affix??!1)},closeOtherTabs:f=>{t.tabs=t.tabs.filter(y=>y.fullPath==f.fullPath||(y?.meta?.affix??!1))},closeLeftTabs:f=>{const y=t.tabs.findIndex(l=>l.fullPath==f.fullPath);t.tabs=t.tabs.filter((l,D)=>D>=y||(l?.meta?.affix??!1))},closeRightTabs:f=>{const y=t.tabs.findIndex(l=>l.fullPath==f.fullPath);t.tabs=t.tabs.filter((l,D)=>D<=y||(l?.meta?.affix??!1))},collapse:()=>{t.collapsed=!t.collapsed},setTitle:f=>{t.title=f},setLogo:f=>{t.logo=f},setUser:(f,y)=>{t.uid=f,t.uname=y},setSettingPages:f=>{t.settingPages=f},setLogout:f=>{t.logout=f},enableLanguage:f=>{t.enableLanguage=f}}}),we={class:"logo"},Ce=e.defineComponent({__name:"PLogo",setup(t){const a=q();return(s,u)=>(e.openBlock(),e.createElementBlock("div",we,[e.createVNode(e.unref(n.NAvatar),{color:"var(--color-logo)",size:32,src:e.unref(a).state.logo,class:e.normalizeClass({"mr-2":!e.unref(a).state.collapsed})},null,8,["src","class"]),e.withDirectives(e.createElementVNode("h1",{class:"font-bold ease-in-out ml-2 logo-size"},e.toDisplayString(e.unref(a).state.title),513),[[e.vShow,!e.unref(a).state.collapsed]])]))}}),R=(t,a)=>{const s=t.__vccOpts||t;for(const[u,h]of a)s[u]=h;return s},Ne=R(Ce,[["__scopeId","data-v-e48aeefa"]]),Pe={translationApiUrl:"https://translate.zvo.cn/api",defaultLanguage:"chinese",currentLanguage:"",options:[],initLanguages:async()=>[],selectLanguage:async t=>{}},G=K.defineStore("language",()=>{const t=e.ref(Pe),a=async()=>(t.value.options.length===0&&(t.value.options=await t.value.initLanguages()),t.value.options);return{select:async r=>{if(t.value.currentLanguage===r)return;const N=(await a()).find(i=>i.key===r);N&&(t.value.currentLanguage=N.key,t.value.selectLanguage(N))},selectLanguageCallback:async r=>{t.value.selectLanguage=r},initLanguagesCallback:async r=>{t.value.initLanguages=r},getLanguages:a,getCurrentLanguage:async()=>{if(t.value.currentLanguage)return(await a()).find(r=>r.key===t.value.currentLanguage)},setTranslationApiUrl:r=>{t.value.translationApiUrl=r},getTranslationApiUrl:()=>t.value.translationApiUrl,getDefaultLanguage:()=>t.value.defaultLanguage?t.value.defaultLanguage:"chinese_simplified",setDefaultLanguage:r=>{(r==="Chinese"||r==="chinese")&&(r="chinese_simplified"),t.value.defaultLanguage=r}}}),xe={key:1},Q=e.defineComponent({__name:"PLanguage",setup(t){const{select:a,getLanguages:s,getCurrentLanguage:u,getDefaultLanguage:h,getTranslationApiUrl:d}=G(),_=e.ref(),c=e.ref([]),E=async r=>await a(r),V=async()=>{const r=window.translate;r&&(r.selectLanguageTag.show=!1,r.selectLanguageTag.languages=(await s()).map(N=>N.key).join(","),r.ignore.class.push("ignore-translate-flag"),r.ignore.id.push("ignore-translation"),r.language.setLocal(h()),r.request.api.translate="api/v1/translation",r.request.api.connectTest="api/v1/translation/connect-test",r.request.api.init="api/v1/translation/init",r.request.api.language="api/v1/translation/language",r.request.setHost(d()),r.request.listener.start(),r.listener.start(),r.whole.enableAll(),r.execute())};return e.onMounted(async()=>{await e.nextTick(),await V(),_.value=await u(),c.value=await s()}),(r,N)=>{const i=n.NIcon,m=n.NButton;return c.value.length>0?(e.openBlock(),e.createBlock(e.unref(n.NDropdown),{key:0,id:"ignore-translation",placement:"bottom-start",trigger:"hover",class:"flex flex-col justify-center h-full ignore",onSelect:E,options:c.value},{default:e.withCtx(()=>[e.createVNode(m,{quaternary:"",type:"info"},{default:e.withCtx(()=>[_.value?(e.openBlock(),e.createElementBlock("label",xe,e.toDisplayString(_.value?.label),1)):(e.openBlock(),e.createBlock(i,{key:0,size:"18"},{default:e.withCtx(()=>[...N[0]||(N[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},[e.createElementVNode("path",{d:"M478.33 433.6l-90-218a22 22 0 0 0-40.67 0l-90 218a22 22 0 1 0 40.67 16.79L316.66 406h102.67l18.33 44.39A22 22 0 0 0 458 464a22 22 0 0 0 20.32-30.4zM334.83 362L368 281.65L401.17 362z",fill:"currentColor"}),e.createElementVNode("path",{d:"M267.84 342.92a22 22 0 0 0-4.89-30.7c-.2-.15-15-11.13-36.49-34.73c39.65-53.68 62.11-114.75 71.27-143.49H330a22 22 0 0 0 0-44H214V70a22 22 0 0 0-44 0v20H54a22 22 0 0 0 0 44h197.25c-9.52 26.95-27.05 69.5-53.79 108.36c-31.41-41.68-43.08-68.65-43.17-68.87a22 22 0 0 0-40.58 17c.58 1.38 14.55 34.23 52.86 83.93c.92 1.19 1.83 2.35 2.74 3.51c-39.24 44.35-77.74 71.86-93.85 80.74a22 22 0 1 0 21.07 38.63c2.16-1.18 48.6-26.89 101.63-85.59c22.52 24.08 38 35.44 38.93 36.1a22 22 0 0 0 30.75-4.9z",fill:"currentColor"})],-1)])]),_:1}))]),_:1})]),_:1},8,["options"])):e.createCommentVNode("",!0)}}}),Be={class:"layout-header"},Ve={class:"layout-header-left"},Le={class:"link-text"},Se={key:1,class:"link-text"},Ee={class:"layout-header-right"},Te={key:0,class:"layout-header-trigger-min"},$e={class:"layout-header-trigger layout-header-trigger-min"},Oe={class:"layout-header-trigger layout-header-trigger-min"},De={class:"avatar"},Ie=R(e.defineComponent({__name:"PHeader",setup(t){const a=n.useMessage(),s=n.useDialog(),u=q(),h=I.useRouter(),d=I.useRoute(),_=e.inject("reloadPage"),c=P=>h.push({name:P}),E=e.computed(()=>V(d.matched)),V=P=>P.map(b=>{const L={key:b.name,label:b.meta.title,icon:b.meta.icon,meta:b.meta,disabled:b.path==="/",children:void 0};return b.children&&b.children.length>0&&(L.children=V(b.children)),L}),r=e.ref(!1),N=()=>{document.fullscreenElement?document.exitFullscreen&&(document.exitFullscreen(),r.value=!1):(document.documentElement.requestFullscreen(),r.value=!0)},i=e.computed(()=>{const P=[];return P.push({label:"退出登录",key:"logout"}),u.state.settingPages&&u.state.settingPages.length>0&&u.state.settingPages.forEach(b=>{P.push({label:b.title,key:b.route})}),P}),m=P=>{P==="logout"?x():h.push({name:P})},x=()=>{s.info({title:"提示",content:"您确定要退出登录吗",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(u.state.logout)try{await u.state.logout(),localStorage.removeItem("TABS-ROUTES"),a.error("退出成功")}catch(P){console.error(P),a.error("退出登录失败")}finally{location.reload()}else a.error("没有配置登出接口, 请配置[usePLayoutStore.logout]方法")},onNegativeClick:()=>{}})};return(P,b)=>{const L=n.NTooltip,f=n.NDivider,y=n.NAvatar;return e.openBlock(),e.createElementBlock("div",Be,[e.createElementVNode("div",Ve,[e.createElementVNode("div",{class:"ml-1 layout-header-trigger layout-header-trigger-min",onClick:b[0]||(b[0]=(...l)=>e.unref(u).collapse&&e.unref(u).collapse(...l))},[e.unref(u).state.collapsed?(e.openBlock(),e.createBlock(e.unref(n.NIcon),{key:0,size:"18"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.MenuUnfoldOutlined))]),_:1})):(e.openBlock(),e.createBlock(e.unref(n.NIcon),{key:1,size:"18"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.MenuFoldOutlined))]),_:1}))]),e.createElementVNode("div",{class:"mr-1 layout-header-trigger layout-header-trigger-min",onClick:b[1]||(b[1]=(...l)=>e.unref(_)&&e.unref(_)(...l))},[e.createVNode(e.unref(n.NIcon),{size:"18"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.ReloadOutlined))]),_:1})]),e.createVNode(e.unref(n.NBreadcrumb),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,l=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:l.label},[l.label?(e.openBlock(),e.createBlock(e.unref(n.NBreadcrumbItem),{key:0},{default:e.withCtx(()=>[l.children&&l.children.length?(e.openBlock(),e.createBlock(e.unref(n.NDropdown),{key:0,options:l.children,onSelect:c},{default:e.withCtx(()=>[e.createElementVNode("span",Le,[l.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.icon),{key:0})):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(l.label),1)])]),_:2},1032,["options"])):(e.openBlock(),e.createElementBlock("span",Se,[l.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.icon),{key:0})):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(l.label),1)]))]),_:2},1024)):e.createCommentVNode("",!0)],64))),128))]),_:1})]),e.createElementVNode("div",Ee,[e.unref(u).state.enableLanguage?(e.openBlock(),e.createElementBlock("div",Te,[e.createVNode(Q)])):e.createCommentVNode("",!0),e.createElementVNode("div",$e,[e.createVNode(L,{placement:"bottom"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(n.NIcon),{size:"18",onClick:e.withModifiers(N,["stop"])},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(T.FullscreenExitOutlined),{key:1})):(e.openBlock(),e.createBlock(e.unref(T.FullscreenOutlined),{key:0}))]),_:1})]),default:e.withCtx(()=>[b[2]||(b[2]=e.createElementVNode("span",null,"全屏",-1))]),_:1})]),e.createElementVNode("div",Oe,[e.createVNode(e.unref(n.NDropdown),{trigger:"hover",onSelect:m,options:i.value},{default:e.withCtx(()=>[e.createElementVNode("div",De,[e.createElementVNode("span",null,e.toDisplayString(e.unref(u).state.uname),1),e.createVNode(f,{vertical:""}),e.createVNode(y,{round:"",src:e.unref(u).state.avatar},null,8,["src"])])]),_:1},8,["options"])])])])}}}),[["__scopeId","data-v-563e4e55"]]),Me={class:"mt-1"},Re=e.defineComponent({__name:"PContent",props:{loading:{type:Boolean,default:!1}},setup(t){return(a,s)=>{const u=e.resolveComponent("RouterView");return e.openBlock(),e.createElementBlock("div",Me,[t.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(u,{key:0},{default:e.withCtx(({Component:h,route:d})=>[(e.openBlock(),e.createBlock(e.KeepAlive,null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h),{key:d.fullPath}))],1024))]),_:1}))])}}}),Ae={class:"tabs-view-main"},ze=["id","onClick","onContextmenu"],qe={class:"tabs-close"},je={class:"tabs-close-btn"},He=R(e.defineComponent({__name:"PTabs",setup(t){e.useCssVars(o=>({v4f917f8c:s.value,v1c2fb72a:u.value}));const a=n.useThemeVars(),s=e.computed(()=>a.value.cardColor),u=e.computed(()=>a.value.textColor1),h=n.useMessage(),d=I.useRoute(),_=I.useRouter(),c=e.ref(null),E=e.ref(null),V=e.ref(!1),r=q(),N=e.computed(()=>r.state.tabs),i=e.reactive({activeKey:d.fullPath,scrollable:!0,dropdownX:0,dropdownY:0,showDropdown:!1,isMultiHeaderFixed:!0,multiTabsSetting:!0}),m=["Login","Redirect","ErrorPage"],x=o=>({meta:o.meta,name:o.name,fullPath:o.fullPath??o.path,path:o.path,hash:o.hash??"",query:o.query??{},params:o.params??{}}),P=e.computed(()=>{const k=r.state.collapsed?"64px":"272px";return{left:k,width:`calc(100% - ${k})`}}),b=e.computed(()=>{const o=N.value.length<=1;return[{label:"刷新当前",key:"1",icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.ReloadOutlined)})},{label:"关闭当前",key:"2",disabled:V.value||o,icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.CloseOutlined)})},{label:"关闭其他",key:"3",disabled:o,icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.ColumnWidthOutlined)})},{label:"关闭全部",key:"4",disabled:o,icon:()=>e.h(n.NIcon,null,{default:()=>e.h(T.MinusOutlined)})}]}),L=()=>{let o=[x(d)];_.getRoutes().filter(p=>p.meta.affix).forEach(p=>{const k=x(p);o.every($=>$.name!==k.name)&&o.push(k)});try{if(r.state.cacheTabs){const p=localStorage.getItem("TABS_ROUTES");o=p?JSON.parse(p):o}}finally{return o}},f=o=>{const p=_.getRoutes();o.forEach(k=>{const $=p.find(W=>W.path===k.path);$&&(k.meta=$.meta||k.meta,k.name=$.name||k.name)}),r.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(o))},y=()=>{const o=L();f(o),r.initTabs(o)},l=async o=>{if(await e.nextTick(),!c.value)return;const p=c.value.offsetWidth,k=c.value.scrollWidth;p<k?(i.scrollable=!0,o&&[...c.value.querySelectorAll(".tabs-card-scroll-item")||[]].forEach(W=>{W.id===`tag${i.activeKey.split("/").join("/")}`&&W.scrollIntoView&&W.scrollIntoView()})):i.scrollable=!1},D=o=>!(o.draggedContext.element.meta.affix||o.relatedContext.element.meta.affix),H=()=>{let o;o=me(),o.listenTo(E.value,()=>l(!0))},Y=o=>{if(!o||o.fullPath===d.fullPath)return;if(i.activeKey=o.fullPath,toString.call(o)==="[object String]"){_.replace(o).catch(console.error);return}const p=o;_.replace(p).catch(console.error)},F=(o,p)=>{o.preventDefault(),V.value=p.path==="/home",i.showDropdown=!1,e.nextTick().then(()=>{i.showDropdown=!0,i.dropdownX=o.clientX,i.dropdownY=o.clientY})},z=()=>{if(d.meta.keepAlive){var o=_.currentRoute.value.matched.find(p=>p.name==d.name);o&&o.components?.default?.name}},j=o=>{if(N.value.length===1)return h.warning("这已经是最后一页,不能再关闭了!");if(z(),r.closeCurrentTab(o),i.activeKey===o.fullPath){const p=N.value[Math.max(0,N.value.length-1)];i.activeKey=p.fullPath,_.push(p)}l()},X=o=>{const p=N.value.find(k=>k.fullPath==o.fullPath);p&&j(p)},J=o=>{r.closeOtherTabs(o),i.activeKey=o.fullPath,l()},g=()=>{r.closeAllTabs(),l()},w=e.inject("reloadPage"),B=o=>{switch(o){case"1":w();break;case"2":j(d);break;case"3":J(d);break;case"4":g();break}l(),i.showDropdown=!1},S=(o,p)=>{const k=c.value.scrollLeft,$=p>0&&k+p>=o||p<0&&k+p<=o?o:k+p;if(c.value&&c.value.scrollTo($,0),$!==o)return window.requestAnimationFrame(()=>S(o,p))},M=()=>{const o=c.value.offsetWidth,p=c.value.scrollLeft;if(!p)return;const k=p>o?p-o:0;S(k,(k-p)/20)},A=()=>{const o=c.value.offsetWidth,p=c.value.scrollWidth,k=c.value.scrollLeft;if(p-k<=o)return;const $=p-k>o*2?k+o:p-o;S($,($-k)/20)};return window.addEventListener("beforeunload",()=>{r.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(N.value))}),window.addEventListener("scroll",o=>{let p=o.target.scrollTop||document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;i.isMultiHeaderFixed=p>=64},!0),e.watch(()=>d.fullPath,o=>{m.includes(d.name)||(i.activeKey=o,r.addTab(x(d)),l(!0))},{immediate:!0}),y(),e.onMounted(()=>H()),(o,p)=>(e.openBlock(),e.createElementBlock("div",{class:"box-border tabs-view tabs-view-fix tabs-view-default-background",style:e.normalizeStyle(P.value)},[e.createElementVNode("div",Ae,[e.createElementVNode("div",{ref_key:"navWrap",ref:E,class:e.normalizeClass(["tabs-card",{"tabs-card-scrollable":i.scrollable}])},[e.createElementVNode("span",{class:e.normalizeClass(["tabs-card-prev",{"tabs-card-prev-hide":!i.scrollable}]),onClick:M},[e.createVNode(e.unref(n.NIcon),{size:"16",color:"#515a6e"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.LeftOutlined))]),_:1})],2),e.createElementVNode("span",{class:e.normalizeClass(["tabs-card-next",{"tabs-card-next-hide":!i.scrollable}]),onClick:A},[e.createVNode(e.unref(n.NIcon),{size:"16",color:"#515a6e"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.RightOutlined))]),_:1})],2),e.createElementVNode("div",{ref_key:"navScroll",ref:c,class:"tabs-card-scroll"},[e.createVNode(e.unref(ue),{animation:"300","item-key":"fullPath",class:"flex",list:N.value,move:D},{item:e.withCtx(({element:k})=>[e.createElementVNode("div",{class:e.normalizeClass(["tabs-card-scroll-item",{"active-item":i.activeKey===k.fullPath}]),id:`tag${k.fullPath.split("/").join("/")}`,onClick:e.withModifiers($=>Y(k),["stop"]),onContextmenu:$=>F($,k)},[e.createElementVNode("span",null,e.toDisplayString(k.meta.title),1),k.meta.affix?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(n.NIcon),{key:0,size:"14",onClick:e.withModifiers($=>X(k),["stop"])},{default:e.withCtx(()=>[e.createVNode(e.unref(T.CloseOutlined))]),_:1},8,["onClick"]))],42,ze)]),_:1},8,["list"])],512)],2),e.createElementVNode("div",qe,[e.createVNode(e.unref(n.NDropdown),{trigger:"hover",placement:"bottom-end",options:b.value,onSelect:B},{default:e.withCtx(()=>[e.createElementVNode("div",je,[e.createVNode(e.unref(n.NIcon),{size:"16",color:"#515a6e"},{default:e.withCtx(()=>[e.createVNode(e.unref(T.DownOutlined))]),_:1})])]),_:1},8,["options"])]),e.createVNode(e.unref(n.NDropdown),{placement:"bottom-start",show:i.showDropdown,x:i.dropdownX,y:i.dropdownY,options:b.value,onClickoutside:p[0]||(p[0]=k=>i.showDropdown=!1),onSelect:B},null,8,["show","x","y","options"])])],4))}}),[["__scopeId","data-v-50f5202c"]]),We=e.defineComponent({__name:"PMenus",setup(t){const a=e.ref([]),s=I.useRoute(),u=I.useRouter(),h=q(),d=e.ref(s.name),_=e.ref(s.matched&&s.matched.length?s.matched.map(m=>m.name):[]),c=m=>{s.name!==m&&(/http(s)?:/.test(m)?window.open(m):u.push({name:m}))},E=m=>{if(!m)return;const x=m.find(P=>_.value.indexOf(P)===-1);_.value=x?[x]:[]},V=()=>{const m=s.matched;_.value=m.map(P=>P.name);const x=s.meta?.activeMenu||"";d.value=x||s.name},r=["/:path(.*)*","/redirect","/redirect/:path(.*)","/login","/oidc-callback"],N=(m,x=[],P=!1)=>{const b=[];if(!m||m.length===0)return b;m=m.sort((L,f)=>{let y=(f.children?.length?1:0)-(L.children?.length?1:0);return y===0&&(y=Number(L.meta?.sort??0)-Number(f.meta?.sort??0)),y});for(const L of m){if(P||L.meta?.hidden||r.includes(L.path.toLowerCase())){x.push(L.name),N(L.children||[],x,!0);continue}const f=L.children?.filter(H=>!H.meta?.hidden)||[],y=f.length===1,l=y?f[0]:L,D={key:l.name,label:l.meta?.title,affix:l.meta?.affix,sort:Number(y?L.meta?.sort??0:l.meta?.sort??0),path:l.path,redirect:l.redirect,icon:y?L.meta?.icon:l.meta?.icon,permission:l.meta?.permission,meta:l.meta,children:void 0};if(l.children&&l.children.length>0&&(D.children=N(l.children,x,P),!y&&(!D.children||D.children.length===0))){x.push(l.name);continue}x.includes(l.name)||(b.push(D),x.push(l.name))}return b},i=()=>{const m=u.getRoutes();a.value=N(m)};return e.watch(()=>s.fullPath,()=>{V()}),e.onMounted(()=>{i(),V()}),(m,x)=>(e.openBlock(),e.createBlock(e.unref(n.NMenu),{class:"h-full",inverted:"",mode:"vertical",options:a.value,collapsed:e.unref(h).state.collapsed,"collapsed-width":64,"collapsed-icon-size":20,indent:24,"expanded-keys":_.value,value:d.value,"onUpdate:value":c,"onUpdate:expandedKeys":E},null,8,["options","collapsed","expanded-keys","value"]))}}),Fe={class:"layout-content-main layout-content-main-fix"},Ke={class:"main-view main-view-fix"},Ye=R(e.defineComponent({__name:"PLayout",setup(t){const a=q(),s=e.ref(!1),u=()=>{s.value=!0,e.nextTick(()=>s.value=!1)};return e.provide("reloadPage",u),(h,d)=>{const _=n.NBackTop;return e.openBlock(),e.createBlock(e.unref(n.NLayout),{"has-sider":"",class:"layout",position:"absolute"},{default:e.withCtx(()=>[e.createVNode(e.unref(n.NLayoutSider),{class:"layout-sider",inverted:"","show-trigger":"bar",position:"absolute","collapse-mode":"width","trigger-class":"!-right-5","collapsed-trigger-class":"!-right-5",collapsed:e.unref(a).state.collapsed,"native-scrollbar":!1,"collapsed-width":64,onCollapse:e.unref(a).collapse,onExpand:e.unref(a).collapse},{default:e.withCtx(()=>[e.createVNode(e.unref(n.NFlex),{vertical:""},{default:e.withCtx(()=>[e.createVNode(Ne),e.createVNode(We)]),_:1})]),_:1},8,["collapsed","onCollapse","onExpand"]),e.createVNode(e.unref(n.NLayout),null,{default:e.withCtx(()=>[e.createVNode(e.unref(n.NLayoutHeader),{position:"absolute"},{default:e.withCtx(()=>[e.createVNode(Ie)]),_:1}),e.createVNode(e.unref(n.NLayoutContent),{class:"layout-content layout-default-background"},{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[e.createVNode(He),e.createElementVNode("div",Ke,[e.createVNode(Re,{loading:s.value},null,8,["loading"])])])]),_:1}),e.createVNode(_,{right:20,class:"z-50"})]),_:1})]),_:1})}}}),[["__scopeId","data-v-0bac2e7d"]]),Xe={};function Je(t,a){const s=e.resolveComponent("router-view");return e.openBlock(),e.createBlock(s)}const U=O("PEmptyLayout",R(Xe,[["render",Je]])),v=O("PLayout",Ye),ee=O("PApplication",e.defineComponent({__name:"PApplication",props:{theme:{},themeOverrides:{default:{common:{primaryColor:"#2d8cf0",primaryColorHover:"#3c9bff",primaryColorPressed:"#3c9bff",primaryColorSuppl:"#2d8cf0"},LoadingBar:{colorLoading:"#2d8cf0"}}}},setup(t){return(a,s)=>{const u=n.NConfigProvider;return e.openBlock(),e.createBlock(u,{locale:e.unref(n.zhCN),theme:t.theme,"theme-overrides":t.themeOverrides,"date-locale":e.unref(n.dateZhCN)},{default:e.withCtx(()=>[e.createVNode(e.unref(n.NDialogProvider),null,{default:e.withCtx(()=>[e.createVNode(e.unref(n.NNotificationProvider),null,{default:e.withCtx(()=>[e.createVNode(e.unref(n.NMessageProvider),null,{default:e.withCtx(()=>[e.renderSlot(a.$slots,"default")]),_:3})]),_:3})]),_:3})]),_:3},8,["locale","theme","theme-overrides","date-locale"])}}})),te=O("PModal",e.defineComponent({__name:"PModal",props:{saveBtnText:{default:"保存"},cancelBtnText:{default:"取消"},hideCancelBtn:{type:Boolean,default:!1},hideSaveBtn:{type:Boolean,default:!1},title:{},width:{default:800},height:{default:500},visible:{type:Boolean},onSave:{},onClose:{},onAfterEnter:{},onAfterLeave:{},onUpdateVisible:{}},emits:["update:visible","update:loading"],setup(t,{expose:a,emit:s}){const u=n.useMessage(),h=e.ref(!1),d=e.ref(!1),_=s,c=t,E=async()=>{try{h.value=!0,c.onSave&&await c.onSave()&&V()}catch(i){i instanceof Error&&u.error(i.message),console.error(i)}finally{h.value=!1}},V=()=>{h.value=!1,d.value=!1,_("update:visible",!1)},r=async()=>{try{d.value=!0,c.onClose?await c.onClose()&&V():V()}catch(i){u.error(i.message)}finally{d.value=!1}};return a({open:()=>{h.value=!1,d.value=!1,_("update:visible",!0)},close:V}),(i,m)=>{const x=n.NText,P=n.NButton,b=n.NSpace;return e.openBlock(),e.createBlock(e.unref(n.NModal),e.mergeProps({ref:"$modal",preset:"card"},i.$attrs,{"header-class":"bg-gray-50",show:c.visible,draggable:!0,closable:!1,"close-on-esc":!1,"mask-closable":!1,bordered:!1,style:{width:`${c.width}px`},onClose:V,onAfterEnter:c.onAfterEnter,onAfterLeave:c.onAfterLeave,onUpdateVisible:c.onUpdateVisible}),{header:e.withCtx(()=>[i.$slots.header?e.renderSlot(i.$slots,"header",{key:0}):c.title?(e.openBlock(),e.createBlock(x,{key:1},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:1})):e.createCommentVNode("",!0)]),"header-extra":e.withCtx(()=>[e.renderSlot(i.$slots,"header-extra")]),default:e.withCtx(()=>[e.createElementVNode("div",{class:"overflow-y-auto overflow-hidden mt-5",style:e.normalizeStyle({maxHeight:`${c.height}px`})},[e.renderSlot(i.$slots,"default")],4)]),footer:e.withCtx(()=>[e.renderSlot(i.$slots,"footer")]),action:e.withCtx(()=>[e.createVNode(b,{justify:"end"},{default:e.withCtx(()=>[c.hideSaveBtn?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(P,{key:0,type:"primary",loading:h.value,onClick:E},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.saveBtnText),1)]),_:1},8,["loading"])),e.renderSlot(i.$slots,"action-extra"),c.hideCancelBtn?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(P,{key:1,loading:d.value,onClick:r},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.cancelBtnText),1)]),_:1},8,["loading"]))]),_:3})]),_:3},16,["show","style","onAfterEnter","onAfterLeave","onUpdateVisible"])}}})),oe=O("PLanguage",Q),Ze=e.defineComponent({name:"Redirect",setup(){const t=I.useRoute(),a=I.useRouter();return e.onBeforeMount(()=>{const{params:s,query:u}=t,{path:h}=s;a.replace({path:"/"+(Array.isArray(h)?h.join("/"):h),query:u})}),()=>React.createElement(n.NEmpty,null)}}),ne=O("PRedirect",Ze),Ge={class:"frame"},Qe=["src"],ae=O("PIframe",R(e.defineComponent({__name:"PIframe",setup(t){const a=I.useRoute(),s=e.ref(!1),u=e.ref(null),h=e.ref("");e.unref(a.meta)?.frameSrc&&(h.value=e.unref(a.meta)?.frameSrc);function d(){s.value=!1}function _(){e.nextTick(()=>{const c=e.unref(u);if(!c)return;const E=c;E.attachEvent?E.attachEvent("onload",()=>{d()}):c.onload=()=>{d()}})}return e.onMounted(()=>{s.value=!0,_()}),(c,E)=>{const V=n.NSpin;return e.openBlock(),e.createBlock(V,{show:s.value},{default:e.withCtx(()=>[e.createElementVNode("div",Ge,[e.createElementVNode("iframe",{src:h.value,class:"frame-iframe",ref_key:"frameRef",ref:u},null,8,Qe)])]),_:1},8,["show"])}}}),[["__scopeId","data-v-161a378e"]])),Ue={class:"border border-gray-100 rounded-lg"},ve={class:"text-xl font-semibold text-gray-800"},et={class:"text-sm text-gray-500 mt-1"},le=O("PPage",e.defineComponent({__name:"PPage",props:{icon:{type:Object,required:!1,default:()=>T.AlertOutlined},title:{type:String,required:!0},subtitle:{type:String,required:!1}},setup(t){const a=t;return(s,u)=>{const h=n.NIcon,d=n.NAvatar,_=n.NSpace,c=n.NCard;return e.openBlock(),e.createElementBlock("div",Ue,[a.title?(e.openBlock(),e.createBlock(c,{key:0,class:"mb-4",bordered:!1,"content-class":"py-4"},{default:e.withCtx(()=>[e.createVNode(_,{align:"center",justify:"space-between"},{default:e.withCtx(()=>[e.createVNode(_,{align:"center",size:16},{default:e.withCtx(()=>[a.icon?(e.openBlock(),e.createBlock(d,{key:0,size:48,class:"bg-linear-to-br from-blue-500 to-indigo-600"},{default:e.withCtx(()=>[e.createVNode(h,{size:24,component:a.icon,color:"#fff"},null,8,["component"])]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",null,[e.createElementVNode("div",ve,e.toDisplayString(a.title),1),e.createElementVNode("div",et,e.toDisplayString(a.subtitle??a.title+"主页"),1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),s.$slots.search?(e.openBlock(),e.createBlock(c,{key:1,class:"mb-4","content-class":"flex flex-row gap-2",bordered:!1},{default:e.withCtx(()=>[e.renderSlot(s.$slots,"search")]),_:3})):e.createCommentVNode("",!0),s.$slots.default?(e.openBlock(),e.createBlock(c,{key:2,"content-class":"flex flex-row gap-2 p-0!",bordered:!1},{default:e.withCtx(()=>[e.renderSlot(s.$slots,"default")]),_:3})):e.createCommentVNode("",!0)])}}})),tt={},ot={class:"flex flex-col justify-center page-container"};function nt(t,a){const s=n.NResult;return e.openBlock(),e.createElementBlock("div",ot,[e.createVNode(s,{status:"500",title:"服务器错误",description:"抱歉,服务器出错了"})])}const at=R(tt,[["render",nt],["__scopeId","data-v-89cb65c7"]]),lt={},st={class:"flex flex-col justify-center page-container"};function rt(t,a){const s=n.NResult;return e.openBlock(),e.createElementBlock("div",st,[e.createVNode(s,{status:"404",title:"资源不存在",description:"抱歉,你访问的页面不存在"})])}const ct=R(lt,[["render",rt],["__scopeId","data-v-99232671"]]),it={},dt={class:"flex flex-col justify-center page-container"};function ft(t,a){const s=n.NResult;return e.openBlock(),e.createElementBlock("div",dt,[e.createVNode(s,{status:"403",title:"禁止访问",description:"抱歉,你无权访问该页面"})])}const mt=R(it,[["render",ft],["__scopeId","data-v-3baa9c16"]]),se=O("P500",at),re=O("P404",ct),ce=O("P403",mt),ie=K.defineStore("app-oidc",()=>{const t=e.reactive({});return{setCallback:d=>t.callback=d,callCallback:async d=>await t.callback?.(d),setError:d=>t.error=d,callError:async(d,_)=>await t.error?.(d,_)}}),ut={class:"view-auth-callback"},de=O("POidc",R(e.defineComponent({__name:"POidc",setup(t){const a=I.useRouter(),{callCallback:s,callError:u}=ie();return e.onMounted(async()=>{try{await s(a)}catch(h){await u(a,h)}}),(h,d)=>(e.openBlock(),e.createElementBlock("div",ut,[...d[0]||(d[0]=[e.createElementVNode("div",{class:"view-auth-callback-content"},[e.createElementVNode("div",{class:"view-auth-callback-spinner"},[e.createElementVNode("span",null,"正在处理登录回调...")])],-1)])]))}}),[["__scopeId","data-v-167395ae"]])),pt=Object.freeze(Object.defineProperty({__proto__:null,P403:ce,P404:re,P500:se,PApplication:ee,PEmptyLayout:U,PIframe:ae,PLanguage:oe,PLayout:v,PModal:te,POidc:de,PPage:le,PRedirect:ne,PTable:Z},Symbol.toStringTag,{value:"Module"})),fe=(t,a)=>(Object.values(pt).forEach(s=>{s.install&&t.use(s)}),a?.(),t),ht={install:fe};C.P403=ce,C.P404=re,C.P500=se,C.PApplication=ee,C.PEmptyLayout=U,C.PIframe=ae,C.PLanguage=oe,C.PLayout=v,C.PModal=te,C.POidc=de,C.PPage=le,C.PRedirect=ne,C.PTable=Z,C.default=ht,C.install=fe,C.useLanguageStore=G,C.useLayoutStore=q,C.useOidcStore=ie,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/es/table/PTable.vue.js
CHANGED
|
@@ -1,239 +1,250 @@
|
|
|
1
|
-
import { useDialog as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { useDialog as X, useMessage as Y, NCard as Z, NDataTable as ee, NSpace as te, NTooltip as ne, NIcon as m, NDropdown as oe, NButton as ae } from "naive-ui";
|
|
2
|
+
import { defineComponent as ie, ref as u, computed as E, watch as se, unref as c, onMounted as le, openBlock as C, createBlock as z, withCtx as i, createElementVNode as g, createElementBlock as re, renderSlot as ue, createCommentVNode as N, createVNode as s, toDisplayString as ce, h as l, toRaw as H } from "vue";
|
|
3
|
+
import { getViewportOffset as de } from "../utils/helper.js";
|
|
4
|
+
import { PlusSquareOutlined as fe, DeleteOutlined as A, ReloadOutlined as me, MoreOutlined as pe, EditOutlined as ge } from "@vicons/antd";
|
|
5
|
+
const he = { class: "text-lg font-medium" }, ve = { id: "data-content" }, ye = {
|
|
5
6
|
key: 0,
|
|
6
7
|
class: "rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"
|
|
7
|
-
},
|
|
8
|
+
}, _e = /* @__PURE__ */ ie({
|
|
8
9
|
__name: "PTable",
|
|
9
10
|
props: {
|
|
10
11
|
title: {},
|
|
11
12
|
idField: { default: "id" },
|
|
13
|
+
addPermission: {},
|
|
14
|
+
editPermission: {},
|
|
15
|
+
deletePermission: {},
|
|
12
16
|
columns: {},
|
|
13
17
|
onLoad: {},
|
|
14
18
|
onDelete: {},
|
|
15
19
|
onAdd: {},
|
|
16
|
-
onEdit: {}
|
|
20
|
+
onEdit: {},
|
|
21
|
+
onCheckPermission: {}
|
|
17
22
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const
|
|
23
|
+
setup(P, { expose: T }) {
|
|
24
|
+
const B = u(null), L = X(), h = Y(), v = u(!1), y = u([]), k = u([]), x = u(!1), _ = u(!1), w = u(!1), D = u({}), R = E(
|
|
25
|
+
() => _.value || w.value || Object.keys(D.value).length > 0
|
|
26
|
+
), a = P, b = async (e) => !e || !a.onCheckPermission ? !0 : await a.onCheckPermission(e) ?? !1;
|
|
27
|
+
se(
|
|
28
|
+
a,
|
|
29
|
+
async () => {
|
|
30
|
+
x.value = !!a.onAdd && await b(a.addPermission), _.value = !!a.onEdit && await b(a.editPermission), w.value = !!a.onDelete && await b(a.deletePermission);
|
|
31
|
+
const e = a.columns.find(
|
|
32
|
+
(t) => t.key === "action"
|
|
33
|
+
);
|
|
34
|
+
if (e && e.action)
|
|
35
|
+
for (const t of e.action) {
|
|
36
|
+
if (!t.permission) continue;
|
|
37
|
+
const n = await b(
|
|
38
|
+
t.permission.toLowerCase()
|
|
39
|
+
);
|
|
40
|
+
n && (D.value[t.permission] = n);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{ immediate: !0 }
|
|
44
|
+
);
|
|
45
|
+
const M = E(() => {
|
|
46
|
+
const e = [{ type: "selection", fixed: "left" }], t = [];
|
|
47
|
+
return a.columns.forEach((n) => {
|
|
48
|
+
if (n.key !== "action") {
|
|
49
|
+
e.push({
|
|
50
|
+
title: n.title,
|
|
51
|
+
key: n.key,
|
|
52
|
+
width: n.width,
|
|
53
|
+
fixed: n.fixed ?? !1,
|
|
54
|
+
render: n.render,
|
|
55
|
+
ellipsis: n.ellipsis ? { tooltip: !0 } : !1
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
!n.action || n.action.length <= 0 || !R.value || t.push({
|
|
60
|
+
title: "操作",
|
|
61
|
+
key: "actions",
|
|
62
|
+
width: 100,
|
|
63
|
+
fixed: "right",
|
|
64
|
+
render: (o) => {
|
|
65
|
+
const r = [];
|
|
66
|
+
if (j(r, o), q(r, o), I(r, o, n.action), !(r.length <= 0))
|
|
67
|
+
return l(
|
|
68
|
+
oe,
|
|
69
|
+
{
|
|
70
|
+
options: r,
|
|
71
|
+
placement: "bottom-start"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
default: () => l(
|
|
75
|
+
ae,
|
|
76
|
+
{ size: "small", type: "primary" },
|
|
77
|
+
{ default: () => ["操作", l(m, () => l(pe))] }
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}), [...e, ...R.value ? t : []];
|
|
84
|
+
}), d = u({
|
|
20
85
|
page: 1,
|
|
21
86
|
itemCount: 0,
|
|
22
87
|
pageSize: 10,
|
|
23
88
|
pageSizes: [10, 20, 30, 50],
|
|
24
89
|
showSizePicker: !0,
|
|
25
90
|
onChange: async (e) => {
|
|
26
|
-
|
|
91
|
+
d.value.page = e, await p();
|
|
27
92
|
},
|
|
28
93
|
onUpdatePageSize: async (e) => {
|
|
29
|
-
|
|
94
|
+
d.value.pageSize = e, await p();
|
|
30
95
|
}
|
|
31
|
-
}),
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
96
|
+
}), V = E(() => {
|
|
97
|
+
const e = c(B);
|
|
98
|
+
if (!e) return;
|
|
99
|
+
const t = e?.$el, n = t.querySelector(".n-data-table-thead "), { bottomIncludeBody: o } = de(n), r = 48;
|
|
100
|
+
let f = 12, Q = 25;
|
|
101
|
+
const $ = t.querySelector(
|
|
102
|
+
".n-data-table__pagination"
|
|
103
|
+
);
|
|
104
|
+
if ($) {
|
|
105
|
+
const W = $.offsetHeight;
|
|
106
|
+
f += W || 0;
|
|
107
|
+
} else
|
|
108
|
+
f += 28;
|
|
109
|
+
return o - (r + f + Q);
|
|
110
|
+
}), j = async (e, t) => {
|
|
111
|
+
_.value && e.push({
|
|
112
|
+
label: "编辑",
|
|
113
|
+
key: "edit",
|
|
114
|
+
icon: () => l(m, null, { default: () => l(ge) }),
|
|
115
|
+
props: { onClick: async () => await a.onEdit(t) }
|
|
116
|
+
});
|
|
117
|
+
}, q = async (e, t) => {
|
|
118
|
+
w.value && e.push({
|
|
119
|
+
label: "删除",
|
|
120
|
+
key: "delete",
|
|
121
|
+
icon: () => l(m, null, { default: () => l(A) }),
|
|
122
|
+
props: { onClick: () => K(t) }
|
|
123
|
+
});
|
|
124
|
+
}, I = (e, t, n) => {
|
|
125
|
+
if (n)
|
|
126
|
+
for (const o of n) {
|
|
127
|
+
if (o.key === "edit" || o.key === "delete" || !o.permission || !D.value[o.permission])
|
|
128
|
+
return;
|
|
129
|
+
e.push({
|
|
130
|
+
label: o.name,
|
|
131
|
+
key: o.key,
|
|
132
|
+
icon: o.icon && (() => l(m, null, { default: () => l(o.icon) })),
|
|
133
|
+
props: { onClick: () => o.action(t) }
|
|
40
134
|
});
|
|
41
|
-
}), n;
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
title: "操作",
|
|
45
|
-
key: "actions",
|
|
46
|
-
width: 100,
|
|
47
|
-
fixed: "right",
|
|
48
|
-
render: (o) => {
|
|
49
|
-
let n = [];
|
|
50
|
-
if (l.onEdit && n.push({
|
|
51
|
-
label: "编辑",
|
|
52
|
-
key: "edit",
|
|
53
|
-
icon: () => r(f, null, { default: () => r(ve) }),
|
|
54
|
-
props: { onClick: async () => await l.onEdit(o) }
|
|
55
|
-
}), l.onDelete && n.push({
|
|
56
|
-
label: "删除",
|
|
57
|
-
key: "delete",
|
|
58
|
-
icon: () => r(f, null, { default: () => r(P) }),
|
|
59
|
-
props: { onClick: () => W(o) }
|
|
60
|
-
}), n = [...n, ...t(o)], !(n.length <= 0))
|
|
61
|
-
return r(
|
|
62
|
-
ce,
|
|
63
|
-
{
|
|
64
|
-
options: n,
|
|
65
|
-
placement: "bottom-start"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
default: () => r(
|
|
69
|
-
de,
|
|
70
|
-
{ size: "small", type: "primary" },
|
|
71
|
-
{ default: () => ["操作", r(f, () => r(ke))] }
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
135
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
width: o.width,
|
|
82
|
-
fixed: o.fixed ?? !1,
|
|
83
|
-
render: o.render,
|
|
84
|
-
ellipsis: o.ellipsis ? { tooltip: !0 } : !1
|
|
85
|
-
})), t = l.columns.reduce(
|
|
86
|
-
(o, n) => n.key === "action" ? n : o,
|
|
87
|
-
void 0
|
|
88
|
-
)?.action;
|
|
89
|
-
return t && t?.length > 0 || l.onEdit || l.onDelete ? [
|
|
90
|
-
{ type: "selection", fixed: "left" },
|
|
91
|
-
...e,
|
|
92
|
-
M(t)
|
|
93
|
-
] : [{ type: "selection", fixed: "left" }, ...e];
|
|
94
|
-
}), q = async () => await p(), W = (e) => z([e]), j = () => {
|
|
95
|
-
const e = D();
|
|
96
|
-
z(e);
|
|
97
|
-
}, z = (e) => {
|
|
98
|
-
e && e.length > 0 && A.warning({
|
|
136
|
+
}, F = async () => await p(), K = (e) => O([e]), U = () => {
|
|
137
|
+
const e = S();
|
|
138
|
+
O(e);
|
|
139
|
+
}, O = (e) => {
|
|
140
|
+
!e || e.length === 0 || L.warning({
|
|
99
141
|
title: "警告",
|
|
100
142
|
content: "删除数据不可恢复, 确认删除吗?",
|
|
101
143
|
positiveText: "确定",
|
|
102
144
|
negativeText: "取消",
|
|
103
145
|
onPositiveClick: async () => {
|
|
104
|
-
if (
|
|
146
|
+
if (a.onDelete)
|
|
105
147
|
try {
|
|
106
|
-
await
|
|
148
|
+
await a.onDelete(e) ? (p(), h.success("删除成功")) : h.error("删除失败");
|
|
107
149
|
} catch (t) {
|
|
108
|
-
|
|
150
|
+
h.error(t.message);
|
|
109
151
|
}
|
|
110
152
|
}
|
|
111
153
|
});
|
|
112
|
-
},
|
|
113
|
-
if (!
|
|
114
|
-
|
|
154
|
+
}, p = async () => {
|
|
155
|
+
if (a.onLoad && !v.value) {
|
|
156
|
+
v.value = !0;
|
|
115
157
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
} catch (o) {
|
|
124
|
-
y.error(o.message);
|
|
158
|
+
var { items: e, totalCount: t } = await a.onLoad(
|
|
159
|
+
d.value.page,
|
|
160
|
+
d.value.pageSize
|
|
161
|
+
);
|
|
162
|
+
k.value = e, d.value.itemCount = t;
|
|
163
|
+
} catch (n) {
|
|
164
|
+
h.error(n.message);
|
|
125
165
|
} finally {
|
|
126
|
-
|
|
166
|
+
v.value = !1;
|
|
127
167
|
}
|
|
128
168
|
}
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const g = t.querySelector(
|
|
135
|
-
".n-data-table__pagination"
|
|
136
|
-
);
|
|
137
|
-
if (g) {
|
|
138
|
-
const S = g.offsetHeight;
|
|
139
|
-
c += S || 0;
|
|
140
|
-
} else
|
|
141
|
-
c += 28;
|
|
142
|
-
return n - (a + c + b);
|
|
143
|
-
}), X = (e) => !e || !e.getBoundingClientRect ? 0 : e.getBoundingClientRect(), Y = (e) => {
|
|
144
|
-
const t = document.documentElement, o = t.scrollLeft, n = t.scrollTop, a = t.clientLeft, c = t.clientTop, b = window.pageXOffset, g = window.pageYOffset, B = X(e), {
|
|
145
|
-
left: S,
|
|
146
|
-
top: G,
|
|
147
|
-
width: J,
|
|
148
|
-
height: Q
|
|
149
|
-
} = B, Z = (b || o) - (a || 0), ee = (g || n) - (c || 0), te = S + b, oe = G + g, x = te - Z, E = oe - ee, L = window.document.documentElement.clientWidth, N = window.document.documentElement.clientHeight;
|
|
150
|
-
return {
|
|
151
|
-
left: x,
|
|
152
|
-
top: E,
|
|
153
|
-
right: L - J - x,
|
|
154
|
-
bottom: N - Q - E,
|
|
155
|
-
rightIncludeBody: L - x,
|
|
156
|
-
bottomIncludeBody: N - E
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
return fe(async () => await p()), I({
|
|
160
|
-
getData: K,
|
|
161
|
-
getSelectedRow: F,
|
|
162
|
-
getSelectedRows: D,
|
|
169
|
+
}, S = () => y.value ? k.value.filter((e) => y.value.includes(e.id)).map((e) => H(e)) : [], G = () => S()[0], J = () => H(k.value);
|
|
170
|
+
return le(async () => await p()), T({
|
|
171
|
+
getData: J,
|
|
172
|
+
getSelectedRow: G,
|
|
173
|
+
getSelectedRows: S,
|
|
163
174
|
refreshData: p,
|
|
164
175
|
resetPage: () => {
|
|
165
|
-
|
|
176
|
+
d.value.page = 1;
|
|
166
177
|
}
|
|
167
178
|
}), (e, t) => {
|
|
168
|
-
const
|
|
169
|
-
return C(),
|
|
179
|
+
const n = ne, o = te, r = ee;
|
|
180
|
+
return C(), z(c(Z), { bordered: !1 }, {
|
|
170
181
|
header: i(() => [
|
|
171
|
-
s(
|
|
182
|
+
s(o, {
|
|
172
183
|
justify: "space-between",
|
|
173
184
|
align: "center",
|
|
174
185
|
class: "w-full"
|
|
175
186
|
}, {
|
|
176
187
|
default: i(() => [
|
|
177
|
-
|
|
178
|
-
s(
|
|
188
|
+
g("span", he, ce(P.title), 1),
|
|
189
|
+
s(o, null, {
|
|
179
190
|
default: i(() => [
|
|
180
|
-
|
|
191
|
+
x.value ? (C(), z(n, {
|
|
181
192
|
key: 0,
|
|
182
193
|
trigger: "hover"
|
|
183
194
|
}, {
|
|
184
195
|
trigger: i(() => [
|
|
185
|
-
s(
|
|
196
|
+
s(c(m), {
|
|
186
197
|
size: "18",
|
|
187
198
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
188
|
-
onClick:
|
|
199
|
+
onClick: a.onAdd
|
|
189
200
|
}, {
|
|
190
201
|
default: i(() => [
|
|
191
|
-
s(
|
|
202
|
+
s(c(fe))
|
|
192
203
|
]),
|
|
193
204
|
_: 1
|
|
194
205
|
}, 8, ["onClick"])
|
|
195
206
|
]),
|
|
196
207
|
default: i(() => [
|
|
197
|
-
t[1] || (t[1] =
|
|
208
|
+
t[1] || (t[1] = g("span", null, "新增", -1))
|
|
198
209
|
]),
|
|
199
210
|
_: 1
|
|
200
|
-
})) :
|
|
201
|
-
|
|
211
|
+
})) : N("", !0),
|
|
212
|
+
w.value ? (C(), z(n, {
|
|
202
213
|
key: 1,
|
|
203
214
|
trigger: "hover"
|
|
204
215
|
}, {
|
|
205
216
|
trigger: i(() => [
|
|
206
|
-
s(
|
|
217
|
+
s(c(m), {
|
|
207
218
|
size: "18",
|
|
208
219
|
class: "mr-1 cursor-pointer hover:text-blue-600",
|
|
209
|
-
onClick:
|
|
220
|
+
onClick: U
|
|
210
221
|
}, {
|
|
211
222
|
default: i(() => [
|
|
212
|
-
s(
|
|
223
|
+
s(c(A))
|
|
213
224
|
]),
|
|
214
225
|
_: 1
|
|
215
226
|
})
|
|
216
227
|
]),
|
|
217
228
|
default: i(() => [
|
|
218
|
-
t[2] || (t[2] =
|
|
229
|
+
t[2] || (t[2] = g("span", null, "删除", -1))
|
|
219
230
|
]),
|
|
220
231
|
_: 1
|
|
221
|
-
})) :
|
|
222
|
-
s(
|
|
232
|
+
})) : N("", !0),
|
|
233
|
+
s(n, { trigger: "hover" }, {
|
|
223
234
|
trigger: i(() => [
|
|
224
|
-
s(
|
|
235
|
+
s(c(m), {
|
|
225
236
|
size: "18",
|
|
226
237
|
class: "cursor-pointer hover:text-blue-600",
|
|
227
|
-
onClick:
|
|
238
|
+
onClick: F
|
|
228
239
|
}, {
|
|
229
240
|
default: i(() => [
|
|
230
|
-
s(
|
|
241
|
+
s(c(me))
|
|
231
242
|
]),
|
|
232
243
|
_: 1
|
|
233
244
|
})
|
|
234
245
|
]),
|
|
235
246
|
default: i(() => [
|
|
236
|
-
t[3] || (t[3] =
|
|
247
|
+
t[3] || (t[3] = g("span", null, "刷新", -1))
|
|
237
248
|
]),
|
|
238
249
|
_: 1
|
|
239
250
|
})
|
|
@@ -245,24 +256,24 @@ const we = { class: "text-lg font-medium" }, be = { id: "data-content" }, Ce = {
|
|
|
245
256
|
})
|
|
246
257
|
]),
|
|
247
258
|
default: i(() => [
|
|
248
|
-
|
|
249
|
-
e.$slots.toolbar ? (C(),
|
|
250
|
-
|
|
251
|
-
])) :
|
|
252
|
-
s(
|
|
259
|
+
g("div", ve, [
|
|
260
|
+
e.$slots.toolbar ? (C(), re("div", ye, [
|
|
261
|
+
ue(e.$slots, "toolbar")
|
|
262
|
+
])) : N("", !0),
|
|
263
|
+
s(r, {
|
|
253
264
|
remote: "",
|
|
254
265
|
ref_key: "$table",
|
|
255
|
-
ref:
|
|
256
|
-
"checked-row-keys":
|
|
257
|
-
"onUpdate:checkedRowKeys": t[0] || (t[0] = (
|
|
258
|
-
"max-height":
|
|
259
|
-
loading:
|
|
266
|
+
ref: B,
|
|
267
|
+
"checked-row-keys": y.value,
|
|
268
|
+
"onUpdate:checkedRowKeys": t[0] || (t[0] = (f) => y.value = f),
|
|
269
|
+
"max-height": V.value,
|
|
270
|
+
loading: v.value,
|
|
260
271
|
bordered: !1,
|
|
261
272
|
"single-line": !1,
|
|
262
|
-
columns:
|
|
263
|
-
data:
|
|
264
|
-
pagination:
|
|
265
|
-
"row-key": (
|
|
273
|
+
columns: M.value,
|
|
274
|
+
data: k.value,
|
|
275
|
+
pagination: d.value,
|
|
276
|
+
"row-key": (f) => f[P.idField]
|
|
266
277
|
}, null, 8, ["checked-row-keys", "max-height", "loading", "columns", "data", "pagination", "row-key"])
|
|
267
278
|
])
|
|
268
279
|
]),
|
|
@@ -272,5 +283,5 @@ const we = { class: "text-lg font-medium" }, be = { id: "data-content" }, Ce = {
|
|
|
272
283
|
}
|
|
273
284
|
});
|
|
274
285
|
export {
|
|
275
|
-
|
|
286
|
+
_e as default
|
|
276
287
|
};
|