Leon il y a 2 ans
Parent
commit
002fda1be7
3 fichiers modifiés avec 37 ajouts et 15 suppressions
  1. 26 3
      src/features/trackSomething/components/Metric.tsx
  2. 2 1
      src/pages/clock.tsx
  3. 9 11
      src/store/common.tsx

+ 26 - 3
src/features/trackSomething/components/Metric.tsx

@@ -32,12 +32,17 @@ export default function Component(props: any) {
 
     const [showErrorPage, setErrorPage] = useState(false)
 
+    const [setupTime,setSetupTime] = useState(0)
+
+
     //未登录<->已登录 状态切换时,执行一次授权检查
     useEffect(() => {
         getCards();
     }, [user.isLogin])
 
     const openModal = () => {
+        setSetupTime(new Date().getTime())
+        debugger
         setIsModalOpen(true);
     };
 
@@ -198,7 +203,14 @@ export default function Component(props: any) {
         }
 
         uploadMetric(params).then(res => {
-            getCards();
+            list.map((item, index) => {
+                if ((item as any).code == (res as any).code) {
+                    (item as any).latest_record = (res as any).latest_record
+                }
+            })
+            debugger
+            setList(list)
+            // getCards();
         })
     }
 
@@ -235,14 +247,25 @@ export default function Component(props: any) {
             code: (metricItem as any).code,
             timestamp: time,
             date: strDate,
-            items: array
+            items: array,
+            extra:{
+                set_time: setupTime,
+                confirm_time: new Date().getTime()
+            }
         }
         uploadMetric(params).then(res => {
-            getCards();
+            // getCards();
             (metricItem as any).schemas.map((item, index) => {
                 item.tempValue = ''
             })
 
+            list.map((item, index) => {
+                if ((item as any).code == (res as any).code) {
+                    (item as any).latest_record = (res as any).latest_record
+                }
+            })
+            setList(JSON.parse(JSON.stringify(list)))
+
         })
     }
 

+ 2 - 1
src/pages/clock.tsx

@@ -24,6 +24,7 @@ import trackTimeService from '@/store/trackTimeMachine';
 import { setWXFollow } from '@/store/permission';
 import Tooltip from '@/components/Tooltip'
 import RequestType, { thirdPartRequest } from '@/services/thirdPartRequest'
+import { setConfigs } from '@/store/common'
 // import TabBar from '../../components/Tabbar';
 
 export default function IndexPage() {
@@ -41,7 +42,6 @@ export default function IndexPage() {
   global.dispatch = dispatch;
   useEffect(() => {
     dispatch(staticResources() as any);
-    dispatch(gobalConfigs() as any);
     // dispatch(gobalConfigs() as any);
     trackTimeService.onTransition(state => {
       if ((state.value as any).FAST_SLEEP == 'COMPLETED' ||
@@ -161,6 +161,7 @@ export default function IndexPage() {
 
   function getCheckData() {
     getClocks().then(res => {
+      dispatch(setConfigs((res as any).time_input_schema));
       dispatch(setScenario((res as any).scenario));
       machine.context.checkData = res as any;
 

+ 9 - 11
src/store/common.tsx

@@ -26,18 +26,16 @@ const commonSlice = createSlice({
         },
         //time配置文件
         setConfigs(state, action) {
-            state.configs = action.payload.data;
+            state.configs = action.payload;
+
             if (state.configs) {
-                var list = state.configs
-                list.map(item => {
-                    if (item.key == 'time_duration') {
-                        state.duration = {
-                            min: item.value.min_time / 60,
-                            max: item.value.max_time / 60,
-                            step: item.value.step_time
-                        }
-                    }
-                })
+
+                state.duration = {
+                    min: state.configs.min / 60,
+                    max: state.configs.max / 60,
+                    step: state.configs.step
+                }
+
             }
         }
     }