Browse Source

权限验证登录

lipengtao 6 years ago
parent
commit
fc7e002a70

+ 1 - 2
src/api/login.js

6
    method: 'post',
6
    method: 'post',
7
    data: {
7
    data: {
8
      account,
8
      account,
9
      pw,
9
      pw
10
      vc
11
    }
10
    }
12
  })
11
  })
13
}
12
}

+ 3 - 0
src/api/loginnew.js

1
export const loginUrl = '/ajax/sys/login'
2
export const getInfoUrl = '/ajax/sys/manager'
3
export const logoutUrl = '/ajax/sys/logout'

+ 2 - 0
src/api/modifyAccountInformation.js

1
export const url = '/ajax/sys/manager'
2
export const modifyUrl = '/ajax/sys/manager'

+ 1 - 0
src/api/modifyPassword.js

1
export default '/ajax/sys/manager/changepasswd' //  重置密码

src/views/contentPub/editorUE.vue → src/components/editorUE/index.vue


src/views/contentPub/searchTemplate.vue → src/components/searchBar/index.vue


src/views/contentPub/uploadFile.vue → src/components/uploadFile/index.vue


+ 47 - 54
src/permission.js

1
// import router from './router'
1
import router from './router'
2
// import store from './store'
2
import store from './store'
3
// import NProgress from 'nprogress' // Progress 进度条
3
import NProgress from 'nprogress' // Progress 进度条
4
// import 'nprogress/nprogress.css'// Progress 进度条样式
4
import 'nprogress/nprogress.css'// Progress 进度条样式
5
// import { Message } from 'element-ui'
5
import { Message } from 'element-ui'
6
// import { getCookiesName } from '@/utils/auth' // 验权
6
import Cookies from 'js-cookie'
7
// import queryInfo from '@/utils/queryInfo'
7
//  import queryInfo from '@/utils/queryInfo'
8
8
9
// NProgress.configure({ showSpinner: false })// NProgress Configuration
9
NProgress.configure({ showSpinner: false })// NProgress Configuration
10
10
11
// function hasPermission(roles, permissionRoles) {
11
const whiteList = ['/login', '/findPwd'] // 不重定向白名单
12
//   if (roles.indexOf('1') >= 0) return true
13
//   if (!permissionRoles) return true
14
//   return roles.some(role => permissionRoles.indexOf(role) >= 0)
15
// }
16
12
17
// const whiteList = ['/login', '/findPwd'] // 不重定向白名单
13
router.beforeEach((to, from, next) => {
14
  NProgress.start()
15
  if (Cookies.get('userid')) {
16
    if (to.path === '/login') {
17
      next({ path: '/' })
18
      NProgress.done()
19
    } else {
20
      if (!store.getters.account) { // 判断当前用户是否已拉取完user_info信息
21
        store.dispatch('GetUserInfo').then(res => { // 拉取user_info
22
          if (res.success && res.data) {
23
            store.dispatch('GenerateRoutes', res.data.rightCode).then(() => { // 根据roles权限生成可访问的路由表
24
              router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
25
              next({ ...to, replace: true })
26
            })
27
          }
28
        }).catch((err) => {
29
          store.dispatch('LogOut').then(() => {
30
            Message.error(err || '登录状态失效,请重新登录')
31
            next({ path: '/' })
32
          })
33
        })
34
      } else {
35
        next()
36
      }
37
      //  queryInfo.queryAllInfo()
38
    }
39
  } else {
40
    if (whiteList.indexOf(to.path) !== -1) {
41
      next()
42
    } else {
43
      next('/login')
44
      NProgress.done()
45
    }
46
  }
47
})
18
48
19
// router.beforeEach((to, from, next) => {
49
router.afterEach(() => {
20
//   NProgress.start()
50
  NProgress.done() // 结束Progress
21
//   if (getCookiesName()) {
51
})
22
//     if (to.path === '/login') {
23
//       next({ path: '/' })
24
//       NProgress.done()
25
//     } else {
26
//       if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
27
//         store.dispatch('GetUserInfo').then(res => { // 拉取user_info
28
//           const roles = [res.data.type.toString()]
29
//           store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
30
//             router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
31
//             next({ ...to, replace: true })
32
//           })
33
//         }).catch((err) => {
34
//           store.dispatch('FedLogOut').then(() => {
35
//             Message.error(err || '登录状态失效,请重新登录')
36
//             next({ path: '/' })
37
//           })
38
//         })
39
//       } else {
40
//         if (hasPermission(store.getters.roles, to.meta.roles)) {
41
//           next()
42
//         }
43
//       }
44
//       queryInfo.queryAllInfo()
45
//     }
46
//   } else {
47
//     if (whiteList.indexOf(to.path) !== -1) {
48
//       next()
49
//     } else {
50
//       next('/login')
51
//       NProgress.done()
52
//     }
53
//   }
54
// })
55
56
// router.afterEach(() => {
57
//   NProgress.done() // 结束Progress
58
// })

+ 256 - 256
src/router/index.js

39
      name: 'dashboard',
39
      name: 'dashboard',
40
      meta: { title: '主页' }
40
      meta: { title: '主页' }
41
    }]
41
    }]
42
  },
42
  }
43
  {
43
]
44
    path: '',
45
export const asynsingle = [
45
    component: Layout,
46
    name: 'contentModule',
47
    redirect: 'noredirect',
48
    meta: { title: '内容发布' },
49
    children: [
50
      {
51
        path: 'content',
52
        component: () => import('@/views/contentPub/index'),
53
        name: 'content',
54
        redirect: '/content/pubList',
55
        meta: { title: '内容发布列表' },
56
        children: [
57
          {
58
            path: 'pubList',
59
            component: () => import('@/views/contentPub/pubList'),
60
            name: 'pubList',
61
            meta: { title: '内容发布列表' }
62
          },
63
          {
64
            path: 'publish',
65
            hidden: true,
66
            component: () => import('@/views/contentPub/publish'),
67
            name: 'publish',
68
            meta: { title: ' 新内容发布' }
69
          }
70
        ]
71
      },
72
      {
73
        path: 'recycle',
74
        component: () => import('@/views/contentPub/index'),
75
        name: 'recycle',
76
        redirect: '/recycle/recycleBinList',
77
        meta: { title: '内容回收站列表' },
78
        children: [
79
          {
80
            path: 'recycleBinList',
81
            component: () => import('@/views/contentPub/recycleBin'),
82
            name: 'recycleBinList',
83
            meta: { title: '内容回收站列表' }
84
          },
85
          {
86
            path: 'viewRecycling',
87
            hidden: true,
88
            component: () => import('@/views/contentPub/viewRecyclingBins'),
89
            name: 'viewRecycling',
90
            meta: { title: ' 查看回收内容' }
91
          }
92
        ]
93
      },
94
      {
95
        path: 'draftList',
96
        component: () => import('@/views/contentPub/draftList'),
97
        name: 'draftList',
98
        meta: { title: '内容草稿箱列表' }
99
      }
100
    ]
101
  },
102
  {
103
    path: '',
104
    component: Layout,
105
    name: 'demand',
106
    redirect: 'noredirect',
107
    meta: { title: '需求中心' },
108
    children: [
109
      {
110
        path: 'publishedList',
111
        component: () => import('@/views/demandCen/publishedList'),
112
        name: 'publishedList',
113
        meta: { title: '发布中需求' }
114
      },
115
      {
116
        path: 'expiredList',
117
        component: () => import('@/views/demandCen/expiredList'),
118
        name: 'expiredList',
119
        meta: { title: '已过期需求' }
120
      },
121
      {
122
        path: 'completedList',
123
        component: () => import('@/views/demandCen/completedList'),
124
        name: 'completedList',
125
        meta: { title: '已完成需求' }
126
      },
127
      {
128
        path: 'closedList',
129
        component: () => import('@/views/demandCen/closedList'),
130
        name: 'closedList',
131
        meta: { title: '已关闭需求' }
132
      }
133
    ]
134
  },
