From 21cd9cadb16cf44daeba85f5e419031ba3bcf74e Mon Sep 17 00:00:00 2001 From: kgdxpr Date: Mon, 15 Apr 2024 11:57:43 +0800 Subject: [PATCH] 'commit' --- WebRoot/view/tb/zbdc/zbxx.html | 101 +++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 29 deletions(-) diff --git a/WebRoot/view/tb/zbdc/zbxx.html b/WebRoot/view/tb/zbdc/zbxx.html index 55b543d0..cab71f21 100644 --- a/WebRoot/view/tb/zbdc/zbxx.html +++ b/WebRoot/view/tb/zbdc/zbxx.html @@ -29,22 +29,22 @@ - -
-
-
-
- -
- -
+ + +
+
+
+ +
+
-
- -
-
- +
+
+ +
-
- -
-
-
-
- -
- -
+
+ +
+ +
- +
+ @@ -84,6 +84,8 @@ var form = layui.form; var laytpl = layui.laytpl; + var xmSelectData = []; + $.ajax({ @@ -143,6 +145,7 @@ async: false, url: '/QingLong/zbdc/getKmFeiLeiTree?km_code=xxty', success: function (res) { + xmSelectData = res.data; fenleiSelect.update({ data: res.data }); @@ -150,6 +153,46 @@ } }); + function findNodeAndParents(levelName) { + function search(node, path) { + const newPath = [...path, node.level_name]; + if (node.level_name === levelName) { + return newPath; + } + if (node.children) { + for (const child of node.children) { + const result = search(child, newPath); + if (result) { + return result; + } + } + } + + return null; + } + for (const root of xmSelectData) { + const result = search(root, []); + if (result) { + return result; + } + } + return null; + } + + form.on('submit(user-query)', function () { + + var selectArr = fenleiSelect.getValue(); + console.log(selectArr[0].level_name); + + const levelName = "少儿(趣味)田径"; + const result = findNodeAndParents(levelName); + console.log(result.join(',')); + + + // 阻止表单的默认提交行为 + return false; + }); + table.render({