style(系统设置): 样式优化

This commit is contained in:
RubyLiu 2023-10-25 20:03:29 +08:00 committed by rubylliu
parent cfb103f2ae
commit f306e1628d
15 changed files with 87 additions and 39 deletions

View File

@ -175,9 +175,9 @@
try { try {
await updateOrAddProjectUserGroup(record); await updateOrAddProjectUserGroup(record);
Message.success(t('common.updateSuccess')); Message.success(t('common.updateSuccess'));
return true;
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console return false;
console.log(error);
} }
}; };

View File

@ -116,6 +116,7 @@
} }
const handleCancel = () => { const handleCancel = () => {
keyword.value = '';
emit('cancel'); emit('cancel');
}; };
@ -149,9 +150,15 @@
console.error(error); console.error(error);
} }
}; };
watchEffect(() => { watch(
currentVisible.value = props.visible; () => props.visible,
}); (visible) => {
currentVisible.value = visible;
if (visible) {
fetchData();
}
}
);
watchEffect(() => { watchEffect(() => {
const { projectId, userRoleId } = props; const { projectId, userRoleId } = props;
if (projectId && userRoleId) { if (projectId && userRoleId) {

View File

@ -21,11 +21,12 @@
field="name" field="name"
required required
:label="t('system.project.name')" :label="t('system.project.name')"
asterisk-position="end"
:rules="[{ required: true, message: t('system.project.projectNameRequired') }]" :rules="[{ required: true, message: t('system.project.projectNameRequired') }]"
> >
<a-input v-model="form.name" allow-clear :placeholder="t('system.project.projectNamePlaceholder')" /> <a-input v-model="form.name" allow-clear :placeholder="t('system.project.projectNamePlaceholder')" />
</a-form-item> </a-form-item>
<a-form-item field="organizationId" :label="t('system.project.affiliatedOrg')"> <a-form-item field="organizationId" asterisk-position="end" :label="t('system.project.affiliatedOrg')">
<a-select <a-select
v-model="form.organizationId" v-model="form.organizationId"
disabled disabled
@ -166,7 +167,6 @@
form.resourcePoolIds = []; form.resourcePoolIds = [];
}; };
const handleCancel = (shouldSearch: boolean) => { const handleCancel = (shouldSearch: boolean) => {
formReset();
emit('cancel', shouldSearch); emit('cancel', shouldSearch);
}; };
@ -200,7 +200,6 @@
} }
}; };
watchEffect(() => { watchEffect(() => {
initAffiliatedOrgOption();
if (isEdit.value && props.currentProject) { if (isEdit.value && props.currentProject) {
form.id = props.currentProject.id; form.id = props.currentProject.id;
form.name = props.currentProject.name; form.name = props.currentProject.name;
@ -212,4 +211,15 @@
form.resourcePoolIds = props.currentProject.resourcePoolIds; form.resourcePoolIds = props.currentProject.resourcePoolIds;
} }
}); });
watch(
() => props.visible,
(val) => {
currentVisible.value = val;
if (!val) {
formReset();
} else {
initAffiliatedOrgOption();
}
}
);
</script> </script>

View File

@ -13,6 +13,7 @@
<a-form-item <a-form-item
field="name" field="name"
:label="t('system.organization.member')" :label="t('system.organization.member')"
asterisk-position="end"
:rules="[{ required: true, message: t('system.organization.addMemberRequired') }]" :rules="[{ required: true, message: t('system.organization.addMemberRequired') }]"
> >
<MsUserSelector <MsUserSelector

View File

@ -115,6 +115,7 @@
} }
const handleCancel = () => { const handleCancel = () => {
keyword.value = '';
emit('cancel'); emit('cancel');
}; };
@ -157,6 +158,9 @@
() => props.visible, () => props.visible,
(visible) => { (visible) => {
currentVisible.value = visible; currentVisible.value = visible;
if (visible) {
fetchData();
}
} }
); );
</script> </script>

View File

