import { View, Text, CoverView } from '@tarojs/components' import './MetricModalAdd.scss' import { useTranslation } from 'react-i18next' import { alphaToHex } from '@/utils/tools' import SlidngScale from '@/components/input/SlidngScale' import { useEffect, useState } from 'react' export default function Component(props: { item: any, strTime: string, showPicker: Function, cancel: Function, confirm: Function }) { const [metricItem, setMetricItem] = useState(props.item) const [enable, setEnable] = useState(true) const [currentSel, setCurrentSel] = useState({}) // const [disableCode,setDisableCode] = useState(0) const { t } = useTranslation() useEffect(() => { setMetricItem(props.item) }, [props.item]) return {(metricItem as any).name ? (metricItem as any).name : ''} { (metricItem as any).schemas.map((item, index) => { var obj = item; const { unit_options, chosen_unit } = item; if (unit_options && unit_options.length > 0) { unit_options.map((temp, i) => { if (temp.unit == chosen_unit) { obj = temp var tempMap = JSON.parse(JSON.stringify(currentSel)) tempMap[index] = i; } }) } return { (metricItem as any).schemas.length > 1 && {item.name} } { unit_options && unit_options.length > 1 && 切换 } { item.tempValue = e; item.tempUnit = obj.unit ? obj.unit : item.default_unit debugger }} updateStatus={(isEnable) => { setEnable(isEnable) }} /> }) } { props.showPicker(metricItem) }}> {props.strTime} props.cancel()}> { t('feature.common.picker_cancel_btn') } { if (enable) { props.confirm(metricItem) } }}> { t('feature.common.picker_confirm_btn') } }