Commit bea472ce authored by youjie's avatar youjie
parents ed12cc64 ae22c6d1
......@@ -108,12 +108,11 @@
<span class="resource-lititle sheshi">{{$t('hotel.hotel_type')}}</span>
<div class="res-span">
<el-tree
:data="categoryTree"
:data="categoryTree" default-expand-all
:props="{label: 'CategoryName', children: 'SubList'}"
show-checkbox
node-key="Id"
ref="treeForm"
check-strictly
@check-change="handleNodeClick"
>
</el-tree>
......@@ -537,7 +536,8 @@
this.addMsg.HotelImageList = this.HotelImageArray;
this.addMsg.DeleteImageList = this.DeleteImageArray;
this.addMsg.WebSiteCategoryIds = this.checkedId.join(',')
// this.addMsg.WebSiteCategoryIds = this.checkedId.join(',')
this.addMsg.WebSiteCategoryIds = this.getLastSubmitIds()
this.apipost(
"hotel_post_Set",
this.addMsg,
......@@ -631,7 +631,6 @@
},
initCategoryTree() {
var msg = {};
this.getDinnerList();
var _self = this;
this.apipost(
"ws_post_GetCategoryTreeList",
......@@ -641,7 +640,7 @@
let categoryTree = res.data.data.filter(item => item.CategoryName === '住宿')
this.addParentId(categoryTree, [])
this.categoryTree = categoryTree
console.log('this.categoryTree', this.categoryTree)
this.setSelectedKeys()
} else {
_self.Error(res.data.message);
}
......@@ -657,13 +656,45 @@
}
})
},
setSelectedKeys() {
this.arr = []
if(this.checkedId.length && this.categoryTree.length) {
this.findSelcetedKey(this.categoryTree)
if(this.$refs.treeForm) {
this.$refs.treeForm.setCheckedKeys(this.arr)
}
}
},
findSelcetedKey(tree,) {
tree.forEach(item => {
if(item.SubList && item.SubList.length) {
this.findSelcetedKey(item.SubList)
} else {
if(this.checkedId.includes(item.Id)) {
this.arr.push(item.Id)
}
}
})
},
getLastSubmitIds() {
this.idsList = []
this.selectedKeys = this.$refs.treeForm.getCheckedKeys()
this.getSelcetedKeyIds(this.categoryTree)
return [... new Set(this.idsList)].join(',')
},
getSelcetedKeyIds(tree) {
console.log('getSelcetedKeyIds', tree, this.idsList)
tree.forEach(item => {
if(item.SubList && item.SubList.length) {
this.getSelcetedKeyIds(item.SubList)
}
if(this.selectedKeys.includes(item.Id)) {
this.idsList = this.idsList.concat(item.ids)
}
})
},
handleNodeClick(data, checked, node) {
if(checked === true) {
console.log('data, checked, node', data, checked, node)
this.checkedId = data.ids;
this.$refs.treeForm.setCheckedKeys([data.Id]);
}
},
initHotelData() {
var msg = {
......@@ -676,8 +707,8 @@ handleNodeClick(data, checked, node) {
msg,
res => {
if (res.data.resultCode == 1) {
this.checkedId = res.data.data.WebSiteCategoryIds.split(',') || []
this.$refs.treeForm.setCheckedKeys([res.data.data.WebSiteCategoryIds.split(',').pop()]);
this.checkedId = res.data.data.WebSiteCategoryIds ? res.data.data.WebSiteCategoryIds.split(',').map(item => Number(item)) : []
this.setSelectedKeys()
_self.addMsg = res.data.data;
if (_self.addMsg.Country > 0) {
this.GetSubAreaList(_self.addMsg.Country, 1, 1);
......
......@@ -885,15 +885,14 @@
class="w300"
></el-input>
</el-form-item>
<span class="resource-lititle sheshi">{{$t('hotel.hotel_type')}}</span>
<span class="resource-lititle sheshi">景点门票类型</span>
<div class="res-span margin-bottom">
<el-tree
:data="categoryTree"
:data="categoryTree" default-expand-all
:props="{label: 'CategoryName', children: 'SubList'}"
show-checkbox
node-key="Id"
ref="treeForm"
check-strictly
@check-change="handleNodeClick"
>
</el-tree>
......@@ -1432,6 +1431,7 @@ export default {
this.addParentId(categoryTree, [])
this.categoryTree = categoryTree
console.log('this.categoryTree', this.categoryTree)
this.setSelectedKeys()
} else {
_self.Error(res.data.message);
}
......@@ -1446,13 +1446,50 @@ export default {
this.addParentId(item.SubList, item.ids)
}
})
},setSelectedKeys() {
this.arr = []
if(this.checkedId.length && this.categoryTree.length) {
this.findSelcetedKey(this.categoryTree)
if(this.$refs.treeForm) {
this.$refs.treeForm.setCheckedKeys(this.arr)
}
}
},
findSelcetedKey(tree,) {
tree.forEach(item => {
if(item.SubList && item.SubList.length) {
this.findSelcetedKey(item.SubList)
} else {
if(this.checkedId.includes(item.Id)) {
this.arr.push(item.Id)
}
}
})
},
getLastSubmitIds() {
this.idsList = []
this.selectedKeys = this.$refs.treeForm.getCheckedKeys()
this.getSelcetedKeyIds(this.categoryTree)
return [... new Set(this.idsList)].join(',')
},
getSelcetedKeyIds(tree) {
console.log('getSelcetedKeyIds', tree, this.idsList)
tree.forEach(item => {
if(item.SubList && item.SubList.length) {
this.getSelcetedKeyIds(item.SubList)
}
if(this.selectedKeys.includes(item.Id)) {
this.idsList = this.idsList.concat(item.ids)
}
})
},
handleNodeClick(data, checked, node) {
if(checked === true) {
console.log('data, checked, node', data, checked, node)
this.checkedId = data.ids;
this.$refs.treeForm.setCheckedKeys([data.Id]);
}
// if(checked === true) {
// console.log('data, checked, node', data, checked, node)
// this.checkedId = data.ids;
// this.$refs.treeForm.setCheckedKeys([data.Id]);
// }
},
inited(viewer) {
this.$viewer = viewer;
......@@ -1535,7 +1572,8 @@ export default {
this.addMsg.GeographicTag = this.Geographic.join(",");
this.addMsg.TicketCouponsImageList = this.TicketCouponsImageArray;
this.addMsg.DeleteImageList = this.DeleteImageArray;
this.addMsg.WebSiteCategoryIds = this.checkedId.join(',')
// this.addMsg.WebSiteCategoryIds = this.checkedId.join(',')
this.addMsg.WebSiteCategoryIds = this.getLastSubmitIds()
this.apipost(
"ticketcoupons_post_Set",
this.addMsg,
......@@ -1598,8 +1636,9 @@ export default {
"ticketcoupons_post_Get",
msg,
(res) => {
if (res.data.resultCode == 1) {this.checkedId = res.data.data.WebSiteCategoryIds.split(',') || []
this.$refs.treeForm.setCheckedKeys([res.data.data.WebSiteCategoryIds.split(',').pop()]);
if (res.data.resultCode == 1) {
this.checkedId = res.data.data.WebSiteCategoryIds ? res.data.data.WebSiteCategoryIds.split(',').map(item => Number(item)) : []
this.setSelectedKeys()
this.addMsg = res.data.data;
if (this.addMsg.Country > 0) {
this.GetSubAreaList(this.addMsg.Country, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment