修改文档库的人员选择

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> <template>
<div> <div>
<div class="box-title-text"> <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"> <a-button type="primary" class="button-box" @click="standardClick">
{{this.$t('PersonnelSelection')}} {{this.$t('PersonnelSelection')}}
</a-button> </a-button>
@@ -15,16 +16,18 @@
@close="handleCancel" @close="handleCancel"
:visible="visible" :visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;"> 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"> <div class="drawer-content">
<a-tree <a-tree
style="margin-bottom: 60px;height: 600px" style="margin-bottom: 60px;height: 600px"
v-if="treeVisible"
checkable checkable
:loading="loading" :loading="loading"
:tree-data="gData" :tree-data="gData"
@select="onSelect" @select="onSelect"
@check="onCheck" @check="onCheck"
@expand="onExpand" @expand="onExpand"
:defaultCheckedKeys="defaultCheckedKeys"
:defaultExpandedKeys="defaultExpandedKeys" :defaultExpandedKeys="defaultExpandedKeys"
> >
</a-tree> </a-tree>
@@ -32,7 +35,7 @@
<div class="drawer-bootom-button"> <div class="drawer-bootom-button">
<a-button @click="handleCancel" type="danger" style="margin-right: 16px">{{$t('cancel')}}</a-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> </div>
</a-drawer> </a-drawer>
</div> </div>
@@ -40,29 +43,36 @@
<script> <script>
import { getAction, postAction } from '@/api/manage' import { getAction, postAction } from '@/api/manage'
export default { export default {
name: 'index', name: 'index',
props: ['query', 'value'], props: ['query', 'value', 'personneQuery'],
data(){ data() {
return{ return {
loading:true, loading: true,
gData:[], gData: [],
autoExpandParent: true, autoExpandParent: true,
expandedKeys:[], expandedKeys: [],
visible: false, visible: false,
confirmLoading:false, treeVisible: false,
departId:'', confirmLoading: false,
departId: '',
selectedKey: [], selectedKey: [],
userIds:[], userIds: [],
defaultExpandedKeys: [],
defaultCheckedKeys: []
} }
}, },
mounted() { mounted() {
}, },
methods:{ methods: {
standardClick() { standardClick() {
this.treeVisible = false
this.departId = '' this.departId = ''
this.userIds = [] this.userIds = []
this.userName = []
this.queryDepartUserTreeList()
this.visible = true this.visible = true
}, },
onSelect(selectedKeys, info) { onSelect(selectedKeys, info) {
@@ -70,18 +80,35 @@
}, },
onCheck(checkedKeys, info) { 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.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) { indexclick(event) {
this.$emit('input', event.target.value) this.$emit('input', event.target.value)
}, },
onChange(){ onChange() {
}, },
onExpand(selectedKeys, val) { onExpand(selectedKeys, val) {
@@ -94,17 +121,30 @@
} }
}, },
queryDepartUserTreeList() { queryDepartUserTreeList() {
let gData = JSON.parse(JSON.stringify(this.gData))
if (gData && gData.length > 0) {
gData = JSON.stringify(gData)
} else {
gData = ''
}
this.confirmLoading = true 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 this.confirmLoading = false
if (res.success) { if (res.success) {
this.gData = res.result 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 { } else {
this.gData = [] this.gData = []
} }
}) })
}, }
}, }
} }
</script> </script>
@@ -126,6 +166,7 @@
line-height: 38px; line-height: 38px;
} }
.drawer-bootom-button { .drawer-bootom-button {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@@ -137,7 +178,8 @@
background: #fff; background: #fff;
border-radius: 0 0 2px 2px; border-radius: 0 0 2px 2px;
} }
.drawer-content{
.drawer-content {
height: calc(100% - 60px); height: calc(100% - 60px);
overflow: auto; overflow: auto;
} }
@@ -153,7 +153,6 @@
} }
}, },
indexclick(event) { indexclick(event) {
console.log(event)
this.$emit('input', event.target.value) this.$emit('input', event.target.value)
}, },
onSelectChange(value) { onSelectChange(value) {
@@ -147,6 +147,8 @@
</div> </div>
<a-form-model-item class="itemModel" :prop="item.db_field_name"> <a-form-model-item class="itemModel" :prop="item.db_field_name">
<PersonnelSelection :query="item" <PersonnelSelection :query="item"
:personneQuery="formInline"
@change="PersonnelSelectionChange"
:disabled="disabled" :disabled="disabled"
v-model="formInline[item.db_field_name]"/> v-model="formInline[item.db_field_name]"/>
</a-form-model-item> </a-form-model-item>
@@ -323,7 +325,7 @@
this.$emit('addFormClick') this.$emit('addFormClick')
} else { } else {
this.confirmLoading = false this.confirmLoading = false
if (res.message.indexOf('发布日期不能大于')>=0) { if (res.message.indexOf('发布日期不能大于') >= 0) {
this.$message.warning(res.message) this.$message.warning(res.message)
} else { } else {
this.$message.warning(this.$t('operationFailed')) this.$message.warning(this.$t('operationFailed'))
@@ -474,6 +476,10 @@
StandardselectionChange(value, id) { StandardselectionChange(value, id) {
this.formInline[value + '_id'] = id this.formInline[value + '_id'] = id
this.formInline = { ...this.formInline } this.formInline = { ...this.formInline }
},
PersonnelSelectionChange(value, id) {
this.formInline[value + '_id'] = id
this.formInline = { ...this.formInline }
} }
} }
} }