Jelajahi Sumber

Merge branch 'master' of http://222.243.138.146:2000/ygtx/ygoa_miniapp

wangpx 11 bulan lalu
induk
melakukan
c87168ba1e

+ 1 - 1
config_hnyz.js

@@ -7,4 +7,4 @@ export default {
 	mapKey: 'CEBBZ-ASFKI-GZ2GU-UBGBO-MM6PZ-VTF3E',
 	timeout: 10000,
 	defaultAvatarPath:'/shares/document/miniApp/avatar/defaultAvatar.jpg',//默认服务器存储的头像路径
-}
+	clock: 'multiple', //single:单班打卡,multiple:双班打卡

+ 8 - 3
config_test.js

@@ -1,17 +1,22 @@
 export default {
-	baseUrl: 'http://127.0.0.1:8081/oa',
-	baseUrlPre: 'http://127.0.0.1:8081',
+	//baseUrl: 'http://127.0.0.1:8081/oa',
+	//baseUrlPre: 'http://127.0.0.1:8081',
+	baseUrl: 'http://127.0.0.1:8080/ynet',
+	baseUrlPre: 'http://127.0.0.1:8080',
 	// baseUrl: 'http://192.168.110.82:8081/oa',
 	// baseUrlPre:'http://192.168.110.82:8081',
 	// baseUrl: 'https://api.ygtxfj.com/ynet',
 	// baseUrlPre:'https://api.ygtxfj.com',
 	logoSrc: 'https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg-I3cuQYo6IXe9AQw9AM4Rg.png',
 	companyName:'宇光同行',
-	companyCode: 'yg',
+	//companyCode: 'yg',
+	companyCode: 'yz',
 	mapKey: 'KJBBZ-5JCLZ-3NLXD-742CK-Y26UZ-X7BJN',
 	// signInTimeRange:['08:30:00', '09:30:00'], //正常签到时间范围
 	// signOutTimeRange:['17:30:00', '20:00:00'], //正常签退时间
 	// lateTimeRange:['09:00:00', '09:30:00'], //迟到时间范围
 	timeout: 10000,
 	defaultAvatarPath:'/shares/document/miniApp/avatar/defaultAvatar.jpg',//默认服务器存储的头像路径
+	//clock: 'single', //单班打卡
+	clock: 'multiple', //双班打卡
 }

+ 1 - 0
config_ygtx.js

@@ -7,4 +7,5 @@ export default {
 	mapKey: 'KJBBZ-5JCLZ-3NLXD-742CK-Y26UZ-X7BJN',
 	timeout: 10000,
 	defaultAvatarPath:'/shares/document/miniApp/avatar/defaultAvatar.jpg',//默认服务器存储的头像路径
+	clock: 'single',//single:单班打卡,multiple:双班打卡
 }

+ 1 - 1
package.json

@@ -3,6 +3,6 @@
     "@turf/boolean-point-in-polygon": "^7.1.0",
     "clipboard": "^2.0.11",
     "dayjs": "^1.11.13",
-    "decimal.js": "^10.4.3"
+    "decimal.js": "^10.5.0"
   }
 }

+ 8 - 1
pages/login.vue

@@ -67,7 +67,14 @@ function loginSuccess() {
 		// 是否在上班打卡时间段
 		configStore.GetAttRule(userStore.user).then(() => {
 			console.log('GetAttRule');
-			if (isInTimeRange(...configStore.signInTimeRange)) {
+			let inTime = false;
+			if(config.clock && config.clock == 'multiple'){
+				inTime = isInTimeRange(...configStore.signInTimeRange[0]) || isInTimeRange(...configStore.signInTimeRange[1])
+			}else{
+				inTime = isInTimeRange(...configStore.signInTimeRange[0])
+			}
+			//if (isInTimeRange(...configStore.signInTimeRange)) {
+			if (inTime) {
 				const now = new Date()
 				const params = {
 					universalid: userStore.useId,

+ 81 - 7
pages/mine/checkIn/checkIn.vue

@@ -26,18 +26,40 @@
 				</view>
 				<view class="info-row">
 					<view>
-						<text class="ygoa_icon icon-day"></text>
-						<text class="value">晨签时间:</text>
+						<text class="ygoa-icon icon-day"></text>
+						<text class="value" v-if="!clockMultiple">晨签时间:</text>
+						<text class="value" v-if="clockMultiple">早上签到:</text>
 					</view>
 					<view>
 						<text class="label">{{ todayData.startTime || '未打卡' }}</text>
 						<text class="att_status">{{todayData.startStatus}}</text>
 					</view>
 				</view>
+				<view class="info-row" v-if="clockMultiple">
+					<view>
+						<text class="ygoa-icon icon-day"></text> 
+						<text class="value">早上签退:</text>
+					</view>
+					<view>
+						<text class="label">{{ todayData.endTimeAm || '未打卡' }}</text>
+						<text class="att_status">{{todayData.endStatusForAm}}</text>
+					</view>
+				</view>
+				<view class="info-row" v-if="clockMultiple">
+					<view>
+						<text class="ygoa-icon icon-night"></text> 
+						<text class="value">下午签到:</text>
+					</view>
+					<view>
+						<text class="label">{{ todayData.startTimePm || '未打卡' }}</text>
+						<text class="att_status">{{todayData.startStatusForPm}}</text>
+					</view>
+				</view>
 				<view class="info-row">
 					<view>
-						<text class="ygoa_icon icon-night"></text>
-						<text class="value">晚签时间:</text>
+						<text class="ygoa-icon icon-night"></text> 
+						<text class="value" v-if="!clockMultiple">晚签时间:</text>
+						<text class="value" v-if="clockMultiple">下午签退:</text>
 					</view>
 					<view>
 						<text class="label">{{ todayData.endTime || '未打卡' }}</text>
@@ -148,6 +170,7 @@
 	import {useUserStore} from '@/store/user.js';
 	import { useConfigStore } from '@/store/config'
 	import $tab from '@/plugins/tab.js'
+	import config from '@/config.js';
 	const userStore = useUserStore();
 	//考勤规则数据
 	const configStore = useConfigStore();
@@ -158,6 +181,10 @@
 		startStatus:'',//晨签状态
 		endTime: '', // 晚签到时间
 		endStatus:'',//晚签状态
+		endTimeAm: '',//早上下班签退时间
+		endStatusForAm:'',//早上下班签退状态
+		startTimePm: '', // 下午上班签到时间
+		startStatusForPm:'',//下午上班签到状态
 	})
 
 
@@ -210,6 +237,13 @@
 	const userId = userStore.user.useId; //拿到用户id
 	//当前周的周一日期
 	const thisMondayDate = ref('');
+	
+	const clockMultiple = ref(false)
+	if(config.clock && config.clock == 'multiple'){
+		clockMultiple.value = true;
+	}else{
+		clockMultiple.value = false;
+	}
 
 	onMounted(() => {
 		initAttData(); //初始化日考勤数据
@@ -246,8 +280,12 @@
 				//数据初始化
 				todayData.startTime = ''
 				todayData.endTime = ''
+				todayData.startTimePm = ''
+				todayData.endTimeAm = ''
 				todayData.startStatus=''
 				todayData.endStatus=''
+				todayData.startStatusForPm=''
+				todayData.endStatusForAm=''
 				if (res.returnParams.list.length == 0) {
 					return
 				}
@@ -255,6 +293,8 @@
 			
 				let time1;
 				let time2;
+				let time3;
+				let time4;
 				const filteredRecord1 = attList.filter(item => item.att_type_id === '1');
 				if (filteredRecord1.length > 0) {
 					time1 = filteredRecord1.reduce((latest, current) => {
@@ -264,6 +304,26 @@
 					});
 				}
 				
+				//上午下班,取最大时间的那个
+				const filteredRecord3 = attList.filter(item => item.att_type_id === '7');
+				if (filteredRecord3.length > 0) {
+					time3 = filteredRecord3.reduce((latest, current) => {
+						const latestTime = new Date(latest.att_time);
+						const currentTime = new Date(current.att_time);
+						return (currentTime > latestTime) ? current : latest;
+					});
+				}
+				
+				//下午上班,取最小时间
+				const filteredRecord4 = attList.filter(item => item.att_type_id === '8');
+				if (filteredRecord4.length > 0) {
+					time4 = filteredRecord4.reduce((latest, current) => {
+						const latestTime = new Date(latest.att_time);
+						const currentTime = new Date(current.att_time);
+						return (currentTime < latestTime) ? current : latest;
+					});
+				}
+				
 				//拿到所有签退数据后,取最大时间的那个
 				const filteredRecord2 = attList.filter(item => item.att_type_id === '2');
 				if (filteredRecord2.length > 0) {
@@ -276,13 +336,25 @@
 				
 				if (time1 !== undefined) {
 					todayData.startTime = time1.att_time.split(' ')[1];
-					if(subOneMinute(todayData.startTime)>=configStore.signInTimeRange[1]){
+					if(subOneMinute(todayData.startTime)>=configStore.signInTimeRange[0][1]){
 						todayData.startStatus='(迟到)'
 					}
 				}
+				if (time3 !== undefined) {
+					todayData.endTimeAm = time3.att_time.split(' ')[1];
+					if(todayData.endTimeAm<configStore.signOutTimeRange[0][0]){
+						todayData.endStatusForAm='(早退)'
+					}
+				}
+				if (time4 !== undefined) {
+					todayData.startTimePm = time4.att_time.split(' ')[1];
+					if(subOneMinute(todayData.startTimePm)>=configStore.signInTimeRange[1][1]){
+						todayData.startStatusForPm='(迟到)'
+					}
+				}
 				if (time2 !== undefined) {
 					todayData.endTime = time2.att_time.split(' ')[1];
-					if(todayData.endTime<configStore.signOutTimeRange[0]){
+					if(todayData.endTime<configStore.signOutTimeRange[1][0]){
 						todayData.endStatus='(早退)'
 					}
 				}
@@ -338,7 +410,9 @@
 	function changeDate(e) {
 		// console.log('changeDate: ',e);
 		// console.log("3:calenderData.value " + JSON.stringify(calenderData.value));
-		lackCardState.value = !!e.extraInfo.info;//!!转布尔值
+		if(config.companyCode && config.companyCode == 'yg'){
+			lackCardState.value = !!e.extraInfo.info;//!!转布尔值
+		} 
 		todayData.day = e.fulldate
 		getDayAttData()
 	}

+ 202 - 69
pages/mine/clockIn/clockIn.vue

@@ -114,8 +114,11 @@ function showNowTime() {
 	}, 1000); // 每1秒更新一次
 }
 
-const signInTime = ref(''); // 上班签到时间
-const signOutTime = ref(''); // 下班签到时间
+const signInTime = ref(''); // 上午上班签到时间
+const signOutTime = ref(''); // 下午下班签到时间
+const signOutTimeAm = ref(''); // 上午下班签到时间
+const signInTimePm= ref(''); // 下午上班签到时间
+
 //打卡按钮文字显示
 const signName = ref('')
 
@@ -136,6 +139,9 @@ function getTodayAtt() {
 			const attList = res.returnParams.list;
 			let time1;
 			let time2;
+			let time3;
+			let time4;
+			//上午上班
 			const filteredRecord1 = attList.filter(item => item.att_type_id === '1');
 			if (filteredRecord1.length > 0) {
 				time1 = filteredRecord1.reduce((latest, current) => {
@@ -145,7 +151,7 @@ function getTodayAtt() {
 				});
 			}
 
-			//拿到所有签退数据后,取最大时间的那个
+			//下午下班拿到所有签退数据后,取最大时间的那个
 			const filteredRecord2 = attList.filter(item => item.att_type_id === '2');
 			if (filteredRecord2.length > 0) {
 				time2 = filteredRecord2.reduce((latest, current) => {
@@ -154,12 +160,39 @@ function getTodayAtt() {
 					return (currentTime > latestTime) ? current : latest;
 				});
 			}
+			
+			//上午下班,取最大时间的那个
+			const filteredRecord3 = attList.filter(item => item.att_type_id === '7');
+			if (filteredRecord3.length > 0) {
+				time3 = filteredRecord3.reduce((latest, current) => {
+					const latestTime = new Date(latest.att_time);
+					const currentTime = new Date(current.att_time);
+					return (currentTime > latestTime) ? current : latest;
+				});
+			}
+			
+			//下午上班,取最小时间
+			const filteredRecord4 = attList.filter(item => item.att_type_id === '8');
+			if (filteredRecord4.length > 0) {
+				time4 = filteredRecord4.reduce((latest, current) => {
+					const latestTime = new Date(latest.att_time);
+					const currentTime = new Date(current.att_time);
+					return (currentTime < latestTime) ? current : latest;
+				});
+			}
+			
 			//打卡状态修改
 			//打了上班卡
+			let checkContinue = false;
 			if (time1 !== undefined) {
 				// console.log('getTime1',time1);
 				signInTime.value = time1.att_time.split(' ')[1];
-				selectedTypeRange.value='下班'
+				if(config.clock && config.clock == 'multiple'){
+					selectedTypeRange.value='上午下班'
+				}else{
+					selectedTypeRange.value='下班'
+				}
+				checkContinue = true;
 				// signName.value = '下班签退';
 				// if (isTimeInRange(subOneMinute(signInTime.value), ...configStore.lateTimeRange)) {//迟到
 				// 	signInStatusName.value = '迟到';
@@ -173,9 +206,32 @@ function getTodayAtt() {
 			// 	signName.value = '下班签退'
 			// } 
 			else {
-				// signName.value = '上班签到';
-				selectedTypeRange.value='上班'
+				// signName.value = '上班签到'; 
+				if(config.clock && config.clock == 'multiple'){
+					selectedTypeRange.value='上午上班'
+				}else{
+					selectedTypeRange.value='上班'
+				}
+				checkContinue = false;
 			}
+			//上午下班卡
+			if (time3 !== undefined) {
+				signOutTimeAm.value = time3.att_time.split(' ')[1]; 
+				if(checkContinue){
+					selectedTypeRange.value='下午上班' 
+				} 
+			}else{
+				checkContinue = false;
+			} 
+			//下午上班卡
+			if (time4 !== undefined) {
+				signInTimePm.value = time4.att_time.split(' ')[1];
+				 if(checkContinue){
+					 selectedTypeRange.value='下午下班' 
+				 } 
+			}else{
+				checkContinue = false;
+			}   
 			//打了下班卡
 			if (time2 !== undefined) {
 				signOutTime.value = time2.att_time.split(' ')[1];
@@ -191,11 +247,18 @@ function getTodayAtt() {
 				// 	isSignOutStatusDisabled.value = true; //隐藏早退状态
 				// }
 			}
+			
+			
 		}
 	})
 }
 
-const typeRanges=ref(['上班','下班','外出','外出返回'])
+let typeRanges;
+if(config.clock && config.clock == 'multiple'){
+	typeRanges=ref(['上午上班','上午下班','下午上班','下午下班','外出','外出返回'])
+}else{
+	typeRanges=ref(['上班','下班','外出','外出返回'])
+}
 const selectedTypeRange=ref('上班')
 //打卡类型切换
 function onTypeRangeChange(event){
@@ -211,17 +274,38 @@ function signInOrOut() {
 	// } else {
 	// 	signOut();
 	// }
-	switch(selectedTypeRange.value){
-		case '上班':
-			signIn()
-			break
-		case '下班':
-			signOut()
-			break
-		case '外出':
-		case '外出返回':
-			otherTypeClockIn()
-			break		
+	if(config.clock && config.clock == 'multiple'){
+		switch(selectedTypeRange.value){
+			case '上午上班':
+				signInForMultiple('上午上班')
+				break
+			case '下午下班':
+				signOutForMultiple('下午下班')
+				break
+			case '外出':
+			case '外出返回':
+				otherTypeClockIn()
+				break
+			case '下午上班':
+				signInForMultiple('下午上班')
+				break
+			case '上午下班':
+				signOutForMultiple('上午下班')
+				break
+		}
+	}else{
+		switch(selectedTypeRange.value){
+			case '上班':
+				signIn()
+				break
+			case '下班':
+				signOut()
+				break
+			case '外出':
+			case '外出返回':
+				otherTypeClockIn()
+				break		
+		}
 	}
 }
 
@@ -243,12 +327,50 @@ function signIn() {
 	});
 };
 
+function signInForMultiple(selectTypeName) { 
+	let signIn = 1;
+	if(selectTypeName == '上午上班'){
+		signIn = 1
+	}else if(selectTypeName == '下午上班'){
+		signIn = 8
+	}
+	getAddress().then(() => {
+		clockIn(signIn);
+	});
+};
+
 // 下班签退
 function signOut() {
 	const now = getNowTime();
-	const signOut = 2;
+	const signOut = 2; 
+	//判断打卡时间是否符合
+	const currentRangeIndex = 1; 
+	if (!isTimeInRange(now, ...configStore.signOutTimeRange[currentRangeIndex])) {
+		$modal.confirm('当前非正常签退时间,是否继续?').then(res => {
+			if (res) {
+				getAddress().then(() => {
+					clockIn(signOut); // 执行打卡并获取结果
+				});
+			}
+		}).catch(() => { })
+	} else {
+		getAddress().then(() => {
+			clockIn(signOut);
+		});
+	}
+};
+
+function signOutForMultiple(selectTypeName) {
+	const now = getNowTime();
+	let signOut = 2;
+	if(selectTypeName == '上午下班'){
+		signOut = 7
+	}else if(selectTypeName == '下午下班'){
+		signOut = 2
+	}
 	//判断打卡时间是否符合
-	if (!isTimeInRange(now, ...configStore.signOutTimeRange)) {
+	const currentRangeIndex = signOut === 7 ? 0 : 1; 
+	if (!isTimeInRange(now, ...configStore.signOutTimeRange[currentRangeIndex])) {
 		$modal.confirm('当前非正常签退时间,是否继续?').then(res => {
 			if (res) {
 				getAddress().then(() => {
@@ -363,6 +485,9 @@ function getlocation() {
 // 封装获取位置的函数
 function fetchLocation(resolve, reject) {
 	wx.getLocation({
+		type: 'gcj02',
+		isHighAccuracy: true, // 开启高精度定位 
+		highAccuracyExpireTime: 4000, // 高精度定位超时时间 
 		success: (res) => {
 			longitude.value = res.longitude; // 保存经度
 			latitude.value = res.latitude; // 保存纬度	
@@ -458,7 +583,7 @@ function clockIn(attType) {
 	};
 	createAttendance(params).then(res => {
 		if ("success" == res.returnMsg) {
-			if(1==attType || 2==attType){
+			if(1==attType || 2==attType || 7==attType || 8==attType){
 				getTodayAtt(); //更新今日考勤数据
 			}	
 			isToFillClock(attType, localString.substring(11, 19));//判断考勤状态是否异常
@@ -481,61 +606,69 @@ function clockIn(attType) {
 }
 
 //是否补卡、请假判断
-function isToFillClock(attType, time) {
-	// console.log('isToFillClock',attType,time);
-	//早上迟到跳补卡
-	let status = '';
-	if (attType == 1) {
-		if (isTimeInRange(subOneMinute(time), ...configStore.lateTimeRange)) {
-			status = '迟到'
-		} else if (isTimeInRange(time, configStore.lateTimeRange[1], '23:59:59')) {
-			status = '旷工'
-		} else {
-			$modal.msgSuccess('打卡成功')
-			setTimeout(() => {
-				$tab.navigateTo('/pages/mine/checkIn/checkIn')
-			}, 1000)
-			return
+function isToFillClock(attType, time) { 
+    // console.log('isToFillClock',attType,time);  
+    // 早上迟到跳补卡 
+    let status = ''; 
+    if (attType === 1 || attType === 8) {  
+        const currentRangeIndex = attType === 1 ? 0 : 1; 
+        if (isTimeInRange(subOneMinute(time), ...configStore.lateTimeRange[currentRangeIndex]))  { 
+            status = '迟到'; 
+        } else if (isTimeInRange(time, configStore.lateTimeRange[currentRangeIndex][1],  '23:59:59')) { 
+            status = '旷工'; 
+        } else { 
+            $modal.msgSuccess(' 打卡成功'); 
+            setTimeout(() => { 
+                $tab.navigateTo('/pages/mine/checkIn/checkIn');  
+            }, 1000); 
+            return; 
+        } 
+		if(config.companyCode && config.companyCode == 'yg'){
+			$modal.confirm(' 当前状态为' + status + '!\n是否跳转补卡页面').then(() => {
+				 $tab.reLaunch('/pages/work/index');  
+			 }) 
+			 .catch(() => { 
+				 $tab.navigateTo('/pages/mine/checkIn/checkIn');  
+			 });
+		}else{
+			$tab.navigateTo('/pages/mine/checkIn/checkIn');  
 		}
-		$modal.confirm('当前状态为' + status + '!\n是否跳转补卡页面').then(() => {
-			$tab.reLaunch('/pages/work/index')
-		})
-			.catch(() => {
-				$tab.navigateTo('/pages/mine/checkIn/checkIn')
-			})
-	} else if (attType == 2) {
-		//早退请假提示
-		if (isTimeInRange(time, '00:00:00', configStore.earlyTimeRange[0])) {
-			status = '旷工'
-		} else if (isTimeInRange(time, ...configStore.earlyTimeRange)) {
-			status = '早退'
-		} else {
-			$modal.msgSuccess('打卡成功')
-			setTimeout(() => {
-				$tab.navigateTo('/pages/mine/checkIn/checkIn')
-			}, 1000)
-			return
-		}
-		$modal.confirm('当前状态为' + status + '!\n是否跳转请假页面').then(() => {
-			$tab.reLaunch('/pages/work/index')
-		})
-			.catch(() => {
-				$tab.navigateTo('/pages/mine/checkIn/checkIn')
-			})
-	}else{
-		$modal.msgSuccess('打卡成功')
-		setTimeout(() => {
-			$tab.navigateBack()
-		}, 1000)
-	}
-
-}
+    } else if (attType === 2 || attType === 7) { 
+        const currentRangeIndex = attType === 7 ? 0 : 1; 
+        // 早退请假提示 
+        if (isTimeInRange(time, '00:00:00', configStore.earlyTimeRange[currentRangeIndex][0]))  { 
+            status = '旷工'; 
+        } else if (isTimeInRange(time, ...configStore.earlyTimeRange[currentRangeIndex]))  { 
+            status = '早退'; 
+        } else { 
+            $modal.msgSuccess(' 打卡成功'); 
+            setTimeout(() => { 
+                $tab.navigateTo('/pages/mine/checkIn/checkIn');  
+            }, 1000); 
+            return; 
+        } 
+        $modal.confirm(' 当前状态为' + status + '!\n是否跳转请假页面').then(() => { 
+            $tab.reLaunch('/pages/work/index');  
+        }) 
+        .catch(() => { 
+            $tab.navigateTo('/pages/mine/checkIn/checkIn');  
+        }); 
+    } else { 
+        $modal.msgSuccess(' 打卡成功'); 
+        setTimeout(() => { 
+            $tab.navigateBack();  
+        }, 1000); 
+    } 
+} 
 
 //判断是否已经打过上班卡
 function isClockIn(attType) {
 	if (1==attType && '' != signInTime.value) {
 		$modal.showToast('请勿重复打卡')
 		return true;
+	}else if (8==attType && '' != signInTimePm.value) {
+		$modal.showToast('请勿重复打卡')
+		return true;
 	}
 	return false;
 }

+ 2 - 2
pages/work/edit/index.vue

@@ -272,8 +272,8 @@ function initProcessForm() {
 //单选框(补卡类型)
 function changeDataSingleCheckBox(e, elem) {
 	// console.log('单选框切换事件',e.detail.value);
-	const workStartTime = configStore.signInTimeRange?.[1] || "09:00:00"
-	const workEndTime = configStore.signOutTimeRange?.[0] || "17:30:00"
+	const workStartTime = configStore.signInTimeRange[0]?.[1] || "09:00:00"
+	const workEndTime = configStore.signOutTimeRange[1]?.[0] || "17:30:00"
 	// console.log(workStartTime)
 	if (BUKA_MODELID.value == processInfo.modelId && '' != formElements.value[0].defaultValue) {
 		if ('上班' == e.detail.value) {

+ 26 - 17
pages/work/index.vue

@@ -33,24 +33,25 @@
 				</uni-grid-item>
 			</uni-grid>
 		</view>
-		<uni-section title="日报周报" titleFontSize="1.3rem" type="line"></uni-section>
-		<view class="grid-body">
-			<uni-grid :column="uni_grid_column" :showBorder="false" @change="changeDiaryGrid">
-				<uni-grid-item :index="1">
-					<view class="grid-item-box">
-						<text class="ygoa_icon icon-diary"></text>
-						<text class="text">日报</text>
-					</view>
-				</uni-grid-item>
-				<!-- <uni-grid-item :index="2">
-					<view class="grid-item-box">
-						<text class="ygoa_icon icon-diary"></text>
-						<text class="text">日报</text>
-					</view>
-				</uni-grid-item> -->
-			</uni-grid>
+		<view v-if="diaryShow">
+			<uni-section title="日报周报" titleFontSize="1.3rem" type="line"></uni-section>
+			<view class="grid-body">
+				<uni-grid :column="uni_grid_column" :showBorder="false" @change="changeDiaryGrid">
+					<uni-grid-item :index="1">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-diary"></text>
+							<text class="text">日报</text>
+						</view>
+					</uni-grid-item>
+					<!-- <uni-grid-item :index="2">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-diary"></text>
+							<text class="text">日报</text>
+						</view>
+					</uni-grid-item> -->
+				</uni-grid>
+			</view>
 		</view>
-
 		<uni-section title="系统工具" titleFontSize="1.3rem" type="line"></uni-section>
 		<view class="grid-body">
 			<uni-grid :column="uni_grid_column" :showBorder="false" @change="changeToolsGrid">
@@ -89,11 +90,19 @@ import { useUserStore } from '@/store/user.js'
 import { getProcessList } from '@/api/work.js'
 import { clearCache } from '@/utils/ygoa.js'
 import { onShow } from '@dcloudio/uni-app'
+import config from '@/config.js';
 const userStore = useUserStore()
 
 let sysFontSize = 0
 const uni_grid_column = ref(4)
 
+const diaryShow = ref(false)
+if(config.companyCode && config.companyCode == 'yg'){
+	diaryShow.value = true;
+}else{
+	diaryShow.value = false;
+}
+
 onMounted(() => {
 	sysFontSize = uni.getAppBaseInfo().fontSizeSetting
 	if (sysFontSize > 20) uni_grid_column.value = 3

+ 128 - 93
store/config.js

@@ -1,93 +1,128 @@
-import { defineStore } from 'pinia'
-import { getAttendanceRule, getAttendanceSegment } from '@/api/mine.js'
-import { ref } from 'vue'
-
-export const useConfigStore = defineStore('config', () => {
-	const signInTimeRange = ref([]);//正常签到时间
-	const signOutTimeRange = ref([]);//正常签退时间
-	const lateTimeRange = ref([]);//迟到时间
-	const earlyTimeRange = ref([]);//早退时间
-	
-	function GetAttRule(user) {
-		const fillZero = (timeStr) => timeStr + ':00'
-		return new Promise((resolve, reject) => {
-			try {
-				getAttendanceSegment(user.unitId).then(res => {
-					console.log('getAttendanceSegment', res);
-					const result = res.returnParams.find(item => item.segment_status == "1");
-					const { startTime, endTime } = getStartAndEndTime(result.work_time);
-					getAttendanceRule(user.unitId).then(res => {
-						// 找到正在用的考勤规则
-						const attRule = res.returnParams.Rows.find(item => item.rule_status == "1");
-						signInTimeRange.value = [addMinutesToTime(startTime, -attRule.on_advance_num), fillZero(startTime)];
-						signOutTimeRange.value = [fillZero(endTime), addMinutesToTime(endTime, attRule.off_delay_num)];
-						lateTimeRange.value = [fillZero(startTime), addMinutesToTime(startTime, attRule.late_num)];
-						earlyTimeRange.value = [addMinutesToTime(endTime, -attRule.eary_num), fillZero(endTime)];
-						resolve(); // 确保执行完成后调用 resolve
-					}).catch(err => {
-						console.log('获取考勤规则时发生错误', err);
-						reject('getAttendanceRuleErr');
-					});
-				}).catch(err => {
-					console.log('获取考勤时间段时发生错误', err);
-					reject('getAttendanceSegmentErr');
-				});
-			} catch (err) {
-				console.error('处理考勤数据时发生错误', err);
-				reject(err);
-			}
-		});
-		
-		
-	}
-	
-	//获取当天的上班时间和下班时间
-	function getStartAndEndTime(timeString) {
-		//去除最后一个分号
-		timeString = timeString.trim().replace(/;$/, '');
-		const periods = timeString.split(';');
-		let startTime = null;
-		let endTime = null;
-		// 遍历每个时间段
-		for (let period of periods) {
-			if (period) { // 确保不是空字符串
-				const [start, end] = period.split(',').map(time => time.trim());
-				if (!startTime || start < startTime) {
-					startTime = start;
-				}
-				if (!endTime || end > endTime) {
-					endTime = end;
-				}
-			}
-		}
-		return { startTime, endTime };
-	}
-	
-	//处理时间运算
-	function addMinutesToTime(timeStr, minutesToAdd) {
-		const [hours, minutes] = timeStr.split(':').map(Number);
-		let date = new Date();
-		date.setHours(hours);
-		date.setMinutes(minutes);
-		// 添加分钟数
-		date.setMinutes(date.getMinutes() + minutesToAdd);
-		// 获取新的小时和分钟值,确保它们是两位数格式
-		const newHours = String(date.getHours()).padStart(2, '0');
-		const newMinutes = String(date.getMinutes()).padStart(2, '0');
-		// 返回格式化后的新时间字符串
-		return `${newHours}:${newMinutes}:00`;
-	}
-	
-	//补零方法(09:00=>09:00:00)
-	
-	
-
-
-	return {
-		signInTimeRange,
-		signOutTimeRange,
-		lateTimeRange,
-		earlyTimeRange,
-		GetAttRule
-	}
-})
+import { defineStore } from 'pinia' 
+import { getAttendanceRule, getAttendanceSegment } from '@/api/mine.js'  
+import { ref } from 'vue' 
+ 
+export const useConfigStore = defineStore('config', () => { 
+    // 正常签到时间,分别为上午和下午 
+    const signInTimeRange = ref([[], []]); 
+    // 正常签退时间,分别为上午和下午 
+    const signOutTimeRange = ref([[], []]); 
+    // 迟到时间,分别为上午和下午 
+    const lateTimeRange = ref([[], []]); 
+    // 早退时间,分别为上午和下午 
+    const earlyTimeRange = ref([[], []]); 
+ 
+    function GetAttRule(user) { 
+        const fillZero = (timeStr) => timeStr + ':00'; 
+        return new Promise((resolve, reject) => { 
+            try { 
+                getAttendanceSegment(user.unitId).then(res  => { 
+                    console.log('getAttendanceSegment',  res); 
+                    const result = res.returnParams.find(item  => item.segment_status  == "1"); 
+                    const { startTimeAm, endTimeAm, startTimePm, endTimePm } = getStartAndEndTime(result.work_time);  
+                    getAttendanceRule(user.unitId).then(res  => { 
+                        // 找到正在用的考勤规则 
+                        const attRule = res.returnParams.Rows.find(item  => item.rule_status  == "1"); 
+                        // 上午签到时间范围 
+                        signInTimeRange.value[0]  = [addMinutesToTime(startTimeAm, -attRule.on_advance_num),  fillZero(startTimeAm)]; 
+                        // 上午签退时间范围 
+                        signOutTimeRange.value[0]  = [fillZero(endTimeAm), addMinutesToTime(endTimeAm, attRule.off_delay_num)];  
+                        // 上午迟到时间范围 
+                        lateTimeRange.value[0]  = [fillZero(startTimeAm), addMinutesToTime(startTimeAm, attRule.late_num)];  
+                        // 上午早退时间范围 
+                        earlyTimeRange.value[0]  = [addMinutesToTime(endTimeAm, -attRule.eary_num),  fillZero(endTimeAm)]; 
+ 
+						if(startTimePm){
+							// 下午签到时间范围
+							signInTimeRange.value[1]  = [addMinutesToTime(startTimePm, -attRule.on_advance_num),  fillZero(startTimePm)]; 
+							// 下午签退时间范围 
+							signOutTimeRange.value[1]  = [fillZero(endTimePm), addMinutesToTime(endTimePm, attRule.off_delay_num)];  
+							// 下午迟到时间范围 
+							lateTimeRange.value[1]  = [fillZero(startTimePm), addMinutesToTime(startTimePm, attRule.late_num)];  
+							// 下午早退时间范围 
+							earlyTimeRange.value[1]  = [addMinutesToTime(endTimePm, -attRule.eary_num),  fillZero(endTimePm)]; 
+						}else{
+							//防止考勤设置时,没有分段设置考勤导致的异常
+							// 下午签到时间范围
+							signInTimeRange.value[1]  = [addMinutesToTime(startTimeAm, -attRule.on_advance_num),  fillZero(startTimeAm)];
+							// 下午签退时间范围 
+							signOutTimeRange.value[1]  = [fillZero(endTimeAm), addMinutesToTime(endTimeAm, attRule.off_delay_num)];  
+							// 下午迟到时间范围 
+							lateTimeRange.value[1]  = [fillZero(startTimeAm), addMinutesToTime(startTimeAm, attRule.late_num)];  
+							// 下午早退时间范围 
+							earlyTimeRange.value[1]  = [addMinutesToTime(endTimeAm, -attRule.eary_num),  fillZero(endTimeAm)]; 
+						} 
+                        resolve(); // 确保执行完成后调用 resolve 
+                    }).catch(err => { 
+                        console.log(' 获取考勤规则时发生错误', err); 
+                        reject('getAttendanceRuleErr'); 
+                    }); 
+                }).catch(err => { 
+                    console.log(' 获取考勤时间段时发生错误', err); 
+                    reject('getAttendanceSegmentErr'); 
+                }); 
+            } catch (err) { 
+                console.error(' 处理考勤数据时发生错误', err); 
+                reject(err); 
+            } 
+        }); 
+    } 
+ 
+    // 获取当天的上午上班、上午下班、下午上班和下午下班时间 
+    function getStartAndEndTime(timeString) { 
+        // 去除最后一个分号 
+        timeString = timeString.trim().replace(/;$/,  ''); 
+        const periods = timeString.split(';');  
+        let startTimeAm = null; 
+        let endTimeAm = null; 
+        let startTimePm = null; 
+        let endTimePm = null; 
+ 
+        // 遍历每个时间段 
+        for (let period of periods) { 
+            if (period) { // 确保不是空字符串 
+                const [start, end] = period.split(',').map(time  => time.trim());  
+                const startHour = parseInt(start.split(':')[0]);  
+                if (startHour < 12) { // 上午时间段 
+                    if (!startTimeAm || start < startTimeAm) { 
+                        startTimeAm = start; 
+                    } 
+                    if (!endTimeAm || end > endTimeAm) { 
+                        endTimeAm = end; 
+                    } 
+                } else { // 下午时间段 
+                    if (!startTimePm || start < startTimePm) { 
+                        startTimePm = start; 
+                    } 
+                    if (!endTimePm || end > endTimePm) { 
+                        endTimePm = end; 
+                    } 
+                } 
+            } 
+        } 
+        return { startTimeAm, endTimeAm, startTimePm, endTimePm }; 
+    } 
+ 
+    // 处理时间运算 
+    function addMinutesToTime(timeStr, minutesToAdd) { 
+        const [hours, minutes] = timeStr.split(':').map(Number);  
+        let date = new Date(); 
+        date.setHours(hours);  
+        date.setMinutes(minutes);  
+        // 添加分钟数 
+        date.setMinutes(date.getMinutes()  + minutesToAdd); 
+        // 获取新的小时和分钟值,确保它们是两位数格式 
+        const newHours = String(date.getHours()).padStart(2,  '0'); 
+        const newMinutes = String(date.getMinutes()).padStart(2,  '0'); 
+        // 返回格式化后的新时间字符串 
+        return `${newHours}:${newMinutes}:00`; 
+    } 
+ 
+    return { 
+        signInTimeRange, 
+        signOutTimeRange, 
+        lateTimeRange, 
+        earlyTimeRange, 
+        GetAttRule 
+    } 
+})