|
|
@@ -1,7 +1,7 @@
|
|
|
import { View, Text, CoverView } from '@tarojs/components'
|
|
|
import './MetricModalAdd.scss'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
-import { alphaToHex } from '@/utils/tools'
|
|
|
+import { alphaToHex, rpxToPx } from '@/utils/tools'
|
|
|
import SlidngScale from '@/components/input/SlidngScale'
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
|
|
@@ -9,8 +9,9 @@ export default function Component(props: { item: any, strTime: string, showPicke
|
|
|
const [metricItem, setMetricItem] = useState(props.item)
|
|
|
const [enable, setEnable] = useState(true)
|
|
|
const [currentSel, setCurrentSel] = useState<any>({})
|
|
|
- const [selUnit,setSelUnit] = useState(-1)
|
|
|
- const [changeIndex,setChangeIndex] = useState(-1)
|
|
|
+ const [selUnit, setSelUnit] = useState(-1)
|
|
|
+ const [changeIndex, setChangeIndex] = useState(-1)
|
|
|
+ const [isChanging, setIsChanging] = useState(false)
|
|
|
// const [disableCode,setDisableCode] = useState(0)
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
@@ -20,6 +21,10 @@ export default function Component(props: { item: any, strTime: string, showPicke
|
|
|
setMetricItem(props.item)
|
|
|
}, [props.item])
|
|
|
|
|
|
+ global.dimissSel = () => {
|
|
|
+ setSelUnit(-1)
|
|
|
+ }
|
|
|
+
|
|
|
return <View>
|
|
|
<View className='modal_content'>
|
|
|
<Text className='modal_title' style={{ color: (metricItem as any).theme_color }}>{(metricItem as any).name ? (metricItem as any).name : ''}</Text>
|
|
|
@@ -38,7 +43,7 @@ export default function Component(props: { item: any, strTime: string, showPicke
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- return <View key={index} style={{position:'relative'}}>
|
|
|
+ return <View key={index} style={{ position: 'relative' }}>
|
|
|
{
|
|
|
(metricItem as any).schemas.length > 1 && <Text style={{
|
|
|
textAlign: 'center', width: '100%', display: 'flex',
|
|
|
@@ -47,23 +52,31 @@ export default function Component(props: { item: any, strTime: string, showPicke
|
|
|
}}>{item.name}</Text>
|
|
|
}
|
|
|
{
|
|
|
- unit_options && unit_options.length > 1 && <View style={{position:'absolute',right:20,zIndex:1000000}}>
|
|
|
- <Text style={{color:'#fff'}} onClick={()=>{
|
|
|
+ unit_options && unit_options.length > 1 && <View style={{ position: 'absolute', right: 20, zIndex: 1000000 }}>
|
|
|
+ <Text style={{ color: '#fff' }} onClick={(e) => {
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
+ e.stopPropagation()
|
|
|
+ }
|
|
|
setSelUnit(index)
|
|
|
}}>切换</Text>
|
|
|
{
|
|
|
- selUnit==index && <View style={{display:'flex',flexDirection:'column',position:'absolute',top:30,right:0,backgroundColor:'red'}}>
|
|
|
+ selUnit == index && <View style={{ display: 'flex', flexDirection: 'column', position: 'absolute', top: 30, right: 0, backgroundColor: 'red' }}>
|
|
|
{
|
|
|
- unit_options.map((obj,j)=>{
|
|
|
- return <View key={j*1000} onClick={()=>{
|
|
|
+ unit_options.map((obj, j) => {
|
|
|
+ return <View key={j * 1000} onClick={() => {
|
|
|
var dt = JSON.parse(JSON.stringify(metricItem))
|
|
|
dt.schemas[index].chosen_unit = obj.unit
|
|
|
setMetricItem(dt)
|
|
|
|
|
|
setChangeIndex(index)
|
|
|
- setTimeout(()=>{
|
|
|
+ setIsChanging(true)
|
|
|
+ setTimeout(() => {
|
|
|
+ setIsChanging(false)
|
|
|
+ }, 20)
|
|
|
+ setTimeout(() => {
|
|
|
setChangeIndex(-1)
|
|
|
- },100)
|
|
|
+
|
|
|
+ }, 100)
|
|
|
}}>
|
|
|
<Text>{obj.unit}</Text>
|
|
|
</View>
|
|
|
@@ -73,20 +86,42 @@ export default function Component(props: { item: any, strTime: string, showPicke
|
|
|
}
|
|
|
</View>
|
|
|
}
|
|
|
- <SlidngScale step={obj.step} min={obj.min} max={obj.max}
|
|
|
- default_value={obj.default_value}
|
|
|
- scale={obj.scale}
|
|
|
- unit={obj.unit ? obj.unit : item.default_unit}
|
|
|
- special={obj.special ?? null}
|
|
|
- themeColor={(metricItem as any).theme_color}
|
|
|
- changed={(e) => {
|
|
|
- item.tempValue = e;
|
|
|
- item.tempUnit = obj.unit ? obj.unit : item.default_unit
|
|
|
- debugger
|
|
|
- }}
|
|
|
- updateStatus={(isEnable) => {
|
|
|
- setEnable(isEnable)
|
|
|
- }} />
|
|
|
+ {
|
|
|
+ !isChanging && process.env.TARO_ENV == 'rn' && <SlidngScale step={obj.step} min={obj.min} max={obj.max}
|
|
|
+ default_value={obj.default_value}
|
|
|
+ scale={obj.scale}
|
|
|
+ unit={obj.unit ? obj.unit : item.default_unit}
|
|
|
+ special={obj.special ?? null}
|
|
|
+ themeColor={(metricItem as any).theme_color}
|
|
|
+ changed={(e) => {
|
|
|
+ item.tempValue = e;
|
|
|
+ item.tempUnit = obj.unit ? obj.unit : item.default_unit
|
|
|
+ debugger
|
|
|
+ }}
|
|
|
+ updateStatus={(isEnable) => {
|
|
|
+ setEnable(isEnable)
|
|
|
+ }} />
|
|
|
+ }
|
|
|
+ {
|
|
|
+ isChanging && process.env.TARO_ENV == 'rn' && <View style={{ height: rpxToPx(240) }} />
|
|
|
+ }
|
|
|
+ {
|
|
|
+ process.env.TARO_ENV == 'weapp' && <SlidngScale step={obj.step} min={obj.min} max={obj.max}
|
|
|
+ default_value={obj.default_value}
|
|
|
+ scale={obj.scale}
|
|
|
+ unit={obj.unit ? obj.unit : item.default_unit}
|
|
|
+ special={obj.special ?? null}
|
|
|
+ themeColor={(metricItem as any).theme_color}
|
|
|
+ changed={(e) => {
|
|
|
+ item.tempValue = e;
|
|
|
+ item.tempUnit = obj.unit ? obj.unit : item.default_unit
|
|
|
+ debugger
|
|
|
+ }}
|
|
|
+ updateStatus={(isEnable) => {
|
|
|
+ setEnable(isEnable)
|
|
|
+ }} />
|
|
|
+ }
|
|
|
+
|
|
|
</View>
|
|
|
})
|
|
|
}
|