Skip to content

Commit 6d9ddad

Browse files
committed
add table demo
1 parent 95aca8e commit 6d9ddad

File tree

8 files changed

+431
-6
lines changed

8 files changed

+431
-6
lines changed

src/api/article.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { tpFetch } from 'utils/fetch';
1+
import { fetch } from 'utils/fetch';
22

33
export function getList() {
4-
return tpFetch({
4+
return fetch({
55
url: '/article/list',
66
method: 'get'
77
});

src/api/article_table.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { fetch } from 'utils/fetch';
2+
import { param } from 'utils';
3+
4+
// export function calendarsList(query) {
5+
// return fetch({
6+
// url: '/finfo/calendars?' + param(query),
7+
// method: 'get'
8+
// });
9+
// }
10+
11+
export function fetchList(query) {
12+
return fetch({
13+
url: '/article_table/list',
14+
method: 'get'
15+
});
16+
}
17+
18+
19+
export function calendarCreate(data) {
20+
return fetch({
21+
url: '/finfo/calendar/create',
22+
method: 'post',
23+
data
24+
});
25+
}
26+
27+
export function calendarDelete(id) {
28+
return fetch({
29+
url: '/finfo/calendar/delete',
30+
method: 'post',
31+
data: { id }
32+
});
33+
}
34+
35+
export function calendarUpdate(data) {
36+
return fetch({
37+
url: '/finfo/calendar/update',
38+
method: 'post',
39+
data
40+
});
41+
}
42+
43+
export function calcountriesList() {
44+
return fetch({
45+
url: '/finfo/calcountries',
46+
method: 'get'
47+
});
48+
}

src/assets/iconfont/iconfont.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
'' +
3939
'</symbol>' +
4040
'' +
41+
'<symbol id="icon-wujiaoxing" viewBox="0 0 1024 1024">' +
42+
'' +
43+
'<path d="M565.272827 34.627285l112.095872 237.542288c8.706637 18.321022 25.411424 31.051641 44.82285 33.996289l250.776598 38.081157c48.697387 7.411435 68.22505 70.046082 32.933559 105.979639l-181.494353 184.937155c-13.998147 14.230618-20.352386 34.815477-17.05903 54.93539l42.819161 261.127145c8.346858 50.695541-42.64204 89.451974-86.225039 65.51841l-224.307979-123.271141c-17.285968-9.525824-37.992596-9.525824-55.278564 0l-224.313514 123.271141c-43.582999 23.933565-94.571897-14.822869-86.219504-65.51841l42.813626-261.127145c3.321031-20.119914-3.088559-40.704772-17.086706-54.93539l-181.439002-184.937155c-35.285956-35.933557-15.819179-98.57374 32.933559-105.979639l250.748923-38.081157c19.350541-2.939112 36.083003-15.675267 44.75643-33.996289l112.123547-237.542288C480.497972-11.540583 543.509003-11.540583 565.272827 34.627285z" ></path>' +
44+
'' +
45+
'</symbol>' +
46+
'' +
4147
'<symbol id="icon-EXCEL" viewBox="0 0 1024 1024">' +
4248
'' +
4349
'<path d="M625.664 132.608V199.68h309.76v43.008h-309.76V312.32h309.76v43.008h-309.76v68.608h309.76v43.008h-309.76v68.608h309.76v43.008h-309.76v68.608h309.76v43.008h-309.76v68.096h309.76v43.008h-309.76v89.088H1024v-757.76h-398.336zM0 914.944L577.024 1024V0L0 109.056" ></path>' +

src/mock/article_table.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import Mock from 'mockjs';
2+
3+
4+
const List = [];
5+
const count = 50;
6+
7+
for (let i = 0; i < count; i++) {
8+
List.push(Mock.mock({
9+
id: '@increment',
10+
timestamp: +Mock.Random.date('T'),
11+
author: '@cname',
12+
title: '@ctitle(10, 20)',
13+
forecast: '@float(0, 100, 2, 2)',
14+
importance: '@integer(1, 3)',
15+
'calendar_type|1': ['FD', 'FE', 'BI', 'VN'],
16+
'status|1': ['published', 'draft', 'deleted']
17+
}));
18+
}
19+
20+
export default {
21+
getList: config =>
22+
// let {page, sortWay, startTime, endTime, userName, age} = config.params;
23+
// let mockUsers = _Users.filter(user => {
24+
// if (startTime && user.date < startTime) return false;
25+
// if (endTime && user.date > endTime) return false;
26+
// if (userName && user.name !== userName) return false;
27+
// if (age && user.age !== age) return false;
28+
// return true;
29+
// });
30+
// if (sortWay) {
31+
// let {order, prop} = sortWay;
32+
// mockUsers = mockUsers.sort((u1, u2) => order === 'ascending' ? u1[prop] - u2[prop] : u2[prop] - u1[prop]);
33+
// }
34+
// if (page === 0) page++;
35+
// mockUsers = mockUsers.filter((u, index) => index < 20 * page && index >= 20 * (page - 1));
36+
new Promise(resolve => {
37+
setTimeout(() => {
38+
resolve([200, {
39+
total: List.length,
40+
items: List
41+
}]);
42+
}, 100);
43+
})
44+
45+
};

src/mock/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from 'axios';
22
import Mock from 'mockjs';
33
import MockAdapter from 'axios-mock-adapter';
4+
import article_tableAPI from './article_table'
45
const mock = new MockAdapter(axios);
56

67
const articleList = {
@@ -15,4 +16,10 @@ const articleList = {
1516
}
1617
const data = JSON.stringify(Mock.mock(articleList))
1718
mock.onGet('/article/list').reply(200, data);
19+
20+
21+
mock.onGet('/article_table/list').reply(article_tableAPI.getList);
22+
23+
24+
1825
export default mock;

src/router/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const Theme = resolve => require(['../views/theme/index'], resolve);
5050

5151
/* example*/
5252
const DynamicTable = resolve => require(['../views/example/dynamictable'], resolve);
53+
const Table = resolve => require(['../views/example/table'], resolve);
5354

5455

5556
/* admin*/
@@ -168,7 +169,8 @@ export default new Router({
168169
name: '综合实例',
169170
icon: 'zonghe',
170171
children: [
171-
{ path: 'dynamictable', component: DynamicTable, name: '动态table' }
172+
{ path: 'dynamictable', component: DynamicTable, name: '动态table' },
173+
{ path: 'table', component: Table, name: '综合table' }
172174
]
173175
},
174176
// {

src/utils/fetch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Message } from 'element-ui';
33
import store from '../store';
44
import router from '../router';
55

6-
export default function fetch(options) {
6+
export default function _fetch(options) {
77
return new Promise((resolve, reject) => {
88
const instance = axios.create({
99
baseURL: process.env.BASE_API,
@@ -49,10 +49,10 @@ export default function fetch(options) {
4949
});
5050
}
5151

52-
export function tpFetch(options) {
52+
export function fetch(options) {
5353
return new Promise((resolve, reject) => {
5454
const instance = axios.create({
55-
// timeout: 2000,
55+
timeout: 2000 // 超时
5656
});
5757
instance(options)
5858
.then(response => {

0 commit comments

Comments
 (0)