From 2b29d38bf7ee6355463e79fff1c6a90dd7f94c5b Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 12 八月 2025 10:35:39 +0800
Subject: [PATCH] Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev

---
 pages/index/tab1.vue     |   93 ++++++++++--------
 utils/getdateTime.js     |   93 ++++++++++++++++++
 pages/gongxuOut/form.vue |  100 +++++++++++++++++++
 3 files changed, 238 insertions(+), 48 deletions(-)

diff --git a/pages/gongxuOut/form.vue b/pages/gongxuOut/form.vue
index 368e7e9..b6812bc 100644
--- a/pages/gongxuOut/form.vue
+++ b/pages/gongxuOut/form.vue
@@ -99,7 +99,7 @@
                 <view class="form-item">
                     <view class="title">宸ユ椂:</view>
                     <view class="right">
-                        <input v-model="hform.HWorkTimes" placeholder="璇疯緭鍏ュ伐鏃�" />
+                        <input v-model="hform.HWorkTimes" placeholder="璇疯緭鍏ュ伐鏃�" @blur="HWorkTimesChange"/>
                     </view>
                 </view>
                 <view class="form-item">
@@ -111,6 +111,22 @@
                     </checkbox-group>
                 </view>
             </view>
+			<view class="form-item">
+				<view class="title">寮�宸ユ椂闂�:</view>
+				<view class="right">
+					 <uni-datetime-picker v-model="hform.HRelBeginTime" @change="HRelBeginTimeChange" v-if="hform.HIsTimeFlag==1" :hide-second="true">
+						 <input disabled v-model="hform.HRelBeginTime" placeholder="璇烽�夋嫨寮�宸ユ椂闂�"  style="pointer-events: none;"/>
+					 </uni-datetime-picker>
+				</view>
+			</view>
+			<view class="form-item">
+				<view class="title">瀹屽伐鏃堕棿:</view>
+				<view class="right">
+					 <uni-datetime-picker v-model="hform.HRelEndTime" @change="HRelEndTimeChange" v-if="hform.HIsTimeFlag==1" :hide-second="true">
+						 <input disabled v-model="hform.HRelEndTime" placeholder="璇烽�夋嫨瀹屽伐鏃堕棿" />
+					 </uni-datetime-picker>
+				</view>
+			</view>
             <!-- 
                 <view class="title">鏄惁璁℃椂</view>
                 <checkbox-group name="checkboxGroup" @change="onCGChangeHandler">
@@ -515,6 +531,8 @@
 					HProcNumber: '',
                     HNotReportQty: 0,
                     HIsTimeFlag: 0,
+					HRelBeginTime:'',
+					HRelEndTime:'',
                     // HPieceQty:'',
                     HWasterQty: 0,
                     HSourceName: '',
@@ -639,6 +657,10 @@
                 detail
             }) {
                 this.hform.HIsTimeFlag = detail.value[0] || 0
+				if(detail.value[0]){
+					this.getNewHRelBeginDate()
+					this.hform.HRelEndTime = getDateTime.dateTimeStr('y-m-d h:i');
+				}
             },
             //閫氳繃鐧诲綍鐢ㄦ埛鑾峰彇榛樿鍊�
             getDefValByUser() {
@@ -751,7 +773,20 @@
                 console.log(e.detail.value)
                 this.hform.HDate = e.detail.value
             },
-
+			HRelBeginTimeChange(e) {
+			    console.log(e)
+			    this.hform.HRelBeginTime = e
+				this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
+			},
+			HRelEndTimeChange(e) {
+			    console.log(e)
+			    this.hform.HRelEndTime = e
+				this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
+			},
+			HWorkTimesChange(e){
+				console.log(e);
+				this.hform.HRelEndTime = getDateTime.addHoursToDate(this.hform.HRelBeginTime,e.detail.value);
+			},
             //鑾峰彇浜у搧鏁版嵁
             getHMaterList() {
                 var Value = " Where HStopFlag=0  and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync('OrganizationID')
@@ -1389,7 +1424,62 @@
                     },
                 });
             },
-            //鏂板
+            
+			//鑾峰彇鏈�鏂扮殑鎶ュ伐鏃ユ湡
+			getNewHRelBeginDate(){
+				uni.request({
+				    url: this.serverUrl + '/Cj_StationOutBill/get_Display',
+					data:{ 
+						sWhere: ` and HEmpID = N'${this.hform.HEmpID}'`,
+						user: uni.getStorageSync('HUserName'),
+						HBillSubType:'',
+					},
+				    success: (res) => {
+						if(res.data.count == 1){
+							//鑾峰彇鍒楄〃鏁版嵁
+							const listData = res.data.data
+							// 鑾峰彇褰撳墠鏃ユ湡锛堝幓鎺夋椂闂撮儴鍒嗭級
+							const today = new Date();
+							today.setHours(0, 0, 0, 0);
+							if(listData.length==0){
+								this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i');
+								this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
+							}else{
+								// 浠庡璞℃暟缁勪腑鎻愬彇鎵�鏈夋棩鏈熷瓧娈靛苟鎵惧埌鏈�澶у��
+								const maxDate = listData.reduce((max, obj) => {
+									const date = new Date(obj[鍑虹珯鏃堕棿]);
+									return date > max ? date : max;
+								}, new Date(0)); // 鍒濆鍊间负鏈�灏忔棩鏈�
+								// 姣旇緝鏈�澶ф棩鏈熷拰浠婂ぉ鐨勬棩鏈熼儴鍒嗭紙涓嶆瘮杈冩椂闂达級
+								const maxDateDateOnly = new Date(maxDate);
+								maxDateDateOnly.setHours(0, 0, 0, 0);
+								  // 姣旇緝鏈�澶ф棩鏈熷拰浠婂ぉ
+								if (maxDateDateOnly.getTime() !== today.getTime()) {
+									// 濡傛灉涓嶆槸浠婂ぉ锛岃繑鍥炲綋鍓嶆棩鏈�
+									this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i');
+									this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
+								}else{
+									this.hform.HRelBeginTime = maxDate.replace(/(:\d{2})(:\d{2}\.\d{3})/, '$1');//浣跨敤姝e垯琛ㄨ揪寮忓幓闄ょ鍜屾绉�
+									this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
+								}
+							}
+						}else{
+							uni.showToast({
+								title:res.data.Message,
+								icon:'none'
+							})
+						}
+					},
+					fail: (res) => {
+						console.log(res);
+						uni.showToast({
+							title:'鎺ュ彛璇锋眰澶辫触',
+							icon:'none'
+						})
+					},
+				});
+			},
+			//鏂板
             getNewData() {
                 uni.request({
                     url: this.serverUrl + '/Web/GetMAXNum',
@@ -1644,7 +1734,9 @@
         margin: 20rpx auto;
         padding-bottom: 240rpx;
     }
-
+	picker input{
+		pointer-events: none;
+	}
     .tab_area {
         width: 100%;
         height: 50rpx;
diff --git a/pages/index/tab1.vue b/pages/index/tab1.vue
index bf4d913..5fbbe68 100644
--- a/pages/index/tab1.vue
+++ b/pages/index/tab1.vue
@@ -92,49 +92,56 @@
 						id: 8,
 						hidden: false,
 					}
-					// , {
-					// 	img: '../../static/icon/icon1.png',
-					// 	text: '璁惧妗f鏌ヨ',
-					// 	tip: '鏌ョ湅璇︽儏',
-					// 	url: '/pages/shebeidangan/table',
-					// 	id: 9,
-					// }, {
-					// 	img: '../../static/icon/icon8.png',
-					// 	text: '璁惧灞ュ巻鏌ヨ',
-					// 	tip: '鏌ョ湅璇︽儏',
-					// 	url: '/pages/shebeilvli/table',
-					// 	id: 10,
-					// }, {
-					// 	img: '../../static/icon/icon14.png',
-					// 	text: '鎴戠殑鎶ュ伐骞冲彴',
-					// 	tip: '鐐瑰嚮杩涘叆',
-					// 	url: '/pages/baogong/table',
-					// 	id: 11,
-					// }, {
-					// 	img: '../../static/icon/icon13.png',
-					// 	text: '涓婃ā鍗�',
-					// 	tip: '鏌ョ湅璇︽儏',
-					// 	url: '/pages/MJGL/shangmudan/table',
-					// 	id: 12,
-					// }, {
-					// 	img: '../../static/icon/icon13.png',
-					// 	text: '涓嬫ā鍗�',
-					// 	tip: '鏌ョ湅璇︽儏',
-					// 	url: '',
-					// 	id: 13,
-					// }, {
-					// 	img: '../../static/icon/icon32.png',
-					// 	text: '璁惧杩愯鐘舵��',
-					// 	tip: '鏌ョ湅璇︽儏',
-					// 	url: '/pages/shebeiyunxingzhuangtai/shebeiyunxingzhuangtai',
-					// 	id: 14,
-					// }, {
-					// 	img: '../../static/icon/icon6.png',
-					// 	text: '妯″叿鐘舵�佸垎鏋�',
-					// 	tip: '鏌ョ湅璇︽儏',
-					// 	url: '/pages/mujvzhuangtai/mujvzhuangtai',
-					// 	id: 15,
-					// },
+					, {
+						img: '../../static/icon/icon1.png',
+						text: '璁惧妗f鏌ヨ',
+						tip: '鏌ョ湅璇︽儏',
+						url: '/pages/shebeidangan/table',
+						id: 9,
+						hidden: true,
+					}, {
+						img: '../../static/icon/icon8.png',
+						text: '璁惧灞ュ巻鏌ヨ',
+						tip: '鏌ョ湅璇︽儏',
+						url: '/pages/shebeilvli/table',
+						id: 10,
+						hidden: true,
+					}, {
+						img: '../../static/icon/icon14.png',
+						text: '鎴戠殑鎶ュ伐骞冲彴',
+						tip: '鐐瑰嚮杩涘叆',
+						url: '/pages/baogong/table',
+						id: 11,
+						hidden: true,
+					}, {
+						img: '../../static/icon/icon13.png',
+						text: '涓婃ā鍗�',
+						tip: '鏌ョ湅璇︽儏',
+						url: '/pages/MJGL/shangmudan/table',
+						id: 12,
+						hidden: true,
+					}, {
+						img: '../../static/icon/icon13.png',
+						text: '涓嬫ā鍗�',
+						tip: '鏌ョ湅璇︽儏',
+						url: '',
+						id: 13,
+						hidden: true,
+					}, {
+						img: '../../static/icon/icon32.png',
+						text: '璁惧杩愯鐘舵��',
+						tip: '鏌ョ湅璇︽儏',
+						url: '/pages/shebeiyunxingzhuangtai/shebeiyunxingzhuangtai',
+						id: 14,
+						hidden: true,
+					}, {
+						img: '../../static/icon/icon6.png',
+						text: '妯″叿鐘舵�佸垎鏋�',
+						tip: '鏌ョ湅璇︽儏',
+						url: '/pages/mujvzhuangtai/mujvzhuangtai',
+						id: 15,
+						hidden: true,
+					},
 				]
 				// itemData: [{
 				// 	//  img:'../../static/icon0.png',
diff --git a/utils/getdateTime.js b/utils/getdateTime.js
index 4c960f4..1a1fba9 100644
--- a/utils/getdateTime.js
+++ b/utils/getdateTime.js
@@ -34,7 +34,98 @@
 	}
 	return str;
 }
