update:权限管理
This commit is contained in:
parent
d99647a0e0
commit
5892c10361
168
src/api/match/account.js
Normal file
168
src/api/match/account.js
Normal file
@ -0,0 +1,168 @@
|
||||
import { BaseApi } from '../baseApi';
|
||||
import { http } from '../../utils/request';
|
||||
|
||||
// ==================== 系统用户管理 ====================
|
||||
|
||||
/**
|
||||
* 系统用户分页查询
|
||||
* @param {Object} params - 查询参数
|
||||
* @param {string} [params.Account] - 账号 (模糊查询)
|
||||
* @param {string} [params.Name] - 姓名 (模糊查询)
|
||||
* @param {number} [params.RoleId] - 关联角色ID
|
||||
* @param {string} [params.StartTime] - 开始时间 (格式: ISO日期时间)
|
||||
* @param {string} [params.EndTime] - 结束时间 (格式: ISO日期时间)
|
||||
* @param {number} [params.PageNo] - 当前页码
|
||||
* @param {number} [params.PageSize] - 每页条数
|
||||
* @returns {Promise<{
|
||||
* pageNo: number,
|
||||
* pageSize: number,
|
||||
* pages: number,
|
||||
* total: number,
|
||||
* rows: Array<{
|
||||
* id: number,
|
||||
* name: string,
|
||||
* account: string,
|
||||
* roleNames: string,
|
||||
* createdTime: string,
|
||||
* status: number | string
|
||||
* }>
|
||||
* }>}
|
||||
*/
|
||||
export const sysuserPageGet = (params) => {
|
||||
return http.get('/sysuser/page', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 添加系统用户
|
||||
* @param {Object} data - 用户信息
|
||||
* @param {string} data.name - 姓名
|
||||
* @param {string} data.account - 账号
|
||||
* @param {Array<number>} data.roles - 角色ID列表
|
||||
* @param {string} [data.status] - 状态 (Enable=启用, Disable=禁用,默认Enable)
|
||||
*/
|
||||
export const sysuserUserPost = (data) => {
|
||||
return http.post('/sysuser/user', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新系统用户信息
|
||||
* @param {Object} data - 用户信息
|
||||
* @param {number} data.id - 用户ID
|
||||
* @param {string} data.name - 姓名
|
||||
* @param {string} data.account - 账号
|
||||
* @param {Array<number>} data.roles - 角色ID列表
|
||||
* @param {string} [data.status] - 状态 (Enable=启用, Disable=禁用)
|
||||
*/
|
||||
export const sysuserUserPut = (data) => {
|
||||
return http.put('/sysuser/user', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除系统用户
|
||||
* @param {Object} data - 删除参数
|
||||
* @param {number} data.id - 用户ID
|
||||
*/
|
||||
export const sysuserDelete = (data) => {
|
||||
return http.delete('/sysuser', { data });
|
||||
};
|
||||
|
||||
/**
|
||||
* 关联角色
|
||||
* @param {Object} data - 角色关联信息
|
||||
* @param {number} data.userId - 用户ID
|
||||
* @param {Array<number>} data.roleIds - 角色ID列表
|
||||
*/
|
||||
export const sysuserGrantrolePost = (data) => {
|
||||
return http.post('/sysuser/grantrole', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 系统用户详情
|
||||
* @param {Object} params - 查询参数
|
||||
* @param {number} params.id - 用户ID
|
||||
* @returns {Promise<{
|
||||
* id: number,
|
||||
* name: string,
|
||||
* account: string,
|
||||
* roles: Array<number>,
|
||||
* status: string
|
||||
* }>}
|
||||
*/
|
||||
export const sysuserDetailGet = (params) => {
|
||||
return http.get('/sysuser/detail', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 重置系统用户密码
|
||||
* @param {Object} data - 重置密码参数
|
||||
* @param {number} data.id - 用户ID
|
||||
* @param {string} data.password - 新密码
|
||||
*/
|
||||
export const sysuserResetPatch = (data) => {
|
||||
return http.patch('/sysuser/reset', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的信息
|
||||
* @returns {Promise<{
|
||||
* name: string,
|
||||
* account: string,
|
||||
* avatar: string,
|
||||
* birthday: string,
|
||||
* email: string,
|
||||
* gender: string,
|
||||
* nickName: string,
|
||||
* remark: string,
|
||||
* lastLoginIp: string,
|
||||
* lastLoginAddress: string,
|
||||
* mobile: string,
|
||||
* orgId: number,
|
||||
* orgName: string,
|
||||
* authBtnList: Array<string>
|
||||
* }>}
|
||||
*/
|
||||
export const sysuserCurrentuserinfoGet = () => {
|
||||
return http.get('/sysuser/currentuserinfo');
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户修改账户密码
|
||||
* @param {Object} data - 修改密码参数
|
||||
* @param {string} data.originalPwd - 原密码
|
||||
* @param {string} data.password - 新密码
|
||||
*/
|
||||
export const sysuserChangepasswordPatch = (data) => {
|
||||
return http.patch('/sysuser/changepassword', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户修改头像
|
||||
* @param {string} data - 头像URL
|
||||
*/
|
||||
export const sysuserUploadavatarPatch = (data) => {
|
||||
return http.patch('/sysuser/uploadavatar', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 系统用户修改自己的信息
|
||||
* @param {Object} data - 用户信息
|
||||
* @param {string} [data.name] - 姓名
|
||||
* @param {string} [data.gender] - 性别 (Male=男, Female=女)
|
||||
* @param {string} [data.nickName] - 昵称
|
||||
* @param {string} [data.birthday] - 生日 (格式:2026-03-11)
|
||||
* @param {string} [data.mobile] - 手机号
|
||||
* @param {string} [data.email] - 邮箱
|
||||
*/
|
||||
export const sysuserUpdatecurrentuserPatch = (data) => {
|
||||
return http.patch('/sysuser/updatecurrentuser', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
* @param {Object} data - 状态参数
|
||||
* @param {number} data.id - 用户ID
|
||||
* @param {string} data.status - 状态 (Enable=启用, Disable=禁用)
|
||||
*/
|
||||
export const sysuserSetstatusPatch = (data) => {
|
||||
return http.patch('/sysuser/setstatus', data);
|
||||
};
|
||||
105
src/api/match/role.js
Normal file
105
src/api/match/role.js
Normal file
@ -0,0 +1,105 @@
|
||||
import { BaseApi } from '../baseApi';
|
||||
import { http } from '../../utils/request';
|
||||
|
||||
// ==================== 角色管理 ====================
|
||||
|
||||
/**
|
||||
* 角色分页查询
|
||||
* @param {Object} params - 查询参数
|
||||
* @param {string} [params.Name] - 角色名称 (模糊查询)
|
||||
* @param {number} [params.PageNo] - 当前页码
|
||||
* @param {number} [params.PageSize] - 每页条数
|
||||
* @returns {Promise<{
|
||||
* pageNo: number,
|
||||
* pageSize: number,
|
||||
* pages: number,
|
||||
* total: number,
|
||||
* rows: Array<{
|
||||
* id: number,
|
||||
* name: string,
|
||||
* code: string,
|
||||
* sort: number,
|
||||
* status: string,
|
||||
* remark: string,
|
||||
* createdTime: string
|
||||
* }>
|
||||
* }>}
|
||||
*/
|
||||
export const sysrolePageGet = (params) => {
|
||||
return http.get('/sysrole/page', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
* @param {Object} data - 角色信息
|
||||
* @param {string} data.name - 角色名称
|
||||
* @param {string} [data.remark] - 备注说明
|
||||
* @param {number} [data.sort] - 排序号
|
||||
* @param {string} [data.status] - 状态 (Enable=启用, Disable=禁用,默认Enable)
|
||||
*/
|
||||
export const sysroleAddPost = (data) => {
|
||||
return http.post('/sysrole/add', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
* @param {Object} data - 角色信息
|
||||
* @param {number} data.id - 角色ID
|
||||
* @param {string} data.name - 角色名称
|
||||
* @param {string} [data.remark] - 备注说明
|
||||
* @param {number} [data.sort] - 排序号
|
||||
* @param {string} [data.status] - 状态 (Enable=启用, Disable=禁用)
|
||||
*/
|
||||
export const sysroleEditPut = (data) => {
|
||||
return http.put('/sysrole/edit', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 授权角色权限
|
||||
* @param {Object} data - 权限信息
|
||||
* @param {number} data.id - 角色ID
|
||||
* @param {Array<number>} data.menuIds - 菜单/按钮ID列表
|
||||
*/
|
||||
export const sysroleGrantpermissionPost = (data) => {
|
||||
return http.post('/sysrole/grantpermission', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取角色可访问的菜单和按钮ID
|
||||
* @param {Object} params - 查询参数
|
||||
* @param {number} params.id - 角色ID
|
||||
* @returns {Promise<Array<number>>} - 返回菜单/按钮ID数组
|
||||
*/
|
||||
export const sysroleGetrolemenuGet = (params) => {
|
||||
return http.get('/sysrole/getrolemenu', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改角色状态
|
||||
* @param {Object} data - 状态参数
|
||||
* @param {number} data.id - 角色ID
|
||||
* @param {string} data.status - 状态 (Enable=启用, Disable=禁用)
|
||||
*/
|
||||
export const sysroleSetstatusPut = (data) => {
|
||||
return http.put('/sysrole/setstatus', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
* @param {Object} data - 删除参数
|
||||
* @param {number} data.id - 角色ID
|
||||
*/
|
||||
export const sysroleDeleteDelete = (data) => {
|
||||
return http.delete('/sysrole/delete', { data });
|
||||
};
|
||||
|
||||
/**
|
||||
* 角色下拉选项
|
||||
* @returns {Promise<Array<{
|
||||
* label: string,
|
||||
* value: number
|
||||
* }>>} - 返回下拉选项列表
|
||||
*/
|
||||
export const sysroleSelectGet = () => {
|
||||
return http.get('/sysrole/select');
|
||||
};
|
||||
@ -350,6 +350,46 @@ export const dynamicRoutes: Array<RouteRecordRaw> = [
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/permission',
|
||||
name: 'permission',
|
||||
component: () => import('/@/views/permission/account/index.vue'),
|
||||
meta: {
|
||||
isKeepAlive: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/permission/account',
|
||||
name: 'account',
|
||||
component: () => import('/@/views/permission/account/index.vue'),
|
||||
meta: {
|
||||
title: '账户管理',
|
||||
isLink: '',
|
||||
isHide: false,
|
||||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin', 'common'],
|
||||
icon: 'iconfont icon-shouye',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/permission/role',
|
||||
name: 'role',
|
||||
component: () => import('/@/views/permission/role/index.vue'),
|
||||
meta: {
|
||||
title: '角色管理',
|
||||
isLink: '',
|
||||
isHide: false,
|
||||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin', 'common'],
|
||||
icon: 'iconfont icon-shouye',
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -52,14 +52,14 @@
|
||||
</el-form-item>
|
||||
|
||||
<!-- 填写折扣 -->
|
||||
<el-form-item label="填写折扣" prop="value" v-if="formData.type === '1'">
|
||||
<el-form-item label="填写折扣" prop="value" v-if="formData.type == '1'">
|
||||
<el-input v-model="formData.value" placeholder="请输入折扣百分比">
|
||||
<template #append>%</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 填写优惠金额 -->
|
||||
<el-form-item label="填写优惠金额" prop="value" v-if="formData.type === '2'">
|
||||
<el-form-item label="填写优惠金额" prop="value" v-if="formData.type == '2'">
|
||||
<el-input v-model="formData.value" placeholder="请输入优惠金额" class="fee-input">
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
@ -190,8 +190,9 @@ const onOpenMenu = async (row) => {
|
||||
|
||||
//删除菜单
|
||||
const onDeleteMenu = async (id) => {
|
||||
const { succeeded, errors } = await SysMenuApi.delete({ id });
|
||||
const { succeeded, errors } = await couponDelete([ id ]);
|
||||
if (succeeded) {
|
||||
initParam.value = !initParam.value;
|
||||
ElMessage.success('删除成功');
|
||||
} else {
|
||||
ElMessage.error(errors);
|
||||
|
||||
244
src/views/permission/account/index.vue
Normal file
244
src/views/permission/account/index.vue
Normal file
@ -0,0 +1,244 @@
|
||||
<template>
|
||||
<div class="system-menu-container layout-padding">
|
||||
<ProTable ref="tableRef" :request-api="sysuserPageGet" :columns="columns" :pagination="true"
|
||||
:tool-button="false" :initParam="initParam">
|
||||
<template #tools>
|
||||
<el-button v-auth="'permission:account:add'" type="primary" icon="ele-Plus" @click="onOpenMenu()"> 新增
|
||||
</el-button>
|
||||
</template>
|
||||
<template #index="scope">
|
||||
{{ scope.$index + 1 }}
|
||||
</template>
|
||||
<template #action="scope">
|
||||
<el-button v-auth="'permission:account:edit'" icon="ele-Edit" size="small" text type="primary"
|
||||
@click="onOpenMenu(scope.row)"> 编辑 </el-button>
|
||||
<el-popconfirm title="确认删除吗?" @confirm="onDeleteMenu(scope.row.id)">
|
||||
<template #reference>
|
||||
<el-button v-auth="'permission:account:delete'" icon="ele-Delete" size="small" text
|
||||
type="danger"> 删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<el-dialog :title="dialogTitle" v-model="isShowDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="150px"
|
||||
style="max-width: 600px;margin-bottom: 30px;" v-if="isShowDialog">
|
||||
|
||||
<!-- 商户名称 -->
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入优惠券名称"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 账号 -->
|
||||
<el-form-item label="账号" prop="account">
|
||||
<el-input v-model="formData.account" placeholder="请输入账号"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 可用赛事 -->
|
||||
<el-form-item label="关联角色" prop="roles">
|
||||
<el-select v-model="formData.roles" placeholder="请选择关联角色" multiple style="width: 100%;">
|
||||
<el-option v-for="item in eventList" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="onCancel">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="sysMenu">
|
||||
import { defineAsyncComponent, ref, reactive, onMounted } from 'vue';
|
||||
import { ElMessage, ElForm } from 'element-plus';
|
||||
import SysMenuApi from '/@/api/SysMenuApi';
|
||||
import { auths } from '/@/utils/authFunction';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
import { sysuserPageGet, sysuserUserPost, sysuserUserPut, sysuserDelete } from '/@/api/match/account';
|
||||
import { sysroleSelectGet } from '/@/api/match/role';
|
||||
|
||||
// 定义表单引用类型
|
||||
const formRef = ref();
|
||||
const eventList = ref([]);
|
||||
const formData = ref({
|
||||
name: '',
|
||||
account: '',
|
||||
roles: []
|
||||
})
|
||||
const initParam = ref(true)
|
||||
const formRules = ref({
|
||||
name: [
|
||||
{ required: true, message: '姓名', trigger: 'blur' }
|
||||
],
|
||||
account: [
|
||||
{ required: true, message: '请输入账号', trigger: 'blur' }
|
||||
],
|
||||
});
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
prop: 'index',
|
||||
label: '序号',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '姓名',
|
||||
align: 'center',
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'account',
|
||||
label: '账号',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
prop: 'roleNames',
|
||||
label: '关联角色',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
prop: 'roleId',
|
||||
label: '关联角色',
|
||||
align: 'center',
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'select',
|
||||
enum: [],
|
||||
},
|
||||
},
|
||||
{ prop: 'createdTime', label: '生成时间', search: { el: 'date-picker', props: { type: 'date' } } },
|
||||
|
||||
{ prop: 'action', label: '操作', align: 'center', fixed: 'right', isShow: auths(['coupon:delete', 'coupon:edit']) },
|
||||
]);
|
||||
|
||||
const isShowDialog = ref(false);
|
||||
const dialogTitle = ref('新增');
|
||||
|
||||
const onOpenMenu = async (row) => {
|
||||
|
||||
dialogTitle.value = row ? '编辑' : '新增';
|
||||
if (row) {
|
||||
formData.value = row;
|
||||
|
||||
} else {
|
||||
formData.value = {
|
||||
name: '',
|
||||
account: '',
|
||||
roles: []
|
||||
};
|
||||
}
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
//删除菜单
|
||||
const onDeleteMenu = async (id) => {
|
||||
const { succeeded, errors } = await sysuserDelete({ id });
|
||||
if (succeeded) {
|
||||
initParam.value = !initParam.value;
|
||||
ElMessage.success('删除成功');
|
||||
} else {
|
||||
ElMessage.error(errors);
|
||||
}
|
||||
};
|
||||
|
||||
// 表单提交
|
||||
const onSubmit = () => {
|
||||
if (!formRef.value) return;
|
||||
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
|
||||
try {
|
||||
let res;
|
||||
if (formData.value.id) {
|
||||
res = await sysuserUserPut(formData.value);
|
||||
} else {
|
||||
res = await sysuserUserPost(formData.value);
|
||||
}
|
||||
|
||||
if (res.succeeded) {
|
||||
initParam.value = !initParam.value;
|
||||
ElMessage.success(dialogTitle.value + '成功');
|
||||
isShowDialog.value = false;
|
||||
} else {
|
||||
ElMessage.error(res.errors);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const { data } = await sysroleSelectGet();
|
||||
console.log('获取的角色数据:', data);
|
||||
columns.value[4].search.enum = data;
|
||||
eventList.value = data;
|
||||
});
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.dialog-footer {
|
||||
margin-top: 80px;
|
||||
}
|
||||
|
||||
/* 时长组合框样式 */
|
||||
.duration-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.duration-row .el-input {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.duration-separator {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.duration-label {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.avatar-uploader .el-upload {
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: var(--el-transition-duration-fast);
|
||||
}
|
||||
|
||||
.avatar-uploader .el-upload:hover {
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.el-icon.avatar-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
200
src/views/permission/role/index.vue
Normal file
200
src/views/permission/role/index.vue
Normal file
@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<div class="system-menu-container layout-padding">
|
||||
<ProTable ref="tableRef" :request-api="sysrolePageGet" :columns="columns" :pagination="true" :tool-button="false" :initParam="initParam">
|
||||
<template #tools>
|
||||
<el-button v-auth="'permission:role:add'" type="primary" icon="ele-Plus" @click="onOpenMenu()"> 新增 </el-button>
|
||||
</template>
|
||||
<template #index="scope">
|
||||
{{ scope.$index + 1 }}
|
||||
</template>
|
||||
<template #action="scope">
|
||||
<el-button v-auth="'permission:role:edit'" icon="ele-Edit" size="small" text type="primary"
|
||||
@click="onOpenMenu(scope.row)"> 编辑 </el-button>
|
||||
<el-popconfirm title="确认删除吗?" @confirm="onDeleteMenu(scope.row.id)">
|
||||
<template #reference>
|
||||
<el-button v-auth="'permission:role:delete'" icon="ele-Delete" size="small" text type="danger"> 删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
<el-button v-auth="'permission:role:config'" size="small" text type="primary" @click="getSdk(scope.row.id)"> 权限配置 </el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<el-dialog :title="dialogTitle" v-model="isShowDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="150px"
|
||||
style="max-width: 600px;margin-bottom: 30px;" v-if="isShowDialog">
|
||||
|
||||
<!-- 商户名称 -->
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入角色名称"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 填写描述 -->
|
||||
<el-form-item label="填写描述" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入角色描述"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="onCancel">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="sysMenu">
|
||||
import { defineAsyncComponent, ref, reactive } from 'vue';
|
||||
import { ElMessage, ElForm } from 'element-plus';
|
||||
import SysMenuApi from '/@/api/SysMenuApi';
|
||||
import { auths } from '/@/utils/authFunction';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
import { sysrolePageGet, sysroleAddPost, sysroleEditPut, sysroleDeleteDelete } from '/@/api/match/role';
|
||||
// 定义表单引用类型
|
||||
const formRef = ref();
|
||||
const eventList = ref([]);
|
||||
const formData = ref({
|
||||
name: '',
|
||||
remark: '',
|
||||
})
|
||||
const initParam = ref(true)
|
||||
const formRules = ref({
|
||||
name: [
|
||||
{ required: true, message: '请输入角色名称', trigger: 'blur' }
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
prop: 'index',
|
||||
label: '序号',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '角色名称',
|
||||
align: 'center',
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
},
|
||||
{ prop: 'remark', label: '角色描述'},
|
||||
{ prop: 'action', label: '操作', align: 'center', fixed: 'right', isShow: auths(['permission:role:add', 'permission:role:edit']) },
|
||||
]);
|
||||
|
||||
const isShowDialog = ref(false);
|
||||
const dialogTitle = ref('新增');
|
||||
|
||||
const onOpenMenu = async (row) => {
|
||||
|
||||
dialogTitle.value = row ? '编辑' : '新增';
|
||||
if (row) {
|
||||
formData.value = row;
|
||||
|
||||
} else {
|
||||
formData.value = {
|
||||
name: '',
|
||||
remark: '',
|
||||
};
|
||||
}
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
//删除菜单
|
||||
const onDeleteMenu = async (id) => {
|
||||
const { succeeded, errors } = await sysroleDeleteDelete({ id });
|
||||
if (succeeded) {
|
||||
initParam.value = !initParam.value;
|
||||
ElMessage.success('删除成功');
|
||||
} else {
|
||||
ElMessage.error(errors);
|
||||
}
|
||||
};
|
||||
|
||||
// 表单提交
|
||||
const onSubmit = () => {
|
||||
if (!formRef.value) return;
|
||||
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
|
||||
try {
|
||||
let res;
|
||||
if (formData.value.id) {
|
||||
res = await sysroleEditPut(formData.value);
|
||||
} else {
|
||||
res = await sysroleAddPost(formData.value);
|
||||
}
|
||||
|
||||
if (res.succeeded) {
|
||||
initParam.value = !initParam.value;
|
||||
ElMessage.success(dialogTitle.value + '成功');
|
||||
isShowDialog.value = false;
|
||||
} else {
|
||||
ElMessage.error(res.errors);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.dialog-footer {
|
||||
margin-top: 80px;
|
||||
}
|
||||
|
||||
/* 时长组合框样式 */
|
||||
.duration-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.duration-row .el-input {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.duration-separator {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.duration-label {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.avatar-uploader .el-upload {
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: var(--el-transition-duration-fast);
|
||||
}
|
||||
|
||||
.avatar-uploader .el-upload:hover {
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.el-icon.avatar-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user