Commit 159cd230 by 前端

处理编辑回显名称问题

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