@ -5,7 +5,7 @@
:ok-text="t('system.organization.create')" :ok-text="t('system.organization.create')"
unmount-on-close unmount-on-close
title-align="start" title-align="start"
@cancel="handleCancel" @cancel="handleCancel(false)"
> >
<template #title> <template #title>
<span v-if="isEdit"> <span v-if="isEdit">
@ -21,6 +21,7 @@
<a-form-item <a-form-item
field="name" field="name"
required required
asterisk-position="end"
:label="t('system.organization.organizationName')" :label="t('system.organization.organizationName')"
:rules="[{ required: true, message: t('system.organization.organizationNameRequired') }]" :rules="[{ required: true, message: t('system.organization.organizationNameRequired') }]"
> >
@ -39,7 +40,7 @@
</a-form> </a-form>
</div> </div>
<template #footer> <template #footer>
<a-button type="secondary" :loading="loading" @click="handleCancel"> <a-button type="secondary" :disabled="loading" @click="handleCancel(false)">
{{ t('common.cancel') }} {{ t('common.cancel') }}
</a-button> </a-button>
<a-button type="primary" :loading="loading" @click="handleBeforeOk"> <a-button type="primary" :loading="loading" @click="handleBeforeOk">
@ -74,8 +75,7 @@
const loading = ref(false); const loading = ref(false);
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'cancel'): void; (e: 'cancel', shouldSearch: boolean): void;
(e: 'submit'): void;
}>(); }>();
const form = reactive<{ name: string; userIds: string[]; description: string }>({ const form = reactive<{ name: string; userIds: string[]; description: string }>({
@ -89,13 +89,9 @@
watchEffect(() => { watchEffect(() => {
currentVisible.value = props.visible; currentVisible.value = props.visible;
}); });
const handleCancel = () => { const handleCancel = (shouldSearch = false) => {
emit('cancel'); emit('cancel', shouldSearch);
}; formRef.value?.resetFields();
const handleSubmit = () => {
handleCancel();
emit('submit');
}; };
const handleBeforeOk = () => { const handleBeforeOk = () => {
@ -111,12 +107,10 @@
? t('system.organization.updateOrganizationSuccess') ? t('system.organization.updateOrganizationSuccess')
: t('system.organization.createOrganizationSuccess') : t('system.organization.createOrganizationSuccess')
); );
handleSubmit(); handleCancel(true);
return true;
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(error); console.error(error);
return false;
} finally { } finally {
loading.value = false; loading.value = false;
} }

View File

@ -21,6 +21,7 @@
<a-form-item <a-form-item
field="name" field="name"
required required
asterisk-position="end"
:label="t('system.project.name')" :label="t('system.project.name')"
:rules="[{ required: true, message: t('system.project.projectNameRequired') }]" :rules="[{ required: true, message: t('system.project.projectNameRequired') }]"
> >
@ -29,6 +30,7 @@
<a-form-item <a-form-item
required required
field="organizationId" field="organizationId"
asterisk-position="end"
:label="t('system.project.affiliatedOrg')" :label="t('system.project.affiliatedOrg')"
:rules="[{ required: true, message: t('system.project.affiliatedOrgRequired') }]" :rules="[{ required: true, message: t('system.project.affiliatedOrgRequired') }]"
> >
@ -73,14 +75,14 @@
<template #footer> <template #footer>
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<div class="flex flex-row items-center gap-[4px]"> <div class="flex flex-row items-center gap-[4px]">
<a-switch v-model="form.enable" /> <a-switch v-model="form.enable" size="small" />
<span>{{ t('system.organization.status') }}</span> <span>{{ t('system.organization.status') }}</span>
<a-tooltip :content="t('system.project.createTip')" position="top"> <a-tooltip :content="t('system.project.createTip')" position="top">
<MsIcon type="icon-icon-maybe_outlined" class="text-[var(--color-text-4)]" /> <MsIcon type="icon-icon-maybe_outlined" class="text-[var(--color-text-4)]" />
</a-tooltip> </a-tooltip>
</div> </div>
<div class="flex flex-row gap-[14px]"> <div class="flex flex-row gap-[14px]">
<a-button type="secondary" :loading="loading" @click="handleCancel(false)"> <a-button type="secondary" :disabled="loading" @click="handleCancel(false)">
{{ t('common.cancel') }} {{ t('common.cancel') }}
</a-button> </a-button>
<a-button type="primary" :loading="loading" @click="handleBeforeOk"> <a-button type="primary" :loading="loading" @click="handleBeforeOk">
@ -151,10 +153,6 @@
return licenseStore.hasLicense(); return licenseStore.hasLicense();
}); });
watchEffect(() => {
currentVisible.value = props.visible;
});
const formReset = () => { const formReset = () => {
form.name = ''; form.name = '';
form.userIds = []; form.userIds = [];
@ -165,7 +163,6 @@
}; };
const handleCancel = (shouldSearch: boolean) => { const handleCancel = (shouldSearch: boolean) => {
emit('cancel', shouldSearch); emit('cancel', shouldSearch);
formReset();
}; };
const handleBeforeOk = async () => { const handleBeforeOk = async () => {
@ -179,7 +176,6 @@
Message.success( Message.success(
isEdit.value ? t('system.project.updateProjectSuccess') : t('system.project.createProjectSuccess') isEdit.value ? t('system.project.updateProjectSuccess') : t('system.project.createProjectSuccess')
); );
handleCancel(true); handleCancel(true);
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@ -199,7 +195,6 @@
} }
}; };
watchEffect(() => { watchEffect(() => {
initAffiliatedOrgOption();
if (props.currentProject) { if (props.currentProject) {
form.id = props.currentProject.id; form.id = props.currentProject.id;
form.name = props.currentProject.name; form.name = props.currentProject.name;
@ -211,4 +206,15 @@
form.resourcePoolIds = props.currentProject.resourcePoolIds; form.resourcePoolIds = props.currentProject.resourcePoolIds;
} }
}); });
watch(
() => props.visible,
(val) => {
currentVisible.value = val;
if (!val) {
formReset();
} else {
initAffiliatedOrgOption();
}
}
);
</script> </script>

