feat(系统设置): 用户组管理新增用户组接口对接
This commit is contained in:
parent
88ed8dc8a8
commit
8603b1cc2c
|
@ -3,25 +3,31 @@
|
||||||
v-model:visible="currentVisible"
|
v-model:visible="currentVisible"
|
||||||
width="680px"
|
width="680px"
|
||||||
:ok-text="t('system.userGroup.create')"
|
:ok-text="t('system.userGroup.create')"
|
||||||
@ok="handelOk"
|
:loading="props.loading"
|
||||||
|
unmount-on-close
|
||||||
|
:on-before-ok="handleBeforeOk"
|
||||||
@cancel="handleCancel"
|
@cancel="handleCancel"
|
||||||
>
|
>
|
||||||
<template #title> {{ t('system.userGroup.createUserGroup') }} </template>
|
<template #title> {{ t('system.userGroup.createUserGroup') }} </template>
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<a-form :model="form" size="large" :style="{ width: '600px' }" layout="vertical">
|
<a-form ref="formRef" :model="form" size="large" :style="{ width: '600px' }" layout="vertical">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
field="name"
|
field="name"
|
||||||
|
required
|
||||||
:label="t('system.userGroup.userGroupName')"
|
:label="t('system.userGroup.userGroupName')"
|
||||||
:rules="[{ required: true, message: t('system.userGroup.userGroupNameIsNotNone') }]"
|
:rules="[
|
||||||
|
{ required: true, message: t('system.userGroup.userGroupNameIsNotNone') },
|
||||||
|
{ validator: validateName },
|
||||||
|
]"
|
||||||
>
|
>
|
||||||
<a-input v-model="form.name" :placeholder="t('system.userGroup.pleaseInputUserGroupName')" />
|
<a-input v-model="form.name" :placeholder="t('system.userGroup.pleaseInputUserGroupName')" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item
|
<a-form-item
|
||||||
field="authScope"
|
field="type"
|
||||||
:label="t('system.userGroup.authScope')"
|
:label="t('system.userGroup.authScope')"
|
||||||
:rules="[{ required: true, message: t('system.userGroup.authScopeIsNotNone') }]"
|
:rules="[{ required: true, message: t('system.userGroup.authScopeIsNotNone') }]"
|
||||||
>
|
>
|
||||||
<a-select v-model="form.authScope" :placeholder="t('system.userGroup.pleaseSelectAuthScope')">
|
<a-select v-model="form.type" :placeholder="t('system.userGroup.pleaseSelectAuthScope')">
|
||||||
<a-option value="SYSTEM">{{ t('system.userGroup.SYSTEM') }}</a-option>
|
<a-option value="SYSTEM">{{ t('system.userGroup.SYSTEM') }}</a-option>
|
||||||
<a-option value="ORGANIZATION">{{ t('system.userGroup.ORGANIZATION') }}</a-option>
|
<a-option value="ORGANIZATION">{{ t('system.userGroup.ORGANIZATION') }}</a-option>
|
||||||
<a-option value="PROJECT">{{ t('system.userGroup.PROJECT') }}</a-option>
|
<a-option value="PROJECT">{{ t('system.userGroup.PROJECT') }}</a-option>
|
||||||
|
@ -35,23 +41,40 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
import { reactive, ref, watchEffect } from 'vue';
|
import { reactive, ref, watchEffect } from 'vue';
|
||||||
|
import { UserGroupItem } from './type';
|
||||||
|
import type { FormInstance, ValidatedError } from '@arco-design/web-vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
list: UserGroupItem[];
|
||||||
|
loading: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'cancel'): void;
|
(e: 'cancel'): void;
|
||||||
|
(e: 'submit', value: Partial<UserGroupItem>): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
authScope: '',
|
type: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentVisible = ref(props.visible);
|
const currentVisible = ref(props.visible);
|
||||||
|
|
||||||
|
const validateName = (value: string, callback: (error?: string) => void) => {
|
||||||
|
if (value !== '') {
|
||||||
|
const isExist = props.list.some((item) => item.name === value);
|
||||||
|
if (isExist) {
|
||||||
|
callback(t('system.userGroup.userGroupNameIsExist', { name: value }));
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
currentVisible.value = props.visible;
|
currentVisible.value = props.visible;
|
||||||
});
|
});
|
||||||
|
@ -59,9 +82,13 @@
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handelOk = () => {
|
const handleBeforeOk = () => {
|
||||||
// eslint-disable-next-line no-console
|
formRef.value?.validate((errors: undefined | Record<string, ValidatedError>) => {
|
||||||
console.log('ok');
|
if (errors) {
|
||||||
handleCancel();
|
return false;
|
||||||
|
}
|
||||||
|
emit('submit', form);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
:scroll="{ y: '860px', x: '1440px' }"
|
:scroll="{ y: '860px', x: '1440px' }"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="data"
|
:data="data"
|
||||||
:span-method="dataSpanMethod"
|
|
||||||
:bordered="{ wrapper: true, cell: true }"
|
:bordered="{ wrapper: true, cell: true }"
|
||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { TableData, TableColumnData } from '@arco-design/web-vue';
|
import { TableData } from '@arco-design/web-vue';
|
||||||
import { RenderFunction, VNodeChild } from 'vue';
|
import { RenderFunction, VNodeChild } from 'vue';
|
||||||
|
|
||||||
export declare type OperationName = 'selection-checkbox' | 'selection-radio' | 'expand' | 'drag-handle';
|
export declare type OperationName = 'selection-checkbox' | 'selection-radio' | 'expand' | 'drag-handle';
|
||||||
|
@ -79,20 +78,4 @@
|
||||||
email: 'william.smith@example.com',
|
email: 'william.smith@example.com',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const dataSpanMethod = ({
|
|
||||||
record,
|
|
||||||
column,
|
|
||||||
}: {
|
|
||||||
record: TableData;
|
|
||||||
column: TableColumnData | TableOperationColumn;
|
|
||||||
rowIndex: number;
|
|
||||||
columnIndex: number;
|
|
||||||
}): { rowspan?: number; colspan?: number } | void => {
|
|
||||||
if (record.name === 'Alisa Ross' && column.dataIndex === 'salary') {
|
|
||||||
return {
|
|
||||||
rowspan: 2,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -48,7 +48,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<AddUserModal :visible="addUserVisible" @cancel="addUserVisible = false" />
|
<AddUserModal :visible="addUserVisible" @cancel="addUserVisible = false" />
|
||||||
<AddUserGroupModal :visible="addUserGroupVisible" @cancel="addUserGroupVisible = false" />
|
<AddUserGroupModal
|
||||||
|
:list="userGroupList"
|
||||||
|
:visible="addUserGroupVisible"
|
||||||
|
:loading="addUserGrouploading"
|
||||||
|
@cancel="addUserGroupVisible = false"
|
||||||
|
@submit="handleAddUserGroup"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -74,6 +80,7 @@
|
||||||
const currentId = ref('');
|
const currentId = ref('');
|
||||||
const addUserVisible = ref(false);
|
const addUserVisible = ref(false);
|
||||||
const addUserGroupVisible = ref(false);
|
const addUserGroupVisible = ref(false);
|
||||||
|
const addUserGrouploading = ref(false);
|
||||||
// 修改用户组名字,权限范围
|
// 修改用户组名字,权限范围
|
||||||
const popVisible = ref<PopVisibleItem>({});
|
const popVisible = ref<PopVisibleItem>({});
|
||||||
// 用户组和权限范围的状态
|
// 用户组和权限范围的状态
|
||||||
|
@ -212,6 +219,23 @@
|
||||||
const tmpArr = userGroupList.value.filter((ele) => ele.name.includes(keyword));
|
const tmpArr = userGroupList.value.filter((ele) => ele.name.includes(keyword));
|
||||||
userGroupList.value = tmpArr;
|
userGroupList.value = tmpArr;
|
||||||
}
|
}
|
||||||
|
// 新增用户组
|
||||||
|
const handleAddUserGroup = async (value: Partial<UserGroupItem>) => {
|
||||||
|
try {
|
||||||
|
addUserGrouploading.value = true;
|
||||||
|
const res = await updateOrAddUserGroup(value);
|
||||||
|
if (res) {
|
||||||
|
Message.success(t('system.userGroup.addUserGroupSuccess'));
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
addUserGrouploading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initData();
|
initData();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue