Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-web
/
authority
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ac388b3e
authored
Sep 18, 2018
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调用接口
1 parent
69432b72
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
87 deletions
src/components/UserCreate/src/main.vue
src/config/common.conf.js
src/views/customer/user/index.vue
src/components/UserCreate/src/main.vue
View file @
ac388b3
...
...
@@ -24,8 +24,8 @@
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
<gl-form-item
label=
"注册IP"
prop=
"
registeredIP
"
>
<gl-input
v-model=
"userManageForm.
registeredIP
"
clearable
></gl-input>
<gl-form-item
label=
"注册IP"
prop=
"
joinip
"
>
<gl-input
v-model=
"userManageForm.
joinip
"
clearable
></gl-input>
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
...
...
@@ -37,44 +37,44 @@
<gl-col
:span=
"12"
>
<gl-form-item
label=
"状态"
prop=
"state"
>
<gl-select
v-model=
"userManageForm.state"
placeholder=
"启用"
>
<gl-option
label=
"启用"
value=
"启用"
></gl-option>
<gl-option
label=
"禁用"
value=
"禁用"
></gl-option>
<gl-option
label=
"启用"
value=
'0'
></gl-option>
<gl-option
label=
"禁用"
value=
'1'
></gl-option>
</gl-select>
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
<gl-form-item
label=
"管理员"
>
<gl-select
v-model=
"userManageForm.isadmin"
placeholder=
"否"
>
<gl-option
label=
"否"
value=
"否"
></gl-option>
<gl-option
label=
"是"
value=
"是"
></gl-option>
<gl-option
label=
"否"
value=
'0'
></gl-option>
<gl-option
label=
"是"
value=
'1'
></gl-option>
</gl-select>
</gl-form-item>
</gl-col>
<gl-col
:span=
"24"
>
<gl-form-item
label=
"所属部门"
prop=
"departName"
>
<gl-select
v-model=
"userManageForm.departName"
placeholder=
"请选择"
>
<
!--
<
gl-select
v-model=
"userManageForm.departName"
placeholder=
"请选择"
>
<gl-option
v-for=
"item in userManageForm.options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</gl-option>
</gl-select>
</gl-select>
-->
<gl-select
v-model=
"value"
placeholder=
"请选择"
>
<gl-option
v-for=
"item in userManageForm.options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</gl-option>
</gl-select>
</gl-form-item>
</gl-col>
<gl-col
:span=
"24"
>
<gl-form-item
label=
"角色选项"
prop=
"roles"
>
<gl-checkbox-group
v-model=
"userManageForm.roles"
>
<gl-checkbox
label=
"诺威达-艺展-系统日志上报"
></gl-checkbox>
<gl-checkbox
label=
"盗抢险"
></gl-checkbox>
<gl-checkbox
label=
"研发工具-增量"
></gl-checkbox>
<gl-checkbox
label=
"精品分期0329角色"
></gl-checkbox>
<gl-checkbox
label=
"好车主"
></gl-checkbox>
<gl-checkbox
label=
"云商分润"
></gl-checkbox>
<gl-checkbox
label=
"营销系统"
></gl-checkbox>
<gl-checkbox
label=
"GPS后台角色控制"
></gl-checkbox>
<gl-checkbox
label=
"外场测试"
></gl-checkbox>
</gl-checkbox-group>
<gl-col
:span=
"10"
>
<gl-checkbox
v-for=
"item in list"
:key=
"item.id"
v-model=
"item.isSelect"
>
{{
item
.
rolename
}}
</gl-checkbox>
</gl-col>
</gl-form-item>
</gl-col>
</gl-form>
...
...
@@ -90,41 +90,63 @@ export default {
name
:
'UserCreate'
,
props
:
{
dialogFormVisible
:
Boolean
,
editUser
:
Object
userManageForm
:
Object
},
watch
:
{
dialogFormVisible
(
val
)
{
!
val
&&
this
.
$refs
[
'userManageForm'
].
resetFields
()
},
editUser
(
val
)
{
if
(
val
)
{
this
.
userManageForm
=
val
}
console
.
log
(
this
.
userManageForm
)
// !val && this.$refs['userManageForm'].resetFields()
}
// editUser(val) {
// if (val) {
// console.log(val)
// this.userManageForm = val
// }
// }
},
mounted
()
{
this
.
list
.
forEach
(
element
=>
{
element
.
isSelect
=
true
})
},
data
()
{
return
{
tel
:
'[ 1, /[34578]/, /\d/{9}]'
,
userManageForm
:
{
username
:
''
,
realname
:
''
,
password
:
''
,
mobile
:
''
,
registeredIP
:
''
,
email
:
''
,
state
:
''
,
isadmin
:
''
,
departName
:
''
,
roles
:
[],
options
:
[{
value
:
'选项1'
,
label
:
'总经办'
},
{
value
:
'选项2'
,
label
:
'研发中心-网络软件部'
}]
},
tel
:
'[ 1, /[34578]/, /d/{9}]'
,
value
:
''
,
list
:
[
{
id
:
1
,
rolename
:
'诺威达-艺展-系统日志上报'
},
{
id
:
2
,
rolename
:
'盗抢险'
},
{
id
:
3
,
rolename
:
'研发工具-增量'
},
{
id
:
4
,
rolename
:
'精品分期0329角色'
},
{
id
:
5
,
rolename
:
'云商分润'
},
{
id
:
6
,
rolename
:
'营销系统'
},
{
id
:
7
,
rolename
:
'GPS后台角色控制'
},
{
id
:
8
,
rolename
:
'外场测试'
}
],
rules
:
{
username
:
[
{
required
:
true
,
message
:
'请输入用户名'
,
trigger
:
'blur'
},
...
...
@@ -155,19 +177,23 @@ export default {
},
methods
:
{
message
(
message
,
type
)
{
type
&&
this
.
$message
({
showClose
:
true
,
type
:
type
,
message
:
message
})
!
type
&&
this
.
$message
({
showClose
:
true
,
message
:
message
})
type
&&
this
.
$message
({
showClose
:
true
,
type
:
type
,
message
:
message
})
!
type
&&
this
.
$message
({
showClose
:
true
,
message
:
message
})
},
submitForm
(
formName
)
{
this
.
$refs
[
formName
].
validate
(
(
valid
)
=>
{
this
.
$refs
[
formName
].
validate
(
valid
=>
{
const
userData
=
this
.
$deep_clone
(
this
.
userManageForm
)
// userData.roles = userData.roles.join(',')
console
.
log
(
userData
.
roles
)
const
isflagId
=
userData
.
id
if
(
valid
)
{
this
.
$emit
(
'userFormData'
,
isflagId
,
userData
)
...
...
@@ -183,11 +209,10 @@ export default {
}
</
script
>
<
style
scoped
>
.el-checkbox
+
.el-checkbox
{
margin-left
:
0
!important
;
.el-checkbox
+
.el-checkbox
{
margin-left
:
0
!important
;
}
</
style
>
<
style
>
</
style
>
src/config/common.conf.js
View file @
ac388b3
export
default
{
axios
:
{
//
baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/',
baseURL
:
'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/'
,
baseURL
:
'http://cas.dev.glsx.net/admin-operating-auth/'
,
//
baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/',
whiteList
:
[
'role/deleteRoleById'
,
'role/deleteUserRoleById'
,
'role/getRoleDetail'
,
'role/getRoleDetail'
,
'role/getRoleList'
,
'role/isRoleNameExit'
,
'role/saveRoleList'
,
'role/selectMenuTreeRoleId'
,
'role/selectUserRoleByRoleId'
,
'role/updateRole'
,
'user/batcheDel'
,
'user/findAll'
,
'user/get'
,
'user/getWithRoles'
,
'user/operatUser'
,
'user/updateUser'
,
'department/del'
,
'department/findTree'
,
'department/getPName'
,
'department/getTreeNode'
,
'department/updateDepartment'
,
'menu/add'
,
'menu/del'
,
'menu/edit'
,
'menu/findById'
,
'menu/findTree'
,
'menu/getByUserId'
,
'menu/getPName'
],
timeout
:
15000
,
result
:
{
...
...
src/views/customer/user/index.vue
View file @
ac388b3
...
...
@@ -8,9 +8,9 @@
<hr>
<div
class=
"default p-t15"
>
<div
class=
"control-tabledata-button"
>
<gl-button
size=
"small"
@
click=
"createUser(
editUser=
{}
)">新增用户
</gl-button>
<gl-button
size=
"small"
@
click=
"createUser()"
>
新增用户
</gl-button>
<gl-button
size=
"small"
@
click=
"toggleRowSelection"
>
删除选中
</gl-button>
<user-create
:dialogFormVisible=
"dialogFormVisible"
:
editUser=
"editUser
"
@
userFormData=
"handleUserFormData"
></user-create>
<user-create
:dialogFormVisible=
"dialogFormVisible"
:
userManageForm=
"userManageForm
"
@
userFormData=
"handleUserFormData"
></user-create>
</div>
<div
class=
"m-b8"
>
<gl-table
:table=
"userData"
ref=
"multipleTable"
></gl-table>
...
...
@@ -25,20 +25,43 @@
<
script
>
import
{
UserCreate
,
UserDetail
}
from
'@/components/index'
// 接口
import
{
findAll
}
from
'@/api/api'
import
{
findAll
,
updateUser
,
getRoleList
}
from
'@/api/api'
import
{
userDetailColumn
}
from
'@/common/commonConst'
export
default
{
name
:
'user'
,
components
:
{
UserCreate
,
UserDetail
UserDetail
,
updateUser
},
data
()
{
return
{
userName
:
''
,
toggle
:
[],
dialogFormVisible
:
false
,
editUser
:
{},
userManageForm
:
{},
userForm
:
{
username
:
''
,
realname
:
''
,
password
:
''
,
mobile
:
''
,
joinip
:
''
,
email
:
''
,
state
:
''
,
isadmin
:
''
,
departName
:
''
,
roles
:
[
'1'
,
'2'
],
options
:
[
{
value
:
'1'
,
label
:
'总经办'
},
{
value
:
'2'
,
label
:
'研发中心-网络软件部'
}
]
},
userDetailVisible
:
false
,
userDetailTitle
:
'用户详情'
,
// 分页所需参数-start
...
...
@@ -96,20 +119,20 @@ export default {
label
:
'详细'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
this
.
$alert
(
rows
[
index
])
this
.
handleGetUserDetail
()
// this.$alert(rows[index])
}
},
{
label
:
'
删除
'
,
label
:
'
禁用
'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
this
.
confirmDeleteOrNot
(
index
,
rows
)
this
.
$alert
(
rows
[
index
]
)
}
},
{
label
:
'
用户
'
,
label
:
'
删除
'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
this
.
handleGetUserDetail
()
// this.$alert(rows[index])
this
.
confirmDeleteOrNot
(
index
,
rows
)
}
}]
},
...
...
@@ -120,6 +143,7 @@ export default {
},
mounted
()
{
this
.
findUserList
()
this
.
getRoleOptions
()
},
methods
:
{
// 获取所需字段
...
...
@@ -152,24 +176,41 @@ export default {
message
:
message
})
},
// 获取所有角色选项
getRoleOptions
()
{
getRoleList
.
req
().
then
(
res
=>
{
console
.
log
(
res
)
})
},
// 新增更新用户接口请求
updateUser_Post
(
params
)
{
if
(
params
)
{
updateUser
.
req
(
params
).
then
(
res
=>
{
console
.
log
(
res
)
})
}
else
{
console
.
log
(
'no data!'
)
}
},
// 接受子组件传递的值
handleUserFormData
(
isflag
,
params
)
{
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
// this.userManageForm = {}
!
params
&&
this
.
message
(
'取消操作'
)
params
&&
!
isflag
&&
this
.
userDataCreate
(
params
)
params
&&
isflag
&&
this
.
message
(
'已经成功修改数据!'
,
'success'
)
this
.
updateUser_Post
(
params
)
},
// 新增按钮
createUser
(
editUser
)
{
console
.
log
(
editUser
)
this
.
editUser
=
editUser
createUser
(
userManageForm
)
{
this
.
userManageForm
=
userManageForm
?
this
.
$deep_clone
(
userManageForm
)
:
this
.
userForm
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
},
// 新增事件
userDataCreate
(
params
)
{
// this.dateFormat()
params
.
id
=
'100'
+
this
.
userData
.
data
.
length
params
.
createTime
=
this
.
dateFormat
()
//
params.id = '100' + this.userData.data.length
//
params.createTime = this.dateFormat()
const
newData
=
params
// { id: '100' + this.userData.data.length, username: params.username, realname: params.realname, isadmin: params.isadmin, mobile: params.mobile, state: params.state, createTime: this.dateFormat() }
this
.
userData
.
data
.
push
(
newData
)
...
...
@@ -192,23 +233,21 @@ export default {
const
m
=
zeroize
(
currentTime
.
getHours
())
const
s
=
zeroize
(
currentTime
.
getSeconds
())
const
createTime
=
year
+
'-'
+
month
+
'-'
+
day
+
' '
+
h
+
':'
+
m
+
':'
+
s
console
.
log
(
createTime
)
return
createTime
},
// 获取选中的行
handleSelectionChange
(
val
,
row
)
{
// this.multipleSelection = val
this
.
toggle
=
val
console
.
log
(
this
.
toggle
)
},
// 删除选中的行
toggleRowSelection
()
{
console
.
log
(
this
.
$refs
.
multipleTable
,
this
.
toggle
)
if
(
this
.
toggle
)
{
this
.
toggle
.
forEach
(
row
=>
{
this
.
userData
.
data
.
splice
(
this
.
toggle
,
1
)
// this.$refs.multipleTable.$refs.table.toggleRowSelection(row)
})
}
else
{
// this.$refs.multipleTable.clearSelection(
)
this
.
message
(
''
,
'操作失败'
)
}
},
finduserName
()
{
...
...
@@ -224,9 +263,6 @@ export default {
this
.
pageNum
=
val
this
.
findUserList
()
},
delteSelected
(
val
)
{
console
.
log
(
val
)
},
confirmDeleteOrNot
(
index
,
rows
)
{
this
.
$confirm
(
'确定要删除这条数据?'
,
''
,
{
confirmButtonTest
:
'确定'
,
...
...
@@ -259,9 +295,9 @@ export default {
</
script
>
<
style
scoped
>
.search-w250
{
width
:
250px
;
width
:
250px
;
}
.m-b8
{
margin-bottom
:
8px
;
margin-bottom
:
8px
;
}
</
style
>
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment