From cba0ef063a24b5b965bfa943cf1c8d2c8acba84a Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期四, 03 八月 2023 10:16:43 +0800
Subject: [PATCH] 排产 工艺路线的加工数量排产需要 生产入库 单据号改成流转卡号

---
 WebTM/views/生产管理/生产计划平台/JIT_DayPlanPlatForm.html |  976 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 948 insertions(+), 28 deletions(-)

diff --git "a/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\350\256\241\345\210\222\345\271\263\345\217\260/JIT_DayPlanPlatForm.html" "b/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\350\256\241\345\210\222\345\271\263\345\217\260/JIT_DayPlanPlatForm.html"
index ba3dcba..2e0facc 100644
--- "a/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\350\256\241\345\210\222\345\271\263\345\217\260/JIT_DayPlanPlatForm.html"
+++ "b/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\350\256\241\345\210\222\345\271\263\345\217\260/JIT_DayPlanPlatForm.html"
@@ -24,7 +24,10 @@
                             <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnLock" id="btnLock">閿佸畾</button>
                             <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnUnlock" id="btnUnlock">瑙i攣</button>
                             <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnCompleteSetAnalysis" id="btnCompleteSetAnalysis">榻愬鍒嗘瀽</button>
+                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnTLYS" id="btnTLYS">鎻愭枡杩愮畻</button>
                             <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnICMOBill" id="btnICMOBill">鐢熶骇璁㈠崟閫夊崟</button>
+                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnReady" id="btnReady">鍑嗗</button>
+                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnProPC" id="btnProPC">鎺掍骇</button>
                         </div>
                         <div class="layui-collapse">
                             <div class="layui-colla-item">
@@ -40,13 +43,16 @@
                                     </div>
                                 </div>
                                 <div class="layui-inline">
-                                    <label class="layui-form-label" style="width: 85px;">鐢熶骇璁㈠崟缁勭粐</label>
+                                    <label class="layui-form-label" style="width: 85px;">鎻愭枡绫诲瀷</label>
                                     <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
-                                        <select name="HProdORGID" id="HProdORGID" lay-verify="HProdORGID">
-                                            <!--鍔ㄦ�佹覆鏌撶粍缁�-->
+                                        <select name="HTLType" id="HTLType" lay-verify="HTLType">
+                                            <option value="缂烘枡" selected="selected">缂烘枡</option>
+                                            <option value="鐢熶骇鐢ㄦ枡娓呭崟">鐢熶骇鐢ㄦ枡娓呭崟</option>
+                                            <!--<option value="閲囪喘璁㈠崟">閲囪喘璁㈠崟</option> 鏆傛椂娌℃湁-->
                                         </select>
                                     </div>
                                 </div>
+
                                 <div class="layui-inline">
                                     <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">鐢熶骇杞﹂棿</label>
                                     <div class="layui-input-block" style="margin-left: 77px;">
@@ -71,7 +77,7 @@
                                             <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">鐗╂枡缂栫爜</label>
                                             <div class="layui-input-block" style="margin-left: 77px;">
                                                 <input type="hidden" class="layui-input" lay-verify="HMaterID" name="HMaterID" id="HMaterID" value="0" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
-                                                <input type="text" class="layui-input" lay-verify="HMaterNumber" name="HMaterNumber" id="HMaterNumber" value="" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
+                                                <input type="text" class="layui-input" lay-verify="HMaterNumber" name="HMaterNumber" id="HMaterNumber" value="" style="width: 60%;display: inline-block;">
                                                 <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHMaterID" id="btnHMaterID" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                 </button>
@@ -94,15 +100,14 @@
                                         <div class="layui-inline">
                                             <label class="layui-form-label" style="width: 85px;">鐗╂枡鍚嶇О</label>
                                             <div class="layui-input-block" style="margin-left: 120px;">
-                                                <input type="text" class="layui-input" name="HMaterName" id="HMaterName" style="background-color:#efefef4d" readonly>
+                                                <input type="text" class="layui-input" name="HMaterName" id="HMaterName">
                                             </div>
                                         </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label" style="width: 85px;">榻愬绫诲瀷</label>
                                             <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                                 <select name="HOrderType" id="HOrderType" lay-verify="HOrderType">
-                                                    <option value="鍏ㄩ儴">鍏ㄩ儴</option>
-                                                    <option value="鐢熶骇鐢ㄦ枡娓呭崟">鐢熶骇鐢ㄦ枡娓呭崟</option>
+                                                    <option value="鐢熶骇鐢ㄦ枡娓呭崟" selected="selected">鐢熶骇鐢ㄦ枡娓呭崟</option>
                                                     <option value="鏍囧噯Bom">鏍囧噯Bom</option>
                                                 </select>
                                             </div>
@@ -118,7 +123,7 @@
                                         <div class="layui-inline">
                                             <label class="layui-form-label" style="width: 85px;">瑙勬牸鍨嬪彿</label>
                                             <div class="layui-input-block" style="margin-left: 120px;">
-                                                <input type="text" class="layui-input" name="HMaterModel" id="HMaterModel" style="background-color:#efefef4d" readonly>
+                                                <input type="text" class="layui-input" name="HMaterModel" id="HMaterModel">
                                             </div>
                                         </div>
                                         <div class="layui-inline">
@@ -128,16 +133,63 @@
                                             </div>
                                         </div>
                                     </div>
+                                    <div class="layui-row" style="margin-top:10px;">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label" style="width: 85px;">鐢熶骇璁㈠崟缁勭粐</label>
+                                            <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
+                                                <select name="HProdORGID" id="HProdORGID" lay-verify="HProdORGID">
+                                                    <!--鍔ㄦ�佹覆鏌撶粍缁�-->
+                                                </select>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label" style="width: 85px;">鎺掍骇鏃ユ湡</label>
+                                            <div class="layui-input-block" style="margin-left: 120px;">
+                                                <input type="date" class="layui-input" lay-verify="HMastersDate" name="HMastersDate" id="HMastersDate" style="padding-left: 75px;">
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row" style="margin-top: 10px; margin-bottom: 10px;">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">杩囨护</label>
+                                            <div class="layui-input-block">
+                                                <select name="ColName" id="ColName" lay-filter="ColName" style="width:190px;">
+                                                </select>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <select name="Comparator" id="Comparator" lay-filter="Comparator" style="width:190px;">
+                                                <option value="0" selected="selected"></option>
+                                                <option value="=">=</option>
+                                                <option value=">=">>=</option>
+                                                <option value=">">></option>
+                                                <option value="<="><=</option>
+                                                <option value="<"><</option>
+                                                <option value="<>"><></option>
+                                                <option value="7">鍖呭惈</option>
+                                                <option value="8">宸﹀寘鍚�</option>
+                                                <option value="9">鍙冲寘鍚�</option>
+                                                <option value="10">涓嶅寘鍚�</option>
+                                            </select>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <input type="text" class="layui-input" value="" name="ColContent" id="ColContent">
+                                        </div>
+                                    </div>
                                 </div>
                             </div>
                         </div>
+                        <div id="HProgressBar"></div>
                         <table class="" id="mainTable" lay-filter="mainTable"></table>
                         <script type="text/html" id="toolbarDemo">
                             <div class="layui-btn-container">
-                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_BatchFill"><i class="layui-icon layui-icon-file-b"></i>鎵归噺濉厖</button>
-                                <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="set_ShowBill"><i class="layui-icon layui-icon-form"></i>缂栬緫</button>-->
+                                <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="set_BatchFill"><i class="layui-icon layui-icon-file-b"></i>鎵归噺濉厖</button>
+            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_ShowBill"><i class="layui-icon layui-icon-form"></i>缂栬緫</button>-->
                                 <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>澶嶅埗琛�</button>
                                 <button type="button" class="layui-btn layui-btn-sm" lay-event="set_DeleteBill"><i class="layui-icon layui-icon-delete"></i>鍒犻櫎琛�</button>
