去掉多余的api地址
This commit is contained in:
@@ -1,241 +1,226 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-modal
|
<a-modal
|
||||||
title="选择部门"
|
title="选择部门"
|
||||||
:width="modalWidth"
|
:width="modalWidth"
|
||||||
:visible="visible"
|
:visible="visible"
|
||||||
:confirmLoading="confirmLoading"
|
:confirmLoading="confirmLoading"
|
||||||
@ok="handleSubmit"
|
@ok="handleSubmit"
|
||||||
@cancel="handleCancel"
|
@cancel="handleCancel"
|
||||||
cancelText="关闭">
|
cancelText="关闭">
|
||||||
<a-spin tip="Loading..." :spinning="false">
|
<a-spin tip="Loading..." :spinning="false">
|
||||||
<a-input-search style="margin-bottom: 1px" placeholder="请输入部门名称按回车进行搜索" @search="onSearch" />
|
<a-input-search style="margin-bottom: 1px" placeholder="请输入部门名称按回车进行搜索" @search="onSearch" />
|
||||||
<a-tree
|
<a-tree
|
||||||
checkable
|
checkable
|
||||||
:treeData="treeData"
|
:treeData="treeData"
|
||||||
:checkStrictly="true"
|
:checkStrictly="true"
|
||||||
@check="onCheck"
|
@check="onCheck"
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
@expand="onExpand"
|
@expand="onExpand"
|
||||||
:autoExpandParent="autoExpandParent"
|
:autoExpandParent="autoExpandParent"
|
||||||
:expandedKeys="expandedKeys"
|
:expandedKeys="expandedKeys"
|
||||||
:checkedKeys="checkedKeys">
|
:checkedKeys="checkedKeys">
|
||||||
|
|
||||||
<template slot="title" slot-scope="{title}">
|
<template slot="title" slot-scope="{title}">
|
||||||
<span v-if="title.indexOf(searchValue) > -1">
|
<span v-if="title.indexOf(searchValue) > -1">
|
||||||
{{title.substr(0, title.indexOf(searchValue))}}
|
{{title.substr(0, title.indexOf(searchValue))}}
|
||||||
<span style="color: #f50">{{searchValue}}</span>
|
<span style="color: #f50">{{searchValue}}</span>
|
||||||
{{title.substr(title.indexOf(searchValue) + searchValue.length)}}
|
{{title.substr(title.indexOf(searchValue) + searchValue.length)}}
|
||||||
</span>
|
</span>
|
||||||
<span v-else>{{title}}</span>
|
<span v-else>{{title}}</span>
|
||||||
</template>
|
</template>
|
||||||
</a-tree>
|
</a-tree>
|
||||||
|
|
||||||
</a-spin>
|
</a-spin>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { queryDepartTreeList } from '@/api/api'
|
export default {
|
||||||
export default {
|
name: 'JSelectDepartModal',
|
||||||
name: 'JSelectDepartModal',
|
props:['modalWidth','multi','rootOpened','departId'],
|
||||||
props:['modalWidth','multi','rootOpened','departId'],
|
data(){
|
||||||
data(){
|
return {
|
||||||
return {
|
visible:false,
|
||||||
visible:false,
|
confirmLoading:false,
|
||||||
confirmLoading:false,
|
treeData:[],
|
||||||
treeData:[],
|
autoExpandParent:true,
|
||||||
autoExpandParent:true,
|
expandedKeys:[],
|
||||||
expandedKeys:[],
|
dataList:[],
|
||||||
dataList:[],
|
checkedKeys:[],
|
||||||
checkedKeys:[],
|
checkedRows:[],
|
||||||
checkedRows:[],
|
searchValue:""
|
||||||
searchValue:""
|
}
|
||||||
}
|
},
|
||||||
},
|
created(){
|
||||||
created(){
|
},
|
||||||
this.loadDepart();
|
watch:{
|
||||||
},
|
departId(){
|
||||||
watch:{
|
this.initDepartComponent()
|
||||||
departId(){
|
},
|
||||||
this.initDepartComponent()
|
visible: {
|
||||||
},
|
handler() {
|
||||||
visible: {
|
if (this.departId) {
|
||||||
handler() {
|
this.checkedKeys = this.departId.split(",");
|
||||||
if (this.departId) {
|
// console.log('this.departId', this.departId)
|
||||||
this.checkedKeys = this.departId.split(",");
|
} else {
|
||||||
// console.log('this.departId', this.departId)
|
this.checkedKeys = [];
|
||||||
} else {
|
}
|
||||||
this.checkedKeys = [];
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
methods:{
|
||||||
},
|
show(){
|
||||||
methods:{
|
this.visible=true
|
||||||
show(){
|
this.checkedRows=[]
|
||||||
this.visible=true
|
this.checkedKeys=[]
|
||||||
this.checkedRows=[]
|
},
|
||||||
this.checkedKeys=[]
|
initDepartComponent(){
|
||||||
},
|
let names = ''
|
||||||
loadDepart(){
|
if(this.departId){
|
||||||
queryDepartTreeList().then(res=>{
|
let currDepartId = this.departId
|
||||||
if(res.success){
|
for(let item of this.dataList){
|
||||||
let arr = [...res.result]
|
if(currDepartId.indexOf(item.key)>=0){
|
||||||
this.reWriterWithSlot(arr)
|
names+=","+item.title
|
||||||
this.treeData = arr
|
}
|
||||||
this.initDepartComponent()
|
}
|
||||||
if(this.rootOpened){
|
if(names){
|
||||||
this.initExpandedKeys(res.result)
|
names = names.substring(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
this.$emit("initComp",names)
|
||||||
},
|
},
|
||||||
initDepartComponent(){
|
reWriterWithSlot(arr){
|
||||||
let names = ''
|
for(let item of arr){
|
||||||
if(this.departId){
|
if(item.children && item.children.length>0){
|
||||||
let currDepartId = this.departId
|
this.reWriterWithSlot(item.children)
|
||||||
for(let item of this.dataList){
|
let temp = Object.assign({},item)
|
||||||
if(currDepartId.indexOf(item.key)>=0){
|
temp.children = {}
|
||||||
names+=","+item.title
|
this.dataList.push(temp)
|
||||||
}
|
}else{
|
||||||
}
|
this.dataList.push(item)
|
||||||
if(names){
|
item.scopedSlots={ title: 'title' }
|
||||||
names = names.substring(1)
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
this.$emit("initComp",names)
|
initExpandedKeys(arr){
|
||||||
},
|
if(arr && arr.length>0){
|
||||||
reWriterWithSlot(arr){
|
let keys = []
|
||||||
for(let item of arr){
|
for(let item of arr){
|
||||||
if(item.children && item.children.length>0){
|
if(item.children && item.children.length>0){
|
||||||
this.reWriterWithSlot(item.children)
|
keys.push(item.id)
|
||||||
let temp = Object.assign({},item)
|
}
|
||||||
temp.children = {}
|
}
|
||||||
this.dataList.push(temp)
|
this.expandedKeys=[...keys]
|
||||||
}else{
|
}else{
|
||||||
this.dataList.push(item)
|
this.expandedKeys=[]
|
||||||
item.scopedSlots={ title: 'title' }
|
}
|
||||||
}
|
},
|
||||||
}
|
onCheck (checkedKeys,info) {
|
||||||
},
|
if(!this.multi){
|
||||||
initExpandedKeys(arr){
|
let arr = checkedKeys.checked.filter(item => this.checkedKeys.indexOf(item) < 0)
|
||||||
if(arr && arr.length>0){
|
this.checkedKeys = [...arr]
|
||||||
let keys = []
|
this.checkedRows = (this.checkedKeys.length === 0) ? [] : [info.node.dataRef]
|
||||||
for(let item of arr){
|
}else{
|
||||||
if(item.children && item.children.length>0){
|
this.checkedKeys = checkedKeys.checked
|
||||||
keys.push(item.id)
|
this.checkedRows = this.getCheckedRows(this.checkedKeys)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
this.expandedKeys=[...keys]
|
onSelect(selectedKeys,info) {
|
||||||
}else{
|
let keys = []
|
||||||
this.expandedKeys=[]
|
keys.push(selectedKeys[0])
|
||||||
}
|
if(!this.checkedKeys || this.checkedKeys.length===0 || !this.multi){
|
||||||
},
|
this.checkedKeys = [...keys]
|
||||||
onCheck (checkedKeys,info) {
|
this.checkedRows=[info.node.dataRef]
|
||||||
if(!this.multi){
|
}else{
|
||||||
let arr = checkedKeys.checked.filter(item => this.checkedKeys.indexOf(item) < 0)
|
let currKey = info.node.dataRef.key
|
||||||
this.checkedKeys = [...arr]
|
if(this.checkedKeys.indexOf(currKey)>=0){
|
||||||
this.checkedRows = (this.checkedKeys.length === 0) ? [] : [info.node.dataRef]
|
this.checkedKeys = this.checkedKeys.filter(item=> item !==currKey)
|
||||||
}else{
|
}else{
|
||||||
this.checkedKeys = checkedKeys.checked
|
this.checkedKeys.push(...keys)
|
||||||
this.checkedRows = this.getCheckedRows(this.checkedKeys)
|
}
|
||||||
}
|
}
|
||||||
},
|
this.checkedRows = this.getCheckedRows(this.checkedKeys)
|
||||||
onSelect(selectedKeys,info) {
|
},
|
||||||
let keys = []
|
onExpand (expandedKeys) {
|
||||||
keys.push(selectedKeys[0])
|
this.expandedKeys = expandedKeys
|
||||||
if(!this.checkedKeys || this.checkedKeys.length===0 || !this.multi){
|
this.autoExpandParent = false
|
||||||
this.checkedKeys = [...keys]
|
},
|
||||||
this.checkedRows=[info.node.dataRef]
|
handleSubmit(){
|
||||||
}else{
|
if(!this.checkedKeys || this.checkedKeys.length==0){
|
||||||
let currKey = info.node.dataRef.key
|
this.$emit("ok",'')
|
||||||
if(this.checkedKeys.indexOf(currKey)>=0){
|
}else{
|
||||||
this.checkedKeys = this.checkedKeys.filter(item=> item !==currKey)
|
this.$emit("ok",this.checkedRows,this.checkedKeys.join(","))
|
||||||
}else{
|
}
|
||||||
this.checkedKeys.push(...keys)
|
this.handleClear()
|
||||||
}
|
},
|
||||||
}
|
handleCancel(){
|
||||||
this.checkedRows = this.getCheckedRows(this.checkedKeys)
|
this.handleClear()
|
||||||
},
|
},
|
||||||
onExpand (expandedKeys) {
|
handleClear(){
|
||||||
this.expandedKeys = expandedKeys
|
this.visible=false
|
||||||
this.autoExpandParent = false
|
this.checkedKeys=[]
|
||||||
},
|
},
|
||||||
handleSubmit(){
|
getParentKey(currKey,treeData){
|
||||||
if(!this.checkedKeys || this.checkedKeys.length==0){
|
let parentKey
|
||||||
this.$emit("ok",'')
|
for (let i = 0; i < treeData.length; i++) {
|
||||||
}else{
|
const node = treeData[i]
|
||||||
this.$emit("ok",this.checkedRows,this.checkedKeys.join(","))
|
if (node.children) {
|
||||||
}
|
if (node.children.some(item => item.key === currKey)) {
|
||||||
this.handleClear()
|
parentKey = node.key
|
||||||
},
|
} else if (this.getParentKey(currKey, node.children)) {
|
||||||
handleCancel(){
|
parentKey = this.getParentKey(currKey, node.children)
|
||||||
this.handleClear()
|
}
|
||||||
},
|
}
|
||||||
handleClear(){
|
}
|
||||||
this.visible=false
|
return parentKey
|
||||||
this.checkedKeys=[]
|
},
|
||||||
},
|
onSearch(value){
|
||||||
getParentKey(currKey,treeData){
|
const expandedKeys = this.dataList.map((item) => {
|
||||||
let parentKey
|
if (item.title.indexOf(value) > -1) {
|
||||||
for (let i = 0; i < treeData.length; i++) {
|
return this.getParentKey(item.key,this.treeData)
|
||||||
const node = treeData[i]
|
}
|
||||||
if (node.children) {
|
return null
|
||||||
if (node.children.some(item => item.key === currKey)) {
|
}).filter((item, i, self) => item && self.indexOf(item) === i)
|
||||||
parentKey = node.key
|
|
||||||
} else if (this.getParentKey(currKey, node.children)) {
|
Object.assign(this, {
|
||||||
parentKey = this.getParentKey(currKey, node.children)
|
expandedKeys,
|
||||||
}
|
searchValue: value,
|
||||||
}
|
autoExpandParent: true,
|
||||||
}
|
})
|
||||||
return parentKey
|
|
||||||
},
|
|
||||||
onSearch(value){
|
},
|
||||||
const expandedKeys = this.dataList.map((item) => {
|
// 根据 checkedKeys 获取 rows
|
||||||
if (item.title.indexOf(value) > -1) {
|
getCheckedRows(checkedKeys) {
|
||||||
return this.getParentKey(item.key,this.treeData)
|
const forChildren = (list, key) => {
|
||||||
}
|
for (let item of list) {
|
||||||
return null
|
if (item.id === key) {
|
||||||
}).filter((item, i, self) => item && self.indexOf(item) === i)
|
return item
|
||||||
|
}
|
||||||
Object.assign(this, {
|
if (item.children instanceof Array) {
|
||||||
expandedKeys,
|
let value = forChildren(item.children, key)
|
||||||
searchValue: value,
|
if (value != null) {
|
||||||
autoExpandParent: true,
|
return value
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
return null
|
||||||
// 根据 checkedKeys 获取 rows
|
}
|
||||||
getCheckedRows(checkedKeys) {
|
|
||||||
const forChildren = (list, key) => {
|
let rows = []
|
||||||
for (let item of list) {
|
for (let key of checkedKeys) {
|
||||||
if (item.id === key) {
|
let row = forChildren(this.treeData, key)
|
||||||
return item
|
if (row != null) {
|
||||||
}
|
rows.push(row)
|
||||||
if (item.children instanceof Array) {
|
}
|
||||||
let value = forChildren(item.children, key)
|
}
|
||||||
if (value != null) {
|
return rows
|
||||||
return value
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null
|
</script>
|
||||||
}
|
|
||||||
|
<style scoped>
|
||||||
let rows = []
|
|
||||||
for (let key of checkedKeys) {
|
|
||||||
let row = forChildren(this.treeData, key)
|
|
||||||
if (row != null) {
|
|
||||||
rows.push(row)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -1,329 +1,322 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-modal
|
<a-modal
|
||||||
:width="modalWidth"
|
:width="modalWidth"
|
||||||
:visible="visible"
|
:visible="visible"
|
||||||
:title="title"
|
:title="title"
|
||||||
@ok="handleSubmit"
|
@ok="handleSubmit"
|
||||||
@cancel="close"
|
@cancel="close"
|
||||||
cancelText="关闭"
|
cancelText="关闭"
|
||||||
style="margin-top: -70px"
|
style="margin-top: -70px"
|
||||||
wrapClassName="ant-modal-cust-warp"
|
wrapClassName="ant-modal-cust-warp"
|
||||||
>
|
>
|
||||||
<a-row :gutter="10" style="background-color: #ececec; padding: 10px; margin: -10px">
|
<a-row :gutter="10" style="background-color: #ececec; padding: 10px; margin: -10px">
|
||||||
<a-col :md="6" :sm="24">
|
<a-col :md="6" :sm="24">
|
||||||
<a-card :bordered="false">
|
<a-card :bordered="false">
|
||||||
<!--组织机构-->
|
<!--组织机构-->
|
||||||
<a-directory-tree
|
<a-directory-tree
|
||||||
selectable
|
selectable
|
||||||
:selectedKeys="selectedDepIds"
|
:selectedKeys="selectedDepIds"
|
||||||
:checkStrictly="true"
|
:checkStrictly="true"
|
||||||
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
|
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
|
||||||
:treeData="departTree"
|
:treeData="departTree"
|
||||||
:expandAction="false"
|
:expandAction="false"
|
||||||
:expandedKeys.sync="expandedKeys"
|
:expandedKeys.sync="expandedKeys"
|
||||||
@select="onDepSelect"
|
@select="onDepSelect"
|
||||||
/>
|
/>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :md="18" :sm="24">
|
<a-col :md="18" :sm="24">
|
||||||
<a-card :bordered="false">
|
<a-card :bordered="false">
|
||||||
用户账号:
|
用户账号:
|
||||||
<a-input-search
|
<a-input-search
|
||||||
:style="{width:'150px',marginBottom:'15px'}"
|
:style="{width:'150px',marginBottom:'15px'}"
|
||||||
placeholder="请输入账号"
|
placeholder="请输入账号"
|
||||||
v-model="queryParam.username"
|
v-model="queryParam.username"
|
||||||
@search="onSearch"
|
@search="onSearch"
|
||||||
></a-input-search>
|
></a-input-search>
|
||||||
<a-button @click="searchReset(1)" style="margin-left: 20px" icon="redo">重置</a-button>
|
<a-button @click="searchReset(1)" style="margin-left: 20px" icon="redo">重置</a-button>
|
||||||
<!--用户列表-->
|
<!--用户列表-->
|
||||||
<a-table
|
<a-table
|
||||||
ref="table"
|
ref="table"
|
||||||
:scroll="scrollTrigger"
|
:scroll="scrollTrigger"
|
||||||
size="middle"
|
size="middle"
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:dataSource="dataSource"
|
:dataSource="dataSource"
|
||||||
:pagination="ipagination"
|
:pagination="ipagination"
|
||||||
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type: getType}"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type: getType}"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@change="handleTableChange">
|
@change="handleTableChange">
|
||||||
</a-table>
|
</a-table>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {filterObj} from '@/utils/util'
|
import {filterObj} from '@/utils/util'
|
||||||
import {queryDepartTreeList, getUserList, queryUserByDepId} from '@/api/api'
|
import {getUserList, queryUserByDepId} from '@/api/api'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JSelectUserByDepModal',
|
name: 'JSelectUserByDepModal',
|
||||||
components: {},
|
components: {},
|
||||||
props: ['modalWidth', 'multi', 'userIds'],
|
props: ['modalWidth', 'multi', 'userIds'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
queryParam: {
|
queryParam: {
|
||||||
username: "",
|
username: "",
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: '用户账号',
|
title: '用户账号',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'username'
|
dataIndex: 'username'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '用户姓名',
|
title: '用户姓名',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'realname'
|
dataIndex: 'realname'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '性别',
|
title: '性别',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'sex',
|
dataIndex: 'sex',
|
||||||
customRender: function (text) {
|
customRender: function (text) {
|
||||||
if (text === 1) {
|
if (text === 1) {
|
||||||
return '男'
|
return '男'
|
||||||
} else if (text === 2) {
|
} else if (text === 2) {
|
||||||
return '女'
|
return '女'
|
||||||
} else {
|
} else {
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '手机',
|
title: '手机',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'phone'
|
dataIndex: 'phone'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '部门',
|
title: '部门',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'orgCode'
|
dataIndex: 'orgCode'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
scrollTrigger: {},
|
scrollTrigger: {},
|
||||||
dataSource: [],
|
dataSource: [],
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
selectUserRows: [],
|
selectUserRows: [],
|
||||||
selectUserIds: [],
|
selectUserIds: [],
|
||||||
title: '根据部门选择用户',
|
title: '根据部门选择用户',
|
||||||
ipagination: {
|
ipagination: {
|
||||||
current: 1,
|
current: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
pageSizeOptions: ['10', '20', '30'],
|
pageSizeOptions: ['10', '20', '30'],
|
||||||
showTotal: (total, range) => {
|
showTotal: (total, range) => {
|
||||||
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
||||||
},
|
},
|
||||||
showQuickJumper: true,
|
showQuickJumper: true,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
total: 0
|
total: 0
|
||||||
},
|
},
|
||||||
isorter: {
|
isorter: {
|
||||||
column: 'createTime',
|
column: 'createTime',
|
||||||
order: 'desc'
|
order: 'desc'
|
||||||
},
|
},
|
||||||
selectedDepIds: [],
|
selectedDepIds: [],
|
||||||
departTree: [],
|
departTree: [],
|
||||||
visible: false,
|
visible: false,
|
||||||
form: this.$form.createForm(this),
|
form: this.$form.createForm(this),
|
||||||
loading: false,
|
loading: false,
|
||||||
expandedKeys: [],
|
expandedKeys: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// 计算属性的 getter
|
// 计算属性的 getter
|
||||||
getType: function () {
|
getType: function () {
|
||||||
return this.multi == true ? 'checkbox' : 'radio';
|
return this.multi == true ? 'checkbox' : 'radio';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
userIds: {
|
userIds: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler() {
|
handler() {
|
||||||
this.initUserNames()
|
this.initUserNames()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// 该方法触发屏幕自适应
|
// 该方法触发屏幕自适应
|
||||||
this.resetScreenSize();
|
this.resetScreenSize();
|
||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initUserNames() {
|
initUserNames() {
|
||||||
if (this.userIds) {
|
if (this.userIds) {
|
||||||
// 这里最后加一个 , 的原因是因为无论如何都要使用 in 查询,防止后台进行了模糊匹配,导致查询结果不准确
|
// 这里最后加一个 , 的原因是因为无论如何都要使用 in 查询,防止后台进行了模糊匹配,导致查询结果不准确
|
||||||
let values = this.userIds.split(',') + ','
|
let values = this.userIds.split(',') + ','
|
||||||
getUserList({
|
getUserList({
|
||||||
username: values,
|
username: values,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: values.length
|
pageSize: values.length
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
let selectedRowKeys = []
|
let selectedRowKeys = []
|
||||||
let realNames = []
|
let realNames = []
|
||||||
res.result.records.forEach(user => {
|
res.result.records.forEach(user => {
|
||||||
realNames.push(user['realname'])
|
realNames.push(user['realname'])
|
||||||
selectedRowKeys.push(user['id'])
|
selectedRowKeys.push(user['id'])
|
||||||
})
|
})
|
||||||
this.selectedRowKeys = selectedRowKeys
|
this.selectedRowKeys = selectedRowKeys
|
||||||
this.$emit('initComp', realNames.join(','))
|
this.$emit('initComp', realNames.join(','))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// JSelectUserByDep组件bug issues/I16634
|
// JSelectUserByDep组件bug issues/I16634
|
||||||
this.$emit('initComp', '')
|
this.$emit('initComp', '')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async loadData(arg) {
|
async loadData(arg) {
|
||||||
if (arg === 1) {
|
if (arg === 1) {
|
||||||
this.ipagination.current = 1;
|
this.ipagination.current = 1;
|
||||||
}
|
}
|
||||||
if (this.selectedDepIds && this.selectedDepIds.length > 0) {
|
if (this.selectedDepIds && this.selectedDepIds.length > 0) {
|
||||||
await this.initQueryUserByDepId(this.selectedDepIds)
|
await this.initQueryUserByDepId(this.selectedDepIds)
|
||||||
} else {
|
} else {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
let params = this.getQueryParams()//查询条件
|
let params = this.getQueryParams()//查询条件
|
||||||
await getUserList(params).then((res) => {
|
await getUserList(params).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.dataSource = res.result.records
|
this.dataSource = res.result.records
|
||||||
this.ipagination.total = res.result.total
|
this.ipagination.total = res.result.total
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 触发屏幕自适应
|
// 触发屏幕自适应
|
||||||
resetScreenSize() {
|
resetScreenSize() {
|
||||||
let screenWidth = document.body.clientWidth;
|
let screenWidth = document.body.clientWidth;
|
||||||
if (screenWidth < 500) {
|
if (screenWidth < 500) {
|
||||||
this.scrollTrigger = {x: 800};
|
this.scrollTrigger = {x: 800};
|
||||||
} else {
|
} else {
|
||||||
this.scrollTrigger = {};
|
this.scrollTrigger = {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showModal() {
|
showModal() {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.queryDepartTree();
|
this.queryDepartTree();
|
||||||
this.initUserNames()
|
this.initUserNames()
|
||||||
this.loadData();
|
this.loadData();
|
||||||
this.form.resetFields();
|
this.form.resetFields();
|
||||||
},
|
},
|
||||||
getQueryParams() {
|
getQueryParams() {
|
||||||
let param = Object.assign({}, this.queryParam, this.isorter);
|
let param = Object.assign({}, this.queryParam, this.isorter);
|
||||||
param.field = this.getQueryField();
|
param.field = this.getQueryField();
|
||||||
param.pageNo = this.ipagination.current;
|
param.pageNo = this.ipagination.current;
|
||||||
param.pageSize = this.ipagination.pageSize;
|
param.pageSize = this.ipagination.pageSize;
|
||||||
return filterObj(param);
|
return filterObj(param);
|
||||||
},
|
},
|
||||||
getQueryField() {
|
getQueryField() {
|
||||||
let str = 'id,';
|
let str = 'id,';
|
||||||
for (let a = 0; a < this.columns.length; a++) {
|
for (let a = 0; a < this.columns.length; a++) {
|
||||||
str += ',' + this.columns[a].dataIndex;
|
str += ',' + this.columns[a].dataIndex;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
searchReset(num) {
|
searchReset(num) {
|
||||||
let that = this;
|
let that = this;
|
||||||
if (num !== 0) {
|
if (num !== 0) {
|
||||||
that.queryParam = {};
|
that.queryParam = {};
|
||||||
that.loadData(1);
|
that.loadData(1);
|
||||||
}
|
}
|
||||||
that.selectedRowKeys = [];
|
that.selectedRowKeys = [];
|
||||||
that.selectUserIds = [];
|
that.selectUserIds = [];
|
||||||
that.selectedDepIds = [];
|
that.selectedDepIds = [];
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.searchReset(0);
|
this.searchReset(0);
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
},
|
},
|
||||||
handleTableChange(pagination, filters, sorter) {
|
handleTableChange(pagination, filters, sorter) {
|
||||||
//TODO 筛选
|
//TODO 筛选
|
||||||
if (Object.keys(sorter).length > 0) {
|
if (Object.keys(sorter).length > 0) {
|
||||||
this.isorter.column = sorter.field;
|
this.isorter.column = sorter.field;
|
||||||
this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc';
|
this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc';
|
||||||
}
|
}
|
||||||
this.ipagination = pagination;
|
this.ipagination = pagination;
|
||||||
this.loadData();
|
this.loadData();
|
||||||
},
|
},
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getSelectUserRows();
|
this.getSelectUserRows();
|
||||||
that.$emit('ok', that.selectUserRows, that.selectUserIds);
|
that.$emit('ok', that.selectUserRows, that.selectUserIds);
|
||||||
that.searchReset(0)
|
that.searchReset(0)
|
||||||
that.close();
|
that.close();
|
||||||
},
|
},
|
||||||
//获取选择用户信息
|
//获取选择用户信息
|
||||||
getSelectUserRows(rowId) {
|
getSelectUserRows(rowId) {
|
||||||
let dataSource = this.dataSource;
|
let dataSource = this.dataSource;
|
||||||
let userIds = "";
|
let userIds = "";
|
||||||
this.selectUserRows = [];
|
this.selectUserRows = [];
|
||||||
for (let i = 0, len = dataSource.length; i < len; i++) {
|
for (let i = 0, len = dataSource.length; i < len; i++) {
|
||||||
if (this.selectedRowKeys.includes(dataSource[i].id)) {
|
if (this.selectedRowKeys.includes(dataSource[i].id)) {
|
||||||
this.selectUserRows.push(dataSource[i]);
|
this.selectUserRows.push(dataSource[i]);
|
||||||
userIds = userIds + "," + dataSource[i].username
|
userIds = userIds + "," + dataSource[i].username
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.selectUserIds = userIds.substring(1);
|
this.selectUserIds = userIds.substring(1);
|
||||||
},
|
},
|
||||||
// 点击树节点,筛选出对应的用户
|
// 点击树节点,筛选出对应的用户
|
||||||
onDepSelect(selectedDepIds) {
|
onDepSelect(selectedDepIds) {
|
||||||
if (selectedDepIds[0] != null) {
|
if (selectedDepIds[0] != null) {
|
||||||
this.initQueryUserByDepId(selectedDepIds); // 调用方法根据选选择的id查询用户信息
|
this.initQueryUserByDepId(selectedDepIds); // 调用方法根据选选择的id查询用户信息
|
||||||
if (this.selectedDepIds[0] !== selectedDepIds[0]) {
|
if (this.selectedDepIds[0] !== selectedDepIds[0]) {
|
||||||
this.selectedDepIds = [selectedDepIds[0]];
|
this.selectedDepIds = [selectedDepIds[0]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSelectChange(selectedRowKeys, selectionRows) {
|
onSelectChange(selectedRowKeys, selectionRows) {
|
||||||
this.selectedRowKeys = selectedRowKeys;
|
this.selectedRowKeys = selectedRowKeys;
|
||||||
this.selectionRows = selectionRows;
|
this.selectionRows = selectionRows;
|
||||||
},
|
},
|
||||||
onSearch() {
|
onSearch() {
|
||||||
this.loadData(1);
|
this.loadData(1);
|
||||||
},
|
},
|
||||||
// 根据选择的id来查询用户信息
|
// 根据选择的id来查询用户信息
|
||||||
initQueryUserByDepId(selectedDepIds) {
|
initQueryUserByDepId(selectedDepIds) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
return queryUserByDepId({id: selectedDepIds.toString()}).then((res) => {
|
return queryUserByDepId({id: selectedDepIds.toString()}).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.dataSource = res.result;
|
this.dataSource = res.result;
|
||||||
this.ipagination.total = res.result.length;
|
this.ipagination.total = res.result.length;
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
queryDepartTree() {
|
queryDepartTree() {
|
||||||
queryDepartTreeList().then((res) => {
|
},
|
||||||
if (res.success) {
|
modalFormOk() {
|
||||||
this.departTree = res.result;
|
this.loadData();
|
||||||
// 默认展开父节点
|
}
|
||||||
this.expandedKeys = this.departTree.map(item => item.id)
|
}
|
||||||
}
|
}
|
||||||
})
|
</script>
|
||||||
},
|
|
||||||
modalFormOk() {
|
<style scoped>
|
||||||
this.loadData();
|
.ant-table-tbody .ant-table-row td {
|
||||||
}
|
padding-top: 10px;
|
||||||
}
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
|
#components-layout-demo-custom-trigger .trigger {
|
||||||
<style scoped>
|
font-size: 18px;
|
||||||
.ant-table-tbody .ant-table-row td {
|
line-height: 64px;
|
||||||
padding-top: 10px;
|
padding: 0 24px;
|
||||||
padding-bottom: 10px;
|
cursor: pointer;
|
||||||
}
|
transition: color .3s;
|
||||||
|
}
|
||||||
#components-layout-demo-custom-trigger .trigger {
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 64px;
|
|
||||||
padding: 0 24px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: color .3s;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user