Skip to content

Commit b207125

Browse files
authored
Merge pull request #124 from Tencent/feat/tab-router
Feat/tab router
2 parents 9fb445e + 2e403b0 commit b207125

File tree

6 files changed

+41
-12
lines changed

6 files changed

+41
-12
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"nprogress": "^0.2.0",
2525
"qrcode.vue": "^1.7.0",
2626
"tdesign-icons-vue": "~0.0.8",
27-
"tdesign-vue": "~0.41.0",
27+
"tdesign-vue": "~0.41.5",
2828
"tvision-color": "~1.3.0",
2929
"typescript": "^4.2.4",
3030
"vue": "^2.6.11",

src/layouts/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ export default Vue.extend({
173173
renderContent(): VNode {
174174
const { showBreadcrumb } = this.setting;
175175
const { showFooter } = this;
176+
176177
return (
177-
<t-layout class={[`${prefix}-layout`]}>
178+
<t-layout class={[`${prefix}-layout`]} key={this.$route.name}>
178179
{this.isUseTabsRouter && (
179180
<t-tabs
180181
theme="card"

src/pages/form/base/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<!-- 表单内容 -->
1616

1717
<!-- 合同名称,合同类型 -->
18-
<t-row class="row-gap" :gutter="[16, 0]">
18+
<t-row class="row-gap" :gutter="[16, 24]">
1919
<t-col :span="6">
2020
<t-form-item label="合同名称" name="name">
2121
<t-input v-model="formData.name" :style="{ width: '322px' }" placeholder="请输入内容" />

src/pages/list/base/index.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
</t-row>
1616

1717
<div class="table-container">
18-
<!-- 如果开启多标签tab页 请修改offsetTop的配置 -->
1918
<t-table
2019
:columns="columns"
2120
:data="data"
@@ -29,7 +28,7 @@
2928
@change="rehandleChange"
3029
@select-change="rehandleSelectChange"
3130
:headerAffixedTop="true"
32-
:headerAffixProps="{ offsetTop: 0, container: getContainer }"
31+
:headerAffixProps="{ offsetTop: offsetTop, container: getContainer }"
3332
>
3433
<template #status="{ row }">
3534
<t-tag v-if="row.status === CONTRACT_STATUS.FAIL" theme="danger" variant="light">审核失败</t-tag>
@@ -163,6 +162,9 @@ export default Vue.extend({
163162
}
164163
return '';
165164
},
165+
offsetTop() {
166+
return this.$store.state.setting.isUseTabsRouter ? 48 : 0;
167+
},
166168
},
167169
mounted() {
168170
this.dataLoading = true;

src/pages/list/components/CommonTable.vue

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<template>
22
<div class="list-common-table">
3-
<t-form ref="form" :data="formData" :label-width="80" colon @reset="onReset" @submit="onSubmit">
3+
<t-form
4+
ref="form"
5+
:data="formData"
6+
:label-width="80"
7+
colon
8+
@reset="onReset"
9+
@submit="onSubmit"
10+
:style="{ marginBottom: '8px' }"
11+
>
412
<t-row>
513
<t-col :span="10">
6-
<t-row :gutter="[16]">
14+
<t-row :gutter="[16, 24]">
715
<t-col :flex="1">
816
<t-form-item label="合同名称" name="name">
917
<t-input
@@ -55,7 +63,6 @@
5563
</t-row>
5664
</t-form>
5765
<div class="table-container">
58-
<!-- 如果开启多标签tab页 请修改offsetTop的配置 -->
5966
<t-table
6067
:data="data"
6168
:columns="columns"
@@ -67,7 +74,7 @@
6774
@change="rehandleChange"
6875
:loading="dataLoading"
6976
:headerAffixedTop="true"
70-
:headerAffixProps="{ offsetTop: 0, container: getContainer }"
77+
:headerAffixProps="{ offsetTop, container: getContainer }"
7178
>
7279
<template #status="{ row }">
7380
<t-tag v-if="row.status === CONTRACT_STATUS.FAIL" theme="danger" variant="light">审核失败</t-tag>
@@ -206,6 +213,9 @@ export default {
206213
}
207214
return '';
208215
},
216+
offsetTop() {
217+
return this.$store.state.setting.isUseTabsRouter ? 48 : 0;
218+
},
209219
},
210220
mounted() {
211221
this.dataLoading = true;

src/store/modules/tab-router.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,52 @@ export type TTabRouterType = {
1212
tabRouterList: Array<TRouterInfo>;
1313
};
1414

15+
const homeRoute: Array<TRouterInfo> = [
16+
{
17+
path: '/dashboard/base',
18+
routeIdx: 0,
19+
title: '仪表盘',
20+
name: 'DashboardBase',
21+
isHome: true,
22+
},
23+
];
24+
1525
const state: TTabRouterType = {
16-
tabRouterList: [{ path: '/dashboard/base', routeIdx: 0, name: 'DashboardBase', title: '仪表盘', isHome: true }],
26+
tabRouterList: homeRoute,
1727
isRefreshing: false,
1828
};
1929

2030
const mutations = {
31+
// 处理刷新
2132
toggleTabRouterAlive(state: TTabRouterType, routeIdx: number) {
2233
state.isRefreshing = !state.isRefreshing;
2334
state.tabRouterList[routeIdx].isAlive = !state.tabRouterList[routeIdx].isAlive;
2435
},
36+
// 处理新增
2537
appendTabRouterList(state: TTabRouterType, newRoute: TRouterInfo) {
2638
if (!state.tabRouterList.find((route: TRouterInfo) => route.path === newRoute.path))
2739
// eslint-disable-next-line no-param-reassign
2840
state.tabRouterList = state.tabRouterList.concat(newRoute);
2941
},
42+
// 处理关闭当前
3043
subtractCurrentTabRouter(state: TTabRouterType, newRoute: TRouterInfo) {
3144
const { routeIdx } = newRoute;
3245
state.tabRouterList = state.tabRouterList.slice(0, routeIdx).concat(state.tabRouterList.slice(routeIdx + 1));
3346
},
47+
// 处理关闭右侧
3448
subtractTabRouterBehind(state: TTabRouterType, newRoute: TRouterInfo) {
3549
const { routeIdx } = newRoute;
3650
state.tabRouterList = state.tabRouterList.slice(0, routeIdx + 1);
3751
},
52+
// 处理关闭左侧
3853
subtractTabRouterAhead(state: TTabRouterType, newRoute: TRouterInfo) {
3954
const { routeIdx } = newRoute;
40-
state.tabRouterList = state.tabRouterList.slice(routeIdx);
55+
state.tabRouterList = homeRoute.concat(state.tabRouterList.slice(routeIdx));
4156
},
57+
// 处理关闭其他
4258
subtractTabRouterOther(state: TTabRouterType, newRoute: TRouterInfo) {
4359
const { routeIdx } = newRoute;
44-
state.tabRouterList = [state.tabRouterList?.[routeIdx]];
60+
state.tabRouterList = homeRoute.concat([state.tabRouterList?.[routeIdx]]);
4561
},
4662
removeTabRouterList() {
4763
state.tabRouterList = [];

0 commit comments

Comments
 (0)