import React from 'react'
import { connect } from 'dva'
import config from '../../../config'
import storage from "../../../utils/storage"
import { isEqual } from 'lodash'

// 流程方案编辑
class FlowSchemesEditPage extends React.Component {

  shouldComponentUpdate (nextProps) {
    const { login, data } = nextProps
    const newParams = { orgId: login.OrgId, id: data?.id }

    const { login: prevLogin, data: prevData } = this.props
    const prevParams = { orgId: prevLogin.OrgId, id: prevData?.id }
    return !isEqual(newParams, prevParams)
  }

  render () {
    const { login, data } = this.props
    const token = storage('lacal').getItem('accessToken').val
    const tenant = storage('lacal').getItem('Tenant').val
    const url = `${config.flowServiceHost}/Flow/html/flowSchemeEdit.html?id=${data?.id}&orgId=${login.OrgId}&token=${token}&tenant=${tenant}`

    return (
      <div style={{ height: '100%' }}>
        <iframe src={url} style={{ width: '100%', height: '100%', border: 'none' }} title='流程方案编辑'></iframe>
      </div>
    )
  }
}

export default connect(({ login }) => ({ login }))(FlowSchemesEditPage)