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 d4cbe9f6
authored
Oct 30, 2018
by
cwq0219
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
各个组件loading;代码梳理;提示
1 parent
7a37243a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
286 additions
and
98 deletions
src/common/commonConst.js
src/common/notice.js
src/common/roleConst.js
src/common/userConst.js
src/components/RightForm/src/main.vue
src/components/RoleCreate/src/main.vue
src/components/UserDetail/src/main.vue
src/views/customer/role/index.vue
src/views/customer/user/index.vue
src/common/commonConst.js
View file @
d4cbe9f
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
}
from
'./roleConst'
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
}
from
'./roleConst'
import
{
userForm
,
userDetailColumn
}
from
'./userConst'
function
fn
(
data
,
pid
)
{
...
...
@@ -20,7 +20,6 @@ export {
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
,
userDetailColumn
,
userForm
,
fn
...
...
src/common/notice.js
View file @
d4cbe9f
import
Vue
from
'vue'
import
{
deleteUserRoleById
}
from
'@/api/api'
export
default
new
Vue
({
methods
:
{
confirmTips
(
conMessage
,
source
,
index
,
rows
,
roleLoadingParams
)
{
this
.
$confirm
(
conMessage
,
''
,
{
conirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
if
(
source
===
'userRoleDetail'
)
{
roleLoadingParams
.
loading
=
true
this
.
deleteUserRole
(
index
,
rows
,
roleLoadingParams
)
}
}).
catch
(()
=>
{})
},
deleteUserRole
(
index
,
rows
,
roleLoadingParams
)
{
const
data
=
rows
[
index
]
const
params
=
{
roleId
:
data
.
roleId
,
userId
:
data
.
userId
}
// clearTimeout(timer)
// var timer = setTimeout(() => {
deleteUserRoleById
.
req
(
params
).
then
(()
=>
{
this
.
okTips
(
`删除成功`
)
roleLoadingParams
.
freshList
=
true
// roleLoadingParams.loading = false
// rows.splice(index, 1)
}).
catch
(
err
=>
{
roleLoadingParams
.
loading
=
false
this
.
errorTips
(
err
)
})
// }, 2000)
},
warningTips
(
message
)
{
this
.
$notify
({
type
:
'warning'
,
title
:
message
})
},
okTips
(
message
)
{
this
.
$notify
({
type
:
'success'
,
...
...
src/common/roleConst.js
View file @
d4cbe9f
import
{
deleteUserRoleById
}
from
'@/api/api'
import
notice
from
'./notice'
const
roleCreateStructure
=
{
id
:
Number
,
roleName
:
''
,
...
...
@@ -54,32 +51,8 @@ const userRoleDetailColumn = [{
}
}]
const
userRoleDetailConsole
=
{
show
:
true
,
label
:
'操作'
,
prop
:
'option'
,
button
:
[{
label
:
'删除'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
const
data
=
rows
[
index
]
const
params
=
{
roleId
:
data
.
roleId
,
userId
:
data
.
userId
}
deleteUserRoleById
.
req
(
params
).
then
(
res
=>
{
notice
.
okTips
(
'删除成功'
)
rows
.
splice
(
index
,
1
)
}).
catch
(
err
=>
{
notice
.
errorTips
(
err
)
})
}
}]
}
export
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
userRoleDetailColumn
}
src/common/userConst.js
View file @
d4cbe9f
...
...
@@ -38,7 +38,6 @@ const userDetailColumn = [{
label
:
'状态'
,
prop
:
'state'
,
formatter
:
(
cellValue
)
=>
{
console
.
log
(
cellValue
)
return
cellValue
.
state
<
1
?
'禁用'
:
'启动'
}
}]
...
...
src/components/RightForm/src/main.vue
View file @
d4cbe9f
...
...
@@ -32,8 +32,8 @@
<div
v-show=
"err && index === 0"
class=
"err"
>
{{
textName
}}
</div>
</gl-form-item>
<gl-form-item>
<gl-button
type=
"primary"
@
click=
"submit"
>
{{
value
.
btnTxt
}}
</gl-button>
<gl-button
type=
"danger"
v-show=
'value.del'
@
click=
"dialog = true "
>
删除
</gl-button>
<gl-button
type=
"primary"
@
click=
"submit"
:loading=
"subLoading"
>
{{
value
.
btnTxt
}}
</gl-button>
<gl-button
type=
"danger"
v-show=
'value.del'
@
click=
"dialog = true "
:loading=
"delLoading"
>
删除
</gl-button>
<gl-button
@
click=
'value.showDetails = false'
style=
"float:right"
>
取消
</gl-button>
</gl-form-item>
</gl-form>
...
...
@@ -52,6 +52,7 @@
</
template
>
<
script
type=
'text/ecmascript-6'
>
import
{
delDepartment
,
delMenu
,
editMenu
,
addMenu
,
updateDepartment
}
from
'@/api/api'
import
notice
from
'@/common/notice'
const
reg
=
new
RegExp
(
/^
[
0-9
]
*$/
)
export
default
{
name
:
'rightForm'
,
...
...
@@ -63,6 +64,8 @@ export default {
errExist
:
false
,
textExist
:
''
,
errIorder
:
false
,
subLoading
:
false
,
delLoading
:
false
,
textType
:
'请填写数字'
}
},
...
...
@@ -93,10 +96,10 @@ export default {
this
.
errExist
=
false
this
.
textExist
=
''
},
nameExitTip
(
err
)
{
this
.
errExist
=
true
this
.
textExist
=
err
},
//
nameExitTip(err) {
//
this.errExist = true
//
this.textExist = err
//
},
getMenuObj
(
obj
=
{})
{
for
(
const
key
in
this
.
value
.
form
)
{
obj
[
key
]
=
this
.
value
.
form
[
key
]
...
...
@@ -108,30 +111,45 @@ export default {
},
// 接口调用-start
addOrEditDepart
(
params
)
{
// clearTimeout(timer)
// var timer = setTimeout(() => {
updateDepartment
.
req
(
params
).
then
(
res
=>
{
this
.
subLoading
=
false
this
.
Tip
(
true
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
subLoading
=
false
notice
.
errorTips
(
err
)
// console.log(err)
})
// }, 2000)
},
// 接口调用-end
// 删除
delData
()
{
this
.
delLoading
=
true
const
obj
=
this
.
getMenuObj
()
obj
.
isHidden
=
this
.
value
.
form
.
isHidden
===
true
?
0
:
1
this
.
dialog
=
false
// clearTimeout(timer)
// var timer = setTimeout(() => {
this
.
isDepart
?
delDepartment
.
req
(
obj
).
then
(
res
=>
{
this
.
delLoading
=
false
this
.
delTip
(
true
)
}).
catch
(
err
=>
{
this
.
delLoading
=
false
console
.
log
(
err
)
this
.
delErrTip
()
})
:
delMenu
.
req
({
menuId
:
obj
.
id
}).
then
(
res
=>
{
this
.
delLoading
=
false
this
.
delTip
(
true
)
}).
catch
(
err
=>
{
this
.
delLoading
=
false
console
.
log
(
err
)
this
.
delErrTip
()
})
// }, 2000)
},
delTip
(
val
)
{
if
(
val
)
{
...
...
@@ -145,13 +163,14 @@ export default {
})
this
.
value
.
showDetails
=
false
this
.
value
.
updateTree
=
!
this
.
value
.
updateTree
}
else
{
this
.
$notify
({
title
:
'已取消'
,
type
:
'info'
})
}
this
.
dialog
=
false
// else {
// this.$notify({
// title: '已取消',
// type: 'info'
// })
// }
// this.dialog = false
},
delErrTip
()
{
this
.
$notify
({
...
...
@@ -165,6 +184,7 @@ export default {
const
treeData
=
this
.
value
.
allNode
if
(
this
.
value
.
form
[
this
.
form
[
0
].
value
]
!==
''
&&
this
.
value
.
form
[
this
.
form
[
0
].
value
]
!==
null
)
{
const
obj
=
this
.
getMenuObj
()
this
.
subLoading
=
true
obj
.
isHidden
=
this
.
value
.
form
.
isHidden
===
true
?
0
:
1
// 添加同级
if
(
this
.
value
.
sublings
)
{
...
...
@@ -173,6 +193,7 @@ export default {
}
else
{
obj
.
parentId
=
treeData
.
parent
}
// this.subLoading = true
this
.
addData
(
obj
)
// 添加子级
}
else
if
(
this
.
value
.
children
)
{
...
...
@@ -181,13 +202,19 @@ export default {
// 修改
}
else
{
if
(
!
this
.
isDepart
)
{
// clearTimeout(timer)
// var timer = setTimeout(() => {
editMenu
.
req
(
obj
).
then
(
res
=>
{
this
.
subLoading
=
false
this
.
Tip
(
true
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
subLoading
=
false
this
.
Tip
(
false
)
})
// }, 2000)
}
else
{
this
.
subLoading
=
true
this
.
addOrEditDepart
(
obj
)
}
}
...
...
@@ -201,15 +228,22 @@ export default {
return
new
Date
(
time
).
getTime
()
},
addData
(
obj
)
{
// clearTimeout(timer)
// var timer = setTimeout(() => {
if
(
!
this
.
isDepart
)
{
addMenu
.
req
(
obj
).
then
(
res
=>
{
this
.
subLoading
=
false
this
.
Tip
(
true
)
}).
catch
(
err
=>
{
this
.
nameExitTip
(
err
)
this
.
subLoading
=
false
notice
.
errorTips
(
err
)
// this.nameExitTip(err)
})
}
else
{
this
.
errIorder
=
true
this
.
addOrEditDepart
(
obj
)
}
// }, 2000)
},
Tip
(
val
)
{
if
(
val
)
{
...
...
src/components/RoleCreate/src/main.vue
View file @
d4cbe9f
<!-- createRoleComponent -->
<
template
>
<gl-dialog
:title=
"title"
:visible
.
sync=
"createVisible"
:before-close=
"handleCreateCancel"
>
<gl-form
:model=
"createRuleForm"
:rules=
"createRules"
ref=
"createRuleForm"
label-width=
"10
5
px"
>
<gl-form
:model=
"createRuleForm"
:rules=
"createRules"
ref=
"createRuleForm"
label-width=
"10
0
px"
>
<gl-form-item
label=
"角色名称:"
prop=
"roleName"
>
<gl-input
name=
"roleName"
data-vv-as=
"角色名称"
v-validate=
"'required'"
v-model=
"createRuleForm.roleName"
clearable
></gl-input>
<span
v-show=
"errorBags.has('roleName')"
class=
"error"
>
{{
errorBags
.
first
(
'roleName'
)
}}
</span>
...
...
@@ -39,7 +39,7 @@
:defaultExpandAll=
"defaultExpandAll"
:defaultCheckedKeys=
"defaultCheckedKeys"
@
input=
"getMenuOption"
style=
"height:1
6
0px"
style=
"height:1
8
0px"
:keyFresh=
"keyFresh"
>
</tree>
<span
v-show=
"errorBags.has('rights')"
class=
"error"
>
{{
errorBags
.
first
(
'rights'
)
}}
</span>
...
...
@@ -148,6 +148,9 @@ export default {
}
</
script
>
<
style
scoped
>
.dialog-footer
{
margin-top
:
-40px
;
}
.err
{
color
:
red
;
}
...
...
src/components/UserDetail/src/main.vue
View file @
d4cbe9f
...
...
@@ -2,7 +2,7 @@
<
template
>
<div>
<gl-dialog
:title=
"userDetailTitle"
:visible
.
sync=
"userDetailVisible"
:before-close=
"handleClose"
>
<gl-table
:table=
"tableParam"
></gl-table>
<gl-table
:table=
"tableParam"
v-loading=
"roleLoadingParams.loading"
gl-loading-text=
"拼命加载中"
></gl-table>
<gl-pagination
background
v-show=
"flagRoleOrUser"
...
...
@@ -18,6 +18,8 @@
<
script
>
import
{
selectUserRoleByRoleId
}
from
'@/api/api'
import
notice
from
'@/common/notice'
export
default
{
name
:
'UserDetail'
,
props
:
{
...
...
@@ -25,33 +27,46 @@ export default {
userDetailVisible
:
Boolean
,
apiParam
:
[
Object
,
Function
],
flagRoleOrUser
:
[
Boolean
,
Function
],
columnParam
:
Array
,
consoleParam
:
[
Array
,
Object
]
columnParam
:
Array
},
watch
:
{
columnParam
(
val
)
{
this
.
tableParam
.
column
=
val
},
consoleParam
(
val
)
{
this
.
tableParam
.
console
=
val
this
.
flagRoleOrUser
&&
(
this
.
tableParam
.
console
=
this
.
userRoleDetailConsole
)
},
apiParam
(
val
)
{
this
.
id
=
val
.
id
this
.
id
&&
this
.
callApi
()
},
'roleLoadingParams.freshList'
(
val
)
{
val
&&
this
.
callApi
()
}
},
data
()
{
return
{
pageNum
:
1
,
pageSize
:
5
,
total
:
10
,
total
:
5
,
id
:
Number
,
roleLoadingParams
:
{
loading
:
false
,
freshList
:
false
},
userRoleDetailConsole
:
{
show
:
true
,
label
:
'操作'
,
prop
:
'option'
,
button
:
[{
label
:
'删除'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
notice
.
confirmTips
(
'确定要删除该用户吗?'
,
'userRoleDetail'
,
index
,
rows
,
this
.
roleLoadingParams
)
}
}]
},
tableParam
:
{
border
:
true
,
align
:
'center'
,
data
:
[],
column
:
[],
console
:
[]
console
:
{}
}
}
},
...
...
@@ -66,19 +81,29 @@ export default {
// 获取角色的相关用户详细信息
selectUser
()
{
const
params
=
this
.
getRoleParams
()
// clearTimeout(timer)
// var timer = setTimeout(() => {
selectUserRoleByRoleId
.
req
(
params
).
then
(
res
=>
{
this
.
total
=
res
.
total
this
.
tableParam
.
data
=
res
.
list
this
.
roleLoadingParams
.
loading
=
false
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
roleLoadingParams
.
loading
=
false
notice
.
errorTips
(
err
)
})
// }, 2000)
},
callApi
()
{
this
.
flagRoleOrUser
&&
this
.
selectUser
()
!
this
.
flagRoleOrUser
&&
(
this
.
tableParam
.
data
=
[
this
.
apiParam
])
this
.
flagRoleOrUser
&&
(
this
.
roleLoadingParams
.
loading
=
true
)
this
.
flagRoleOrUser
?
this
.
selectUser
()
:
(
this
.
tableParam
.
data
=
[
this
.
apiParam
])
this
.
roleLoadingParams
.
freshList
=
false
},
handleClose
()
{
this
.
$emit
(
'userDetailClose'
)
clearTimeout
(
timer
)
var
timer
=
setTimeout
(()
=>
{
this
.
pageNum
=
1
},
200
)
},
handleCurrentChange
(
val
)
{
this
.
pageNum
=
val
...
...
src/views/customer/role/index.vue
View file @
d4cbe9f
...
...
@@ -18,7 +18,7 @@
</role-create>
<div
class=
"m-b8"
>
<transition>
<gl-table
:table=
"roleData"
></gl-table>
<gl-table
:table=
"roleData"
v-loading=
"loadingTable"
gl-loading-text=
"拼命加载中"
></gl-table>
</transition>
<gl-pagination
background
@
size-change=
"handleSizeChange"
...
...
@@ -41,7 +41,6 @@
@
userDetailClose=
"handleUserDetailClose"
:apiParam=
"apiParam"
:columnParam=
"columnParam"
:consoleParam=
"consoleParam"
:flagRoleOrUser=
"flagRoleOrUser"
></user-detail>
</div>
</div>
...
...
@@ -52,7 +51,7 @@
import
{
RoleCreate
,
RoleDetail
,
UserDetail
}
from
'@/components/index'
// 接口
import
{
getRoleList
,
deleteRoleById
,
selectMenuTreeRoleId
,
saveRoleList
,
updateRole
,
findDepartTree
}
from
'@/api/api'
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
,
fn
}
from
'@/common/commonConst'
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
fn
}
from
'@/common/commonConst'
import
notice
from
'@/common/notice'
export
default
{
name
:
'role'
,
...
...
@@ -65,6 +64,7 @@ export default {
},
data
()
{
return
{
loadingTable
:
false
,
loading
:
false
,
roleName
:
''
,
createVisible
:
false
,
...
...
@@ -73,7 +73,6 @@ export default {
roleParam
:
this
.
$deep_clone
(
roleCreateStructure
),
roleMenu
:
[],
columnParam
:
[],
consoleParam
:
[],
apiParam
:
Object
,
flagRoleOrUser
:
true
,
flagCOrE
:
Boolean
,
...
...
@@ -82,6 +81,7 @@ export default {
createOrEditTitle
:
'新增角色'
,
userDetailTitle
:
'用户列表'
,
departList
:
[],
tipParams
:
''
,
// 分页所需参数-start
total
:
10
,
pageNum
:
1
,
...
...
@@ -133,7 +133,11 @@ export default {
},
watch
:
{
roleName
(
val
)
{
!
val
&&
this
.
getList
()
// !val && this.getList()
if
(
!
val
)
{
this
.
loadingTable
=
true
this
.
getList
()
}
}
},
methods
:
{
...
...
@@ -144,6 +148,7 @@ export default {
type
:
'warning'
}).
then
(()
=>
{
// 删除角色,根据返回的code值来判断是否删除成功(已有拦截器)
this
.
loadingTable
=
true
this
.
deleteRole
(
rows
[
index
].
id
)
}).
catch
(()
=>
{
})
...
...
@@ -156,25 +161,53 @@ export default {
keyWork
:
this
.
roleName
}
},
// getTips() {
// switch (this.tipParams) {
// case 'delete':
// notice.okTips('删除成功')
// break
// case 'add':
// notice.okTips('创建成功')
// break
// case 'edit':
// notice.okTips('编辑成功')
// break
// }
// },
// 接口请求-start---------------------------------------
// 获取展示数据,请求表格数据
getList
()
{
const
params
=
this
.
getParams
()
// clearTimeout(timer)
// var timer = setTimeout(() => {
getRoleList
.
req
(
params
).
then
(
res
=>
{
this
.
total
=
res
.
total
this
.
roleData
.
data
=
res
.
list
this
.
loadingTable
=
false
// this.getTips()
this
.
tipParams
=
''
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
tipParams
=
''
this
.
loadingTable
=
false
notice
.
errorTips
(
err
)
// console.log(err)
})
// }, 2000)
},
// 删除角色
deleteRole
(
params
)
{
// clearTimeout(timer)
// var timer = setTimeout(() => {
deleteRoleById
.
req
({
roleId
:
params
}).
then
(
res
=>
{
// this.tipParams = 'delete'
notice
.
okTips
(
'删除成功'
)
// this.loadingTable = false
this
.
getList
()
}).
catch
(
message
=>
{
this
.
loadingTable
=
false
notice
.
errorTips
(
message
)
})
// }, 2000)
},
roleMenuOption
(
data
,
pid
)
{
data
.
forEach
(
item
=>
{
...
...
@@ -200,30 +233,37 @@ export default {
},
// 添加角色
addRole
(
params
)
{
// clearTimeout(timer)
// var timer = setTimeout(() => {
saveRoleList
.
req
(
params
).
then
((
data
)
=>
{
this
.
createOrEditSuccess
()
}).
catch
(
err
=>
{
this
.
loading
=
false
notice
.
errorTips
(
err
)
console
.
log
(
err
)
})
this
.
loading
=
false
// }, 2000)
},
// 编辑角色
updateRoleInfo
(
params
)
{
delete
params
.
createTime
delete
params
.
updateTime
// clearTimeout(timer)
// var timer = setTimeout(() => {
updateRole
.
req
(
params
).
then
((
data
)
=>
{
this
.
createOrEditSuccess
()
}).
catch
(
err
=>
{
this
.
loading
=
false
notice
.
errorTips
(
err
)
console
.
log
(
err
)
//
console.log(err)
})
this
.
loading
=
false
// }, 2000)
},
// 获取部门树
getdepartData
()
{
findDepartTree
.
req
().
then
(
res
=>
{
this
.
departList
=
fn
(
res
,
'#'
)
}).
catch
(
err
=>
{
notice
.
errorTips
(
err
)
})
},
// 接口请求-end---------------------------------------
...
...
@@ -238,6 +278,7 @@ export default {
},
emptyParam
()
{
this
.
createDialogVisible
()
this
.
roleMenu
=
[]
clearTimeout
(
timer
)
var
timer
=
setTimeout
(()
=>
{
this
.
roleParam
=
this
.
$deep_clone
(
roleCreateStructure
)
...
...
@@ -248,19 +289,23 @@ export default {
this
.
emptyParam
()
this
.
loading
=
false
notice
.
okTips
(
this
.
flagCOrE
?
'创建角色成功!'
:
'已经成功修改数据!'
)
this
.
roleMenu
=
[]
// this.tipParams = this.flagCOrE ? 'add' : 'edit'
this
.
loadingTable
=
true
this
.
getList
()
},
// 调取接口相关函数
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
loadingTable
=
true
this
.
getList
()
},
handleCurrentChange
(
val
)
{
this
.
pageNum
=
val
this
.
loadingTable
=
true
this
.
getList
()
},
handleSearchRoleName
()
{
this
.
loadingTable
=
true
this
.
getList
()
},
handleGetRoleDetail
()
{
...
...
@@ -273,13 +318,13 @@ export default {
},
handleGetUserDetail
(
index
,
rows
)
{
this
.
columnParam
=
userRoleDetailColumn
this
.
consoleParam
=
userRoleDetailConsole
this
.
flagRoleOrUser
=
true
this
.
apiParam
=
rows
[
index
]
this
.
userDetailDialogVisible
()
},
handleUserDetailClose
()
{
this
.
userDetailDialogVisible
()
this
.
loadingTable
=
true
this
.
getList
()
this
.
apiParam
=
Object
},
...
...
@@ -291,6 +336,7 @@ export default {
handleCreateClose
(
data
)
{
if
(
!
data
)
{
this
.
emptyParam
()
// this.roleMenu = []
return
false
}
this
.
loading
=
true
...
...
src/views/customer/user/index.vue
View file @
d4cbe9f
...
...
@@ -18,7 +18,7 @@
</user-create>
</div>
<div
class=
"m-b8"
>
<gl-table
:table=
"userData"
ref=
"multipleTable"
></gl-table>
<gl-table
:table=
"userData"
v-loading=
"laodingTable"
gl-loading-text=
"拼命加载中"
ref=
"multipleTable"
></gl-table>
<gl-pagination
background
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
...
...
@@ -66,6 +66,8 @@ export default {
userManageForm
:
this
.
$deep_clone
(
userForm
),
userDetailVisible
:
false
,
loading
:
false
,
laodingTable
:
false
,
tipParams
:
''
,
userDetailTitle
:
'用户详情'
,
// 分页所需参数-start
total
:
10
,
...
...
@@ -151,16 +153,17 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
laodingTable
=
true
if
(
rows
[
index
].
state
<
1
)
{
this
.
$set
(
rows
[
index
],
'state'
,
'1'
)
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
1
})
//
this.$set(rows[index], 'state', '1')
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
1
}
,
rows
,
index
)
}
else
{
this
.
$set
(
rows
[
index
],
'state'
,
'0'
)
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
0
})
//
this.$set(rows[index], 'state', '0')
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
0
}
,
rows
,
index
)
}
notice
.
okTips
(
'修改成功'
)
//
notice.okTips('修改成功')
}).
catch
(()
=>
{
notice
.
errorTips
(
'修改失败'
)
//
notice.errorTips('修改失败')
})
}
},
{
...
...
@@ -183,7 +186,10 @@ export default {
},
watch
:
{
userName
(
val
)
{
!
val
&&
this
.
findUserList
()
if
(
!
val
)
{
this
.
laodingTable
=
true
this
.
findUserList
()
}
}
},
methods
:
{
...
...
@@ -195,15 +201,37 @@ export default {
keyWork
:
this
.
userName
}
},
// getTips() {
// switch (this.tipParams) {
// case 'delete':
// notice.okTips('删除成功')
// break
// case 'add':
// notice.okTips('新增成功')
// break
// case 'edit':
// notice.okTips('编辑成功')
// break
// }
// },
// 接口请求-start
findUserList
()
{
const
params
=
this
.
getParams
()
// clearTimeout(timer)
// var timer = setTimeout(() => {
findAll
.
req
(
params
).
then
(
res
=>
{
this
.
total
=
res
.
total
this
.
userData
.
data
=
res
.
list
this
.
laodingTable
=
false
// this.getTips(this.tipParams)
this
.
tipParams
=
''
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
tipParams
=
''
this
.
laodingTable
=
false
notice
.
errorTips
(
err
)
// console.log(err)
})
// }, 2000)
},
// 获取所有角色选项
getRoleOptions
()
{
...
...
@@ -220,10 +248,13 @@ export default {
},
// 新增更新用户接口请求
updateUser_Post
(
params
)
{
this
.
loading
=
true
updateUser
.
req
(
params
).
then
(
res
=>
{
notice
.
okTips
(
'操作成功'
)
this
.
emptyForm
()
this
.
loading
=
false
// this.loading = false
this
.
laodingTable
=
true
notice
.
okTips
(
'操作成功'
)
// this.tipParams = this.isEdit ? 'edit' : 'add'
this
.
findUserList
()
}).
catch
(
message
=>
{
notice
.
errorTips
(
message
)
...
...
@@ -232,17 +263,51 @@ export default {
},
// 删除用户接口
batcheDel
(
params
)
{
this
.
laodingTable
=
true
// clearTimeout(timer)
// var timer = setTimeout(() => {
batcheDelUser
.
req
({
ids
:
params
}).
then
(
res
=>
{
// this.tipParams = 'delete'
notice
.
okTips
(
'删除成功'
)
this
.
findUserList
()
// this.laodingTable = false
}).
catch
(
err
=>
{
this
.
laodingTable
=
false
notice
.
errorTips
(
err
)
})
// }, 2000)
},
// 删除、禁用、启用接口f
operatUser
(
params
)
{
operatUser
(
params
,
rows
,
index
)
{
// clearTimeout(timer)
// var timer = setTimeout(() => {
operatUser
.
req
(
params
).
then
(
res
=>
{
(
params
.
state
===
2
)
&&
this
.
findUserList
()
switch
(
params
.
state
)
{
case
0
:
this
.
$set
(
rows
[
index
],
'state'
,
'0'
)
this
.
laodingTable
=
false
notice
.
okTips
(
rows
[
index
].
username
+
'用户状态已禁用'
)
break
case
1
:
this
.
$set
(
rows
[
index
],
'state'
,
'1'
)
this
.
laodingTable
=
false
notice
.
okTips
(
rows
[
index
].
username
+
'用户状态已启动'
)
break
case
2
:
// this.tipParams = 'delete'
notice
.
okTips
(
'删除成功'
)
this
.
findUserList
()
// this.laodingTable = false
break
}
}).
catch
(
err
=>
{
this
.
laodingTable
=
false
notice
.
errorTips
(
err
)
})
// }, 2000)
},
emptyForm
()
{
this
.
loading
=
false
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
clearTimeout
(
timer
)
var
timer
=
setTimeout
(()
=>
{
...
...
@@ -251,20 +316,19 @@ export default {
},
// 接受子组件传递的值
handleUserFormData
(
isEdit
,
params
)
{
this
.
loading
=
true
params
&&
this
.
updateUser_Post
(
params
)
!
params
&&
this
.
emptyForm
()
},
// 新增按钮
createUser
()
{
this
.
loading
=
false
//
this.loading = false
this
.
userManageForm
=
this
.
$deep_clone
(
userForm
)
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
this
.
isEdit
=
false
},
// 编辑按钮
editUser
(
row
)
{
this
.
loading
=
false
//
this.loading = false
row
.
password
=
''
row
.
roleList
=
this
.
$deep_clone
(
userForm
.
roleList
)
row
.
departList
=
this
.
$deep_clone
(
userForm
.
departList
)
...
...
@@ -299,30 +363,33 @@ export default {
this
.
toggle
.
forEach
(
row
=>
{
ids
.
push
(
row
.
id
+
''
)
})
this
.
$confirm
(
'确定要删除这条数据?'
,
''
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消
'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
batcheDel
(
ids
.
join
(
','
))
notice
.
okTips
(
'删除成功'
)
}).
catch
(
err
=>
{
notice
.
errorTips
(
err
)
// console.log('error'
)
}
)
ids
.
length
?
this
.
$confirm
(
'确定要删除这条数据?'
,
''
,
{
confirmButtonText
:
'确定
'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
batcheDel
(
ids
.
join
(
','
)
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
}
)
:
notice
.
warningTips
(
'请选中你需要删除的用户'
)
}
},
// 搜索
finduserName
()
{
this
.
laodingTable
=
true
this
.
findUserList
()
},
// 调取接口相关函数 分页
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
laodingTable
=
true
this
.
findUserList
()
},
handleCurrentChange
(
val
)
{
this
.
pageNum
=
val
this
.
laodingTable
=
true
this
.
findUserList
()
},
// 单行删除
...
...
@@ -332,8 +399,10 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
laodingTable
=
true
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
2
})
notice
.
okTips
(
'成功删除该用户'
)
// this.laodingTable = false
// notice.okTips('成功删除该用户')
}).
catch
(()
=>
{
})
},
...
...
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