Commit 159cd230 by 前端

处理编辑回显名称问题

1 parent bce7f7bb
...@@ -132,13 +132,16 @@ export default { ...@@ -132,13 +132,16 @@ export default {
type: String, type: String,
}, },
selectRobot: { selectRobot: {
type: Array || String, type: [Array, String],
}, },
type: { type: {
type: Boolean, type: Boolean,
}, },
errorType: {
type: Boolean,
},
robotNo: { robotNo: {
type: Number || String, type: [Number, String],
}, },
}, },
watch: { watch: {
...@@ -191,36 +194,34 @@ export default { ...@@ -191,36 +194,34 @@ export default {
// }, // },
}, },
mounted() { mounted() {
console.log(this.type, this.robotNo, this.selectRobot) console.log(this.type, this.errorType, this.robotNo, this.selectRobot)
if (this.type && this.robotNo) this.getlistDepartmentTree(this.robotNo) if (this.type && this.robotNo) this.getlistDepartmentTree(this.robotNo)
if (this.errorType && this.robotNo) this.getlistDepartmentTree(this.robotNo)
}, },
methods: { methods: {
async dealVal(val) {
await this.initData(val)
this.robotListTree = val
console.log(this.robotListTree)
},
getlistDepartmentTree(merchantId) { getlistDepartmentTree(merchantId) {
let params = { addChildrensFlag: true, queryMerchantId: merchantId } let params = { addChildrensFlag: true, queryMerchantId: merchantId }
taskApi.getlistDepartmentTree(params).then(async (res) => { taskApi.getlistDepartmentTree(params).then(async (res) => {
console.log(res)
if (res) { if (res) {
this.robotListTree = res.data.data this.robotListTree = res.data.data
await this.initData(this.robotListTree) await this.initData(this.robotListTree)
console.log(this.robotListTree, '=======22')
if (this.selectRobot && this.selectRobot.length) { if (this.selectRobot && this.selectRobot.length) {
if (this.errorType) {
this.$refs[this.memberRef].setCheckedKeys([this.selectRobot])
} else {
this.$refs[this.memberRef].setCheckedKeys(this.selectRobot) this.$refs[this.memberRef].setCheckedKeys(this.selectRobot)
}
let treeArrInfo = this.getTreeName( let treeArrInfo = this.getTreeName(
this.robotListTree, this.robotListTree,
this.selectRobot[0] this.errorType ? this.selectRobot : this.selectRobot[0]
) )
this.treeArr.push(treeArrInfo) this.treeArr.push(treeArrInfo)
console.log(this.treeArr)
} }
} }
}) })
}, },
getTreeName(treeList, id) { getTreeName(treeList, id) {
console.log(treeList, id)
for (let i = 0; i < treeList.length; i++) { for (let i = 0; i < treeList.length; i++) {
let treeItem = treeList[i] let treeItem = treeList[i]
if (treeItem.id == id) { if (treeItem.id == id) {
...@@ -236,7 +237,6 @@ export default { ...@@ -236,7 +237,6 @@ export default {
} }
}, },
initData(data) { initData(data) {
console.log(11)
data.forEach((item, index) => { data.forEach((item, index) => {
this.$set( this.$set(
item, item,
...@@ -284,56 +284,10 @@ export default { ...@@ -284,56 +284,10 @@ export default {
children.length && this.initData(children) children.length && this.initData(children)
}) })
}, },
getMerchantBrandList() {
let getCheckedNodes = this.$refs[this.memberRef].getCheckedNodes()
const getCheckedKeys = this.$refs[this.memberRef].getCheckedKeys()
const getHalfCheckedNodes =
this.$refs[this.memberRef].getHalfCheckedNodes()
let merchantBrandList = getHalfCheckedNodes.map((car) => {
let merchantBrandId = []
car.children.forEach((item) => {
if (getCheckedKeys.includes(item.id)) {
merchantBrandId.push(item.id)
}
})
return {
cars: car.id,
merchantBrandId,
}
})
let checkNodes = getCheckedNodes.filter((item) => item.children)
let noCheckNodes = getCheckedNodes
.filter((item) => item.children === null)
.map((i) => {
return {
cars: i.id,
}
})
let merchantBrandList2 = checkNodes.map((car) => {
let merchantBrandId = []
car.children.forEach((item) => {
if (getCheckedKeys.includes(item.id)) {
merchantBrandId.push(item.id)
}
})
return {
cars: car.id,
merchantBrandId,
}
})
return merchantBrandList.concat(merchantBrandList2).concat(noCheckNodes)
},
//勾选 //勾选
handleCheck(val) { handleCheck(val) {
// this.treeArr = this.getTreeArray()
console.log(val)
// this.currentCheckData = this.$refs[this.memberRef]
// .getCheckedNodes()
// .filter((item) => item.children && item.children.length == 0)
this.currentCheckData = val this.currentCheckData = val
this.$refs[this.memberRef].setCheckedKeys([val.id]) this.$refs[this.memberRef].setCheckedKeys([val.id])
console.log(this.currentCheckData.staffId)
// console.log(this.treeArr[0].staffId)
if (!this.treeArr.length) { if (!this.treeArr.length) {
this.treeArr = [this.currentCheckData] this.treeArr = [this.currentCheckData]
} }
...@@ -348,43 +302,36 @@ export default { ...@@ -348,43 +302,36 @@ export default {
this.treeArr.length > 0 && this.treeArr.length < this.ids.length this.treeArr.length > 0 && this.treeArr.length < this.ids.length
this.checkedAll = this.treeArr.length === this.ids.length this.checkedAll = this.treeArr.length === this.ids.length
}, },
getCheckList(checkArr = []) { // //获取选择项
checkArr.forEach((item) => (item = parseInt(item))) // getTreeArray() {
this.$refs[this.memberRef].setCheckedKeys(checkArr) // let tree_arr = []
this.$nextTick(() => { // this.robotListTree.forEach((k) => {
this.handleCheck() // let child = k.children
}) // if (child && child.length > 0) {
}, // child.forEach((j) => {
//获取选择项 // tree_arr.push(j.id)
getTreeArray() { // })
let tree_arr = [] // } else {
this.robotListTree.forEach((k) => { // tree_arr.push(k.id)
let child = k.children // }
if (child && child.length > 0) { // })
child.forEach((j) => { // return tree_arr
tree_arr.push(j.id) // },
}) // //全选
} else { // selectAll() {
tree_arr.push(k.id) // this.loading = true
} // this.treeArr = this.getTreeArray()
}) // if (this.getCheckedArr.length == this.treeArr.length) {
return tree_arr // this.checkedAll = false
}, // this.$refs[this.memberRef].setCheckedKeys([])
//全选 // } else {
selectAll() { // this.checkedAll = true
this.loading = true // this.$refs[this.memberRef].setCheckedKeys(this.treeArr)
this.treeArr = this.getTreeArray() // }
if (this.getCheckedArr.length == this.treeArr.length) { // setTimeout(() => {
this.checkedAll = false // this.loading = false
this.$refs[this.memberRef].setCheckedKeys([]) // }, 1000)
} else { // },
this.checkedAll = true
this.$refs[this.memberRef].setCheckedKeys(this.treeArr)
}
setTimeout(() => {
this.loading = false
}, 1000)
},
//重置 //重置
selectClear() { selectClear() {
this.treeArr = [] this.treeArr = []
...@@ -404,10 +351,10 @@ export default { ...@@ -404,10 +351,10 @@ export default {
return data.label.indexOf(value) !== -1 return data.label.indexOf(value) !== -1
}, },
// 显示隐藏 // 显示隐藏
switchBrand() { // switchBrand() {
this.brandTree = !this.brandTree // this.brandTree = !this.brandTree
this.$emit('clickBrand', this.brandTree) // this.$emit('clickBrand', this.brandTree)
}, // },
}, },
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!