Authored by 陈峰

router

1 /** 1 /**
2 * Created by TaoHuang on 2017/4/26. 2 * Created by TaoHuang on 2017/4/26.
3 */ 3 */
4 -  
5 -const editProduct = r => require.ensure([], () => r(require('./edit')), 'product.create'); 4 +const editProduct = r => require.ensure([], () => r(require('./edit')), 'product.edit');
6 5
7 export default { 6 export default {
8 path: '/edit/:id.html', 7 path: '/edit/:id.html',
@@ -2,7 +2,7 @@ const allotList = r => require.ensure([], () => r(require('./allot-list')), 'tra @@ -2,7 +2,7 @@ const allotList = r => require.ensure([], () => r(require('./allot-list')), 'tra
2 2
3 export default { 3 export default {
4 path: '/allotList.html', 4 path: '/allotList.html',
5 - name: 'allotList', 5 + name: 'allotlist',
6 component: allotList, 6 component: allotList,
7 meta: { 7 meta: {
8 pageName: '调拨单' 8 pageName: '调拨单'
@@ -2,6 +2,6 @@ const printDetail = r => require.ensure([], () => r(require('./print-detail')), @@ -2,6 +2,6 @@ const printDetail = r => require.ensure([], () => r(require('./print-detail')),
2 2
3 export default { 3 export default {
4 path: '/printDetail.html', 4 path: '/printDetail.html',
5 - name: 'printDetail', 5 + name: 'printdetail',
6 component: printDetail 6 component: printDetail
7 }; 7 };
@@ -9,14 +9,17 @@ export default { @@ -9,14 +9,17 @@ export default {
9 if (_.has(rous, 'path')) { 9 if (_.has(rous, 'path')) {
10 let ps = _.flattenDeep(paths).filter(p => p); 10 let ps = _.flattenDeep(paths).filter(p => p);
11 11
12 - rous.name = _.join(ps, '.'); 12 + if (_.last(ps) === rous.name) {
  13 + ps = _.dropRight(ps);
  14 + }
13 if (!children) { 15 if (!children) {
14 if (rous.path) { 16 if (rous.path) {
15 - rous.path = _.join(_.dropRight(ps, 1), '/') + (rous.path[0] === '/' ? '' : '/') + rous.path; 17 + rous.path = _.join(ps, '/') + (rous.path[0] === '/' ? '' : '/') + rous.path;
16 } else { 18 } else {
17 rous.path = _.join(ps, '/') + '.html'; 19 rous.path = _.join(ps, '/') + '.html';
18 } 20 }
19 } 21 }
  22 + rous.name = _.join(_.concat(ps, [rous.name]), '.');
20 23
21 if (rous.children) { 24 if (rous.children) {
22 _.each(rous.children, child => this.loadRouters(child, [paths, child.name], true)); 25 _.each(rous.children, child => this.loadRouters(child, [paths, child.name], true));
@@ -26,7 +29,7 @@ export default { @@ -26,7 +29,7 @@ export default {
26 } 29 }
27 if (rous.length) { 30 if (rous.length) {
28 return _.map(rous, r => { 31 return _.map(rous, r => {
29 - return this.loadRouters(r, [paths, r.name]); 32 + return this.loadRouters(r, [paths]);
30 }); 33 });
31 } else { 34 } else {
32 return _.map(rous, (rou, k) => { 35 return _.map(rous, (rou, k) => {