From af1b8e2d783d0589ed5d4807ca1a02d672d14270 Mon Sep 17 00:00:00 2001
From: YL <YL@LAPTOP-SE03PLUR>
Date: 星期六, 24 七月 2021 00:34:33 +0800
Subject: [PATCH] 制作通用的单据编辑样例模块(生产汇报单列表/编辑),以方便其他开发人员可以借鉴。

---
 WebTM/views/生产管理/生产汇报单/Sc_Add_ICMOReportBillList.html |  496 ++++++++++++++++++++++++++----------------------------
 1 files changed, 239 insertions(+), 257 deletions(-)

diff --git "a/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\346\261\207\346\212\245\345\215\225/Sc_Add_ICMOReportBillList.html" "b/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\346\261\207\346\212\245\345\215\225/Sc_Add_ICMOReportBillList.html"
index beab3e3..300880a 100644
--- "a/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\346\261\207\346\212\245\345\215\225/Sc_Add_ICMOReportBillList.html"
+++ "b/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\346\261\207\346\212\245\345\215\225/Sc_Add_ICMOReportBillList.html"
@@ -90,18 +90,18 @@
                                             <div class="layui-inline">
                                                 <label class="layui-form-label">婧愬崟绫诲瀷</label>
                                                 <div class="layui-input-inline">
-                                                    <select name="HSourceBillType" lay-filter="HSourceBillType" id="HSourceBillType">
-                                                        <option value="0" selected="selected">鐢熶骇浠诲姟鍗�</option>
-                                                        <option value="1">鎵嬪伐褰曞叆</option>
+                                                    <select name="HMainSourceBillType" lay-filter="HMainSourceBillType" id="HMainSourceBillType">
+                                                        <option value="2">鐢熶骇浠诲姟鍗�</option>
+                                                        <option value="1" selected="selected">鎵嬪伐褰曞叆</option>
                                                     </select>
                                                 </div>
                                             </div>
                                             <div class="layui-inline">
                                                 <label class="layui-form-label">閫夊崟鍙�</label>
                                                 <div class="layui-input-inline">
-                                                    <input type="text" name="HSourceBillNo" id="HSourceBillNo" class="layui-input" value="" style="float:left;width:150px;">
-                                                    <input type="hidden" name="HSourceInterID" id="HSourceInterID" class="layui-input" value="" style="float:left;width:150px;">
-                                                    <input type="hidden" name="HSourceEntryID" id="HSourceEntryID" class="layui-input" value="" style="float:left;width:150px;">
+                                                    <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float:left;width:150px;">
+                                                    <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="" style="float:left;width:150px;">
+                                                    <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="" style="float:left;width:150px;">
                                                     <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
                                                         <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                     </button>
@@ -162,6 +162,8 @@
 
         var params = getUrlVars();
         var hID = params[params[0]];//缂栬緫鏌ョ湅
