Commit d4cbe9f6 by cwq0219

各个组件loading;代码梳理;提示

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