!5 update app/view/dorawhite/users/userAddContent.html.

Merge pull request !5 from 刘成举-liuchengju/N/A
This commit is contained in:
doramart 2021-04-12 21:06:27 +08:00 committed by Gitee
commit daec15593e

View File

@ -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(',');
}
}