mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
2 lines
4.0 KiB
JavaScript
2 lines
4.0 KiB
JavaScript
var h=(l,f,s)=>new Promise((g,i)=>{var c=n=>{try{o(s.next(n))}catch(r){i(r)}},v=n=>{try{o(s.throw(n))}catch(r){i(r)}},o=n=>n.done?g(n.value):Promise.resolve(n.value).then(c,v);o((s=s.apply(l,f)).next())});import{r as D,a as t,m as Q,aF as X,gL as Z,n as $,ab as x,f as q,aZ as G,bp as w,J as y,ai as ee,L as ae,X as te,h as ne,fR as se}from"./index-DMqaFtX4.js";import{_ as le}from"./form.vue_vue_type_script_setup_true_lang-DkChxe5p.js";import{u as oe}from"./hooks-BE0p9dqE.js";import{h as ue,i as ie,j as ce}from"./system-rA6lrtqS.js";function ve(l){const f=D({name:"",code:"",status:""}),s=t(),g=t(),i=t([]),c=t([]),v=t([]),o=t(!1),n=t(!0),r=t(!1),F=t(),d=t({}),b=t(!1),S=t(!1),{switchStyle:I}=oe(),L={value:"id",label:"title",children:"children"},p=D({total:0,pageSize:10,currentPage:1,background:!0}),R=[{label:"角色编号",prop:"id"},{label:"角色名称",prop:"name"},{label:"角色标识",prop:"code"},{label:"状态",cellRenderer:e=>{var a;return q(ne("el-switch"),{size:e.props.size==="small"?"small":"default",loading:(a=d.value[e.index])==null?void 0:a.loading,modelValue:e.row.status,"onUpdate:modelValue":u=>e.row.status=u,"active-value":1,"inactive-value":0,"active-text":"已启用","inactive-text":"已停用","inline-prompt":!0,style:I.value,onChange:()=>T(e)},null)},minWidth:90},{label:"备注",prop:"remark",minWidth:160},{label:"创建时间",prop:"createTime",minWidth:160,formatter:({createTime:e})=>G(e).format("YYYY-MM-DD HH:mm:ss")},{label:"操作",fixed:"right",width:210,slot:"operation"}];function T({row:e,index:a}){se.confirm(`确认要<strong>${e.status===0?"停用":"启用"}</strong><strong style='color:var(--el-color-primary)'>${e.name}</strong>吗?`,"系统提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning",dangerouslyUseHTMLString:!0,draggable:!0}).then(()=>{d.value[a]=Object.assign({},d.value[a],{loading:!0}),setTimeout(()=>{d.value[a]=Object.assign({},d.value[a],{loading:!1}),y(`已${e.status===0?"停用":"启用"}${e.name}`,{type:"success"})},300)}).catch(()=>{e.status===0?e.status=1:e.status=0})}function z(e){y(`您删除了角色名称为${e.name}的这条数据`,{type:"success"}),m()}function K(e){}function P(e){}function j(e){}function m(){return h(this,null,function*(){n.value=!0;const{data:e}=yield ie(w(f));i.value=e.list,p.total=e.total,p.pageSize=e.pageSize,p.currentPage=e.currentPage,setTimeout(()=>{n.value=!1},500)})}const H=e=>{e&&(e.resetFields(),m())};function V(e="新增",a){var u,C,k;ee({title:`${e}角色`,props:{formInline:{name:(u=a==null?void 0:a.name)!=null?u:"",code:(C=a==null?void 0:a.code)!=null?C:"",remark:(k=a==null?void 0:a.remark)!=null?k:""}},width:"40%",draggable:!0,fullscreen:te(),fullscreenIcon:!0,closeOnClickModal:!1,contentRenderer:()=>ae(le,{ref:g,formInline:null}),beforeSure:(_,{options:A})=>{const U=g.value.getRef(),J=A.props.formInline;function M(){y(`您${e}了角色名称为${J.name}的这条数据`,{type:"success"}),_(),m()}U.validate(N=>{N&&M()})}})}function Y(e){return h(this,null,function*(){const{id:a}=e;if(a){s.value=e,o.value=!0;const{data:u}=yield ce({id:a});l.value.setCheckedKeys(u)}else s.value=null,o.value=!1})}function B({row:{id:e}}){var a;return{cursor:"pointer",background:e===((a=s.value)==null?void 0:a.id)?"var(--el-fill-color-light)":""}}function E(){const{id:e,name:a}=s.value;y(`角色名称为${a}的菜单权限修改成功`,{type:"success"})}const O=e=>{l.value.filter(e)},W=(e,a)=>x(a.title).includes(e);return Q(()=>h(this,null,function*(){m();const{data:e}=yield ue();c.value=X(e,"id"),v.value=Z(e)})),$(b,e=>{e?l.value.setExpandedKeys(c.value):l.value.setExpandedKeys([])}),$(S,e=>{e?l.value.setCheckedKeys(c.value):l.value.setCheckedKeys([])}),{form:f,isShow:o,curRow:s,loading:n,columns:R,rowStyle:B,dataList:i,treeData:v,treeProps:L,isLinkage:r,pagination:p,isExpandAll:b,isSelectAll:S,treeSearchValue:F,onSearch:m,resetForm:H,openDialog:V,handleMenu:Y,handleSave:E,handleDelete:z,filterMethod:W,transformI18n:x,onQueryChanged:O,handleSizeChange:K,handleCurrentChange:P,handleSelectionChange:j}}export{ve as useRole};
|