From 4c4a4031e33959292339e542e711ca94240b87ac Mon Sep 17 00:00:00 2001 From: mj&sz <307336854@qq.com> Date: Wed, 20 May 2020 17:20:28 +0800 Subject: [PATCH] =?UTF-8?q?update=20app/view/dorawhite/users/userAddConten?= =?UTF-8?q?t.html.=20=E8=BF=98=E6=98=AF=E4=B8=80=E6=A0=B7=EF=BC=8C?= =?UTF-8?q?=E4=B8=BA=E4=BA=86=E6=94=AF=E6=8C=813=E7=BA=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BB=20=E7=BC=96=E8=BE=91=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E8=99=BD=E7=84=B6=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9=E5=88=B0?= =?UTF-8?q?3=E7=BA=A7=E5=88=86=E7=B1=BB=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E5=9C=A8=E5=AE=A1=E6=A0=B8=E7=95=8C=E9=9D=A2=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E5=88=86=E7=B1=BB=E4=BF=A1=E6=81=AF=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/view/dorawhite/users/userAddContent.html | 44 +++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/app/view/dorawhite/users/userAddContent.html b/app/view/dorawhite/users/userAddContent.html index 8afe698..576ee7a 100755 --- a/app/view/dorawhite/users/userAddContent.html +++ b/app/view/dorawhite/users/userAddContent.html @@ -107,6 +107,7 @@ result) { if (result.status == 200 && result.data) { var childCates = result.data.cates; + childCates = ChildCateTreeToArray(ChildCateArrayToTree(childCates, typeId),[]); var childHtml = ''; 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(','); } }