- 
+/**
+ * @param {Object} hour 灏忔椂鐨勬暟鍊�
+ * @param {Object} min 鍒嗛挓鐨勬暟鍊笺��
+ * @param {Object} sec 绉掔殑鏁板�笺��
+ * @param {Object} millisec 姣鐨勬暟鍊笺��
+ * @param {Object} str 锛坹-m-d h:i:s) y:骞� m:鏈� d:鏃� h:鏃� i:鍒� s:绉�
+ */
+function dateTimeSetHoureStr(hour,min,sec,millisec,str){
+	var date = new Date();
+	date.setHours(hour,min,sec,millisec);
+	var year = date.getFullYear(), //骞�
+	month = date.getMonth() + 1, //鏈�
+	day = date.getDate(), //鏃�
+	hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(), //鏃�
+	minute = date.getMinutes() < 10 ? date.getMinutes() : date.getMinutes(), //鍒�
+	second = date.getSeconds() < 10 ? date.getSeconds() : date.getSeconds(); //绉�
+	month >= 1 && month <= 9 ? (month = "0" + month) : "";
+	day >= 0 && day <= 9 ? (day = "0" + day) : "";
+	hour >= 0 && hour <= 9 ? hour : "";
+	minute >= 0 && minute <= 9 ? (minute = "0" + minute) : "";
+	second >= 0 && second <= 9 ? (second = "0" + second) : "";
+	if(str.indexOf('y') != -1){
+		str = str.replace('y', year)
+	}
+	if(str.indexOf('m') != -1){
+		str = str.replace('m', month)
+	}
+	if(str.indexOf('d') != -1){
+		str = str.replace('d', day)
+	}
+	if(str.indexOf('h') != -1){
+		str = str.replace('h', hour)
+	}
+	if(str.indexOf('i') != -1){
+		str = str.replace('i', minute)
+	}
+	if(str.indexOf('s') != -1){
+		str = str.replace('s', second)
+	}
+	return str;
+}
+/** 璁$畻涓よ�呮椂闂村樊浠ュ皬鏃朵负鍗曚綅
+ * @param {Object} beginStr YYYY-MM-DD HH:MM
+ * @param {Object} endStr YYYY-MM-DD HH:MM
+ */
+function calculateHoursDiff(beginStr, endStr) {
+    // 瑙f瀽寮�濮嬫椂闂�
+    const parseDateTime = (dateTimeStr) => {
+        const [datePart, timePart] = dateTimeStr.split(' ');
+        const [yyyy, mm, dd] = datePart.split('-').map(Number);
+        const [hh, min] = timePart.split(':').map(Number);
+        return new Date(yyyy, mm - 1, dd, hh, min);
+    };
+
+    const beginTime = parseDateTime(beginStr);
+    const endTime = parseDateTime(endStr);
+
+    // 璁$畻姣宸紝骞惰浆鎹负灏忔椂锛堜繚鐣�2浣嶅皬鏁帮級
+    const diffMs = endTime - beginTime;
+    const diffHours = (diffMs / (1000 * 60 * 60)).toFixed(2);
+
+    return parseFloat(diffHours)>0?parseFloat(diffHours):0; // 杩斿洖鏁板瓧绫诲瀷锛屽 3.25
+}
+
+/**杩斿洖鏃堕棿鍔犱笂灏忔椂
+ * @param {Object} dateTimeStr YYYY-MM-DD HH:MM
+ * @param {Object} hoursToAdd 灏忔椂
+ */
+function addHoursToDate(dateTimeStr, hoursToAdd) {
+  // 瑙f瀽杈撳叆鏃ユ湡鏃堕棿
+  const [datePart, timePart] = dateTimeStr.split(' ');
+  const [yyyy, mm, dd] = datePart.split('-').map(Number);
+  const [hh, min] = timePart.split(':').map(Number);
+  
+  // 鍒涘缓Date瀵硅薄
+  const date = new Date(yyyy, mm - 1, dd, hh, min);
+  
+  // 娣诲姞鎸囧畾灏忔椂鏁帮紙鏀寔灏忔暟灏忔椂锛�
+  date.setTime(date.getTime() + hoursToAdd * 60 * 60 * 1000);
+  
+  // 鏍煎紡鍖栦负YYYY-MM-DD HH:MM
+  const newYYYY = String(date.getFullYear()).padStart(4, '0');
+  const newMM = String(date.getMonth() + 1).padStart(2, '0');
+  const newDD = String(date.getDate()).padStart(2, '0');
+  const newHH = String(date.getHours()).padStart(2, '0');
+  const newMin = String(date.getMinutes()).padStart(2, '0');
+  
+  return `${newYYYY}-${newMM}-${newDD} ${newHH}:${newMin}`;
+}
 module.exports = {
 	dateTimeStr: dateTimeStr,
+	dateTimeSetHoureStr:dateTimeSetHoureStr,
+	calculateHoursDiff:calculateHoursDiff,
+	addHoursToDate:addHoursToDate,
 }
\ No newline at end of file

--
Gitblit v1.9.1