135
  {
136
    path: '',
137
    component: Layout,
138
    name: 'specialExperts',
139
    redirect: 'noredirect',
140
    alwaysShow: true,
141
    meta: { title: '特约专家' },
142
    children: [
143
      {
144
        path: 'expertslist',
145
        component: () => import('@/views/specialExperts/index'),
146
        name: 'publishedList',
147
        meta: { title: '特约专家列表' }
148
      }
149
    ]
150
  },
151
  {
152
    path: '',
153
    component: Layout,
154
    name: 'cooperationAgency',
155
    redirect: 'noredirect',
156
    alwaysShow: true,
157
    meta: { title: '合作机构' },
158
    children: [
159
      {
160
        path: 'agencylist',
161
        component: () => import('@/views/cooperationAgency/index'),
162
        name: 'publishedList',
163
        meta: { title: '合作机构管理列表' }
164
      }
165
    ]
166
  },
167
  {
168
    path: '',
169
    component: Layout,
170
    name: 'company',
171
    redirect: 'noredirect',
172
    meta: { title: '企业中心' },
173
    children: [
174
      {
175
        path: 'noactive',
176
        component: () => import('@/views/companyCen/noactive/index'),
177
        name: 'noactive',
178
        parentPath: true,
179
        redirect: { name: 'noactiveList' },
180
        meta: { title: '未激活企业' },
181
        children: [
182
          {
183
            path: 'noactiveList',
184
            name: 'noactiveList',
185
            hidden: true,
186
            component: () => import('@/views/companyCen/noactive/noactiveList')
187
          },
188
          {
189
            path: 'compHome',
190
            component: () => import('@/views/companyCen/noactive/compHome'),
191
            name: 'compHome',
192
            parentPath: true,
193
            redirect: { name: 'compInfo' },
194
            meta: { title: '企业信息' },
195
            children: [
196
              {
197
                path: 'compInfo',
198
                name: 'compInfo',
199
                hidden: true,
200
                component: () => import('@/views/companyCen/noactive/compInfo')
201
              },
202
              {
203
                path: 'productHome',
204
                component: () => import('@/views/companyCen/noactive/productHome'),
205
                name: 'productHome',
206
                parentPath: true,
207
                redirect: { name: 'compProduct' },
208
                children: [
209
                  {
210
                    path: 'compProduct',
211
                    component: () => import('@/views/companyCen/noactive/compProduct'),
212
                    name: 'compProduct',
213
                    meta: { title: '企业产品' }
214
                  },
215
                  {
216
                    path: 'productInfo',
217
                    component: () => import('@/views/companyCen/noactive/productInfo'),
218
                    name: 'productInfo',
219
                    hidden: true,
220
                    meta: { title: '产品详情' }
221
                  }
222
                ]
223
              }
224
            ]
225
          }
226
        ]
227
      },
228
      {
229
        path: 'activeList',
230
        component: () => import('@/views/companyCen/activeList'),
231
        name: 'activeList',
232
        meta: { title: '已激活企业' }
233
      }
234
    ]
235
  },
236
  {
237
    path: '',
238
    component: Layout,
239
    name: 'platinfo',
240
    redirect: 'noredirect',
241
    alwaysShow: true,
242
    meta: { title: '平台信息' },
243
    children: [
244
      {
245
        path: 'platUpdate',
246
        component: () => import('@/views/platInfo/platUpdate'),
247
        name: 'platUpdate',
248
        meta: { title: '修改平台信息' }
249
      }
250
    ]
251
  },
252
  {
253
    path: '',
254
    component: Layout,
255
    name: 'userinfo',
256
    redirect: 'noredirect',
257
    alwaysShow: true,
258
    meta: { title: '用户信息' },
259
    children: [
260
      {
261
        path: 'usingList',
262
        component: () => import('@/views/userInfo/usingList'),
263
        name: 'usingList',
264
        meta: { title: '正常用户' }
265
      },
266
      {
267
        path: 'blackList',
268
        component: () => import('@/views/userInfo/blackList'),
269
        name: 'blackList',
270
        meta: { title: '黑名单用户' }
271
      }
272
    ]
273
  },
274
  {
275
    path: '',
276
    component: Layout,
277
    name: 'sysSetting',
278
    redirect: 'noredirect',
279
    alwaysShow: true,
280
    meta: { title: '系统设置' },
281
    children: [
282
      {
283
        path: 'adminUser',
284
        component: () => import('@/views/sysSetting/adminUser'),
285
        name: 'adminUser',
286
        meta: { title: '平台后台用户管理列表' }
287
      }
288
    ]
289
  },
290
  {
46
  {
291
    path: '',
47
    path: '',
292
    component: Layout,
48
    component: Layout,
293
    name: 'accountSettings',
294
    redirect: 'noredirect',
49
    redirect: 'noredirect',
295
    meta: { title: '账户设置' },
50
    meta: { title: '账户设置' },
296
    children: [
51
    children: [
297
      {
52
      {
298
        path: 'modifyInformation',
53
        path: 'modifyInformation',
299
        component: () => import('@/views/accountSettings/modifyAccountInformation'),
54
        component: () => import('@/views/accountSettings/modifyAccountInformation'),
300
        name: 'modifyInformation',
301
        meta: { title: '修改账户资料' }
55
        meta: { title: '修改账户资料' }
302
      },
56
      },
303
      {
57
      {
304
        path: 'modifyPassword',
58
        path: 'modifyPassword',
305
        component: () => import('@/views/accountSettings/modifyPassword'),
59
        component: () => import('@/views/accountSettings/modifyPassword'),
306
        name: 'modifyPassword',
307
        meta: { title: '修改密码' }
60
        meta: { title: '修改密码' }
308
      }
61
      }
309
    ]
62
    ]
310
  },
63
  }
