[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> <role-assignment v-if='rolevisible' :selectedRowKeysArray='selectedRowKeys' @rolevisible='rolevisibleMethods'></role-assignment>
</a-modal> </a-modal>
<!-- 部门配置 --> <!-- 部门配置 -->
<a-modal v-model="departmentvisible" :title="$t('RoleAssignment')" width='650px' :footer="null"> <a-modal v-model="departmentvisible" :title="$t('DepartmentAllocation')" width='650px' :footer="null">
<department-allocation v-if='departmentvisible' :selectedRowKeysArray='selectedRowKeys'></department-allocation> <department-allocation v-if='departmentvisible' :selectedRowKeysArray='selectedRowKeys' @departmentvisible='departmentvisibleMethods'></department-allocation>
</a-modal> </a-modal>
</a-card> </a-card>
</template> </template>
@@ -286,6 +286,10 @@
this.rolevisible = val this.rolevisible = val
this.selectedRowKeys = [] this.selectedRowKeys = []
}, },
departmentvisibleMethods(val) {
this.departmentvisible = val
this.selectedRowKeys = []
},
getAvatarView: function(avatar) { getAvatarView: function(avatar) {
return getFileAccessHttpUrl(avatar) return getFileAccessHttpUrl(avatar)
}, },
@@ -11,25 +11,24 @@
> >
<a-row :gutter='24'> <a-row :gutter='24'>
<a-col :span='24'> <a-col :span='24'>
<!-- <a-form-item :label="$t('RoleAssignment')" :labelCol="labelCol" :wrapperCol="wrapperCol">--> <a-input-search @search="onSearch" style="width:100%;margin-top: 6px"
<!-- <a-select mode="multiple" :placeholder="$t('PleaseSelect')+$t('controlVerification')" v-model:value="selectedRole">--> :placeholder="$t('enterDepartmentName')"/>
<!-- <a-select-option v-for="(role,roleindex) in roleList" :key="role.id" :value="role.id">--> <!-- 树-->
<!-- <span style="display: inline-block;width: 100%">--> <template>
<!-- {{ role.roleName }}--> <a-tree
<!-- </span>--> multiple
<!-- </a-select-option>--> style="height:600px;overflow: auto;width: 100%"
<!-- </a-select>--> @select="onSelect"
<!-- </a-form-item>--> @check="onCheck"
<a-form-item :label="$t('DepartmentAllocation')" :labelCol="labelCol" :wrapperCol="wrapperCol" @rightClick="rightHandle"
> :selectedKeys="selectedKeys"
<a-input-search :checkedKeys="checkedKeys"
:placeholder="$t('ClickSelectDepartment')" :treeData="departTree"
v-model="checkedDepartNameString" checkable
readOnly :checkStrictly="checkStrictly"
@search="onSearch"> :autoExpandParent="false"
<a-button slot="enterButton" icon="search">{{$t('choice')}}</a-button> @expand="onExpand"/>
</a-input-search> </template>
</a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-form-model> </a-form-model>
@@ -38,7 +37,6 @@
<a-button style='margin-right: .8rem' @click='handleCancel'>{{ $t('cancel') }}</a-button> <a-button style='margin-right: .8rem' @click='handleCancel'>{{ $t('cancel') }}</a-button>
<a-button @click='handleSubmit' type='primary' :loading='confirmLoading'>{{ $t('determine') }}</a-button> <a-button @click='handleSubmit' type='primary' :loading='confirmLoading'>{{ $t('determine') }}</a-button>
</div> </div>
<depart-window ref="departWindow" @ok="modalFormOk"></depart-window>
</div> </div>
</template> </template>
@@ -47,15 +45,11 @@ import { putAction, postAction, getAction, deleteAction } from '@/api/manage'
import axios from 'axios' import axios from 'axios'
import Vue from 'vue' import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
import moment from 'moment' import { queryDepartTreeList, searchByKeywords, deleteByDepartId } from '@/api/api'
// import eventBUs from '../../common/event' import pick from 'lodash.pick'
// 引入搜索部门弹出框的组件
import departWindow from './DepartWindow'
export default { export default {
name: 'diolagArea', name: 'diolagArea',
components: { components: {},
departWindow
},
data() { data() {
return { return {
checkedDepartNameString: '', checkedDepartNameString: '',
@@ -83,7 +77,11 @@ export default {
confirmLoading: false, confirmLoading: false,
selectedRowKeys: [], selectedRowKeys: [],
roleList: [], roleList: [],
defaultValue: undefined departTree: [],
allTreeKeys: [],
selectedKeys: [],
checkStrictly: true,
checkedKeys: [],
} }
}, },
props: { props: {
@@ -95,15 +93,118 @@ export default {
}, },
mounted() { mounted() {
this.loadData() this.loadData()
this.loadTree()
}, },
methods: { methods: {
modalFormOk(val,vauel) { loadTree() {
// console.log('pppppp') var that = this
console.log(val) that.treeData = []
console.log(vauel,'vauelvauel') 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() { setThisExpandedKeys(node) {
this.$refs.departWindow.add(this.checkedDepartKeys, this.userId) 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() { loadData() {
this.loading = true this.loading = true
@@ -116,14 +217,14 @@ export default {
}) })
}, },
handleCancel() { handleCancel() {
this.$emit('areaVisibleTaskCutOffTimeflag', false) this.$emit('departmentvisible', false)
}, },
//保存 //保存
handleSubmit() { handleSubmit() {
let param = {ids: this.selectedRowKeysArray.join(','), selectedroles: `${this.selectedRole.join(',')}` } let param = {ids: this.selectedRowKeysArray.join(','), selecteddeparts: `${this.checkedKeys.join(',')}` }
postAction('/sys/user/setRole', param).then((res) => { postAction('/sys/user/setDepart', param).then((res) => {
if (res.success) { if (res.success) {
this.$emit('areaVisibleTaskCutOffTimeflag', false) this.$emit('departmentvisible', false)
this.$message.success(res.message) this.$message.success(res.message)
} else { } else {
this.$message.warning(res.message) this.$message.warning(res.message)