修改禅道已知bug

This commit is contained in:
sunFlower
2022-09-30 22:32:56 +08:00
parent 718cf9333a
commit 294f9ea383
@@ -32,40 +32,40 @@
v-model="searchModel" @search="onSearch"/> v-model="searchModel" @search="onSearch"/>
<div class="drawer-content"> <div class="drawer-content">
<JLoading :loading="loading">{{$t('dataLoading')}}</JLoading> <JLoading :loading="loading">{{$t('dataLoading')}}</JLoading>
<virtualNodeTree <!-- <virtualNodeTree-->
v-if="treeVisible"
:keeps="40"
show-checkbox
v-model="checkboxList"
class="treeWrap"
:props="{
isLeaf: 'leaf'
}"
:defaultCheckedKeys="defaultCheckedKeys"
:defaultExpandAll="defaultExpandAll"
:check-strictly="false"
node-key="id"
@check-change="handleCheckChange"
:data.sync="gData">
<span slot-scope="{ data }">
<span :class="{'active':data.color ? true:false}">
{{ data.title }}
</span>
</span>
</virtualNodeTree>
<!-- <a-tree-->
<!-- style="margin-bottom: 60px;height: 600px"-->
<!-- v-if="treeVisible"--> <!-- v-if="treeVisible"-->
<!-- checkable--> <!-- :keeps="40"-->
<!-- checkStrictly--> <!-- show-checkbox-->
<!-- :loading="loading"--> <!-- v-model="checkboxList"-->
<!-- :tree-data="gData"--> <!-- class="treeWrap"-->
<!-- @check="onCheck"--> <!-- :props="{-->
<!-- @expand="onExpand"--> <!-- isLeaf: 'leaf'-->
<!-- v-model:checkedKeys="defaultCheckedKeys"--> <!-- }"-->
<!-- :defaultExpandedKeys="defaultExpandedKeys"--> <!-- :defaultCheckedKeys="defaultCheckedKeys"-->
<!-- >--> <!-- :defaultExpandAll="defaultExpandAll"-->
<!-- </a-tree>--> <!-- :check-strictly="false"-->
<!-- node-key="id"-->
<!-- @check-change="handleCheckChange"-->
<!-- :data.sync="gData">-->
<!-- <span slot-scope="{ data }">-->
<!-- <span :class="{'active':data.color ? true:false}">-->
<!-- {{ data.title }}-->
<!-- </span>-->
<!-- </span>-->
<!-- </virtualNodeTree>-->
<a-tree
style="margin-bottom: 60px;height: 600px"
v-if="treeVisible"
checkable
checkStrictly
:loading="loading"
:tree-data="gData"
@check="onCheck"
@expand="onExpand"
v-model:checkedKeys="defaultCheckedKeys"
:defaultExpandedKeys="defaultExpandedKeys"
>
</a-tree>
</div> </div>
<div class="drawer-bootom-button"> <div class="drawer-bootom-button">
<a-button @click="handleCancel" style="margin-right: 16px">{{$t('cancel')}}</a-button> <a-button @click="handleCancel" style="margin-right: 16px">{{$t('cancel')}}</a-button>
@@ -114,101 +114,102 @@
}, },
methods: { methods: {
handleCheckChange(val, checked, indeterminate) { // handleCheckChange(val, checked, indeterminate) {
if (checked) { // if (checked) {
this.userName.push(val.title) // this.userName.push(val.title)
this.userIds.push(val.id) // this.userIds.push(val.id)
} else { // } else {
for (let i = 0; i < this.userName.length; i++) { // for (let i = 0; i < this.userName.length; i++) {
if (this.userName[i] == val.title) { // if (this.userName[i] == val.title) {
this.userName.splice(i, 1) // this.userName.splice(i, 1)
i-- // i--
} // }
} // }
for (let i = 0; i < this.userIds.length; i++) { // for (let i = 0; i < this.userIds.length; i++) {
if (this.userIds[i] == val.id) { // if (this.userIds[i] == val.id) {
this.userIds.splice(i, 1) // this.userIds.splice(i, 1)
i-- // i--
} // }
} // }
} // }
}, // },
standardClick() { standardClick() {
this.visible = true
this.treeVisible = false this.treeVisible = false
this.departId = '' this.departId = ''
this.searchModel = '' this.searchModel = ''
this.userName = []
this.userIds = [] this.userIds = []
let gData = localStorage.getItem('gData') this.userName = []
if (gData) { this.queryDepartUserTreeList(1)
let dataList = JSON.parse(gData) this.visible = true
if (!this.selectDepartment) { // let gData = localStorage.getItem('gData')
dataList.forEach(res => { // if (gData) {
if (res.type == 'Depart') { // let dataList = JSON.parse(gData)
res.disabled = true // if (!this.selectDepartment) {
} // dataList.forEach(res => {
}) // if (res.type == 'Depart') {
} // res.disabled = true
this.dataList = this.toTree(dataList) // }
} // })
setTimeout(() => { // }
if (gData) { // this.dataList = this.toTree(dataList)
this.gData = this.dataList // }
this.gData = [...this.gData] // setTimeout(() => {
// this.treeVisible = true // if (gData) {
if (this.personneQuery[this.query.db_field_name + 'Name']) { // this.gData = this.dataList
this.userName = this.personneQuery[this.query.db_field_name + 'Name'].split(',') // this.gData = [...this.gData]
} else if (this.personneQuery[this.query.db_field_name]) { // // this.treeVisible = true
this.userName = this.personneQuery[this.query.db_field_name].split(',') // if (this.personneQuery[this.query.db_field_name + 'Name']) {
} else { // this.userName = this.personneQuery[this.query.db_field_name + 'Name'].split(',')
this.userName = [] // } else if (this.personneQuery[this.query.db_field_name]) {
} // this.userName = this.personneQuery[this.query.db_field_name].split(',')
if (this.personneQuery[this.query.db_field_name + '_id']) { // } else {
this.userIds = this.personneQuery[this.query.db_field_name + '_id'].split(',') // this.userName = []
} else if (this.personneQuery[this.query.db_field_name]) { // }
this.userIds = this.personneQuery[this.query.db_field_name].split(',') // if (this.personneQuery[this.query.db_field_name + '_id']) {
} else { // this.userIds = this.personneQuery[this.query.db_field_name + '_id'].split(',')
this.userIds = [] // } else if (this.personneQuery[this.query.db_field_name]) {
} // this.userIds = this.personneQuery[this.query.db_field_name].split(',')
this.defaultCheckedKeys = this.userIds // } else {
this.defaultCheckedKeys = [...this.defaultCheckedKeys] // this.userIds = []
this.defaultExpandAll = false // }
this.treeVisible = true // this.defaultCheckedKeys = this.userIds
} else { // this.defaultCheckedKeys = [...this.defaultCheckedKeys]
this.queryDepartUserTreeList(1) // this.defaultExpandAll = false
} // this.treeVisible = true
}, 200) // } else {
// this.queryDepartUserTreeList(1)
// }
// }, 200)
}, },
//将数据拼成树形结构 //将数据拼成树形结构
toTree(config) { // toTree(config) {
// 删除 所有 children,以防止多次调用 // // 删除 所有 children,以防止多次调用
config.forEach(function(item) { // config.forEach(function(item) {
delete item.children // delete item.children
}) // })
// 将数据存储为 以 id 为 KEY 的 map 索引数据列 // // 将数据存储为 以 id 为 KEY 的 map 索引数据列
let map = {} // let map = {}
config.forEach((item) => { // config.forEach((item) => {
item.label = item.name // item.label = item.name
item.key = item.id // item.key = item.id
//
item.title = item.name + (item.itemName ? ' ' + item.itemName : '') // item.title = item.name + (item.itemName ? ' ' + item.itemName : '')
map[item.id] = item // map[item.id] = item
}) // })
let val = [] // let val = []
config.forEach((item) => { // config.forEach((item) => {
// 以当前遍历项,的pid,去map对象中找到索引的id // // 以当前遍历项,的pid,去map对象中找到索引的id
let parent = map[item.parentId] // let parent = map[item.parentId]
// 如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中 // // 如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
if (parent) { // if (parent) {
(parent.children || (parent.children = [])).push(item) // (parent.children || (parent.children = [])).push(item)
} else { // } else {
//如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级 // //如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
val.push(item) // val.push(item)
} // }
}) // })
return val // return val
}, // },
standardDelete() { standardDelete() {
this.$emit('input', null) this.$emit('input', null)
this.$forceUpdate() this.$forceUpdate()
@@ -288,12 +289,12 @@
} }
let userIds = JSON.parse(JSON.stringify(this.userIds)) let userIds = JSON.parse(JSON.stringify(this.userIds))
let userName = JSON.parse(JSON.stringify(this.userName)) let userName = JSON.parse(JSON.stringify(this.userName))
userName = userName.filter(function(item, index) { // userName = userName.filter(function(item, index) {
return userName.indexOf(item) === index // 因为indexOf 只能查找到第一个 // return userName.indexOf(item) === index // 因为indexOf 只能查找到第一个
}) // })
userIds = userIds.filter(function(item, index) { // userIds = userIds.filter(function(item, index) {
return userIds.indexOf(item) === index // 因为indexOf 只能查找到第一个 // return userIds.indexOf(item) === index // 因为indexOf 只能查找到第一个
}) // })
this.$emit('input', userName.join(',')) this.$emit('input', userName.join(','))
this.$emit('change', this.query.db_field_name, userIds.join(','), this.query.subscript) this.$emit('change', this.query.db_field_name, userIds.join(','), this.query.subscript)
this.visible = false this.visible = false
@@ -311,146 +312,146 @@
this.defaultCheckedKeys = [] this.defaultCheckedKeys = []
}, },
onSearch(e) { onSearch(e) {
this.loading = true // this.loading = true
this.treeVisible = false // this.treeVisible = false
let p = new Promise((resolve, reject) => { // let p = new Promise((resolve, reject) => {
resolve() // resolve()
// })
// p.then(() => {
// let gData = localStorage.getItem('gData')
// let content = []
// if (gData) {
// if (e) {
// JSON.parse(gData).forEach(res => {
// if (res.type == 'User') {
// if (res.name.includes(e)) {
// res.color = true
// content.push(res)
// }
// } else if (res.type == 'Depart') {
// if (!this.selectDepartment) {
// res.disabled = true
// }
// content.push(res)
// }
// })
// this.defaultExpandAll = true
// this.gData = this.toTree(content)
// } else {
// let content = JSON.parse(gData)
// if (!this.selectDepartment) {
// content.forEach(res => {
// if (res.type == 'Depart') {
// res.disabled = true
// }
// })
// }
// this.gData = this.toTree(content)
// this.defaultExpandAll = false
// }
// }
// this.defaultCheckedKeys = this.userIds
// this.defaultCheckedKeys = [...this.defaultCheckedKeys]
// this.treeVisible = true
// this.loading = false
// })
this.gData = []
this.departId = ''
this.visibleTree = false
if (e) {
this.getUserAndDepart()
} else {
this.treeVisible = false
this.queryDepartUserTreeList(2)
}
},
getUserAndDepart() {
getAction('sys/user/getUserAndDepart', { name: this.searchModel }).then((res) => {
if (res) {
this.gData = res.filter(ele => ele.flag === 'DEPART')
} else {
this.gData = []
}
this.visibleTree = true
}) })
p.then(() => { },
let gData = localStorage.getItem('gData') onExpand(selectedKeys, val) {
let content = [] if (this.searchModel == '' || !this.searchModel) {
if (gData) { if (val.expanded) {
if (e) { if (this.departId == val.node.value) {
JSON.parse(gData).forEach(res => {
if (res.type == 'User') {
if (res.name.includes(e)) {
res.color = true
content.push(res)
}
} else if (res.type == 'Depart') {
if (!this.selectDepartment) {
res.disabled = true
}
content.push(res)
}
})
this.defaultExpandAll = true
this.gData = this.toTree(content)
} else { } else {
let content = JSON.parse(gData) this.departId = val.node.value
if (!this.selectDepartment) { this.queryDepartUserTreeList(2)
content.forEach(res => {
if (res.type == 'Depart') {
res.disabled = true
}
})
}
this.gData = this.toTree(content)
this.defaultExpandAll = false
} }
} }
this.defaultCheckedKeys = this.userIds }
this.defaultCheckedKeys = [...this.defaultCheckedKeys]
this.treeVisible = true
this.loading = false
})
// this.gData = []
// this.departId = ''
// this.visibleTree = false
// if (e) {
// this.getUserAndDepart()
// } else {
// this.treeVisible = false
// this.queryDepartUserTreeList(2)
// }
}, },
// getUserAndDepart() {
// getAction('sys/user/getUserAndDepart', { name: this.searchModel }).then((res) => {
// if (res) {
// this.gData = res.filter(ele => ele.flag === 'DEPART')
// } else {
// this.gData = []
// }
// this.visibleTree = true
// })
// },
// onExpand(selectedKeys, val) {
// if (this.searchModel == '' || !this.searchModel) {
// if (val.expanded) {
// if (this.departId == val.node.value) {
// } else {
// this.departId = val.node.value
// this.queryDepartUserTreeList(2)
// }
// }
// }
// },
queryDepartUserTreeList(num) { queryDepartUserTreeList(num) {
// let gData = JSON.parse(JSON.stringify(this.gData)) let gData = JSON.parse(JSON.stringify(this.gData))
// if (gData && gData.length > 0) { if (gData && gData.length > 0) {
// gData = JSON.stringify(gData) gData = JSON.stringify(gData)
// } else { } else {
// gData = '' gData = ''
// } }
this.confirmLoading = true this.confirmLoading = true
this.loading = true this.loading = true
//queryDepartUserTreeList //queryDepartUserTreeList
//queryUserTreeList //queryUserTreeList
getAction('sys/user/queryUserTreeList', { postAction('sys/user/queryDepartUserTreeList', {
// departId: this.departId, departId: this.departId,
// json: gData, json: gData,
// flag: '1' flag: '1'
}).then((res) => { }).then((res) => {
this.confirmLoading = false this.confirmLoading = false
if (res.success) { if (res.success) {
this.loading = false this.loading = false
// localStorage.setItem('gData', JSON.stringify(res.result)) // localStorage.setItem('gData', JSON.stringify(res.result))
// this.toTree(dataList) // this.toTree(dataList)
let content = JSON.parse(JSON.stringify(res.result)) // let content = JSON.parse(JSON.stringify(res.result))
if (!this.selectDepartment) { // if (!this.selectDepartment) {
res.result.forEach(res => { // res.result.forEach(res => {
if (res.type == 'Depart') { // if (res.type == 'Depart') {
res.disabled = true // res.disabled = true
} // }
}) // })
} // }
localStorage.removeItem('gData') // localStorage.removeItem('gData')
localStorage.setItem('gData', JSON.stringify(content)) // localStorage.setItem('gData', JSON.stringify(content))
this.gData = this.toTree(res.result) // this.gData = this.toTree(res.result)
console.log(this.gData) this.gData = res.result
this.gData = [...this.gData] this.gData = [...this.gData]
// this.gData[0].isLeaf = false // this.gData[0].isLeaf = false
// this.defaultExpandedKeys = [this.departId] this.defaultExpandedKeys = [this.departId]
if (num == 1) { if (num == 1) {
// if (this.userName && this.userName.length == 0) { if (this.userName && this.userName.length == 0) {
if (this.personneQuery[this.query.db_field_name + 'Name']) { if (this.personneQuery[this.query.db_field_name + 'Name']) {
this.userName = this.personneQuery[this.query.db_field_name + 'Name'].split(',') this.userName = this.personneQuery[this.query.db_field_name + 'Name'].split(',')
} else if (this.personneQuery[this.query.db_field_name]) { } else if (this.personneQuery[this.query.db_field_name]) {
this.userName = this.personneQuery[this.query.db_field_name].split(',') this.userName = this.personneQuery[this.query.db_field_name].split(',')
} else { } else {
this.userName = [] this.userName = []
}
} }
// } if (this.userIds && this.userIds.length == 0) {
// if (this.userIds && this.userIds.length == 0) { if (this.personneQuery[this.query.db_field_name + '_id']) {
if (this.personneQuery[this.query.db_field_name + '_id']) { this.userIds = this.personneQuery[this.query.db_field_name + '_id'].split(',')
this.userIds = this.personneQuery[this.query.db_field_name + '_id'].split(',') } else if (this.personneQuery[this.query.db_field_name]) {
} else if (this.personneQuery[this.query.db_field_name]) { this.userIds = this.personneQuery[this.query.db_field_name].split(',')
this.userIds = this.personneQuery[this.query.db_field_name].split(',') } else {
} else { this.userIds = []
this.userIds = [] }
} }
// }
this.defaultCheckedKeys = this.userIds this.defaultCheckedKeys = this.userIds
this.defaultCheckedKeys = [...this.defaultCheckedKeys] this.defaultCheckedKeys = [...this.defaultCheckedKeys]
// this.defaultCheckedKeysName = [] this.defaultCheckedKeysName = []
// if (this.defaultCheckedKeys.length > 0) { if (this.defaultCheckedKeys.length > 0) {
// for (let i = 0; i < this.defaultCheckedKeys.length; i++) { for (let i = 0; i < this.defaultCheckedKeys.length; i++) {
// this.defaultCheckedKeysName.push({ this.defaultCheckedKeysName.push({
// id: this.defaultCheckedKeys[i], id: this.defaultCheckedKeys[i],
// name: this.userName[i] name: this.userName[i]
// }) })
// } }
// } }
} }
this.defaultExpandAll = false this.defaultExpandAll = false
this.treeVisible = true this.treeVisible = true
@@ -546,7 +547,8 @@
.treeWrap { .treeWrap {
height: calc(100vh - 240px); height: calc(100vh - 240px);
} }
.active{
.active {
color: #21c9cc; color: #21c9cc;
display: inline-block; display: inline-block;
} }