-
-
-
-
-
-
- 新建
-
-
-
-
-
-
-
-
- 刷新
-
-
-
-
-
+
+
+
+
-
-
getDictContent(lastDictCode)" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+ 新增字典数据
+
+
+
+
+
+
+
-
-
diff --git a/src/views/setting/menu/columns.tsx b/src/views/setting/menu/columns.tsx
index 5321346..56dbc61 100644
--- a/src/views/setting/menu/columns.tsx
+++ b/src/views/setting/menu/columns.tsx
@@ -88,7 +88,7 @@ export function createMenuColumns(actions: MenuColumnActions): DataTableColumns<
type="primary"
onClick={() => onAdd(row)}
>
- 新建
+ 新增
)}
) {
modalForm.open()
const handlers = {
async add() {
- // 如果新建传入了menuId,设置为父级菜单
+ // 如果新增传入了menuId,设置为父级菜单
if (data?.id) {
modalForm.values.value.parentId = data.id
modalForm.values.value.path = `${data.path}/`
@@ -93,27 +93,34 @@ async function submitModal(filedValues: Partial) {
try {
await createMenu(filedValues)
window.$message.success('菜单创建成功')
+ return true
}
catch (error) {
console.error('创建菜单失败', error)
+ return false
}
},
async edit() {
try {
await updateMenu(modalForm.values.value.id!, filedValues)
window.$message.success('菜单更新成功')
+ return true
}
catch (error) {
console.error('更新菜单失败', error)
+ return false
}
},
}
startLoading()
- await handlers[modalType.value]()
- emit('success')
- modalForm.close()
+ const success = await handlers[modalType.value]()
endLoading()
+
+ if (success) {
+ emit('success')
+ modalForm.close()
+ }
}
defineExpose({
@@ -127,6 +134,7 @@ defineExpose({
:form="modalForm"
:loading="submitLoading"
width="700px"
+ label-width="120px"
>
{
-
+
- 新建
+ 新增
diff --git a/src/views/setting/role/columns.tsx b/src/views/setting/role/columns.tsx
index 45a59f3..1731f27 100644
--- a/src/views/setting/role/columns.tsx
+++ b/src/views/setting/role/columns.tsx
@@ -9,12 +9,12 @@ export const searchColumns: ProSearchFormColumns = [
path: 'roleName',
},
{
- title: '角色权限',
+ title: '权限标识',
path: 'roleKey',
},
{
title: '状态',
- path: 'roleStatus',
+ path: 'status',
field: 'select',
fieldProps: {
options: [
@@ -35,24 +35,18 @@ export const searchColumns: ProSearchFormColumns = [
interface RoleColumnActions {
onEdit: (row: Entity.Role) => void
onDelete: (id: number) => void
- onStatusChange: (value: 0 | 1, id: number) => void
+ onStatusChange: (id: number, value: 0 | 1) => void
}
export function createRoleColumns(actions: RoleColumnActions): DataTableColumns {
return [
- {
- title: '角色ID',
- align: 'center',
- key: 'roleId',
- width: 80,
- },
{
title: '角色名称',
align: 'center',
key: 'roleName',
},
{
- title: '角色权限',
+ title: '权限标识',
align: 'center',
key: 'roleKey',
render: row => renderProCopyableText(row.roleKey),
@@ -63,25 +57,18 @@ export function createRoleColumns(actions: RoleColumnActions): DataTableColumns<
key: 'remark',
width: 200,
},
- {
- title: '排序',
- align: 'center',
- key: 'sort',
- width: 80,
- },
{
title: '状态',
align: 'center',
- key: 'roleStatus',
+ key: 'status',
width: 100,
render: (row) => {
return (
- actions.onStatusChange(value, row.roleId)}
+ value={row.status}
+ checked-value={0}
+ unchecked-value={1}
+ onUpdateValue={(value: 0 | 1) => actions.onStatusChange(row.id, value)}
>
{{ checked: () => '启用', unchecked: () => '禁用' }}
@@ -106,19 +93,19 @@ export function createRoleColumns(actions: RoleColumnActions): DataTableColumns<
return (
actions.onEdit(row)}
>
编辑
actions.onDelete(row.roleId)}
+ onPositiveClick={() => actions.onDelete(row.id)}
>
{{
default: () => '确认删除该角色?',
trigger: () => (
-
+
删除
),
diff --git a/src/views/setting/role/components/RoleModal.vue b/src/views/setting/role/components/RoleModal.vue
index 7e27253..c768d37 100644
--- a/src/views/setting/role/components/RoleModal.vue
+++ b/src/views/setting/role/components/RoleModal.vue
@@ -20,11 +20,7 @@ const { bool: submitLoading, setTrue: startLoading, setFalse: endLoading } = use
const modalForm = createProModalForm>({
omitEmptyString: false,
initialValues: {
- roleName: '',
- roleKey: '',
- remark: '',
- sort: 0,
- roleStatus: 1,
+ status: 0,
},
onSubmit: submitModal,
})
@@ -51,7 +47,7 @@ async function openModal(type: ModalType = 'add', data?: Partial) {
if (!data)
return
- const { data: role } = await getRoleById(data.roleId!)
+ const { data: role } = await getRoleById(data.id!)
modalForm.values.value = role
},
}
@@ -64,28 +60,33 @@ async function submitModal(filedValues: Partial) {
try {
await createRole(filedValues)
window.$message.success('角色创建成功')
+ return true
}
catch (error) {
console.error('创建角色失败', error)
- window.$message.error('创建角色失败')
+ return false
}
},
async edit() {
try {
- await updateRole(modalForm.values.value.roleId!, filedValues)
+ await updateRole(modalForm.values.value.id!, filedValues)
window.$message.success('角色更新成功')
+ return true
}
catch (error) {
console.error('更新角色失败', error)
- window.$message.error('更新角色失败')
+ return false
}
},
}
startLoading()
- await handlers[modalType.value]()
+ const success = await handlers[modalType.value]()
endLoading()
- emit('success')
- modalForm.close()
+
+ if (success) {
+ emit('success')
+ modalForm.close()
+ }
}
defineExpose({
@@ -105,29 +106,21 @@ defineExpose({
required
title="角色名称"
path="roleName"
- placeholder="请输入角色名称"
/>
+
-
-
diff --git a/src/views/setting/role/index.vue b/src/views/setting/role/index.vue
index f1187b4..2444f84 100644
--- a/src/views/setting/role/index.vue
+++ b/src/views/setting/role/index.vue
@@ -1,6 +1,6 @@