From 674aef62d298f9fbce41b9b1725c71d056dfd55b Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期三, 03 四月 2024 10:26:32 +0800
Subject: [PATCH] #周计划

---
 src/main/webapp/static/js/weekly/weekly.js |  640 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 569 insertions(+), 71 deletions(-)

diff --git a/src/main/webapp/static/js/weekly/weekly.js b/src/main/webapp/static/js/weekly/weekly.js
index 1dd5c67..47d267b 100644
--- a/src/main/webapp/static/js/weekly/weekly.js
+++ b/src/main/webapp/static/js/weekly/weekly.js
@@ -3,6 +3,22 @@
 var treeCond;
 var htmlCstme;
 var htmlCstmrData;
+var indexS = "9999,8888";
+var indexDelSign = 0;
+let nowUserId2 = 0;
+fWeekly();
+function fWeekly() {
+    layui.jquery.ajax({
+        url: baseUrl + "/dashboard/user/id/popup/auth",
+        data:{token : localStorage.getItem('token')},
+        method: 'GET',
+        success: function (res) {
+            if (res.code === 200) {
+                nowUserId2 = res.data;
+            }
+        }
+    })
+}
 layui.config({
     base: baseUrl + "/static/layui/lay/modules/"
 }).extend({
@@ -19,6 +35,8 @@
     admin = layui.admin;
 
     $('#organization').html(localStorage.getItem('nickname') + ' <i class="layui-icon">&#xe61a;</i>');
+    $(".laytable-cell-2-0-7").css('color', 'rgba(0, 0, 0, 0)');
+
 
     // 閮ㄩ棬浜哄憳 绛涢��
     dropdown.render({
@@ -74,35 +92,6 @@
         })
     }
 
-    // // 娓叉煋鎼滅储妯℃澘
-    // $.ajax({
-    //     url: baseUrl+"/cstmr/all/get/kv",
-    //     headers: {'token': localStorage.getItem('token')},
-    //     data: {
-    //         limit: 9999
-    //     },
-    //     method: 'POST',
-    //     // async: false, // 璁剧疆涓哄悓姝ユ墽琛�
-    //     success: function (res) {
-    //         htmlCstme = "<select id=\"select_cstmr\" name=\"select_cstmr\" lay-vertype=\"tips\" lay-verify=\"required\" required=\"\">"
-    //         htmlCstme = htmlCstme +
-    //             "                    <option style=\"display: none\"></option>\n"
-    //         if (res.code === 200){
-    //             for (var val in res.data) {
-    //                 var cstmrVal = res.data[val]
-    //                 console.log(cstmrVal)
-    //                 htmlCstme = htmlCstme +
-    //                     "        <option value = \""+cstmrVal.value+"\"+\n" +
-    //                     "        > "+cstmrVal.name+" </option>\n"
-    //             }
-    //         } else {
-    //             htmlCstme = htmlCstme +
-    //                 "<option value=\"0\">寮傚父</option>"
-    //         }
-    //         htmlCstme = htmlCstme +  "\n" + " </select>";
-    //     }
-    // })
-
     // 鏁版嵁娓叉煋
     tableIns = table.render({
         elem: '#weekly',
@@ -118,31 +107,36 @@
             {field: 'id', align: 'center',title: 'ID',hide : true}
             ,{field: 'startTime$', align: 'center',title: '寮�濮嬫棩鏈�',hide : true}
             ,{field: 'endTime$', align: 'center',title: '缁撴潫鏃ユ湡',hide : true}
+            ,{field: 'weeklyDayMonth', align: 'center',title: '鍛�',hide : false}
             ,{field: 'userId$', align: 'center',title: '鎵�灞炰汉鍛�',hide : true}
             ,{field: 'hostId$', align: 'center',title: '鎵�灞炲晢鎴�',hide : true}
             ,{field: 'deptId$', align: 'center',title: '鎵�灞為儴闂�',hide : true}
             ,{field: 'cstmrIdsReality', align: 'center',title: '瀹為檯鐢叉柟鍗曚綅ID闆嗗悎',hide : true}
             ,{field: 'status$', align: 'center',title: '鐘舵��',hide : false}
-            ,{field: 'settle$', align: 'center',title: '杩涘害',hide : false}
             ,{field: 'settleMsg', align: 'center',title: '瀹℃牳杩涘害',hide : true}
+            ,{field: 'weeklyDailyPlan', align: 'center',title: '鏃ヨ鍒�',hide : false, toolbar: '#tbLookPlan'}
+            ,{field: 'weeklyDailyReality', align: 'center',title: '鏃ヨ绋�',hide : false, toolbar: '#tbLookReality'}
             ,{field: 'comment', align: 'center',title: '璇勮',hide : false}
             ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳',hide : true}
             ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿',hide : true}
             ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳',hide : true}
             ,{field: 'updateTime$', align: 'center',title: 'update_time',hide : true}
             ,{field: 'memo', align: 'center',title: '澶囨敞锛�50瀛楋級',hide : false}
-            ,{field: 'director$', align: 'center',title: '瀹℃壒浜�',hide : true}
+            ,{field: 'director$', align: 'center',title: '瀹℃牳鑺傜偣',hide : true}
+            ,{field: 'director', align: 'center',title: '瀹℃牳鑺傜偣',hide : true}
+            ,{field: 'settle', align: 'center',title: '杩涘害',hide : true}
             ,{field: 'settleSize', align: 'center',title: '娴佺▼闀垮害',hide : true}
+            ,{field: 'settle$', align: 'center',title: '杩涘害', style: 'color: #1890ff;cursor:pointer', event: 'more',hide: false}
             ,{field: 'settleCurrent', align: 'center',title: '褰撳墠杩涘害',hide : true}
             ,{field: 'cstmrIdsPlan', align: 'center',title: '璁″垝鐢叉柟鍗曚綅ID闆嗗悎',hide : true}
-            ,{field: 'weeklyAll', align: 'center',title: '鍛ㄦ暟',hide : false}
+            ,{field: 'weeklyAll', align: 'center',title: '鍛ㄦ暟',hide : true}
             ,{field: 'weeklyNowMonth', align: 'center',title: '褰撴湀绗嚑鍛�',hide : true}
+            ,{field: 'nowUserId', align: 'center', title: 'nowUserId', hide: true, templet:function(){ return nowUserId2 }}
             ,{field: 'weeklyYear', align: 'center',title: '骞�',hide : true}
             ,{field: 'weeklyMonth', align: 'center',title: '鏈�',hide : true}
             ,{field: 'weeklyDay', align: 'center',title: '鏃�',hide : true}
-            ,{field: 'weeklyDayMonth', align: 'center',title: '鍛�',hide : true}
 
-            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
+            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:240}
         ]],
         request: {
             pageName: 'curr',
@@ -313,7 +307,6 @@
                         url: baseUrl+"/weekly/delete/auth",
                         headers: {'token': localStorage.getItem('token')},
                         data: {ids: data.id},
-                        method: 'POST',
                         traditional:true,
                         success: function (res) {
                             if (res.code === 200){
@@ -331,16 +324,19 @@
             case "edit":
                 showEditModel(data);
                 break;
-            case "look":
-                var $a = $(obj.tr).find('a[lay-event="look"]');
+            case "editReality":
+                showEditModel2(data);
+                break;
+            case "lookPlan":
+                var $a = $(obj.tr).find('a[lay-event="lookPlan"]');
                 var offset = $a.offset();
                 var top2 = offset.top;
                 var left = offset.left;
                 layer.open({
                     type: 1,
                     title: false,
-                    area: '2100px',
-                    offset: [top2 + 'px', (left - 1430 + $a.outerWidth()) + 'px'],
+                    area: '1100px',
+                    offset: [top2 + 'px', (left - 430 + $a.outerWidth()) + 'px'],
                     shade: .01,
                     shadeClose: true,
                     fixed: false,
@@ -349,37 +345,27 @@
                         table.render({
                             elem: '#lookSSXMTable',
                             headers: {token: localStorage.getItem('token')},
-                            url: baseUrl+'/weeklyDetl/list/auth',
+                            url: baseUrl+'/weeklyDailyPlan/list/auth',
                             where: {
-                                order_id: data.id
+                                weekly_id: data.id
                             },
                             page: true,
                             cellMinWidth: 100,
                             cols: [[
-                                {type: 'checkbox'}
-                                ,{field: 'id', align: 'center',title: 'ID'}
-                                ,{field: 'dailyTime$', align: 'center',title: '鏃ユ姤鏃ユ湡'}
-                                ,{field: 'userId$', align: 'center',title: '鎵�灞炰汉鍛�'}
-                                ,{field: 'hostId$', align: 'center',title: '鎵�灞炲晢鎴�'}
-                                ,{field: 'deptId$', align: 'center',title: '鎵�灞為儴闂�'}
-                                ,{field: 'status$', align: 'center',title: '鐘舵��'}
-                                ,{field: 'settle$', align: 'center',title: '杩涘害'}
-                                ,{field: 'settleMsg', align: 'center',title: '瀹℃牳杩涘害'}
-                                ,{field: 'comment', align: 'center',title: '璇勮'}
-                                ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳'}
-                                ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
-                                ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳'}
-                                ,{field: 'updateTime$', align: 'center',title: 'update_time'}
-                                ,{field: 'weeklyMatter', align: 'center',title: '闇�鍗忓姪浜嬮」'}
-                                ,{field: 'director$', align: 'center',title: '璐熻矗浜�'}
-                                ,{field: 'settleSize', align: 'center',title: '娴佺▼闀垮害'}
-                                ,{field: 'settleCurrent', align: 'center',title: '褰撳墠杩涘害'}
-                                ,{field: 'weeklyId', align: 'center',title: '鍛ㄦ姤ID'}
-                                ,{field: 'cstmrId', align: 'center',title: '鐢叉柟鍗曚綅ID'}
-                                ,{field: 'weeklyDay', align: 'center',title: '鏄熸湡'}
-                                ,{field: 'memo', align: 'center',title: '澶囨敞'}
-
-                                ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
+                                {type: 'numbers'}
+                                ,{field: 'weeklyDay$', align: 'center',title: '鏄熸湡'}
+                                ,{field: 'dailyTime$',width : 120, align: 'center',title: '鏃ユ湡'}
+                                ,{field: 'workContent', align: 'center', title: '宸ヤ綔鍐呭', edit:false}
+                                ,{field: 'workPurpose', title: '宸ヤ綔鐩殑', edit:false}
+                                ,{field: 'comment', title: '璇勮', edit:false}
+                                ,{field: 'weeklyMatter', title: '闇�鍗忓姪浜嬮」',  edit:false}
+                                // ,{field: 'dailyTime$', align: 'center',title: '鏃ユ姤鏃ユ湡'}
+                                // ,{field: 'settleMsg', align: 'center',title: '瀹℃牳杩涘害'}
+                                // ,{field: 'director', align: 'center',title: '璐熻矗浜�'}
+                                // ,{field: 'settleSize', align: 'center',title: '娴佺▼闀垮害'}
+                                // ,{field: 'settleCurrent', align: 'center',title: '褰撳墠杩涘害'}
+                                ,{field: 'cstmrId$', align: 'center',title: '鐢叉柟鍗曚綅ID'}//, templet: function () { return htmlCstme;}
+                                ,{field: 'memo', align: 'center',title: '澶囨敞',   edit:false}
                             ]],
                             request: {
                                 pageName: 'curr',
@@ -404,8 +390,147 @@
                     }
                 });
                 break;
+            case "lookReality":
+                var $a = $(obj.tr).find('a[lay-event="lookReality"]');
+                var offset = $a.offset();
+                var top2 = offset.top;
+                var left = offset.left;
+                layer.open({
+                    type: 1,
+                    title: false,
+                    area: '1100px',
+                    offset: [top2 + 'px', (left - 830 + $a.outerWidth()) + 'px'],
+                    shade: .01,
+                    shadeClose: true,
+                    fixed: false,
+                    content: '<table id="lookSSXMTable" lay-filter="lookSSXMTable"></table>',
+                    success: function (layero) {
+                        table.render({
+                            elem: '#lookSSXMTable',
+                            headers: {token: localStorage.getItem('token')},
+                            url: baseUrl+'/weeklyDailyReality/list/auth',
+                            where: {
+                                weekly_id: data.id
+                            },
+                            page: true,
+                            cellMinWidth: 100,
+                            cols: [[
+                                {type: 'numbers'}
+                                ,{field: 'weeklyDay$', align: 'center',title: '鏄熸湡'}
+                                ,{field: 'dailyTime$',width : 120, align: 'center',title: '鏃ユ湡'}
+                                ,{field: 'workContent', align: 'center', title: '宸ヤ綔鍐呭', edit:false}
+                                ,{field: 'workPurpose', title: '宸ヤ綔鐩殑', edit:false}
+                                ,{field: 'comment', title: '璇勮', edit:false}
+                                ,{field: 'weeklyMatter', title: '闇�鍗忓姪浜嬮」',  edit:false}
+                                // ,{field: 'dailyTime$', align: 'center',title: '鏃ユ姤鏃ユ湡'}
+                                // ,{field: 'settleMsg', align: 'center',title: '瀹℃牳杩涘害'}
+                                // ,{field: 'director', align: 'center',title: '璐熻矗浜�'}
+                                // ,{field: 'settleSize', align: 'center',title: '娴佺▼闀垮害'}
+                                // ,{field: 'settleCurrent', align: 'center',title: '褰撳墠杩涘害'}
+                                ,{field: 'cstmrId$', align: 'center',title: '鐢叉柟鍗曚綅ID'}//, templet: function () { return htmlCstme;}
+                                ,{field: 'memo', align: 'center',title: '澶囨敞',   edit:false}
+                            ]],
+                            request: {
+                                pageName: 'curr',
+                                pageSize: 'limit'
+                            },
+                            parseData: function (res) {
+                                return {
+                                    'code': res.code,
+                                    'msg': res.msg,
+                                    'count': res.data.total,
+                                    'data': res.data.records
+                                }
+                            },
+                            response: {
+                                statusCode: 200
+                            },
+                            done: function () {
+                                $(layero).find('.layui-table-view').css('margin', '0');
+                            },
+                            size: ''
+                        });
+                    }
+                });
+                break;
+            case 'approval':
+                layer.confirm('瀹℃壒閫氳繃锛�', {
+                    skin: 'layui-layer-admin',
+                    shade: .1,
+                    offset: '200px',
+                    title: data.name
+                }, function (i) {
+                    layer.close(i);
+                    approval(data.id);
+                });
+                break;
+            case 'approvalEnd':
+                layer.confirm('瀹℃壒鎷掔粷锛�', {
+                    skin: 'layui-layer-admin',
+                    shade: .1,
+                    offset: '200px',
+                    title: data.name
+                }, function (i) {
+                    layer.close(i);
+                    approvalEnd(data.id);
+                });
+                break;
         }
     });
+
+    function approvalEnd(weeklyId, plannerId, dIdx) {
+        let loadIndex = layer.load(2);
+        $.ajax({
+            url: baseUrl+"/weekly/approvalEnd/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: {
+                weeklyId: weeklyId,
+                plannerId: plannerId
+            },
+            method: 'POST',
+            success: function (res) {
+                if (dIdx) {
+                    layer.close(dIdx);
+                }
+                layer.close(loadIndex);
+                if (res.code === 200){
+                    layer.msg(res.msg, {icon: 1});
+                    tableReload();
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                } else {
+                    layer.msg(res.msg, {icon: 2});
+                }
+            }
+        })
+    }
+
+    function approval(weeklyId, plannerId, dIdx) {
+        let loadIndex = layer.load(2);
+        $.ajax({
+            url: baseUrl+"/weekly/approval/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: {
+                weeklyId: weeklyId,
+                plannerId: plannerId
+            },
+            method: 'POST',
+            success: function (res) {
+                if (dIdx) {
+                    layer.close(dIdx);
+                }
+                layer.close(loadIndex);
+                if (res.code === 200){
+                    layer.msg(res.msg, {icon: 1});
+                    tableReload();
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                } else {
+                    layer.msg(res.msg, {icon: 2});
+                }
+            }
+        })
+    }
 
     // 鎼滅储
     form.on('submit(search)', function (data) {
@@ -418,7 +543,7 @@
     function showEditModel(expTpe) {
         admin.open({
             type: 1,
-            title: (expTpe ? '淇敼' : '娣诲姞') + '鎶ラ攢瀹℃壒',
+            title: (expTpe ? '淇敼' : '鍒涘缓') + '鍛ㄨ鍒�',
             content: $('#editDialog').html(),
             area: '2200px',
             success: function (layero, dIndex) {
@@ -453,7 +578,7 @@
                         headers: {'token': localStorage.getItem('token')},
                         data: JSON.stringify({
                             weeklyType: Number(data.field.weeklyType),
-                            orderId: data.field.orderId,
+                            weeklyId: data.field.id,
                             // type: Number(data.field.type),
                             type: Number(1),
                             weeklyDailyPlanList: nList
@@ -473,7 +598,12 @@
                             }
                         }
                     })
+                    location.reload();
+
                     return false;
+                });
+                $('#cancelBtn').on('click', function () {
+                    location.reload();
                 });
                 // 鏄庣粏琛ㄦ牸
                 var xxDataList = [];
@@ -489,6 +619,7 @@
                         ,{field: 'weeklyDay$', align: 'center',title: '鏄熸湡'}
                         ,{field: 'workContent', title: '宸ヤ綔鍐呭', style: 'color: blue;font-weight: bold', edit:true}
                         ,{field: 'workPurpose', title: '宸ヤ綔鐩殑', style: 'color: blue;font-weight: bold', edit:true}
+                        ,{field: 'addr', title: '鍦板潃', style: 'color: blue;font-weight: bold', edit:true}
                         ,{field: 'comment', title: '璇勮', style: 'color: blue;font-weight: bold', edit:true}
                         ,{field: 'weeklyMatter', title: '闇�鍗忓姪浜嬮」', style: 'color: blue;font-weight: bold', edit:true}
                         // ,{field: 'dailyTime$', align: 'center',title: '鏃ユ姤鏃ユ湡'}
@@ -510,17 +641,52 @@
                     },
                     done: function (res, curr, count) {
                         $(".layui-table-cell").css('overflow', 'visible');//瑙e喅layui鏁版嵁琛ㄦ牸涓祵濂椾笅鎷夋鏄剧ず闂
+                        $(".laytable-cell-2-0-7").css('color', 'rgba(0, 0, 0, 0)');
+
                         $(layero).find('.layui-table-view').css('margin', '0');
                         var options = this;
-
+                        var indexSign = 0;
                         // 鑾峰彇褰撳墠琛屾暟鎹�
                         table.getRowData = function(elem){
                             var index = $(elem).closest('tr').data('index');
+                            var indexArray = indexS.split(","); // 灏嗗瓧绗︿覆鎷嗗垎涓烘暟缁�
+                            // 閬嶅巻鏁扮粍涓殑姣忎釜鍏冪礌
+                            for (var i = 0; i < indexArray.length; i++) {
+                                var element = Number(indexArray[i]);
+                                // 杩涜鐩稿簲鐨勬搷浣�
+                                if (element===index){
+                                    indexSign = 1;
+                                }
+                            }
+                            if (indexSign === 0){
+                                indexS = indexS+","+index;
+                            }
                             return table.cache[options.id][index] || {};
                         };
 
+                        if (indexSign === 0 && indexDelSign === 0){
+                            // 娓叉煋鎼滅储妯℃澘
+                            $.ajax({
+                                url: baseUrl+"/cstmr/all/get/kv",
+                                headers: {'token': localStorage.getItem('token')},
+                                data: {
+                                    limit: 9999
+                                },
+                                method: 'POST',
+                                // async: false, // 璁剧疆涓哄悓姝ユ墽琛�
+                                success: function (res) {
+                                    // console.log(res)
+                                    // console.log($("#cstmrId").html())
+                                    res.data.forEach((item) => {
+                                        // console.log(item)
+                                        $("#cstmrId").append("<option value='" + item.value  + "';"+" class=\"cstmrDetl\""+">" + item.name + "</option>")
+                                    })
+                                }
+                            })
+                        }
+
                         $('.select-cstmr').on('change', function(){
-                            console.log("cstmrId")
+                            // console.log("cstmrId")
                             var value = this.value; // 鑾峰彇閫変腑椤� value
                             var data = table.getRowData(this);
                             xxDataList.forEach(res => {
@@ -542,8 +708,8 @@
                                 method: 'POST',
                                 success: function (res) {
                                     if (res.code === 200) {
-                                        console.log("res111111111111")
-                                        console.log(res)
+                                        // console.log("res111111111111")
+                                        // console.log(res)
                                         var template = $('#cstmrId').html(); // 鑾峰彇妯℃澘鍐呭
                                         var compiledTemplate = Handlebars.compile(template); // 缂栬瘧妯℃澘
                                         var html = compiledTemplate(res.data); // 灏嗘暟鎹簲鐢ㄥ埌妯℃澘涓�
@@ -631,6 +797,9 @@
                         title: (exp ? '淇敼' : '娣诲姞') + '鏄庣粏',
                         content: $('#matEditDialog').html(),
                         success: function (layero, dIndex) {
+                            if (!exp){
+                                indexDelSign = 1;
+                            }
                             // 鍥炴樉鏁版嵁
                             form.val('matEditForm', exp);
                             // 琛ㄥ崟鎻愪氦浜嬩欢
@@ -642,6 +811,333 @@
                                     // 鏌ヨ鐗╂枡璇︽儏
                                     $.ajax({
                                         url: baseUrl+"/weeklyCostTypes/covert/plan/"+item.value+"/auth",
+                                        headers: {'token': localStorage.getItem('token')},
+                                        method: 'GET',
+                                        async: false,
+                                        success: function (res) {
+                                            if (res.code === 200){
+                                                var bige=true;
+
+                                                if (bige){
+                                                    // console.log("-------2.3-------")
+                                                    xxDataList.push(res.data);
+                                                    insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
+                                                }
+                                            } else if (res.code === 403){
+                                                top.location.href = baseUrl+"/";
+                                            }else {
+                                                layer.msg(res.msg, {icon: 2})
+                                            }
+                                        }
+                                    })
+                                }
+                                layer.close(dIndex);
+                                return false;
+                            });
+                            // 娓叉煋鐗╂枡閫夋嫨
+                            var matXmSelect = xmSelect.render({
+                                el: '#weeklyCostTypes',
+                                style: {
+                                    width: '340px',
+                                },
+                                autoRow: true,
+                                toolbar: { show: true },
+                                filterable: true,
+                                remoteSearch: true,
+                                remoteMethod: function(val, cb, show){
+                                    $.ajax({
+                                        url: baseUrl+"/weeklyCostTypes/all/get/kv",
+                                        headers: {'token': localStorage.getItem('token')},
+                                        data: {
+                                            condition: val
+                                        },
+                                        method: 'POST',
+                                        success: function (res) {
+                                            if (res.code === 200){
+                                                cb(res.data)
+                                            } else {
+                                                cb([]);
+                                                layer.msg(res.msg, {icon: 2});
+                                            }
+                                        }
+                                    });
+                                }
+                            })
+                            // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
+                            $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                            layui.form.render('select');
+                        }
+                    });
+                }
+            }
+        });
+    }
+
+    // 鏄剧ず琛ㄥ崟寮圭獥
+    function showEditModel2(expTpe) {
+        admin.open({
+            type: 1,
+            title: (expTpe ? '鍒涘缓' : '鍒涘缓') + '鏃ヨ绋�',
+            content: $('#editDialog').html(),
+            area: '2200px',
+            success: function (layero, dIndex) {
+                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                var isExpAdd = !expTpe;
+                if (expTpe){
+                    document.getElementById('weeklyDisplay').style.display = 'none';
+                }
+                // 鍥炴樉鏁版嵁
+                form.val('editForm', expTpe);
+                console.log(expTpe)
+                if (expTpe) {
+                    // $('#orderNo').attr("disabled", "disabled");
+                }
+                // 琛ㄥ崟鎻愪氦浜嬩欢
+                form.on('submit(weeklyEditSubmit)', function (data) {
+                    // 缁勮鏁版嵁
+                    if (xxDataList.length <= 0) {
+                        layer.tips('璇锋坊鍔犳姤閿�鏄庣粏', '#matAddBtnComment', {tips: [1, '#ff4c4c']});
+                        return false;
+                    }
+                    let nList = admin.util.deepClone(xxDataList);
+                    for (let xi = 0; xi < nList.length; xi++) {
+                        // if (nList[xi].anfme <= 0){
+                        //     layer.msg('鏄庣粏淇敼鏁伴噺涓嶅悎娉�', {icon: 2});
+                        //     return false;
+                        // }
+                    }
+                    layer.load(2);
+                    $.ajax({
+                        url: baseUrl+"/weekly/from/" + (isExpAdd?"add":"modify") + "/auth2",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: JSON.stringify({
+                            weeklyType: Number(data.field.weeklyType),
+                            weeklyId: data.field.id,
+                            // type: Number(data.field.type),
+                            type: Number(1),
+                            weeklyDailyRealityList: nList
+                        }),
+                        contentType:'application/json;charset=UTF-8',
+                        method: 'POST',
+                        success: function (res) {
+                            layer.closeAll('loading');
+                            if (res.code === 200){
+                                layer.close(dIndex);
+                                $(".layui-laypage-btn")[0].click();
+                                layer.msg(res.msg, {icon: 1});
+                            } else if (res.code === 403){
+                                top.location.href = baseUrl+"/";
+                            }else {
+                                layer.msg(res.msg, {icon: 2});
+                            }
+                        }
+                    })
+                    location.reload();
+                    return false;
+                });
+                // 鏄庣粏琛ㄦ牸
+                var xxDataList = [];
+                var tbOptions = {
+                    elem: '#formSSXMTable',
+                    headers: {token: localStorage.getItem('token')},
+                    data: xxDataList,
+                    page: true,
+                    height: '350px;',
+                    cellMinWidth: 100,
+                    cols: [[
+                        {type: 'numbers', title: '#'}
+                        ,{field: 'weeklyDay$', align: 'center',title: '鏄熸湡'}
+                        ,{field: 'workContent', title: '宸ヤ綔鍐呭', style: 'color: blue;font-weight: bold', edit:true}
+                        ,{field: 'workPurpose', title: '宸ヤ綔鐩殑', style: 'color: blue;font-weight: bold', edit:true}
+                        ,{field: 'addr', title: '鍦板潃', style: 'color: blue;font-weight: bold', edit:true}
+                        ,{field: 'comment', title: '璇勮', style: 'color: blue;font-weight: bold', edit:true}
+                        ,{field: 'weeklyMatter', title: '闇�鍗忓姪浜嬮」', style: 'color: blue;font-weight: bold', edit:true}
+                        // ,{field: 'dailyTime$', align: 'center',title: '鏃ユ姤鏃ユ湡'}
+                        // ,{field: 'settleMsg', align: 'center',title: '瀹℃牳杩涘害'}
+                        // ,{field: 'director', align: 'center',title: '璐熻矗浜�'}
+                        // ,{field: 'settleSize', align: 'center',title: '娴佺▼闀垮害'}
+                        // ,{field: 'settleCurrent', align: 'center',title: '褰撳墠杩涘害'}
+                        ,{field: 'cstmrId', align: 'center',title: '鐢叉柟鍗曚綅ID', style: 'color: blue;font-weight: bold', templet: '#cstmrId'}//, templet: function () { return htmlCstme;}
+                        ,{field: 'memo', align: 'center',title: '澶囨敞', width: 100, style: 'color: blue;font-weight: bold', edit:true}
+                        ,{align: 'center', title: '鎿嶄綔', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right'}
+                    ]],
+                    parseData: function (res) {
+                        return {
+                            'code': res.code,
+                            'msg': res.msg,
+                            'count': res.data.total,
+                            'data': res.data.records
+                        }
+                    },
+                    done: function (res, curr, count) {
+                        $(".layui-table-cell").css('overflow', 'visible');//瑙e喅layui鏁版嵁琛ㄦ牸涓祵濂椾笅鎷夋鏄剧ず闂
+                        $(".laytable-cell-2-0-6").css('color', 'rgba(0, 0, 0, 0)');
+
+                        $(layero).find('.layui-table-view').css('margin', '0');
+                        var options = this;
+                        var indexSign = 0;
+                        // 鑾峰彇褰撳墠琛屾暟鎹�
+                        table.getRowData = function(elem){
+                            var index = $(elem).closest('tr').data('index');
+                            var indexArray = indexS.split(","); // 灏嗗瓧绗︿覆鎷嗗垎涓烘暟缁�
+                            // 閬嶅巻鏁扮粍涓殑姣忎釜鍏冪礌
+                            for (var i = 0; i < indexArray.length; i++) {
+                                var element = Number(indexArray[i]);
+                                // 杩涜鐩稿簲鐨勬搷浣�
+                                if (element===index){
+                                    indexSign = 1;
+                                }
+                            }
+                            if (indexSign === 0){
+                                indexS = indexS+","+index;
+                            }
+                            return table.cache[options.id][index] || {};
+                        };
+
+                        if (indexSign === 0 && indexDelSign === 0){
+                            // 娓叉煋鎼滅储妯℃澘
+                            $.ajax({
+                                url: baseUrl+"/cstmr/all/get/kv",
+                                headers: {'token': localStorage.getItem('token')},
+                                data: {
+                                    limit: 9999
+                                },
+                                method: 'POST',
+                                // async: false, // 璁剧疆涓哄悓姝ユ墽琛�
+                                success: function (res) {
+                                    // console.log(res)
+                                    // console.log($("#cstmrId").html())
+                                    res.data.forEach((item) => {
+                                        // console.log(item)
+                                        $("#cstmrId").append("<option value='" + item.value  + "';"+" class=\"cstmrDetl\""+">" + item.name + "</option>")
+                                    })
+                                }
+                            })
+                        }
+
+                        $('.select-cstmr').on('change', function(){
+                            // console.log("cstmrId")
+                            var value = this.value; // 鑾峰彇閫変腑椤� value
+                            var data = table.getRowData(this);
+                            xxDataList.forEach(res => {
+                                if (data.LAY_TABLE_INDEX === res.LAY_TABLE_INDEX){
+                                    console.log(res)
+                                    // console.log(data)
+                                    res.cstmrId = value;
+                                }
+                            })
+                        });
+
+                        $(document).ready(function () {
+                            $.ajax({
+                                url: baseUrl + "/cstmr/all/get/kv",
+                                headers: { 'token': localStorage.getItem('token') },
+                                data: {
+                                    limit: 9999
+                                },
+                                method: 'POST',
+                                success: function (res) {
+                                    if (res.code === 200) {
+                                        // console.log("res111111111111")
+                                        // console.log(res)
+                                        var template = $('#cstmrId').html(); // 鑾峰彇妯℃澘鍐呭
+                                        var compiledTemplate = Handlebars.compile(template); // 缂栬瘧妯℃澘
+                                        var html = compiledTemplate(res.data); // 灏嗘暟鎹簲鐢ㄥ埌妯℃澘涓�
+                                        $('.select-cstmr').html(html); // 娓叉煋妯℃澘鍒伴〉闈�
+                                    } else {
+                                        // 澶勭悊寮傚父鎯呭喌
+                                    }
+                                }
+                            });
+                        });
+                    },
+                    size: ''
+                };
+                if (!isExpAdd) {
+                    $.ajax({
+                        url: baseUrl+"/weekly/detl/all/auth2?weeklyId=" + expTpe.id,
+                        headers: {'token': localStorage.getItem('token')},
+                        method: 'GET',
+                        async: false,
+                        success: function (res) {
+                            if (res.code === 200){
+                                xxDataList = res.data;
+                                tbOptions.data = xxDataList;
+                            } else if (res.code === 403){
+                                top.location.href = baseUrl+"/";
+                            }else {
+                                layer.msg(res.msg, {icon: 2})
+                            }
+                        }
+                    })
+                }
+                var insTbSSXM = table.render(tbOptions);
+                // 宸ュ叿鏉$偣鍑讳簨浠�
+                table.on('tool(formSSXMTable)', function (obj) {
+                    var data = obj.data;
+                    var layEvent = obj.event;
+                    if (layEvent === 'edit') {
+                        showEditModel2(data);
+                    } else if (layEvent === 'del') {
+                        layer.confirm('纭畾瑕佸垹闄ゅ悧锛�', {
+                            shade: .1,
+                            skin: 'layui-layer-admin'
+                        }, function (i) {
+                            layer.close(i);
+                            for (var j = 0; j < xxDataList.length; j++) {
+                                if (xxDataList[j].matnr === data.matnr && xxDataList[j].batch === data.batch) {
+                                    xxDataList.splice(j, 1);
+                                    break;
+                                }
+                            }
+                            insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
+                        });
+                    }
+                });
+                // 鏄庣粏鏁版嵁淇敼
+                table.on('edit(formSSXMTable)', function (obj) {
+                    let index = obj.tr.attr("data-index");
+                    let data = xxDataList[index];
+                    if (obj.field === 'anfme'){
+                        let vle = Number(obj.value);
+                        if (isNaN(vle)) {
+                            layer.msg("璇疯緭鍏ユ暟瀛�", {icon: 2});
+                            return false;
+                        } else {
+                            if (vle <= 0) {
+                                layer.msg("鏁伴噺蹇呴』澶т簬闆�", {icon: 2});
+                                return false;
+                            }
+                        }
+                    }
+                    data[obj.field] = obj.value;
+                    insTbSSXM.reload({data: xxDataList});
+                });
+
+                $('#matAddBtnComment').click(function () {
+                    showEditModel2();
+                });
+
+                // 鏄剧ず娣诲姞鏄庣粏琛ㄥ崟寮圭獥
+                function showEditModel2(exp) {
+                    admin.open({
+                        type: 1,
+                        offset: '150px',
+                        area: '680px',
+                        title: (exp ? '淇敼' : '娣诲姞') + '鏄庣粏',
+                        content: $('#matEditDialog').html(),
+                        success: function (layero, dIndex) {
+                            // 鍥炴樉鏁版嵁
+                            form.val('matEditForm', exp);
+                            // 琛ㄥ崟鎻愪氦浜嬩欢
+                            form.on('submit(matEditSubmit)', function (data) {
+                                let selectList = matXmSelect.getValue();
+                                console.log(selectList)
+                                for (let i = 0; i<selectList.length; i++) {
+                                    let item = selectList[i];
+                                    // 鏌ヨ鐗╂枡璇︽儏
+                                    $.ajax({
+                                        url: baseUrl+"/weeklyCostTypes/covert/reality/"+item.value+"/auth",
                                         headers: {'token': localStorage.getItem('token')},
                                         method: 'GET',
                                         async: false,
@@ -736,8 +1232,10 @@
 // 鍏抽棴鍔ㄤ綔
 $(document).on('click','#data-detail-close', function () {
     parent.layer.closeAll();
+    location.reload();
 });
 
+
 function tableReload(child) {
     var searchData = {};
     $.each($('#search-box [name]').serializeArray(), function() {

--
Gitblit v1.9.1