mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 09:27:19 +08:00
2 lines
2.3 KiB
JavaScript
2 lines
2.3 KiB
JavaScript
import{a7 as i,r as o,x as W,a as w,g as u,c,bo as z,br as M}from"./index-0dd8d5e4.js";import{m as T}from"./message-ac5811da.js";import{a as S}from"./system-5c5ef8e0.js";function j(){const d=i({name:"",code:"",status:""}),s=o([]),n=o(!0),a=o({}),r=i({total:0,pageSize:10,currentPage:1,background:!0}),m=[{label:"序号",type:"index",width:70,fixed:"left"},{label:"角色编号",prop:"id",minWidth:100},{label:"角色名称",prop:"name",minWidth:120},{label:"角色标识",prop:"code",minWidth:150},{label:"角色类型",prop:"type",minWidth:150,cellRenderer:({row:e,props:t})=>u(c("el-tag"),{size:t.size,type:e.type===1?"danger":"",effect:"plain"},{default:()=>[e.type===1?"内置":"自定义"]})},{label:"显示顺序",prop:"sort",minWidth:100},{label:"状态",minWidth:130,cellRenderer:e=>{var t;return u(c("el-switch"),{size:e.props.size==="small"?"small":"default",loading:(t=a.value[e.index])==null?void 0:t.loading,modelValue:e.row.status,"onUpdate:modelValue":C=>e.row.status=C,"active-value":1,"inactive-value":0,"active-text":"已开启","inactive-text":"已关闭","inline-prompt":!0,onChange:()=>g(e)},null)}},{label:"创建时间",minWidth:180,prop:"createTime",formatter:({createTime:e})=>z(e).format("YYYY-MM-DD HH:mm:ss")},{label:"操作",fixed:"right",width:180,slot:"operation"}],p=W(()=>["!h-[20px]","reset-margin","!text-gray-500","dark:!text-white","dark:hover:!text-primary"]);function g({row:e,index:t}){M.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(()=>{a.value[t]=Object.assign({},a.value[t],{loading:!0}),setTimeout(()=>{a.value[t]=Object.assign({},a.value[t],{loading:!1}),T("已成功修改角色状态",{type:"success"})},300)}).catch(()=>{e.status===0?e.status=1:e.status=0})}function h(e){}function f(e){}function v(e){}function b(e){}function y(e){}async function l(){n.value=!0;const{data:e}=await S();s.value=e.list,r.total=e.total,setTimeout(()=>{n.value=!1},500)}const x=e=>{e&&(e.resetFields(),l())};return w(()=>{l()}),{form:d,loading:n,columns:m,dataList:s,pagination:r,buttonClass:p,onSearch:l,resetForm:x,handleUpdate:h,handleDelete:f,handleSizeChange:v,handleCurrentChange:b,handleSelectionChange:y}}export{j as useRole};
|