+        var Type = params[params[1]] == undefined ? "1" : params[params[1]];//鍗曟嵁缂栬緫鐘舵�侊細 1.鏃犳簮鍗曟柊澧灺� 聽2.鏈夋簮鍗曟柊澧灺� 聽3.缂栬緫聽 4.娴忚聽 5.鍙樻洿
+
         var Sctag = "0";
 
         layui.config({
@@ -177,122 +179,83 @@
                 , laydate = layui.laydate
                 , element = layui.element;
 
-           
 
-            //甯歌鐢ㄦ硶
-            laydate.render({
-                elem: '#HDate'
+            //鍏叡鍙橀噺
+            var option = [];
 
-            });
-            //鍒ゆ柇鏄惁鐧诲綍 鏈櫥褰曞垯璺冲埌鐧诲綍椤�
-            //if (sessionStorage.login != "login") {
-            //    layer.confirm("鐧诲綍澶辨晥锛岃閲嶆柊鐧诲綍锛�", {
-            //        icon: 4, skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず", closeBtn: 0, btn: ['閲嶆柊鐧诲綍']
-            //    }, function () { window.location.href = "../../user/login.html"; });
-            //}
-            //var tableReload = table.reload;
-            var option = {
-                id:'mainTable'
-                ,elem: '#mainTable'
-                , toolbar: '#toolbarDemo'
-                , height: 500
-                //,url: '/demo/table/user/' //鏁版嵁鎺ュ彛
-                , page: true //寮�鍚垎椤�
-                , cols: [[ //琛ㄥご
-                    { type: 'checkbox', fixed: 'left' }
-                    , { templet: '#xuhao', title: '搴忓彿', sort: true, fixed: 'left', event: "qwe", width: 100 }
-                    , { field: 'HMaterID', title: 'HMaterID', edit: 'text', width: 100, hide: true }
-                    , { field: 'HMaterCode', title: '鐗╂枡浠g爜', edit: 'text', event: 'HMaterCode', width: 100 }
-                    , { field: 'HMaterName', title: '鐗╂枡鍚嶇О', edit: 'text', width: 100 }
-                    , { field: 'HMaterSpec', title: '瑙勬牸鍨嬪彿', edit: 'text', width: 100 }
-                    , { field: 'HUnitID', title: 'HUnitID', edit: 'text', width: 100, hide: true }
-                    , { field: 'HUnitCode', title: '鍗曚綅浠g爜', edit: 'text', event: 'HUnitCode', width: 100 }
-                    , { field: 'HUnitName', title: '鍗曚綅鍚嶇О', edit: 'text', width: 100 }
-                    , { field: 'HSourceID', title: 'HSourceID', edit: 'text', width: 100, hide: true }
-                    , { field: 'HSourceCode', title: '璧勬簮浠g爜', edit: 'text', event: 'HSourceCode', width: 100 }
-                    , { field: 'HSourceName', title: '璧勬簮鍚嶇О', edit: 'text', width: 100 }
-                    , { field: 'HWorkerid', title: 'HWorkerid', edit: 'text', width: 100, hide: true }
-                    , { field: 'HWorkerCode', title: '鎿嶄綔鍛樹唬鐮�', edit: 'text', event: 'HWorkerCode', width: 100 }
-                    , { field: 'HWorkerName', title: '鎿嶄綔鍛樺悕绉�', edit: 'text', width: 100 }
-                    , { field: 'HQty', title: '鐢熶骇鏁伴噺', edit: 'text', width: 100 }
-                    , { field: 'HRemark', title: '琛ㄤ綋澶囨敞', edit: 'text', width: 100 }
-                    , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 150 }
-                ]]
-                , limit: 500 //姣忛〉榛樿鏄剧ず鐨勬暟閲�
-            };
-          
-
-            //鍒ゆ柇鏄惁鏂板
-            if (hID == null || hID == 0) {
-                //鍒濆鍔犺浇琛ㄦ牸{ "ID": 0, "HWasterReasonName": " ","HBadReasonID":0,"HEmpName": "  ", "HSQProcName": "   ","HProcID":0, "HZRProcName": "  ", "HMRBChecker": "  ", "HRemark": "  ", "HPSProcName": "  ", "HCloseMan": "   " }
-                option.data = [TabRow];
-                table.render(option);
-            }
-            else {
-                $("#HInterID").val(hID);//淇敼鏃朵富琛↖D
-                //缂栬緫鍔犺浇鏁版嵁
-                $.ajax({
-                    url: GetWEBURL() + 'Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai',
-                    type: "GET",
-                    data: { "sqlWhere": "and hmainid=" + hID },
-                    success: function (result) {
-                        //console.log(result);
-                        //console.log('gouba' + result);
-                        if (result.count == 1) {
-                            option.data = result.data;
-                            table.render(option);
-
-                        } else {
-                            layer.alert(result.code + result.Message, { icon: 5 });
-                        }
-                    }, error: function () {
-                        layer.close(index0);
-                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
-                    }
-                });
-
-            }
-
+            //鍒濆鍖栬〃鍗曟彃浠�
+            set_InitFrom();
 
             //澶村伐鍏锋爮浜嬩欢
-            var rowid = 0;
-            var rows = 0;
             table.on('toolbar(mainTable)', function (obj) {
+                var rowid = 0;
+                var rows = 0;
                 var checkStatus = table.checkStatus('mainTable')
                     , data = checkStatus.data;;
                 var AddRow = table.cache['mainTable'];
                 var NewRow = TabRow;
                 switch (obj.event) {
-                    case 'btn-AddLine':
-                        //table.cache["mainTable"].push(AddRow[rows]);
-                        table.cache["mainTable"].push(NewRow);
-                        option.data = table.cache["mainTable"];
-                        table.render(option);
-                        rows++;
-                        layer.msg('澧炲姞涓�琛屾寜閽紒')
+                    case 'btn-AddLine': btnAddLine(NewRow);
                         break;
-                    case 'btn-CopyLine':
-                        var copydata = JSON.stringify(data);
-                        if (data.length <= 0) {
-                            layer.alert("璇烽�夋嫨闇�瑕佸鍒剁殑涓�琛岋紒");
-                        }
-                        else if (data.length > 1) {
-                            layer.alert("鍙兘閫夋嫨澶嶅埗涓�琛岋紒");
-                        }
-                        else {
-                            var copydata2 = copydata.substring(1, copydata.length);//鍘婚櫎棣栬瀛楃'['
-                            var copyrow = copydata2.substring(0, copydata2.length - 1);//鍘婚櫎鏈熬瀛楃']'
-                            table.cache["mainTable"].push(JSON.parse(copyrow));//灏嗗鍒剁殑琛屽己杞垚json杩藉姞鍒拌〃鏍间笂
-                            option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
-                            table.render(option);//灏嗘暟鎹覆鏌撳埌琛ㄦ牸涓�
-                            //layer.alert(copyrow);
-                        }
+                    case 'btn-CopyLine': btnCopyLine(data);
+
                         break;
                 }
             });
+
             //琛屽唴浜嬩欢
             table.on('tool(mainTable)', function (obj) {
+                set_GridDelete(obj);   //琛屽唴鍒犻櫎
+                set_GridCellCheck(obj); //琛屽唴蹇嵎閿瓫閫�
+            });
 
+            //鍒濆鍖栬〃鏍�
+            set_InitGrid();
+
+            //鍒ゆ柇鏄簮鍗曟柊澧炪�佹棤婧愬崟鏂板銆佺紪杈�
+            set_Type(Type);
+
+            //鍒ゆ柇鏄惁婧愬崟鏂板銆佹垨鑰呯紪杈�
+            set_CheckSelect();
+
+
+            //鍒濆鍖栬〃鍗�
+            function set_InitFrom() {
+                laydate.render({
+                    elem: '#HDate'
+
+                });
+            }
+
+            //琛ㄦ牸澧炲姞琛屼簨浠�
+            function btnAddLine(NewRow) {
+                table.cache["mainTable"].push(NewRow);
+                option.data = table.cache["mainTable"];
+                table.render(option);
+                rows++;
+                layer.msg('澧炲姞涓�琛屾寜閽紒')
+            }
+
+            //琛ㄦ牸澶嶅埗琛屼簨浠�
+            function btnCopyLine(data) {
+                var copydata = JSON.stringify(data);
+                if (data.length <= 0) {
+                    layer.alert("璇烽�夋嫨闇�瑕佸鍒剁殑涓�琛岋紒");
+                }
+                else if (data.length > 1) {
+                    layer.alert("鍙兘閫夋嫨澶嶅埗涓�琛岋紒");
+                }
+                else {
+                    var copydata2 = copydata.substring(1, copydata.length);//鍘婚櫎棣栬瀛楃'['
+                    var copyrow = copydata2.substring(0, copydata2.length - 1);//鍘婚櫎鏈熬瀛楃']'
+                    table.cache["mainTable"].push(JSON.parse(copyrow));//灏嗗鍒剁殑琛屽己杞垚json杩藉姞鍒拌〃鏍间笂
+                    option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
+                    table.render(option);//灏嗘暟鎹覆鏌撳埌琛ㄦ牸涓�
+                }
+            }
+
+            //琛ㄦ牸琛屽唴浜嬩欢鍒犻櫎
+            function set_GridDelete(obj) {
                 var data = obj.data;
                 var rowIndex = $(obj.tr).attr("data-index");
                 if (obj.event === 'del') {
@@ -305,17 +268,13 @@
                             option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
                             table.reload(option);
                             layer.close(index);
-                            //obj.del();
-                            //layer.close(index);
-
-                            //var oldData = table.cache["mainTable"];
-                            //oldData.splice(obj.tr.data('index'), 1);
-                            //table.reload('mainTable', { data: oldData });
-                            //layer.close(index);
                         }
                     });
                 }
