From 641de82a0458ab5ba66b5e735895caad26708fa8 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 12 四月 2021 11:24:56 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/mat/mat.js |  270 +++++++++++++++++++++--------------------------------
 1 files changed, 107 insertions(+), 163 deletions(-)

diff --git a/src/main/webapp/static/js/mat/mat.js b/src/main/webapp/static/js/mat/mat.js
index 2233719..8f563ab 100644
--- a/src/main/webapp/static/js/mat/mat.js
+++ b/src/main/webapp/static/js/mat/mat.js
@@ -1,11 +1,48 @@
 var pageCurr;
 var printMatCodeNos = [];
-layui.use(['table','laydate', 'form'], function(){
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"
+}).use(['table','laydate', 'form', 'treeTable', 'admin', 'xmSelect'], function(){
     var table = layui.table;
     var $ = layui.jquery;
     var layer = layui.layer;
     var layDate = layui.laydate;
     var form = layui.form;
+    var admin = layui.admin;
+    var treeTable = layui.treeTable;
+    var xmSelect = layui.xmSelect;
+
+    // 鍟嗗搧鍒嗙被鏁版嵁
+    var insTb = treeTable.render({
+        elem: '#tag',
+        url: baseUrl+'/tag/list/auth',
+        headers: {token: localStorage.getItem('token')},
+        tree: {
+            iconIndex: 2,           // 鎶樺彔鍥炬爣鏄剧ず鍦ㄧ鍑犲垪
+            isPidData: true,        // 鏄惁鏄痠d銆乸id褰㈠紡鏁版嵁
+            idName: 'id',           // id瀛楁鍚嶇О
+            pidName: 'parentId'     // pid瀛楁鍚嶇О
+        },
+        cols: [[
+            {type: 'checkbox'}
+            ,{type: 'numbers'}
+            ,{field: 'name', align: 'left',title: '鍚嶇О', minWidth: 150}
+            ,{field: 'type$', align: 'center',title: '绫诲瀷'}
+            ,{field: 'leading', align: 'center',title: '璐熻矗浜�'}
+            ,{field: 'img', align: 'center',title: '鍥剧墖', hide: true}
+            ,{field: 'sort', align: 'center',title: '鎺掑簭', hide: true}
+            ,{field: 'status$', align: 'center',title: '鐘舵��'}
+            ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'}
+            ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳', hide: true}
+            ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true}
+
+            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150}
+        ]],
+        done: function (data) {
+            $('.ew-tree-table-box').css('height', '100%');
+            insTb.expandAll();
+        }
+    });
 
     // 鏁版嵁娓叉煋
     tableIns = table.render({
@@ -18,6 +55,7 @@
         even: true,
         toolbar: '#toolbar',
         cellMinWidth: 50,
+        height: 'full-100',
         cols: [[
             {type: 'checkbox'}
 //            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
@@ -108,18 +146,7 @@
         var checkStatus = table.checkStatus(obj.config.id);
         switch(obj.event) {
             case 'addData':
-                layer.open({
-                    type: 2,
-                    title: '鏂板',
-                    maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    content: 'mat_detail.html',
-                    success: function(layero, index){
-                        layer.getChildFrame('#data-detail-submit-edit', index).hide();
-                    	clearFormVal(layer.getChildFrame('#detail', index));
-                        layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
-                    }
-                });
+                showEditModel()
                 break;
             case 'deleteData':
                 var data = checkStatus.data;
@@ -232,46 +259,77 @@
                     }
                 });
                 break;
-            // 璇︽儏
-            case 'detail':
-                layer.open({
-                    type: 2,
-                    title: '璇︽儏',
-                    maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    shadeClose: true,
-                    content: 'mat_detail.html',
-                    success: function(layero, index){
-                        setFormVal(layer.getChildFrame('#detail', index), data, true);
-                        top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
-                        layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide();
-                        layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
-                        layero.find('iframe')[0].contentWindow.layui.form.render('select');
-                        layero.find('iframe')[0].contentWindow.layui.form.render('checkbox');
-                    }
-                });
-                break;
             // 缂栬緫
             case 'edit':
-                layer.open({
-                    type: 2,
-                    title: '淇敼',
-                    maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    content: 'mat_detail.html',
-                    success: function(layero, index){
-                        layer.getChildFrame('#data-detail-submit-save', index).hide();
-                        setFormVal(layer.getChildFrame('#detail', index), data, false);
-                        top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
-                        top.convertDisabled(layer.getChildFrame('#id', index), true);
-                        layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
-                        layero.find('iframe')[0].contentWindow.layui.form.render('select');
-                        layero.find('iframe')[0].contentWindow.layui.form.render('checkbox');
-                    }
-                });
+                showEditModel(data)
                 break;
         }
     });
