Commit 04e55fcfe10fc43f97ad53414df502369dbdba57
1 parent
a1b48a4445
Exists in
master
auto commit the code by alias command
Showing
5 changed files
with
419 additions
and
460 deletions
Show diff stats
mock/prod/list.js
| 1 | import Mock from 'mockjs' | File was deleted | |
| 2 | // import logoPath from "~@/assets/img/yp_logo.jpeg" | ||
| 3 | |||
| 4 | const List = [] | ||
| 5 | const count = 20 | ||
| 6 | |||
| 7 | const baseContent = '<p>I am testing data, I am testing data.</p><p></p>' | ||
| 8 | // const image_uri = logoPath | ||
| 9 | const image_uri = 'https://wpimg.wallstcn.com/360e4842-4db5-42d0-b078-f9a84a825546.gif' | ||
| 10 | |||
| 11 | for (let i = 0; i < count; i++) { | ||
| 12 | List.push(Mock.mock({ | ||
| 13 | pid: '@increment', | ||
| 14 | pname: '@title(5,10)', | ||
| 15 | timestamp: +Mock.Random.date('T'), | ||
| 16 | shoper: '@first', //所属工厂 | ||
| 17 | salescount: '@first', //购买次数 | ||
| 18 | importance: '@integer(1, 3)', //排序权重 | ||
| 19 | prod_info_weight: '@integer(1, 3)', //重量 | ||
| 20 | prod_info_leg_long: '@integer(1, 3)', //腿长 | ||
| 21 | prod_info_glass_width: '@integer(1, 3)', //镜宽 | ||
| 22 | prod_info_glass_height: '@integer(1, 3)', //镜高 | ||
| 23 | prod_info_frame_width: '@integer(1, 3)', //框宽 | ||
| 24 | prod_info_frame_height: '@integer(1, 3)', //框高 | ||
| 25 | prod_info_norse_width: '@integer(1, 3)', //鼻宽 | ||
| 26 | prod_info_window_pic: [], //鼻宽 | ||
| 27 | image_uri: image_uri | ||
| 28 | })) | ||
| 29 | } | ||
| 30 | |||
| 31 | export default [{ | ||
| 32 | url: '/yp/prod/list', | ||
| 33 | type: 'post', | ||
| 34 | response: config => { | ||
| 35 | const { | ||
| 36 | importance, | ||
| 37 | type, | ||
| 38 | title, | ||
| 39 | page = 1, | ||
| 40 | limit = 20, | ||
| 41 | sort | ||
| 42 | } = config.query | ||
| 43 | |||
| 44 | // let mockList = List.filter(item => { | ||
| 45 | // if (importance && item.importance !== +importance) return false | ||
| 46 | // if (type && item.type !== type) return false | ||
| 47 | // if (title && item.title.indexOf(title) < 0) return false | ||
| 48 | // return true | ||
| 49 | // }) | ||
| 50 | |||
| 51 | if (sort === '-id') { | ||
| 52 | mockList = mockList.reverse() | ||
| 53 | } | ||
| 54 | |||
| 55 | const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1)) | ||
| 56 | |||
| 57 | return { | ||
| 58 | code: 20000, | ||
| 59 | data: { | ||
| 60 | total: mockList.length, | ||
| 61 | items: pageList | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
| 65 | }, | ||
| 66 | |||
| 67 | // { | ||
| 68 | // url: '/yp/prod/detail', | ||
| 69 | // type: 'get', | ||
| 70 | // response: config => { | ||
| 71 | // const { | ||
| 72 | // id | ||
| 73 | // } = config.query | ||
| 74 | // for (const article of List) { | ||
| 75 | // if (article.id === +id) { | ||
| 76 | // return { | ||
| 77 | // code: 20000, | ||
| 78 | // data: article | ||
| 79 | // } | ||
| 80 | // } | ||
| 81 | // } | ||
| 82 | // } | ||
| 83 | // }, | ||
| 84 | |||
| 85 | // { | ||
| 86 | // url: '/yp/article/pv', | ||
| 87 | // type: 'get', | ||
| 88 | // response: _ => { | ||
| 89 | // return { | ||
| 90 | // code: 20000, | ||
| 91 | // data: { | ||
| 92 | // pvData: [{ | ||
| 93 | // key: 'PC', | ||
| 94 | // pv: 1024 | ||
| 95 | // }, | ||
| 96 | // { | ||
| 97 | // key: 'mobile', | ||
| 98 | // pv: 1024 | ||
| 99 | // }, | ||
| 100 | // { | ||
| 101 | // key: 'ios', | ||
| 102 | // pv: 1024 | ||
| 103 | // }, | ||
| 104 | // { | ||
| 105 | // key: 'android', | ||
| 106 | // pv: 1024 | ||
| 107 | // } | ||
| 108 | // ] | ||
| 109 | // } | ||
| 110 | // } | ||
| 111 | // } | ||
| 112 | // }, | ||
| 113 | |||
| 114 | // { | ||
| 115 | // url: '/yp/article/create', | ||
| 116 | // type: 'post', | ||
| 117 | // response: _ => { | ||
| 118 | // return { | ||
| 119 | // code: 20000, | ||
| 120 | // data: 'success' | ||
| 121 | // } | ||
| 122 | // } | ||
| 123 | // }, | ||
| 124 | |||
| 125 | // { | ||
| 126 | // url: '/yp/article/update', | ||
| 127 | // type: 'post', | ||
| 128 | // response: _ => { | ||
| 129 | // return { | ||
| 130 | // code: 20000, | ||
| 131 | // data: 'success' | ||
| 132 | // } | ||
| 133 | // } | ||
| 134 | // } | ||
| 135 | ] | ||
| 136 | 1 | import Mock from 'mockjs' |
mock/role/routes.js
| 1 | // Just a mock data | 1 | // Just a mock data |
| 2 | 2 | ||
| 3 | export const constantRoutes = [ | 3 | export const constantRoutes = [{ |
| 4 | { | ||
| 5 | path: '/redirect', | 4 | path: '/redirect', |
| 6 | component: 'layout/Layout', | 5 | component: 'layout/Layout', |
| 7 | hidden: true, | 6 | hidden: true, |
| 8 | children: [ | 7 | children: [{ |
| 9 | { | 8 | path: '/redirect/:path*', |
| 10 | path: '/redirect/:path*', | 9 | component: 'views/redirect/index' |
| 11 | component: 'views/redirect/index' | 10 | }] |
| 12 | } | ||
| 13 | ] | ||
| 14 | }, | 11 | }, |
| 15 | { | 12 | { |
| 16 | path: '/login', | 13 | path: '/login', |
| 17 | component: 'views/login/index', | 14 | component: 'views/login/index', |
| 18 | hidden: true | 15 | hidden: true |
| 19 | }, | 16 | }, |
| 20 | { | 17 | { |
| 21 | path: '/auth-redirect', | 18 | path: '/auth-redirect', |
| 22 | component: 'views/login/auth-redirect', | 19 | component: 'views/login/auth-redirect', |
| 23 | hidden: true | 20 | hidden: true |
| 24 | }, | 21 | }, |
| 25 | { | 22 | { |
| 26 | path: '/401', | 23 | path: '/401', |
| 27 | component: 'views/error-page/401', | 24 | component: 'views/error-page/401', |
| 28 | hidden: true | 25 | hidden: true |
| 29 | }, | 26 | }, |
| 30 | { | 27 | { |
| 31 | path: '/403', | 28 | path: '/403', |
| 32 | component: 'views/error-page/403', | 29 | component: 'views/error-page/403', |
| 33 | hidden: true | 30 | hidden: true |
| 34 | }, | 31 | }, |
| 35 | { | 32 | { |
| 36 | path: '/404', | 33 | path: '/404', |
| 37 | component: 'views/error-page/404', | 34 | component: 'views/error-page/404', |
| 38 | hidden: true | 35 | hidden: true |
| 39 | }, | 36 | }, |
| 40 | { | 37 | { |
| 41 | path: '/500', | 38 | path: '/500', |
| 42 | component: 'views/error-page/500', | 39 | component: 'views/error-page/500', |
| 43 | hidden: true | 40 | hidden: true |
| 44 | }, | 41 | }, |
| 45 | { | 42 | { |
| 46 | path: '', | 43 | path: '', |
| 47 | component: 'layout/Layout', | 44 | component: 'layout/Layout', |
| 48 | redirect: 'dashboard', | 45 | redirect: 'dashboard', |
| 49 | children: [ | 46 | children: [{ |
| 50 | { | 47 | path: 'dashboard', |
| 51 | path: 'dashboard', | 48 | component: 'views/dashboard/index', |
| 52 | component: 'views/dashboard/index', | 49 | name: 'Dashboard', |
| 53 | name: 'Dashboard', | 50 | meta: { |
| 54 | meta: { title: 'dashboard', icon: 'dashboard', affix: true } | 51 | title: 'dashboard', |
| 52 | icon: 'dashboard', | ||
| 53 | affix: true | ||
| 55 | } | 54 | } |
| 56 | ] | 55 | }] |
| 57 | }, | 56 | }, |
| 58 | { | 57 | { |
| 59 | path: '/documentation', | 58 | path: '/documentation', |
| 60 | component: 'layout/Layout', | 59 | component: 'layout/Layout', |
| 61 | children: [ | 60 | children: [{ |
| 62 | { | 61 | path: 'index', |
| 63 | path: 'index', | 62 | component: 'views/documentation/index', |
| 64 | component: 'views/documentation/index', | 63 | name: 'Documentation', |
| 65 | name: 'Documentation', | 64 | meta: { |
| 66 | meta: { title: 'documentation', icon: 'documentation', affix: true } | 65 | title: 'documentation', |
| 66 | icon: 'documentation', | ||
| 67 | affix: true | ||
| 67 | } | 68 | } |
| 68 | ] | 69 | }] |
| 69 | }, | 70 | }, |
| 70 | { | 71 | { |
| 71 | path: '/guide', | 72 | path: '/guide', |
| 72 | component: 'layout/Layout', | 73 | component: 'layout/Layout', |
| 73 | redirect: '/guide/index', | 74 | redirect: '/guide/index', |
| 74 | children: [ | 75 | children: [{ |
| 75 | { | 76 | path: 'index', |
| 76 | path: 'index', | 77 | component: 'views/guide/index', |
| 77 | component: 'views/guide/index', | 78 | name: 'Guide', |
| 78 | name: 'Guide', | 79 | meta: { |
| 79 | meta: { title: 'guide', icon: 'guide', noCache: true } | 80 | title: 'guide', |
| 81 | icon: 'guide', | ||
| 82 | noCache: true | ||
| 80 | } | 83 | } |
| 81 | ] | 84 | }] |
| 82 | } | 85 | } |
| 83 | ] | 86 | ] |
| 84 | 87 | ||
| 85 | export const asyncRoutes = [ | 88 | export const asyncRoutes = [{ |
| 86 | // { | 89 | path: '/permission', |
| 87 | // path: '/permission', | 90 | component: 'layout/Layout', |
| 88 | // component: 'layout/Layout', | 91 | redirect: '/permission/index', |
| 89 | // redirect: '/permission/index', | 92 | alwaysShow: true, |
| 90 | // alwaysShow: true, | 93 | meta: { |
| 91 | // meta: { | 94 | title: 'permission', |
| 92 | // title: 'permission', | 95 | icon: 'lock', |
| 93 | // icon: 'lock', | 96 | // roles: ['admin', 'assistant', 'runner', 'shoper'] |
| 94 | // // roles: ['admin', 'assistant', 'runner', 'shoper'] | 97 | }, |
| 95 | // }, | 98 | children: [{ |
| 96 | // children: [ | 99 | path: 'page', |
| 97 | // { | 100 | component: 'views/permission/page', |
| 98 | // path: 'page', | 101 | name: 'PagePermission', |
| 99 | // component: 'views/permission/page', | 102 | meta: { |
| 100 | // name: 'PagePermission', | 103 | title: 'pagePermission', |
| 101 | // meta: { | 104 | roles: ['admin', 'assistant'] |
| 102 | // title: 'pagePermission', | 105 | } |
| 103 | // roles: ['admin','assistant'] | 106 | }, |
| 104 | // } | 107 | { |
| 105 | // }, | 108 | path: 'directive', |
| 106 | // { | 109 | component: 'views/permission/directive', |
| 107 | // path: 'directive', | 110 | name: 'DirectivePermission', |
| 108 | // component: 'views/permission/directive', | 111 | meta: { |
| 109 | // name: 'DirectivePermission', | 112 | title: 'directivePermission', |
| 110 | // meta: { | 113 | roles: ['shoper'] |
| 111 | // title: 'directivePermission', | 114 | } |
| 112 | // roles:['shoper'] | 115 | }, |
| 113 | // } | 116 | { |
| 114 | // }, | 117 | path: 'role', |
| 115 | // { | 118 | component: 'views/permission/role', |
| 116 | // path: 'role', | 119 | name: 'RolePermission', |
| 117 | // component: 'views/permission/role', | 120 | meta: { |
| 118 | // name: 'RolePermission', | 121 | title: 'rolePermission', |
| 119 | // meta: { | 122 | roles: ['runner'] |
| 120 | // title: 'rolePermission', | 123 | } |
| 121 | // roles: ['runner'] | 124 | } |
| 122 | // } | 125 | ] |
| 123 | // } | 126 | }, |
| 124 | // ] | ||
| 125 | // }, | ||
| 126 | 127 | ||
| 127 | { | 128 | { |
| 128 | path: '/icon', | 129 | path: '/icon', |
| 129 | component: 'layout/Layout', | 130 | component: 'layout/Layout', |
| 130 | meta: { | 131 | meta: { |
| 131 | title: 'ddddd', | 132 | title: 'ddddd', |
| 132 | icon:'people', | 133 | icon: 'people', |
| 133 | roles: ['runner'] | 134 | roles: ['runner'] |
| 134 | }, | 135 | }, |
| 135 | children: [ | 136 | children: [{ |
| 136 | { | 137 | path: 'index', |
| 137 | path: 'index', | 138 | component: 'views/icons/index', |
| 138 | component: 'views/icons/index', | 139 | name: 'Icons', |
| 139 | name: 'Icons', | 140 | meta: { |
| 140 | meta: { title: 'icons', icon: 'icon', noCache: true } | 141 | title: 'icons', |
| 142 | icon: 'icon', | ||
| 143 | noCache: true | ||
| 141 | } | 144 | } |
| 142 | ] | 145 | }] |
| 143 | }, | 146 | }, |
| 144 | 147 | ||
| 145 | { | 148 | { |
| 146 | path: '/components', | 149 | path: '/components', |
| 147 | component: 'layout/Layout', | 150 | component: 'layout/Layout', |
| 148 | redirect: 'noRedirect', | 151 | redirect: 'noRedirect', |
| 149 | name: 'ComponentDemo', | 152 | name: 'ComponentDemo', |
| 150 | meta: { | 153 | meta: { |
| 151 | title: 'components', | 154 | title: 'components', |
| 152 | icon: 'component' | 155 | icon: 'component' |
| 153 | }, | 156 | }, |
| 154 | children: [ | 157 | children: [{ |
| 155 | { | ||
| 156 | path: 'tinymce', | 158 | path: 'tinymce', |
| 157 | component: 'views/components-demo/tinymce', | 159 | component: 'views/components-demo/tinymce', |
| 158 | name: 'TinymceDemo', | 160 | name: 'TinymceDemo', |
| 159 | meta: { title: 'tinymce' } | 161 | meta: { |
| 162 | title: 'tinymce' | ||
| 163 | } | ||
| 160 | }, | 164 | }, |
| 161 | { | 165 | { |
| 162 | path: 'markdown', | 166 | path: 'markdown', |
| 163 | component: 'views/components-demo/markdown', | 167 | component: 'views/components-demo/markdown', |
| 164 | name: 'MarkdownDemo', | 168 | name: 'MarkdownDemo', |
| 165 | meta: { title: 'markdown' } | 169 | meta: { |
| 170 | title: 'markdown' | ||
| 171 | } | ||
| 166 | }, | 172 | }, |
| 167 | { | 173 | { |
| 168 | path: 'json-editor', | 174 | path: 'json-editor', |
| 169 | component: 'views/components-demo/json-editor', | 175 | component: 'views/components-demo/json-editor', |
| 170 | name: 'JsonEditorDemo', | 176 | name: 'JsonEditorDemo', |
| 171 | meta: { title: 'jsonEditor' } | 177 | meta: { |
| 178 | title: 'jsonEditor' | ||
| 179 | } | ||
| 172 | }, | 180 | }, |
| 173 | { | 181 | { |
| 174 | path: 'split-pane', | 182 | path: 'split-pane', |
| 175 | component: 'views/components-demo/split-pane', | 183 | component: 'views/components-demo/split-pane', |
| 176 | name: 'SplitpaneDemo', | 184 | name: 'SplitpaneDemo', |
| 177 | meta: { title: 'splitPane' } | 185 | meta: { |
| 186 | title: 'splitPane' | ||
| 187 | } | ||
| 178 | }, | 188 | }, |
| 179 | { | 189 | { |
| 180 | path: 'avatar-upload', | 190 | path: 'avatar-upload', |
| 181 | component: 'views/components-demo/avatar-upload', | 191 | component: 'views/components-demo/avatar-upload', |
| 182 | name: 'AvatarUploadDemo', | 192 | name: 'AvatarUploadDemo', |
| 183 | meta: { title: 'avatarUpload' } | 193 | meta: { |
| 194 | title: 'avatarUpload' | ||
| 195 | } | ||
| 184 | }, | 196 | }, |
| 185 | { | 197 | { |
| 186 | path: 'dropzone', | 198 | path: 'dropzone', |
| 187 | component: 'views/components-demo/dropzone', | 199 | component: 'views/components-demo/dropzone', |
| 188 | name: 'DropzoneDemo', | 200 | name: 'DropzoneDemo', |
| 189 | meta: { title: 'dropzone' } | 201 | meta: { |
| 202 | title: 'dropzone' | ||
| 203 | } | ||
| 190 | }, | 204 | }, |
| 191 | { | 205 | { |
| 192 | path: 'sticky', | 206 | path: 'sticky', |
| 193 | component: 'views/components-demo/sticky', | 207 | component: 'views/components-demo/sticky', |
| 194 | name: 'StickyDemo', | 208 | name: 'StickyDemo', |
| 195 | meta: { title: 'sticky' } | 209 | meta: { |
| 210 | title: 'sticky' | ||
| 211 | } | ||
| 196 | }, | 212 | }, |
| 197 | { | 213 | { |
| 198 | path: 'count-to', | 214 | path: 'count-to', |
| 199 | component: 'views/components-demo/count-to', | 215 | component: 'views/components-demo/count-to', |
| 200 | name: 'CountToDemo', | 216 | name: 'CountToDemo', |
| 201 | meta: { title: 'countTo' } | 217 | meta: { |
| 218 | title: 'countTo' | ||
| 219 | } | ||
| 202 | }, | 220 | }, |
| 203 | { | 221 | { |
| 204 | path: 'mixin', | 222 | path: 'mixin', |
| 205 | component: 'views/components-demo/mixin', | 223 | component: 'views/components-demo/mixin', |
| 206 | name: 'ComponentMixinDemo', | 224 | name: 'ComponentMixinDemo', |
| 207 | meta: { title: 'componentMixin' } | 225 | meta: { |
| 226 | title: 'componentMixin' | ||
| 227 | } | ||
| 208 | }, | 228 | }, |
| 209 | { | 229 | { |
| 210 | path: 'back-to-top', | 230 | path: 'back-to-top', |
| 211 | component: 'views/components-demo/back-to-top', | 231 | component: 'views/components-demo/back-to-top', |
| 212 | name: 'BackToTopDemo', | 232 | name: 'BackToTopDemo', |
| 213 | meta: { title: 'backToTop' } | 233 | meta: { |
| 234 | title: 'backToTop' | ||
| 235 | } | ||
| 214 | }, | 236 | }, |
| 215 | { | 237 | { |
| 216 | path: 'drag-dialog', | 238 | path: 'drag-dialog', |
| 217 | component: 'views/components-demo/drag-dialog', | 239 | component: 'views/components-demo/drag-dialog', |
| 218 | name: 'DragDialogDemo', | 240 | name: 'DragDialogDemo', |
| 219 | meta: { title: 'dragDialog' } | 241 | meta: { |
| 242 | title: 'dragDialog' | ||
| 243 | } | ||
| 220 | }, | 244 | }, |
| 221 | { | 245 | { |
| 222 | path: 'drag-select', | 246 | path: 'drag-select', |
| 223 | component: 'views/components-demo/drag-select', | 247 | component: 'views/components-demo/drag-select', |
| 224 | name: 'DragSelectDemo', | 248 | name: 'DragSelectDemo', |
| 225 | meta: { title: 'dragSelect' } | 249 | meta: { |
| 250 | title: 'dragSelect' | ||
| 251 | } | ||
| 226 | }, | 252 | }, |
| 227 | { | 253 | { |
| 228 | path: 'dnd-list', | 254 | path: 'dnd-list', |
| 229 | component: 'views/components-demo/dnd-list', | 255 | component: 'views/components-demo/dnd-list', |
| 230 | name: 'DndListDemo', | 256 | name: 'DndListDemo', |
| 231 | meta: { title: 'dndList' } | 257 | meta: { |
| 258 | title: 'dndList' | ||
| 259 | } | ||
| 232 | }, | 260 | }, |
| 233 | { | 261 | { |
| 234 | path: 'drag-kanban', | 262 | path: 'drag-kanban', |
| 235 | component: 'views/components-demo/drag-kanban', | 263 | component: 'views/components-demo/drag-kanban', |
| 236 | name: 'DragKanbanDemo', | 264 | name: 'DragKanbanDemo', |
| 237 | meta: { title: 'dragKanban' } | 265 | meta: { |
| 266 | title: 'dragKanban' | ||
| 267 | } | ||
| 238 | } | 268 | } |
| 239 | ] | 269 | ] |
| 240 | }, | 270 | }, |
| 241 | { | 271 | { |
| 242 | path: '/charts', | 272 | path: '/charts', |
| 243 | component: 'layout/Layout', | 273 | component: 'layout/Layout', |
| 244 | redirect: 'noRedirect', | 274 | redirect: 'noRedirect', |
| 245 | name: 'Charts', | 275 | name: 'Charts', |
| 246 | meta: { | 276 | meta: { |
| 247 | title: 'charts', | 277 | title: 'charts', |
| 248 | icon: 'chart' | 278 | icon: 'chart' |
| 249 | }, | 279 | }, |
| 250 | children: [ | 280 | children: [{ |
| 251 | { | ||
| 252 | path: 'keyboard', | 281 | path: 'keyboard', |
| 253 | component: 'views/charts/keyboard', | 282 | component: 'views/charts/keyboard', |
| 254 | name: 'KeyboardChart', | 283 | name: 'KeyboardChart', |
| 255 | meta: { title: 'keyboardChart', noCache: true } | 284 | meta: { |
| 285 | title: 'keyboardChart', | ||
| 286 | noCache: true | ||
| 287 | } | ||
| 256 | }, | 288 | }, |
| 257 | { | 289 | { |
| 258 | path: 'line', | 290 | path: 'line', |
| 259 | component: 'views/charts/line', | 291 | component: 'views/charts/line', |
| 260 | name: 'LineChart', | 292 | name: 'LineChart', |
| 261 | meta: { title: 'lineChart', noCache: true } | 293 | meta: { |
| 294 | title: 'lineChart', | ||
| 295 | noCache: true | ||
| 296 | } | ||
| 262 | }, | 297 | }, |
| 263 | { | 298 | { |
| 264 | path: 'mixchart', | 299 | path: 'mixchart', |
| 265 | component: 'views/charts/mixChart', | 300 | component: 'views/charts/mixChart', |
| 266 | name: 'MixChart', | 301 | name: 'MixChart', |
| 267 | meta: { title: 'mixChart', noCache: true } | 302 | meta: { |
| 303 | title: 'mixChart', | ||
| 304 | noCache: true | ||
| 305 | } | ||
| 268 | } | 306 | } |
| 269 | ] | 307 | ] |
| 270 | }, | 308 | }, |
| 271 | { | 309 | { |
| 272 | path: '/nested', | 310 | path: '/nested', |
| 273 | component: 'layout/Layout', | 311 | component: 'layout/Layout', |
| 274 | redirect: '/nested/menu1/menu1-1', | 312 | redirect: '/nested/menu1/menu1-1', |
| 275 | name: 'Nested', | 313 | name: 'Nested', |
| 276 | meta: { | 314 | meta: { |
| 277 | title: 'nested', | 315 | title: 'nested', |
| 278 | icon: 'nested' | 316 | icon: 'nested' |
| 279 | }, | 317 | }, |
| 280 | children: [ | 318 | children: [{ |
| 281 | { | ||
| 282 | path: 'menu1', | 319 | path: 'menu1', |
| 283 | component: 'views/nested/menu1/index', | 320 | component: 'views/nested/menu1/index', |
| 284 | name: 'Menu1', | 321 | name: 'Menu1', |
| 285 | meta: { title: 'menu1' }, | 322 | meta: { |
| 323 | title: 'menu1' | ||
| 324 | }, | ||
| 286 | redirect: '/nested/menu1/menu1-1', | 325 | redirect: '/nested/menu1/menu1-1', |
| 287 | children: [ | 326 | children: [{ |
| 288 | { | ||
| 289 | path: 'menu1-1', | 327 | path: 'menu1-1', |
| 290 | component: 'views/nested/menu1/menu1-1', | 328 | component: 'views/nested/menu1/menu1-1', |
| 291 | name: 'Menu1-1', | 329 | name: 'Menu1-1', |
| 292 | meta: { title: 'menu1-1' } | 330 | meta: { |
| 331 | title: 'menu1-1' | ||
| 332 | } | ||
| 293 | }, | 333 | }, |
| 294 | { | 334 | { |
| 295 | path: 'menu1-2', | 335 | path: 'menu1-2', |
| 296 | component: 'views/nested/menu1/menu1-2', | 336 | component: 'views/nested/menu1/menu1-2', |
| 297 | name: 'Menu1-2', | 337 | name: 'Menu1-2', |
| 298 | redirect: '/nested/menu1/menu1-2/menu1-2-1', | 338 | redirect: '/nested/menu1/menu1-2/menu1-2-1', |
| 299 | meta: { title: 'menu1-2' }, | 339 | meta: { |
| 300 | children: [ | 340 | title: 'menu1-2' |
| 301 | { | 341 | }, |
| 342 | children: [{ | ||
| 302 | path: 'menu1-2-1', | 343 | path: 'menu1-2-1', |
| 303 | component: 'views/nested/menu1/menu1-2/menu1-2-1', | 344 | component: 'views/nested/menu1/menu1-2/menu1-2-1', |
| 304 | name: 'Menu1-2-1', | 345 | name: 'Menu1-2-1', |
| 305 | meta: { title: 'menu1-2-1' } | 346 | meta: { |
| 347 | title: 'menu1-2-1' | ||
| 348 | } | ||
| 306 | }, | 349 | }, |
| 307 | { | 350 | { |
| 308 | path: 'menu1-2-2', | 351 | path: 'menu1-2-2', |
| 309 | component: 'views/nested/menu1/menu1-2/menu1-2-2', | 352 | component: 'views/nested/menu1/menu1-2/menu1-2-2', |
| 310 | name: 'Menu1-2-2', | 353 | name: 'Menu1-2-2', |
| 311 | meta: { title: 'menu1-2-2' } | 354 | meta: { |
| 355 | title: 'menu1-2-2' | ||
| 356 | } | ||
| 312 | } | 357 | } |
| 313 | ] | 358 | ] |
| 314 | }, | 359 | }, |
| 315 | { | 360 | { |
| 316 | path: 'menu1-3', | 361 | path: 'menu1-3', |
| 317 | component: 'views/nested/menu1/menu1-3', | 362 | component: 'views/nested/menu1/menu1-3', |
| 318 | name: 'Menu1-3', | 363 | name: 'Menu1-3', |
| 319 | meta: { title: 'menu1-3' } | 364 | meta: { |
| 365 | title: 'menu1-3' | ||
| 366 | } | ||
| 320 | } | 367 | } |
| 321 | ] | 368 | ] |
| 322 | }, | 369 | }, |
| 323 | { | 370 | { |
| 324 | path: 'menu2', | 371 | path: 'menu2', |
| 325 | name: 'Menu2', | 372 | name: 'Menu2', |
| 326 | component: 'views/nested/menu2/index', | 373 | component: 'views/nested/menu2/index', |
| 327 | meta: { title: 'menu2' } | 374 | meta: { |
| 375 | title: 'menu2' | ||
| 376 | } | ||
| 328 | } | 377 | } |
| 329 | ] | 378 | ] |
| 330 | }, | 379 | }, |
| 331 | 380 | ||
| 332 | { | 381 | { |
| 333 | path: '/example', | 382 | path: '/example', |
| 334 | component: 'layout/Layout', | 383 | component: 'layout/Layout', |
| 335 | redirect: '/example/list', | 384 | redirect: '/example/list', |
| 336 | name: 'Example', | 385 | name: 'Example', |
| 337 | meta: { | 386 | meta: { |
| 338 | title: 'example', | 387 | title: 'example', |
| 339 | icon: 'example' | 388 | icon: 'example' |
| 340 | }, | 389 | }, |
| 341 | children: [ | 390 | children: [{ |
| 342 | { | ||
| 343 | path: 'create', | 391 | path: 'create', |
| 344 | component: 'views/example/create', | 392 | component: 'views/example/create', |
| 345 | name: 'CreateArticle', | 393 | name: 'CreateArticle', |
| 346 | meta: { title: 'createArticle', icon: 'edit' } | 394 | meta: { |
| 395 | title: 'createArticle', | ||
| 396 | icon: 'edit' | ||
| 397 | } | ||
| 347 | }, | 398 | }, |
| 348 | { | 399 | { |
| 349 | path: 'edit/:id(\\d+)', | 400 | path: 'edit/:id(\\d+)', |
| 350 | component: 'views/example/edit', | 401 | component: 'views/example/edit', |
| 351 | name: 'EditArticle', | 402 | name: 'EditArticle', |
| 352 | meta: { title: 'editArticle', noCache: true }, | 403 | meta: { |
| 404 | title: 'editArticle', | ||
| 405 | noCache: true | ||
| 406 | }, | ||
| 353 | hidden: true | 407 | hidden: true |
| 354 | }, | 408 | }, |
| 355 | { | 409 | { |
| 356 | path: 'list', | 410 | path: 'list', |
| 357 | component: 'views/example/list', | 411 | component: 'views/example/list', |
| 358 | name: 'ArticleList', | 412 | name: 'ArticleList', |
| 359 | meta: { title: 'articleList', icon: 'list' } | 413 | meta: { |
| 414 | title: 'articleList', | ||
| 415 | icon: 'list' | ||
| 416 | } | ||
| 360 | } | 417 | } |
| 361 | ] | 418 | ] |
| 362 | }, | 419 | }, |
| 363 | 420 | ||
| 364 | { | 421 | { |
| 365 | path: '/tab', | 422 | path: '/tab', |
| 366 | component: 'layout/Layout', | 423 | component: 'layout/Layout', |
| 367 | children: [ | 424 | children: [{ |
| 368 | { | 425 | path: 'index', |
| 369 | path: 'index', | 426 | component: 'views/tab/index', |
| 370 | component: 'views/tab/index', | 427 | name: 'Tab', |
| 371 | name: 'Tab', | 428 | meta: { |
| 372 | meta: { title: 'tab', icon: 'tab' } | 429 | title: 'tab', |
| 430 | icon: 'tab' | ||
| 373 | } | 431 | } |
| 374 | ] | 432 | }] |
| 375 | }, | 433 | }, |
| 376 | 434 | ||
| 377 | { | 435 | { |
| 378 | path: '/error', | 436 | path: '/error', |
| 379 | component: 'layout/Layout', | 437 | component: 'layout/Layout', |
| 380 | redirect: 'noRedirect', | 438 | redirect: 'noRedirect', |
| 381 | name: 'ErrorPages', | 439 | name: 'ErrorPages', |
| 382 | meta: { | 440 | meta: { |
| 383 | title: 'errorPages', | 441 | title: 'errorPages', |
| 384 | icon: '404' | 442 | icon: '404' |
| 385 | }, | 443 | }, |
| 386 | children: [ | 444 | children: [{ |
| 387 | { | ||
| 388 | path: '401', | 445 | path: '401', |
| 389 | component: 'views/error-page/401', | 446 | component: 'views/error-page/401', |
| 390 | name: 'Page401', | 447 | name: 'Page401', |
| 391 | meta: { title: 'page401', noCache: true } | 448 | meta: { |
| 449 | title: 'page401', | ||
| 450 | noCache: true | ||
| 451 | } | ||
| 392 | }, | 452 | }, |
| 393 | { | 453 | { |
| 394 | path: '404', | 454 | path: '404', |
| 395 | component: 'views/error-page/404', | 455 | component: 'views/error-page/404', |
| 396 | name: 'Page404', | 456 | name: 'Page404', |
| 397 | meta: { title: 'page404', noCache: true } | 457 | meta: { |
| 458 | title: 'page404', | ||
| 459 | noCache: true | ||
| 460 | } | ||
| 398 | }, | 461 | }, |
| 399 | { | 462 | { |
| 400 | path: '500', | 463 | path: '500', |
| 401 | component: 'views/error-page/500', | 464 | component: 'views/error-page/500', |
| 402 | name: 'Page500', | 465 | name: 'Page500', |
| 403 | meta: { title: 'page500', noCache: true } | 466 | meta: { |
| 467 | title: 'page500', | ||
| 468 | noCache: true | ||
| 469 | } | ||
| 404 | } | 470 | } |
| 405 | ] | 471 | ] |
| 406 | }, | 472 | }, |
| 407 | 473 | ||
| 408 | { | 474 | { |
| 409 | path: '/error-log', | 475 | path: '/error-log', |
| 410 | component: 'layout/Layout', | 476 | component: 'layout/Layout', |
| 411 | redirect: 'noRedirect', | 477 | redirect: 'noRedirect', |
| 412 | children: [ | 478 | children: [{ |
| 413 | { | 479 | path: 'log', |
| 414 | path: 'log', | 480 | component: 'views/error-log/index', |
| 415 | component: 'views/error-log/index', | 481 | name: 'ErrorLog', |
| 416 | name: 'ErrorLog', | 482 | meta: { |
| 417 | meta: { title: 'errorLog', icon: 'bug' } | 483 | title: 'errorLog', |
| 484 | icon: 'bug' | ||
| 418 | } | 485 | } |
| 419 | ] | 486 | }] |
| 420 | }, | 487 | }, |
| 421 | 488 | ||
| 422 | { | 489 | { |
| 423 | path: '/excel', | 490 | path: '/excel', |
| 424 | component: 'layout/Layout', | 491 | component: 'layout/Layout', |
| 425 | redirect: '/excel/export-excel', | 492 | redirect: '/excel/export-excel', |
| 426 | name: 'Excel', | 493 | name: 'Excel', |
| 427 | meta: { | 494 | meta: { |
| 428 | title: 'excel', | 495 | title: 'excel', |
| 429 | icon: 'excel' | 496 | icon: 'excel' |
| 430 | }, | 497 | }, |
| 431 | children: [ | 498 | children: [{ |
| 432 | { | ||
| 433 | path: 'export-excel', | 499 | path: 'export-excel', |
| 434 | component: 'views/excel/export-excel', | 500 | component: 'views/excel/export-excel', |
| 435 | name: 'ExportExcel', | 501 | name: 'ExportExcel', |
| 436 | meta: { title: 'exportExcel' } | 502 | meta: { |
| 503 | title: 'exportExcel' | ||
| 504 | } | ||
| 437 | }, | 505 | }, |
| 438 | { | 506 | { |
| 439 | path: 'export-selected-excel', | 507 | path: 'export-selected-excel', |
| 440 | component: 'views/excel/select-excel', | 508 | component: 'views/excel/select-excel', |
| 441 | name: 'SelectExcel', | 509 | name: 'SelectExcel', |
| 442 | meta: { title: 'selectExcel' } | 510 | meta: { |
| 511 | title: 'selectExcel' | ||
| 512 | } | ||
| 443 | }, | 513 | }, |
| 444 | { | 514 | { |
| 445 | path: 'export-merge-header', | 515 | path: 'export-merge-header', |
| 446 | component: 'views/excel/merge-header', | 516 | component: 'views/excel/merge-header', |
| 447 | name: 'MergeHeader', | 517 | name: 'MergeHeader', |
| 448 | meta: { title: 'mergeHeader' } | 518 | meta: { |
| 519 | title: 'mergeHeader' | ||
| 520 | } | ||
| 449 | }, | 521 | }, |
| 450 | { | 522 | { |
| 451 | path: 'upload-excel', | 523 | path: 'upload-excel', |
| 452 | component: 'views/excel/upload-excel', | 524 | component: 'views/excel/upload-excel', |
| 453 | name: 'UploadExcel', | 525 | name: 'UploadExcel', |
| 454 | meta: { title: 'uploadExcel' } | 526 | meta: { |
| 527 | title: 'uploadExcel' | ||
| 528 | } | ||
| 455 | } | 529 | } |
| 456 | ] | 530 | ] |
| 457 | }, | 531 | }, |
| 458 | 532 | ||
| 459 | { | 533 | { |
| 460 | path: '/zip', | 534 | path: '/zip', |
| 461 | component: 'layout/Layout', | 535 | component: 'layout/Layout', |
| 462 | redirect: '/zip/download', | 536 | redirect: '/zip/download', |
| 463 | alwaysShow: true, | 537 | alwaysShow: true, |
| 464 | meta: { title: 'zip', icon: 'zip' }, | 538 | meta: { |
| 465 | children: [ | 539 | title: 'zip', |
| 466 | { | 540 | icon: 'zip' |
| 467 | path: 'download', | 541 | }, |
| 468 | component: 'views/zip/index', | 542 | children: [{ |
| 469 | name: 'ExportZip', | 543 | path: 'download', |
| 470 | meta: { title: 'exportZip' } | 544 | component: 'views/zip/index', |
| 545 | name: 'ExportZip', | ||
| 546 | meta: { | ||
| 547 | title: 'exportZip' | ||
| 471 | } | 548 | } |
| 472 | ] | 549 | }] |
| 473 | }, | 550 | }, |
| 474 | 551 | ||
| 475 | { | 552 | { |
| 476 | path: '/pdf', | 553 | path: '/pdf', |
| 477 | component: 'layout/Layout', | 554 | component: 'layout/Layout', |
| 478 | redirect: '/pdf/index', | 555 | redirect: '/pdf/index', |
| 479 | children: [ | 556 | children: [{ |
| 480 | { | 557 | path: 'index', |
| 481 | path: 'index', | 558 | component: 'views/pdf/index', |
| 482 | component: 'views/pdf/index', | 559 | name: 'PDF', |
| 483 | name: 'PDF', | 560 | meta: { |
| 484 | meta: { title: 'pdf', icon: 'pdf' } | 561 | title: 'pdf', |
| 562 | icon: 'pdf' | ||
| 485 | } | 563 | } |
| 486 | ] | 564 | }] |
| 487 | }, | 565 | }, |
| 488 | { | 566 | { |
| 489 | path: '/pdf/download', | 567 | path: '/pdf/download', |
| 490 | component: 'views/pdf/download', | 568 | component: 'views/pdf/download', |
| 491 | hidden: true | 569 | hidden: true |
| 492 | }, | 570 | }, |
| 493 | 571 | ||
| 494 | { | 572 | { |
| 495 | path: '/theme', | 573 | path: '/theme', |
| 496 | component: 'layout/Layout', | 574 | component: 'layout/Layout', |
| 497 | redirect: 'noRedirect', | 575 | redirect: 'noRedirect', |
| 498 | children: [ | 576 | children: [{ |
| 499 | { | 577 | path: 'index', |
| 500 | path: 'index', | 578 | component: 'views/theme/index', |
| 501 | component: 'views/theme/index', | 579 | name: 'Theme', |
| 502 | name: 'Theme', | 580 | meta: { |
| 503 | meta: { title: 'theme', icon: 'theme' } | 581 | title: 'theme', |
| 582 | icon: 'theme' | ||
| 504 | } | 583 | } |
| 505 | ] | 584 | }] |
| 506 | }, | 585 | }, |
| 507 | 586 | ||
| 508 | { | 587 | { |
| 509 | path: '/clipboard', | 588 | path: '/clipboard', |
| 510 | component: 'layout/Layout', | 589 | component: 'layout/Layout', |
| 511 | redirect: 'noRedirect', | 590 | redirect: 'noRedirect', |
| 512 | children: [ | 591 | children: [{ |
| 513 | { | 592 | path: 'index', |
| 514 | path: 'index', | 593 | component: 'views/clipboard/index', |
| 515 | component: 'views/clipboard/index', | 594 | name: 'ClipboardDemo', |
| 516 | name: 'ClipboardDemo', | 595 | meta: { |
| 517 | meta: { title: 'clipboardDemo', icon: 'clipboard' } | 596 | title: 'clipboardDemo', |
| 597 | icon: 'clipboard' | ||
| 518 | } | 598 | } |
| 519 | ] | 599 | }] |
| 520 | }, | 600 | }, |
| 521 | 601 | ||
| 522 | { | 602 | { |
| 523 | path: '/i18n', | 603 | path: '/i18n', |
| 524 | component: 'layout/Layout', | 604 | component: 'layout/Layout', |
| 525 | children: [ | 605 | children: [{ |
| 526 | { | 606 | path: 'index', |
| 527 | path: 'index', | 607 | component: 'views/i18n-demo/index', |
| 528 | component: 'views/i18n-demo/index', | 608 | name: 'I18n', |
| 529 | name: 'I18n', | 609 | meta: { |
| 530 | meta: { title: 'i18n', icon: 'international' } | 610 | title: 'i18n', |
| 611 | icon: 'international' | ||
| 531 | } | 612 | } |
| 532 | ] | 613 | }] |
| 533 | }, | 614 | }, |
| 534 | 615 | ||
| 535 | { | 616 | { |
| 536 | path: 'external-link', | 617 | path: 'external-link', |
| 537 | component: 'layout/Layout', | 618 | component: 'layout/Layout', |
| 538 | children: [ | 619 | children: [{ |
| 539 | { | 620 | path: 'https://github.com/PanJiaChen/vue-element-admin', |
| 540 | path: 'https://github.com/PanJiaChen/vue-element-admin', | 621 | meta: { |
| 541 | meta: { title: 'externalLink', icon: 'link' } | 622 | title: 'externalLink', |
src/api/prod.js
| 1 | import request from '@/utils/request' | 1 | import request from '@/utils/request' |
| 2 | import { | ||
| 3 | Notification | ||
| 4 | } from 'element-ui' | ||
| 5 | 2 | ||
| 6 | // export const getPersonInfo = data => { | 3 | // export const getPersonInfo = data => { |
| 7 | // return service({ | 4 | // return service({ |
| 8 | // url: '/person_pay/getpersoninfo', | 5 | // url: '/person_pay/getpersoninfo', |
| 9 | // method: 'post', | 6 | // method: 'post', |
| 10 | // data | 7 | // data |
| 11 | // }) | 8 | // }) |
| 12 | // } | 9 | // } |
| 13 | 10 | ||
| 14 | export function fetchList(query) { | 11 | export function fetchList(query) { |
| 15 | // console.log('api/prod/list/ ==fetchList=== query', query); | ||
| 16 | const options = { | ||
| 17 | type: 'error', | ||
| 18 | message: query, | ||
| 19 | title: '==query value ===', | ||
| 20 | showClose: true, | ||
| 21 | duration: 4000 | ||
| 22 | } | ||
| 23 | Notification(options) | ||
| 24 | return request({ | 12 | return request({ |
| 25 | url: '/yp/prod/list', | 13 | url: '/yp/prod/list', |
| 26 | method: 'post', | 14 | method: 'post', |
| 27 | params: query | 15 | params: query |
| 28 | }) | 16 | }) |
| 29 | } | 17 | } |
| 18 | |||
| 19 | export function fetchArticle(id) { | ||
| 20 | return request({ | ||
| 21 | url: '/yp/prod/detail', | ||
| 22 | method: 'get', | ||
| 23 | params: { | ||
| 24 | id | ||
| 25 | } | ||
| 26 | }) | ||
| 27 | } | ||
| 28 | |||
| 29 | export function fetchPv(pv) { | ||
| 30 | return request({ | ||
| 31 | url: '/yp/prod/pv', | ||
| 32 | method: 'get', | ||
| 33 | params: { | ||
| 34 | pv | ||
| 35 | } | ||
| 36 | }) | ||
| 37 | } | ||
| 38 | |||
| 39 | export function createArticle(data) { | ||
| 40 | return request({ | ||
| 41 | url: '/yp/prod/create', | ||
| 42 | method: 'post', |
src/store/modules/tagsView.js
| 1 | const state = { | 1 | const state = { |
| 2 | visitedViews: [], | 2 | visitedViews: [], |
| 3 | cachedViews: [] | 3 | cachedViews: [] |
| 4 | } | 4 | } |
| 5 | 5 | ||
| 6 | const mutations = { | 6 | const mutations = { |
| 7 | ADD_VISITED_VIEW: (state, view) => { | 7 | ADD_VISITED_VIEW: (state, view) => { |
| 8 | if (state.visitedViews.some(v => v.path === view.path)) return | 8 | if (state.visitedViews.some(v => v.path === view.path)) return |
| 9 | state.visitedViews.push( | 9 | state.visitedViews.push( |
| 10 | Object.assign({}, view, { | 10 | Object.assign({}, view, { |
| 11 | title: view.meta.title || 'no-name' | 11 | title: view.meta.title || 'no-name' |
| 12 | }) | 12 | }) |
| 13 | ) | 13 | ) |
| 14 | }, | 14 | }, |
| 15 | ADD_CACHED_VIEW: (state, view) => { | 15 | ADD_CACHED_VIEW: (state, view) => { |
| 16 | if (state.cachedViews.includes(view.name)) return | 16 | if (state.cachedViews.includes(view.name)) return |
| 17 | if (!view.meta.noCache) { | 17 | if (!view.meta.noCache) { |
| 18 | state.cachedViews.push(view.name) | 18 | state.cachedViews.push(view.name) |
| 19 | } | 19 | } |
| 20 | }, | 20 | }, |
| 21 | 21 | ||
| 22 | DEL_VISITED_VIEW: (state, view) => { | 22 | DEL_VISITED_VIEW: (state, view) => { |
| 23 | for (const [i, v] of state.visitedViews.entries()) { | 23 | for (const [i, v] of state.visitedViews.entries()) { |
| 24 | if (v.path === view.path) { | 24 | if (v.path === view.path) { |
| 25 | state.visitedViews.splice(i, 1) | 25 | state.visitedViews.splice(i, 1) |
| 26 | break | 26 | break |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | }, | 29 | }, |
| 30 | DEL_CACHED_VIEW: (state, view) => { | 30 | DEL_CACHED_VIEW: (state, view) => { |
| 31 | const index = state.cachedViews.indexOf(view.name) | 31 | const index = state.cachedViews.indexOf(view.name) |
| 32 | index > -1 && state.cachedViews.splice(index, 1) | 32 | index > -1 && state.cachedViews.splice(index, 1) |
| 33 | }, | 33 | }, |
| 34 | 34 | ||
| 35 | DEL_OTHERS_VISITED_VIEWS: (state, view) => { | 35 | DEL_OTHERS_VISITED_VIEWS: (state, view) => { |
| 36 | state.visitedViews = state.visitedViews.filter(v => { | 36 | state.visitedViews = state.visitedViews.filter(v => { |
| 37 | return v.meta.affix || v.path === view.path | 37 | return v.meta.affix || v.path === view.path |
| 38 | }) | 38 | }) |
| 39 | }, | 39 | }, |
| 40 | DEL_OTHERS_CACHED_VIEWS: (state, view) => { | 40 | DEL_OTHERS_CACHED_VIEWS: (state, view) => { |
| 41 | const index = state.cachedViews.indexOf(view.name) | 41 | const index = state.cachedViews.indexOf(view.name) |
| 42 | if (index > -1) { | 42 | if (index > -1) { |
| 43 | state.cachedViews = state.cachedViews.slice(index, index + 1) | 43 | state.cachedViews = state.cachedViews.slice(index, index + 1) |
| 44 | } else { | 44 | } else { |
| 45 | // if index = -1, there is no cached tags | 45 | // if index = -1, there is no cached tags |
| 46 | state.cachedViews = [] | 46 | state.cachedViews = [] |
| 47 | } | 47 | } |
| 48 | }, | 48 | }, |
| 49 | 49 | ||
| 50 | DEL_ALL_VISITED_VIEWS: state => { | 50 | DEL_ALL_VISITED_VIEWS: state => { |
| 51 | // keep affix tags | 51 | // keep affix tags |
| 52 | const affixTags = state.visitedViews.filter(tag => tag.meta.affix) | 52 | const affixTags = state.visitedViews.filter(tag => tag.meta.affix) |
| 53 | state.visitedViews = affixTags | 53 | state.visitedViews = affixTags |
| 54 | }, | 54 | }, |
| 55 | DEL_ALL_CACHED_VIEWS: state => { | 55 | DEL_ALL_CACHED_VIEWS: state => { |
| 56 | state.cachedViews = [] | 56 | state.cachedViews = [] |
| 57 | }, | 57 | }, |
| 58 | 58 | ||
| 59 | UPDATE_VISITED_VIEW: (state, view) => { | 59 | UPDATE_VISITED_VIEW: (state, view) => { |
| 60 | for (let v of state.visitedViews) { | 60 | for (let v of state.visitedViews) { |
| 61 | if (v.path === view.path) { | 61 | if (v.path === view.path) { |
| 62 | v = Object.assign(v, view) | 62 | v = Object.assign(v, view) |
| 63 | break | 63 | break |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | const actions = { | 69 | const actions = { |
| 70 | addView({ dispatch }, view) { | 70 | addView({ |
| 71 | dispatch | ||
| 72 | }, view) { | ||
| 71 | dispatch('addVisitedView', view) | 73 | dispatch('addVisitedView', view) |
| 72 | dispatch('addCachedView', view) | 74 | dispatch('addCachedView', view) |
| 73 | }, | 75 | }, |
| 74 | addVisitedView({ commit }, view) { | 76 | addVisitedView({ |
| 77 | commit | ||
| 78 | }, view) { | ||
| 75 | commit('ADD_VISITED_VIEW', view) | 79 | commit('ADD_VISITED_VIEW', view) |
| 76 | }, | 80 | }, |
| 77 | addCachedView({ commit }, view) { | 81 | addCachedView({ |
| 82 | commit | ||
| 83 | }, view) { | ||
| 78 | commit('ADD_CACHED_VIEW', view) | 84 | commit('ADD_CACHED_VIEW', view) |
| 79 | }, | 85 | }, |
| 80 | 86 | ||
| 81 | delView({ dispatch, state }, view) { | 87 | delView({ |
| 88 | dispatch, | ||
| 89 | state | ||
| 90 | }, view) { | ||
| 82 | return new Promise(resolve => { | 91 | return new Promise(resolve => { |
| 83 | dispatch('delVisitedView', view) | 92 | dispatch('delVisitedView', view) |
| 84 | dispatch('delCachedView', view) | 93 | dispatch('delCachedView', view) |
| 85 | resolve({ | 94 | resolve({ |
| 86 | visitedViews: [...state.visitedViews], | 95 | visitedViews: [...state.visitedViews], |
| 87 | cachedViews: [...state.cachedViews] | 96 | cachedViews: [...state.cachedViews] |
| 88 | }) | 97 | }) |
| 89 | }) | 98 | }) |
| 90 | }, | 99 | }, |
| 91 | delVisitedView({ commit, state }, view) { | 100 | delVisitedView({ |
| 101 | commit, | ||
| 102 | state | ||
| 103 | }, view) { | ||
| 92 | return new Promise(resolve => { | 104 | return new Promise(resolve => { |
| 93 | commit('DEL_VISITED_VIEW', view) | 105 | commit('DEL_VISITED_VIEW', view) |
| 94 | resolve([...state.visitedViews]) | 106 | resolve([...state.visitedViews]) |
| 95 | }) | 107 | }) |
| 96 | }, | 108 | }, |
| 97 | delCachedView({ commit, state }, view) { | 109 | delCachedView({ |
| 110 | commit, | ||
| 111 | state | ||
| 112 | }, view) { | ||
| 98 | return new Promise(resolve => { | 113 | return new Promise(resolve => { |
| 99 | commit('DEL_CACHED_VIEW', view) | 114 | commit('DEL_CACHED_VIEW', view) |
| 100 | resolve([...state.cachedViews]) | 115 | resolve([...state.cachedViews]) |
| 101 | }) | 116 | }) |
| 102 | }, | 117 | }, |
| 103 | 118 | ||
| 104 | delOthersViews({ dispatch, state }, view) { | 119 | delOthersViews({ |
| 120 | dispatch, | ||
| 121 | state | ||
| 122 | }, view) { | ||
| 105 | return new Promise(resolve => { | 123 | return new Promise(resolve => { |
| 106 | dispatch('delOthersVisitedViews', view) | 124 | dispatch('delOthersVisitedViews', view) |
| 107 | dispatch('delOthersCachedViews', view) | 125 | dispatch('delOthersCachedViews', view) |
| 108 | resolve({ | 126 | resolve({ |
| 109 | visitedViews: [...state.visitedViews], | 127 | visitedViews: [...state.visitedViews], |
| 110 | cachedViews: [...state.cachedViews] | 128 | cachedViews: [...state.cachedViews] |
| 111 | }) | 129 | }) |
| 112 | }) | 130 | }) |
| 113 | }, | 131 | }, |
| 114 | delOthersVisitedViews({ commit, state }, view) { | 132 | delOthersVisitedViews({ |
| 133 | commit, | ||
| 134 | state | ||
| 135 | }, view) { | ||
| 115 | return new Promise(resolve => { | 136 | return new Promise(resolve => { |
| 116 | commit('DEL_OTHERS_VISITED_VIEWS', view) | 137 | commit('DEL_OTHERS_VISITED_VIEWS', view) |
| 117 | resolve([...state.visitedViews]) | 138 | resolve([...state.visitedViews]) |
| 118 | }) | 139 | }) |
| 119 | }, | 140 | }, |
| 120 | delOthersCachedViews({ commit, state }, view) { | 141 | delOthersCachedViews({ |
| 142 | commit, | ||
| 143 | state | ||
| 144 | }, view) { | ||
| 121 | return new Promise(resolve => { | 145 | return new Promise(resolve => { |
| 122 | commit('DEL_OTHERS_CACHED_VIEWS', view) | 146 | commit('DEL_OTHERS_CACHED_VIEWS', view) |
| 123 | resolve([...state.cachedViews]) | 147 | resolve([...state.cachedViews]) |
| 124 | }) | 148 | }) |
| 125 | }, | 149 | }, |
| 126 | 150 | ||
| 127 | delAllViews({ dispatch, state }, view) { | 151 | delAllViews({ |
| 152 | dispatch, | ||
| 153 | state | ||
| 154 | }, view) { | ||
| 128 | return new Promise(resolve => { | 155 | return new Promise(resolve => { |
| 129 | dispatch('delAllVisitedViews', view) | 156 | dispatch('delAllVisitedViews', view) |
| 130 | dispatch('delAllCachedViews', view) | 157 | dispatch('delAllCachedViews', view) |
| 131 | resolve({ | 158 | resolve({ |
| 132 | visitedViews: [...state.visitedViews], | 159 | visitedViews: [...state.visitedViews], |
| 133 | cachedViews: [...state.cachedViews] | 160 | cachedViews: [...state.cachedViews] |
| 134 | }) | 161 | }) |
| 135 | }) | 162 | }) |
| 136 | }, | 163 | }, |
| 137 | delAllVisitedViews({ commit, state }) { | 164 | delAllVisitedViews({ |
| 165 | commit, | ||
| 166 | state | ||
| 167 | }) { | ||
| 138 | return new Promise(resolve => { | 168 | return new Promise(resolve => { |
| 139 | commit('DEL_ALL_VISITED_VIEWS') | 169 | commit('DEL_ALL_VISITED_VIEWS') |
| 140 | resolve([...state.visitedViews]) | 170 | resolve([...state.visitedViews]) |
| 141 | }) | 171 | }) |
| 142 | }, | 172 | }, |
| 143 | delAllCachedViews({ commit, state }) { | 173 | delAllCachedViews({ |
| 174 | commit, | ||
| 175 | state | ||
| 176 | }) { | ||
| 144 | return new Promise(resolve => { | 177 | return new Promise(resolve => { |
| 145 | commit('DEL_ALL_CACHED_VIEWS') | 178 | commit('DEL_ALL_CACHED_VIEWS') |
| 146 | resolve([...state.cachedViews]) | 179 | resolve([...state.cachedViews]) |
| 147 | }) | 180 | }) |
| 148 | }, | 181 | }, |
| 149 | 182 | ||
| 150 | updateVisitedView({ commit }, view) { | 183 | updateVisitedView({ |
| 184 | commit | ||
| 185 | }, view) { | ||
| 151 | commit('UPDATE_VISITED_VIEW', view) | 186 | commit('UPDATE_VISITED_VIEW', view) |
| 152 | } | 187 | } |
| 153 | } | 188 | } |
| 154 | 189 | ||
| 155 | export default { | 190 | export default { |
| 156 | namespaced: true, | 191 | namespaced: true, |
| 157 | state, | 192 | state, |
| 158 | mutations, | 193 | mutations, |
| 159 | actions | 194 | actions |
| 160 | } | 195 | } |
| 161 | 196 |
src/views/prod/list.vue
| 1 | <template> | 1 | <template> |
| 2 | <div class="app-container"> | 2 | <div class="app-container"> |
| 3 | <!-- Note that row-key is necessary to get a correct row order. --> | ||
| 4 | <el-table | 3 | <el-table |
| 5 | ref="dragTable" | ||
| 6 | v-loading="listLoading" | 4 | v-loading="listLoading" |
| 7 | :data="list" | 5 | :data="list" |
| 8 | row-key="id" | ||
| 9 | border | 6 | border |
| 10 | fit | 7 | fit |
| 11 | highlight-current-row | 8 | highlight-current-row |
| 12 | style="width: 100%" | 9 | style="width: 100%" |
| 13 | > | 10 | > |
| 14 | <el-table-column | 11 | <el-table-column |
| 15 | align="center" | 12 | align="center" |
| 16 | label="PID" | 13 | label="ID" |
| 17 | width="65" | 14 | width="80" |
| 18 | > | 15 | > |
| 19 | <template slot-scope="{row}"> | 16 | <template slot-scope="scope"> |
| 20 | <span>{{ row.id }}</span> | 17 | <span>{{ scope.row.id }}</span> |
| 21 | </template> | 18 | </template> |
| 22 | </el-table-column> | 19 | </el-table-column> |
| 23 | 20 | ||
| 24 | <el-table-column | 21 | <el-table-column |
| 25 | width="180px" | 22 | width="180px" |
| 26 | align="center" | 23 | align="center" |
| 27 | label="Date2" | 24 | label="Date" |
| 28 | > | 25 | > |
| 29 | <template slot-scope="{row}"> | 26 | <template slot-scope="scope"> |
| 30 | <span>{{ row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> | 27 | <span>{{ scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> |
| 31 | </template> | 28 | </template> |
| 32 | </el-table-column> | 29 | </el-table-column> |
| 33 | 30 | ||
| 34 | <el-table-column | 31 | <el-table-column |
| 35 | min-width="300px" | 32 | width="120px" |
| 36 | label="Title" | ||
| 37 | > | ||
| 38 | <template slot-scope="{row}"> | ||
| 39 | <span>{{ row.title }}</span> | ||
| 40 | </template> | ||
| 41 | </el-table-column> | ||
| 42 | |||
| 43 | <el-table-column | ||
| 44 | width="110px" | ||
| 45 | align="center" | 33 | align="center" |
| 46 | label="Author" | 34 | label="Author" |
| 47 | > | 35 | > |
| 48 | <template slot-scope="{row}"> | 36 | <template slot-scope="scope"> |
| 49 | <span>{{ row.author }}</span> | 37 | <span>{{ scope.row.author }}</span> |
| 50 | </template> | 38 | </template> |
| 51 | </el-table-column> | 39 | </el-table-column> |
| 52 | 40 | ||
| 53 | <el-table-column | 41 | <el-table-column |
| 54 | width="100px" | 42 | width="100px" |
| 55 | label="Importance" | 43 | label="Importance" |
| 56 | > | 44 | > |
| 57 | <template slot-scope="{row}"> | 45 | <template slot-scope="scope"> |
| 58 | <svg-icon | 46 | <svg-icon |
| 59 | v-for="n in + row.importance" | 47 | v-for="n in +scope.row.importance" |
| 60 | :key="n" | 48 | :key="n" |
| 61 | icon-class="star" | 49 | icon-class="star" |
| 62 | class="icon-star" | 50 | class="meta-item__icon" |
| 63 | /> | 51 | /> |
| 64 | </template> | 52 | </template> |
| 65 | </el-table-column> | 53 | </el-table-column> |
| 66 | 54 | ||
| 67 | <el-table-column | 55 | <el-table-column |
| 68 | align="center" | ||
| 69 | label="Readings" | ||
| 70 | width="95" | ||
| 71 | > | ||
| 72 | <template slot-scope="{row}"> | ||
| 73 | <span>{{ row.pageviews }}</span> | ||
| 74 | </template> | ||
| 75 | </el-table-column> | ||
| 76 | |||
| 77 | <el-table-column | ||
| 78 | class-name="status-col" | 56 | class-name="status-col" |
| 79 | label="Status" | 57 | label="Status" |
| 80 | width="110" | 58 | width="110" |
| 81 | > | 59 | > |
| 82 | <template slot-scope="{row}"> | 60 | <template slot-scope="{row}"> |
| 83 | <el-tag :type="row.status | statusFilter"> | 61 | <el-tag :type="row.status | statusFilter"> |
| 84 | {{ row.status }} | 62 | {{ row.status }} |
| 85 | </el-tag> | 63 | </el-tag> |
| 86 | </template> | 64 | </template> |
| 87 | </el-table-column> | 65 | </el-table-column> |
| 88 | 66 | ||
| 89 | <el-table-column | 67 | <el-table-column |
| 68 | min-width="300px" | ||
| 69 | label="Title" | ||
| 70 | > | ||
| 71 | <template slot-scope="{row}"> | ||
| 72 | <router-link | ||
| 73 | :to="'/example/edit/'+row.id" | ||
| 74 | class="link-type" | ||
| 75 | > | ||
| 76 | <span>{{ row.title }}</span> | ||
| 77 | </router-link> | ||
| 78 | </template> | ||
| 79 | </el-table-column> | ||
| 80 | |||
| 81 | <el-table-column | ||
| 90 | align="center" | 82 | align="center" |
| 91 | label="Drag" | 83 | label="Actions" |
| 92 | width="80" | 84 | width="120" |
| 93 | > | 85 | > |
| 94 | <template slot-scope="{}"> | 86 | <template slot-scope="scope"> |
| 95 | <svg-icon | 87 | <router-link :to="'/example/edit/'+scope.row.id"> |
| 96 | class="drag-handler" | 88 | <el-button |
| 97 | icon-class="drag" | 89 | type="primary" |
| 98 | /> | 90 | size="small" |
| 91 | icon="el-icon-edit" | ||
| 92 | > | ||
| 93 | Edit | ||
| 94 | </el-button> | ||
| 95 | </router-link> | ||
| 99 | </template> | 96 | </template> |
| 100 | </el-table-column> | 97 | </el-table-column> |
| 101 | </el-table> | 98 | </el-table> |
| 102 | <!-- $t is vue-i18n global function to translate lang (lang in @/lang) --> | 99 | |
| 103 | <div class="show-d"> | 100 | <pagination |
| 104 | <el-tag style="margin-right:12px;">{{ $t('table.dragTips1') }} :</el-tag> {{ oldList }} | 101 | v-show="total>0" |
| 105 | </div> | 102 | :total="total" |
| 106 | <div class="show-d"> | 103 | :page.sync="listQuery.page" |
| 107 | <el-tag>{{ $t('table.dragTips2') }} :</el-tag> {{ newList }} | 104 | :limit.sync="listQuery.limit" |
| 108 | </div> | 105 | @pagination="getList" |
| 106 | /> | ||
| 109 | </div> | 107 | </div> |
| 110 | </template> | 108 | </template> |
| 111 | 109 | ||
| 112 | <script> | 110 | <script> |
| 113 | import { | 111 | import { fetchList } from '@/api/article' |
| 114 | fetchList | 112 | import Pagination from '@/components/Pagination' // Secondary package based on el-pagination |
| 115 | // fetchPv | ||
| 116 | // createUser, | ||
| 117 | // updateUser, | ||
| 118 | // delUser | ||
| 119 | } from '@/api/prod' | ||
| 120 | import Sortable from 'sortablejs' | ||
| 121 | // import waves from '@/directive/waves' // waves directive | ||
| 122 | // import { parseTime } from "@/utils"; | ||
| 123 | // import Pagination from "@/components/Pagination"; // secondary package based on el-pagination | ||
| 124 | 113 | ||
| 125 | export default { | 114 | export default { |
| 126 | name: 'DragTable', | 115 | name: 'ArticleList', |
| 116 | components: { Pagination }, | ||
| 127 | filters: { | 117 | filters: { |
| 128 | statusFilter(status) { | 118 | statusFilter(status) { |
| 129 | const statusMap = { | 119 | const statusMap = { |
| 130 | published: 'success', | 120 | published: 'success', |
| 131 | draft: 'info', | 121 | draft: 'info', |
| 132 | deleted: 'danger' | 122 | deleted: 'danger' |
| 133 | } | 123 | } |
| 134 | return statusMap[status] | 124 | return statusMap[status] |
| 135 | } | 125 | } |
| 136 | }, | 126 | }, |
| 137 | data() { | 127 | data() { |
| 138 | return { | 128 | return { |
| 139 | list: null, | 129 | list: null, |
| 140 | total: null, | 130 | total: 0, |
| 141 | listLoading: true, | 131 | listLoading: true, |
| 142 | listQuery: { | 132 | listQuery: { |
| 143 | page: 1, | 133 | page: 1, |
| 144 | limit: 10 | 134 | limit: 20 |
| 145 | }, | 135 | } |
| 146 | sortable: null, | ||
| 147 | oldList: [], | ||
| 148 | newList: [] | ||
| 149 | } | 136 | } |
| 150 | }, | 137 | }, |
| 151 | created() { | 138 | created() { |
| 152 | this.getList() | 139 | this.getList() |
| 153 | }, | 140 | }, |
| 154 | methods: { | 141 | methods: { |
| 155 | async getList() { | 142 | getList() { |
| 156 | console.log('test======>', 'prod ..... -----getList') | ||
| 157 | this.listLoading = true | 143 | this.listLoading = true |
| 158 | const { data } = await fetchList(this.listQuery) | 144 | fetchList(this.listQuery).then(response => { |
| 159 | console.log('data===========getList=======', data) | 145 | this.list = response.data.items |
| 160 | this.list = data.items | 146 | this.total = response.data.total |
| 161 | this.total = data.total | 147 | this.listLoading = false |
| 162 | // this.listLoading = false; | ||
| 163 | // this.oldList = this.list.map(v => v.id); | ||
| 164 | // this.newList = this.oldList.slice(); | ||
| 165 | // this.$nextTick(() => { | ||
| 166 | // this.setSort(); | ||
| 167 | // }); | ||
| 168 | }, | ||
| 169 | setSort() { | ||
| 170 | const el = this.$refs.dragTable.$el.querySelectorAll( | ||
| 171 | '.el-table__body-wrapper > table > tbody' | ||
| 172 | )[0] | ||
| 173 | this.sortable = Sortable.create(el, { | ||
| 174 | ghostClass: 'sortable-ghost', // Class name for the drop placeholder, | ||
| 175 | setData: function(dataTransfer) { | ||
| 176 | // to avoid Firefox bug | ||
| 177 | // Detail see : https://github.com/RubaXa/Sortable/issues/1012 | ||
| 178 | dataTransfer.setData('Text', '') | ||
| 179 | }, | ||
| 180 | onEnd: evt => { | ||
| 181 | const targetRow = this.list.splice(evt.oldIndex, 1)[0] | ||
| 182 | this.list.splice(evt.newIndex, 0, targetRow) | ||
| 183 | |||
| 184 | // for show the changes, you can delete in you code | ||
| 185 | const tempIndex = this.newList.splice(evt.oldIndex, 1)[0] | ||
| 186 | this.newList.splice(evt.newIndex, 0, tempIndex) | ||
| 187 | } | ||
| 188 | }) | 148 | }) |
| 189 | } | 149 | } |
| 190 | } | 150 | } |
| 191 | } | 151 | } |
| 192 | </script> | 152 | </script> |
| 193 | 153 | ||
| 194 | <style> |