+            }
 
+            //琛ㄦ牸琛屽唴浜嬩欢蹇嵎閿瓫閫�
+            function set_GridCellCheck(obj) {
                 $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                     if (event.key == "F7") {
                         if (obj.event === 'HMaterCode')  //鐗╂枡淇℃伅
@@ -487,19 +446,115 @@
 
                     }
                 })
+            }
 
-            });
+            //鍒濆鍖栬〃鏍�
+            function set_InitGrid() {
+                var columns = [
+                    { type: 'checkbox', fixed: 'left' }
+                    , { templet: '#xuhao', title: '搴忓彿', sort: true, fixed: 'left', event: "qwe", width: 100 }
+                    , { field: 'HMaterID', title: 'HMaterID', edit: 'text', width: 100, hide: true }
+                    , { field: 'HMaterCode', title: '鐗╂枡浠g爜', edit: 'text', event: 'HMaterCode', width: 100 }
+                    , { field: 'HMaterName', title: '鐗╂枡鍚嶇О', edit: 'text', width: 100 }
+                    , { field: 'HMaterSpec', title: '瑙勬牸鍨嬪彿', edit: 'text', width: 100 }
+                    , { field: 'HUnitID', title: 'HUnitID', edit: 'text', width: 100, hide: true }
+                    , { field: 'HUnitCode', title: '鍗曚綅浠g爜', edit: 'text', event: 'HUnitCode', width: 100 }
+                    , { field: 'HUnitName', title: '鍗曚綅鍚嶇О', edit: 'text', width: 100 }
+                    , { field: 'HSourceID', title: 'HSourceID', edit: 'text', width: 100, hide: true }
+                    , { field: 'HSourceCode', title: '璧勬簮浠g爜', edit: 'text', event: 'HSourceCode', width: 100 }
+                    , { field: 'HSourceName', title: '璧勬簮鍚嶇О', edit: 'text', width: 100 }
+                    , { field: 'HWorkerid', title: 'HWorkerid', edit: 'text', width: 100, hide: true }
+                    , { field: 'HWorkerCode', title: '鎿嶄綔鍛樹唬鐮�', edit: 'text', event: 'HWorkerCode', width: 100 }
+                    , { field: 'HWorkerName', title: '鎿嶄綔鍛樺悕绉�', edit: 'text', width: 100 }
+                    , { field: 'HQty', title: '鐢熶骇鏁伴噺', edit: 'text', width: 100 }
+                    , { field: 'HRemark', title: '琛ㄤ綋澶囨敞', edit: 'text', width: 100 }
+                    , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 150 }
+                ];
+                option = {
+                    id: 'mainTable'
+                    , elem: '#mainTable'
+                    , toolbar: '#toolbarDemo'
+                    , page: false
+                    , cellMinWidth: 120
+                    , height: 500
+                    , cols: [columns]
+                    , done: function (res, curr, count) {
 
+                    }
+                };
+            }
 
