import Taro, { Component, render } from '@tarojs/taro'
import { View, Text } from "@tarojs/components";
import Floor from "./Floor";
import './unit.scss'


export default class Unit extends Component {

  onShowMoreClick = (item) => {

    if (!item.noshow) {
      item.noshow = true
    } else {
      item.noshow = false
    }
    this.setState({})  // 强制页面刷新
  }
  render() {
    const { termName, blockName, unitName, noshow = false, floorList = [] } = this.props.dataset || {}
    return (
      <View className="unit">
        <View className="head" onClick={() => this.onShowMoreClick(this.props.dataset)} >
          <View>
            <Text className="item">{termName}</Text>
            <Text className="item">{blockName}</Text>
            <Text className="item">{unitName}</Text>
          </View>
          <Image className="arrow" style={!noshow ? 'transform:rotate(90deg);' : ''} src={require('@/assets/person/arrow2.png')} mode="widthFix"></Image>
        </View>
        <View className="body" >
          {!noshow && floorList.map((floor) => {
            return (
              <Floor
                key={floor.floorId}
                dataset={floor}
                showDataType={this.props.showDataType}
                onRoomClick={this.props.onRoomClick}
                chooseList={this.props.chooseList}
                showAction={this.props.showAction}
                onActionClick={this.props.onActionClick}                
              />)
          })}
        </View>
      </View>
    )
  }

}