Browse Source

PC端用户管理修改支持关联多个部门

feature/syp_points
liuchuang 5 years ago
parent
commit
8f13d84572
  1. 83
      src/views/modules/sys/user-add-or-update.vue

83
src/views/modules/sys/user-add-or-update.vue

@ -7,7 +7,7 @@
:rules="dataRule" :rules="dataRule"
ref="dataForm" ref="dataForm"
@keyup.enter.native="dataFormSubmitHandle()" @keyup.enter.native="dataFormSubmitHandle()"
label-width="120px"> label-width="130px">
<el-form-item prop="username" <el-form-item prop="username"
:label="$t('user.username')"> :label="$t('user.username')">
<el-input v-model="dataForm.username" <el-input v-model="dataForm.username"
@ -35,27 +35,49 @@
:readonly="true" :readonly="true"
:placeholder="$t('user.deptName')"></el-input> :placeholder="$t('user.deptName')"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="relationDeptName" <el-form-item prop="relationWorkDeptName"
label="关联部门" label="关联工作人员网格"
class="dept-list"> class="dept-list">
<el-popover v-model="relationDeptListVisible" <el-popover v-model="relationWorkDeptListVisible"
ref="relationDeptListPopover" ref="relationWorkDeptListPopover"
placement="bottom-start" placement="bottom-start"
trigger="click"> trigger="click">
<el-tree :data="relationDeptList" <el-tree :data="relationWorkDeptList"
:props="{ label: 'name', children: 'children' }" :props="{ label: 'name', children: 'children' }"
node-key="id" node-key="id"
ref="relationDeptListTree" ref="relationWorkDeptListTree"
:highlight-current="true" :highlight-current="true"
:expand-on-click-node="false" :expand-on-click-node="false"
accordion accordion
@current-change="relationDeptListTreeCurrentChangeHandle"> @current-change="relationWorkDeptListTreeCurrentChangeHandle">
</el-tree> </el-tree>
</el-popover> </el-popover>
<el-input v-model="dataForm.relationDeptName" <el-input v-model="dataForm.relationWorkDeptName"
v-popover:relationDeptListPopover v-popover:relationWorkDeptListPopover
:readonly="true" clearable
placeholder="关联部门"></el-input> placeholder="关联工作人员网格"></el-input>
</el-form-item>
<el-form-item prop="relationLeaderDeptName"
label="关联领导干部网格"
class="dept-list">
<el-popover v-model="relationLeaderDeptListVisible"
ref="relationLeaderDeptListPopover"
placement="bottom-start"
trigger="click">
<el-tree :data="relationLeaderDeptList"
:props="{ label: 'name', children: 'children' }"
node-key="id"
ref="relationLeaderDeptListTree"
:highlight-current="true"
:expand-on-click-node="false"
accordion
@current-change="relationLeaderDeptListTreeCurrentChangeHandle">
</el-tree>
</el-popover>
<el-input v-model="dataForm.relationLeaderDeptName"
v-popover:relationLeaderDeptListPopover
clearable
placeholder="关联领导干部网格"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="用户类型" <el-form-item label="用户类型"
prop="userTagKey"> prop="userTagKey">
@ -142,9 +164,11 @@ export default {
return { return {
visible: false, visible: false,
deptList: [], deptList: [],
relationDeptList: [], relationWorkDeptList: [],
relationLeaderDeptList: [],
deptListVisible: false, deptListVisible: false,
relationDeptListVisible: false, relationWorkDeptListVisible: false,
relationLeaderDeptListVisible: false,
roleList: [], roleList: [],
roleIdListDefault: [], roleIdListDefault: [],
dataForm: { dataForm: {
@ -152,8 +176,10 @@ export default {
username: '', username: '',
deptId: '0', deptId: '0',
deptName: '', deptName: '',
relationDeptId: '', relationWorkDeptId: '',
relationDeptName: '', relationLeaderDeptId: '',
relationWorkDeptName: '',
relationLeaderDeptName: '',
password: '', password: '',
comfirmPassword: '', comfirmPassword: '',
realName: '', realName: '',
@ -250,7 +276,8 @@ export default {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.deptList = res.data this.deptList = res.data
this.relationDeptList = res.data this.relationWorkDeptList = res.data
this.relationLeaderDeptList = res.data
}).catch(() => { }) }).catch(() => { })
}, },
// //
@ -283,7 +310,8 @@ export default {
roleIdList: [] roleIdList: []
} }
this.$refs.deptListTree.setCurrentKey(this.dataForm.deptId) this.$refs.deptListTree.setCurrentKey(this.dataForm.deptId)
this.$refs.relationDeptListTree.setCurrentKey(this.dataForm.relationDeptId) this.$refs.relationWorkDeptListTree.setCurrentKey(this.dataForm.relationWorkDeptId)
this.$refs.relationLeaderDeptListTree.setCurrentKey(this.dataForm.relationLeaderDeptId)
// , // ,
for (var i = 0; i < res.data.roleIdList.length; i++) { for (var i = 0; i < res.data.roleIdList.length; i++) {
if (this.roleList.filter(item => item.id === res.data.roleIdList[i])[0]) { if (this.roleList.filter(item => item.id === res.data.roleIdList[i])[0]) {
@ -301,10 +329,15 @@ export default {
this.deptListVisible = false this.deptListVisible = false
}, },
// , // ,
relationDeptListTreeCurrentChangeHandle (data, node) { relationWorkDeptListTreeCurrentChangeHandle (data, node) {
this.dataForm.relationDeptId = data.id this.dataForm.relationWorkDeptId = data.id
this.dataForm.relationDeptName = data.name this.dataForm.relationWorkDeptName = data.name
this.relationDeptListVisible = false this.relationWorkDeptListVisible = false
},
relationLeaderDeptListTreeCurrentChangeHandle (data, node) {
this.dataForm.relationLeaderDeptId = data.id
this.dataForm.relationLeaderDeptName = data.name
this.relationLeaderDeptListVisible = false
}, },
// //
dataFormSubmitHandle: debounce(function () { dataFormSubmitHandle: debounce(function () {
@ -312,6 +345,12 @@ export default {
if (!valid) { if (!valid) {
return false return false
} }
if (this.dataForm.relationWorkDeptName === '') {
this.dataForm.relationWorkDeptId = ''
}
if (this.dataForm.relationLeaderDeptName === '') {
this.dataForm.relationLeaderDeptId = ''
}
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/user', { this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/user', {
...this.dataForm, ...this.dataForm,
roleIdList: [ roleIdList: [

Loading…
Cancel
Save