import React, { Component } from "react";
import { Form } from "antd";
import ImgList from "../../../common/imgList/index.js";
import { splitUrl } from "../../../tools.js";

/**
 * 订单保密&违约说明详情
 */
const FormItem = Form.Item;

const ndaOptions = {
  1: '是',
  0: '否'
};

const breachClauseOptions = {
  0: '否',
  1: '有，有限责任违约条款，与技术服务有关',
  2: '有，有限责任违约条款，与技术服务无关',
  3: '无，无限责任违约条款，与技术服务有关',
  4: '无，无限责任违约条款，与技术服务无关'
};
class ConfidenBreachView extends Component {
  constructor(props) {
    super(props);
  }

  onChange(value, updateKey) {
    this.props.onChange(value, updateKey)
  }

  getFileList(url) {
    let fileList = []

    if (url instanceof Array) {
      fileList = url
    } else {
      fileList = url ? splitUrl(url, ",", globalConfig.avatarHost + "/upload") : []
    }

    return fileList
  }

  render() {
    let _data = {}
    if (!!this.props.data) {
      _data = this.props.data
    }
    const { nda, ndaUrl, breachClauseUrl, breachClause } = _data;

    console.log(nda, ndaUrl, breachClause, breachClauseUrl)
    return (
      <div>
        <div style={{display: 'flex', alignItems: 'center' }}>
          <h3
            style={{
              marginLeft: 10,
              fontWeight: 800,
              marginBottom: 10,
            }}
          >
            保密&违约说明 &nbsp; &nbsp; &nbsp;
          </h3>
          <div style={{ padding: '10px', backgroundColor: 'yellow', color: '#000' }}>
            <p>营销说明：未如实填报，责任由营销本人全部承担</p>
            <p>技术说明：请认真阅读保密/违约条款，并规避相关事项，含保密要求的企业，发送任何资料必须脱密</p>
          </div>
        </div>
        <FormItem
          labelCol={{ span: this.props.labelCol || 5 }}
          wrapperCol={{ span: this.props.wrapperCol || 19 }}
          label='是否签订保密协议'
        >
          <div>{ndaOptions[nda]}</div>
          {nda === 1 ? <ImgList domId={"ndaImg"} fileList={this.getFileList(ndaUrl)} ItemWidth={'96px'} /> : null}
        </FormItem>

        <FormItem
          labelCol={{ span: this.props.labelCol || 5 }}
          wrapperCol={{ span: this.props.wrapperCol || 19 }}
          label='是否有违约条款'
        >
          <div>{breachClauseOptions[breachClause]}</div>
          {breachClause !== 0 ? <ImgList domId={"breachClauseImg"} fileList={this.getFileList(breachClauseUrl)} ItemWidth={'96px'} /> : null}
        </FormItem>
      </div >
    );
  }
}

export default ConfidenBreachView;