+            //鑾峰彇鏈�澶у崟鎹彿
+            function set_MAXNum() {
+                var date = new Date();
+                var day = date.getDate();
+                var month = date.getMonth() + 1;
+                var year = date.getFullYear();
+                var shijian = year + "-" + month + "-" + day;
 
+                //鑾峰彇鏈�澶у崟鎹彿 new
+                $("#HInterID").val("0");
+                $("#HBillNo").val("");
+                $.ajax({
+                    url: GetWEBURL() + "/Web/GetMAXNum",
+                    type: "GET",
+                    data: { "HBillType": '3711' },
+                    success: function (d) {
+                        //console.log(d.data);
+                        $("#HBillNo").val(d.data[0].HBillNo);
+                        $("#HDate").val(shijian);
+                        $("#HInterID").val(0);
+                    }
+                });
+            }
 
+            //鍒ゆ柇鏄簮鍗曟柊澧炪�佹棤婧愬崟鏂板銆佺紪杈�
+            function set_Type(Type) {
+                console.log(Type);
+                switch (Type) {
+                    //鏃犳簮鍗曟柊澧�
+                    case '1': set_AddFNew();
+                        break;
+                    //鏈夋簮鍗曟柊澧灺� 聽
+                    case '2': set_AddNew();
+                        break;
+                    //缂栬緫聽
+                    case '3': set_EditFromGrid();
+                        break;
+                }
+            }
 
