Commit db31f240 authored by liuyang's avatar liuyang

完成用户新增功能

parent 59186984
This diff is collapsed.
...@@ -32,9 +32,7 @@ const mainRoutes = { ...@@ -32,9 +32,7 @@ const mainRoutes = {
// 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否 // 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否
// 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理! // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理!
{ path: '/home', component: ()=>import('@/views/common/home'), name: 'home', meta: { title: '首页' } }, { path: '/home', component: ()=>import('@/views/common/home'), name: 'home', meta: { title: '首页' } },
{ path: '/theme', component: ()=>import('@/views/common/theme'), name: 'theme', meta: { title: '主题' } }, { path: '/theme', component: ()=>import('@/views/common/theme'), name: 'theme', meta: { title: '主题' } }
{ path: '/article-add-or-update', component: ()=>import('@/views/modules/wx/article-add-or-update'), name: 'article', meta: { title: '编辑文章', isTab: true } },
{ path: '/material-news-add-or-update', component: ()=>import('@/views/modules/wx/material-news-add-or-update'), name: 'material-news', meta: { title: '图文素材' ,isDynamic:true,isTab:true} },
], ],
beforeEnter (to, from, next) { beforeEnter (to, from, next) {
let token = Vue.cookie.get('token') let token = Vue.cookie.get('token')
...@@ -112,9 +110,9 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) { ...@@ -112,9 +110,9 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
} else if (menuList[i].url && /\S/.test(menuList[i].url)) { } else if (menuList[i].url && /\S/.test(menuList[i].url)) {
menuList[i].url = menuList[i].url.replace(/^\//, '') menuList[i].url = menuList[i].url.replace(/^\//, '')
var route = { var route = {
path: menuList[i].url.replace('/', '-'), path: menuList[i].url,
component: null, component: null,
name: menuList[i].url.replace('/', '-'), name: menuList[i].url,
meta: { meta: {
menuId: menuList[i].menuId, menuId: menuList[i].menuId,
title: menuList[i].name, title: menuList[i].name,
...@@ -147,10 +145,10 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) { ...@@ -147,10 +145,10 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
{ path: '*', redirect: { name: '404' } } { path: '*', redirect: { name: '404' } }
]) ])
sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]'))
console.log('\n') // console.log('\n')
console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') // console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue')
console.log(mainRoutes.children) // console.log(mainRoutes.children)
console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') // console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue')
} }
} }
export default router export default router
...@@ -14,15 +14,10 @@ export default { ...@@ -14,15 +14,10 @@ export default {
}; };
}, },
mounted() { mounted() {
this.getAccessToken()
}, },
methods: { methods: {
getAccessToken(){
this.$http({
url: this.$http.adornUrl('/manage/wxAccessToken/getAccessToken'),
method: 'get'
})
}
} }
}; };
</script> </script>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
:visible.sync="visible"> :visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"> <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="用户名" prop="userName"> <el-form-item label="用户名" prop="userName">
<el-input v-model="dataForm.userName" placeholder="登录帐号"></el-input> <el-input v-model="dataForm.userName" placeholder="登录帐号" :disabled="dataForm.id"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="密码" prop="password" :class="{ 'is-required': !dataForm.id }"> <el-form-item label="密码" prop="password" :class="{ 'is-required': !dataForm.id }">
<el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input> <el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
...@@ -80,7 +80,6 @@ ...@@ -80,7 +80,6 @@
userName: '', userName: '',
password: '', password: '',
comfirmPassword: '', comfirmPassword: '',
salt: '',
email: '', email: '',
mobile: '', mobile: '',
roleIdList: [], roleIdList: [],
...@@ -111,11 +110,11 @@ ...@@ -111,11 +110,11 @@
init (id) { init (id) {
this.dataForm.id = id || 0 this.dataForm.id = id || 0
this.$http({ this.$http({
url: this.$http.adornUrl('/sys/role/select'), url: this.$http.adornUrl('/api/sys/role/select'),
method: 'get', method: 'get',
params: this.$http.adornParams() params: this.$http.adornParams()
}).then(({data}) => { }).then(({data}) => {
this.roleList = data && data.code === 200 ? data.list : [] this.roleList = data && !data.errorCode ? data : []
}).then(() => { }).then(() => {
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
...@@ -124,17 +123,16 @@ ...@@ -124,17 +123,16 @@
}).then(() => { }).then(() => {
if (this.dataForm.id) { if (this.dataForm.id) {
this.$http({ this.$http({
url: this.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`), url: this.$http.adornUrl(`/api/sys/user/info/${this.dataForm.id}`),
method: 'get', method: 'get',
params: this.$http.adornParams() params: this.$http.adornParams()
}).then(({data}) => { }).then(({data}) => {
if (data && data.code === 200) { if (data && !data.errorCode) {
this.dataForm.userName = data.user.username this.dataForm.userName = data.username
this.dataForm.salt = data.user.salt this.dataForm.email = data.email
this.dataForm.email = data.user.email this.dataForm.mobile = data.mobile
this.dataForm.mobile = data.user.mobile this.dataForm.roleIdList = data.roleIdList
this.dataForm.roleIdList = data.user.roleIdList this.dataForm.status = data.status
this.dataForm.status = data.user.status
} }
}) })
} }
...@@ -145,20 +143,22 @@ ...@@ -145,20 +143,22 @@
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
this.$http({ this.$http({
url: this.$http.adornUrl(`/sys/user/${!this.dataForm.id ? 'save' : 'update'}`), url: this.$http.adornUrl(`/api/sys/user/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post', method: 'post',
data: this.$http.adornData({ data: this.$http.adornData({
'userId': this.dataForm.id || undefined, 'userId': this.dataForm.id || undefined,
'username': this.dataForm.userName, 'username': this.dataForm.userName,
'password': this.dataForm.password, 'password': this.dataForm.password,
'salt': this.dataForm.salt,
'email': this.dataForm.email, 'email': this.dataForm.email,
'mobile': this.dataForm.mobile, 'mobile': this.dataForm.mobile,
'status': this.dataForm.status, 'status': this.dataForm.status,
'roleIdList': this.dataForm.roleIdList 'roleIdList': this.dataForm.roleIdList
}) })
}).then(({data}) => { }).then(({data}) => {
if (data && data.code === 200) { if (data && data.errorCode) {
this.$message.error(data.message)
} else {
this.$message({ this.$message({
message: '操作成功', message: '操作成功',
type: 'success', type: 'success',
...@@ -168,8 +168,6 @@ ...@@ -168,8 +168,6 @@
this.$emit('refreshDataList') this.$emit('refreshDataList')
} }
}) })
} else {
this.$message.error(data.msg)
} }
}) })
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
width="50"> width="50">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="userId" prop="id"
header-align="center" header-align="center"
align="center" align="center"
width="80" width="80"
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
width="150" width="150"
label="操作"> label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="isAuth('sys:user:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.userId)">修改</el-button> <el-button v-if="isAuth('sys:user:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button v-if="isAuth('sys:user:delete')" type="text" size="small" @click="deleteHandle(scope.row.userId)">删除</el-button> <el-button v-if="isAuth('sys:user:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -111,17 +111,17 @@ ...@@ -111,17 +111,17 @@
getDataList () { getDataList () {
this.dataListLoading = true this.dataListLoading = true
this.$http({ this.$http({
url: this.$http.adornUrl('/sys/user/list'), url: this.$http.adornUrl('/api/sys/user/list'),
method: 'get', method: 'get',
params: this.$http.adornParams({ params: this.$http.adornParams({
'page': this.pageIndex, 'pageIndex': this.pageIndex,
'limit': this.pageSize, 'pageSize': this.pageSize,
'username': this.dataForm.userName 'username': this.dataForm.userName
}) })
}).then(({data}) => { }).then(({data}) => {
if (data && data.code === 200) { if (data && !data.errorCode) {
this.dataList = data.page.list this.dataList = data.result
this.totalCount= data.page.totalCount this.totalCount= data.total
} else { } else {
this.dataList = [] this.dataList = []
this.totalCount= 0 this.totalCount= 0
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$http({ this.$http({
url: this.$http.adornUrl('/sys/user/delete'), url: this.$http.adornUrl('/api/sys/user/delete'),
method: 'post', method: 'post',
data: this.$http.adornData(userIds, false) data: this.$http.adornData(userIds, false)
}).then(({data}) => { }).then(({data}) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment