import React from 'react'
import { connect } from 'dva'
import { Button, Row, Col, Form, Input, Select, Transfer, message, Upload, Icon, Modal, DatePicker,Checkbox } from 'antd'
import {
  extend,
  extendRule,
  initFilter,
  getOnlyPropertyData,
  extendInclude,
  setDataFieldValue,
  getPropertyData,
  guid
} from '../../../utils/common'
import moment from 'moment'
import DropDownPagination from '../../common/DropDownPaginationEx'
import config from '../../../config'
import classNames from 'classnames'
import styles from '../../../baseComponents/Component.css'
import storage from '../../../utils/storage'
import FormPage from '../../FormPage';
import MultiSelectPagination from "../../common/MultiSelectPagination";
import FoTeamActivity from '../FO/FoTeamActivity'
const Option = Select.Option
const { TextArea } = Input
const CheckboxGroup = Checkbox.Group
class UserEditPage extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      data: {
        PASSWORD: 'E10ADC3949BA59ABBE56E057F20F883E', // 默认密码为123456
      },
      btns: [],
      userGroupTargetKeys: [],
      roleTargetKeys: [],
      roleGroupTargetKeys: [],
      disabled:false
    }

  };

  componentDidMount() {
    this.props.form.resetFields()
    this.loadData()
  };

  componentWillReceiveProps(NextProps) {
    const { data } = this.props
    let { id } = data ? data : {}
    if (!id)
      id = ''
    if (NextProps.custom['userEditClick' + id]) {
      this.props.form.resetFields()
      this.props.dispatch({
        type: 'custom/save',
        payload: {
          ['userEditClick' + id]: false
        },
      })
      this.loadData()
    }
  }

  loadDataSource = (orgId) => {
    const { dispatch } = this.props
    const userGroupJson = initFilter(orgId, '', 'CODE', 1)
    extendRule(userGroupJson, 'ENABLE_STATUS', 1, 0)
    userGroupJson.OrgType = 1
    dispatch({
      type: 'FMBase/getUserGroupDatasource',
      payload: userGroupJson,
    })
    const roleJson = initFilter(orgId, '', 'CODE', 1)
    extendRule(roleJson, 'ENABLE_STATUS', 1, 0)
    roleJson.OrgType = 1
    dispatch({
      type: 'FMBase/getRoleDatasource',
      payload: roleJson,

    })
    const roleGroupJson = initFilter(orgId, '', 'CODE', 1)
    extendRule(roleGroupJson, 'ENABLE_STATUS', 1, 0)
    roleGroupJson.OrgType = 1
    dispatch({
      type: 'FMBase/getRoleGroupDatasource',
      payload: roleGroupJson,
    })
  };
  loadData = () => {
    const { data, formId, login} = this.props
    const { id } = data || {}


    if (id) {
      const userJson = initFilter(this.props.login.OrgId)
      extendRule(userJson, 'ID', 1, id)
      extendInclude(userJson, 'Nav_Department')
      extendInclude(userJson, 'Nav_ApproveRole')
      extendInclude(userJson, 'Nav_Person.Nav_TeamPersons.Nav_Team')
      extendInclude(userJson, 'Nav_Person.Nav_Post')
      extendInclude(userJson, 'Nav_BelongRoles')
      // extendInclude(userJson, 'Nav_BelongRoleGroups')
      // extendInclude(userJson, 'Nav_BelongUserGroups')
      // extendInclude(userJson, 'Nav_UserPhotoFiles')
      extendInclude(userJson, 'Nav_UserPhotoFiles.Nav_ImgFile')
      extendInclude(userJson, 'Nav_UserSignFiles.Nav_ImgFile')
      extendInclude(userJson, 'Nav_ProdutionUnit.Nav_Enums')
      this.props.dispatch({
        type: 'FMUserEdit/getUser',
        payload: userJson,
        onComplete: (ret) => {
          if (ret) {
            let userGroup = []
            let role = []
            let roleGroup = []
            if (ret.Nav_BelongRoles) {
              ret.Nav_BelongRoles.forEach(item => {
                role.push(item.BELONG_ROLE_ID.toString().toUpperCase())
              })
            }
            if (ret.Nav_BelongRoleGroups) {
              ret.Nav_BelongRoleGroups.forEach(item => {
                roleGroup.push(item.BELONG_ROLE_GROUP_ID.toString().toUpperCase())
              })
            }

            if (ret.Nav_BelongUserGroups) {
              ret.Nav_BelongUserGroups.forEach(item => {
                userGroup.push(item.BELONG_USER_GROUP_ID.toString().toUpperCase())
              })
            }
            
            this.loadDataSource(ret.ORG_ID)
            this.fillData(ret)
            this.fillSignData(ret)
            this.setState({
              data: ret,
              userGroupTargetKeys: userGroup,
              roleTargetKeys: role,
              roleGroupTargetKeys: roleGroup,
              disabled:true,
            })
          }
        }
      })
    }
    else {
      this.props.form.resetFields()
      this.loadDataSource(login.OrgId)

      this.setState({
        data: {
          ...this.state.data,
          ORG_ID: this.props.login.OrgId,
          ENABLE_STATUS: 0,
          ID: guid(),
          Nav_Person: {
            Nav_TeamPersons: [],
            Nav_Post: {}
          },
        },
        disabled:false,
      })
      const { form, } = this.props
      const { setFieldsValue } = form
      if (this.props.login.OrgCode) {
        setFieldsValue({
          CODE: (this.props.login.OrgCode),
        })
      }
    }
    if (formId) {
      const btnJson = initFilter(this.props.login.OrgId, '', 'NUM', 0)
      extendRule(btnJson, 'PAGE_CUSTOM_FORM_ID', 1, formId)
      this.props.dispatch({
        type: 'FMUserEdit/getBtnList',
        payload: btnJson,
        onComplete: (ret) => {
          if (ret) {
            this.setState({
              btns: ret,
            })
          }
        }
      })
    }


  };

  fillData = (ret) => {
    const updateLoadFileList = []
    if (ret.Nav_UserPhotoFiles) {
      ret.Nav_UserPhotoFiles.forEach(t => {
        updateLoadFileList.push({
          uid: t.ID,
          name: t.Nav_ImgFile ? t.Nav_ImgFile.FILE_NAME : '未知文件',
          status: 'done',
          response: { Data: { imgFileID: t.IMG_FILE_ID }, file: t },
        })
      })
    }
    this.setState({
      updateLoadFileList: updateLoadFileList,
    })
  }

  fillSignData = (ret) => {
    const updateLoadSignFileList = []
    if (ret.Nav_UserSignFiles) {
      ret.Nav_UserSignFiles.forEach(t => {
        updateLoadSignFileList.push({
          uid: t.ID,
          name: t.Nav_ImgFile ? t.Nav_ImgFile.FILE_NAME : '未知文件',
          status: 'done',
          response: { Data: { imgFileID: t.IMG_FILE_ID }, file: t },
        })
      })
    }
    this.setState({
      updateLoadSignFileList: updateLoadSignFileList,
    })
  }

  getBtns = () => {
    const btns = []
    if (this.state.btns) {
      this.state.btns.forEach(item => {
        if (item.BTN_TYPE == 1 && this.state.data.ENABLE_STATUS == 0) {
          btns.push(<Button type={item.CSS} icon={item.ICON} key={item.ID} onClick={() => this.handleOk()}>{item.LABEL}</Button>)
        }
      })
      if (this.state.data.ENABLE_STATUS == 0) {
        btns.push(<Button type="danger" icon="stop" onClick={() => this.handleStatus(this.state.data.ENABLE_STATUS)}>停用</Button>)
      } else {
        btns.push(<Button type="primary" icon="plus" onClick={() => this.handleStatus(this.state.data.ENABLE_STATUS)}>启用</Button>)
      }

    }
    return btns
  };
  handleStatus = (status) => {
    const { form, dispatch, data } = this.props
    if (this.state.data.Nav_Department.NAME.length == 0) {//Nav_Person.Nav_TeamPersons
      message.error(`请先选择班组`);
      return;
    }
    dispatch({
      type: 'app/getDataByPost',
      url: 'FM/User/updateStatus',
      payload: {
        Parameter1: status,
        Parameter2: data.id,
        Parameter3: this.state.data.DEPARTMENT_ID,//this.state.data.Nav_Person.Nav_TeamPersons[0].TEAM_ID,

      },
      onComplete: (ret) => {
        if (ret) {
          if (data.close) {
            data.close()
          }
          message.success('执行成功')
        }
      }
    })
  }
  handleOk = () => {
    const { form, dispatch, data } = this.props
    const { validateFieldsAndScroll } = form
    const { updateLoadFileList, updateLoadSignFileList } = this.state
    validateFieldsAndScroll((errors, values) => {
      if (errors) return
      extend(this.state.data, values)
      let updateData = getOnlyPropertyData(this.state.data)
      const ret = this.state.data
      let personTeam = getPropertyData(this.state.data.Nav_Person);
      let userGroup = []
      let role = []
      let roleGroup = []
      let userPhoto = []
      let userSign = []
      if (updateLoadFileList) {
        updateLoadFileList.forEach(item => {
          if (item.response && item.response.Data) {
            userPhoto.push({ IMG_FILE_ID: item.response.Data.imgFileID, ORG_ID: updateData.ORG_ID, USER_ID: updateData.ID })
          }
        })
      }
      if (updateLoadSignFileList) {
        updateLoadSignFileList.forEach(item => {
          if (item.response && item.response.Data) {
            userSign.push({ IMG_FILE_ID: item.response.Data.imgFileID, ORG_ID: updateData.ORG_ID, USER_ID: updateData.ID })
          }
        })
      }
      if (this.state.roleTargetKeys) {
        this.state.roleTargetKeys.forEach(item => {
          let isGet = false
          if (ret.Nav_BelongRoles) {
            ret.Nav_BelongRoles.forEach(t => {
              if (t.BELONG_ROLE_ID.toString().toUpperCase() == item) {
                role.push(t)
                isGet = true
              }
            })
          }
          if (!isGet) {
            role.push({ BELONG_ROLE_ID: item, ORG_ID: updateData.ORG_ID })
          }
        })
      }

      if (this.state.userGroupTargetKeys) {
        this.state.userGroupTargetKeys.forEach(item => {
          let isGet = false
          if (ret.Nav_BelongUserGroups) {
            ret.Nav_BelongUserGroups.forEach(t => {
              if (t.BELONG_USER_GROUP_ID.toString().toUpperCase() == item) {
                userGroup.push(t)
                isGet = true
              }
            })
          }
          if (!isGet) {
            userGroup.push({ BELONG_USER_GROUP_ID: item, ORG_ID: updateData.ORG_ID })
          }
        })
      }


      if (this.state.roleGroupTargetKeys) {
        this.state.roleGroupTargetKeys.forEach(item => {
          let isGet = false
          if (ret.Nav_BelongRoleGroups) {
            ret.Nav_BelongRoleGroups.forEach(t => {
              if (t.BELONG_ROLE_GROUP_ID.toString().toUpperCase() == item) {
                roleGroup.push(t)
                isGet = true
              }
            })
          }
          if (!isGet) {
            roleGroup.push({ BELONG_ROLE_GROUP_ID: item, ORG_ID: updateData.ORG_ID })
          }
        })
      }
      updateData['Nav_BelongRoles'] = role
      updateData['Nav_BelongUserGroups'] = userGroup
      updateData['Nav_BelongRoleGroups'] = roleGroup
      updateData['Nav_UserPhotoFiles'] = userPhoto
      updateData['Nav_UserSignFiles'] = userSign
      updateData['Nav_Person'] = personTeam;
      dispatch({
        type: 'FMUserEdit/updateUser',
        payload: updateData,
        onComplete: (ret) => {
          if (ret) {
            if (data.close) {
              data.close()
            }
            message.success('执行成功')
          }
        }
      })
    })
  };

  handleSopClick = async function (recordId, ids) {
    await this.props.dispatch({
      type: 'custom/save',
      payload: {
        ['sopViewClick' + recordId]: true,
      },
    });
  };

  handleSopShowModal = (file) => {
    this.setState({
      sopData: { ids: file.response.Data.imgFileID, id: file.response.Data.imgFileID },
      sopVisible: true
    }, () => {
      this.handleSopClick(file.response.Data.imgFileID, file.response.Data.imgFileID);
    });
  };
  handleSopCloseModal = () => {
    this.setState({
      sopVisible: false
    });
  };

  render() {
    const { form } = this.props
    const { getFieldDecorator } = form

    const handleRoleChange = (nextTargetKeys, direction, moveKeys) => {
      this.setState({ roleTargetKeys: nextTargetKeys })
    }
    const formItemLayout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    }
    const onSelectDepartment = ({ data, record }) => {
      
      if (data && data.length > 0) {
        let json = initFilter(this.props.login.OrgId,record.ID);
        this.props.dispatch({
            type: 'app/getDataByPost',
            payload: json,
            url: 'FM/User/GetProductionUnit',
            onComplete: (ret) => {
                if(ret)
                {
                  this.setState({
                    data: {
                      ...this.state.data,
                      MineType:ret.MineType
                    }
                  })
                }                   
            }
        });
        this.setState({
          data: {
            ...this.state.data,
            DEPARTMENT_ID: data[0],
            Nav_Department: { NAME: record.NAME },
          }
        })
      }
      else {
        this.setState({
          data: {
            ...this.state.data,
            Nav_Department: { NAME: null },
            DEPARTMENT_ID: null,
          }
        })
      };
    }
    const onSelectApproveRole = ({ data, record }) => {
      
      if (data && data.length > 0) {
        this.setState({
          data: {
            ...this.state.data,
            APPROVE_ROLE_ID: data[0],
            Nav_ApproveRole: { NAME: record.NAME }
          }
        })
      }
      else {
        this.setState({
          data: {
            ...this.state.data,
            Nav_ApproveRole: { NAME: null },
            APPROVE_ROLE_ID: null,
          }
        })
      };
    }
    const onSelectPost = ({ data, record }) => {
      var tmpData = { ...this.state.data };
      if (data && data.length > 0) {
        tmpData.Nav_Person.Post_ID = data[0];
        tmpData.Nav_Person.Nav_Post = { NAME: record.NAME };

      }
      else {
        tmpData.Nav_Person.Post_ID = '';
        tmpData.Nav_Person.Nav_Post = { NAME: '' };
      };
      this.setState({
        data: tmpData
      })
    }
    const onSelectPerson = ({ data, record }) => {
      if (data && data.length > 0) {
        this.setState({
          data: {
            ...this.state.data,
            PERSON_ID: data[0],
            Nav_Person: { NAME: record.NAME }
          }
        })
      }
      else {
        this.setState({
          data: {
            ...this.state.data,
            Nav_Person: { NAME: null },
            PERSON_ID: null,
          }
        })
      };
    }

    const onSelectTeam = (value) => {
      var tmpData = { ...this.state.data }
      setDataFieldValue(tmpData, 'Nav_Person.Nav_TeamPersons', value)
      this.setState({
        data: tmpData,
      });
    }
    const onSelectProduction = (value) => {
      var tmpData = { ...this.state.data }
      setDataFieldValue(tmpData, 'Nav_ProdutionUnit', value)
      this.setState({
        data: tmpData,
      });
    }
    const onUnitChange = (value) => {
      var tmpData = { ...this.state.data }
      if(value.length==0)
      {
        setDataFieldValue(tmpData, 'MineType',value.toString())
      }
      else
      {
        setDataFieldValue(tmpData, 'MineType',tmpData.MineType +","+value.toString())
      }
      this.setState({
        data: tmpData,
      });
    }
    const onChange = (field, value,) => {
      const data = { ...this.state.data };
      data[field] = value;
      this.setState({
        data: data,
      });
    }

    const that = this
    const Tenant = storage('lacal').getItem('Tenant').val
    const uploadSopProps = {
      name: 'file',
      action: config.serviceHost('api/PF/File/UploadFileToImage'),
      data: { OrgId: this.props.login.OrgId, IsSaveSelf: true },
      fileList: this.state.updateLoadFileList,
      headers: {
        Tenant: Tenant,
      },
      onPreview: function (file) {
        that.handleSopShowModal(file);
      },
      onChange(info) {
        that.setState({
          updateLoadFileList: info.fileList,
        })
        if (info.file.status === 'done') {
          message.success(`${info.file.name} file uploaded successfully`)
        } else if (info.file.status === 'error') {
          message.error(`${info.file.name} file upload failed.`)
        }
      },
    }

    const uploadSingProps = {
      name: 'file',
      action: config.serviceHost('api/PF/File/UploadFileToImage'),
      data: { OrgId: this.props.login.OrgId, IsSaveSelf: true },
      fileList: this.state.updateLoadSignFileList,
      headers: {
        Tenant: Tenant,
      },
      onPreview: function (file) {
        that.handleSopShowModal(file);
      },
      onChange(info) {
        that.setState({
          updateLoadSignFileList: info.fileList,
        })
        if (info.file.status === 'done') {
          console.log(that.state)
          message.success(`${info.file.name} file uploaded successfully`)
        } else if (info.file.status === 'error') {
          message.error(`${info.file.name} file upload failed.`)
        }
      },
    }

    return (

      <Form style={{ padding: 12, overflow: 'hidden' }}>
        <div className={styles.topBar}>
          <div className={classNames(styles.topBarLeftBtns, styles.antBtns_mr8)}>
            {this.getBtns()}
          </div>
        </div>
        <Row gutter={32}>
          <Col span={16}>
            <Row>
              <Col span={8}>
                <Form.Item
                  label={'姓名'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('NAME', {
                    validateTrigger: 'onBlur',
                    initialValue: this.state.data.NAME,
                    rules: [{ required: true, message: '请输入姓名' }],
                  })(<Input disabled={this.state.disabled} maxLength={30} placeholder={'请输入姓名'} />)}
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'登入名'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('CODE', {
                    validateTrigger: 'onBlur',
                    initialValue: this.state.data.CODE,
                    rules: [{ required: true, message: '请输入登入名' }],
                  })(<Input disabled={this.state.disabled} maxLength={30} placeholder={'请输入登入名'} />)}
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'组织结构'}
                  {...formItemLayout}
                >
                  <DropDownPagination inputDataApi={'FM/Department/OrderPaged'} fieldName={'Nav_Department.NAME'}
                    data={this.state.data} onSelect={onSelectDepartment} onFilter={({ params }) => {
                      params.OrderType = 1
                      params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId
                    }} />
                </Form.Item>
              </Col>
              {/* <Col span={12}>
                <Form.Item
                  label={'关联人员'}
                  {...formItemLayout}
                >
                  <DropDownPagination inputDataApi={'FM/Person/OrderPaged'} fieldName={'Nav_Person.NAME'}
                    data={this.state.data} onSelect={onSelectPerson} onFilter={({ params }) => {
                      params.OrderType = 1
                      params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId
                    }} />
                </Form.Item>
              </Col> */}
              {/* <Col span={8}>
                <Form.Item
                  label={'班组'}
                  {...formItemLayout}
                >
                  <MultiSelectPagination api={'FM/Team/OrderPaged'}
                    data={
                      {
                        navField: 'ID,NAME',
                        saveField: 'TEAM_ID,Nav_Team.NAME',
                        labelField: "Nav_Team.NAME",
                        showField: "NAME",
                        filterField: "NAME",
                        idField: "PERSON_ID",
                        selectLabelField: "NAME",//不配置则默认取labelField，如果labelField也不配置，默认取NAME字段
                      }
                    }
                    colConfig={{ field: "Nav_Person.Nav_TeamPersons" }}
                    record={this.state.data} onChange={onSelectTeam} onFilter={({ params }) => {
                      params.OrderType = 1
                      params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId
                    }} />
                </Form.Item>
              </Col> */}
              <Col span={8}>
                <Form.Item
                  label={'岗位'}
                  {...formItemLayout}
                >
                  <DropDownPagination inputDataApi={'FM/UserPost/OrderPaged'} fieldName={'Nav_Person.Nav_Post.NAME'}
                    data={this.state.data} onSelect={onSelectPost} onFilter={({ params }) => {
                      params.OrderType = 1
                      params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId
                    }} />
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'手机号'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('PHONE', {
                    validateTrigger: 'onBlur',
                    initialValue: this.state.data.PHONE,
                    rules: [],
                  })(<Input maxLength={13} placeholder={'请输入手机号'} />)}
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'身份证号'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('ID_CARD', {
                    initialValue: this.state.data.ID_CARD,
                    rules: [],
                  })(<Input maxLength={50} placeholder={'请输入身份证号'} />)}
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'性别'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('SEX', {
                    initialValue: this.state.data.SEX ? this.state.data.SEX.toString() : "0",
                    rules: [],
                  })(<Select placeholder="性别" >
                    <Option value="0">女</Option>
                    <Option value="1">男</Option>
                  </Select>)}
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'入职时间'}
                  {...formItemLayout}
                >
                  <DatePicker
                    value={moment(this.state.data.ENTRYTIME)}
                    placeholder={'请输入入职时间'}
                    onChange={(value, dateString) => { onChange('ENTRYTIME', dateString, 0) }}
                  />
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'离职时间'}
                  {...formItemLayout}
                >
                  <DatePicker
                    value={moment(this.state.data.DEPARTURETIME?this.state.data.DEPARTURETIME:'2099-01-01')}
                    placeholder={'请输入离职时间'}
                    onChange={(value, dateString) => { onChange('DEPARTURETIME', dateString, 0) }}
                  />
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'工龄'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('WORKINGYEAR', {
                    initialValue: this.state.data.WORKINGYEAR,
                    rules: [],
                  })(<Input placeholder={'请输入工龄'} />)}
                </Form.Item>
              </Col>
              <Col span={8}>
                <Form.Item
                  label={'审核角色'}
                  {...formItemLayout}
                >
                  <DropDownPagination inputDataApi={'PF/ApprovalRole/OrderPaged'} fieldName={'Nav_ApproveRole.NAME'}
                    data={this.state.data} onSelect={onSelectApproveRole} onFilter={({ params }) => {
                      params.OrderType = 1
                      params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId
                    }} />
                </Form.Item>
              </Col>
              {/* <Col span={8}>
                <Form.Item label={'启用标志'} {...formItemLayout}>
                  {getFieldDecorator('ENABLE_STATUS', {
                    validateTrigger: 'onBlur',
                    initialValue: this.state.data.ENABLE_STATUS ? this.state.data.ENABLE_STATUS.toString() : "0",
                    rules: [],

                  })(<Select placeholder="数据类型" >
                    <Option value="0">启用</Option>
                    <Option value="1">不启用</Option>
                  </Select>)}

                </Form.Item>
              </Col> */}
              {/* style={{display:this.props.login.user?.NAME.indexOf("管理员") === -1 ?"none":"block"}} */}
               <Col span={8}>
                <Form.Item
                  label={'生产单元'}
                  {...formItemLayout}
                >
                {/* <CheckboxGroup options={this.props.app.enums.FMProductionUnit.options} value={this.state.data.MineType} onChange={onUnitChange} /> */}
                <MultiSelectPagination api={'FM/Enum/GetEnumsByCode'}
                    data={
                      {
                        navField: 'ID,VALUE,NAME',
                        saveField: 'ENUMS_ID,Nav_Enums.VALUE,Nav_Enums.NAME',
                        labelField: "Nav_Enums.NAME",
                        showField: "NAME",
                        filterField: "NAME",
                        idField: "USER_ID",
                        selectLabelField: "NAME",//不配置则默认取labelField，如果labelField也不配置，默认取NAME字段
                      }
                    }
                    colConfig={{ field: "Nav_ProdutionUnit" }}
                    record={this.state.data} onChange={onSelectProduction} onFilter={({ params }) => {
                      // extendRule(params, 'CODE', 1, 'BSMineTypeEnum');
                      params.OrderType = 1
                      params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId
                      // params.Parameter1='BSMineTypeEnum'
                    }} />
                </Form.Item>
              </Col>
                  
              <Col span={12}>
                <Form.Item
                  label={'备注'}
                  {...formItemLayout}
                >
                  {getFieldDecorator('REMARK', {
                    initialValue: this.state.data.REMARK,
                  })(<TextArea maxLength={300} rows={4} placeholder={'请输入备注'} />)}
                </Form.Item>
              </Col>
              {/* <Col span={12}>
                <Modal visible={this.state.sopVisible} maskClosable={false} onCancel={this.handleSopCloseModal} footer={false} width={"86%"}>
                  <FormPage formCode={'BD119'} data={this.state.sopData} />
                </Modal>
                <Form.Item
                  label={'照片'}
                  {...formItemLayout}
                >
                  <Upload {...uploadSopProps}>
                    <Icon type="upload" /> 上传人员照片
                  </Upload>
                </Form.Item>
              </Col> */}
              <Col span={12}>
                <Form.Item
                  label={'签名'}
                  {...formItemLayout}
                >
                  <Upload {...uploadSingProps}>
                    <Icon type="upload" /> 上传签名图片
                  </Upload>
                </Form.Item>
              </Col>
            </Row>
          </Col>
          <Col span={8} style={{display:this.props.login.user?.NAME.indexOf("管理员") === -1 ?"none":"block"}}>
            <Transfer
              dataSource={this.props.FMBase.roleDatasource}
              titles={['角色', '已选择']}
              targetKeys={this.state.roleTargetKeys}
              onChange={handleRoleChange}
              render={item => item.title}
              style={{ marginTop: 4 }}
            />
          </Col>
        </Row>
      </Form>
    )
  }
}

export default connect(({ login, FMBase, custom,app }) => ({ login, FMBase, custom,app }))(Form.create()(UserEditPage))
