diff --git a/src/router/index.js b/src/router/index.js index 3d49cf3959539a3c08daee80b3f9bdeb04534801..139fe2e725157b6ec5421661977b525a4c21f2c9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -58,6 +58,7 @@ const DragTable = () => import('../views/example/table/dragTable'); const InlineEditTable = () => import('../views/example/table/inlineEditTable'); const Form = () => import('../views/example/form'); +const Tab = () => import('../views/example/tab/index'); /* permission */ const Permission = () => import('../views/permission/index'); @@ -198,7 +199,7 @@ export const asyncRouterMap = [ path: '/table', component: TableLayout, redirect: '/table/table', - name: 'table', + name: 'Table', children: [ { path: 'dynamictable', component: DynamicTable, name: '动æ€table' }, { path: 'dragtable', component: DragTable, name: '拖拽table' }, @@ -206,8 +207,10 @@ export const asyncRouterMap = [ { path: 'table', component: Table, name: '综åˆtable' } ] }, - { path: 'form/edit', component: Form, name: '编辑form', meta: { isEdit: true } }, - { path: 'form/create', component: Form, name: '创建form' } + { path: 'form/edit', component: Form, name: '编辑Form', meta: { isEdit: true } }, + { path: 'form/create', component: Form, name: '创建Form' }, + + { path: 'tab/index', component: Tab, name: 'Tab' } ] }, { path: '*', redirect: '/404', hidden: true } diff --git a/src/views/example/tab/components/tabPane.vue b/src/views/example/tab/components/tabPane.vue new file mode 100644 index 0000000000000000000000000000000000000000..1a318c36f490321c1885a809296e3019d46921a9 --- /dev/null +++ b/src/views/example/tab/components/tabPane.vue @@ -0,0 +1,98 @@ +<template> + <el-table :data="list" border fit highlight-current-row style="width: 100%"> + + <el-table-column align="center" label="åºå·" width="65"> + <template scope="scope"> + <span>{{scope.row.id}}</span> + </template> + </el-table-column> + + <el-table-column width="180px" align="center" label="æ—¶é—´"> + <template scope="scope"> + <span>{{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}</span> + </template> + </el-table-column> + + <el-table-column min-width="300px" label="æ ‡é¢˜"> + <template scope="scope"> + <span class="link-type" @click="handleUpdate(scope.row)">{{scope.row.title}}</span> + <el-tag>{{scope.row.type}}</el-tag> + </template> + </el-table-column> + + <el-table-column width="110px" align="center" label="作者"> + <template scope="scope"> + <span>{{scope.row.author}}</span> + </template> + </el-table-column> + + <el-table-column width="80px" label="é‡è¦æ€§"> + <template scope="scope"> + <wscn-icon-svg v-for="n in +scope.row.importance" icon-class="wujiaoxing" class="meta-item__icon" :key="n" /> + </template> + </el-table-column> + + <el-table-column align="center" label="阅读数" width="95"> + <template scope="scope"> + <span>{{scope.row.pageviews}}</span> + </template> + </el-table-column> + + <el-table-column class-name="status-col" label="状æ€" width="90"> + <template scope="scope"> + <el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag> + </template> + </el-table-column> + + </el-table> +</template> + +<script> + import { fetchList } from 'api/article_table'; + + export default { + name: 'articleDetail', + props: { + type: { + type: String, + default: 'CN' + } + }, + data() { + return { + list: null, + total: null, + listQuery: { + page: 1, + limit: 5, + type: this.type, + sort: '+id' + } + } + }, + filters: { + statusFilter(status) { + const statusMap = { + published: 'success', + draft: 'gray', + deleted: 'danger' + }; + return statusMap[status] + } + }, + created() { + this.getList(); + }, + methods: { + getList() { + this.$emit('create'); // for test + + fetchList(this.listQuery).then(response => { + this.list = response.data.items; + this.total = response.data.total; + }) + } + } + } +</script> + diff --git a/src/views/example/tab/index.vue b/src/views/example/tab/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..2c63f18da8968e094218a3824dd0e5e86baa9adc --- /dev/null +++ b/src/views/example/tab/index.vue @@ -0,0 +1,44 @@ +<template> + <div class="tab-container"> + <el-tag type="primary">create times :{{createdTimes}}</el-tag> + <el-tabs style='margin-top:15px;' v-model="activeName" type="border-card"> + <el-tab-pane v-for="item in tabMapOptions" :label="item.label" :key='item.key' :name="item.key"> + <keep-alive> + <tab-pane v-if='activeName==item.key' :type='item.key' @create='showCreatedTimes'></tab-pane> + </keep-alive> + </el-tab-pane> + </el-tabs> + </div> +</template> + +<script> + import tabPane from './components/tabPane' + + export default { + name: 'tabDemo', + components: { tabPane }, + data() { + return { + tabMapOptions: [ + { label: 'ä¸å›½', key: 'CN' }, + { label: '美国', key: 'US' }, + { label: '日本', key: 'JP' }, + { label: '欧元区', key: 'EU' } + ], + activeName: 'CN', + createdTimes: 0 + } + }, + methods: { + showCreatedTimes() { + this.createdTimes = this.createdTimes + 1; + } + } + } +</script> + +<style scoped> + .tab-container{ + margin: 30px; + } +</style>