-
-
-
-            function RoadBillMain(hID)//鍔犺浇琛ㄥご
+            //鏃犳簮鍗曟柊澧�
+            function set_AddFNew()
             {
-               
+                
+                //鑾峰彇鏈�澶у崟鎹彿
+                set_MAXNum();
+                $('#HMainSourceBillNo').attr("disabled", false);
+                $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
+                option.data = [TabRow];
+                table.render(option);
+            }
+
+            //鏈夋簮鍗曟柊澧�
+            function set_AddNew() {
+                //鑾峰彇鏈�澶у崟鎹彿
+                set_MAXNum();
+                option.data = [TabRow];
+                table.render(option);
+            }
+
+            //缂栬緫鑾峰彇琛ㄥご銆佽幏鍙栬〃浣�
+            function set_EditFromGrid() {
+                set_EditForm(hID);  //缂栬緫鑾峰彇琛ㄥご
+                set_EditGrid(hID);  //缂栬緫鑾峰彇琛ㄤ綋
+                option.data = [TabRow];
+                table.render(option);
+            }
+
+            //缂栬緫鑾峰彇琛ㄥご
+            function set_EditForm(hID) {
+
                 //鏌ヨ妫�楠屾柟妗堝崟鏄惁瀛樺湪
                 $.ajax({
                     url: GetWEBURL() + "Sc_ICMOReportBill/Sc_GetICMOReportBillListCheckDetai",
@@ -523,8 +578,9 @@
                                 , "HGroupName": data.鐝粍                //鐝粍鍚嶇О
                                 , "HEmpID": data.HEmpID                  //缁熻鍛業D
                                 , "HEmpName": data.缁熻鍛�                //缁熻鍛樺悕绉�
-                                , "HSourceBillType": ""                   //婧愬崟绫诲瀷
-                                , "XDH": ""                               //閫夊崟鍙�
+                                , "HMainSourceBillNo": data.HMainSourceBillNo
+                                , "HMainSourceInterID": data.HMainSourceInterID
+                                , "HMainSourceEntryID": data.HMainSourceEntryID
                                 , "HExplanation": ""                      //鎽樿
                                 , "HRemark": data.琛ㄥご澶囨敞                //澶囨敞
                             });
@@ -538,46 +594,56 @@
                 });
             }
 
