optimize: ♻️ 优化部分代码
This commit is contained in:
parent
f8b571a4f7
commit
2babba2574
|
@ -12,18 +12,14 @@ export const selectRows = ref([]);
|
|||
export const formRef = ref();
|
||||
const emailTemplateStore = useEmailTemplateStore();
|
||||
|
||||
/**
|
||||
* * 搜索初始化邮件模板表
|
||||
*/
|
||||
/** 搜索初始化邮件模板表 */
|
||||
export async function onSearch() {
|
||||
emailTemplateStore.loading = true;
|
||||
await emailTemplateStore.getEmailTemplateList();
|
||||
emailTemplateStore.loading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 添加邮件模板表
|
||||
*/
|
||||
/** 添加邮件模板表 */
|
||||
export function onAdd() {
|
||||
addDialog({
|
||||
title: `${$t('addNew')}${$t('emailTemplate')}`,
|
||||
|
|
|
@ -64,18 +64,26 @@ onMounted(() => {
|
|||
<template>
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="emailUsersStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
||||
<!-- 邮箱-->
|
||||
<el-form-item :label="$t('emailUsers_email')" prop="email">
|
||||
<el-input v-model="emailUsersStore.form.email" :placeholder="`${$t('input')}${$t('emailUsers_email')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<!-- host地址-->
|
||||
<el-form-item :label="$t('emailUsers_host')" prop="host">
|
||||
<el-input v-model="emailUsersStore.form.host" :placeholder="`${$t('input')}${$t('emailUsers_host')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 端口号-->
|
||||
<el-form-item :label="$t('emailUsers_port')" prop="port">
|
||||
<el-input v-model="emailUsersStore.form.port" :placeholder="`${$t('input')}${$t('emailUsers_port')}`" class="!w-[180px]" clearable />
|
||||
<el-input v-model="emailUsersStore.form.port" :placeholder="`${$t('input')}${$t('emailUsers_port')}`" class="!w-[180px]" clearable max="99999" min="0" type="number" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 协议 -->
|
||||
<el-form-item :label="$t('emailUsers_smtpAgreement')" prop="smtpAgreement">
|
||||
<el-input v-model="emailUsersStore.form.smtpAgreement" :placeholder="`${$t('input')}${$t('emailUsers_smtpAgreement')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button :icon="useRenderIcon('ri:search-line')" :loading="emailUsersStore.loading" type="primary" @click="onSearch"> {{ $t('search') }} </el-button>
|
||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
||||
|
|
|
@ -14,18 +14,14 @@ export const switchLoadMap = ref({});
|
|||
export const deleteIds = ref([]);
|
||||
const emailUsersStore = useEmailUsersStore();
|
||||
|
||||
/**
|
||||
* * 搜索初始化邮箱用户发送配置
|
||||
*/
|
||||
/** 搜索初始化邮箱用户发送配置 */
|
||||
export async function onSearch() {
|
||||
emailUsersStore.loading = true;
|
||||
await emailUsersStore.getEmailUsersList();
|
||||
emailUsersStore.loading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 添加邮箱用户发送配置
|
||||
*/
|
||||
/** 添加邮箱用户发送配置 */
|
||||
export function onAdd() {
|
||||
addDialog({
|
||||
title: `${$t('addNew')}${$t('emailUsers')}`,
|
||||
|
@ -94,9 +90,7 @@ export function onUpdate(row: any) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* * 删除邮箱用户发送配置
|
||||
*/
|
||||
/** 删除邮箱用户发送配置 */
|
||||
export const onDelete = async (row: any) => {
|
||||
const id = row.id;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Tree } from '@/views/system/adminUser/utils/types';
|
|||
import { buttonClass, defaultProps } from '@/views/system/adminUser/utils/columns';
|
||||
import { useAdminUserStore } from '@/store/system/adminUser';
|
||||
import { onSearch } from '@/views/system/adminUser/utils/hooks';
|
||||
import { $t } from '../../../plugins/i18n';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
|
||||
defineProps({
|
||||
treeLoading: Boolean,
|
||||
|
|
|
@ -5,8 +5,9 @@ import { deptSelector, rules } from '@/views/system/dept/utils/columns';
|
|||
import { FormProps } from '@/views/system/dept/utils/types';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import { useDeptStore } from '@/store/system/dept';
|
||||
import UserSelectSearch from '@/views/system/dept/user-select-search.vue';
|
||||
import { handleTree } from '@pureadmin/utils';
|
||||
import LoadingSvg from '@/assets/svg/loading.svg';
|
||||
import { useAdminUserStore } from '@/store/system/adminUser';
|
||||
|
||||
const props = withDefaults(defineProps<FormProps>(), {
|
||||
formInline: () => ({
|
||||
|
@ -22,8 +23,18 @@ const props = withDefaults(defineProps<FormProps>(), {
|
|||
});
|
||||
|
||||
const deptStore = useDeptStore();
|
||||
const adminUserStore = useAdminUserStore();
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = ref(props.formInline);
|
||||
const loading = ref(false);
|
||||
const userDataList = ref();
|
||||
|
||||
/** 搜索 */
|
||||
const onSearchUserinfo = async (keyword: string) => {
|
||||
loading.value = true;
|
||||
userDataList.value = await adminUserStore.queryUser({ keyword });
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
deptStore.getAllDeptList();
|
||||
|
@ -34,15 +45,29 @@ defineExpose({ formRef });
|
|||
|
||||
<template>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||
<!-- 父级ID -->
|
||||
<el-form-item :label="$t('dept_parentId')" prop="parentId">
|
||||
<el-cascader v-model="form.parentId" :options="handleTree(deptStore.allDeptList)" :props="deptSelector" class="w-full" clearable filterable show-all-levels />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 管理员 -->
|
||||
<el-form-item :label="$t('dept_manager')" prop="manager">
|
||||
<user-select-search :formInline="form" />
|
||||
<el-select v-model="form.manager" :loading="loading" :placeholder="$t('receivedUserIdTip')" :remote-method="onSearchUserinfo" clearable filterable multiple remote remote-show-suffix>
|
||||
<el-option v-for="item in userDataList" :key="item.id" :label="item.username" :value="item.username" />
|
||||
<template #loading>
|
||||
<el-icon class="is-loading">
|
||||
<LoadingSvg />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 部门名称-->
|
||||
<el-form-item :label="$t('dept_deptName')" prop="deptName">
|
||||
<el-input v-model="form.deptName" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 简介 -->
|
||||
<el-form-item :label="$t('dept_summary')" prop="summary">
|
||||
<el-input v-model="form.summary" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
<script lang="ts" setup>
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import { ref } from 'vue';
|
||||
import LoadingSvg from '@/assets/svg/loading.svg';
|
||||
import { useAdminUserStore } from '@/store/system/adminUser';
|
||||
import { FormProps } from '@/views/system/dept/utils/types';
|
||||
|
||||
const props = withDefaults(defineProps<FormProps>(), {
|
||||
formInline: () => ({
|
||||
// 父级id
|
||||
parentId: undefined,
|
||||
// 管理者id
|
||||
manager: undefined,
|
||||
// 部门名称
|
||||
deptName: undefined,
|
||||
// 部门简介
|
||||
summary: undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
const adminUserStore = useAdminUserStore();
|
||||
const loading = ref(false);
|
||||
const userDataList = ref();
|
||||
const form = ref(props.formInline);
|
||||
|
||||
/**
|
||||
* * 搜索
|
||||
*/
|
||||
const onSearchUserinfo = async (keyword: string) => {
|
||||
if (!keyword) return;
|
||||
loading.value = true;
|
||||
userDataList.value = await adminUserStore.queryUser({ keyword });
|
||||
loading.value = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-select v-model="form.manager" :loading="loading" :placeholder="$t('input')" :remote-method="onSearchUserinfo" clearable filterable multiple remote remote-show-suffix>
|
||||
<el-option v-for="item in userDataList" :key="item.id" :label="item.username" :value="item.username" />
|
||||
<template #loading>
|
||||
<el-icon class="is-loading">
|
||||
<LoadingSvg />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.el-select-dropdown__loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.circular {
|
||||
display: inline;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
animation: loading-rotate 2s linear infinite;
|
||||
}
|
||||
|
||||
.path {
|
||||
stroke: var(--el-color-primary);
|
||||
stroke-dasharray: 90, 150;
|
||||
stroke-dashoffset: 0;
|
||||
stroke-linecap: round;
|
||||
stroke-width: 2;
|
||||
animation: loading-dash 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.loading-path .dot1 {
|
||||
opacity: 0.3;
|
||||
fill: var(--el-color-primary);
|
||||
transform: translate(3.75px, 3.75px);
|
||||
animation: custom-spin-move 1s infinite linear alternate;
|
||||
}
|
||||
|
||||
.loading-path .dot2 {
|
||||
opacity: 0.3;
|
||||
fill: var(--el-color-primary);
|
||||
transform: translate(calc(100% - 3.75px), 3.75px);
|
||||
animation: custom-spin-move 1s infinite linear alternate;
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.loading-path .dot3 {
|
||||
opacity: 0.3;
|
||||
fill: var(--el-color-primary);
|
||||
transform: translate(3.75px, calc(100% - 3.75px));
|
||||
animation: custom-spin-move 1s infinite linear alternate;
|
||||
animation-delay: 1.2s;
|
||||
}
|
||||
|
||||
.loading-path .dot4 {
|
||||
opacity: 0.3;
|
||||
fill: var(--el-color-primary);
|
||||
transform: translate(calc(100% - 3.75px), calc(100% - 3.75px));
|
||||
animation: custom-spin-move 1s infinite linear alternate;
|
||||
animation-delay: 0.8s;
|
||||
}
|
||||
|
||||
@keyframes loading-rotate {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes loading-dash {
|
||||
0% {
|
||||
stroke-dasharray: 1, 200;
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
|
||||
50% {
|
||||
stroke-dasharray: 90, 150;
|
||||
stroke-dashoffset: -40px;
|
||||
}
|
||||
|
||||
100% {
|
||||
stroke-dasharray: 90, 150;
|
||||
stroke-dashoffset: -120px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes custom-spin-move {
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -60,7 +60,7 @@ export function onUpdate(row: any) {
|
|||
props: {
|
||||
formInline: {
|
||||
parentId: row.parentId,
|
||||
manager: row.manager,
|
||||
manager: row.manager ? row.manager.split(',') : row.manager,
|
||||
deptName: row.deptName,
|
||||
summary: row.summary,
|
||||
},
|
||||
|
|
|
@ -25,8 +25,6 @@ import { columns } from '@/views/system/menu/utils/columns';
|
|||
import { userMenuStore } from '@/store/system/menu';
|
||||
import { useRenderIcon } from '@/components/CommonIcon/src/hooks';
|
||||
import { selectUserinfo } from '@/components/Table/Userinfo/columns';
|
||||
import More from '@iconify-icons/ep/more-filled';
|
||||
import { tableSelectButtonClass } from '@/enums/baseConstant';
|
||||
import Upload from '@iconify-icons/ri/upload-line';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { usePublicHooks } from '@/views/hooks';
|
||||
|
@ -145,17 +143,11 @@ onMounted(() => {
|
|||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
<!-- 更多操作 -->
|
||||
<el-dropdown>
|
||||
<el-button :icon="useRenderIcon(More)" :size="size" class="ml-3 mt-[2px]" link type="primary" />
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-button :class="tableSelectButtonClass" :icon="useRenderIcon(Upload)" :size="size" link type="primary" @click="assignRolesToRouter(row)"> {{ $t('assign_roles') }} </el-button>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
<!-- 分配角色 -->
|
||||
<el-button v-show="row.menuType !== 3" :icon="useRenderIcon(Upload)" :size="size" class="reset-margin" link type="primary" @click="assignRolesToRouter(row)">
|
||||
{{ $t('assign_roles') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</pure-table>
|
||||
</template>
|
||||
|
|
|
@ -72,7 +72,7 @@ export const columns: TableColumnList = [
|
|||
{ label: $t('table.createTime'), prop: 'createTime', sortable: true },
|
||||
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 130 },
|
||||
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 130 },
|
||||
{ label: $t('table.operation'), fixed: 'right', width: 230, slot: 'operation' },
|
||||
{ label: $t('table.operation'), fixed: 'right', width: 310, slot: 'operation' },
|
||||
];
|
||||
|
||||
/** 自定义表单规则校验 */
|
||||
|
|
|
@ -209,7 +209,7 @@ export const onChangeMenuRank = async (row: any) => {
|
|||
*/
|
||||
export const assignRolesToRouter = (row: any) => {
|
||||
addDialog({
|
||||
title: `为 【${$t(row.name)}】 分配角色`,
|
||||
title: `为 【${$t(row.title)}】 分配角色`,
|
||||
width: '45%',
|
||||
draggable: true,
|
||||
closeOnClickModal: false,
|
||||
|
|
|
@ -61,7 +61,7 @@ onMounted(() => {
|
|||
<el-input v-model="filesStore.form.fileType" :placeholder="`${$t('input')}${$t('files_fileType')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('files_downloadCount')" prop="downloadCount">
|
||||
<el-input v-model="filesStore.form.downloadCount" :placeholder="`${$t('input')}${$t('files_downloadCount')}`" class="!w-[180px]" clearable />
|
||||
<el-input v-model="filesStore.form.downloadCount" :placeholder="`${$t('input')}${$t('files_downloadCount')}`" class="!w-[180px]" clearable min="0" type="number" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :icon="useRenderIcon('ri:search-line')" :loading="filesStore.loading" type="primary" @click="onSearch"> {{ $t('search') }} </el-button>
|
||||
|
|
Loading…
Reference in New Issue