|
|
@@ -1,5 +1,6 @@
|
|
|
import { View, Text, Image } from "@tarojs/components";
|
|
|
import './log_time.scss'
|
|
|
+import './fast_sleep.scss'
|
|
|
import { useSelector } from "react-redux";
|
|
|
import { useEffect, useState } from "react";
|
|
|
import NewButton, { NewButtonType } from "../base/new_button";
|
|
|
@@ -37,7 +38,7 @@ export default function LogTime() {
|
|
|
else {
|
|
|
router = useRouter()
|
|
|
}
|
|
|
- const enterTime = new Date().getTime()
|
|
|
+ const [enterTime,setEnterTime] = useState(new Date().getTime())
|
|
|
|
|
|
const isSingle = router.params.single == '1'
|
|
|
const isFast = router.params.window == 'FAST'
|
|
|
@@ -51,7 +52,11 @@ export default function LogTime() {
|
|
|
|
|
|
const [expandIndex, setExpandIndex] = useState(tapIndex)
|
|
|
const [array, setArray] = useState<any>([])
|
|
|
+ const [errors, setErrors] = useState<any>([])
|
|
|
+ const [conflicts, setConflicts] = useState<any>([])
|
|
|
const [loaded, setLoaded] = useState(false)
|
|
|
+ const [autoCheck, setAutoCheck] = useState(false)
|
|
|
+ const [initCheck,setInitCheck] = useState(router.params.initCheck=='1')
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (isSingle) {
|
|
|
@@ -71,6 +76,16 @@ export default function LogTime() {
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (autoCheck) {
|
|
|
+ tapCommit(true)
|
|
|
+ }
|
|
|
+ if (initCheck && array.length>0){
|
|
|
+ tapCommit(true)
|
|
|
+ setInitCheck(false)
|
|
|
+ }
|
|
|
+ }, [array])
|
|
|
+
|
|
|
function loadData() {
|
|
|
fastWithSleep().then(res => {
|
|
|
setData(res)
|
|
|
@@ -213,7 +228,7 @@ export default function LogTime() {
|
|
|
return timestamp
|
|
|
}
|
|
|
|
|
|
- function tapCommit() {
|
|
|
+ function tapCommit(onlyCheck) {
|
|
|
var list: any = []
|
|
|
if (isSingle) {
|
|
|
var obj = array[0]
|
|
|
@@ -310,36 +325,41 @@ export default function LogTime() {
|
|
|
cancel: () => {
|
|
|
},
|
|
|
confirm: () => {
|
|
|
- commit(list)
|
|
|
+ commit(list, onlyCheck)
|
|
|
}
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- commit(list)
|
|
|
+ commit(list, onlyCheck)
|
|
|
|
|
|
}
|
|
|
|
|
|
- function commit(list) {
|
|
|
+ function commit(list, onlyCheck) {
|
|
|
clockTimes({
|
|
|
check_items: list,
|
|
|
- op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : null
|
|
|
+ op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : null,
|
|
|
+ only_check: onlyCheck
|
|
|
}).then(res => {
|
|
|
- if ((res as any).result){
|
|
|
- global.refreshWindow()
|
|
|
- if (global.refreshFastSleep)
|
|
|
- global.refreshFastSleep()
|
|
|
- Taro.redirectTo({
|
|
|
- url: './post_result?data=' + JSON.stringify(res)
|
|
|
- })
|
|
|
+ if ((res as any).result) {
|
|
|
+ setErrors([])
|
|
|
+ setConflicts([])
|
|
|
+ if (!onlyCheck) {
|
|
|
+ global.refreshWindow()
|
|
|
+ if (global.refreshFastSleep)
|
|
|
+ global.refreshFastSleep()
|
|
|
+ Taro.redirectTo({
|
|
|
+ url: './post_result?data=' + JSON.stringify(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
- showAlert({
|
|
|
- title:'error',
|
|
|
- content:(res as any).error_messages[0]
|
|
|
- })
|
|
|
+ setErrors((res as any).error_messages)
|
|
|
+ setConflicts((res as any).conflict_schedule_ids)
|
|
|
+ setAutoCheck(true)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Taro.navigateBack({
|
|
|
// delta: 1
|
|
|
// })
|
|
|
@@ -383,8 +403,10 @@ export default function LogTime() {
|
|
|
var time = array[index].time
|
|
|
|
|
|
const today = dayjs();
|
|
|
+ var schedule_id = ''
|
|
|
if (iFast) {
|
|
|
schedule_time = iStart ? fast.period.start_time : fast.period.end_time
|
|
|
+ schedule_id = iStart ? fast.timeline[0].schedule_id : fast.timeline[1].schedule_id
|
|
|
if (!iStart && fast.status == 'OG') {
|
|
|
schedule_time = dayjs(fast.target.end_timestamp).format('HH:mm')
|
|
|
}
|
|
|
@@ -409,6 +431,7 @@ export default function LogTime() {
|
|
|
}
|
|
|
else {
|
|
|
schedule_time = iStart ? sleep.period.start_time : sleep.period.end_time
|
|
|
+ schedule_id = iStart ? sleep.timeline[0].schedule_id : sleep.timeline[1].schedule_id
|
|
|
if (!iStart && sleep.status == 'OG') {
|
|
|
schedule_time = dayjs(sleep.target.end_timestamp).format('HH:mm')
|
|
|
}
|
|
|
@@ -429,41 +452,67 @@ export default function LogTime() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var showError = false;
|
|
|
+ if ( conflicts.includes(schedule_id)) {
|
|
|
+ showError = true
|
|
|
+ disable = false
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
return <View style={{ position: 'relative' }}>
|
|
|
<View className="card_header">
|
|
|
+ {
|
|
|
+ showError && <View className="error_icon_bg">
|
|
|
+ <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
|
|
|
+ </View>
|
|
|
+
|
|
|
+ }
|
|
|
{
|
|
|
isSingle ? <View style={{ flex: 1 }} /> :
|
|
|
<View className="h34" style={{ flex: 1 }}>{title}</View>
|
|
|
}
|
|
|
|
|
|
- <NewButton
|
|
|
- type={NewButtonType.gray}
|
|
|
- title={date}
|
|
|
- fontSize={rpxToPx(34)}
|
|
|
- width={rpxToPx(196)}
|
|
|
- height={rpxToPx(84)}
|
|
|
- disable={disable}
|
|
|
- onClick={() => {
|
|
|
- var list = JSON.parse(JSON.stringify(array))
|
|
|
- list[index].today = !list[index].today
|
|
|
- setArray(list)
|
|
|
- }}
|
|
|
- />
|
|
|
+ <View style={{
|
|
|
+ borderColor: showError ? 'red' : 'transparent',
|
|
|
+ borderWidth: rpxToPx(2),
|
|
|
+ borderRadius: rpxToPx(88 / 4),
|
|
|
+ borderStyle: 'solid'
|
|
|
+ }}>
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.gray}
|
|
|
+ title={date}
|
|
|
+ fontSize={rpxToPx(34)}
|
|
|
+ width={rpxToPx(196)}
|
|
|
+ height={rpxToPx(84)}
|
|
|
+ disable={disable}
|
|
|
+ onClick={() => {
|
|
|
+ var list = JSON.parse(JSON.stringify(array))
|
|
|
+ list[index].today = !list[index].today
|
|
|
+ setArray(list)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
<View style={{ width: rpxToPx(12) }} />
|
|
|
- <NewButton
|
|
|
- type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
|
|
|
- color={iFast ? MainColorType.fast : MainColorType.sleep}
|
|
|
- title={time}
|
|
|
- fontSize={rpxToPx(34)}
|
|
|
- width={rpxToPx(196)}
|
|
|
- height={rpxToPx(84)}
|
|
|
- disable={disable}
|
|
|
- onClick={() => {
|
|
|
- setExpandIndex(index)
|
|
|
- }}
|
|
|
- />
|
|
|
+ <View style={{
|
|
|
+ borderColor: showError ? 'red' : 'transparent',
|
|
|
+ borderWidth: rpxToPx(2),
|
|
|
+ borderRadius: rpxToPx(88 / 4),
|
|
|
+ borderStyle: 'solid'
|
|
|
+ }}>
|
|
|
+ <NewButton
|
|
|
+ type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
|
|
|
+ color={iFast ? MainColorType.fast : MainColorType.sleep}
|
|
|
+ title={time}
|
|
|
+ fontSize={rpxToPx(34)}
|
|
|
+ width={rpxToPx(136)}
|
|
|
+ height={rpxToPx(84)}
|
|
|
+ disable={disable}
|
|
|
+ onClick={() => {
|
|
|
+ setExpandIndex(index)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
{
|
|
|
isSingle && <View style={{ flex: 1 }} />
|
|
|
}
|
|
|
@@ -519,7 +568,7 @@ export default function LogTime() {
|
|
|
case 1:
|
|
|
return <View style={{ position: 'relative' }}>
|
|
|
{
|
|
|
- logItem(0, true, true, true)
|
|
|
+ logItem(0, true, true, true, !(status == 'WFS' || status == 'OG2_NO1'))
|
|
|
}
|
|
|
{
|
|
|
logItem(1, false, true, false)
|
|
|
@@ -560,13 +609,33 @@ export default function LogTime() {
|
|
|
|
|
|
return <View className="page_container">
|
|
|
<Card>
|
|
|
- {
|
|
|
- isSingle ? <View style={{ position: 'relative' }}>
|
|
|
- {
|
|
|
- logItem(0, isFast, isStart, false)
|
|
|
- }
|
|
|
- </View> : multiContent()
|
|
|
- }
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
+ {
|
|
|
+ errors.map((item, index) => {
|
|
|
+ return <View className="error_bg" key={index}>
|
|
|
+ <View className="error_icon_bg">
|
|
|
+ <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
|
|
|
+ </View>
|
|
|
+ <Text className="h24" style={{ lineHeight: rpxToPx(36) + 'px' }}>{item}</Text>
|
|
|
+ </View>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ {
|
|
|
+ autoCheck && errors.length == 0 && <View className="error_bg" style={{ backgroundColor: MainColorType.success + '1A' }}>
|
|
|
+ <View className="error_icon_bg" style={{ backgroundColor: MainColorType.success }}>
|
|
|
+ <Image src={require('@assets/_health/tip_check.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
|
|
|
+ </View>
|
|
|
+ <Text className="h24" style={{ lineHeight: rpxToPx(36) + 'px' }}>成功提示</Text>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ isSingle ? <View style={{ position: 'relative' }}>
|
|
|
+ {
|
|
|
+ logItem(0, isFast, isStart, false)
|
|
|
+ }
|
|
|
+ </View> : multiContent()
|
|
|
+ }
|
|
|
+ </View>
|
|
|
|
|
|
</Card>
|
|
|
<View style={{ height: rpxToPx(36) }} />
|
|
|
@@ -622,7 +691,7 @@ export default function LogTime() {
|
|
|
width={rpxToPx(670)}
|
|
|
height={rpxToPx(96)}
|
|
|
bold={true}
|
|
|
- onClick={tapCommit} />
|
|
|
+ onClick={() => tapCommit(false)} />
|
|
|
</View>
|
|
|
|
|
|
</View>
|