View File

@ -12,6 +12,7 @@
<a-form ref="formRef" class="rounded-[4px]" :model="form" layout="vertical"> <a-form ref="formRef" class="rounded-[4px]" :model="form" layout="vertical">
<a-form-item <a-form-item
field="name" field="name"
asterisk-position="end"
:label="t('system.organization.member')" :label="t('system.organization.member')"
:rules="[{ required: true, message: t('system.organization.addMemberRequired') }]" :rules="[{ required: true, message: t('system.organization.addMemberRequired') }]"
> >

View File

@ -106,6 +106,11 @@
() => props.visible, () => props.visible,
(visible) => { (visible) => {
currentVisible.value = visible; currentVisible.value = visible;
if (visible) {
fetchData();
} else {
setKeyword('');
}
} }
); );
</script> </script>

View File

@ -187,6 +187,7 @@
const currentUserDrawer = reactive({ const currentUserDrawer = reactive({
visible: false, visible: false,
organizationId: '', organizationId: '',
currentName: '',
}); });
const tableActions: ActionsItem[] = [ const tableActions: ActionsItem[] = [
@ -221,11 +222,11 @@
}; };
const handleEnableOrDisableOrg = async (record: any, isEnable = true) => { const handleEnableOrDisableOrg = async (record: any, isEnable = true) => {
const title = isEnable ? t('system.organization.enableTitle') : t('system.organization.enableTitle'); const title = isEnable ? t('system.organization.enableTitle') : t('system.organization.endTitle');
const content = isEnable ? t('system.organization.enableContent') : t('system.organization.endContent'); const content = isEnable ? t('system.organization.enableContent') : t('system.organization.endContent');
const okText = isEnable ? t('common.confirmEnable') : t('common.confirmClose'); const okText = isEnable ? t('common.confirmEnable') : t('common.confirmClose');
openModal({ openModal({
type: 'warning', type: 'info',
cancelText: t('common.cancel'), cancelText: t('common.cancel'),
title, title,
content, content,
@ -275,6 +276,7 @@
currentProjectDrawer.visible = false; currentProjectDrawer.visible = false;
currentUserDrawer.visible = true; currentUserDrawer.visible = true;
currentUserDrawer.organizationId = record.id; currentUserDrawer.organizationId = record.id;
currentUserDrawer.currentName = record.name;
}; };
const handleUserDrawerCancel = () => { const handleUserDrawerCancel = () => {
@ -284,9 +286,11 @@
const handleAddUserModalCancel = () => { const handleAddUserModalCancel = () => {
userVisible.value = false; userVisible.value = false;
}; };
const handleAddOrgModalCancel = () => { const handleAddOrgModalCancel = (shouldSearch: boolean) => {
orgVisible.value = false; orgVisible.value = false;
if (shouldSearch) {
fetchData(); fetchData();
}
}; };
const handleRevokeDelete = async (record: TableData) => { const handleRevokeDelete = async (record: TableData) => {

View File

@ -181,6 +181,7 @@
const currentUserDrawer = reactive({ const currentUserDrawer = reactive({
visible: false, visible: false,
projectId: '', projectId: '',
currentName: '',
}); });
const tableActions: ActionsItem[] = [ const tableActions: ActionsItem[] = [
@ -219,7 +220,7 @@
const content = isEnable ? t('system.project.enableContent') : t('system.project.endContent'); const content = isEnable ? t('system.project.enableContent') : t('system.project.endContent');
const okText = isEnable ? t('common.confirmEnable') : t('common.confirmClose'); const okText = isEnable ? t('common.confirmEnable') : t('common.confirmClose');
openModal({ openModal({
type: 'error', type: 'info',
cancelText: t('common.cancel'), cancelText: t('common.cancel'),
title, title,
content, content,
@ -261,11 +262,13 @@
const showUserDrawer = (record: TableData) => { const showUserDrawer = (record: TableData) => {
currentUserDrawer.visible = true; currentUserDrawer.visible = true;
currentUserDrawer.projectId = record.id; currentUserDrawer.projectId = record.id;
currentUserDrawer.currentName = record.name;
}; };
const handleUserDrawerCancel = () => { const handleUserDrawerCancel = () => {
currentUserDrawer.visible = false; currentUserDrawer.visible = false;
currentUserDrawer.projectId = ''; currentUserDrawer.projectId = '';
currentUserDrawer.currentName = '';
}; };
const handleAddUserModalCancel = () => { const handleAddUserModalCancel = () => {

View File

@ -6,7 +6,7 @@
unmount-on-close unmount-on-close
:footer="false" :footer="false"
class="ms-drawer-no-mask" class="ms-drawer-no-mask"
:title="t('system.organization.addMember')" :title="t('system.organization.addMemberTitle', { name: props.currentName })"
@cancel="handleCancel" @cancel="handleCancel"
> >
<div> <div>
@ -70,6 +70,7 @@
visible: boolean; visible: boolean;
organizationId?: string; organizationId?: string;
projectId?: string; projectId?: string;
currentName: string;
} }
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps<projectDrawerProps>(); const props = defineProps<projectDrawerProps>();
@ -127,6 +128,7 @@
} }
const handleCancel = () => { const handleCancel = () => {
keyword.value = '';
emit('cancel'); emit('cancel');
}; };
@ -184,6 +186,9 @@
() => props.visible, () => props.visible,
(visible) => { (visible) => {
currentVisible.value = visible; currentVisible.value = visible;
if (visible) {
fetchData();
}
} }
); );
</script> </script>

View File

@ -106,11 +106,17 @@
} }
}; };
const handleAddProjectCancel = () => { const handleAddProjectCancel = (shouldSearch: boolean) => {
projectVisible.value = false; projectVisible.value = false;
if (shouldSearch) {
tableSearch();
}
}; };
const handleAddOrganizationCancel = () => { const handleAddOrganizationCancel = (shouldSearch: boolean) => {
organizationVisible.value = false; organizationVisible.value = false;
if (shouldSearch) {
tableSearch();
}
}; };
watch( watch(

View File

@ -9,6 +9,7 @@ export default {
'system.organization.removeName': 'Confirm to remove {name} this user', 'system.organization.removeName': 'Confirm to remove {name} this user',
'system.organization.removeTip': 'After removal, the organization permission will be lost', 'system.organization.removeTip': 'After removal, the organization permission will be lost',
'system.organization.addMember': 'Add Member', 'system.organization.addMember': 'Add Member',
'system.organization.addMemberTitle': 'Add Member ({name})',
'system.organization.addMemberPlaceholder': 'Please select member', 'system.organization.addMemberPlaceholder': 'Please select member',
'system.organization.addMemberRequired': 'Please select member', 'system.organization.addMemberRequired': 'Please select member',
'system.organization.searchPlaceholder': 'Please enter the organization name to query', 'system.organization.searchPlaceholder': 'Please enter the organization name to query',

View File

@ -9,6 +9,7 @@ export default {
'system.organization.removeName': '确认移除 {name} 这个用户吗', 'system.organization.removeName': '确认移除 {name} 这个用户吗',
'system.organization.removeTip': '移除后,将失去组织权限', 'system.organization.removeTip': '移除后,将失去组织权限',
'system.organization.addMember': '添加成员', 'system.organization.addMember': '添加成员',
'system.organization.addMemberTitle': '添加成员({name}',
'system.organization.addMemberPlaceholder': '请选择成员', 'system.organization.addMemberPlaceholder': '请选择成员',
'system.organization.addMemberRequired': '请选择成员', 'system.organization.addMemberRequired': '请选择成员',
'system.organization.searchPlaceholder': '请输入组织名称回车查询', 'system.organization.searchPlaceholder': '请输入组织名称回车查询',