+
+    /* 鏄剧ず琛ㄥ崟寮圭獥 */
+    function showEditModel(mData) {
+        admin.open({
+            type: 1,
+            area: '600px',
+            title: (mData ? '淇敼' : '娣诲姞') + '鏉冮檺',
+            content: $('#editDialog').html(),
+            success: function (layero, dIndex) {
+                // 鍥炴樉琛ㄥ崟鏁版嵁
+                form.val('detail', mData);
+                // 琛ㄥ崟鎻愪氦浜嬩欢
+                form.on('submit(editSubmit)', function (data) {
+                    data.field.tagId = insXmSel.getValue('valueStr');
+                    if (isEmpty(data.field.tagId)) {
+                        layer.msg('鍒嗙被涓嶈兘涓虹┖', {icon: 2});
+                        return false;
+                    }
+                    var loadIndex = layer.load(2);
+                    $.ajax({
+                        url: baseUrl+"/mat/"+(mData?'update':'add')+"/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: data.field,
+                        method: 'POST',
+                        success: function (res) {
+                            layer.close(loadIndex);
+                            if (res.code === 200){
+                                layer.close(dIndex);
+                                layer.msg(res.msg, {icon: 1});
+                                $(".layui-laypage-btn")[0].click();
+                            } else if (res.code === 403){
+                                top.location.href = baseUrl+"/";
+                            }else {
+                                layer.msg(res.msg, {icon: 2});
+                            }
+                        }
+                    })
+                    return false;
+                });
+                // 娓叉煋涓嬫媺鏍�
+                var insXmSel = xmSelect.render({
+                    el: '#tagSel',
+                    height: '250px',
+                    data: insTb.options.data,
+                    initValue: mData ? [mData.tagId] : [],
+                    model: {label: {type: 'text'}},
+                    prop: {
+                        name: 'name',
+                        value: 'id'
+                    },
+                    radio: true,
+                    clickClose: true,
+                    tree: {
+                        show: true,
+                        indent: 15,
+                        strict: false,
+                        expandedKeys: true
+                    }
+                });
+                // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
+                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                layui.form.render('select');
+            }
+        });
+    }
 
     // 妯℃澘閫夋嫨
     form.on('radio(selectTemplateRadio)', function (data) {
@@ -303,7 +361,7 @@
                     var tpl = templateDom.html();
                     var template = Handlebars.compile(tpl);
                     var html = template(res);
-                    let box = $("#box");
+                    var box = $("#box");
                     box.html(html);box.show();
                     box.print({mediaPrint:true});
                     box.hide();
@@ -315,74 +373,6 @@
             }
         })
     })
-
-    // 鏁版嵁淇濆瓨鍔ㄤ綔
-    form.on('submit(save)', function () {
-        if (banMsg != null){
-            layer.msg(banMsg);
-            return;
-        }
-        method("add");
-    });
-
-    // 鏁版嵁淇敼鍔ㄤ綔
-    form.on('submit(edit)', function () {
-        method("update")
-    });
-
-    function method(name){
-        var index = layer.load(1, {
-            shade: [0.5,'#000'] //0.1閫忔槑搴︾殑鑳屾櫙
-        });
-        var data = {
-//            id: $('#id').val(),
-            id: $('#id').val(),
-            uuid: $('#uuid').val(),
-            nodeId: $('#nodeId').val(),
-            tagId: $('#tagId').val(),
-            matnr: $('#matnr').val(),
-            maktx: $('#maktx').val(),
-            name: $('#name').val(),
-            specs: $('#specs').val(),
-            model: $('#model').val(),
-            batch: $('#batch').val(),
-            unit: $('#unit').val(),
-            barcode: $('#barcode').val(),
-            docId: $('#docId').val(),
-            docNum: $('#docNum').val(),
-            custName: $('#custName').val(),
-            itemNum: $('#itemNum').val(),
-            count: $('#count').val(),
-            weight: $('#weight').val(),
-            status: $('#status').val(),
-            createBy: $('#createBy').val(),
-            createTime: top.strToDate($('#createTime\\$').val()),
-            updateBy: $('#updateBy').val(),
-            updateTime: top.strToDate($('#updateTime\\$').val()),
-            memo: $('#memo').val(),
-
-        };
-        $.ajax({
-            url: baseUrl+"/mat/"+name+"/auth",
-            headers: {'token': localStorage.getItem('token')},
-            data: top.reObject(data),
-            method: 'POST',
-            success: function (res) {
-                if (res.code === 200){
-                    parent.layer.closeAll();
-                    parent.$(".layui-laypage-btn")[0].click();
-                    $("#data-detail :input").each(function () {
-                        $(this).val("");
-                    });
-                } else if (res.code === 403){
-                    top.location.href = baseUrl+"/";
-                }else {
-                    layer.msg(res.msg)
-                }
-                layer.close(index);
-            }
-        })
-    }
 
     // 澶嶉�夋浜嬩欢
     form.on('checkbox(detailCheckbox)', function (data) {
@@ -420,11 +410,6 @@
 
 });
 
-// 鍏抽棴鍔ㄤ綔
-$(document).on('click','#data-detail-close', function () {
-    parent.layer.closeAll();
-});
-
 function tableReload(child) {
     var searchData = {};
     $.each($('#search-box [name]').serializeArray(), function() {
@@ -454,52 +439,11 @@
     });
 }
 
-function setFormVal(el, data, showImg) {
-    for (var val in data) {
-        var find = el.find(":input[id='" + val + "']");
-        if (find[0]!=null){
-            if (find[0].type === 'checkbox'){
-                if (data[val]==='Y'){
-                    find.attr("checked","checked");
-                    find.val('Y');
-                } else {
-                    find.remove("checked");
-                    find.val('N');
-                }
-                continue;
-            }
-        }
-        find.val(data[val]);
-        if (showImg){
-            var next = find.next();
-            if (next.get(0)){
-                if (next.get(0).localName === "img") {
-                    find.hide();
-                    next.attr("src", data[val]);
-                    next.show();
-                }
-            }
-        }
-    }
-}
-
 function clearFormVal(el) {
     $(':input', el)
         .val('')
         .removeAttr('checked')
         .removeAttr('selected');
-}
-
-function detailScreen(index) {
-    var detail = layer.getChildFrame('#data-detail', index);
-    var height = detail.height()+60;
-    if (height > ($(window).height()*0.9)) {
-        height = ($(window).height()*0.8);
-    }
-    layer.style(index, {
-//        top: (($(window).height()-height)/3)+"px",
-        height: height+'px'
-    });
 }
 
 $('body').keydown(function () {

--
Gitblit v1.9.1