-
-            var date = new Date();
-            var day = date.getDate();
-            var month = date.getMonth() + 1;
-            var year = date.getFullYear();
-            var shijian = year + "-" + month + "-" + day;
-
-            //鍒ゆ柇鏄惁鏂板
-            if (hID == null || hID == 0) {
-                //鑾峰彇鏈�澶у崟鎹彿 new
-                $("#HInterID").val("0");
-                $("#HBillNo").val("");
+            //缂栬緫鑾峰彇琛ㄤ綋
+            function set_EditGrid(hID) {
+                $("#HInterID").val(hID);//淇敼鏃朵富琛↖D
+                //缂栬緫鍔犺浇鏁版嵁
                 $.ajax({
-                    url: GetWEBURL() + "/Web/GetMAXNum",
+                    url: GetWEBURL() + 'Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai',
                     type: "GET",
-                    data: { "HBillType": '3711' },
-                    success: function (d) {
-                        //console.log(d.data);
-                        $("#HBillNo").val(d.data[0].HBillNo);
-                        $("#HDate").val(shijian);
-                        $("#HInterID").val(0);
+                    data: { "sqlWhere": "and hmainid=" + hID },
+                    success: function (result) {
+                        if (result.count == 1) {
+                            option.data = result.data;
+                            table.render(option);
+
+                        } else {
+                            layer.alert(result.code + result.Message, { icon: 5 });
+                        }
+                    }, error: function () {
+                        layer.close(index0);
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
                     }
                 });
             }
-            else {//濡傛灉淇敼鍒欒蛋涓嬮潰 new
-                RoadBillMain(hID);
-                /* RoadBillSub(linterid);*/
-            }
 
-            //鑾峰彇涓嬫媺閫変腑鍊�
-            form.on('select(HSourceBillType)', function (data) {
-                Sctag = data.value;
-                form.render('select');
-                if (Sctag != "0") {
-                    $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
-                }
-                else {
-                    $('#XDHList').removeClass("layui-btn-disabled").attr("disabled", false);
-                }
-            });
+
+            //鐩戣涓嬫媺妗嗘槸鍚︽簮鍗�
+            function set_CheckSelect() {
+                //鑾峰彇涓嬫媺閫変腑鍊�
+                form.on('select(HMainSourceBillType)', function (data) {
+                    Sctag = data.value;
+                    form.render('select');
+                    switch (Sctag) {
+                        //鏃犳簮鍗曟柊澧�
+                        case '1':
+                            $("#HMainSourceInterID").val("0");
+                            $("#HMainSourceEntryID").val("0");
+                            $('#HMainSourceBillNo').attr("disabled", false);
+                            $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
+                            Type = 1;
+                            break;
+                        //鏈夋簮鍗曟柊澧灺� 聽
+                        case '2':
+                            $("#HMainSourceInterID").val("0");
+                            $("#HMainSourceEntryID").val("0");
+                            $('#HMainSourceBillNo').attr("disabled", true);
+                            $('#XDHList').removeClass("layui-btn-disabled").attr("disabled", false);
+                            Type = 2;
+                            break;
+                    }
+                });
+            }
 
 
             //琛ㄥご淇℃伅杞﹂棿寮圭獥
@@ -721,18 +787,18 @@
                         //var rowIndex = $("#mainTable").find("tbody tr").attr('data-index');//褰撳墠琛岀殑绱㈠紩
                         //$(".layui-table-view .layui-table tbody tr[data-index=" + 1+ "]").remove();
 
-                        $("#HSourceBillNo").val(checkStatus.data[0].鍗曟嵁鍙�);
-                        $("#HSourceInterID").val(checkStatus.data[0].hmainid);
-                        $("#HSourceEntryID").val(checkStatus.data[0].HEntryID);
+                        $("#HMainSourceBillNo").val(checkStatus.data[0].鍗曟嵁鍙�);
+                        $("#HMainSourceInterID").val(checkStatus.data[0].hmainid);
+                        $("#HMainSourceEntryID").val(checkStatus.data[0].HEntryID);
                         var list = [];
-                        for (var i = 0; i <checkStatus.data.length; i++) {
+                        for (var i = 0; i < checkStatus.data.length; i++) {
                             list.push(checkStatus.data[i].鍗曟嵁鍙�)
                         }
                         if (isAllEqual(list))  //鐩稿悓鍗曞彿
                         {
-                            if (checkStatus.data.length>1)
-                            {
-                                for (var i = 0; i < checkStatus.data.length-1; i++) //琛ヨ
+                            console.log(checkStatus.data);
+                            if (checkStatus.data.length > 1) {
+                                for (var i = 0; i < checkStatus.data.length - 1; i++) //琛ヨ
                                 {
                                     //var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HRemark": "" };
                                     table.cache["mainTable"].push(TabRow);
@@ -751,11 +817,10 @@
                             }
                             layer.close(layer.index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
                         }
-                        else   
-                        {
+                        else {
                             layer.msg("璇烽�夋嫨鐩稿悓鍗曞彿!", { time: 1 * 2000, icon: 5 });
                         }
-                       
+
                     }
                     , btn2: function (index, layero) {
                         //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
@@ -771,22 +836,13 @@
             });
 
 
-
+            //閫�鍑�
             form.on('submit(Exit)', function (data) {//
                 var index = parent.layer.getFrameIndex(window.name); //鍏堝緱鍒板綋鍓峣frame灞傜殑绱㈠紩
                 parent.layer.close(index); //鍐嶆墽琛屽叧闂�
             });
 
-
-
-
-
-            form.on('submit(Cancel)', function () {
-                //sessionStorage["SourceFlag"] = false;
-                parent.location.href = "../../../views/index.html"
-                //window.close();//鍏抽棴褰撳墠椤�
-            })
-
+            //缂栬緫鑾峰彇琛ㄤ綋鏃舵椂闂存牸寮忕煫姝f柟寮�
             function formatDate(date) {
                 var d = new Date(date),
                     month = '' + (d.getMonth() + 1),
@@ -799,6 +855,7 @@
                 return [year, month, day].join('-');
             }
 
+            //鎻愪氦淇濆瓨
             form.on('submit(Saver)', function (data) {//淇濆瓨
                 var refSav = "";
                 if (hID == "" || hID == null) {
@@ -819,7 +876,6 @@
                     return false;
                 }
 
-
                 $.ajax(
                     {
                         type: "POST",
@@ -836,39 +892,18 @@
                                 });
                             }
                             else {
-
-                                f_alert(data.Message);
-                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
+                                layer.alert(data.Message, { icon: 5 });
                             }
-                            layer.closeAll("loading");
                         },
                         error: function (err) {
-
-                            f_alert("閿欒:" + err);
-                            console.log("Reason" + sMainStr);
+                            layer.alert(err.Message, { icon: 5 });
                         }
                     });
-            });
-          
-            function f_alert(sMsg) {
-                layer.alert(sMsg, { icon: 5 });
-
-            }
-
-            //鐩戝惉鎻愪氦
-            form.verify({
-                numberOrEmpty: function (value, item) {
-                    // if (value != '') {
-                    if (!/^\d+$/.test(value)) {
-                        return '涓嶈兘涓虹┖鎴栨暟瀛楁垨鑰�0';
-                    }
-                    //}
-                }
-            });
-
-
+            })
         });
