refactor: 个人中心页面重构和布局代码优化
This commit is contained in:
1 parent
7ffcf8820e
commit
845d117f08
68 files changed
+4026
-3418
No files matched your search
@@ -1,25 +0,0 @@
|
||||
<!-- 接口文档 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<iframe
|
||||
src="https://www.apifox.cn/apidoc/shared-195e783f-4d85-4235-a038-eec696de4ea5"
|
||||
width="100%"
|
||||
height="100%"
|
||||
frameborder="0"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use "@/styles/variables" as *;
|
||||
|
||||
.page-container {
|
||||
height: calc(100vh - $navbar-height);
|
||||
}
|
||||
|
||||
.hasTagsView {
|
||||
.page-container {
|
||||
height: calc(100vh - $navbar-height - $tags-view-height);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -73,10 +73,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { MessageBoxData } from "element-plus";
|
||||
import UserAPI from "@/api/system/user";
|
||||
import DeptAPI from "@/api/system/dept";
|
||||
import RoleAPI from "@/api/system/role";
|
||||
import type { UserForm, UserQueryParams, UserItem } from "@/api/system/user";
|
||||
import type { OptionItem } from "@/api/common";
|
||||
import type { UserForm, UserItem, UserQueryParams } from "@/api/system/user";
|
||||
import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
|
||||
import { DeviceEnum } from "@/enums/settings";
|
||||
import { useAppStore } from "@/stores";
|
||||
@@ -87,14 +89,7 @@ defineOptions({
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
// ========================= 选项数据管理 =========================
|
||||
interface OptionItem {
|
||||
label: string;
|
||||
value: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 共享选项数据
|
||||
// 选项数据
|
||||
const deptArr = ref<OptionItem[]>([]);
|
||||
const roleArr = ref<OptionItem[]>([]);
|
||||
const stateArr = ref<OptionItem[]>([
|
||||
@@ -102,14 +97,13 @@ const stateArr = ref<OptionItem[]>([
|
||||
{ label: "禁用", value: 0 },
|
||||
]);
|
||||
|
||||
// 初始化选项数据
|
||||
const initOptions = async () => {
|
||||
const [dept, roles] = await Promise.all([DeptAPI.getOptions(), RoleAPI.getOptions()]);
|
||||
deptArr.value = dept;
|
||||
roleArr.value = roles;
|
||||
};
|
||||
|
||||
// ========================= 搜索配置 =========================
|
||||
// 搜索配置
|
||||
const searchConfig: ISearchConfig = reactive({
|
||||
permPrefix: "sys:user",
|
||||
formItems: [
|
||||
@@ -165,7 +159,7 @@ const searchConfig: ISearchConfig = reactive({
|
||||
],
|
||||
});
|
||||
|
||||
// ========================= 内容配置 =========================
|
||||
// 内容配置
|
||||
const contentConfig: IContentConfig<UserQueryParams, UserItem> = reactive({
|
||||
permPrefix: "sys:user",
|
||||
table: {
|
||||
@@ -178,7 +172,7 @@ const contentConfig: IContentConfig<UserQueryParams, UserItem> = reactive({
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexAction(params: any) {
|
||||
indexAction(params: UserQueryParams) {
|
||||
return UserAPI.getPage(params);
|
||||
},
|
||||
deleteAction: UserAPI.deleteByIds,
|
||||
@@ -190,7 +184,7 @@ const contentConfig: IContentConfig<UserQueryParams, UserItem> = reactive({
|
||||
importsAction() {
|
||||
return Promise.resolve();
|
||||
},
|
||||
async exportsAction(params: any) {
|
||||
async exportsAction(params: UserQueryParams) {
|
||||
const data = await UserAPI.getPage(params);
|
||||
return data.list;
|
||||
},
|
||||
@@ -232,7 +226,7 @@ const contentConfig: IContentConfig<UserQueryParams, UserItem> = reactive({
|
||||
filters: [],
|
||||
filterMultiple: true,
|
||||
filterJoin: ",",
|
||||
async initFn(colItem: any) {
|
||||
async initFn(colItem: IObject) {
|
||||
const roleOptions = await RoleAPI.getOptions();
|
||||
colItem.filters = roleOptions.map((item) => {
|
||||
return { text: item.label, value: item.value };
|
||||
@@ -285,7 +279,7 @@ const contentConfig: IContentConfig<UserQueryParams, UserItem> = reactive({
|
||||
],
|
||||
});
|
||||
|
||||
// ========================= 新增配置 =========================
|
||||
// 新增配置
|
||||
const addModalConfig: IModalConfig<UserForm> = reactive({
|
||||
permPrefix: "sys:user",
|
||||
dialog: {
|
||||
@@ -401,7 +395,7 @@ const addModalConfig: IModalConfig<UserForm> = reactive({
|
||||
],
|
||||
});
|
||||
|
||||
// ========================= 编辑配置 =========================
|
||||
// 编辑配置
|
||||
const editModalConfig: IModalConfig<UserForm> = reactive({
|
||||
permPrefix: "sys:user",
|
||||
component: "drawer",
|
||||
@@ -410,7 +404,7 @@ const editModalConfig: IModalConfig<UserForm> = reactive({
|
||||
size: useAppStore().device === DeviceEnum.MOBILE ? "80%" : 500,
|
||||
},
|
||||
pk: "id",
|
||||
formAction(data: any) {
|
||||
formAction(data: UserForm) {
|
||||
return UserAPI.update(data.id as string, data);
|
||||
},
|
||||
formItems: [
|
||||
@@ -512,7 +506,7 @@ const editModalConfig: IModalConfig<UserForm> = reactive({
|
||||
],
|
||||
});
|
||||
|
||||
// ========================= 页面逻辑 =========================
|
||||
// 页面逻辑
|
||||
const {
|
||||
searchRef,
|
||||
contentRef,
|
||||
@@ -529,14 +523,12 @@ const {
|
||||
handleFilterChange,
|
||||
} = usePage();
|
||||
|
||||
// 其他工具
|
||||
function handleToolbarClick(name: string) {
|
||||
if (name === "custom1") {
|
||||
ElMessage.success("点击了自定义1按钮");
|
||||
}
|
||||
}
|
||||
|
||||
// 表格工具
|
||||
const handleOperateClick = (data: IObject) => {
|
||||
if (data.name === "detail") {
|
||||
editModalConfig.drawer = { ...editModalConfig.drawer, title: "查看" };
|
||||
@@ -553,7 +545,7 @@ const handleOperateClick = (data: IObject) => {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
}).then(
|
||||
({ value }: any) => {
|
||||
({ value }: MessageBoxData) => {
|
||||
if (!value || value.length < 6) {
|
||||
ElMessage.warning("密码至少需6位字符,请重新输入");
|
||||
return false;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<iframe src="https://juejin.cn/post/7228990409909108793" frameborder="0" />
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
@use "@/styles/variables" as *;
|
||||
|
||||
.page-container {
|
||||
height: calc(100vh - $navbar-height);
|
||||
}
|
||||
|
||||
.hasTagsView {
|
||||
.page-container {
|
||||
height: calc(100vh - $navbar-height - $tags-view-height);
|
||||
}
|
||||
}
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -1,20 +0,0 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div flex flex-col gap-20px>
|
||||
<MultiLevel1 />
|
||||
<MultiLevel2 />
|
||||
<el-alert :closable="false" title="菜单三级-1" type="error" />
|
||||
<el-input v-model="value" placeholder="缓存测试" />
|
||||
<ToDetail />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import ToDetail from "./detail";
|
||||
import MultiLevel1 from "../../level1.vue";
|
||||
import MultiLevel2 from "../level2.vue";
|
||||
|
||||
defineOptions({ name: "MultiLevel31" });
|
||||
|
||||
const value = ref("");
|
||||
</script>
|
||||
@@ -1,20 +0,0 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div flex flex-col gap-20px>
|
||||
<MultiLevel1 />
|
||||
<MultiLevel2 />
|
||||
<el-alert :closable="false" title="菜单三级-2" type="warning" />
|
||||
<el-input v-model="value" placeholder="缓存测试" />
|
||||
<ToDetail />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ToDetail from "./detail";
|
||||
import MultiLevel1 from "../../level1.vue";
|
||||
import MultiLevel2 from "../level2.vue";
|
||||
|
||||
defineOptions({ name: "MultiLevel32" });
|
||||
const value = ref("");
|
||||
</script>
|
||||
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<el-alert :closable="false" title="一级菜单内容片段" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: "LevelOnePanel" });
|
||||
</script>
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<el-alert :closable="false" title="菜单二级" type="success" />
|
||||
<el-alert :closable="false" title="二级菜单内容片段" type="success" />
|
||||
<el-input v-model="value" placeholder="缓存测试" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: "MultiLevel2" });
|
||||
defineOptions({ name: "LevelTwoPanel" });
|
||||
|
||||
const value = ref("");
|
||||
</script>
|
||||
File renamed without changes.
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div flex flex-col gap-20px>
|
||||
<LevelOnePanel />
|
||||
<LevelTwoPanel />
|
||||
<el-alert :closable="false" title="三级菜单 A" type="error" />
|
||||
<el-input v-model="value" placeholder="缓存测试" />
|
||||
<ToDetail />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import LevelOnePanel from "../../../components/LevelOnePanel.vue";
|
||||
import LevelTwoPanel from "../../../components/LevelTwoPanel.vue";
|
||||
import ToDetail from "../../../components/ToDetail";
|
||||
|
||||
defineOptions({ name: "MultiLevelLevelThreeA" });
|
||||
|
||||
const value = ref("");
|
||||
</script>
|
||||
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div flex flex-col gap-20px>
|
||||
<LevelOnePanel />
|
||||
<LevelTwoPanel />
|
||||
<el-alert :closable="false" title="三级菜单 B" type="warning" />
|
||||
<el-input v-model="value" placeholder="缓存测试" />
|
||||
<ToDetail />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import LevelOnePanel from "../../../components/LevelOnePanel.vue";
|
||||
import LevelTwoPanel from "../../../components/LevelTwoPanel.vue";
|
||||
import ToDetail from "../../../components/ToDetail";
|
||||
|
||||
defineOptions({ name: "MultiLevelLevelThreeB" });
|
||||
const value = ref("");
|
||||
</script>
|
||||
@@ -1,6 +0,0 @@
|
||||
<template>
|
||||
<el-alert :closable="false" title="菜单一" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: "MultiLevel1" });
|
||||
</script>
|
||||
Reference in new issue
Block a user