311
]
64
]
312
313
// 实例化vue的时候只挂载constantRouter
65
// 实例化vue的时候只挂载constantRouter
314
66
315
export default new Router({
67
export default new Router({
316
  // mode: 'history', //后端支持可开
68
  // mode: 'history', //后端支持可开
317
  scrollBehavior: () => ({ y: 0 }),
69
  scrollBehavior: () => ({ y: 0 }),
318
  routes: constantRouterMap
70
  routes: [...constantRouterMap, ...asynsingle]
319
})
71
})
320
72
321
// 异步挂载的路由
73
// 异步挂载的路由
322
// 动态需要根据权限加载的路由表
74
// 动态需要根据权限加载的路由表
323
75
//  { path: '*', redirect: '/404', hidden: true }
324
export const asyncRouterMap = [
76
export const asyncRouterMap = [
325
  { path: '*', redirect: '/404', hidden: true }
77
  {
78
    '0': {
79
      path: '',
80
      component: Layout,
81
      name: 'sysSetting',
82
      redirect: 'noredirect',
83
      alwaysShow: true,
84
      meta: { title: '系统设置' },
85
      children: [
86
        {
87
          path: 'adminUser',
88
          component: () => import('@/views/sysSetting/adminUser'),
89
          name: 'adminUser',
90
          meta: { title: '平台后台用户管理列表' }
91
        }
92
      ]
93
    },
94
    '1': {
95
      path: '',
96
      component: Layout,
97
      name: 'contentModule',
98
      redirect: 'noredirect',
99
      meta: { title: '内容发布' },
100
      children: [
101
        {
102
          path: 'content',
103
          component: () => import('@/views/contentPub/index'),
104
          name: 'content',
105
          redirect: '/content/pubList',
106
          meta: { title: '内容发布列表' },
107
          children: [
108
            {
109
              path: 'pubList',
110
              component: () => import('@/views/contentPub/pubList'),
111
              name: 'pubList',
112
              meta: { title: '内容发布列表' }
113
            },
114
            {
115
              path: 'publish',
116
              hidden: true,
117
              component: () => import('@/views/contentPub/publish'),
118
              name: 'publish',
119
              meta: { title: ' 新内容发布' }
120
            }
121
          ]
122
        },
123
        {
124
          path: 'recycle',
125
          component: () => import('@/views/contentPub/index'),
126
          name: 'recycle',
127
          redirect: '/recycle/recycleBinList',
128
          meta: { title: '内容回收站列表' },
129
          children: [
130
            {
131
              path: 'recycleBinList',
132
              component: () => import('@/views/contentPub/recycleBin'),
133
              name: 'recycleBinList',
134
              meta: { title: '内容回收站列表'            meta: { title: '内容回收站列表' }
135
            },
136
            {
137
              path: 'viewRecycling',
138
              hidden: true,
139
              component: () => import('@/views/contentPub/viewRecyclingBins'),
140
              name: 'viewRecycling',
141
              meta: { title: ' 查看回收内容' }
142
            }
143
          ]
144
        },
145
        {
146
          path: 'draftList',
147
          component: () => import('@/views/contentPub/draftList'),
148
          name: 'draftList',
149
          meta: { title: '内容草稿箱列表' }
150
        }
151
      ]
152
    },
153
    '2': {
154
      path: '',
155
      component: Layout,
156
      name: 'specialExperts',
157
      redirect: 'noredirect',
158
      alwaysShow: true,
159
      meta: { title: '特约专家' },
160
      children: [
161
        {
162
          path: 'expertslist',
163
          component: () => import('@/views/specialExperts/index'),
164
          name: 'publishedList',
165
          meta: { title: '特约专家列表' }
166
        }
167
      ]
168
    },
169
    '3': {
170
      path: '',
171
      component: Layout,
172
      name: 'cooperationAgency',
173
      redirect: 'noredirect',
174
      alwaysShow: true,
175
      meta: { title: '合作机构' },
176
      children: [
177
        {
178
          path: 'agencylist',
179
          component: () => import('@/views/cooperationAgency/index'),
180
          name: 'publishedList',
181
          meta: { title: '合作机构管理列表' }
182
        }
183
      ]
184
    },
185
    '4': {
186
      path: '',
187
      component: Layout,
188
      name: 'company',
189
      redirect: 'noredirect',
190
      meta: { title: '企业中心' },
191
      children: [
192
        {
193
          path: 'noactive',
194
          component: () => import('@/views/companyCen/noactive/index'),
195
          name: 'noactive',
196
          parentPath: true,
197
          redirect: { name: 'noactiveList' },
198
          meta: { title: '未激活企业' },
199
          children: [
200
            {
201
              path: 'noactiveList',
202
              name: 'noactiveList',
203
              hidden: true,
204
              component: () => import('@/views/companyCen/noactive/noactiveList')
205
            },
206
            {
207
              path: 'compHome',
208
              component: () => import('@/views/companyCen/noactive/compHome'),
209
              name: 'compHome',
210
              parentPath: true,
211
              redirect: { name: 'compInfo' },
212
              meta: { title: '企业信息' },
213
              children: [
214
                {
215
                  path: 'compInfo',
216
                  name: 'compInfo',
217
                  hidden: true,
218
                  component: () => import('@/views/companyCen/noactive/compInfo')
219
                },
220
                {
221
                  path: 'productHome',
222
                  component: () => import('@/views/companyCen/noactive/productHome'),
223
                  name: 'productHome',
224
                  parentPath: true,
225
                  redirect: { name: 'compProduct' },
226
                  children: [
227
                    {
228
                      path: 'compProduct',
229
                      component: () => import('@/views/companyCen/noactive/compProduct'),
230
                      name: 'compProduct',
231
                      meta: { title: '企业产品' }
232
                    },
233
                    {
234
                      path: 'productInfo',
235
                      component: () => import('@/views/companyCen/noactive/productInfo'),
236
                      name: 'productInfo',
237
                      hidden: true,
238
                      meta: { title: '产品详情' }
239
                    }
240
                  ]
241
                }
242
              ]
243
            }
244
          ]
245
        },
246
        {
247
          path: 'activeList',
248
          component: () => import('@/views/companyCen/activeList'),
249
          name: 'activeList',
250
          meta: { title: '已激活企业' }
251
        }
252
      ]
253
    },
254
    '5': {
255
      path: '',
256
      component: Layout,
257
      name: 'platinfo',
258
      redirect: 'noredirect',
259
      alwaysShow: true,
260
      meta: { title: '平台信息' },
261
      children: [
262
        {
263
          path: 'platUpdate',
264
          component: () => import('@/views/platInfo/platUpdate'),
265
          name: 'platUpdate',
266
          meta: { title: '修改平台信息' }
267
        }
268
      ]
269
    },
270
    '6': {
271
      path: '',
272
      component: Layout,
273
      name: 'userinfo',
274
      redirect: 'noredirect',
275
      alwaysShow: true,
276
      meta: { title: '用户信息' },
277
      children: [
278
        {
279
          path: 'usingList',
280
          component: () => import('@/views/userInfo/usingList'),
281
          name: 'usingList',
282
          meta: { title: '正常用户' }
283
        },
284
        {
285
          path: 'blackList',
286
          component: () => import('@/views/userInfo/blackList'),
287
          name: 'blackList',
288
          meta: { title: '黑名单用户' }
289
        }
290
      ]
291
    },
292
    '7': {
293
      path: '',
294
      component: Layout,
295
      name: 'demand',
296
      redirect: 'noredirect',
297
      meta: { title: '需求中心' },
298
      children: [
299
        {
300
          path: 'publishedList',
301
          component: () => import('@/views/demandCen/publishedList'),
302
          name: 'publishedList',
303
          meta: { title: '发布中需求' }
304
        },
305
        {
306
          path: 'expiredList',
307
          component: () => import('@/views/demandCen/expiredList'),
308
          name: 'expiredList',
309
          meta: { title: '已过期需求' }
310
        },
311
        {
312
          path: 'completedList',
313
          component: () => import('@/views/demandCen/completedList'),
314
          name: 'completedList',
315
          meta: { title: '已完成需求' }
316
        },
317
        {
318
          path: 'closedList',
319
          component: () => import('@/views/demandCen/closedList'),
320
          name: 'closedList',
321
          meta: { title: '已关闭需求' }
322
        }
323
      ]
324
    }
325
  }
326
]
326
]

+ 1 - 4
src/store/getters.js

1
const getters = {
1
const getters = {
2
  sidebar: state => state.app.sidebar,
2
  sidebar: state => state.app.sidebar,
3
  device: state => state.app.device,
3
  device: state => state.app.device,
4
  account: state => state.user.account,
5
  userid: state => state.user.userid,
4
  userid: state => state.user.userid,
5
  account: state => state.user.account,
6
  name: state => state.user.name,
6
  name: state => state.user.name,
7
  roles: state => state.user.roles,
8
  logins: state => state.user.logins,
9
  session: state => state.user.session,
10
  permission_routers: state => state.permission.routers,
7
  permission_routers: state => state.permission.routers,
11
  addRouters: state => state.permission.addRouters
8
  addRouters: state => state.permission.addRouters
12
}
9
}

+ 33 - 33
src/store/modules/permission.js

1
import { asyncRouterMap, constantRouterMap } from '@/router'
1
import { asyncRouterMap, constantRouterMap, asynsingle } from '@/router'
2
2
3
/**
3
const ret = {
4
 * 通过meta.role判断是否与当前用户权限匹配
4
  arr: [],
5
 * @param roles
5
  pos(value) {
6
 * @param route
6
    return this.arr.indexOf(value)
7
 */
7
  },
