// 核心库
import React, { Component } from 'react'
import { connect } from 'dva'
// 工具库
import { initFilter } from '../../utils/common'
import config from '../../config'
// 样式
import styles from './picturePages.css'

class PicturePages extends Component {
  constructor (props) {
    super(props)
    this.state = {
      pictureConfigs: [],
      name: "",
    }
  }

  componentDidMount () {
    this.getPictureConfig()
  }

  getPictureConfig = () => {
    const { formCode, dispatch, login } = this.props
    const { OrgId: ORG_ID } = login
    const json = initFilter(ORG_ID, formCode, '', 0, 1)
    dispatch({
      type: 'picturePage/getPicturePageConfigInfo',
      payload: json,
    }).then(ret => {
      if (ret) {
        if (ret.FILE_NAME) {
          this.setState({
            name: ret.FILE_NAME
          })
        }
      }
    })
  }

  render () {
    const { name } = this.state
    return (
      <div className={styles.pageWrap}>
            <img className={styles.img} src={config.serviceHost('api/PF/File/GetFileByName?name=' + name)} alt="" />
      </div>
    )
  }
}

export default connect(({ login, loading }) => ({ login, loading }))(PicturePages)
