Commit 90966f7c by cwq0219

菜单部门提示;loading优化

1 parent 284c7c08
......@@ -23,18 +23,13 @@ export default new Vue({
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({
......
......@@ -63,6 +63,7 @@ export default {
this.clearFrom()
},
clearFrom() {
// console.log(this.value.form)
this.value.showDetails = true
this.value.btnTxt = '保存'
this.value.del = false
......
......@@ -29,7 +29,9 @@
v-model="value.form[i.value]"
:disabled="i.disabled">
</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-button type="primary" @click="submit" :loading="subLoading">{{value.btnTxt}}</gl-button>
......@@ -63,10 +65,10 @@ export default {
textName: this.isDepart ? '请填写部门名称' : '请填写列表名称',
errExist: false,
textExist: '',
errOpenstyle: false,
errIorder: false,
subLoading: false,
delLoading: false,
textType: '请填写数字'
delLoading: false
}
},
props: {
......@@ -78,9 +80,16 @@ export default {
isDepart: Boolean
},
watch: {
'value.showDetails'(val) {
this.err = false
this.errOpenstyle = false
},
'value.form.urlName'(val) {
if (val !== '') this.nameTip()
},
'value.form.openStyle'(val) {
if (val !== null) this.openStyleTip()
},
'value.form.name'(val) {
if (val !== '') this.nameTip()
}
......@@ -96,10 +105,14 @@ export default {
this.errExist = false
this.textExist = ''
},
// nameExitTip(err) {
// this.errExist = true
// this.textExist = err
// },
openStyleTip() {
this.errOpenstyle = false
this.openText = ''
},
nameExitTip(err) {
this.errExist = true
this.textExist = err
},
getMenuObj(obj = {}) {
for (const key in this.value.form) {
obj[key] = this.value.form[key]
......@@ -111,17 +124,13 @@ export default {
},
// 接口调用-start
addOrEditDepart(params) {
// clearTimeout(timer)
// var timer = setTimeout(() => {
updateDepartment.req(params).then(res => {
this.subLoading = false
this.Tip(true)
}).catch(err => {
this.subLoading = false
notice.errorTips(err)
// console.log(err)
})
// }, 2000)
},
// 接口调用-end
// 删除
......@@ -130,8 +139,6 @@ export default {
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
......@@ -149,7 +156,6 @@ export default {
console.log(err)
this.delErrTip()
})
// }, 2000)
},
delTip(val) {
if (val) {
......@@ -164,13 +170,6 @@ export default {
this.value.showDetails = false
this.value.updateTree = !this.value.updateTree
}
// else {
// this.$notify({
// title: '已取消',
// type: 'info'
// })
// }
// this.dialog = false
},
delErrTip() {
this.$notify({
......@@ -182,7 +181,7 @@ export default {
// 保存修改
submit() {
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()
this.subLoading = true
obj.isHidden = this.value.form.isHidden === true ? 0 : 1
......@@ -193,7 +192,6 @@ export default {
} else {
obj.parentId = treeData.parent
}
// this.subLoading = true
this.addData(obj)
// 添加子级
} else if (this.value.children) {
......@@ -203,8 +201,6 @@ export default {
// 修改
} else {
if (!this.isDepart) {
// clearTimeout(timer)
// var timer = setTimeout(() => {
editMenu.req(obj).then(res => {
this.subLoading = false
this.Tip(true)
......@@ -213,15 +209,18 @@ export default {
this.subLoading = false
this.Tip(false)
})
// }, 2000)
} else {
this.subLoading = true
this.addOrEditDepart(obj)
}
}
} else {
}
if (this.value.form[this.form[0].value] === '' || this.value.form[this.form[0].value] === null) {
this.err = true
}
if (this.value.form[this.form[2].value] === null && !this.isDepart) {
this.errOpenstyle = true
}
},
unix(time) {
time = time.substring(0, 19)
......@@ -229,8 +228,6 @@ 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
......@@ -238,13 +235,12 @@ export default {
}).catch(err => {
this.subLoading = false
notice.errorTips(err)
// this.nameExitTip(err)
this.nameExitTip(err)
})
} else {
this.errIorder = true
this.addOrEditDepart(obj)
}
// }, 2000)
},
Tip(val) {
if (val) {
......
......@@ -81,8 +81,6 @@ 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
......@@ -91,7 +89,6 @@ export default {
this.roleLoadingParams.loading = false
notice.errorTips(err)
})
// }, 2000)
},
callApi() {
this.flagRoleOrUser && (this.roleLoadingParams.loading = true)
......
......@@ -161,53 +161,30 @@ 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 => {
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 => {
......@@ -233,30 +210,23 @@ export default {
},
// 添加角色
addRole(params) {
// clearTimeout(timer)
// var timer = setTimeout(() => {
saveRoleList.req(params).then((data) => {
this.createOrEditSuccess()
}).catch(err => {
this.loading = false
notice.errorTips(err)
})
// }, 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)
})
// }, 2000)
},
// 获取部门树
getdepartData() {
......@@ -285,11 +255,9 @@ export default {
}, 200)
},
createOrEditSuccess() {
// this.createDialogVisible()
this.emptyParam()
this.loading = false
notice.okTips(this.flagCOrE ? '创建角色成功!' : '已经成功修改数据!')
// this.tipParams = this.flagCOrE ? 'add' : 'edit'
this.loadingTable = true
this.getList()
},
......@@ -336,7 +304,6 @@ export default {
handleCreateClose(data) {
if (!data) {
this.emptyParam()
// this.roleMenu = []
return false
}
this.loading = true
......
......@@ -155,16 +155,11 @@ export default {
}).then(() => {
this.laodingTable = true
if (rows[index].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 }, rows, index)
}
// notice.okTips('修改成功')
}).catch(() => {
// notice.errorTips('修改失败')
})
}).catch(() => {})
}
}, {
label: '删除',
......@@ -201,37 +196,19 @@ 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 => {
this.tipParams = ''
this.laodingTable = false
notice.errorTips(err)
// console.log(err)
})
// }, 2000)
},
// 获取所有角色选项
getRoleOptions() {
......@@ -251,10 +228,8 @@ export default {
this.loading = true
updateUser.req(params).then(res => {
this.emptyForm()
// this.loading = false
this.laodingTable = true
notice.okTips('操作成功')
// this.tipParams = this.isEdit ? 'edit' : 'add'
this.findUserList()
}).catch(message => {
notice.errorTips(message)
......@@ -264,23 +239,16 @@ 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, rows, index) {
// clearTimeout(timer)
// var timer = setTimeout(() => {
operatUser.req(params).then(res => {
switch (params.state) {
case 0:
......@@ -294,17 +262,14 @@ export default {
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
......@@ -321,14 +286,12 @@ export default {
},
// 新增按钮
createUser() {
// this.loading = false
this.userManageForm = this.$deep_clone(userForm)
this.dialogFormVisible = !this.dialogFormVisible
this.isEdit = false
},
// 编辑按钮
editUser(row) {
// this.loading = false
row.password = ''
row.roleList = this.$deep_clone(userForm.roleList)
row.departList = this.$deep_clone(userForm.departList)
......@@ -401,8 +364,6 @@ export default {
}).then(() => {
this.laodingTable = true
this.operatUser({ id: rows[index].id, state: 2 })
// this.laodingTable = false
// notice.okTips('成功删除该用户')
}).catch(() => {
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!