From 86fb7988d3597c0e66a5e063f385a213849253bf Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 07 四月 2021 09:16:53 +0800 Subject: [PATCH] # --- src/main/webapp/views/pda/selectMat.html | 104 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 79 insertions(+), 25 deletions(-) diff --git a/src/main/webapp/views/pda/selectMat.html b/src/main/webapp/views/pda/selectMat.html index b88d19a..41ecdc6 100644 --- a/src/main/webapp/views/pda/selectMat.html +++ b/src/main/webapp/views/pda/selectMat.html @@ -72,53 +72,107 @@ <header> <div class="search-box"> - <input type="text"> + <input type="text" placeholder="璇疯緭鍏ュ晢鍝佺紪鐮�/鍚嶇О"> <button> <i class="layui-icon"></i> </button> </div> </header> -<main> - <div class="box-item"> - <div class="box-item-label">灏奸緳澶磋灪涓濈洅瑁�</div> - </div> - <div class="box-item"> - <div class="box-item-label">灏奸緳澶磋灪涓濈洅瑁�</div> - </div> - <div class="box-item"> - <div class="box-item-label">灏奸緳澶磋灪涓濈洅瑁�</div> - </div> - <div class="box-item"> - <div class="box-item-label">灏奸緳澶磋灪涓濈洅瑁�</div> - </div> - <div class="box-item"> - <div class="box-item-label">灏奸緳澶磋灪涓濈洅瑁�</div> - </div> - <div class="box-item"> - <div class="box-item-label">灏奸緳澶磋灪涓濈洅瑁�</div> - </div> - +<main id="main-contain"> </main> </body> <script> $(function () { - - + showTag(); }) $(document).on('click','.box-item', function () { + var tagId = $(this).children('input').get(0).value; + showTag(tagId); }) + + // 灞曠ず褰掔被 + function showTag(parentId){ + $.ajax({ + url: baseUrl + "/tag/list/pda/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + parentId: parentId + }, + method: 'POST', + success: function (res) { + if (res.code === 200) { + if (res.data != null && res.data.length > 0) { + console.log(res.data) + var tplDom = $("#tagTpl"); + var tpl = tplDom.html(); + var template = Handlebars.compile(tpl); + var html = template(res); + $('#main-contain').html(html); + } else { + var tagId = parentId; + showMat(tagId); + } + } else if (res.code === 403) { + top.location.href = baseUrl + "/pda"; + } else { + parent.layer.msg(res.msg, {icon: 2}); + } + } + }) + } + + // 灞曠ず鍟嗗搧 + function showMat(tagId) { + if (isEmpty(tagId)) { + return; + } + $.ajax({ + url: baseUrl + "/mat/list/pda/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + tagId: tagId + }, + method: 'POST', + success: function (res) { + if (res.code === 200) { + if (res.data != null && res.data.length > 0) { + console.log(res.data) + var tplDom = $("#matTpl"); + var tpl = tplDom.html(); + var template = Handlebars.compile(tpl); + var html = template(res); + $('#main-contain').html(html); + } else { + + } + } else if (res.code === 403) { + top.location.href = baseUrl + "/pda"; + } else { + parent.layer.msg(res.msg, {icon: 2}); + } + } + }) + } + + </script> <script type="text/template" id="tagTpl"> {{#each data}} - <option value="{{this}}">{{this}}</option> + <div class="box-item"> + <input name="tagId" type="hidden" value="{{this.id}}"> + <div class="box-item-label">{{this.name}}</div> + </div> {{/each}} </script> <script type="text/template" id="matTpl"> {{#each data}} - <option value="{{this}}">{{this}}</option> + <div class="box-item"> + <input name="matId" type="hidden" value="{{this.id}}"> + <div class="box-item-label">{{this.maktx}}</div> + </div> {{/each}} </script> </html> -- Gitblit v1.9.1