feat: 优化页面

master
绝弹 2023-09-14 22:21:52 +08:00
parent 3fede86baa
commit 20a0aea7d8
8 changed files with 202 additions and 32 deletions

View File

@ -1,4 +1,4 @@
import { Button, Link } from "@arco-design/web-vue"; import { Button } from "@arco-design/web-vue";
import { IconRefresh, IconSearch } from "@arco-design/web-vue/es/icon"; import { IconRefresh, IconSearch } from "@arco-design/web-vue/es/icon";
export const config = { export const config = {
@ -25,7 +25,7 @@ export const config = {
{{ icon: () => <IconRefresh></IconRefresh>, default: () => "重置" }} {{ icon: () => <IconRefresh></IconRefresh>, default: () => "重置" }}
</Button> </Button>
)} )}
<Button type="outline" loading={tableRef?.loading.value} onClick={() => tableRef?.loadData()}> <Button type="primary" loading={tableRef?.loading.value} onClick={() => tableRef?.loadData()}>
{{ icon: () => <IconSearch></IconSearch>, default: () => "查询" }} {{ icon: () => <IconSearch></IconSearch>, default: () => "查询" }}
</Button> </Button>
</div> </div>

View File

@ -166,9 +166,13 @@ export const Table = defineComponent({
)} )}
<div class={`mb-3 flex justify-between ${!this.inlined && "mt-2"}`}> <div class={`mb-3 flex justify-between ${!this.inlined && "mt-2"}`}>
<div class="flex-1 flex gap-2"> <div class={`${this.create || this.$slots.action ? null : '!hidden'} flex-1 flex gap-2 `}>
{this.create && ( {this.create && (
<FormModal ref="createRef" onSubmited={this.reloadData} {...(this.create as any)}></FormModal> <FormModal
{...(this.create as any)}
ref="createRef"
onSubmited={this.reloadData}
></FormModal>
)} )}
{this.modify && ( {this.modify && (
<FormModal <FormModal
@ -180,7 +184,9 @@ export const Table = defineComponent({
)} )}
{this.$slots.action?.()} {this.$slots.action?.()}
</div> </div>
<div>{this.inlined && <Form ref="searchRef" {...this.search}></Form>}</div> <div>
{this.inlined && <Form ref="searchRef" {...this.search}></Form>}
</div>
</div> </div>
<BaseTable <BaseTable

View File

@ -8,19 +8,37 @@
<template #extra> <template #extra>
<a-checkbox>全部选择</a-checkbox> <a-checkbox>全部选择</a-checkbox>
</template> </template>
<a-tree :data="items" :block-node="true" :field-names="{ title: 'title' }" checkable :default-expand-all="true">
<template #extra="nodeData">
<div class="flex-1 flex justify-end px-1">
<a-tag v-if="nodeData.children" color="orange"></a-tag>
<a-tag v-else color="green">页面</a-tag>
</div>
</template>
</a-tree>
</a-card> </a-card>
<a-modal :visible="true" :width="1280" :title="'选择素材'" title-align="start" :closable="false">
<div class="w-full h-[600px] flex gap-4">
<div class="w-64 p-2 pr-4 border">
<a-input-search placeholder="请输入关键字"></a-input-search>
<a-tree
:data="items"
:block-node="true"
:field-names="{ title: 'title' }"
:default-expand-all="true"
class="mt-2"
>
<template #extra="nodeData">
<div class="text-slate-400 mr-2">
10
</div>
</template>
</a-tree>
</div>
<div class="flex-1 h-full">
<Table v-bind="table"></Table>
</div>
</div>
</a-modal>
</bread-page> </bread-page>
</template> </template>
<script setup lang="tsx"> <script setup lang="tsx">
import { api } from '@/api';
import { Table, useTable } from '@/components';
import { dayjs } from '@/libs/dayjs';
import { menus } from "@/router"; import { menus } from "@/router";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
@ -30,7 +48,6 @@ for (const item of items) {
if (item.icon) { if (item.icon) {
const icon = item.icon; const icon = item.icon;
item.icon = () => <i class={icon}></i>; item.icon = () => <i class={icon}></i>;
} }
item.switcherIcon = () => null; item.switcherIcon = () => null;
if (item.children) { if (item.children) {
@ -64,14 +81,125 @@ const onItemChange = (item: any, menu: any) => {
menu.checked = true; menu.checked = true;
} }
}; };
const table = useTable({
data: async (model, paging) => {
return api.role.getRoles();
},
columns: [
{
title: "角色名称",
dataIndex: "username",
width: 180,
render({ record }) {
return (
<div class="flex flex-col overflow-hidden">
<span>{record.name}</span>
<span class="text-gray-400 text-xs truncate">{record.slug}</span>
</div>
);
},
},
{
title: "角色描述",
dataIndex: "description",
},
{
title: "创建时间",
dataIndex: "createdAt",
width: 200,
render: ({ record }) => dayjs(record.createdAt).format(),
},
{
title: "操作",
type: "button",
width: 184,
buttons: [
{
type: "modify",
text: "修改",
},
{
text: '分配权限',
onClick: ({ record }) => {
console.log(record);
},
},
{
text: "删除",
type: "delete",
onClick: ({ record }) => {
return api.role.delRole(record.id);
},
}
],
},
],
search: {
items: [
{
extend: "name",
required: false,
nodeProps: {
placeholder: '请输入角色名称'
},
itemProps: {
hideLabel: true,
}
},
],
},
create: {
title: "新建角色",
modalProps: {
width: 580,
maskClosable: false,
},
formProps: {
layout: "vertical",
},
items: [
{
field: "name",
label: "角色名称",
type: "input",
required: true,
},
{
field: "slug",
label: "角色标识",
type: "input",
},
{
field: "description",
label: "个人描述",
type: "textarea",
},
{
field: "permissionIds",
label: "关联权限",
type: "select",
options: () => api.permission.getPermissions(),
nodeProps: {
multiple: true,
},
},
],
submit: ({ model }) => {
return api.role.addRole(model);
},
},
modify: {
extend: true,
title: "修改角色",
submit: ({ model }) => {
return api.role.updateRole(model.id, model);
},
},
});
</script> </script>
<style lang="less"> <style lang="less">
.arco-tree-node {
&:hover {
background: rgb(var(--primary-1));
}
}
</style> </style>
<route lang="json"> <route lang="json">

View File

@ -69,13 +69,10 @@ const table = useTable({
return api.post.getPosts({ ...model, ...paging }); return api.post.getPosts({ ...model, ...paging });
}, },
columns: [ columns: [
{
type: "index",
},
{ {
title: "文章名称", title: "文章名称",
dataIndex: "title", dataIndex: "title",
width: 200, width: 240,
}, },
{ {
title: "文章描述", title: "文章描述",
@ -112,6 +109,9 @@ const table = useTable({
}, },
], ],
search: { search: {
formProps: {
layout: 'inline',
},
items: [ items: [
{ {
extend: "title", extend: "title",

View File

@ -18,7 +18,7 @@ const table = useTable({
{ {
title: "登陆账号", title: "登陆账号",
dataIndex: "nickname", dataIndex: "nickname",
width: 200, width: 140,
}, },
{ {
title: "操作描述", title: "操作描述",
@ -37,20 +37,23 @@ const table = useTable({
{ {
title: "登陆地址", title: "登陆地址",
dataIndex: "ip", dataIndex: "ip",
width: 200,
render: ({ record }) => `${record.addr || "未知"}(${record.ip})`, render: ({ record }) => `${record.addr || "未知"}(${record.ip})`,
}, },
{ {
title: "操作系统", title: "操作系统",
dataIndex: "os", dataIndex: "os",
width: 160,
}, },
{ {
title: "浏览器", title: "浏览器",
dataIndex: "browser", dataIndex: "browser",
width: 160,
}, },
{ {
title: "登陆时间", title: "登陆时间",
dataIndex: "createdAt", dataIndex: "createdAt",
width: 200, width: 120,
render: ({ record }) => dayjs(record.createdAt).fromNow(), render: ({ record }) => dayjs(record.createdAt).fromNow(),
}, },
], ],

View File

@ -60,6 +60,12 @@ const table = useTable({
label: "权限名称", label: "权限名称",
type: "input", type: "input",
required: false, required: false,
nodeProps: {
placeholder: '请输入名称关键字'
},
itemProps: {
hideLabel: true,
}
}, },
], ],
}, },
@ -72,6 +78,14 @@ const table = useTable({
type: "input", type: "input",
required: true, required: true,
}, },
{
field: 'order',
label: '排序',
type: 'number',
nodeProps: {
min: 0,
}
},
{ {
field: "slug", field: "slug",
label: "角色标识", label: "角色标识",

View File

@ -17,7 +17,7 @@ const table = useTable({
{ {
title: "角色名称", title: "角色名称",
dataIndex: "username", dataIndex: "username",
width: 200, width: 180,
render({ record }) { render({ record }) {
return ( return (
<div class="flex flex-col overflow-hidden"> <div class="flex flex-col overflow-hidden">
@ -67,6 +67,12 @@ const table = useTable({
{ {
extend: "name", extend: "name",
required: false, required: false,
nodeProps: {
placeholder: '请输入角色名称'
},
itemProps: {
hideLabel: true,
}
}, },
], ],
}, },

View File

@ -3,7 +3,15 @@
<template #content> <template #content>
<a-tabs default-active-key="1" size="large" class="bg-white m-4"> <a-tabs default-active-key="1" size="large" class="bg-white m-4">
<a-tab-pane key="1" title="全部"> <a-tab-pane key="1" title="全部">
<Table v-bind="table" class="px-4 pb-4"></Table> <Table v-bind="table" class="px-4 pb-4">
<template #action>
<a-button status="danger" type="outline" :disabled="true">
<template #icon>
<i class="icon-park-outline-delete"></i>
</template>
删除</a-button>
</template>
</Table>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" title="已通过(12)"></a-tab-pane> <a-tab-pane key="2" title="已通过(12)"></a-tab-pane>
</a-tabs> </a-tabs>
@ -25,15 +33,19 @@ const table = useTable({
{ {
title: "用户昵称", title: "用户昵称",
dataIndex: "username", dataIndex: "username",
width: 200, width: 180,
render: ({ record }) => ( render: ({ record }) => (
<div class="flex items-center"> <div class="flex items-center">
<Avatar size={32}> <Avatar size={32}>
<img src={record.avatar} alt="" /> <img src={record.avatar || 'https://github.com/juetan.png'} alt="" />
</Avatar> </Avatar>
<span class="ml-2 flex-1 flex flex-col overflow-hidden"> <span class="ml-2 flex-1 flex flex-col overflow-hidden">
<span>{record.nickname}</span> <span>
<span class="text-gray-400 text-xs truncate">{record.username}</span> {record.nickname}
</span>
<span class="text-gray-400 text-xs truncate">
{record.username}
</span>
</span> </span>
</div> </div>
), ),
@ -45,6 +57,7 @@ const table = useTable({
{ {
title: "用户邮箱", title: "用户邮箱",
dataIndex: "email", dataIndex: "email",
width: 200,
}, },
{ {
title: "创建时间", title: "创建时间",
@ -55,7 +68,7 @@ const table = useTable({
{ {
title: "操作", title: "操作",
type: "button", type: "button",
width: 148, width: 110,
buttons: [ buttons: [
{ {
type: "modify", type: "modify",