修改文档库的人员选择

This commit is contained in:
qq787203167
2022-03-25 16:23:23 +08:00
parent 0e0ea4a792
commit 82685b129f
3 changed files with 71 additions and 24 deletions
@@ -1,7 +1,8 @@
<template>
<div>
<div class="box-title-text">
<a-input class="box-input" :value="value" @input="indexclick($event)" :placeholder="$t('PleaseEnterOrSelect')+query.db_field_txt"/>
<a-input class="box-input" :value="value" @input="indexclick($event)"
:placeholder="$t('PleaseEnterOrSelect')+query.db_field_txt"/>
<a-button type="primary" class="button-box" @click="standardClick">
{{this.$t('PersonnelSelection')}}
</a-button>
@@ -15,16 +16,18 @@
@close="handleCancel"
:visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;">
<a-input-search style="margin-bottom: 8px" placeholder="Search" @change="onChange" />
<a-input-search style="margin-bottom: 8px" placeholder="Search" @change="onChange"/>
<div class="drawer-content">
<a-tree
style="margin-bottom: 60px;height: 600px"
v-if="treeVisible"
checkable
:loading="loading"
:tree-data="gData"
@select="onSelect"
@check="onCheck"
@expand="onExpand"
:defaultCheckedKeys="defaultCheckedKeys"
:defaultExpandedKeys="defaultExpandedKeys"
>
</a-tree>
@@ -32,7 +35,7 @@
<div class="drawer-bootom-button">
<a-button @click="handleCancel" type="danger" style="margin-right: 16px">{{$t('cancel')}}</a-button>
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
<a-button @click="handleSubmit" type="primary">{{$t('submit')}}</a-button>
</div>
</a-drawer>
</div>
@@ -40,29 +43,36 @@
<script>
import { getAction, postAction } from '@/api/manage'
export default {
name: 'index',
props: ['query', 'value'],
data(){
return{
loading:true,
gData:[],
props: ['query', 'value', 'personneQuery'],
data() {
return {
loading: true,
gData: [],
autoExpandParent: true,
expandedKeys:[],
expandedKeys: [],
visible: false,
confirmLoading:false,
departId:'',
treeVisible: false,
confirmLoading: false,
departId: '',
selectedKey: [],
userIds:[],
userIds: [],
defaultExpandedKeys: [],
defaultCheckedKeys: []
}
},
mounted() {
},
methods:{
methods: {
standardClick() {
this.treeVisible = false
this.departId = ''
this.userIds = []
this.userName = []
this.queryDepartUserTreeList()
this.visible = true
},
onSelect(selectedKeys, info) {
@@ -70,18 +80,35 @@
},
onCheck(checkedKeys, info) {
this.userIds = checkedKeys
this.userIds = []
this.userName = []
if (info.checkedNodes && info.checkedNodes.length > 0) {
info.checkedNodes.forEach(res => {
this.userIds.push(res.data.props.id)
this.userName.push(res.data.props.title)
})
}
},
handleCancel(){
handleCancel() {
this.visible = false
this.treeVisible = false
},
handleSubmit(){
handleSubmit() {
if (this.userIds && this.userIds.length > 0) {
let userIds = JSON.parse(JSON.stringify(this.userIds))
let userName = JSON.parse(JSON.stringify(this.userName))
this.$emit('input', userName.join(','))
this.$emit('change', this.query.db_field_name, userIds.join(','))
this.visible = false
this.treeVisible = false
} else {
this.$message.warning('请先选择人员')
}
},
indexclick(event) {
this.$emit('input', event.target.value)
},
onChange(){
onChange() {
},
onExpand(selectedKeys, val) {
@@ -94,17 +121,30 @@
}
},
queryDepartUserTreeList() {
let gData = JSON.parse(JSON.stringify(this.gData))
if (gData && gData.length > 0) {
gData = JSON.stringify(gData)
} else {
gData = ''
}
this.confirmLoading = true
getAction('sys/user/queryDepartUserTreeList', { departId: this.departId }).then((res) => {
postAction('sys/user/queryDepartUserTreeList', {
departId: this.departId,
json: gData
}).then((res) => {
this.confirmLoading = false
if (res.success) {
this.gData = res.result
this.defaultExpandedKeys = [this.departId]
this.defaultCheckedKeys = this.personneQuery[this.query.db_field_name + '_id'] ? this.personneQuery[this.query.db_field_name + '_id'].split(',') : []
console.log(this.defaultCheckedKeys)
this.treeVisible = true
} else {
this.gData = []
}
})
},
},
}
}
}
</script>
@@ -126,6 +166,7 @@
line-height: 38px;
}
.drawer-bootom-button {
position: absolute;
bottom: 0;
@@ -137,7 +178,8 @@
background: #fff;
border-radius: 0 0 2px 2px;
}
.drawer-content{
.drawer-content {
height: calc(100% - 60px);
overflow: auto;
}
@@ -153,7 +153,6 @@
}
},
indexclick(event) {
console.log(event)
this.$emit('input', event.target.value)
},
onSelectChange(value) {
@@ -147,6 +147,8 @@
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<PersonnelSelection :query="item"
:personneQuery="formInline"
@change="PersonnelSelectionChange"
:disabled="disabled"
v-model="formInline[item.db_field_name]"/>
</a-form-model-item>
@@ -323,7 +325,7 @@
this.$emit('addFormClick')
} else {
this.confirmLoading = false
if (res.message.indexOf('发布日期不能大于')>=0) {
if (res.message.indexOf('发布日期不能大于') >= 0) {
this.$message.warning(res.message)
} else {
this.$message.warning(this.$t('operationFailed'))
@@ -474,6 +476,10 @@
StandardselectionChange(value, id) {
this.formInline[value + '_id'] = id
this.formInline = { ...this.formInline }
},
PersonnelSelectionChange(value, id) {
this.formInline[value + '_id'] = id
this.formInline = { ...this.formInline }
}
}
}