mirror of
https://gitee.com/doramart/DoraCMS.git
synced 2024-11-29 18:58:47 +08:00
!5 update app/view/dorawhite/users/userAddContent.html.
Merge pull request !5 from 刘成举-liuchengju/N/A
This commit is contained in:
commit
daec15593e
@ -107,6 +107,7 @@
|
||||
result) {
|
||||
if (result.status == 200 && result.data) {
|
||||
var childCates = result.data.cates;
|
||||
childCates = ChildCateTreeToArray(ChildCateArrayToTree(childCates, typeId),[]);
|
||||
var childHtml = '<option value="0" selected>' + selectTips + '</option>';
|
||||
for (const cateItem of childCates) {
|
||||
if (cateItem._id != typeId) {
|
||||
@ -119,6 +120,46 @@
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function ChildCateArrayToTree(childCates, typeId) {
|
||||
var outCateTree = [];
|
||||
for (const cateItem of childCates) {
|
||||
if (cateItem._id == typeId) {
|
||||
continue;
|
||||
}else if (cateItem.parentId == typeId) {
|
||||
outCateTree.push(cateItem);
|
||||
}else {
|
||||
for (const pcate of childCates) {
|
||||
if (cateItem.parentId == pcate._id) {
|
||||
if (pcate.ChildCates == undefined){
|
||||
pcate.ChildCates = [];
|
||||
}
|
||||
pcate.ChildCates.push(cateItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return outCateTree;
|
||||
}
|
||||
|
||||
|
||||
function ChildCateTreeToArray(childCateTree, outCateArray, parentCateItem) {
|
||||
for (const cateItem of childCateTree) {
|
||||
if (parentCateItem){
|
||||
cateItem.name = parentCateItem.name + '-' + cateItem.name;
|
||||
cateItem._id = parentCateItem._id + ',' + cateItem._id;
|
||||
}
|
||||
outCateArray.push(cateItem);
|
||||
|
||||
if (cateItem.ChildCates){
|
||||
ChildCateTreeToArray(cateItem.ChildCates, outCateArray, cateItem);
|
||||
}
|
||||
delete cateItem.ChildCates;
|
||||
}
|
||||
return outCateArray;
|
||||
}
|
||||
|
||||
function selectTagOnChange(obj) {
|
||||
postArticelVM.tags = obj.value;
|
||||
}
|
||||
@ -126,7 +167,8 @@
|
||||
function childCateOnChange(obj) {
|
||||
currentCate.push(obj.value);
|
||||
if (currentCate.length == 2) {
|
||||
postArticelVM.categories = currentCate;
|
||||
var catesStr = currentCate.join(',');
|
||||
postArticelVM.categories = catesStr.split(',');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user