From fe50d723e5d050113c4ecc493220e264f39d8e5f Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期三, 02 七月 2025 17:00:29 +0800
Subject: [PATCH] 1

---
 WebTM/views/生产管理/生产计划平台/Sc_BulkEditWorkTimeNew.html |  158 ++++++++++++++++++++++------------------------------
 1 files changed, 66 insertions(+), 92 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/Sc_BulkEditWorkTimeNew.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/Sc_BulkEditWorkTimeNew.html"
index b58ab76..dd576dd 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/Sc_BulkEditWorkTimeNew.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/Sc_BulkEditWorkTimeNew.html"
@@ -149,16 +149,6 @@
             set_SaveBill();
         })
 
-        // 鐩戝惉鏃ユ湡閫夋嫨
-        $('#HBeginDate').on('change', function () {
-            get_DisplayDate();
-            // 鍦ㄨ繖閲屽鐞嗘棩鏈熼�夋嫨鍚庣殑閫昏緫
-        });
-
-        $('#HEndDate').on('change', function () {
-            get_DisplayDate();
-            // 鍦ㄨ繖閲屽鐞嗘棩鏈熼�夋嫨鍚庣殑閫昏緫
-        });
 
         //#region 鏃ユ湡闂撮殧涓嬫媺鍒楄〃鐩戝惉
         form.on('select(HInitTimeCycle)', function (data) {
@@ -171,8 +161,6 @@
                 $("#HBeginDate").val(Format(new Date().setDate(new Date().getDate()), "yyyy-MM-dd"));//娆犳枡鏃ユ湡
                 $("#HEndDate").val(Format(new Date().setDate(new Date().getDate() + HInitTimeCycle), "yyyy-MM-dd"));//鑷�
 
-                //鎵ц鏌ヨ鏂规硶
-                get_DisplayDate();
             } else {
                 //$('#HDate').prop('disabled', false);
                 //$('#HDate1').prop('disabled', false);
@@ -205,7 +193,6 @@
             //鑾峰彇榛樿杞﹂棿
             GetDefValByUser();
             //鏌ヨ
-            get_DisplayDate();
             get_DisplaySource();
         }
         //#endregion
@@ -267,15 +254,24 @@
                 , limits: [50, 500, 1000, 5000]
                 //, loading: false               
                 , cols: [[
-                    { field: 'index', title: '搴忓彿', width: 80, sort: true },
-                    { field: 'date', title: '鏃ユ湡', width: 120 },
+                    { type: 'numbers', title: '搴忓彿', width: 80},
                     { field: 'week', title: '鏄熸湡', width: 120 },
                     { field: 'workHours', title: '涓婄彮鏃堕棿', width: 120, edit: 'text' }
                 ]]
+                , data: [
+                    { "week": "鏄熸湡鏃�", "workHours": 0 },
+                    { "week": "鏄熸湡涓�", "workHours": 0 },
+                    { "week": "鏄熸湡浜�", "workHours": 0 },
+                    { "week": "鏄熸湡涓�", "workHours": 0 },
+                    { "week": "鏄熸湡鍥�", "workHours": 0 },
+                    { "week": "鏄熸湡浜�", "workHours": 0 },
+                    { "week": "鏄熸湡鍏�", "workHours": 0 }
+                ]
                 , done: function (res, curr, count) {
                     soulTable.render(this);
                 }
             };
+            table.render(option);
             sourceOption = {
                 elem: '#SourceTable'
                 //, toolbar: '#toolbarDemo'
@@ -295,63 +291,6 @@
                 }
             };
         }
-        //#endregion
-
-        //#region 鏌ヨ
-        function get_DisplayDate() {
-            var HBeginDate = $('#HBeginDate').val();
-            var HEndDate = $('#HEndDate').val();
-
-            if (!HBeginDate || !HEndDate) {
-                layer.msg('璇烽�夋嫨寮�濮嬪拰缁撴潫鏃ユ湡');
-                return;
-            }
-            if (HBeginDate > HEndDate) {
-                return layer.msg("寮�濮嬫棩鏈熶笉鑳藉皬浜庣粨鏉熸棩鏈�!");
-            }
-            // 璁$畻鏃ユ湡宸苟鐢熸垚琛ㄦ牸鏁版嵁
-            var dateArray = getDateRange(HBeginDate, HEndDate);
-            var tableData = [];
-
-            for (var i = 0; i < dateArray.length; i++) {
-                tableData.push({
-                    index: i + 1,
-                    date: dateArray[i].date,
-                    week: dateArray[i].week,
-                    workHours: 0 // 榛樿涓婄彮鏃堕棿涓�0
-                });
-            }
-            option.data = tableData;
-            // 娓叉煋琛ㄦ牸
-            table.render(option)
-        }
-
-        function get_DisplaySource() {
-            var HDeptID = $("#HDeptID").val();
-            if (HDeptID != 0 && HDeptID != "") {
-                var sWhere = " and 绂佺敤鏍囪 != 'Y' and HDeptID=" + HDeptID
-                //杩涘叆椤甸潰鏄剧ず鐨勭紦瀛樺垪琛�
-                $.ajax({
-                    url: GetWEBURL() + '/Gy_Source/list',
-                    type: "GET",
-                    async: false,
-                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
-                    success: function (data1) {
-                        if (data1.count == 1) {
-                            sourceOption.data = data1.data;
-                            table.render(sourceOption);
-                        } else {
-                            layer.alert(data1.code + data1.Message, { icon: 5 });
-                        }
-                    }, error: function () {
-                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
-                    }
-
-                });
-            }
-            
-        }
-
         //#endregion
 
         //#region 鐢熶骇杞﹂棿閫夋嫨鎸夐挳