+                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_MoverUp"><i class="layui-icon layui-icon-delete"></i>涓婄Щ</button>
+                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_MoverDown"><i class="layui-icon layui-icon-delete"></i>涓嬬Щ</button>
+                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_Priority"><i class="layui-icon layui-icon-delete"></i>浼樺厛绾�</button>
                                 <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
                             </div>
                         </script>
@@ -153,9 +205,7 @@
     <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">鍒犻櫎</a>
 </script>
 <script>
-    var treeCkData = { id: 0 };
-    var TagId = "";
-    var TagParentId = "";
+    var OptionData = [];
     layui.config({
         base: '../../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
     }).extend({
@@ -175,6 +225,7 @@
         var sWhere = "";
         var option = [];
         var HModName = "JIT_DayPlanPlatForm";
+      
         //#endregion
 
         //#region 杩涘叆椤甸潰鍗冲姞杞�
@@ -200,7 +251,7 @@
                     return;
                 }
                 if (!isNaN(parseInt(obj.data[Format(yyyy + '/' + MM + '/' + (dd + i), 'yyyy-MM-dd')]))) {
-                    dateHQty += parseInt(obj.data[Format(yyyy + '/' + MM + '/' + (dd + i), 'yyyy-MM-dd')]);
+                    dateHQty += parseInt(obj.data[Format(yyyy + '/' + MM + '/' + (dd + i), 'yyyy-MM-dd')])  ;
                 }
             }
             for (var i = 1; i < dd; i++) {
@@ -208,6 +259,14 @@
                     dateHQty += parseInt(obj.data[Format(yyyy + '/' + (MM + 1) + '/' + i, 'yyyy-MM-dd')]);
                 }
             }
+
+            if (dateHQty > (parseInt(obj.data["璁″垝鏁伴噺"]))) {
+                obj.update({
+                    "鏃ヨ鍒掓暟閲忔�婚噺": dateHQty
+                });
+                return layer.msg("鎺掍骇鏁伴噺澶т簬璁㈠崟鏁伴噺!")
+            }
+
             //淇敼鏁版嵁
             obj.update({
                 "鏃ヨ鍒掓暟閲忔�婚噺": dateHQty
@@ -217,6 +276,47 @@
         //鍙屽嚮琛ㄦ牸浜嬩欢
         table.on('rowDouble(mainTable)', function (obj) {
             btnrowDouble(obj.data);
+        })
+
+        var objData = "";
+        //鐐瑰嚮琛岄�変腑鏁版嵁
+        table.on('row(mainTable)', function (obj) {
+
+            if (objData != "" && objData.tr.find(':checkbox:first').prop('checked') != obj.tr.find(':checkbox:first').prop('checked')) {
+                objData.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//鍙栨秷澶嶉�夋閫変腑鏍峰紡
+                objData.tr.find(':checkbox:first').prop('checked', false);//鍙栨秷澶嶉�夋閫変腑鏍峰紡
+                layui.each(table.cache.mainTable, function (i, l) {
+                    if (objData.tr.index() == l.LAY_TABLE_INDEX) {
+                        l.LAY_CHECKED = false;
+                    }
+                });
+            }
+
+            var flag = !obj.tr.find(':checkbox:first').prop('checked');
+            obj.tr.find(':checkbox').prop('checked', flag);
+            if (flag) {
+                obj.tr.find('.layui-form-checkbox').addClass('layui-form-checked');  //璁剧疆澶嶉�夋閫変腑鏍峰紡
+            } else {
+                obj.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//鍙栨秷澶嶉�夋閫変腑鏍峰紡
+                obj.tr.find(':checkbox:first').prop('checked', false);//鍙栨秷澶嶉�夋閫変腑鏍峰紡
+            }
+            //mainTable 涓鸿〃鏍糏D   娉ㄦ剰姝ゅ濡傛灉ID涓嶆纭皢瀵艰嚧浣犲湪鐩戝惉澶嶉�夋鏃惰幏鍙栦笉鍒颁綘閫夋嫨鐨勬暟鎹紝鍓嶉潰鐨勫彧鏄坊鍔犳垨鍒犻櫎閫変腑鏈�変腑鏍峰紡浠ュ強璁剧疆鑳屾櫙鑹诧紝瀛椾綋棰滆壊
+            layui.each(table.cache.mainTable, function (i, l) {
+                if (obj.tr.index() == l.LAY_TABLE_INDEX) {
+                    l.LAY_CHECKED = flag;
+                }
+            });
+
+            for (var i = 0; i < table.cache["mainTable"].length; i++) {
+                if (table.cache["mainTable"][i]["鐢熶骇璁㈠崟鍙�"] != obj.data["鐢熶骇璁㈠崟鍙�"]) {
+                    table.cache["mainTable"][i].LAY_CHECKED = false;
+                }
+            }
+            option.data = table.cache["mainTable"];
+            table.render(option);
+
+          
+            objData = obj;
         })
 
         //澶村伐鍏锋爮浜嬩欢
@@ -252,6 +352,18 @@
                 case 'set_DeleteBill':
                     set_DeleteBill();
                     break;
+                //涓婄Щ
+                case 'set_MoverUp':
+                    set_MoverUp(data);
+                    break;
+                //涓嬬Щ
+                case 'set_MoverDown':
+                    set_MoverDown(data);
+                    break;
+                //浼樺厛绾�
+                case 'set_Priority':
+                    set_Priority();
+                    break;
             }
         });
 
@@ -268,7 +380,7 @@
             } else if (table.cache["mainTable"].length == 0) {
                 return layer.msg("鏃犳暟鎹�,鏃犳硶淇濆瓨!");
             } else {
-                set_AddNew(data);
+                set_AddNew();
             }
         });
 
@@ -297,9 +409,32 @@
             get_btnCompleteSetAnalysis();
         })
 
+        //鎻愭枡杩愮畻
+        form.on('submit(btnTLYS)', function (data) {
+            get_btnTLYS();
+        })
+
         //鐢熶骇璁㈠崟閫夊崟
         form.on('submit(btnICMOBill)', function (data) {
             get_btnICMOBill();
+        })
+
+        //鍑嗗
+        form.on('submit(btnReady)', function (data) {
+            get_btnReady();
+        })
+
+      
+
+        //鎺掍骇
+        form.on('submit(btnProPC)', function (data) {
+            var HWorkShopID = $("#HWorkShopID").val();//鐢熶骇杞﹂棿
+            if (HWorkShopID == 0) {
+                return layer.msg("鐢熶骇杞﹂棿涓嶈兘涓虹┖!");
+            } else {
+                get_btnProPC(HWorkShopID)
+            }
+          
         })
 
         //琛屽唴浜嬩欢
