Commit 90966f7c by cwq0219

菜单部门提示;loading优化

1 parent 284c7c08
...@@ -23,18 +23,13 @@ export default new Vue({ ...@@ -23,18 +23,13 @@ export default new Vue({
roleId: data.roleId, roleId: data.roleId,
userId: data.userId userId: data.userId
} }
// clearTimeout(timer)
// var timer = setTimeout(() => {
deleteUserRoleById.req(params).then(() => { deleteUserRoleById.req(params).then(() => {
this.okTips(`删除成功`) this.okTips(`删除成功`)
roleLoadingParams.freshList = true roleLoadingParams.freshList = true
// roleLoadingParams.loading = false
// rows.splice(index, 1)
}).catch(err => { }).catch(err => {
roleLoadingParams.loading = false roleLoadingParams.loading = false
this.errorTips(err) this.errorTips(err)
}) })
// }, 2000)
}, },
warningTips(message) { warningTips(message) {
this.$notify({ this.$notify({
......
...@@ -63,6 +63,7 @@ export default { ...@@ -63,6 +63,7 @@ export default {
this.clearFrom() this.clearFrom()
}, },
clearFrom() { clearFrom() {
// console.log(this.value.form)
this.value.showDetails = true this.value.showDetails = true
this.value.btnTxt = '保存' this.value.btnTxt = '保存'
this.value.del = false this.value.del = false
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
v-model="value.form[i.value]" v-model="value.form[i.value]"
:disabled="i.disabled"> :disabled="i.disabled">
</gl-input> </gl-input>
<div v-show="err && index === 0" class="err">{{textName}}</div> <span v-show="err && index === 0" class="err">{{textName}}</span>
<span v-show="errExist && index === 0" class="err">{{textExist}}</span>
<span v-show="errOpenstyle && !isDepart && index === 2" class="err">请选择打开模式</span>
</gl-form-item> </gl-form-item>
<gl-form-item> <gl-form-item>
<gl-button type="primary" @click="submit" :loading="subLoading">{{value.btnTxt}}</gl-button> <gl-button type="primary" @click="submit" :loading="subLoading">{{value.btnTxt}}</gl-button>
...@@ -63,10 +65,10 @@ export default { ...@@ -63,10 +65,10 @@ export default {
textName: this.isDepart ? '请填写部门名称' : '请填写列表名称', textName: this.isDepart ? '请填写部门名称' : '请填写列表名称',
errExist: false, errExist: false,
textExist: '', textExist: '',
errOpenstyle: false,
errIorder: false, errIorder: false,
subLoading: false, subLoading: false,
delLoading: false, delLoading: false
textType: '请填写数字'
} }
}, },
props: { props: {
...@@ -78,9 +80,16 @@ export default { ...@@ -78,9 +80,16 @@ export default {
isDepart: Boolean isDepart: Boolean
}, },
watch: { watch: {
'value.showDetails'(val) {
this.err = false
this.errOpenstyle = false
},
'value.form.urlName'(val) { 'value.form.urlName'(val) {
if (val !== '') this.nameTip() if (val !== '') this.nameTip()
}, },
'value.form.openStyle'(val) {
if (val !== null) this.openStyleTip()
},
'value.form.name'(val) { 'value.form.name'(val) {
if (val !== '') this.nameTip() if (val !== '') this.nameTip()
} }
...@@ -96,10 +105,14 @@ export default { ...@@ -96,10 +105,14 @@ export default {
this.errExist = false this.errExist = false
this.textExist = '' this.textExist = ''
}, },
// nameExitTip(err) { openStyleTip() {
// this.errExist = true this.errOpenstyle = false
// this.textExist = err this.openText = ''
// }, },
nameExitTip(err) {
this.errExist = true
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]
...@@ -111,17 +124,13 @@ export default { ...@@ -111,17 +124,13 @@ 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.subLoading = false
this.Tip(true) this.Tip(true)
}).catch(err => { }).catch(err => {
this.subLoading = false this.subLoading = false
notice.errorTips(err) notice.errorTips(err)
// console.log(err)
}) })
// }, 2000)
}, },
// 接口调用-end // 接口调用-end
// 删除 // 删除
...@@ -130,8 +139,6 @@ export default { ...@@ -130,8 +139,6 @@ export default {
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 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.delLoading = false
...@@ -149,7 +156,6 @@ export default { ...@@ -149,7 +156,6 @@ export default {
console.log(err) console.log(err)
this.delErrTip() this.delErrTip()
}) })
// }, 2000)
}, },
delTip(val) { delTip(val) {
if (val) { if (val) {
...@@ -164,13 +170,6 @@ export default { ...@@ -164,13 +170,6 @@ 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
}, },
delErrTip() { delErrTip() {
this.$notify({ this.$notify({
...@@ -182,7 +181,7 @@ export default { ...@@ -182,7 +181,7 @@ export default {
// 保存修改 // 保存修改
submit() { submit() {
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 && (this.value.form[this.form[2].value] !== null || this.isDepart)) {
const obj = this.getMenuObj() const obj = this.getMenuObj()
this.subLoading = true this.subLoading = true
obj.isHidden = this.value.form.isHidden === true ? 0 : 1 obj.isHidden = this.value.form.isHidden === true ? 0 : 1
...@@ -193,7 +192,6 @@ export default { ...@@ -193,7 +192,6 @@ 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) {
...@@ -203,8 +201,6 @@ export default { ...@@ -203,8 +201,6 @@ 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.subLoading = false
this.Tip(true) this.Tip(true)
...@@ -213,15 +209,18 @@ export default { ...@@ -213,15 +209,18 @@ export default {
this.subLoading = false this.subLoading = false
this.Tip(false) this.Tip(false)
}) })
// }, 2000)
} else { } else {
this.subLoading = true this.subLoading = true
this.addOrEditDepart(obj) this.addOrEditDepart(obj)
} }
} }
} else { }
if (this.value.form[this.form[0].value] === '' || this.value.form[this.form[0].value] === null) {
this.err = true this.err = true
} }
if (this.value.form[this.form[2].value] === null && !this.isDepart) {
this.errOpenstyle = true
}
}, },
unix(time) { unix(time) {
time = time.substring(0, 19) time = time.substring(0, 19)
...@@ -229,8 +228,6 @@ export default { ...@@ -229,8 +228,6 @@ 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.subLoading = false
...@@ -238,13 +235,12 @@ export default { ...@@ -238,13 +235,12 @@ export default {
}).catch(err => { }).catch(err => {
this.subLoading = false this.subLoading = false
notice.errorTips(err) notice.errorTips(err)
// this.nameExitTip(err) this.nameExitTip(err)
}) })
} else { } else {
this.errIorder = true this.errIorder = true
this.addOrEditDepart(obj) this.addOrEditDepart(obj)
} }
// }, 2000)
}, },
Tip(val) { Tip(val) {
if (val) { if (val) {
......
...@@ -81,8 +81,6 @@ export default { ...@@ -81,8 +81,6 @@ 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
...@@ -91,7 +89,6 @@ export default { ...@@ -91,7 +89,6 @@ export default {
this.roleLoadingParams.loading = false this.roleLoadingParams.loading = false
notice.errorTips(err) notice.errorTips(err)
}) })
// }, 2000)
}, },
callApi() { callApi() {
this.flagRoleOrUser && (this.roleLoadingParams.loading = true) this.flagRoleOrUser && (this.roleLoadingParams.loading = true)
......
...@@ -161,53 +161,30 @@ export default { ...@@ -161,53 +161,30 @@ 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.loadingTable = false
// this.getTips()
this.tipParams = '' this.tipParams = ''
}).catch(err => { }).catch(err => {
this.tipParams = '' this.tipParams = ''
this.loadingTable = false this.loadingTable = false
notice.errorTips(err) 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 this.loadingTable = false
notice.errorTips(message) notice.errorTips(message)
}) })
// }, 2000)
}, },
roleMenuOption(data, pid) { roleMenuOption(data, pid) {
data.forEach(item => { data.forEach(item => {
...@@ -233,30 +210,23 @@ export default { ...@@ -233,30 +210,23 @@ 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 this.loading = false
notice.errorTips(err) notice.errorTips(err)
}) })
// }, 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 this.loading = false
notice.errorTips(err) notice.errorTips(err)
// console.log(err)
}) })
// }, 2000)
}, },
// 获取部门树 // 获取部门树
getdepartData() { getdepartData() {
...@@ -285,11 +255,9 @@ export default { ...@@ -285,11 +255,9 @@ export default {
}, 200) }, 200)
}, },
createOrEditSuccess() { createOrEditSuccess() {
// this.createDialogVisible()
this.emptyParam() this.emptyParam()
this.loading = false this.loading = false
notice.okTips(this.flagCOrE ? '创建角色成功!' : '已经成功修改数据!') notice.okTips(this.flagCOrE ? '创建角色成功!' : '已经成功修改数据!')
// this.tipParams = this.flagCOrE ? 'add' : 'edit'
this.loadingTable = true this.loadingTable = true
this.getList() this.getList()
}, },
...@@ -336,7 +304,6 @@ export default { ...@@ -336,7 +304,6 @@ 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
......
...@@ -155,16 +155,11 @@ export default { ...@@ -155,16 +155,11 @@ export default {
}).then(() => { }).then(() => {
this.laodingTable = true this.laodingTable = true
if (rows[index].state < 1) { if (rows[index].state < 1) {
// this.$set(rows[index], 'state', '1')
this.operatUser({ id: rows[index].id, state: 1 }, rows, index) this.operatUser({ id: rows[index].id, state: 1 }, rows, index)
} else { } else {
// this.$set(rows[index], 'state', '0')
this.operatUser({ id: rows[index].id, state: 0 }, rows, index) this.operatUser({ id: rows[index].id, state: 0 }, rows, index)
} }
// notice.okTips('修改成功') }).catch(() => {})
}).catch(() => {
// notice.errorTips('修改失败')
})
} }
}, { }, {
label: '删除', label: '删除',
...@@ -201,37 +196,19 @@ export default { ...@@ -201,37 +196,19 @@ 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.laodingTable = false
// this.getTips(this.tipParams)
this.tipParams = '' this.tipParams = ''
}).catch(err => { }).catch(err => {
this.tipParams = '' this.tipParams = ''
this.laodingTable = false this.laodingTable = false
notice.errorTips(err) notice.errorTips(err)
// console.log(err)
}) })
// }, 2000)
}, },
// 获取所有角色选项 // 获取所有角色选项
getRoleOptions() { getRoleOptions() {
...@@ -251,10 +228,8 @@ export default { ...@@ -251,10 +228,8 @@ export default {
this.loading = true this.loading = true
updateUser.req(params).then(res => { updateUser.req(params).then(res => {
this.emptyForm() this.emptyForm()
// this.loading = false
this.laodingTable = true this.laodingTable = true
notice.okTips('操作成功') notice.okTips('操作成功')
// this.tipParams = this.isEdit ? 'edit' : 'add'
this.findUserList() this.findUserList()
}).catch(message => { }).catch(message => {
notice.errorTips(message) notice.errorTips(message)
...@@ -264,23 +239,16 @@ export default { ...@@ -264,23 +239,16 @@ export default {
// 删除用户接口 // 删除用户接口
batcheDel(params) { batcheDel(params) {
this.laodingTable = true 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('删除成功') notice.okTips('删除成功')
this.findUserList() this.findUserList()
// this.laodingTable = false
}).catch(err => { }).catch(err => {
this.laodingTable = false this.laodingTable = false
notice.errorTips(err) notice.errorTips(err)
}) })
// }, 2000)
}, },
// 删除、禁用、启用接口f // 删除、禁用、启用接口f
operatUser(params, rows, index) { operatUser(params, rows, index) {
// clearTimeout(timer)
// var timer = setTimeout(() => {
operatUser.req(params).then(res => { operatUser.req(params).then(res => {
switch (params.state) { switch (params.state) {
case 0: case 0:
...@@ -294,17 +262,14 @@ export default { ...@@ -294,17 +262,14 @@ export default {
notice.okTips(rows[index].username + '用户状态已启动') notice.okTips(rows[index].username + '用户状态已启动')
break break
case 2: case 2:
// this.tipParams = 'delete'
notice.okTips('删除成功') notice.okTips('删除成功')
this.findUserList() this.findUserList()
// this.laodingTable = false
break break
} }
}).catch(err => { }).catch(err => {
this.laodingTable = false this.laodingTable = false
notice.errorTips(err) notice.errorTips(err)
}) })
// }, 2000)
}, },
emptyForm() { emptyForm() {
this.loading = false this.loading = false
...@@ -321,14 +286,12 @@ export default { ...@@ -321,14 +286,12 @@ export default {
}, },
// 新增按钮 // 新增按钮
createUser() { createUser() {
// 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
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)
...@@ -401,8 +364,6 @@ export default { ...@@ -401,8 +364,6 @@ export default {
}).then(() => { }).then(() => {
this.laodingTable = true this.laodingTable = true
this.operatUser({ id: rows[index].id, state: 2 }) this.operatUser({ id: rows[index].id, state: 2 })
// 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!