@@ -383,6 +322,34 @@
         }
         //#endregion
 
+        //#region 鑾峰彇瀵瑰簲杞﹂棿鐢熶骇璧勬簮
+        function get_DisplaySource() {
+            var HDeptID = $("#HDeptID").val();
+            if (HDeptID != 0 && HDeptID != "") {
+                var sWhere = " and 绂佺敤鏍囪 != 'Y' and HDeptID=" + HDeptID
+                //杩涘叆椤甸潰鏄剧ず鐨勭紦瀛樺垪琛�
+                $.ajax({
+                    url: GetWEBURL() + '/Gy_Source/list',
+                    type: "GET",
+                    async: false,
+                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
+                    success: function (data1) {
+                        if (data1.count == 1) {
+                            sourceOption.data = data1.data;
+                            table.render(sourceOption);
+                        } else {
+                            layer.alert(data1.code + data1.Message, { icon: 5 });
+                        }
+                    }, error: function () {
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                    }
+
+                });
+            }
+
+        }
+        //#endregion
+
         //#region 鍒濆鏃ユ湡闂撮殧 涓嬫媺鍒楄〃
         function setSelect_HInitTimeCycle() {
             var valueList = [7,30, 45, 60];
@@ -403,30 +370,32 @@
             //#endregion
 
         //#region 鏃堕棿鍒楄〃鐩稿叧鍑芥暟
-        function getDateRange(startDate, endDate) {
-            var dateArray = [];
-            var start = new Date(startDate.replace(/-/g, '/'));
-            var end = new Date(endDate.replace(/-/g, '/'));
+        function generateWorkHoursData(startDate, endDate, originalData) {
+            const result = [];
+            const currentDate = new Date(startDate);
+            const lastDate = new Date(endDate);
 
-            while (start <= end) {
-                
-                var dateStr = Format(start,"yyyy-MM-dd");
-                var weekStr = getWeekDay(start);
+            // 鍒涘缓涓�涓槦鏈熸槧灏勮〃锛堜腑鏂囨槦鏈熷悕 -> workHours锛�
+            const weekHoursMap = {};
+            originalData.forEach(item => {
+                weekHoursMap[item.week] = item.workHours;
+            });
 
-                dateArray.push({
-                    date: dateStr,
-                    week: weekStr
+            // 閬嶅巻鏃ユ湡鑼冨洿
+            while (currentDate <= lastDate) {
+                const dayOfWeek = currentDate.toLocaleDateString('zh-CN', { weekday: 'long' }); // 鑾峰彇涓枃鏄熸湡鍚嶏紝濡� "鏄熸湡涓�"
+                const formattedDate = currentDate.toISOString().split('T')[0]; // 鏍煎紡鍖栦负 YYYY-MM-DD
+
+                result.push({
+                    date: formattedDate,
+                    week: dayOfWeek,
+                    workHours: weekHoursMap[dayOfWeek] || 0, // 濡傛灉娌℃湁鍖归厤鐨勬槦鏈燂紝榛樿 0
                 });
 
-                start.setDate(start.getDate() + 1);
+                currentDate.setDate(currentDate.getDate() + 1); // 涓嬩竴澶�
             }
 
-            return dateArray;
-        }
-        // 鑾峰彇鏄熸湡鍑�
-        function getWeekDay(date) {
-            var weekDays = ['鏄熸湡鏃�', '鏄熸湡涓�', '鏄熸湡浜�', '鏄熸湡涓�', '鏄熸湡鍥�', '鏄熸湡浜�', '鏄熸湡鍏�'];
-            return weekDays[date.getDay()];
+            return result;
         }
         //#endregion
 
@@ -459,8 +428,13 @@
         function set_SaveBill() {
             var checkStatus = table.checkStatus('SourceTable')
                 , data = checkStatus.data;
-            var sSubStr = JSON.stringify(table.cache["mainTable"]);
-            var sMainSub = JSON.stringify(data) + ';' + sSubStr + ';' + sessionStorage["HUserName"];
+            var sSubStr = table.cache["mainTable"];
+            //鏍规嵁寮�濮嬫椂闂寸粨鏉熸棩鏈熺敓鎴愭柊鏁版嵁
+            const newData = generateWorkHoursData($("#HBeginDate").val(), $("#HEndDate").val(), sSubStr);
+            if (newData.length == 0) {
+                return layer.msg("璇锋鏌ュ紑濮嬫椂闂村拰缁撴潫鏃ユ湡鏄惁鍚堢悊");
+            }
+            var sMainSub = JSON.stringify(data) + ';' + JSON.stringify(newData) + ';' + sessionStorage["HUserName"];
             if (data.length > 0) {
                 $.ajax({   //寮傛璇锋眰
                     type: "POST",  //璇锋眰绫诲瀷

--
Gitblit v1.9.1