8
function hasPermission(roles, route) {
8
  setArr() {
9
  if (route.meta.roles) {
9
    if (this.arr.length < 2) {
10
    return roles.some(role => route.meta.roles.indexOf(role) >= 0)
10
      return this.route()
11
  } else {
11
    }
12
    return true
12
    if (this.pos('0') !== -1) {
13
  }
13
      this.arr.splice(this.pos('0'), 1)
14
}
14
      this.arr.push('0')
15
15
    }
16
/**
16
    if (this.pos('7') !== -1) {
17
 * 递归过滤异步路由表,返回符合用户角色权限的路由表
17
      this.arr.splice(this.pos('7'), 1)
18
 * @param asyncRouterMap
18
      if (this.pos('1') !== -1) {
19
 * @param roles
19
        this.arr.splice(0, 1, '1', '7')
20
 */
20
      } else {
21
function filterAsyncRouter(asyncRouterMap, roles) {
21
        this.arr.unshift('7')
22
  const accessedRouters = asyncRouterMap.filter(route => {
23
    if (hasPermission(roles, route)) {
24
      if (route.children && route.children.length) {
25
        route.children = filterAsyncRouter(route.children, roles)
26
      }
22
      }
27
      return true
28
    }
23
    }
29
    return false
24
    return this.route()
30
  })
25
  },
31
  return accessedRouters
26
  route() {
27
    for (let i = 0; i < this.arr.length; i++) {
28
      if (asyncRouterMap[0][this.arr[i]]) {
29
        this.arr[i] = asyncRouterMap[0][this.arr[i]]
30
      }
31
    }
32
    return [...this.arr, ...asynsingle]
33
  }
