Skip to content

Commit 33a4369

Browse files
committed
refine code
1 parent 8fa2364 commit 33a4369

File tree

8 files changed

+40
-66
lines changed

8 files changed

+40
-66
lines changed

src/router/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import Layout from '../views/layout/Layout'
1818
export const constantRouterMap = [
1919
{ path: '/login', component: _import('login/index'), hidden: true },
2020
{ path: '/authredirect', component: _import('login/authredirect'), hidden: true },
21-
{ path: '/404', component: _import('error/404'), hidden: true },
22-
{ path: '/401', component: _import('error/401'), hidden: true },
21+
{ path: '/404', component: _import('errorPage/404'), hidden: true },
22+
{ path: '/401', component: _import('errorPage/401'), hidden: true },
2323
{
2424
path: '/',
2525
component: Layout,
@@ -117,14 +117,14 @@ export const asyncRouterMap = [
117117
]
118118
},
119119
{
120-
path: '/errorpage',
120+
path: '/error',
121121
component: Layout,
122122
redirect: 'noredirect',
123123
name: '错误页面',
124124
icon: '404',
125125
children: [
126-
{ path: '401', component: _import('error/401'), name: '401' },
127-
{ path: '404', component: _import('error/404'), name: '404' }
126+
{ path: '401', component: _import('errorPage/401'), name: '401' },
127+
{ path: '404', component: _import('errorPage/404'), name: '404' }
128128
]
129129
},
130130
{
@@ -139,12 +139,12 @@ export const asyncRouterMap = [
139139
{
140140
path: '/excel',
141141
component: Layout,
142-
redirect: 'noredirect',
142+
redirect: '/excel/download',
143143
name: 'excel',
144144
icon: 'EXCEL',
145145
children: [
146146
{ path: 'download', component: _import('excel/index'), name: '导出excel' },
147-
{ path: 'download2', component: _import('excel/selectExcel'), name: '选择导出excel' }
147+
{ path: 'download2', component: _import('excel/selectExcel'), name: '导出已选择项' }
148148
]
149149
},
150150
{

src/views/error/401.vue renamed to src/views/errorPage/401.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<img :src="errGif" width="313" height="428" alt="Girl has dropped her ice cream.">
2121
</el-col>
2222
</el-row>
23-
2423
<el-dialog title="随便看" :visible.sync="dialogVisible" size="large">
2524
<img class="pan-img" :src="ewizardClap">
2625
</el-dialog>

src/views/error/404.vue renamed to src/views/errorPage/404.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,4 @@ export default {
225225
}
226226
}
227227
}
228-
229228
</style>

src/views/example/tab/components/tabPane.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<el-table-column width="80px" label="重要性">
3030
<template scope="scope">
31-
<icon-svg v-for="n in +scope.row.importance" icon-class="wujiaoxing" class="meta-item__icon" :key="n"></icon-svg>
31+
<icon-svg v-for="n in +scope.row.importance" icon-class="wujiaoxing" :key="n"></icon-svg>
3232
</template>
3333
</el-table-column>
3434

@@ -51,7 +51,6 @@
5151
import { fetchList } from 'api/article_table'
5252
5353
export default {
54-
name: 'articleDetail',
5554
props: {
5655
type: {
5756
type: String,
@@ -61,7 +60,6 @@ export default {
6160
data() {
6261
return {
6362
list: null,
64-
total: null,
6563
listQuery: {
6664
page: 1,
6765
limit: 5,
@@ -86,10 +84,8 @@ export default {
8684
methods: {
8785
getList() {
8886
this.$emit('create') // for test
89-
9087
fetchList(this.listQuery).then(response => {
9188
this.list = response.data.items
92-
this.total = response.data.total
9389
})
9490
}
9591
}

src/views/example/tab/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export default {
2020
data() {
2121
return {
2222
tabMapOptions: [
23-
{ label: '中国', key: 'CN' },
24-
{ label: '美国', key: 'US' },
25-
{ label: '日本', key: 'JP' },
26-
{ label: '欧元区', key: 'EU' }
23+
{ label: '中国', key: 'CN' },
24+
{ label: '美国', key: 'US' },
25+
{ label: '日本', key: 'JP' },
26+
{ label: '欧元区', key: 'EU' }
2727
],
2828
activeName: 'CN',
2929
createdTimes: 0

src/views/excel/index.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="app-container">
3-
<el-button style='margin-bottom:20px;float:right' type="primary" icon="document" @click="handleDownload">导出excel</el-button>
3+
<el-button style='margin-bottom:20px;' type="primary" icon="document" @click="handleDownload" :loading="downloadLoading">导出excel</el-button>
44
<el-table :data="list" v-loading.body="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row>
55
<el-table-column align="center" label='ID' width="95">
66
<template scope="scope">
@@ -12,7 +12,6 @@
1212
{{scope.row.title}}
1313
</template>
1414
</el-table-column>
15-
1615
<el-table-column label="作者" width="110">
1716
<template scope="scope">
1817
<span>{{scope.row.author}}</span>
@@ -40,7 +39,8 @@ export default {
4039
data() {
4140
return {
4241
list: null,
43-
listLoading: true
42+
listLoading: true,
43+
downloadLoading: false
4444
}
4545
},
4646
created() {
@@ -49,21 +49,21 @@ export default {
4949
methods: {
5050
fetchData() {
5151
this.listLoading = true
52-
getList(this.listQuery).then(response => {
52+
getList().then(response => {
5353
this.list = response.data
5454
this.listLoading = false
5555
})
5656
},
5757
handleDownload() {
58+
this.downloadLoading = true
5859
require.ensure([], () => {
59-
const {
60-
export_json_to_excel
61-
} = require('vendor/Export2Excel')
60+
const { export_json_to_excel } = require('vendor/Export2Excel')
6261
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
6362
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
6463
const list = this.list
6564
const data = this.formatJson(filterVal, list)
6665
export_json_to_excel(tHeader, data, '列表excel')
66+
this.downloadLoading = false
6767
})
6868
},
6969
formatJson(filterVal, jsonData) {

src/views/excel/selectExcel.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
<template>
22
<div class="app-container">
3-
<el-button style='margin-bottom:20px;float:right' type="primary" icon="document" @click="handleDownload">导出excel</el-button>
4-
5-
<el-table :data="list" v-loading.body="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row @selection-change="handleSelectionChange" ref="multipleTable">
3+
<el-button style='margin-bottom:20px' type="primary" icon="document" @click="handleDownload" :loading="downloadLoading">导出已选择项</el-button>
4+
<el-table :data="list" v-loading.body="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row @selection-change="handleSelectionChange"
5+
ref="multipleTable">
66
<el-table-column type="selection" align="center"></el-table-column>
7-
87
<el-table-column align="center" label='ID' width="95">
98
<template scope="scope">
109
{{scope.$index}}
1110
</template>
1211
</el-table-column>
13-
1412
<el-table-column label="文章标题">
1513
<template scope="scope">
1614
{{scope.row.title}}
1715
</template>
1816
</el-table-column>
19-
2017
<el-table-column label="作者" width="110">
2118
<template scope="scope">
2219
<span>{{scope.row.author}}</span>
2320
</template>
2421
</el-table-column>
25-
2622
<el-table-column label="阅读数" width="105" align="center">
2723
<template scope="scope">
2824
{{scope.row.pageviews}}
2925
</template>
3026
</el-table-column>
31-
3227
<el-table-column align="center" prop="created_at" label="发布时间" width="200">
3328
<template scope="scope">
3429
<i class="el-icon-time"></i>
@@ -39,7 +34,6 @@
3934
</div>
4035
</template>
4136

42-
4337
<script>
4438
import { getList } from 'api/article'
4539
@@ -48,7 +42,8 @@ export default {
4842
return {
4943
list: null,
5044
listLoading: true,
51-
multipleSelection: []
45+
multipleSelection: [],
46+
downloadLoading: false
5247
}
5348
},
5449
created() {
@@ -67,6 +62,7 @@ export default {
6762
},
6863
handleDownload() {
6964
if (this.multipleSelection.length) {
65+
this.downloadLoading = true
7066
require.ensure([], () => {
7167
const { export_json_to_excel } = require('vendor/Export2Excel')
7268
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
@@ -75,10 +71,11 @@ export default {
7571
const data = this.formatJson(filterVal, list)
7672
export_json_to_excel(tHeader, data, '列表excel')
7773
this.$refs.multipleTable.clearSelection()
74+
this.downloadLoading = false
7875
})
7976
} else {
8077
this.$message({
81-
message: '请选择一条或多条记录导出',
78+
message: '请至少选择一条记录',
8279
type: 'warning'
8380
})
8481
}

src/views/theme/index.vue

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<template>
22
<div class="app-container">
3-
<code>会补动态换肤的教程</code>
43
<el-card class="box-card">
54
<div slot="header">
65
<span style="line-height: 36px;">偏好设置</span>
6+
<a class='link-type link-title' target="_blank" href='https://segmentfault.com/a/1190000009762198#articleHeader2'>态换肤的教程</a>
77
</div>
8-
98
<div class="box-item">
109
<span class="field-label">换肤:</span>
1110
<el-switch v-model="theme" on-text="" off-text="">
@@ -43,6 +42,7 @@
4342
</div>
4443
</template>
4544

45+
4646
<script>
4747
import { toggleClass } from 'utils'
4848
import '@/assets/custom-theme/index.css' // 换肤版本element-ui css
@@ -51,39 +51,19 @@ export default {
5151
data() {
5252
return {
5353
theme: false,
54-
tags: [{
55-
name: '标签一',
56-
type: ''
57-
},
58-
{
59-
name: '标签二',
60-
type: 'gray'
61-
},
62-
{
63-
name: '标签三',
64-
type: 'primary'
65-
},
66-
{
67-
name: '标签四',
68-
type: 'success'
69-
},
70-
{
71-
name: '标签五',
72-
type: 'warning'
73-
},
74-
{
75-
name: '标签六',
76-
type: 'danger'
77-
}
78-
],
79-
inputVisible: false,
80-
inputValue: ''
54+
tags: [
55+
{ name: '标签一', type: '' },
56+
{ name: '标签二', type: 'gray' },
57+
{ name: '标签三', type: 'primary' },
58+
{ name: '标签四', type: 'success' },
59+
{ name: '标签五', type: 'warning' },
60+
{ name: '标签六', type: 'danger' }
61+
]
8162
}
8263
},
8364
watch: {
8465
theme() {
8566
toggleClass(document.body, 'custom-theme')
86-
// this.$store.dispatch('setTheme', value);
8767
}
8868
}
8969
}
@@ -103,4 +83,7 @@ export default {
10383
.tag-item{
10484
margin-right: 15px;
10585
}
86+
.link-title{
87+
margin-left:35px;
88+
}
10689
</style>

0 commit comments

Comments
 (0)