Commit bea472ce authored by youjie's avatar youjie
parents ed12cc64 ae22c6d1
...@@ -108,12 +108,11 @@ ...@@ -108,12 +108,11 @@
<span class="resource-lititle sheshi">{{$t('hotel.hotel_type')}}</span> <span class="resource-lititle sheshi">{{$t('hotel.hotel_type')}}</span>
<div class="res-span"> <div class="res-span">
<el-tree <el-tree
:data="categoryTree" :data="categoryTree" default-expand-all
:props="{label: 'CategoryName', children: 'SubList'}" :props="{label: 'CategoryName', children: 'SubList'}"
show-checkbox show-checkbox
node-key="Id" node-key="Id"
ref="treeForm" ref="treeForm"
check-strictly
@check-change="handleNodeClick" @check-change="handleNodeClick"
> >
</el-tree> </el-tree>
...@@ -537,7 +536,8 @@ ...@@ -537,7 +536,8 @@
this.addMsg.HotelImageList = this.HotelImageArray; this.addMsg.HotelImageList = this.HotelImageArray;
this.addMsg.DeleteImageList = this.DeleteImageArray; this.addMsg.DeleteImageList = this.DeleteImageArray;
this.addMsg.WebSiteCategoryIds = this.checkedId.join(',') // this.addMsg.WebSiteCategoryIds = this.checkedId.join(',')
this.addMsg.WebSiteCategoryIds = this.getLastSubmitIds()
this.apipost( this.apipost(
"hotel_post_Set", "hotel_post_Set",
this.addMsg, this.addMsg,
...@@ -631,7 +631,6 @@ ...@@ -631,7 +631,6 @@
}, },
initCategoryTree() { initCategoryTree() {
var msg = {}; var msg = {};
this.getDinnerList();
var _self = this; var _self = this;
this.apipost( this.apipost(
"ws_post_GetCategoryTreeList", "ws_post_GetCategoryTreeList",
...@@ -641,7 +640,7 @@ ...@@ -641,7 +640,7 @@
let categoryTree = res.data.data.filter(item => item.CategoryName === '住宿') let categoryTree = res.data.data.filter(item => item.CategoryName === '住宿')
this.addParentId(categoryTree, []) this.addParentId(categoryTree, [])
this.categoryTree = categoryTree this.categoryTree = categoryTree
console.log('this.categoryTree', this.categoryTree) this.setSelectedKeys()
} else { } else {
_self.Error(res.data.message); _self.Error(res.data.message);
} }
...@@ -657,13 +656,45 @@ ...@@ -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) { 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() { initHotelData() {
var msg = { var msg = {
...@@ -676,8 +707,8 @@ handleNodeClick(data, checked, node) { ...@@ -676,8 +707,8 @@ handleNodeClick(data, checked, node) {
msg, msg,
res => { res => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
this.checkedId = res.data.data.WebSiteCategoryIds.split(',') || [] this.checkedId = res.data.data.WebSiteCategoryIds ? res.data.data.WebSiteCategoryIds.split(',').map(item => Number(item)) : []
this.$refs.treeForm.setCheckedKeys([res.data.data.WebSiteCategoryIds.split(',').pop()]); this.setSelectedKeys()
_self.addMsg = res.data.data; _self.addMsg = res.data.data;
if (_self.addMsg.Country > 0) { if (_self.addMsg.Country > 0) {
this.GetSubAreaList(_self.addMsg.Country, 1, 1); this.GetSubAreaList(_self.addMsg.Country, 1, 1);
......
...@@ -885,15 +885,14 @@ ...@@ -885,15 +885,14 @@
class="w300" class="w300"
></el-input> ></el-input>
</el-form-item> </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"> <div class="res-span margin-bottom">
<el-tree <el-tree
:data="categoryTree" :data="categoryTree" default-expand-all
:props="{label: 'CategoryName', children: 'SubList'}" :props="{label: 'CategoryName', children: 'SubList'}"
show-checkbox show-checkbox
node-key="Id" node-key="Id"
ref="treeForm" ref="treeForm"
check-strictly
@check-change="handleNodeClick" @check-change="handleNodeClick"
> >
</el-tree> </el-tree>
...@@ -1432,6 +1431,7 @@ export default { ...@@ -1432,6 +1431,7 @@ export default {
this.addParentId(categoryTree, []) this.addParentId(categoryTree, [])
this.categoryTree = categoryTree this.categoryTree = categoryTree
console.log('this.categoryTree', this.categoryTree) console.log('this.categoryTree', this.categoryTree)
this.setSelectedKeys()
} else { } else {
_self.Error(res.data.message); _self.Error(res.data.message);
} }
...@@ -1446,13 +1446,50 @@ export default { ...@@ -1446,13 +1446,50 @@ export default {
this.addParentId(item.SubList, item.ids) 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) { handleNodeClick(data, checked, node) {
if(checked === true) { // if(checked === true) {
console.log('data, checked, node', data, checked, node) // console.log('data, checked, node', data, checked, node)
this.checkedId = data.ids; // this.checkedId = data.ids;
this.$refs.treeForm.setCheckedKeys([data.Id]); // this.$refs.treeForm.setCheckedKeys([data.Id]);
} // }
}, },
inited(viewer) { inited(viewer) {
this.$viewer = viewer; this.$viewer = viewer;
...@@ -1535,7 +1572,8 @@ export default { ...@@ -1535,7 +1572,8 @@ export default {
this.addMsg.GeographicTag = this.Geographic.join(","); this.addMsg.GeographicTag = this.Geographic.join(",");
this.addMsg.TicketCouponsImageList = this.TicketCouponsImageArray; this.addMsg.TicketCouponsImageList = this.TicketCouponsImageArray;
this.addMsg.DeleteImageList = this.DeleteImageArray; this.addMsg.DeleteImageList = this.DeleteImageArray;
this.addMsg.WebSiteCategoryIds = this.checkedId.join(',') // this.addMsg.WebSiteCategoryIds = this.checkedId.join(',')
this.addMsg.WebSiteCategoryIds = this.getLastSubmitIds()
this.apipost( this.apipost(
"ticketcoupons_post_Set", "ticketcoupons_post_Set",
this.addMsg, this.addMsg,
...@@ -1598,8 +1636,9 @@ export default { ...@@ -1598,8 +1636,9 @@ export default {
"ticketcoupons_post_Get", "ticketcoupons_post_Get",
msg, msg,
(res) => { (res) => {
if (res.data.resultCode == 1) {this.checkedId = res.data.data.WebSiteCategoryIds.split(',') || [] if (res.data.resultCode == 1) {
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()
this.addMsg = res.data.data; this.addMsg = res.data.data;
if (this.addMsg.Country > 0) { if (this.addMsg.Country > 0) {
this.GetSubAreaList(this.addMsg.Country, 1); 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