-        //鍒ゆ柇鏁扮粍涓殑鍊兼槸鍚︾浉鍚�
+
+
+        //鍒ゆ柇婧愬崟甯﹀洖鏁版嵁鏁扮粍涓殑鍊兼槸鍚︾浉鍚�
         function isAllEqual(array) {
             if (array.length > 0) {
                 return !array.some(function (value, index) {
@@ -879,61 +914,8 @@
             }
         }
 
-        //瀹氫箟鍏ㄥ眬鍙橀噺
-        var HReasonName, ReasonID, EmpName, SQProcName,
-            ProcID, ZRProcName, QRName
-            ;
-        function GetHReasonValue(obj)  //杩斿洖涓嶈壇鍘熷洜
-        {
-            HReasonName = obj[0].HName;
-            ReasonID = obj[0].HItemID;
-        }
-        //杩斿洖鐗╂枡
-        function GetHMaterNameValue(obj) {  //杩斿洖鐗╂枡
-            $("#HMater").val(obj[0].HName);
-            $("#HMaterID").val(obj[0].HItemID);
-            $("#HMaterNumber").val(obj[0].HNumber);
-        }
-        //杩斿洖宸ュ簭
-        function GetHProcValue(obj) {  //杩斿洖宸ュ簭
-            $("#HProcName").val(obj[0].宸ュ簭);
-            $("#HProcID").val(obj[0].HItemID);
-            $("#HProcNumber").val(obj[0].宸ュ簭浠g爜);
-        }
-        function GetHDeptNameValue(obj) {  //杩斿洖閮ㄩ棬
-            $("#HDepName").val(obj[0].HName);
-            $("#HDeptID").val(obj[0].HItemID);
-            $("#HDeptNumber").val(obj[0].HNumber);
-        }
-        //杩斿洖鍗曚綅
-        function GetHUnitNameValue(obj) {
-            $("#HUName").val(obj[0].HName);
-            $("#HUnitID").val(obj[0].HItemID);
-            $("#HUnitNumber").val(obj[0].HNumber);
-        }
 
-        function GetHKeeperValue(obj) {  //杩斿洖璐d换浜�
-            EmpName = obj[0].HName;
-            // $("#HEmpName").val(obj[0].HName);
-            //$("#HItemID").val(obj[0].HItemID);
-        }
-        //function GetHProcValue(obj) {  //杩斿洖鐢宠宸ュ簭
-        //    SQProcName = obj[0].宸ュ簭;
-        //    ProcID = obj[0].HItemID;
-        //    //$("#HSQProcName").val(obj[0].宸ュ簭);
-        //    //$("#HProcID").val(obj[0].HItemID);
-        //}
-        function GetHZRValue(obj) {   //杩斿洖璐d换宸ュ簭
-            ZRProcName = obj[0].宸ュ簭;
-            //$("#HZRProcName").val(obj[0].宸ュ簭);
-            //$("#HItemID").val(obj[0].HItemID);
-        }
-        //HWorker
-        function GetHWorkerValue(obj) {  //杩斿洖涓嶈壇纭浜�
-            QRName = obj[0].HName;
-            //$("#HQRName").val(obj[0].HName);
-            //$("#HItemID").val(obj[0].HItemID);
-        }
+
         function AllowLoadData(sSubStr) {  //闈炵┖楠岃瘉
             var Result = true;
             if ($("#HDeptID").val() == '' || $("#HDeptID").val() == null) {

--
Gitblit v1.9.1