[update] 用户管理 部门分配

This commit is contained in:
zhaomeijing
2022-05-25 15:08:47 +08:00
parent 119d8ea093
commit 24bff736da
2 changed files with 145 additions and 40 deletions
+6 -2
View File
@@ -129,8 +129,8 @@
<role-assignment v-if='rolevisible' :selectedRowKeysArray='selectedRowKeys' @rolevisible='rolevisibleMethods'></role-assignment>
</a-modal>
<!-- 部门配置 -->
<a-modal v-model="departmentvisible" :title="$t('RoleAssignment')" width='650px' :footer="null">
<department-allocation v-if='departmentvisible' :selectedRowKeysArray='selectedRowKeys'></department-allocation>
<a-modal v-model="departmentvisible" :title="$t('DepartmentAllocation')" width='650px' :footer="null">
<department-allocation v-if='departmentvisible' :selectedRowKeysArray='selectedRowKeys' @departmentvisible='departmentvisibleMethods'></department-allocation>
</a-modal>
</a-card>
</template>
@@ -286,6 +286,10 @@
this.rolevisible = val
this.selectedRowKeys = []
},
departmentvisibleMethods(val) {
this.departmentvisible = val
this.selectedRowKeys = []
},
getAvatarView: function(avatar) {
return getFileAccessHttpUrl(avatar)
},
@@ -11,25 +11,24 @@
>
<a-row :gutter='24'>
<a-col :span='24'>
<!-- <a-form-item :label="$t('RoleAssignment')" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!-- <a-select mode="multiple" :placeholder="$t('PleaseSelect')+$t('controlVerification')" v-model:value="selectedRole">-->
<!-- <a-select-option v-for="(role,roleindex) in roleList" :key="role.id" :value="role.id">-->
<!-- <span style="display: inline-block;width: 100%">-->
<!-- {{ role.roleName }}-->
<!-- </span>-->
<!-- </a-select-option>-->
<!-- </a-select>-->
<!-- </a-form-item>-->
<a-form-item :label="$t('DepartmentAllocation')" :labelCol="labelCol" :wrapperCol="wrapperCol"
>
<a-input-search
:placeholder="$t('ClickSelectDepartment')"
v-model="checkedDepartNameString"
readOnly
@search="onSearch">
<a-button slot="enterButton" icon="search">{{$t('choice')}}</a-button>
</a-input-search>
</a-form-item>
<a-input-search @search="onSearch" style="width:100%;margin-top: 6px"
:placeholder="$t('enterDepartmentName')"/>
<!-- -->
<template>
<a-tree
multiple
style="height:600px;overflow: auto;width: 100%"
@select="onSelect"
@check="onCheck"
@rightClick="rightHandle"
:selectedKeys="selectedKeys"
:checkedKeys="checkedKeys"
:treeData="departTree"
checkable
:checkStrictly="checkStrictly"
:autoExpandParent="false"
@expand="onExpand"/>
</template>
</a-col>
</a-row>
</a-form-model>
@@ -38,7 +37,6 @@
<a-button style='margin-right: .8rem' @click='handleCancel'>{{ $t('cancel') }}</a-button>
<a-button @click='handleSubmit' type='primary' :loading='confirmLoading'>{{ $t('determine') }}</a-button>
</div>
<depart-window ref="departWindow" @ok="modalFormOk"></depart-window>
</div>
</template>
@@ -47,15 +45,11 @@ import { putAction, postAction, getAction, deleteAction } from '@/api/manage'
import axios from 'axios'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import moment from 'moment'
// import eventBUs from '../../common/event'
// 引入搜索部门弹出框的组件
import departWindow from './DepartWindow'
import { queryDepartTreeList, searchByKeywords, deleteByDepartId } from '@/api/api'
import pick from 'lodash.pick'
export default {
name: 'diolagArea',
components: {
departWindow
},
components: {},
data() {
return {
checkedDepartNameString: '',
@@ -83,7 +77,11 @@ export default {
confirmLoading: false,
selectedRowKeys: [],
roleList: [],
defaultValue: undefined
departTree: [],
allTreeKeys: [],
selectedKeys: [],
checkStrictly: true,
checkedKeys: [],
}
},
props: {
@@ -95,15 +93,118 @@ export default {
},
mounted() {
this.loadData()
this.loadTree()
},
methods: {
modalFormOk(val,vauel) {
// console.log('pppppp')
console.log(val)
console.log(vauel,'vauelvauel')
loadTree() {
var that = this
that.treeData = []
that.departTree = []
queryDepartTreeList().then((res) => {
if (res.success) {
//部门全选后,再添加部门,选中数量增多
this.allTreeKeys = []
// console.log(res.result.length,'res.result.length')
for (let i = 0; i < res.result.length; i++) {
let temp = res.result[i]
// console.log(i,'oo')
// console.log(temp,'temptemp')
that.treeData.push(temp)
that.departTree.push(temp)
// console.log(that.departTree,'that.departTreethat.departTree')
// that.setThisExpandedKeys(temp)
// that.getAllKeys(temp)
// console.log(temp.id)
}
this.loading = false
}
})
},
onSearch() {
this.$refs.departWindow.add(this.checkedDepartKeys, this.userId)
setThisExpandedKeys(node) {
console.log(node,'setThisExpandedKeys')
if (node.children && node.children.length > 0) {
this.iExpandedKeys.push(node.key)
for (let a = 0; a < node.children.length; a++) {
this.setThisExpandedKeys(node.children[a])
}
}
},
getAllKeys(node) {
console.log('getAllKeys',node);
this.allTreeKeys.push(node.key)
if (node.children && node.children.length > 0) {
for (let a = 0; a < node.children.length; a++) {
this.getAllKeys(node.children[a])
}
}
},
onExpand(expandedKeys) {
console.log(expandedKeys,'expandedKeys')
this.iExpandedKeys = expandedKeys
},
// 触发onSelect事件时,为部门树右侧的form表单赋值
setValuesToForm(record) {
if (record.orgCategory == '1') {
this.orgCategoryDisabled = true
} else {
this.orgCategoryDisabled = false
}
this.$nextTick(() => {
this.form.getFieldDecorator('fax', { initialValue: '' })
this.form.setFieldsValue(pick(record, 'departName', 'orgCategory', 'orgCode', 'departOrder', 'mobile', 'fax', 'address', 'memo'))
})
},
// 右键操作方法
rightHandle(node) {
console.log(node)
this.dropTrigger = 'contextmenu'
console.log(node.node.eventKey)
this.rightClickSelectedKey = node.node.eventKey
this.rightClickSelectedOrgCode = node.node.dataRef.orgCode
},
onCheck(checkedKeys,info) {
// console.log(checkedKeys,info)
this.hiding = false
if (this.checkStrictly) {
this.checkedKeys = checkedKeys.checked
} else {
this.checkedKeys = checkedKeys
}
},
onSelect(selectedKeys, e) {
console.log(selectedKeys,e)
this.hiding = false
let record = e.node.dataRef
this.currSelected = Object.assign({}, record)
this.model = this.currSelected
this.selectedKeys = [record.key]
this.model.parentId = record.parentId
this.setValuesToForm(record)
this.recordTab = record
// this.$refs.departAuth.show(record.id)
// 传用户信息参数
if (this.$refs.DeptUserInfo) {
this.$refs.DeptUserInfo.open(record)
}
},
onSearch(value) {
let that = this
if (value) {
searchByKeywords({ keyWord: value }).then((res) => {
if (res.success) {
that.departTree = []
for (let i = 0; i < res.result.length; i++) {
let temp = res.result[i]
that.departTree.push(temp)
}
} else {
that.$message.warning(res.message)
}
})
} else {
that.loadTree()
}
},
loadData() {
this.loading = true
@@ -116,14 +217,14 @@ export default {
})
},
handleCancel() {
this.$emit('areaVisibleTaskCutOffTimeflag', false)
this.$emit('departmentvisible', false)
},
//保存
handleSubmit() {
let param = {ids: this.selectedRowKeysArray.join(','), selectedroles: `${this.selectedRole.join(',')}` }
postAction('/sys/user/setRole', param).then((res) => {
let param = {ids: this.selectedRowKeysArray.join(','), selecteddeparts: `${this.checkedKeys.join(',')}` }
postAction('/sys/user/setDepart', param).then((res) => {
if (res.success) {
this.$emit('areaVisibleTaskCutOffTimeflag', false)
this.$emit('departmentvisible', false)
this.$message.success(res.message)
} else {
this.$message.warning(res.message)