@@ -336,8 +471,9 @@
         //#region 鍒濆鍖栫晫闈�
         function set_ClearBill() {
             //鍒濆鍖栨椂闂�
-            $("#HPlanBeginDate").val(Format(new Date(), "yyyy-MM-dd"));
+            $("#HPlanBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));
             $("#HPlanEndDate").val(Format(new Date(), "yyyy-MM-dd"));
+            $("#HMastersDate").val("");
             //缁勭粐
             Organ();
             //鍒濆鍖栬〃鏍�
@@ -531,7 +667,13 @@
             columns.push({ field: '浜х嚎鍏ュ簱鏁伴噺', title: '浜х嚎鍏ュ簱鏁伴噺', width: 150 });
             columns.push({ field: '鏈帓鏁伴噺', title: '鍙帓鏁伴噺', width: 150 });
             columns.push({ field: '璁㈠崟绛夌骇', title: '璁㈠崟绛夌骇', width: 150 });
-            columns.push({ field: '浜よ揣鏃ユ湡', title: '浜よ揣鏃ユ湡', width: 150, templet: "<div>{{d.浜よ揣鏃ユ湡 =='' ?'':layui.util.toDateString(d.浜よ揣鏃ユ湡, 'yyyy-MM-dd HH:mm:ss')}}</div>"});
+            columns.push({ field: '璁㈠崟浜よ揣鏈�', title: '璁㈠崟浜よ揣鏈�', width: 150, templet: "<div>{{d.璁㈠崟浜よ揣鏈� =='1900-01-01' ?'':layui.util.toDateString(d.璁㈠崟浜よ揣鏈�, 'yyyy-MM-dd')}}</div>" });
+            columns.push({ field: '璁㈠崟闇�姹傛暟閲�', title: '璁㈠崟闇�姹傛暟閲�', width: 150 });
+            columns.push({ field: '寮�宸ヤ綑閲�', title: '寮�宸ヤ綑閲�', width: 150 });
+            columns.push({ field: '灏忔椂浜ц兘', title: '灏忔椂浜ц兘', width: 150 });
+            columns.push({ field: '鐢熶骇鍛ㄦ湡', title: '鐢熶骇鍛ㄦ湡', width: 150 });
+            columns.push({ field: '鏈�杩熷紑宸ユ棩鏈�', title: '鏈�杩熷紑宸ユ棩鏈�', width: 150, templet: "<div>{{d.鏈�杩熷紑宸ユ棩鏈� =='' ?'':layui.util.toDateString(d.鏈�杩熷紑宸ユ棩鏈�, 'yyyy-MM-dd')}}</div>" });
+            columns.push({ field: '鏈�杩熷畬宸ユ棩鏈�', title: '鏈�杩熷畬宸ユ棩鏈�', width: 150, templet: "<div>{{d.鏈�杩熷畬宸ユ棩鏈� =='' ?'':layui.util.toDateString(d.鏈�杩熷畬宸ユ棩鏈�, 'yyyy-MM-dd')}}</div>"});
             columns.push({ field: '婧愬崟涓诲唴鐮�', title: '婧愬崟涓诲唴鐮�', width: 150 });
             columns.push({ field: '婧愬崟瀛愬唴鐮�', title: '婧愬崟瀛愬唴鐮�', width: 150 });
             columns.push({ field: 'hmainid', title: '鏃ヨ鍒掑伐鍗曚富鐮�', width: 150 });
@@ -540,6 +682,10 @@
             columns.push({ field: '鎷嗗崟鏁伴噺', title: '鎷嗗崟鏁伴噺', width: 150 });//0
             columns.push({ field: '璁㈠崟鍙帓鏁伴噺', title: '璁㈠崟鍙帓鏁伴噺', width: 150 });
             columns.push({ field: '鏈叆搴撴暟閲�', title: '鏈叆搴撴暟閲�', width: 150 });//0
+            columns.push({ field: 'HICMOInterID', title: 'HICMOInterID', width: 150, hide:true });
+            columns.push({ field: 'HGroupID', title: 'HGroupID', width: 150, hide:true });
+            columns.push({ field: 'HGroupName', title: 'HGroupName', width: 150, hide:true });
+            columns.push({ field: '鐢熶骇璧勬簮浠g爜', title: '鐢熶骇璧勬簮浠g爜', width: 150, hide:true });
             columns.push({ fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo' });
 
             option = {
@@ -551,7 +697,6 @@
                 , cols: [columns]
                 , limit: Number.MAX_VALUE//榛樿鏄剧ず鍏ㄩ儴
             };
-
         }
 
         //鏌ヨ鍔犺浇鏁版嵁
@@ -560,6 +705,7 @@
             $.ajax({
                 url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillList',
                 type: "GET",
+                async: false,
                 data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
                 success: function (data1) {
                     if (data1.count == 1) {
@@ -574,6 +720,11 @@
                             get_Display_1(HinterID_S);
                             get_Display_2(HinterID_S)
                         }
+
+                        if ($("#Comparator").val() == 0 && $("#ColContent").val() == "") {
+                            ColFilter();
+                        }
+
                     } else {
                         layer.close(ajaxLoad);
                         layer.alert(data1.code + data1.Message, { icon: 5 });
@@ -594,6 +745,15 @@
                 data: { "sWhere": HinterID_S.toString(),"num":1 },
                 success: function (data1) {
                     if (data1.count == 1) {
+                        for (var i = 0; i < 31; i++) {
+                            option.cols[0][22 + i]["edit"] = "text";
+                            option.cols[0][22 + i]["style"] = "";
+                            var TableDate = option.cols[0][22 + i].field;
+                            var date = new Date(TableDate).getDay();
+                            if (date == 6 || date == 0) {
+                                option.cols[0][22 + i]["style"] = "	background-color: #c3fec8";
+                            }
+                        }
                         if (data1.data[0]["DayNum"] > 0) {
                             //鑾峰彇琚攣瀹氱殑鍒楁暟
                             var tableNum = 0;
@@ -619,12 +779,13 @@
                                 option.cols[0][22 + i]["style"] = "	background-color: #e6e6e6";
                             }
 
-                        } else {
-                            for (var i = 0; i < 31; i++) {
-                                option.cols[0][22 + i]["edit"] = "text";
-                                option.cols[0][22 + i]["style"] = "";
-                            }
                         }
+                        //else {
+                        //    for (var i = 0; i < 31; i++) {
+                        //        option.cols[0][22 + i]["edit"] = "text";
+                        //        option.cols[0][22 + i]["style"] = "";
+                        //    }
+                        //}
                         table.render(option);
                         layer.close(ajaxLoad);
                         //layer.alert("鏌ヨ鎴愬姛", { icon: 1 });
@@ -800,9 +961,36 @@
             }
             var HPlanBeginDate = $("#HPlanBeginDate").val();//寮�宸ヨ捣濮嬫棩鏈�
             var HPlanEndDate = $("#HPlanEndDate").val();//寮�宸ユ埅姝㈡棩鏈�
+            var HMastersDate = $("#HMastersDate").val();//鎺掍骇鏃ユ湡
             var HSeOrderBillNo = $("#HSeOrderBillNo").val();//閿�鍞鍗曞彿
             var HMaterID = $("#HMaterID").val();//鐗╂枡缂栫爜id
             var HICMOBillNo = $("#HICMOBillNo").val();//鐢熶骇璁㈠崟鍙�
+            var ColName = $("#ColName").val();//澶嶉�夋
+            var Comparator = $("#Comparator").val()
+            var ColContent = $("#ColContent").val();
+            var sWheres = "";
+
+            if (ColName != 0 && Comparator != 0) {
+                var com = "";
+                switch (Comparator) {
+                    case "7":
+                        com = "like''%" + ColContent + "%''";
+                        break;
+                    case "8":
+                        com = "like''%" + ColContent + "''";
+                        break;
+                    case "9":
+                        com = "like''" + ColContent + "%''";
+                        break;
+                    case "10":
+                        com = "not like''%" + ColContent + "%''";
+                        break;
+                    default:
+                        com = "" + Comparator + "''" + ColContent + "''";
+                        break;
+                }
+                sWheres += " and [" + ColName + "] " + com;
+            }
 
             sWhere = {
                 HPlanBeginDate: HPlanBeginDate
@@ -812,6 +1000,8 @@
                 , HMaterID: HMaterID
                 , HICMOBillNo: HICMOBillNo
                 , HWorkShopID: HWorkShopID
+                , HMastersDate: HMastersDate
+                , sWheres: sWheres
             }
             get_Display(JSON.stringify(sWhere));
             sWhere = ""//璋冪敤鎺ュ彛鍚庢竻绌簊Where缂撳瓨
@@ -831,6 +1021,7 @@
             layer.open({
                 type: 2 //绫诲瀷
                 , skin: 'layui-layer-rim'//鍔犱笂杈规
+                , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
                 , area: ['90%', '90%']//澶у皬
                 , title: '榻愬鍒嗘瀽鏄庣粏琛�'//鏍囬
                 , shift: 2//寮瑰嚭鍔ㄧ敾
@@ -840,17 +1031,21 @@
 
         //閲嶇疆
         function set_ClearQuery() {
-            $("#HPlanBeginDate").val(Format(new Date(), "yyyy-MM-dd"));//寮�宸ヨ捣濮嬫棩鏈�
+            $("#HPlanBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));//寮�宸ヨ捣濮嬫棩鏈�
             $("#HSeOrderBillNo").val("");//閿�鍞鍗曞彿
             $("#HPlanEndDate").val(Format(new Date(), "yyyy-MM-dd"));//寮�宸ユ埅姝㈡棩鏈�
+            $("#HMastersDate").val("");//鎺掍骇鏃ユ湡
             $("#HMaterID").val("0");//鐗╂枡缂栫爜id
             $("#HMaterNumber").val("");//鐗╂枡缂栫爜
             $("#HMaterName").val("");//鐗╂枡鍚嶇О
-            $("#HMaterModel").val("0");//瑙勬牸鍨嬪彿
+            $("#HMaterModel").val("");//瑙勬牸鍨嬪彿
             $("#HICMOBillNo").val("");//鐢熶骇璁㈠崟鍙�
             $("#HWorkShopID").val("0");//鐢熶骇杞﹂棿id
             $("#HWorkShopIDName").val("");//鐢熶骇杞﹂棿
             $("#HProdORGID").val(sessionStorage["OrganizationID"])//鐢熶骇璁㈠崟缁勭粐
+            $("#ColContent").val("");
+            $("#ColName").val("0");
+            $("#Comparator").val("0");
             form.render('select');
             sWhere = "";
         }
@@ -886,6 +1081,38 @@
             });
         }
 
+        //鎻愭枡杩愮畻
+        function get_btnTLYS() {
+            if ($("#HWorkShopID").val() == 0) {
+                return layer.msg("鐢熶骇杞﹂棿涓嶈兘涓虹┖!");
+            }
+            sWhere = {
+                HProdORGID: $("#HProdORGID").val()
+                , HWorkShopID: $("#HWorkShopID").val()
+            }
+            var HTLType = $("#HTLType").val();
+            sWhere = JSON.stringify(sWhere);
+            var ajaxLoad = layer.load();
+            $.ajax({
+                url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/JIT_TLYS',
+                type: "GET",
+                data: { "sWhere": sWhere, "user": sessionStorage["Czybm"], "HTLType": HTLType },
+                success: function (data1) {
+                    if (data1.count == 1) {
+                        get_FastQuery(2);
+                        layer.msg(data1.Message);
+                        layer.close(ajaxLoad);
+                    } else {
+                        layer.close(ajaxLoad);
+                        layer.alert(data1.code + data1.Message, { icon: 5 });
+                    }
+                }, error: function () {
+                    layer.close(ajaxLoad);
+                    layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                }
+            });
+        } 
+
         //鐢熶骇璁㈠崟閫夊崟
         function get_btnICMOBill() {
             layer.open({
@@ -918,6 +1145,624 @@
                 }
                 , btn2: function (index, layero) { }
             })
+        }
+
+        //鍑嗗
+        function get_btnReady() {
+            var data = table.cache["mainTable"];
+            var HICOMNum = [];
+            for (var i = 0; i < data.length; i++) {
+                HICOMNum.push(data[i]["HICMOInterID"] + ";" + data[i]["HICMOEntryID"]);
+            }
+            $('#HProgressBar').html(`
+    <div class="layui-progress" lay-filter="demo-filter-progress">
+      <div class="layui-progress-bar" lay-percent="40%"></div>
+    </div>
+  `);
+            // 娓叉煋杩涘害鏉$粍浠�
+            element.render('progress', 'demo-filter-progress');
+            $.ajax({
+                url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/ReadyData',
+                type: "GET",
+                data: { "HICOMNum": HICOMNum.toString() },
+                success: function (data1) {
+                    if (data1.count == 1) {
+                        for (var i = 0; i < data1.data.length; i++) {
+                            for (var j = 0; j < option.data.length; j++) {
+                                if (data1.data[i]["HICMOInterID"] == option.data[j]["HICMOInterID"] && data1.data[i]["HICMOEntryID"] == option.data[j]["HICMOEntryID"]) {
+                                    option.data[j]["灏忔椂浜ц兘"] = data1.data[i]["灏忔椂浜ц兘"];
+                                    option.data[j]["鐢熶骇鍛ㄦ湡"] = data1.data[i]["鐢熶骇鍛ㄦ湡"];
+                                    option.data[j]["寮�宸ヤ綑閲�"] = data1.data[i]["寮�宸ヤ綑閲�"];
+                                    option.data[j]["鏈�杩熷紑宸ユ棩鏈�"] = data1.data[i]["鏈�杩熷紑宸ユ棩鏈�"];
+                                    option.data[j]["鏈�杩熷畬宸ユ棩鏈�"] = data1.data[i]["鏈�杩熷畬宸ユ棩鏈�"];
+                                    option.data[j]["璁㈠崟闇�姹傛暟閲�"] = data1.data[i]["璁㈠崟闇�姹傛暟閲�"];
+                                    option.data[j]["璁㈠崟浜よ揣鏈�"] = data1.data[i]["璁㈠崟浜よ揣鏈�"] < "2020-01-01 0:00:00" ? "1900-01-01" : data1.data[i]["璁㈠崟浜よ揣鏈�"];
+                                    break;
+                                }
+                            }
+                        }
+
+                        for (var i = 0; i < option.data.length - 1; i++) {
+                            for (var j = 0; j < option.data.length - i - 1; j++) {
+                                var tables = [];
+                                //璁剧疆浠诲姟鍗曚紭鍏堟帓搴忥紝骞惰缃紭鍏�(鏈�杩熷畬宸ユ棩鏈�+璁㈠崟浜よ揣鏈�)  灏佽
+                                if (option.data[j]["鏈�杩熷畬宸ユ棩鏈�"] > option.data[j + 1]["鏈�杩熷畬宸ユ棩鏈�"]) {
+
+                                    tables.push(option.data[j + 1]);
+                                    option.data[j + 1] = option.data[j];
+                                    option.data[j] = tables[0];
+
+                                } else if (option.data[j]["鏈�杩熷畬宸ユ棩鏈�"] == option.data[j + 1]["鏈�杩熷畬宸ユ棩鏈�"]) {
+                                    if (option.data[j]["璁㈠崟浜よ揣鏈�"] > option.data[j + 1]["璁㈠崟浜よ揣鏈�"]) {
+
+                                        tables.push(option.data[j + 1]);
+                                        option.data[j + 1] = option.data[j];
+                                        option.data[j] = tables[0];
+
+                                    } else if (option.data[j]["璁㈠崟浜よ揣鏈�"] == option.data[j + 1]["璁㈠崟浜よ揣鏈�"]) {
+                                        if (option.data[j]["璁㈠崟闇�姹傛暟"] < option.data[j + 1]["璁㈠崟闇�姹傛暟"]) {
+
+                                            tables.push(option.data[j + 1]);
+                                            option.data[j + 1] = option.data[j];
+                                            option.data[j] = tables[0];
+
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        $('#HProgressBar').html('')
+
+                        table.render(option);
+                       
+                    } else {
+                        //layer.close(ajaxLoad);
+                        layer.alert(data1.code + data1.Message, { icon: 5 });
+                    }
+                }, error: function () {
+                    layer.close(ajaxLoad);
+                    layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                }
+            });
+        }
+
+
+        //鎺掍骇
+        function get_btnProPC(HWorkShopID) {
+
+            var JDTLen = 0;
+            var lMainID = 0;
+            var sICMOBillNo = "";
+            var dEndDate = "";
+            var sProdTimes = 0;
+            var sPlanQty = 0;
+            var lHGroupID = 0;
+            var sGroupName = "";
+            var lMaterID = 0;
+            var sMaterNumber = "";
+            var sMaterName = "";
+            var sMaterModel = "";
+            var sWorkQty = 0;
+            var sYX = 0;
+            var iLeftQty = 0;
+            var sLeftProdTimes = 0;
+            var lSourceID = 0;
+            var iRow = 0;
+            var sSourceName = "";
+            var sSourceNumber = "";
+            var ds = [];
+            var dsSub = [];
+            var bFind = false;
+            var HPlanDay = 0;
+            var HDelData = 0;
+            JDTLen = (100 / option.data.length).toFixed(2);
+            var HJDLen = 0;
+            var ajaxLoad = layer.load();
+           
+
+            //濡傛灉閿佸畾璁″垝锛屽垯涓嶉渶瑕佸啀鎺掔▼
+            //鏌ヨ鏈溅闂存槸鍚︽湁閿佸畾璁″垝鐨勬暟鎹�
+            var HinterID_S = [];
+            for (var i = 0; i < option.data.length; i++) {
+                HinterID_S.push(option.data[i]["hmainid"]);
+            }
+            $.ajax({
+                url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillHinterIDList',
+                type: "GET",
+                async: false,
+                data: { "sWhere": HinterID_S.toString(), "num": 1 },
+                success: function (data1) {
+                    if (data1.count == 1) {
+                        HPlanDay = data1.data[0].DayNum;
+
+                    } else {
+                        layer.alert(data1.code + data1.Message, { icon: 5 });
+                    }
+                }, error: function () {
+                    layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                }
+            });
+
+            //鏍规嵁杞﹂棿鍒犻櫎娌℃湁閿佸畾鐨勬暟鎹�
+            var sql = "delete from Sc_WorkBillSortBillSub  where  HMasterDate>=convert(varchar(10) ,DATEADD(DAY," + HPlanDay + ",GETDATE()),20)  and HInterID in(select  HInterID  from Sc_WorkBillSortBillMain where HWorkShopID=" + HWorkShopID + ")";
+            $.ajax({
+                url: GetWEBURL() +'/Gy_SOPBillList/UpDelSQL',
+                type: "GET",
+                async: false,
+                data: { "sWhere": sql },
+                success: function (data1) {
+                    if (data1.count == 1) {
+                        HDelData = 1;
+                    } else {
+                        layer.alert(data1.code + data1.Message, { icon: 5 });
+                    }
+                }, error: function () {
+                    layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                }
+            });
+
+            get_FastQuery(2);
+
+            if (HDelData == 1) {
+                //鎸変换鍔″崟浼樺厛绾� 寰幆
+                for (var i = 0; i < option.data.length; i++) {
+                    //鎵惧埌鏈换鍔″崟 鍙敤鐢熶骇璧勬簮
+                    lMainID = option.data[i]["HICMOInterID"];
+                    sICMOBillNo = option.data[i]["鐢熶骇璁㈠崟鍙�"];
+                    dEndDate = Format(option.data[i]["鏈�杩熷畬宸ユ棩鏈�"], 'yyyy/MM/dd');
+                    sProdTimes = option.data[i]["鐢熶骇鍛ㄦ湡"];
+                    sPlanQty = option.data[i]["璁″垝鏁伴噺"];
+                    lHGroupID = option.data[i]["HGroupID"];
+                    sGroupName = option.data[i]["HGroupName"];
+                    lMaterID = option.data[i]["HMaterID"];
+                    sMaterNumber = option.data[i]["鐗╂枡浠g爜"];
+                    sMaterName = option.data[i]["鐗╂枡鍚嶇О"];
+                    sMaterModel = option.data[i]["瑙勬牸鍨嬪彿"];
+                    sWorkQty = option.data[i]["灏忔椂浜ц兘"];
+                    sYX = option.data[i]["浼樺厛绾�"];
+                    //鍓╀綑闇�姹傚伐鏃�
+                    iLeftQty = sPlanQty;
+                    if (sWorkQty <= 0) {
+                        sLeftProdTimes = 0;
+                    }
+                    else {
+                        sLeftProdTimes = iLeftQty / sWorkQty;
+                    }
+                    //鑻ユ湰浠诲姟鍗曞凡鏈夊畨鎺掕祫婧愶紙涓婃鎺掔▼鎴栬�呮墜宸ユ帓绋嬶級 鍒欎笉鍐嶅鎵捐祫婧愶紝鐩存帴鎺掔▼
+                    if (option.data[i]["HSourceID"] != 0 && option.data[i]["鐢熶骇璧勬簮"] != "") {
+                        //鑾峰彇璇ョ敓浜ц祫婧愮殑鍓╀綑宸ユ椂杩涜鎺掔▼銆�
+                        lSourceID = option.data[i]["HSourceID"];
+                        sSourceName = option.data[i]["鐢熶骇璧勬簮"];
+                        sSourceNumber = option.data[i]["鐢熶骇璧勬簮浠g爜"];
+                        //鏌ヨ鐢熶骇璧勬簮鐨勫墿浣欏伐鏃惰繘琛屾帓绋嬨��
+                        var sql = "exec h_p_Sc_ICMOGetWorkSource2 " + lMaterID + ",'" + dEndDate + "'," + sProdTimes + "," + lSourceID;
+                        $.ajax({
+                            url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
+                            type: "GET",
+                            async: false,
+                            data: { "sWhere": sql },
+                            success: function (data1) {
+                                if (data1.count == 1) {
+                                    ds = data1.data
+                                } else {
+                                    layer.alert(data1.code + data1.Message, { icon: 5 });
+                                }
+                            }, error: function () {
+                                layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                            }
+                        });
+                    }
+                    else //娌℃湁璧勬簮鍒� 鑷姩鎵惧埌璧勬簮
+                    {
+                        //鏌ヨ鐢熶骇璧勬簮鐨勫墿浣欏伐鏃惰繘琛屾帓绋嬨��
+                        var sql = "exec h_p_Sc_ICMOGetWorkSource2 " + lMaterID + ",'" + dEndDate + "'," + sProdTimes;
+                        $.ajax({
+                            url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
+                            type: "GET",
+                            async: false,
+                            data: { "sWhere": sql },
+                            success: function (data1) {
+                                if (data1.count == 1) {
+                                    ds = data1.data
+                                } else {
+                                    layer.alert(data1.code + data1.Message, { icon: 5 });
+                                }
+                            }, error: function () {
+                                layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                            }
+                        });
+                    }
+                  
+                    if (ds == null || ds.length == 0) //娌℃湁鍙互鎺掔殑璧勬簮
+                    {
+                        //璺冲埌涓嬩竴鍗�  鏈崟绾㈣壊鏄剧ず
+                        $("tr[data-index='" + i + "']").attr({ "style": "background:red;color:black;" });
+                        continue;
+                    }
+                    else {
+                        $("tr[data-index='" + i + "']").attr({ "style": "background:White;color:black;" });
+                        //寮�濮嬫帓鍗� 
+                        bFind = false;
+                        //瓒呬氦璐ф湡  浠嶇劧鎺掔▼
+                        for (var j = 0; j < ds.length; j++) {
+                            //鍒ゆ柇璧勬簮鍓╀綑宸ユ椂锛屾槸鍚﹀ぇ浜� 鐢熶骇鍛ㄦ湡
+                            if (parseFloat(ds[j]["鍓╀綑宸ユ椂"]) > sLeftProdTimes) {
+                                if (iLeftQty > 0) // 鐢熶骇璁㈠崟鍓╀綑鏁伴噺
+                                {
+                                    //鍦ㄦ湰璧勬簮涓婄敓浜�
+                                    //鑾峰彇璇ョ敓浜ц祫婧愮殑鍓╀綑宸ユ椂杩涜鎺掔▼銆�
+                                    lSourceID = ds[j]["HitemID"];
+                                    sSourceName = ds[j]["璧勬簮鍚嶇О"];
+                                    sSourceNumber = ds[j]["璧勬簮浠g爜"];
+                                    option.data[i]["HSourceID"] = lSourceID;
+                                    option.data[i]["鐢熶骇璧勬簮"] = sSourceName;
+                                    option.data[i]["鐢熶骇璧勬簮浠g爜"] = sSourceNumber;
+
+                                    var sql = "exec h_p_Sc_ICMOGetWorkSourceTime " + lSourceID;
+                                    $.ajax({
+                                        url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
+                                        type: "GET",
+                                        async: false,
+                                        data: { "sWhere": sql },
+                                        success: function (data1) {
+                                            if (data1.count == 1) {
+                                                dsSub = data1.data
+                                            } else {
+                                                layer.alert(data1.code + data1.Message, { icon: 5 });
+                                            }
+                                        }, error: function () {
+                                            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                                        }
+                                    });
+
+                                    if (dsSub == null || dsSub.length == 0) {
+                                        continue;//濡傛灉娌℃湁鍓╀綑鍒� 鎵ц涓嬩竴涓敓浜ц鍗�
+                                    }
+                                    if (dsSub != null)//涓嶅姞鐝帓绋�
+                                    {
+                                        iRow = i + 1;
+                                        //灏嗘暟鎹帓鍒扮綉鏍间腑
+                                        //grdMain.RowCount = grdMain.RowCount + 1;  //  grdmain 鏂板涓�琛�
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOBillNoCol].Value = sICMOBillNo;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOInterIDCol].Value = lMainID;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecLeftQtyCol].Value = iLeftQty;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupIDCol].Value = lHGroupID;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupNameCol].Value = sGroupName;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterIDCol].Value = lMaterID;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNameCol].Value = sMaterName;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNumberCol].Value = sMaterNumber;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterModelCol].Value = sMaterModel;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanEndDateCol].Value = dEndDate;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanQtyCol].Value = sPlanQty;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceIDCol].Value = lSourceID;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNameCol].Value = sSourceName;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNumberCol].Value = sSourceNumber;
+                                        //grdMain.Rows[grdMain.RowCount - 1].Cells[HSecYXCol].Value = sYX;
+                                        //Sc_ICMOSortBillFun.SetInfoToGrid(grdMain, dsSub, null, grdMain.RowCount - 1, ref iLeftQty, sWorkQty, false, oClsGridValues);
+                                        SetInfoToGrid(option, dsSub, null, (iRow - 1), iLeftQty, sWorkQty, false, HPlanDay);
+                                    }
+                                    bFind = true;
+                                }
+                            }
+                        }
+                        if (!bFind) {
+                            for (var j = 0; j < ds.length; j++) {
+                                //鍒ゆ柇璧勬簮鏈�澶у墿浣欏伐鏃讹紝鏄惁澶т簬 鐢熶骇鍛ㄦ湡
+                                if (parseFloat(ds[j]["鏈�澶у墿浣欏伐鏃�"]) > sLeftProdTimes) {
+                                    if (iLeftQty > 0) {
+
+                                        //鍦ㄦ湰璧勬簮涓婄敓浜�
+                                        grdMain.RowCount = grdMain.RowCount + 1;
+                                        //鑾峰彇璇ョ敓浜ц祫婧愮殑鍓╀綑宸ユ椂杩涜鎺掔▼銆�
+                                        lSourceID = ds[j]["HitemID"];
+                                        sSourceName = ds[j]["璧勬簮鍚嶇О"];
+                                        sSourceNumber = ds[j]["璧勬簮浠g爜"];
+                                        option.data[i]["HSourceID"] = lSourceID;
+                                        option.data[i]["鐢熶骇璧勬簮"] = sSourceName;
+                                        option.data[i]["鐢熶骇璧勬簮浠g爜"] = sSourceNumber;
+
+                                        var sql = "exec h_p_Sc_ICMOGetWorkSourceTime " + lSourceID;
+                                        $.ajax({
+                                            url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
+                                            type: "GET",
+                                            async: false,
+                                            data: { "sWhere": sql },
+                                            success: function (data1) {
+                                                if (data1.count == 1) {
+                                                    dsSub = data1.data
+                                                } else {
+                                                    layer.alert(data1.code + data1.Message, { icon: 5 });
+                                                }
+                                            }, error: function () {
+                                                layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                                            }
+                                        });
+
+                                        if (dsSub == null || dsSub.length == 0) {
+                                            continue;
+                                        }
+                                        //if (dsSub != null)//鍔犵彮鎺掔▼
+                                        //{
+                                        //    //灏嗘暟鎹帓鍒扮綉鏍间腑
+                                        //    grdMain.RowCount = grdMain.RowCount + 1;  //  grdmain 鏂板涓�琛�
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOBillNoCol].Value = sICMOBillNo;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOInterIDCol].Value = lMainID;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecLeftQtyCol].Value = iLeftQty;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupIDCol].Value = lHGroupID;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupNameCol].Value = sGroupName;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterIDCol].Value = lMaterID;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNameCol].Value = sMaterName;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNumberCol].Value = sMaterNumber;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterModelCol].Value = sMaterModel;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanEndDateCol].Value = dEndDate;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanQtyCol].Value = sPlanQty;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceIDCol].Value = lSourceID;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNameCol].Value = sSourceName;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNumberCol].Value = sSourceNumber;
+                                        //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecYXCol].Value = sYX;
+                                        //    Sc_ICMOSortBillFun.SetInfoToGrid(grdMain, dsSub, null, grdMain.RowCount - 1, ref iLeftQty, sWorkQty, true, oClsGridValues);
+                                        //}
+                                    }
+                                    bFind = true;
+                                }
+                            }
+                        }
+                    
+                        if (!bFind) {
+                            //濡傛灉娌℃湁鎵惧埌鍚堥�傝祫婧愬垯锛岀洿鎺ユ帓鏈�鍚庝竴涓墿浣欐渶澶х殑璧勬簮銆�
+                            //鑾峰彇璇ョ敓浜ц祫婧愮殑鍓╀綑宸ユ椂杩涜鎺掔▼銆�
+                            lSourceID = ds[ds.length - 1]["HitemID"];
+                            sSourceName = ds[ds.length - 1]["璧勬簮鍚嶇О"];
+                            sSourceNumber = ds[ds.length - 1]["璧勬簮浠g爜"];
+                            option.data[i]["HSourceID"] = lSourceID;
+                            option.data[i]["鐢熶骇璧勬簮"] = sSourceName;
+                            option.data[i]["鐢熶骇璧勬簮浠g爜"] = sSourceNumber;
+
+                            //鑾峰彇璇ョ敓浜ц祫婧愮殑鍓╀綑宸ユ椂杩涜鎺掔▼銆�
+                            var sql = "exec h_p_Sc_ICMOGetWorkSourceTime " + lSourceID;
+                            $.ajax({
+                                url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
+                                type: "GET",
+                                async: false,
+                                data: { "sWhere": sql },
+                                success: function (data1) {
+                                    if (data1.count == 1) {
+                                        dsSub = data1.data
+                                    } else {
+                                        layer.alert(data1.code + data1.Message, { icon: 5 });
+                                    }
+                                }, error: function () {
+                                    layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                                }
+                            });
+
+                            if (dsSub == null || dsSub.length == 0) {
+                                continue;
+                            }
+                            //if (dsSub != null)//鍔犵彮鎺掔▼
+                            //{
+                            //    //灏嗘暟鎹帓鍒扮綉鏍间腑
+                            //    grdMain.RowCount = grdMain.RowCount + 1;  //  grdmain 鏂板涓�琛�
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOBillNoCol].Value = sICMOBillNo;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOInterIDCol].Value = lMainID;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecLeftQtyCol].Value = iLeftQty;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupIDCol].Value = lHGroupID;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupNameCol].Value = sGroupName;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterIDCol].Value = lMaterID;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNameCol].Value = sMaterName;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNumberCol].Value = sMaterNumber;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterModelCol].Value = sMaterModel;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanEndDateCol].Value = dEndDate;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanQtyCol].Value = sPlanQty;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceIDCol].Value = lSourceID;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNameCol].Value = sSourceName;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNumberCol].Value = sSourceNumber;
+                            //    grdMain.Rows[grdMain.RowCount - 1].Cells[HSecYXCol].Value = sYX;
+                            //    Sc_ICMOSortBillFun.SetInfoToGrid(grdMain, dsSub, null, grdMain.RowCount - 1, ref iLeftQty, sWorkQty, true, oClsGridValues);
+                            //}
+                        }
+                    }
+                }
+                table.render(option);
+               
+                set_AddNew();
+            } else {
+                layer.msg("鏁版嵁娓呯┖澶辫触!")
+            }
+            layer.close(ajaxLoad);
+        }
+
+        //灏嗘暟鎹帓绋嬪埌缃戞牸
+        function SetInfoToGrid(grd, ds, dsPre, iRow, sLeftQty, sWorkQty, bAddFlag, HPlanDay) {
+            var b = false;
+            var oSub;
+            //寰幆缃戞牸鍒�
+            if (bAddFlag) {
+                for (var i = 0; i < ds.length; i++) {
+                    //鎵惧埌瀵瑰簲鐨勫垪
+                    for (var j = 22; j < grd.cols[0].length; j++) {
+                        if (sLeftQty > 0) {
+                            if (ds[i]["鏃ユ湡"] == grd.cols[0][j].field) //琛ㄦ牸鐨勬爣棰樹笂 淇濆瓨浜嗘棩鏈燂紱
+                            {
+                                //濡傛灉鏃堕棿琚� 涓婇亾浣欓噺鍗犵敤 鍒� 璺宠繃
+                                b = false;
+                                //if (dsPre != null && dsPre.Tables[0].Rows.Count > 0) {
+                                //    for (var m = 0; m < dsPre.Tables[0].Rows.Count; m++)
+                                //    {
+                                //        if (ds[i]["鏃ユ湡"] < DBUtility.ClsPub.isDate(dsPre.Tables[0].Rows[m]["鏃ユ湡"])) {
+                                //            b = true;
+                                //        }
+                                //    }
+                                //}
+                                if (b == false) {
+                                    if (dsPre != null && ds[i]["鏃ユ湡"] == dsPre[0]["鏃ユ湡"]) {
+                                        ////HUseTimes 涓� 涓婇亾浣欓噺鍚� 鍓╀綑宸ユ椂銆�
+                                        //if (ds[i]["鏈�澶у墿浣欏伐鏃�"] > dsPre[0]["HUseTimes"]) {
+                                        //    if (parseFloat(sLeftQty) > parseFloat(sWorkQty * dsPre[0]["HUseTimes"])) {
+                                        //        grd.data[iRow][j] = parseFloat(sWorkQty * (dsPre[0]["HUseTimes"]));
+                                        //        sLeftQty = sLeftQty - parseFloat(sWorkQty * (dsPre[0]["HUseTimes"]));
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = DBUtility.ClsPub.isSingle(dsPre[0]["HUseTimes"]);
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //    else {
+                                        //        grd.data[iRow][j]= sLeftQty;
+                                        //        sLeftQty = 0;
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"]);
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //}
+                                        //else //鍗撳姏涓嶉渶瑕佽�冭檻鍔犵彮锛屼笅闈㈢殑杩欎竴娈典笉闇�瑕�
+                                        //{
+                                        //    if (sLeftQty > sWorkQty * ds[i]["鏈�澶у墿浣欏伐鏃�"]) {
+                                        //        grd.data[iRow][j]= parseFloat(sWorkQty * ds[i]["鏈�澶у墿浣欏伐鏃�"]);
+                                        //        sLeftQty = sLeftQty - (parseFloat(sWorkQty * ds[i]["鏈�澶у墿浣欏伐鏃�"]));
+                                        //        sLeftQty = 0;
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //    else {
+                                        //        grd.data[iRow][j]= sLeftQty;
+                                        //        sLeftQty = 0;
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //}
+                                    }
+                                    else {
+                                        if (sLeftQty > parseFloat(sWorkQty * ds[i]["鏈�澶у墿浣欏伐鏃�"])) {
+                                            grd.data[iRow][grd.cols[0][j + HPlanDay].field] = parseFloat(sWorkQty * ds[i]["鏈�澶у墿浣欏伐鏃�"]);
+                                            sLeftQty = sLeftQty - (parseFloat(sWorkQty * ds[i]["鏈�澶у墿浣欏伐鏃�"]));
+                                            //oSub = new ClsGridValues();
+                                            //oSub.iRow = iRow;
+                                            //oSub.iCol = j;
+                                            option.data[iRow]["HLeftTimes"] = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                            break;
+                                            //oSub.HLeftTimes = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                            //oClsGridValues.Add(oSub);
+                                        }
+                                        else {
+                                            grd.data[iRow][grd.cols[0][j + HPlanDay].field] = sLeftQty;
+                                            sLeftQty = 0;
+                                            //oSub = new ClsGridValues();
+                                            //oSub.iRow = iRow;
+                                            //oSub.iCol = j;
+                                            option.data[iRow]["HLeftTimes"] = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                            break;
+                                            //oSub.HLeftTimes = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                            //oClsGridValues.Add(oSub);
+
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+
+                }
+
+            }
+            else {
+                for (var i = 0; i < ds.length; i++) {
+                    //鎵惧埌瀵瑰簲鐨勫垪
+                    for (var j = 22; j < grd.cols[0].length; j++) {
+                        if (sLeftQty > 0) {
+                            if (ds[i]["鏃ユ湡"] == grd.cols[0][j].field) {
+                                //濡傛灉鏃堕棿琚� 涓婇亾浣欓噺鍗犵敤 鍒� 璺宠繃
+                                b = false;
+                                //if (dsPre != null && dsPre.Tables[0].Rows.Count > 0) {
+                                //    for (var m = 0; m < dsPre.Tables[0].Rows.Count; m++)
+                                //    {
+                                //        if (DBUtility.ClsPub.isDate(ds[i]["鏃ユ湡"]) < DBUtility.ClsPub.isDate(dsPre.Tables[0].Rows[m]["鏃ユ湡"])) {
+                                //            b = true;
+                                //        }
+                                //    }
+                                //}
+                                if (b == false) {
+                                    if (dsPre != null && s[i]["鏃ユ湡"] == dsPre[0]["鏃ユ湡"]) {
+                                        //if (ds[i]["鍓╀綑宸ユ椂"] > (DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"]))) {
+                                        //    if (sLeftQty > parseFloat(sWorkQty * (DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"])))) {
+                                        //        grd.data[iRow][j]= parseFloat(sWorkQty * (DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"])));
+                                        //        sLeftQty = sLeftQty - parseFloat(sWorkQty * (DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"])));
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"]);
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //    else {
+                                        //        grd.data[iRow][j]= sLeftQty;
+                                        //        sLeftQty = 0;
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = DBUtility.ClsPub.isSingle(dsPre.Tables[0].Rows[0]["HUseTimes"]);
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //}
+                                        //else {
+                                        //    if (sLeftQty > sWorkQty * ds[i]["鍓╀綑宸ユ椂"]) {
+                                        //        grd.data[iRow][j]= parseFloat(sWorkQty * ds[i]["鍓╀綑宸ユ椂"]);
+                                        //        sLeftQty = sLeftQty - (parseFloat(sWorkQty * ds[i]["鍓╀綑宸ユ椂"]));
+                                        //        sLeftQty = 0;
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = ds[i]["鍓╀綑宸ユ椂"];
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //    else {
+                                        //        grd.data[iRow][j]= sLeftQty;
+                                        //        sLeftQty = 0;
+                                        //        oSub = new ClsGridValues();
+                                        //        oSub.iRow = iRow;
+                                        //        oSub.iCol = j;
+                                        //        oSub.HLeftTimes = ds[i]["鍓╀綑宸ユ椂"];
+                                        //        oClsGridValues.Add(oSub);
+                                        //    }
+                                        //}
+                                    }
+                                    else {
+                                        if (sLeftQty > parseFloat(sWorkQty * ds[i]["鍓╀綑宸ユ椂"])) {
+                                            grd.data[iRow][grd.cols[0][j + HPlanDay].field] = parseFloat(sWorkQty * ds[i]["鍓╀綑宸ユ椂"]);
+                                            sLeftQty = sLeftQty - (parseFloat(sWorkQty * ds[i]["鍓╀綑宸ユ椂"]));
+                                            //oSub = new ClsGridValues();
+                                            //oSub.iRow = iRow;
+                                            //oSub.iCol = j;
+                                            option.data[iRow]["HLeftTimes"] = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                            break;
+                                            //oSub.HLeftTimes = ds[i]["鍓╀綑宸ユ椂"];
+                                            //oClsGridValues.Add(oSub);
+                                        }
+                                        else {
+                                            grd.data[iRow][grd.cols[0][j + HPlanDay].field] = sLeftQty;
+                                            sLeftQty = 0;
+                                            //oSub = new ClsGridValues();
+                                            //oSub.iRow = iRow;
+                                            //oSub.iCol = j;
+                                            option.data[iRow]["HLeftTimes"] = ds[i]["鏈�澶у墿浣欏伐鏃�"];
+                                            break;
+                                            //oSub.HLeftTimes = ds[i]["鍓╀綑宸ユ椂"];
+                                            //oClsGridValues.Add(oSub);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
         }
 
         //鏌ヨ鐢熶骇璁㈠崟
@@ -1024,8 +1869,60 @@
             }
         }
 
+        //涓婄Щ
+        function set_MoverUp(data) {
+            if (data.length != 1) {
+                layer.msg("璇烽�夋嫨涓�琛屾暟鎹紒");
+            } else if (option.data[0]["鐢熶骇璁㈠崟鍙�"] == data[0]["鐢熶骇璁㈠崟鍙�"]) {
+                layer.msg("棣栬鏁版嵁鏃犳硶绉诲姩锛�");
+            } else {
+                var tables = [];
+                for (var i = 0; i < option.data.length; i++) {
+                    if (option.data[i]["鐢熶骇璁㈠崟鍙�"] == data[0]["鐢熶骇璁㈠崟鍙�"]) {
+                        tables.push(option.data[i - 1]);
+                        data[0].LAY_CHECKED = true;
+                        option.data[i - 1] = data[0];
+                        option.data[i] = tables[0];
+                        table.render(option);
+                        break;
+                    }
+                }
+            }
+        }
+
+        //涓嬬Щ
+        function set_MoverDown(data) {
+            if (data.length != 1) {
+                layer.msg("璇烽�夋嫨涓�琛屾暟鎹紒");
+            } else if (option.data[option.data.length - 1]["鐢熶骇璁㈠崟鍙�"] == data[0]["鐢熶骇璁㈠崟鍙�"]) {
+                layer.msg("鏈鏁版嵁鏃犳硶绉诲姩锛�");
+            } else {
+                var tables = [];
+                for (var i = 0; i < option.data.length; i++) {
+                    if (option.data[i]["鐢熶骇璁㈠崟鍙�"] == data[0]["鐢熶骇璁㈠崟鍙�"]) {
+                        tables.push(option.data[i + 1]);
+                        data[0].LAY_CHECKED = true;
+                        option.data[i + 1] = data[0];
+                        option.data[i] = tables[0];
+                        table.render(option);
+                        break;
+                    }
+                }
+            }
+        }
+
+        //浼樺厛绾�
+        function set_Priority() {
+            var data = table.cache["mainTable"];
+            for (var i = 0; i < data.length; i++) {
+                data[i]["浼樺厛绾�"] = (i + 1);
+            }
+            option.data = data;
+            table.render(option);
+        }
+
         //淇濆瓨
-        function set_AddNew(data) {
+        function set_AddNew() {
 
             //鍒犻櫎瀛愯〃鏁版嵁 浼氬崰鐢ㄦ暟缁勭殑浣嶇疆,闇�瑕侀噸鏂版帓涓�涓嬮『搴�
             var num = [];
@@ -1100,6 +1997,12 @@
                                     , "鐢熶骇璧勬簮": checkStatus.data[0].鐢熶骇璧勬簮鍚嶇О
                                 })
                                 layer.close(index);//鍏抽棴寮圭獥
+                            }
+                            , end: function () {
+                                obj.update({
+                                    "HSourceID": OptionData.HItemID
+                                    , "鐢熶骇璧勬簮": OptionData.鐢熶骇璧勬簮鍚嶇О
+                                })
                             }
                         })
                     }
@@ -1229,9 +2132,9 @@
                             }
                             //璁剧疆鍐呭瀛椾綋澶у皬
                             if (data1.data[0].HFontSize != 0) {
-                                option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
+                                option.cols[0][i + 1]["style"] += ";font-size:" + data1.data[0].HFontSize + "px;";
                             } else {
-                                option.cols[0][i + 1]["style"] = "font-size:100%";
+                                option.cols[0][i + 1]["style"] += ";font-size:100%";
                             }
                             //璁剧疆鍒楀
                             //if (data1.data[0].HColumnWidth != 0) {
@@ -1285,7 +2188,24 @@
             })
         }
 
+        //鍒楁槑鏄剧ず涓嬫媺妗�
+        function ColFilter() {
+            var Organization = '<option  value="0" selected="selected" ></option>';
+            for (var i = 1; i < option.cols[0].length; i++) {
+                if (option.cols[0][i].hide != true) {
+                    Organization += '<option  style="color:blue;" value="' + option.cols[0][i].field + '">' + option.cols[0][i].field + '</option>';
+                }
+            }
+            $("#ColName").empty();
+            $("#ColName").append(Organization);
+            form.render('select');
+        }
         //#endregion
         //浠ヤ笂鏄痩ayui妯″潡
     });
+
+    //鍙屽嚮杩斿洖鐢熶骇璧勬簮
+    function GetGySource(data) {
+        OptionData = data
+    }
 </script>
\ No newline at end of file

--
Gitblit v1.9.1