32
}
34
}
33
34
const permission = {
35
const permission = {
35
  state: {
36
  state: {
36
    routers: constantRouterMap,
37
    routers: constantRouterMap,
39
  mutations: {
40
  mutations: {
40
    SET_ROUTERS: (state, routers) => {
41
    SET_ROUTERS: (state, routers) => {
41
      state.addRouters = routers
42
      state.addRouters = routers
42
      state.routers = constantRouterMap.concat(routers)
43
      state.routers = [...constantRouterMap, ...routers]
43
    }
44
    }
44
  },
45
  },
45
  actions: {
46
  actions: {
46
    GenerateRoutes({ commit }, data) {
47
    GenerateRoutes({ commit }, data) {
47
      return new Promise(resolve => {
48
      return new Promise(resolve => {
48
        const { roles } = data
49
        ret.arr = data.sort((par1, par2) => par1 - par2)
49
        // const roles = ['2']
50
        const accessedRouters = ret.setArr()
50
        const accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
51
        commit('SET_ROUTERS', accessedRouters)
51
        commit('SET_ROUTERS', accessedRouters)
52
        resolve()
52
        resolve()
53
      })
53
      })

+ 19 - 47
src/store/modules/user.js

1
import { login, logout, getInfo } from '@/api/login'
1
import { loginUrl, logoutUrl, getInfoUrl } from '@/api/loginnew'
2
import { getCookiesName, setCookiesName, removeCookiesName } from '@/utils/auth'
2
import http from '@/utils/request'
3
import Cookies from 'js-cookie'
3
4
4
const user = {
5
const user = {
5
  state: {
6
  state: {
6
    account: '',
7
    userid: '',
7
    userid: '',
8
    name: '',
8
    name: '',
9
    roles: [],
9
    account: ''
10
    logins: '',
11
    session: getCookiesName()
12
  },
10
  },
13
  mutations: {
11
  mutations: {
14
    SET_ACCOUNT: (state, account) => {
15
      state.account = account
16
    },
17
    SET_USERID: (state, userid) => {
12
    SET_USERID: (state, userid) => {
18
      state.userid = userid
13
      state.userid = userid
19
    },
14
    },
20
    SET_NAME: (state, name) => {
15
    SET_NAME: (state, name) => {
21
      state.name = name
16
      state.name = name
22
    },
17
    },
23
    SET_ROLES: (state, roles) => {
18
    SET_COUNT: (state, account) => {
24
      state.roles = roles
19
      state.account = account
25
    },
26
    SET_LOGIN: (state, logins) => {
27
      state.logins = logins
28
    },
29
    SET_SESSION: (state, session) => {
30
      state.session = session
31
    }
20
    }
32
  },
21
  },
33
22
34
  actions: {
23
  actions: {
35
    // 用户名登录
24
    // 用户名登录
36
    LoginByUsername({ commit }, userInfo) {
25
    LoginByUsername({ commit }, userInfo) {
37
      const account = userInfo.username.trim()
38
      const pw = userInfo.password
39
      const vc = userInfo.imgVerifyCode.toLocaleUpperCase()
40
      return new Promise((resolve, reject) => {
26
      return new Promise((resolve, reject) => {
41
        login(account, pw, vc).then((response) => {
27
        http.post(loginUrl, userInfo, (response) => {
42
          if (response.success) {
28
          if (response.success) {
43
            if (response.data) {
29
            if (response.data) {
44
              const dataS = response.data
30
              const dataS = response.data
45
              if (dataS.active) {
31
              if (dataS.actived) {
46
                commit('SET_ACCOUNT', dataS.account)
47
                commit('SET_USERID', dataS.id)
32
                commit('SET_USERID', dataS.id)
48
                commit('SET_NAME', dataS.name)
33
                commit('SET_NAME', dataS.name)
49
                setCookiesName(dataS.name)
34
                Cookies.set('userid', dataS.id)
50
              }
35
              }
51
            }
36
            }
52
          }
37
          }
53
          resolve(response)
38
          resolve(response)
54
        }).catch(error => {
39
        }, (error) => {
55
          reject(error)
40
          reject(error)
56
        })
41
        })
57
      })
42
      })
60
    // 获取用户信息
45
    // 获取用户信息
61
    GetUserInfo({ commit, state }) {
46
    GetUserInfo({ commit, state }) {
62
      return new Promise((resolve, reject) => {
47
      return new Promise((resolve, reject) => {
63
        getInfo().then(response => {
48
        http.get(getInfoUrl, '', response => {
64
          if (response.success) {
49
          if (response.success) {
65
            if (response.data) {
50
            if (response.data) {
66
              const dataS = response.data
51
              const dataS = response.data
67
              if (dataS.active) {
52
              if (dataS.actived) {
68
                commit('SET_ACCOUNT', dataS.account)
69
                commit('SET_USERID', dataS.id)
53
                commit('SET_USERID', dataS.id)
70
                // commit('SET_ROLES', ['2'])
71
                commit('SET_ROLES', [dataS.type.toString()])
72
                commit('SET_NAME', dataS.name)
54
                commit('SET_NAME', dataS.name)
55
                commit('SET_COUNT', dataS.account)
56
                Cookies.set('userid', dataS.id)
73
              }
57
              }
74
            }
58
            }
75
          }
59
          }
76
          resolve(response)
60
          resolve(response)
77
        }).catch(error => {
61
        }, error => {
78
          reject(error)
62
          reject(error)
79
        })
63
        })
80
      })
64
      })
83
    // 登出
67
    // 登出
84
    LogOut({ commit, state }) {
68
    LogOut({ commit, state }) {
85
      return new Promise((resolve, reject) => {
69
      return new Promise((resolve, reject) => {
86
        logout().then(() => {
70
        http.get(logoutUrl, '', (response) => {
87
          commit('SET_ACCOUNT', '')
88
          commit('SET_USERID', '')
71
          commit('SET_USERID', '')
89
          commit('SET_ROLES', [])
90
          commit('SET_NAME', '')
72
          commit('SET_NAME', '')
91
          commit('SET_SESSION', '')
73
          Cookies.remove('userid')
92
          removeCookiesName()
74
          resolve(response)
93
          resolve()
75
        }, error => {
94
        }).catch(error => {
95
          reject(error)
76
          reject(error)
96
        })
77
        })
97
      })
78
      })
98
    },
99
100
    // 前端 登出
101
    FedLogOut({ commit }) {
102
      return new Promise(resolve => {
103
        commit('SET_SESSION', '')
104
        removeCookiesName()
105
        resolve()
106
      })
107
    }
79
    }
108
  }
80
  }
109
}
81
}

+ 102 - 103
src/views/accountSettings/modifyAccountInformation.vue

4
      <div class="contain-title">修改账户资料</div>
4
      <div class="contain-title">修改账户资料</div>
5
    </div>
5
    </div>
6
    <div class="content-container">
6
    <div class="content-container">
7
      <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
7
      <el-row>
8
        <el-row>
8
        <el-col :span="18">
9
          <el-col :span="12">
9
          <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
10
            <el-form-item label="账号" prop="pass">
10
            <el-row>
11
              13526242569
11
              <el-col :span="12">
12
               </el-form-item>
12
                   <el-form-item label="账号" prop="account">
13
          </el-col>
13
                  <el-input v-model="ruleForm2.account" placeholder="请填写您的账号" maxlength="20"></el-input>
14
          <el-col :span="12">
14
                </el-form-item>
15
            <el-form-item label="用户名" prop="checkPass">
15
              </el-col>
16
              <el-input type="password" v-model="ruleForm2.checkPass" autocomplete="off" placeholder="请填写您的用户名"></el-input>
16
              <el-col :span="12">
17
               </el-form-item>
17
                   <el-form-item label="用户名" prop="name">
18
          </el-col>
18
                  <el-input v-model="ruleForm2.name" placeholder="请填写您的用户名" maxlength="20"></el-input>
19
        </el-row>
19
                </el-form-item>
20
        <el-row>
20
              </el-col>
21
          <el-col :span="12">
21
            </el-row>
22
            <el-form-item label="联系电话" prop="age">
22
            <el-row>
23
              <el-input v-model.number="ruleForm2.age" placeholder="请填写您的联系电话"></el-input>
23
              <el-col :span="12">
24
               </el-form-item>
24
                   <el-form-item label="联系电话" prop="phone">
25
          </el-col>
25
                  <el-input v-model.number="ruleForm2.phone" placeholder="请填写您的联系电话" maxlength="20"></el-input>
26
          <el-col :span="12">
26
                </el-form-item>
27
            <el-form-item label="联系邮箱" prop="mail">
27
              </el-col>
28
              <el-input v-model.number="ruleForm2.mail" placeholder="请填写您的联系邮箱"></el-input>
28
              <el-col :span="12">
29
               </el-form-item>
29
                   <el-form-item label="联系邮箱" prop="email">
30
          </el-col>
30
                  <el-input v-model="ruleForm2.email" placeholder="请填写您的联系邮箱" maxlength="50"></el-input>
31
        </el-row>
31
                </el-form-item>
32
        <el-row>
32
              </el-col>
33
          <el-col :span="12">
33
            </el-row>
34
            <el-form-item label="职位" prop="position">
34
            <el-row>
35
              <el-input v-model.number="ruleForm2.position" placeholder="请填写您的职位"></el-input>
35
              <el-col :span="12">
36
               </el-form-item>
36
                   <el-form-item label="职位" prop="job">
37
          </el-col>
37
                  <el-input v-model="ruleForm2.job" placeholder="请填写您的职位" maxlength="20"></el-input>
38
          <el-col :span="12">
38
                </el-form-item>
39
            <el-form-item label="所在部门" prop="department">
39
              </el-col>
40
              <el-input v-model.number="ruleForm2.department" placeholder="请填写您的所在部门"></el-input>
40
              <el-col :span="12">
41
               </el-form-item>
41
                   <el-form-item label="所在部门" prop="dep">
42
          </el-col>
42
                  <el-input v-model="ruleForm2.dep" placeholder="请填写您的所在部门" maxlength="20"></el-input>
43
        </el-row>
43
                </el-form-item>
44
        <el-row>
44
              </el-col>
45
          <el-form-item label="所在机构" prop="agency">
45
            </el-row>
46
            <el-input v-model.number="ruleForm2.agency" placeholder="请填写您的所在机构"></el-input>
46
            <el-row>
47
             </el-form-item>
47
                 <el-form-item label="所在机构" prop="comp">
48
        </el-row>
48
                <el-input v-model="ruleForm2.comp" placeholder="请填写您的所在机构" maxlength="50"></el-input>
49
              </el-form-item>
50
            </el-row>
49
51
50
        <el-form-item class="modiaB">
52
            <el-form-item class="modiaB">
51
          <el-button type="primary" @click="submitForm('ruleForm2')">保存修改</el-button>
53
              <el-button type="primary" @click="submitForm('ruleForm2')">保存修改</el-button>
52
        </el-form-item>
54
            </el-form-item>
53
      </el-form>
55
          </el-form>
56
        </el-col>
57
      </el-row>
54
    </div>
58
    </div>
55
  </div>
59
  </div>
56
</template>
60
</template>
57
61
58
<script>
62
<script>
63
  import { url, modifyUrl } from '@/api/modifyAccountInformation'
59
  export default {
64
  export default {
60
    data() {
65
    data() {
61
      var checkAge = (rule, value, callback) => {
66
      var checkPhone = (rule, value, callback) => {
67
        const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
62
        if (!value) {
68
        if (!value) {
63
          return callback(new Error('年龄不能为空'))
69
          return callback(new Error('请填写联系电话'))
64
        }
70
        } else if (!reg.test(value)) {
65
        setTimeout(() => {
71
          callback(new Error('联系电话格式有误,请检查后重新填写'))
66
          if (!Number.isInteger(value)) {
67
            callback(new Error('请输入数字值'))
68
          } else {
69
            if (value < 18) {
70
              callback(new Error('必须年满18岁'))
71
            } else {
72
              callback()
73
            }
74
          }
75
        }, 1000)
76
      }
77
      var validatePass = (rule, value, callback) => {
78
        if (value === '') {
79
          callback(new Error('请输入密码'))
80
        } else {
81
          if (this.ruleForm2.checkPass !== '') {
82
            this.$refs.ruleForm2.validateField('checkPass')
83
          }
84
          callback()
85
        }
86
      }
87
      var validatePass2 = (rule, value, callback) => {
88
        if (value === '') {
89
          callback(new Error('请再次输入密码'))
90
        } else if (value !== this.ruleForm2.pass) {
91
          callback(new Error('两次输入密码不一致!'))
92
        } else {
72
        } else {
93
          callback()
73
          callback()
94
        }
74
        }
95
      }
75
      }
96
      return {
76
      return {
97
        ruleForm2: {
77
        ruleForm2: {
98
          pass: '',
78
          account: '',
99
          checkPass: '',
79
          name: '',
100
          age: '',
80
          phone: '',
101
          mail: '',
81
          email: '',
102
          position: '',
82
          job: '',
103
          department: '',
83
          dep: '',
104
          agency: ''
84
          comp: ''
105
        },
85
        },
106
        rules2: {
86
        rules2: {
107
          pass: [
87
          account: [
108
            { validator: validatePass, trigger: 'blur' }
88
            { message: '请填写账号', required: true }
109
          ],
89
          ],
110
          checkPass: [
90
          name: [
111
            { validator: validatePass2, trigger: 'blur', required: true }
91
            { message: '请填写用户名', required: true }
112
          ],
92
          ],
113
          age: [
93
          phone: [
114
            { validator: checkAge, trigger: 'blur', required: true }
94
            { validator: checkPhone, trigger: 'blur', required: true }
115
          ],
95
          ],
116
          position: [
96
          email: [
117
            { required: true }
97
            { type: 'email', message: '联系邮箱格式有误,请检查后重新填写', trigger: 'blur' }
118
          ],
98
          ],
119
          department: [
99
          job: [
120
            { required: true }
100
            { message: '请填写职位', required: true }
121
          ],
101
          ],
122
          agency: [
102
          dep: [
123
            { required: true }
103
            { message: '请填写所在部门', required: true }
104
          ],
105
          comp: [
106
            { message: '请填写所在机构', required: true }
124
          ]
107
          ]
125
        }
108
        }
126
      }
109
      }
127
    },
110
    },
111
    created() {
112
      this.$http.get(url, '', (response) => {
113
        if (response.success && response.data) {
114
          this.ruleForm2 = {
115
            account: response.data.account,
116
            name: response.data.name,
117
            phone: response.data.phone,
118
            email: response.data.email || '',
119
            job: response.data.job,
120
            dep: response.data.dep,
121
            comp: response.data.comp
122
          }
123
        }
124
      })
125
    },
128
    methods: {
126
    methods: {
129
      submitForm(formName) {
127
      submitForm(formName) {
130
        this.$refs[formName].validate((valid) => {
128
        this.$refs[formName].validate((valid) => {
131
          if (valid) {
129
          if (valid) {
132
            alert('submit!')
130
            this.$http.put(modifyUrl, this.ruleForm2, (response) => {
131
              if (response.success) {
132
                this.$message({
133
                  message: '资料修改成功',
134
                  type: 'success'
135
                })
136
              }
137
            })
133
          } else {
138
          } else {
134
            console.log('error submit!!')
139
            console.log('error submit!!')
135
            return false
140
            return false
136
          }
141
          }
137
        })
142
        })
138
      },
139
      resetForm(formName) {
140
        this.$refs[formName].resetFields()
141
      }
143
      }
142
    }
144
    }
143
  }
145
  }
144
</script>
146
</script>
145
147
146
<style scoped>
148
<style scoped>
147
  .demo-ruleForm {
148
    width: 900px;
149
  }
150
  .modiaB {
149
  .modiaB {
151
    text-align: center;
150
    text-align: center;
152
    margin: 170px 0;
151
    margin: 100px 0;
153
  }
152
  }
154
</style>
153
</style>

+ 48 - 49
src/views/accountSettings/modifyPassword.vue

4
      <div class="contain-title">重置密码</div>
4
      <div class="contain-title">重置密码</div>
5
    </div>
5
    </div>
6
    <div class="content-container">
6
    <div class="content-container">
7
      <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
7
      <el-row>
8
        <el-form-item label="新的密码" prop="pass">
8
        <el-col :span="14">
9
          <el-input type="password" v-model="ruleForm2.pass" autocomplete="off" placeholder="请填写新的密码"></el-input>
9
          <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
10
           </el-form-item>
10
               <el-form-item label="新的密码" prop="pass">
11
        <el-form-item label="确认密码" prop="checkPass">
11
              <el-input type="password" v-model="ruleForm2.pass" placeholder="请填写新的密码"></el-input>
12
          <el-input type="password" v-model="ruleForm2.checkPass" autocomplete="off" placeholder="再次输入新的密码"></el-input>
12
            </el-form-item>
13
           </el-form-item>
13
               <el-form-item label="确认密码" prop="checkPass">
14
        <el-form-item class="modiaB">
14
              <el-input type="password" v-model="ruleForm2.checkPass" placeholder="再次输入新的密码"></el-input>
15
          <el-button type="primary" @click="submitForm('ruleForm2')">确定</el-button>
15
            </el-form-item>
16
           </el-form-item>
16
               <el-form-item class="modiaB">
17
      </el-form>
17
              <el-button type="primary" @click="submitForm('ruleForm2')">确定</el-button>
18
            </el-form-item>
19
          </el-form>
20
        </el-col>
21
      </el-row>
18
    </div>
22
    </div>
19
  </div>
23
  </div>
20
</template>
24
</template>
21
25
22
<script>
26
<script>
27
  import url from '@/api/modifyPassword'
23
  export default {
28
  export default {
24
    data() {
29
    data() {
25
      var checkAge = (rule, value, callback) => {
26
        if (!value) {
27
          return callback(new Error('年龄不能为空'))
28
        }
29
        setTimeout(() => {
30
          if (!Number.isInteger(value)) {
31
            callback(new Error('请输入数字值'))
32
          } else {
33
            if (value < 18) {
34
              callback(new Error('必须年满18岁'))
35
            } else {
36
              callback()
37
            }
38
          }
39
        }, 1000)
40
      }
41
      var validatePass = (rule, value, callback) => {
30
      var validatePass = (rule, value, callback) => {
31
        const reg = /^[a-zA-Z0-9]{6,24}$/
42
        if (value === '') {
32
        if (value === '') {
43
          callback(new Error('请输入密码'))
33
          callback(new Error('请设置您的新密码'))
34
        } else if (!reg.test(value)) {
35
          callback(new Error('密码由6-24位数字和字母组成,区分大小写'))
44
        } else {
36
        } else {
45
          if (this.ruleForm2.checkPass !== '') {
46
            this.$refs.ruleForm2.validateField('checkPass')
47
          }
48
          callback()
37
          callback()
49
        }
38
        }
50
      }
39
      }
51
      var validatePass2 = (rule, value, callback) => {
40
      var validatePass2 = (rule, value, callback) => {
41
        const reg = /^[a-zA-Z0-9]{6,24}$/
52
        if (value === '') {
42
        if (value === '') {
53
          callback(new Error('请再次输入密码'))
43
          callback(new Error('请再次输入密码确认'))
54
        } else if (value !== this.ruleForm2.pass) {
44
        } else if (!reg.test(value)) {
55
          callback(new Error('两次输入密码不一致!'))
45
          callback(new Error('密码由6-24位数字和字母组成,区分大小写'))
46
        } else if (value !== this.ruleForm2.pass && value) {
47
          callback(new Error('两次输入不一致,请重新输入'))
56
        } else {
48
        } else {
57
          callback()
49
          callback()
58
        }
50
        }
60
      return {
52
      return {
61
        ruleForm2: {
53
        ruleForm2: {
62
          pass: '',
54
          pass: '',
63
          checkPass: '',
55
          checkPass: ''
64
          age: ''
65
        },
56
        },
66
        rules2: {
57
        rules2: {
67
          pass: [
58
          pass: [
68
            { validator: validatePass, trigger: 'blur' }
59
            { validator: validatePass, trigger: 'blur', required: true }
69
          ],
60
          ],
70
          checkPass: [
61
          checkPass: [
71
            { validator: validatePass2, trigger: 'blur' }
62
            { validator: validatePass2, trigger: 'blur', required: true }
72
          ],
73
          age: [
74
            { validator: checkAge, trigger: 'blur' }
75
          ]
63
          ]
76
        }
64
        }
77
      }
65
      }
80
      submitForm(formName) {
68
      submitForm(formName) {
81
        this.$refs[formName].validate((valid) => {
69
        this.$refs[formName].validate((valid) => {
82
          if (valid) {
70
          if (valid) {
83
            alert('submit!')
71
            this.$http.post(url, { npw: this.ruleForm2.pass }, (response) => {
72
              if (response.success) {
73
                this.$confirm('密码已修改,快去登录吧!', '修改密码', {
74
                  confirmButtonText: '确定',
75
                  cancelButtonText: '取消',
76
                  center: true,
77
                  showCancelButton: false,
78
                  showClose: false,
79
                  closeOnClickModal: false,
80
                  type: 'success'
81
                }).then(() => {
82
                  this.$store.dispatch('LogOut').then((response) => {
83
                    if (response.success) {
84
                      this.$router.push('/login')
85
                    }
86
                  })
87
                })
88
              }
89
            })
84
          } else {
90
          } else {
85
            console.log('error submit!!')
91
            console.log('error submit!!')
86
            return false
92
            return false
87
          }
93
          }
88
        })
94
        })
89
      },
90
      resetForm(formName) {
91
        this.$refs[formName].resetFields()
92
      }
95
      }
93
    }
96
    }
94
  }
97
  }
95
</script>
98
</script>
96
99
97
<style scoped>
100
<style scoped>
98
  .demo-ruleForm {
99
    width: 900px;
100
  }
101
102
  .modiaB {
101
  .modiaB {
103
    text-align: center;
102
    text-align: center;
104
    margin: 100px 0;
103
    margin: 100px 0;

+ 3 - 3
src/views/contentPub/publish.vue

42
</template>
42
</template>
43
43
44
<script>
44
<script>
45
  import searchTemplate from './searchTemplate'
45
  import searchTemplate from '@/components/searchBar'
46
  import uploadFile from './uploadFile'
46
  import uploadFile from '@/components/uploadFile'
47
  import UE from './editorUE'
47
  import UE from '@/components/editorUE'
48
  export default {
48
  export default {
49
    data() {
49
    data() {
50
      var checkTitle = (rule, value, callback) => {
50
      var checkTitle = (rule, value, callback) => {

+ 2 - 6
src/views/layout/components/Sidebar/index.vue

8
      text-color="#bfcbd9"
8
      text-color="#bfcbd9"
9
      active-text-color="#409EFF"
9
      active-text-color="#409EFF"
10
    >
10
    >
11
      <sidebar-item v-for="route in routes" :key="route.name" :item="route" :base-path="route.path"></sidebar-item>
11
      <sidebar-item v-for="route in permission_routers" :key="permission_routers.name" :item="route" :base-path="route.path"></sidebar-item>
12
    </el-menu>
12
    </el-menu>
13
  </el-scrollbar>
13
  </el-scrollbar>
14
</template>
14
</template>
19
19
20
export default {
20
export default {
21
  components: { SidebarItem },
21
  components: { SidebarItem },
22
  computed: {
22
  computed: mapGetters(['permission_routers'])
23
    routes() {
24
      return this.$router.options.routes
25
    }
26
  }
27
}
23
}
28
</script>
24
</script>

+ 1 - 44
src/views/layout/components/TopNavbar.vue

15
<script>
15
<script>
16
import { mapGetters } from 'vuex'
16
import { mapGetters } from 'vuex'
17
import { MessageBox } from 'element-ui'
17
import { MessageBox } from 'element-ui'
18
import Cookies from 'js-cookie'
19
import '@/styles/variables.scss'
18
import '@/styles/variables.scss'
20
19
21
export default {
20
export default {
22
  data() {
23
    return {
24
      bridgeId: '',
25
      showName: '',
26
      dataList: ''
27
    }
28
  },
29
  computed: {
21
  computed: {
30
    ...mapGetters([
22
    ...mapGetters([
31
      'name',
23
      'name'
32
      'roles'
33
    ])
24
    ])
34
  },
25
  },
35
  watch: {
36
    '$route'(to, from) {
37
      if (to.path === '/dashboard') {
38
        var dataList = this.dataList
39
        for (let i = 0; i < dataList.length; i++) {
40
          dataList[i].disab = false
41
        }
42
        Cookies.remove('bridgeId')
43
        Cookies.remove('bridgeName')
44
        this.showName = ''
45
      } else {
46
        this.bridgeId = Cookies.get('bridgeId')
47
        this.showName = Cookies.get('bridgeName')
48
      }
49
    }
50
  },
51
  created() {
52
    this.bridgeId = Cookies.get('bridgeId')
53
    this.showName = Cookies.get('bridgeName')
54
  },
55
  methods: {
26
  methods: {
56
    toHome() {
27
    toHome() {
57
      this.$router.replace({ path: '/' })
28
      this.$router.replace({ path: '/' })
58
    },
29
    },
59
    toggleSideBar() {
60
      this.$store.dispatch('ToggleSideBar')
61
    },
62
    logout() {
30
    logout() {
63
      MessageBox.confirm('您确认要退出登录吗?', '提示', {
31
      MessageBox.confirm('您确认要退出登录吗?', '提示', {
64
        confirmButtonText: '确定',
32
        confirmButtonText: '确定',
67
        center: true
35
        center: true
68
      }).then(() => {
36
      }).then(() => {
69
        this.$store.dispatch('LogOut').then(() => {
37
        this.$store.dispatch('LogOut').then(() => {
70
          Cookies.remove('bridgeId')
71
          Cookies.remove('bridgeName')
72
          location.reload() // 为了重新实例化vue-router对象 避免bug
38
          location.reload() // 为了重新实例化vue-router对象 避免bug
73
        })
39
        })
74
      }).catch(() => {
40
      }).catch(() => {
75
        console.log('已取消退出')
41
        console.log('已取消退出')
76
      })
42
      })
77
    },
78
    goToDashboardC(id, name) {
79
      this.showName = name
80
      Cookies.set('bridgeId', id)
81
      Cookies.set('bridgeName', name)
82
      this.$router.replace({
83
        name: 'bridgeDetail',
84
        query: { id: id, name: name }
85
      })
86
    }
43
    }
87
  }
44
  }
88
}
45
}

+ 75 - 117
src/views/login/index.vue

5
    </div>
5
    </div>
6
    <el-form class="login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left">
6
    <el-form class="login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left">
7
      <h3 class="title">登录</h3>
7
      <h3 class="title">登录</h3>
8
      <el-form-item prop="username">
8
      <el-form-item prop="account">
9
        <span class="svg-container svg-container_login">
9
        <span class="svg-container svg-container_login">
10
          <svg-icon icon-class="user" />
10
          <svg-icon icon-class="user" />
11
        </span>
11
        </span>
12
        <el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="请输入您的手机号码" maxlength="11" />
12
        <el-input name="username" type="text" v-model="loginForm.account" autoComplete="on" placeholder="请输入用户账号"
13
          maxlength="11" />
13
      </el-form-item>
14
      </el-form-item>
14
      <el-form-item prop="password">
15
      <el-form-item prop="pw">
15
        <span class="svg-container">
16
        <span class="svg-container">
16
          <svg-icon icon-class="password"/>
17
          <svg-icon icon-class="password" />
17
        </span>
18
        </span>
18
        <el-input name="password" :type="pwdType" v-model="loginForm.password" autoComplete="on"
19
        <el-input name="password" :type="pwdType" v-model="loginForm.pw" autoComplete="on" placeholder="请输入登录密码"
19
          placeholder="请输入您的登录密码" maxlength="24"></el-input>
20
          maxlength="24"></el-input>
20
          <span class="show-pwd" @click="showPwd"><svg-icon icon-class="eye" v-show="!falg"/><svg-icon icon-class="password-view" v-show="falg"/></span>
21
        <span class="show-pwd" @click="showPwd">
21
      </el-form-item>
22
          <svg-icon icon-class="eye" v-show="!falg" />
22
      <el-form-item prop="imgVerifyCode">
23
          <svg-icon icon-class="password-view" v-show="falg" /></span>
23
        <span class="svg-container">
24
          <svg-icon icon-class="msgvc"></svg-icon>
25
        </span>
26
        <el-input v-model="loginForm.imgVerifyCode" placeholder="请输入图形验证码" @keyup.enter.native="handleLogin" class="code-btn" maxlength="4">
27
        <img slot="append" :src="imgVcUrl" @click="changeImgVc" /></el-input>
28
      </el-form-item>
24
      </el-form-item>
29
      <el-form-item>
25
      <el-form-item>
30
        <el-button class="log-btn" type="primary" :loading="loading" @click.native.prevent="handleLogin">登录</el-button>
26
        <el-button class="log-btn" type="primary" :loading="loading" @click.native.prevent="handleLogin">登录</el-button>
31
      </el-form-item>
27
      </el-form-item>
32
      <el-form-item class="el-form-find">
33
        <el-button type="text" @click.native.prevent="goBackPwd">忘记密码?</el-button>
34
      </el-form-item>
35
    </el-form>
28
    </el-form>
36
  </div>
29
  </div>
37
</template>
30
</template>
38
31
39
<script>
32
<script>
40
import { Message } from 'element-ui'
33
  import { Message } from 'element-ui'
41
import { getPictureVC } from '@/api/pictureVc'
34
  import '@/styles/loginform.scss'
42
import '@/styles/loginform.scss'
35
  export default {
43
36
    name: 'login',
44
export default {
37
    data() {
45
  name: 'login',
38
      var validPassword = (rule, value, callback) => {
46
  data() {
39
        const reg = /^[a-zA-Z0-9]{6,24}$/
47
    var validPhone = (rule, value, callback) => {
40
        if (!value) {
48
      const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
41
          callback(new Error('请输入您的登录密码'))
49
      if (!value) {
42
        }
50
        callback(new Error('请输入您的手机号码'))
43
        if (!reg.test(value)) {
51
      } else if (!reg.test(value)) {
44
          callback(new Error('密码由6-24个数字和字母组成,区分大小写'))
52
        callback(new Error('请输入正确的手机号码'))
45
        }
53
      } else {
54
        callback()
46
        callback()
55
      }
47
      }
56
    }
48
      return {
57
    return {
49
        falg: false,
58
      falg: false,
50
        loginForm: {
59
      imgVcUrl: '',
51
          account: '',
60
      loginForm: {
52
          pw: ''
61
        username: 'admin',
53
        },
62
        password: 'admin',
54
        loginRules: {
63
        imgVerifyCode: ''
55
          account: [{ required: true, message: '请输入您的用户账号' }],
64
      },
56
          pw: [
65
      loginRules: {
57
            { required: true, validator: validPassword, trigger: 'blur' }
66
        // username: [{ required: true, trigger: 'blur', validator: validPhone }],
58
          ]
67
        // password: [
59
        },
68
        //   { required: true, message: '请输入您的登录密码', trigger: 'blur' },
60
        loading: false,
69
        //   { min: 6, max: 24, message: '密码由6-24个字符组成,区分大小写', trigger: 'blur' }
61
        pwdType: 'password'
70
        // ],
71
        // imgVerifyCode: [{ required: true, message: '请输入图形验证码', trigger: 'blur' }]
72
      },
73
      loading: false,
74
      pwdType: 'password'
75
    }
76
  },
77
  created() {
78
    this.changeImgVc()
79
  },
80
  methods: {
81
    showPwd() {
82
      this.falg = !this.falg
83
      if (this.pwdType === 'password') {
84
        this.pwdType = ''
85
      } else {
86
        this.pwdType = 'password'
87
      }
62
      }
88
    },
63
    },
89
    handleLogin() {
64
    methods: {
90
      this.$router.push({ path: '/dashboard' })
65
      showPwd() {
91
      // this.$refs.loginForm.validate(valid => {
66
        this.falg = !this.falg
92
      //   if (valid) {
67
        if (this.pwdType === 'password') {
93
      //     this.loading = true
68
          this.pwdType = ''
94
      //     this.$store.dispatch('LoginByUsername', this.loginForm).then((response) => {
69
        } else {
95
      //       this.loading = false
70
          this.pwdType = 'password'
96
      //       if (response.success) {
71
        }
97
      //         if (response.data) {
72
      },
98
      //           this.$store.dispatch('GetUserInfo').then(res => {
73
      handleLogin() {
99
      //           })
74
        this.$refs.loginForm.validate(valid => {
100
      //           this.$router.push({ path: '/dashboard' })
75
          if (valid) {
101
      //         } else {
76
            this.loading = true
102
      //           Message.error('登录账号与密码不匹配,请检查后重试')
77
            this.$store.dispatch('LoginByUsername', this.loginForm).then((response) => {
103
      //           this.changeImgVc()
78
              this.loading = false
104
      //           return
79
              if (response.success) {
105
      //         }
80
                if (response.data) {
106
      //       } else {
81
                  this.$store.dispatch('GetUserInfo').then(res => {
107
      //         const errorCode = [{
82
                  })
108
      //           code: -60001,
83
                  this.$router.push({ path: '/dashboard' })
109
      //           msg: '图形验证码不存在'
84
                } else {
110
      //         }, {
85
                  Message.error('该账号已停用,请联系管理员')
111
      //           code: -60002,
86
                }
112
      //           msg: '图形验证码超时'
87
              } else {
113
      //         }, {
88
                if (response.code === -200001) {
114
      //           code: -60003,
89
                  Message.error('账号或密码错误,请重新输入')
115
      //           msg: '图形验证码不正确'
90
                }
116
      //         }, {
91
              }
117
      //           code: -60005,
92
            }).catch(() => {
118
      //           msg: '该账号已停用,请联系管理员'
93
              this.loading = false
119
      //         }]
94
            })
120
      //         for (let i = 0; i < errorCode.length; i++) {
95
          } else {
121
      //           if (response.code === errorCode[i].code) {
96
            console.log('error submit!!')
122
      //             Message.error(errorCode[i].msg)
97
            return false
123
      //             this.changeImgVc()
98
          }
124
      //             return
99
        })
125
      //           }
100
      }
126
      //         }
127
      //       }
128
      //     }).catch(() => {
129
      //       this.loading = false
130
      //     })
131
      //   } else {
132
      //     console.log('error submit!!')
133
      //     return false
134
      //   }
135
      // })
136
    },
137
    goBackPwd() {
138
      this.$router.push({ path: '/findPwd' })
139
    },
140
    changeImgVc() {
141
      this.imgVcUrl = getPictureVC('PIC_LOGIN')
142
    }
101
    }
143
  }
102
  }
144
}
103
</script>
145
</script>