Commit 89ca2a8a by 胡悦

验证提交

2 parents b3fb7b9d 90966f7c
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
deleteUserRoleById, deleteUserRoleById,
getRoleDetail, getRoleDetail,
getRoleList, getRoleList,
// isRoleNameExit, isRoleNameExit,
saveRoleList, saveRoleList,
selectMenuTreeRoleId, selectMenuTreeRoleId,
selectUserRoleByRoleId, selectUserRoleByRoleId,
...@@ -16,7 +16,8 @@ import { ...@@ -16,7 +16,8 @@ import {
getUser, getUser,
getWithRoles, getWithRoles,
operatUser, operatUser,
updateUser updateUser,
existsByName
} from './userApi' } from './userApi'
import { import {
...@@ -43,7 +44,7 @@ export { ...@@ -43,7 +44,7 @@ export {
deleteUserRoleById, deleteUserRoleById,
getRoleDetail, getRoleDetail,
getRoleList, getRoleList,
// isRoleNameExit, isRoleNameExit,
saveRoleList, saveRoleList,
selectMenuTreeRoleId, selectMenuTreeRoleId,
selectUserRoleByRoleId, selectUserRoleByRoleId,
...@@ -55,6 +56,7 @@ export { ...@@ -55,6 +56,7 @@ export {
getWithRoles, getWithRoles,
operatUser, operatUser,
updateUser, updateUser,
existsByName,
// depart接口 // depart接口
delDepartment, delDepartment,
findDepartTree, findDepartTree,
......
...@@ -6,7 +6,7 @@ const __sDeleteRole = `${path}/deleteRoleById` ...@@ -6,7 +6,7 @@ const __sDeleteRole = `${path}/deleteRoleById`
const __sDeleteUserRole = `${path}/deleteUserRoleById` const __sDeleteUserRole = `${path}/deleteUserRoleById`
const __sGetRoleDetail = `${path}/getRoleDetail` const __sGetRoleDetail = `${path}/getRoleDetail`
const __sGetRoleList = `${path}/getRoleList` const __sGetRoleList = `${path}/getRoleList`
// const __sIsRoleNameExit = `${path}/isRoleNameExit` const __sIsRoleNameExit = `${path}/isRoleNameExit`
const __sSaveRoleList = `${path}/saveRoleList` const __sSaveRoleList = `${path}/saveRoleList`
const __sSelectMenuTreeRoleId = `${path}/selectMenuTreeRoleId` const __sSelectMenuTreeRoleId = `${path}/selectMenuTreeRoleId`
const __sSelectUserRole = `${path}/selectUserRoleByRoleId` const __sSelectUserRole = `${path}/selectUserRoleByRoleId`
...@@ -32,10 +32,10 @@ const getRoleList = { ...@@ -32,10 +32,10 @@ const getRoleList = {
req: params => GlAxios.get(__sGetRoleList, { params }) req: params => GlAxios.get(__sGetRoleList, { params })
} }
// const isRoleNameExit = { const isRoleNameExit = {
// p: [__sIsRoleNameExit], p: [__sIsRoleNameExit],
// req: params => GlAxios.get(__sIsRoleNameExit, { params }) req: params => GlAxios.get(__sIsRoleNameExit, { params })
// } }
const saveRoleList = { const saveRoleList = {
p: [__sSaveRoleList], p: [__sSaveRoleList],
...@@ -62,7 +62,7 @@ export { ...@@ -62,7 +62,7 @@ export {
deleteUserRoleById, deleteUserRoleById,
getRoleDetail, getRoleDetail,
getRoleList, getRoleList,
// isRoleNameExit, isRoleNameExit,
saveRoleList, saveRoleList,
selectMenuTreeRoleId, selectMenuTreeRoleId,
selectUserRoleByRoleId, selectUserRoleByRoleId,
......
...@@ -8,6 +8,7 @@ const __sGet = `${path}/get` ...@@ -8,6 +8,7 @@ const __sGet = `${path}/get`
const __sGetWithRoles = `${path}/getWithRoles` const __sGetWithRoles = `${path}/getWithRoles`
const __sOperatUser = `${path}/operatUser` const __sOperatUser = `${path}/operatUser`
const __sUpdateUser = `${path}/updateUser` const __sUpdateUser = `${path}/updateUser`
const __sExistsByName = `${path}/existsByName`
const batcheDelUser = { const batcheDelUser = {
p: [__sBatcheDel], p: [__sBatcheDel],
...@@ -38,6 +39,10 @@ const updateUser = { ...@@ -38,6 +39,10 @@ const updateUser = {
p: [__sUpdateUser], p: [__sUpdateUser],
req: params => GlAxios.post(__sUpdateUser, params) req: params => GlAxios.post(__sUpdateUser, params)
} }
const existsByName = {
p: [__sExistsByName],
req: params => GlAxios.get(__sExistsByName, { params })
}
export { export {
batcheDelUser, batcheDelUser,
...@@ -45,5 +50,6 @@ export { ...@@ -45,5 +50,6 @@ export {
getUser, getUser,
getWithRoles, getWithRoles,
operatUser, operatUser,
updateUser updateUser,
existsByName
} }
...@@ -22,7 +22,7 @@ const config = { ...@@ -22,7 +22,7 @@ const config = {
} }
Vue.use(VeeValidate, config) Vue.use(VeeValidate, config)
Validator.localize('zh_CN', zh_CN) Validator.localize('zh_CN', zh_CN)
Vue.prototype.$valid = Validator
var mixin = { var mixin = {
mounted() { mounted() {
const _this = this const _this = this
......
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
}
deleteUserRoleById.req(params).then(() => {
this.okTips(`删除成功`)
roleLoadingParams.freshList = true
}).catch(err => {
roleLoadingParams.loading = false
this.errorTips(err)
})
},
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 ? '禁用' : '启动'
} }
}] }]
......
...@@ -64,6 +64,7 @@ export default { ...@@ -64,6 +64,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,11 +29,13 @@ ...@@ -29,11 +29,13 @@
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">{{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 +54,7 @@ ...@@ -52,6 +54,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',
...@@ -62,9 +65,12 @@ export default { ...@@ -62,9 +65,12 @@ export default {
textName: this.isDepart ? '请填写部门名称' : '请填写列表名称', textName: this.isDepart ? '请填写部门名称' : '请填写列表名称',
errExist: false, errExist: false,
textExist: '', textExist: '',
errOpenstyle: false,
errIorder: false, errIorder: false,
textType: '请填写数字', textType: '请填写数字',
menu: '' menu: '',
subLoading: false,
delLoading: false
} }
}, },
mounted() { mounted() {
...@@ -82,9 +88,16 @@ export default { ...@@ -82,9 +88,16 @@ export default {
eventBus: Object eventBus: Object
}, },
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()
} }
...@@ -100,6 +113,10 @@ export default { ...@@ -100,6 +113,10 @@ export default {
this.errExist = false this.errExist = false
this.textExist = '' this.textExist = ''
}, },
openStyleTip() {
this.errOpenstyle = false
this.openText = ''
},
nameExitTip(err) { nameExitTip(err) {
this.errExist = true this.errExist = true
this.textExist = err this.textExist = err
...@@ -116,26 +133,34 @@ export default { ...@@ -116,26 +133,34 @@ export default {
// 接口调用-start // 接口调用-start
addOrEditDepart(params) { addOrEditDepart(params) {
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)
}) })
}, },
// 接口调用-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
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()
}) })
...@@ -152,13 +177,7 @@ export default { ...@@ -152,13 +177,7 @@ 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({
...@@ -170,8 +189,9 @@ export default { ...@@ -170,8 +189,9 @@ 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
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) {
...@@ -190,18 +210,25 @@ export default { ...@@ -190,18 +210,25 @@ export default {
} else { } else {
if (!this.isDepart) { if (!this.isDepart) {
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)
}) })
} else { } else {
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)
...@@ -211,11 +238,19 @@ export default { ...@@ -211,11 +238,19 @@ export default {
addData(obj) { addData(obj) {
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
console.log(err)
if (err === '菜单名已存在') {
this.nameExitTip(err)
} else {
notice.errorTips(err)
}
}) })
} else { } else {
this.errIorder = true
this.addOrEditDepart(obj) this.addOrEditDepart(obj)
} }
}, },
......
<!-- 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|uniqueName'"
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>
</gl-form-item> </gl-form-item>
<gl-form-item label="角色描述:" prop="description"> <gl-form-item label="角色描述:" prop="description">
<gl-input name="description" data-vv-as="角色描述" v-validate="'required|max:200'" v-model="createRuleForm.description" type="textarea" :rows="3" clearable></gl-input> <gl-input name="description"
data-vv-as="角色描述"
v-validate="'required|max:200'"
v-model="createRuleForm.description"
type="textarea"
:rows="3" clearable></gl-input>
<span v-show="errorBags.has('description')" class="error">{{ errorBags.first('description') }}</span> <span v-show="errorBags.has('description')" class="error">{{ errorBags.first('description') }}</span>
</gl-form-item> </gl-form-item>
<gl-form-item> <gl-form-item>
...@@ -53,6 +61,7 @@ ...@@ -53,6 +61,7 @@
</template> </template>
<script> <script>
import { isRoleNameExit } from '@/api/api'
export default { export default {
name: 'RoleCreate', name: 'RoleCreate',
props: { props: {
...@@ -77,6 +86,7 @@ export default { ...@@ -77,6 +86,7 @@ export default {
}, },
data() { data() {
return { return {
roleName: '',
isDepart: true, isDepart: true,
show_checkbox: true, show_checkbox: true,
defaultExpandAll: false, defaultExpandAll: false,
...@@ -104,6 +114,31 @@ export default { ...@@ -104,6 +114,31 @@ export default {
} }
} }
}, },
mounted() {
this.$valid.extend('uniqueName', {
validate: value => {
return new Promise((resolve, reject) => {
if (value === this.createRuleForm.oldRoleName) {
resolve(true)
}
isRoleNameExit.req({ roleName: this.createRuleForm.roleName }).then(data => {
// 此处data返回一个布尔值,true为已存在,false为不存在
resolve(data)
}).catch(err => {
console.log(err)
resolve(false)
})
})
}
})
this.$validator.localize('zh_CN', {
custom: {
roleName: {
uniqueName: '该角色已存在'
}
}
})
},
methods: { methods: {
// tree-strat // tree-strat
getMenuOption(params) { getMenuOption(params) {
...@@ -148,6 +183,9 @@ export default { ...@@ -148,6 +183,9 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
.dialog-footer{
margin-top: -40px;
}
.err { .err {
color: red; color: red;
} }
......
...@@ -3,38 +3,73 @@ ...@@ -3,38 +3,73 @@
<gl-form :model="userManageForm" :rules="rules" ref="userManageForm" label-width="100px"> <gl-form :model="userManageForm" :rules="rules" ref="userManageForm" label-width="100px">
<el-col :span="12"> <el-col :span="12">
<gl-form-item label="用户名" prop="username"> <gl-form-item label="用户名" prop="username">
<gl-input type="text" name="username" data-vv-as="用户名" v-validate="'required|min:5'" v-model="userManageForm.username" placeholder="请输入用户名" clearable></gl-input> <gl-input
type="text"
name="username"
data-vv-as="用户名"
v-validate="'required|min:5|uniqueName'"
v-model="userManageForm.username"
placeholder="请输入用户名" clearable></gl-input>
<span v-show="errorBags.has('username')" class="error">{{ errorBags.first('username') }}</span> <span v-show="errorBags.has('username')" class="error">{{ errorBags.first('username') }}</span>
</gl-form-item> </gl-form-item>
</el-col> </el-col>
<gl-col :span="12"> <gl-col :span="12">
<gl-form-item label="真实姓名" prop="realname"> <gl-form-item label="真实姓名" prop="realname">
<gl-input type="text" name="realname" data-vv-as="真实姓名" v-validate="'required'" v-model="userManageForm.realname" placeholder="请输入用户真实名字" clearable></gl-input> <gl-input
type="text"
name="realname"
data-vv-as="真实姓名"
v-validate="'required'"
v-model="userManageForm.realname"
placeholder="请输入用户真实名字" clearable></gl-input>
<span v-show="errorBags.has('realname')" class="error">{{ errorBags.first('realname') }}</span> <span v-show="errorBags.has('realname')" class="error">{{ errorBags.first('realname') }}</span>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
<gl-col :span="12"> <gl-col :span="12">
<gl-form-item label="密码" prop="password" <gl-form-item label="密码" prop="password"
:rules="[{ required: !userManageForm.id }]" > :rules="[{ required: !userManageForm.id }]" >
<gl-input type='password' name="password" data-vv-as="密码" v-validate="!userManageForm.id? 'required|min:5': ''" v-model="userManageForm.password" :placeholder='placeholder' clearable></gl-input> <gl-input
type='password'
name="password"
data-vv-as="密码"
v-validate="!userManageForm.id? 'required|min:5': ''"
v-model="userManageForm.password"
:placeholder='placeholder' clearable></gl-input>
<span v-show="errorBags.has('password')" class="error">{{ errorBags.first('password') }}</span> <span v-show="errorBags.has('password')" class="error">{{ errorBags.first('password') }}</span>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
<gl-col :span="12"> <gl-col :span="12">
<gl-form-item label="手机号码" prop="mobile"> <gl-form-item label="手机号码" prop="mobile">
<gl-masked type="text" name="mobile" data-vv-as="手机号码" v-validate="'required|length:11'" placeholder="请输入手机号码" v-model="userManageForm.mobile" :mask="[ 1, /[34578]/, /\d/, /\d/, /\d/,/\d/, /\d/, /\d/,/\d/, /\d/, /\d/]" clearable></gl-masked> <gl-masked
type="text"
name="mobile"
data-vv-as="手机号码"
v-validate="'required|length:11'"
placeholder="请输入手机号码"
v-model="userManageForm.mobile"
:mask="[ 1, /[34578]/, /\d/, /\d/, /\d/,/\d/, /\d/, /\d/,/\d/, /\d/, /\d/]" clearable></gl-masked>
<span v-show="errorBags.has('mobile')" class="error">{{ errorBags.first('mobile') }}</span> <span v-show="errorBags.has('mobile')" class="error">{{ errorBags.first('mobile') }}</span>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
<gl-col :span="12"> <gl-col :span="12">
<gl-form-item label="注册IP" prop="joinip"> <gl-form-item label="注册IP" prop="joinip">
<gl-masked name="joinip" v-validate="'required'" data-vv-as="注册IP" v-model="userManageForm.joinip" ip clearable></gl-masked> <gl-masked
name="joinip"
v-validate="'required'"
data-vv-as="注册IP"
v-model="userManageForm.joinip" ip clearable></gl-masked>
<span v-show="errorBags.has('joinip')" class="error">{{ errorBags.first('joinip') }}</span> <span v-show="errorBags.has('joinip')" class="error">{{ errorBags.first('joinip') }}</span>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
<gl-col :span="12"> <gl-col :span="12">
<gl-form-item prop="email" label="邮箱"> <gl-form-item prop="email" label="邮箱">
<gl-input type="text" name="email" data-vv-as="邮箱" v-model='userManageForm.email' placeholder="请输入邮箱地址" v-validate="'required|email'" clearable></gl-input> <gl-input
type="text"
name="email"
data-vv-as="邮箱"
v-model='userManageForm.email'
placeholder="请输入邮箱地址"
v-validate="'required|email'" clearable></gl-input>
<span v-show="errorBags.has('email')" class="error">{{ errorBags.first('email') }}</span> <span v-show="errorBags.has('email')" class="error">{{ errorBags.first('email') }}</span>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
...@@ -57,15 +92,32 @@ ...@@ -57,15 +92,32 @@
<gl-col :span="24"> <gl-col :span="24">
<gl-form-item label="所属部门" <gl-form-item label="所属部门"
prop="departName"> prop="departName">
<gl-input-tree name="departName" data-vv-as="所属部门" v-validate="'required'" :data='userManageForm.departList' :props="props" :treeStyle='{ maxHeight: "160px" }' @node-click='clickDepart' v-model="userManageForm.departName" /> <gl-input-tree
name="departName"
data-vv-as="所属部门"
v-validate="'required'"
:data='userManageForm.departList'
:props="props"
:treeStyle='{ maxHeight: "160px" }'
@node-click='clickDepart'
v-model="userManageForm.departName" />
<span v-show="errorBags.has('departName')" class="error">{{ errorBags.first('departName') }}</span> <span v-show="errorBags.has('departName')" class="error">{{ errorBags.first('departName') }}</span>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
<gl-col :span="24"> <gl-col :span="24">
<gl-form-item label="角色选项" <gl-form-item label="角色选项"
prop="roles" :key="key"> prop="roles" :key="key">
<gl-checkbox-group name="roles" data-vv-as="角色选项" v-validate="'required'" class="height" v-model="userManageForm.roles" @change="handleCheckedChange"> <gl-checkbox-group
<gl-checkbox v-for="item in userManageForm.roleList" :key="item.id" :label='item.id'>{{item.roleName}}</gl-checkbox> name="roles"
data-vv-as="角色选项"
v-validate="'required'"
class="height"
v-model="userManageForm.roles"
@change="handleCheckedChange">
<gl-checkbox
v-for="item in userManageForm.roleList"
:key="item.id"
:label='item.id'>{{item.roleName}}</gl-checkbox>
</gl-checkbox-group> </gl-checkbox-group>
<span v-show="errorBags.has('roles')" class="error">{{ errorBags.first('roles') }}</span> <span v-show="errorBags.has('roles')" class="error">{{ errorBags.first('roles') }}</span>
</gl-form-item> </gl-form-item>
...@@ -79,6 +131,7 @@ ...@@ -79,6 +131,7 @@
</template> </template>
<script> <script>
import { existsByName } from '@/api/api'
import { userForm } from '@/common/userConst' import { userForm } from '@/common/userConst'
export default { export default {
name: 'UserCreate', name: 'UserCreate',
...@@ -138,6 +191,31 @@ export default { ...@@ -138,6 +191,31 @@ export default {
} }
} }
}, },
mounted() {
this.$valid.extend('uniqueName', {
validate: value => {
return new Promise((resolve, reject) => {
if (value === this.userManageForm.oldUserName) {
resolve(true)
}
existsByName.req({ username: this.userManageForm.username }).then(data => {
// 此处data返回一个布尔值,false为已存在,true为不存在
resolve(data)
}).catch(err => {
console.log(err)
resolve(false)
})
})
}
})
this.$validator.localize('zh_CN', {
custom: {
username: {
uniqueName: '该用户已存在'
}
}
})
},
methods: { methods: {
// 部门树 // 部门树
clickDepart(data, treeData, vue, props) { clickDepart(data, treeData, vue, props) {
...@@ -181,7 +259,6 @@ export default { ...@@ -181,7 +259,6 @@ export default {
}, },
cancelForm() { cancelForm() {
this.$emit('userFormData') this.$emit('userFormData')
// this.$validator.errors.clear()
}, },
handleCheckedChange(value) { handleCheckedChange(value) {
if (!value) return if (!value) return
......
...@@ -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: {}
} }
} }
}, },
...@@ -69,16 +84,23 @@ export default { ...@@ -69,16 +84,23 @@ export default {
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)
}) })
}, },
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
......
...@@ -2,7 +2,7 @@ export default { ...@@ -2,7 +2,7 @@ export default {
axios: { axios: {
baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/', baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/',
// baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/', // 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'], 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/existsByName', '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, timeout: 15000,
result: { result: {
data_key: 'data', // 返回值数据实体存放对象 data_key: 'data', // 返回值数据实体存放对象
......
...@@ -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,19 +51,18 @@ ...@@ -52,19 +51,18 @@
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',
components: { components: {
RoleCreate, RoleCreate,
RoleDetail, RoleDetail,
UserDetail, UserDetail
saveRoleList,
updateRole
}, },
data() { data() {
return { return {
loadingTable: false,
loading: false, loading: false,
roleName: '', roleName: '',
createVisible: false, createVisible: false,
...@@ -73,7 +71,6 @@ export default { ...@@ -73,7 +71,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 +79,7 @@ export default { ...@@ -82,6 +79,7 @@ export default {
createOrEditTitle: '新增角色', createOrEditTitle: '新增角色',
userDetailTitle: '用户列表', userDetailTitle: '用户列表',
departList: [], departList: [],
tipParams: '',
// 分页所需参数-start // 分页所需参数-start
total: 10, total: 10,
pageNum: 1, pageNum: 1,
...@@ -133,7 +131,11 @@ export default { ...@@ -133,7 +131,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 +146,7 @@ export default { ...@@ -144,6 +146,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(() => {
}) })
...@@ -163,8 +166,12 @@ export default { ...@@ -163,8 +166,12 @@ export default {
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.tipParams = ''
}).catch(err => { }).catch(err => {
console.log(err) this.tipParams = ''
this.loadingTable = false
notice.errorTips(err)
}) })
}, },
// 删除角色 // 删除角色
...@@ -173,6 +180,7 @@ export default { ...@@ -173,6 +180,7 @@ export default {
notice.okTips('删除成功') notice.okTips('删除成功')
this.getList() this.getList()
}).catch(message => { }).catch(message => {
this.loadingTable = false
notice.errorTips(message) notice.errorTips(message)
}) })
}, },
...@@ -203,10 +211,9 @@ export default { ...@@ -203,10 +211,9 @@ export default {
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
}, },
// 编辑角色 // 编辑角色
updateRoleInfo(params) { updateRoleInfo(params) {
...@@ -215,15 +222,16 @@ export default { ...@@ -215,15 +222,16 @@ export default {
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)
}) })
this.loading = false
}, },
// 获取部门树 // 获取部门树
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,29 +246,32 @@ export default { ...@@ -238,29 +246,32 @@ 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)
}, 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.roleMenu = [] 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,18 +284,19 @@ export default { ...@@ -273,18 +284,19 @@ 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
}, },
handleCreateOrEdit() { handleCreateOrEdit() {
this.roleParam = this.flagCOrE ? this.$deep_clone(roleCreateStructure) : this.roleParam this.roleParam = this.flagCOrE ? this.$deep_clone(roleCreateStructure) : this.roleParam
this.roleParam.oldRoleName = this.roleParam.roleName
this.flagCOrE ? this.createDialogVisible() : this.getMenuTree(this.roleParam.id, this.editOrDetail = true) this.flagCOrE ? this.createDialogVisible() : this.getMenuTree(this.roleParam.id, this.editOrDetail = 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"
...@@ -53,7 +53,6 @@ export default { ...@@ -53,7 +53,6 @@ export default {
components: { components: {
UserCreate, UserCreate,
UserDetail, UserDetail,
updateUser,
userForm userForm
}, },
data() { data() {
...@@ -66,6 +65,8 @@ export default { ...@@ -66,6 +65,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,17 +152,13 @@ export default { ...@@ -151,17 +152,13 @@ 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.operatUser({ id: rows[index].id, state: 1 }, rows, index)
this.operatUser({ id: rows[index].id, state: 1 })
} 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 })
} }
notice.okTips('修改成功') }).catch(() => {})
}).catch(() => {
notice.errorTips('修改失败')
})
} }
}, { }, {
label: '删除', label: '删除',
...@@ -183,7 +180,10 @@ export default { ...@@ -183,7 +180,10 @@ export default {
}, },
watch: { watch: {
userName(val) { userName(val) {
!val && this.findUserList() if (!val) {
this.laodingTable = true
this.findUserList()
}
} }
}, },
methods: { methods: {
...@@ -201,8 +201,12 @@ export default { ...@@ -201,8 +201,12 @@ export default {
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.tipParams = ''
}).catch(err => { }).catch(err => {
console.log(err) this.tipParams = ''
this.laodingTable = false
notice.errorTips(err)
}) })
}, },
// 获取所有角色选项 // 获取所有角色选项
...@@ -220,30 +224,55 @@ export default { ...@@ -220,30 +224,55 @@ 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.laodingTable = true
notice.okTips('操作成功')
this.findUserList() this.findUserList()
}).catch(message => { }).catch(message => {
notice.errorTips(message) // notice.errorTips(message)
this.loading = false this.loading = false
}) })
}, },
// 删除用户接口 // 删除用户接口
batcheDel(params) { batcheDel(params) {
this.laodingTable = true
batcheDelUser.req({ ids: params }).then(res => { batcheDelUser.req({ ids: params }).then(res => {
notice.okTips('删除成功')
this.findUserList() this.findUserList()
}).catch(err => {
this.laodingTable = false
notice.errorTips(err)
}) })
}, },
// 删除、禁用、启用接口f // 删除、禁用、启用接口f
operatUser(params) { operatUser(params, rows, index) {
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:
notice.okTips('删除成功')
this.findUserList()
break
}
}).catch(err => {
this.laodingTable = false
notice.errorTips(err)
}) })
}, },
emptyForm() { emptyForm() {
this.dialogFormVisible = !this.dialogFormVisible this.loading = false
this.handleUserFormVisible()
clearTimeout(timer) clearTimeout(timer)
var timer = setTimeout(() => { var timer = setTimeout(() => {
this.userManageForm = this.$deep_clone(userForm) this.userManageForm = this.$deep_clone(userForm)
...@@ -251,21 +280,20 @@ export default { ...@@ -251,21 +280,20 @@ 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.userManageForm = this.$deep_clone(userForm) this.userManageForm = this.$deep_clone(userForm)
this.dialogFormVisible = !this.dialogFormVisible this.handleUserFormVisible()
this.isEdit = false this.isEdit = false
}, },
// 编辑按钮 // 编辑按钮
editUser(row) { editUser(row) {
this.loading = false
row.password = '' row.password = ''
// console.log(row)
row.oldUserName = row.username
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)
row.state = row.state + '' row.state = row.state + ''
...@@ -285,7 +313,7 @@ export default { ...@@ -285,7 +313,7 @@ export default {
} }
this.userManageForm = this.$deep_clone(row) this.userManageForm = this.$deep_clone(row)
}) })
this.dialogFormVisible = !this.dialogFormVisible this.handleUserFormVisible()
this.isEdit = true this.isEdit = true
}, },
// 获取选中的行 // 获取选中的行
...@@ -299,30 +327,33 @@ export default { ...@@ -299,30 +327,33 @@ export default {
this.toggle.forEach(row => { this.toggle.forEach(row => {
ids.push(row.id + '') ids.push(row.id + '')
}) })
this.$confirm('确定要删除这条数据?', '', { ids.length
confirmButtonText: '确定', ? this.$confirm('确定要删除这条数据?', '', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
this.batcheDel(ids.join(',')) }).then(() => {
notice.okTips('删除成功') this.batcheDel(ids.join(','))
}).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 +363,8 @@ export default { ...@@ -332,8 +363,8 @@ 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('成功删除该用户')
}).catch(() => { }).catch(() => {
}) })
}, },
...@@ -361,6 +392,9 @@ export default { ...@@ -361,6 +392,9 @@ export default {
handleUserDetailClose() { handleUserDetailClose() {
this.userDetailVisible = !this.userDetailVisible this.userDetailVisible = !this.userDetailVisible
this.apiParam = Object this.apiParam = Object
},
handleUserFormVisible() {
this.dialogFormVisible = !this.dialogFormVisible
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!