Merge branch 'master' of http://git.yoho.cn/fe/ufo-platform-fe
Showing
20 changed files
with
297 additions
and
28 deletions
package-lock.json
deleted
100644 → 0
This diff could not be displayed because it is too large.
@@ -29,7 +29,9 @@ | @@ -29,7 +29,9 @@ | ||
29 | "babel": "^6.23.0", | 29 | "babel": "^6.23.0", |
30 | "babel-core": "^6.23.1", | 30 | "babel-core": "^6.23.1", |
31 | "babel-loader": "^7.1.2", | 31 | "babel-loader": "^7.1.2", |
32 | + "babel-plugin-syntax-jsx": "^6.18.0", | ||
32 | "babel-plugin-transform-runtime": "^6.12.0", | 33 | "babel-plugin-transform-runtime": "^6.12.0", |
34 | + "babel-plugin-transform-vue-jsx": "^3.7.0", | ||
33 | "babel-preset-es2015": "^6.9.0", | 35 | "babel-preset-es2015": "^6.9.0", |
34 | "babel-runtime": "^6.11.6", | 36 | "babel-runtime": "^6.11.6", |
35 | "css-loader": "^0.28.7", | 37 | "css-loader": "^0.28.7", |
@@ -4,8 +4,8 @@ class Api { | @@ -4,8 +4,8 @@ class Api { | ||
4 | constructor() { | 4 | constructor() { |
5 | } | 5 | } |
6 | 6 | ||
7 | - _get(url, data, debug = false) { | ||
8 | - if (debug) { | 7 | + _get(url, data) { |
8 | + if (!PRODUCTION) { | ||
9 | data = Object.assign({}, data, { | 9 | data = Object.assign({}, data, { |
10 | debug: 'XYZ' | 10 | debug: 'XYZ' |
11 | }); | 11 | }); |
@@ -14,8 +14,8 @@ class Api { | @@ -14,8 +14,8 @@ class Api { | ||
14 | return util.ajax.get(url, data).then(result => result.data); | 14 | return util.ajax.get(url, data).then(result => result.data); |
15 | } | 15 | } |
16 | 16 | ||
17 | - _post(url, data, debug = false, json = false) { | ||
18 | - if (debug) { | 17 | + _post(url, data, json = false) { |
18 | + if (!PRODUCTION) { | ||
19 | url += '?debug=XYZ'; | 19 | url += '?debug=XYZ'; |
20 | } | 20 | } |
21 | 21 | ||
@@ -30,7 +30,9 @@ class Api { | @@ -30,7 +30,9 @@ class Api { | ||
30 | const params = new URLSearchParams(); | 30 | const params = new URLSearchParams(); |
31 | 31 | ||
32 | for (let i of Object.keys(data)) { | 32 | for (let i of Object.keys(data)) { |
33 | - params.append(i, data[i]); | 33 | + if (data[i]) { |
34 | + params.append(i, data[i]); | ||
35 | + } | ||
34 | } | 36 | } |
35 | 37 | ||
36 | return params; | 38 | return params; |
@@ -12,11 +12,11 @@ class ResourceApi extends Api { | @@ -12,11 +12,11 @@ class ResourceApi extends Api { | ||
12 | } | 12 | } |
13 | 13 | ||
14 | editResource(data) { | 14 | editResource(data) { |
15 | - return this._post('/ufoPlatform/resource/editResourceContentData', data, true); | 15 | + return this._post('/ufoPlatform/resource/editResourceContentData', data); |
16 | } | 16 | } |
17 | 17 | ||
18 | editGoodsPool(data) { | 18 | editGoodsPool(data) { |
19 | - return this._post('/ufoPlatform/resource/batchEditResourceGoodsPool', data, true, true); | 19 | + return this._post('/ufoPlatform/resource/batchEditResourceGoodsPool', data, true); |
20 | } | 20 | } |
21 | } | 21 | } |
22 | 22 |
@@ -3,10 +3,18 @@ import iView from 'iview'; | @@ -3,10 +3,18 @@ import iView from 'iview'; | ||
3 | import 'iview/dist/styles/iview.css'; | 3 | import 'iview/dist/styles/iview.css'; |
4 | import emitter from './mixins/emitter'; | 4 | import emitter from './mixins/emitter'; |
5 | import bus from './bus'; | 5 | import bus from './bus'; |
6 | +import components from './views/components' | ||
7 | +import './statics/base.scss' | ||
6 | 8 | ||
7 | Vue.use(iView); | 9 | Vue.use(iView); |
8 | Vue.prototype.$bus = bus; | 10 | Vue.prototype.$bus = bus; |
9 | 11 | ||
12 | +Object.keys(components).forEach(cm => { | ||
13 | + Object.keys(components[cm]).forEach(ck => { | ||
14 | + Vue.component(components[cm][ck].name, components[cm][ck]) | ||
15 | + }) | ||
16 | +}) | ||
17 | + | ||
10 | Vue.mixin(emitter); | 18 | Vue.mixin(emitter); |
11 | 19 | ||
12 | export default (App) => { | 20 | export default (App) => { |
src/statics/base.scss
0 → 100644
@@ -5,14 +5,10 @@ | @@ -5,14 +5,10 @@ | ||
5 | <title>iView project</title> | 5 | <title>iView project</title> |
6 | <meta charset="UTF-8"> | 6 | <meta charset="UTF-8"> |
7 | <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"> | 7 | <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"> |
8 | - <link rel="stylesheet" href="<%= htmlWebpackPlugin.files.css[0] %>"> | ||
9 | - <link rel="stylesheet" href="<%= htmlWebpackPlugin.files.css[1] %>"> | ||
10 | </head> | 8 | </head> |
11 | 9 | ||
12 | <body> | 10 | <body> |
13 | <div id="app"></div> | 11 | <div id="app"></div> |
14 | - <script type="text/javascript" src="<%= htmlWebpackPlugin.files.js[0] %>"></script> | ||
15 | - <script type="text/javascript" src="<%= htmlWebpackPlugin.files.js[1] %>"></script> | ||
16 | </body> | 12 | </body> |
17 | 13 | ||
18 | </html> | 14 | </html> |
src/views/components/index.js
0 → 100644
src/views/components/layout/filter-item.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="filter-item"> | ||
3 | + <slot></slot> | ||
4 | + </div> | ||
5 | +</template> | ||
6 | + | ||
7 | +<script> | ||
8 | +export default { | ||
9 | + name: 'FilterItem', | ||
10 | +} | ||
11 | +</script> | ||
12 | + | ||
13 | +<style lang="scss" scoped> | ||
14 | +.filter-item { | ||
15 | + display: inline-block; | ||
16 | + margin-right: 10px; | ||
17 | + vertical-align: top | ||
18 | +} | ||
19 | +</style> |
src/views/components/layout/index.js
0 → 100644
1 | +import LayoutContent from './layout-content' | ||
2 | +import LayoutFilter from './layout-filter' | ||
3 | +import LayoutTable from './layout-table' | ||
4 | +import LayoutTools from './layout-tools' | ||
5 | +import FilterItem from './filter-item' | ||
6 | + | ||
7 | + | ||
8 | +export default { | ||
9 | + LayoutContent, | ||
10 | + LayoutFilter, | ||
11 | + LayoutTable, | ||
12 | + LayoutTools, | ||
13 | + FilterItem | ||
14 | +} |
1 | +<template> | ||
2 | + <div class="layout-content"> | ||
3 | + <i-card class="layout-card"> | ||
4 | + <slot></slot> | ||
5 | + </i-card> | ||
6 | + </div> | ||
7 | +</template> | ||
8 | + | ||
9 | +<script> | ||
10 | +export default { | ||
11 | + name: 'LayoutContent' | ||
12 | +} | ||
13 | +</script> | ||
14 | + | ||
15 | +<style lang="scss" scoped> | ||
16 | +.layout-content { | ||
17 | + width: 100%; | ||
18 | + height: 100%; | ||
19 | + background: #f5f7f9; | ||
20 | + display: flex; | ||
21 | + overflow: auto; | ||
22 | + padding: 18px; | ||
23 | + | ||
24 | + .layout-card { | ||
25 | + width: 100%; | ||
26 | + | ||
27 | + } | ||
28 | +} | ||
29 | +</style> |
1 | +<template> | ||
2 | + <div class="layout-filter"> | ||
3 | + <div class="filter-box"> | ||
4 | + <slot></slot> | ||
5 | + </div> | ||
6 | + <i-button type="primary" @click="onFilter">筛选</i-button> | ||
7 | + <i-button type="warning" @click="onClear">清空</i-button> | ||
8 | + </div> | ||
9 | +</template> | ||
10 | + | ||
11 | +<script> | ||
12 | +export default { | ||
13 | + name: 'LayoutFilter', | ||
14 | + methods: { | ||
15 | + onFilter() { | ||
16 | + this.$emit('on-filter') | ||
17 | + }, | ||
18 | + onClear() { | ||
19 | + this.$emit('on-clear') | ||
20 | + } | ||
21 | + } | ||
22 | +} | ||
23 | +</script> | ||
24 | + | ||
25 | +<style lang="scss" scoped> | ||
26 | +.layout-filter { | ||
27 | + padding: 10px 0; | ||
28 | + | ||
29 | + .filter-box { | ||
30 | + display: inline-block; | ||
31 | + vertical-align: top | ||
32 | + } | ||
33 | + | ||
34 | + /deep/ .ivu-form-item { | ||
35 | + margin-bottom: 0; | ||
36 | + } | ||
37 | +} | ||
38 | +</style> |
src/views/components/layout/layout-table.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="layout-table"> | ||
3 | + <slot></slot> | ||
4 | + <div class="footer"> | ||
5 | + <slot name="footer"></slot> | ||
6 | + </div> | ||
7 | + </div> | ||
8 | +</template> | ||
9 | + | ||
10 | +<script> | ||
11 | +export default { | ||
12 | + name: 'LayoutTable' | ||
13 | +} | ||
14 | +</script> | ||
15 | + | ||
16 | +<style lang="scss" scoped> | ||
17 | +.layout-table { | ||
18 | + .footer { | ||
19 | + padding: 10px 0; | ||
20 | + text-align: right; | ||
21 | + } | ||
22 | +} | ||
23 | +</style> |
src/views/components/layout/layout-tools.vue
0 → 100644
1 | <template> | 1 | <template> |
2 | - | 2 | + <LayoutContent> |
3 | + <LayoutFilter @on-filter="onFilter" @on-clear="onClear"> | ||
4 | + <i-form ref="filterForm" inline :model="filter"> | ||
5 | + <i-form-item prop="id"> | ||
6 | + <i-input placeholder="输入ID" v-model="filter.id"></i-input> | ||
7 | + </i-form-item> | ||
8 | + <i-form-item prop="name"> | ||
9 | + <i-input placeholder="输入券名称" v-model="filter.name"></i-input> | ||
10 | + </i-form-item> | ||
11 | + <i-form-item prop="status"> | ||
12 | + <i-select v-model="filter.status" style="width: 100px;"> | ||
13 | + <i-option :value="0">全部</i-option> | ||
14 | + <i-option :value="1">未生效</i-option> | ||
15 | + <i-option :value="2">生效中</i-option> | ||
16 | + <i-option :value="3">已过期</i-option> | ||
17 | + <i-option :value="4">已作废</i-option> | ||
18 | + </i-select> | ||
19 | + </i-form-item> | ||
20 | + <i-form-item prop="time"> | ||
21 | + <i-date-picker type="datetimerange" v-model="filter.time" width="300" placeholder="开始-结束时间" format="yyyy-MM-dd HH:mm" style="width: 250px"></i-date-picker> | ||
22 | + </i-form-item> | ||
23 | + </i-form> | ||
24 | + </LayoutFilter> | ||
25 | + <LayoutTools> | ||
26 | + <i-button type="success" icon="md-add">新增优惠券</i-button> | ||
27 | + </LayoutTools> | ||
28 | + <LayoutTable> | ||
29 | + <i-table :columns="columns" :data="data"></i-table> | ||
30 | + <template slot="footer" class="btns"> | ||
31 | + <i-button type="primary" icon="ios-cloud-download">导出</i-button> | ||
32 | + </template> | ||
33 | + </LayoutTable> | ||
34 | + </LayoutContent> | ||
3 | </template> | 35 | </template> |
4 | 36 | ||
5 | <script> | 37 | <script> |
6 | -export default { | 38 | +import {Button} from 'iview' |
39 | +import Api from '@/api/api' | ||
40 | + | ||
41 | +const api = new Api() | ||
7 | 42 | ||
43 | +export default { | ||
44 | + name: 'CouponPage', | ||
45 | + data() { | ||
46 | + return { | ||
47 | + filter: { | ||
48 | + id: '', | ||
49 | + name: '', | ||
50 | + status: 0, | ||
51 | + time: ['', ''] | ||
52 | + }, | ||
53 | + data: [{}], | ||
54 | + columns: [{ | ||
55 | + title: 'ID', | ||
56 | + key: 'id' | ||
57 | + }, { | ||
58 | + title: '券名称', | ||
59 | + key: 'id' | ||
60 | + }, { | ||
61 | + title: '数量', | ||
62 | + key: 'id' | ||
63 | + }, { | ||
64 | + title: '使用期限', | ||
65 | + key: 'id' | ||
66 | + }, { | ||
67 | + title: '优惠券说明', | ||
68 | + width: 300, | ||
69 | + key: 'id' | ||
70 | + }, { | ||
71 | + title: '状态', | ||
72 | + key: 'id' | ||
73 | + }, { | ||
74 | + title: '操作', | ||
75 | + width: 270, | ||
76 | + render() { | ||
77 | + return ( | ||
78 | + <div> | ||
79 | + <i-button type="success" size="small">查看详情</i-button> | ||
80 | + <i-button type="primary" size="small">修改</i-button> | ||
81 | + <i-button type="error" size="small">作废</i-button> | ||
82 | + <i-button type="warning" size="small">发放记录</i-button> | ||
83 | + </div> | ||
84 | + ); | ||
85 | + } | ||
86 | + }] | ||
87 | + } | ||
88 | + }, | ||
89 | + methods: { | ||
90 | + onFilter() { | ||
91 | + this.fetchData(this.filter) | ||
92 | + }, | ||
93 | + onClear() { | ||
94 | + this.$refs.filterForm.resetFields() | ||
95 | + this.fetchData(this.filter) | ||
96 | + }, | ||
97 | + fetchData(params) { | ||
98 | + api._post('/ufoPlatform/coupon/queryCoupons', { | ||
99 | + id: params.id || void 0, | ||
100 | + name: params.name || void 0, | ||
101 | + status: params.status || void 0, | ||
102 | + startTime: params.time[0] || void 0, | ||
103 | + endTime: params.time[1] || void 0, | ||
104 | + }, true) | ||
105 | + } | ||
106 | + } | ||
8 | } | 107 | } |
9 | </script> | 108 | </script> |
10 | 109 |
@@ -6,7 +6,7 @@ module.exports = { | @@ -6,7 +6,7 @@ module.exports = { | ||
6 | entry: { | 6 | entry: { |
7 | 'app-home': './src/main-home-page', | 7 | 'app-home': './src/main-home-page', |
8 | 'app-sort': './src/main-sort-page', | 8 | 'app-sort': './src/main-sort-page', |
9 | - vendors: './src/vendors' | 9 | + 'coupon': './src/main-coupon-page', |
10 | }, | 10 | }, |
11 | output: { | 11 | output: { |
12 | path: path.join(__dirname, './dist') | 12 | path: path.join(__dirname, './dist') |
@@ -18,12 +18,12 @@ module.exports = { | @@ -18,12 +18,12 @@ module.exports = { | ||
18 | loader: 'vue-loader', | 18 | loader: 'vue-loader', |
19 | options: { | 19 | options: { |
20 | loaders: { | 20 | loaders: { |
21 | - less: ExtractTextPlugin.extract({ | ||
22 | - use: ['css-loader?minimize', 'autoprefixer-loader', 'less-loader'], | 21 | + sass: ExtractTextPlugin.extract({ |
22 | + use: ['css-loader?minimize', 'autoprefixer-loader', 'sass-loader'], | ||
23 | fallback: 'vue-style-loader' | 23 | fallback: 'vue-style-loader' |
24 | }), | 24 | }), |
25 | css: ExtractTextPlugin.extract({ | 25 | css: ExtractTextPlugin.extract({ |
26 | - use: ['css-loader', 'autoprefixer-loader', 'less-loader'], | 26 | + use: ['css-loader', 'autoprefixer-loader', 'sass-loader'], |
27 | fallback: 'vue-style-loader' | 27 | fallback: 'vue-style-loader' |
28 | }) | 28 | }) |
29 | } | 29 | } |
@@ -32,7 +32,7 @@ module.exports = { | @@ -32,7 +32,7 @@ module.exports = { | ||
32 | { | 32 | { |
33 | loader: 'iview-loader', | 33 | loader: 'iview-loader', |
34 | options: { | 34 | options: { |
35 | - prefix: false | 35 | + prefix: true |
36 | } | 36 | } |
37 | } | 37 | } |
38 | ] | 38 | ] |
@@ -55,9 +55,9 @@ module.exports = { | @@ -55,9 +55,9 @@ module.exports = { | ||
55 | }, | 55 | }, |
56 | 56 | ||
57 | { | 57 | { |
58 | - test: /\.sass/, | 58 | + test: /\.scss/, |
59 | use: ExtractTextPlugin.extract({ | 59 | use: ExtractTextPlugin.extract({ |
60 | - use: ['autoprefixer-loader', 'sass-loader'], | 60 | + use: ['css-loader', 'autoprefixer-loader', 'sass-loader'], |
61 | fallback: 'style-loader' | 61 | fallback: 'style-loader' |
62 | }) | 62 | }) |
63 | }, | 63 | }, |
@@ -11,13 +11,16 @@ fs.open('./src/config/env.js', 'w', function(err, fd) { | @@ -11,13 +11,16 @@ fs.open('./src/config/env.js', 'w', function(err, fd) { | ||
11 | }); | 11 | }); |
12 | 12 | ||
13 | module.exports = merge(webpackBaseConfig, { | 13 | module.exports = merge(webpackBaseConfig, { |
14 | - devtool: '#source-map', | 14 | + // devtool: '#source-map', |
15 | output: { | 15 | output: { |
16 | publicPath: '/dist/', | 16 | publicPath: '/dist/', |
17 | filename: '[name].js', | 17 | filename: '[name].js', |
18 | chunkFilename: '[name].chunk.js' | 18 | chunkFilename: '[name].chunk.js' |
19 | }, | 19 | }, |
20 | plugins: [ | 20 | plugins: [ |
21 | + new webpack.DefinePlugin({ | ||
22 | + PRODUCTION: 'false' | ||
23 | + }), | ||
21 | new ExtractTextPlugin({ | 24 | new ExtractTextPlugin({ |
22 | filename: '[name].css', | 25 | filename: '[name].css', |
23 | allChunks: true | 26 | allChunks: true |
@@ -27,30 +30,34 @@ module.exports = merge(webpackBaseConfig, { | @@ -27,30 +30,34 @@ module.exports = merge(webpackBaseConfig, { | ||
27 | filename: 'vendors.js' | 30 | filename: 'vendors.js' |
28 | }), | 31 | }), |
29 | new HtmlWebpackPlugin({ | 32 | new HtmlWebpackPlugin({ |
30 | - filename: '../index_home.html', | 33 | + filename: 'index_home.html', |
31 | template: './src/template/index.ejs', | 34 | template: './src/template/index.ejs', |
32 | - inject: false, | 35 | + inject: true, |
33 | chunks: ['vendors', 'app-home'] | 36 | chunks: ['vendors', 'app-home'] |
34 | }), | 37 | }), |
35 | new HtmlWebpackPlugin({ | 38 | new HtmlWebpackPlugin({ |
36 | - filename: '../index_sort.html', | 39 | + filename: 'index_sort.html', |
37 | template: './src/template/index.ejs', | 40 | template: './src/template/index.ejs', |
38 | - inject: false, | 41 | + inject: true, |
39 | chunks: ['vendors', 'app-sort'] | 42 | chunks: ['vendors', 'app-sort'] |
40 | }), | 43 | }), |
41 | new HtmlWebpackPlugin({ | 44 | new HtmlWebpackPlugin({ |
42 | - filename: '../coupon.html', | 45 | + filename: 'coupon.html', |
43 | template: './src/template/index.ejs', | 46 | template: './src/template/index.ejs', |
44 | - inject: false, | 47 | + inject: true, |
45 | chunks: ['vendors', 'coupon'] | 48 | chunks: ['vendors', 'coupon'] |
46 | }) | 49 | }) |
47 | ], | 50 | ], |
48 | devServer: { | 51 | devServer: { |
49 | - openPage: 'index_home.html', | 52 | + openPage: 'dist/coupon.html', |
50 | proxy: { | 53 | proxy: { |
51 | '/ufoPlatform/**': { | 54 | '/ufoPlatform/**': { |
52 | target: 'http://java-ufo-platform.test3.ingress.dev.yohocorp.com', | 55 | target: 'http://java-ufo-platform.test3.ingress.dev.yohocorp.com', |
53 | changeOrigin: true | 56 | changeOrigin: true |
57 | + }, | ||
58 | + '/ufoPlatform': { | ||
59 | + target: 'http://java-ufo-platform.test3.ingress.dev.yohocorp.com', | ||
60 | + changeOrigin: true | ||
54 | } | 61 | } |
55 | }, | 62 | }, |
56 | headers: { | 63 | headers: { |
@@ -17,6 +17,9 @@ module.exports = merge(webpackBaseConfig, { | @@ -17,6 +17,9 @@ module.exports = merge(webpackBaseConfig, { | ||
17 | chunkFilename: '[name].[hash].chunk.js' | 17 | chunkFilename: '[name].[hash].chunk.js' |
18 | }, | 18 | }, |
19 | plugins: [ | 19 | plugins: [ |
20 | + new webpack.DefinePlugin({ | ||
21 | + PRODUCTION: 'true' | ||
22 | + }), | ||
20 | new ExtractTextPlugin({ | 23 | new ExtractTextPlugin({ |
21 | filename: '[name].[hash].css', | 24 | filename: '[name].[hash].css', |
22 | allChunks: true | 25 | allChunks: true |
This diff could not be displayed because it is too large.
-
Please register or login to post a comment