2 lines
7.2 KiB
JavaScript
Executable File
2 lines
7.2 KiB
JavaScript
Executable File
import{_ as e,V as t,T as a,d as i,f as n,c as s,w as o,i as l,x as r,y as d,z as c,A as u,e as p,o as m,h,a as g,t as f,k as _,l as b,F as y,I as x,C,P as z,ab as $}from"./index-Br__yMYG.js";import{_ as S}from"./download-excel.C3TMg6bl.js";import{_ as w}from"./uni-dateformat.CpECqnvT.js";import{_ as k}from"./uni-pagination.iD7RDfIT.js";import{_ as D}from"./unicloud-db.DlY2v4vi.js";import{e as I,f as T}from"./uni-id-permissions.DrKF0XvK.js";const v=t.database(),E=["permission_id","permission_name"],j={ascending:"asc",descending:"desc"};const F=e({data:()=>({query:"",where:"",orderby:"create_date desc",orderByFieldName:"",selectedIndexs:[],pageSizeIndex:0,pageSizeOption:[20,50,100,500],options:{pageSize:20,pageCurrent:1,filterData:{},...I},imageStyles:{width:64,height:64},exportExcel:{filename:"uni-id-permissions.xls",type:"xls",fields:{"权限ID":"permission_id","权限名称":"permission_name","备注":"comment"}},exportExcelData:[]}),onLoad(){this._filter={}},onReady(){this.$refs.udb.loadData()},watch:{pageSizeIndex:{immediate:!0,handler(e,t){this.options.pageSize=this.pageSizeOption[e],this.options.pageCurrent=1}}},methods:{onqueryload(e){this.exportExcelData=e},changeSize(e){this.pageSizeIndex=e.detail.value,this.$nextTick((()=>{this.loadData()}))},getWhere(){const e=this.query.trim();if(!e)return"";const t=new RegExp(e,"i");return E.map((e=>t+".test("+e+")")).join(" || ")},search(){const e=this.getWhere();this.where=e,this.$nextTick((()=>{this.loadData()}))},loadData(e=!0){this.$refs.udb.loadData({clear:e})},onPageChanged(e){this.selectedIndexs.length=0,this.$refs.table.clearSelection(),this.$refs.udb.loadData({current:e.current})},navigateTo(e,t){a({url:e,events:{refreshData:()=>{this.loadData(t)}}})},selectedItems(){var e=this.$refs.udb.dataList;return this.selectedIndexs.map((t=>e[t]._id))},delTable(){this.$refs.udb.remove(this.selectedItems(),{success:e=>{this.$refs.table.clearSelection()}})},selectionChange(e){this.selectedIndexs=e.detail.index},confirmDelete(e){this.$refs.udb.remove(e,{success:e=>{this.$refs.table.clearSelection()}})},sortChange(e,t){this.orderByFieldName=t,e.order?this.orderby=t+" "+j[e.order]:this.orderby="",this.$refs.table.clearSelection(),this.$nextTick((()=>{this.$refs.udb.loadData()}))},filterChange(e,t){this._filter[t]={type:e.filterType,value:e.filter};let a=T(this._filter,v.command);Object.keys(a).length?this.where=a:this.where="",this.$nextTick((()=>{this.$refs.udb.loadData()}))}}},[["render",function(e,t,a,I,T,v){const E=l,j=x,F=C,V=i(n("download-excel"),S),q=i(n("uni-th"),r),O=i(n("uni-tr"),d),P=i(n("uni-td"),c),L=i(n("uni-dateformat"),w),U=i(n("uni-table"),u),A=z,B=i(n("uni-icons"),p),N=$,R=i(n("uni-pagination"),k),W=i(n("unicloud-db"),D);return m(),s(E,{class:"fix-top-window"},{default:o((()=>[h(E,{class:"uni-header"},{default:o((()=>[h(E,{class:"uni-group hide-on-phone"},{default:o((()=>[h(E,{class:"uni-title"},{default:o((()=>[g(f(e.$t("permission.text.permissionManager")),1)])),_:1}),h(E,{class:"uni-sub-title"})])),_:1}),h(E,{class:"uni-group"},{default:o((()=>[h(j,{class:"uni-search",type:"text",modelValue:T.query,"onUpdate:modelValue":t[0]||(t[0]=e=>T.query=e),onConfirm:v.search,placeholder:e.$t("common.placeholder.query")},null,8,["modelValue","onConfirm","placeholder"]),h(F,{class:"uni-button",type:"default",size:"mini",onClick:v.search},{default:o((()=>[g(f(e.$t("common.button.search")),1)])),_:1},8,["onClick"]),h(F,{class:"uni-button",type:"primary",size:"mini",onClick:t[1]||(t[1]=e=>v.navigateTo("./add"))},{default:o((()=>[g(f(e.$t("common.button.add")),1)])),_:1}),h(F,{class:"uni-button",type:"warn",size:"mini",disabled:!T.selectedIndexs.length,onClick:v.delTable},{default:o((()=>[g(f(e.$t("common.button.batchDelete")),1)])),_:1},8,["disabled","onClick"]),h(V,{class:"hide-on-phone",fields:T.exportExcel.fields,data:T.exportExcelData,type:T.exportExcel.type,name:T.exportExcel.filename},{default:o((()=>[h(F,{class:"uni-button",type:"primary",size:"mini"},{default:o((()=>[g(f(e.$t("common.button.exportExcel")),1)])),_:1})])),_:1},8,["fields","data","type","name"])])),_:1})])),_:1}),h(E,{class:"uni-container"},{default:o((()=>[h(W,{ref:"udb",collection:"uni-id-permissions",field:"permission_id,permission_name,comment,create_date",where:T.where,"page-data":"replace",orderby:T.orderby,getcount:!0,"page-size":T.options.pageSize,"page-current":T.options.pageCurrent,options:T.options,loadtime:"manual",onLoad:v.onqueryload},{default:o((({data:a,pagination:i,loading:n,error:l,options:r})=>[h(U,{ref:"table",loading:n,emptyText:l.message||e.$t("common.empty"),border:"",stripe:"",type:"selection",onSelectionChange:v.selectionChange},{default:o((()=>[h(O,null,{default:o((()=>[h(q,{align:"center","filter-type":"search",onFilterChange:t[2]||(t[2]=e=>v.filterChange(e,"permission_id")),sortable:"",onSortChange:t[3]||(t[3]=e=>v.sortChange(e,"permission_id"))},{default:o((()=>[g("权限标识")])),_:1}),h(q,{align:"center","filter-type":"search",onFilterChange:t[4]||(t[4]=e=>v.filterChange(e,"permission_name")),sortable:"",onSortChange:t[5]||(t[5]=e=>v.sortChange(e,"permission_name"))},{default:o((()=>[g("权限名称")])),_:1}),h(q,{align:"center","filter-type":"search",onFilterChange:t[6]||(t[6]=e=>v.filterChange(e,"comment")),sortable:"",onSortChange:t[7]||(t[7]=e=>v.sortChange(e,"comment"))},{default:o((()=>[g("备注")])),_:1}),h(q,{align:"center","filter-type":"timestamp",onFilterChange:t[8]||(t[8]=e=>v.filterChange(e,"create_date")),sortable:"",onSortChange:t[9]||(t[9]=e=>v.sortChange(e,"create_date"))},{default:o((()=>[g("创建时间")])),_:1}),h(q,{align:"center"},{default:o((()=>[g("操作")])),_:1})])),_:1}),(m(!0),_(y,null,b(a,((t,a)=>(m(),s(O,{key:a},{default:o((()=>[h(P,{align:"center"},{default:o((()=>[g(f(t.permission_id),1)])),_:2},1024),h(P,{align:"center"},{default:o((()=>[g(f(t.permission_name),1)])),_:2},1024),h(P,{align:"center"},{default:o((()=>[g(f(t.comment),1)])),_:2},1024),h(P,{align:"center"},{default:o((()=>[h(L,{threshold:[0,0],date:t.create_date},null,8,["date"])])),_:2},1024),h(P,{align:"center"},{default:o((()=>[h(E,{class:"uni-group"},{default:o((()=>[h(F,{onClick:e=>v.navigateTo("./edit?id="+t._id,!1),class:"uni-button",size:"mini",type:"primary"},{default:o((()=>[g(f(e.$t("common.button.edit")),1)])),_:2},1032,["onClick"]),h(F,{onClick:e=>v.confirmDelete(t._id),class:"uni-button",size:"mini",type:"warn"},{default:o((()=>[g(f(e.$t("common.button.delete")),1)])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1024)])),_:2},1024)))),128))])),_:2},1032,["loading","emptyText","onSelectionChange"]),h(E,{class:"uni-pagination-box"},{default:o((()=>[h(N,{class:"select-picker",mode:"selector",value:T.pageSizeIndex,range:T.pageSizeOption,onChange:v.changeSize},{default:o((()=>[h(F,{type:"default",size:"mini",plain:!0},{default:o((()=>[h(A,null,{default:o((()=>[g(f(T.pageSizeOption[T.pageSizeIndex])+" "+f(e.$t("common.piecePerPage")),1)])),_:1}),h(B,{class:"select-picker-icon",type:"arrowdown",size:"12",color:"#999"})])),_:1})])),_:1},8,["value","range","onChange"]),h(R,{"show-icon":"","page-size":i.size,modelValue:i.current,"onUpdate:modelValue":e=>i.current=e,total:i.count,onChange:v.onPageChanged},null,8,["page-size","modelValue","onUpdate:modelValue","total","onChange"])])),_:2},1024)])),_:1},8,["where","orderby","page-size","page-current","options","onLoad"])])),_:1})])),_:1})}]]);export{F as default};
|