/*
 * Author: 黎永顺
 * name: 外部人员添加弹框
 * Description:
 * Date: 2023/3/14
 */
import React, { Component } from "react";
import { WeaBrowser, WeaDialog, WeaFormItem, WeaSearchGroup } from "ecCom";
import { Button, Modal } from "antd";

class Index extends Component {
  constructor(props) {
    super(props);
    this.state = {
      targetIds: "",
      targetNames: ""
    };
  }

  handleExternalPersonSave = () => {
    const { targetIds } = this.state;
    const { onExternalPersonSave } = this.props;
    if (!_.isEmpty(targetIds)) {
      onExternalPersonSave({ targetIds: targetIds.split(",") });
    } else {
      Modal.warning({
        title: "信息确认",
        content: "必要信息不完整，红色*为必填项！"
      });
    }
  };

  render() {
    const { targetIds, targetNames } = this.state;
    const { onCancel, visible, loading } = this.props;
    const buttons = [
      <Button type="primary" onClick={this.handleExternalPersonSave} loading={loading}>确定</Button>,
      <Button type="ghost" onClick={onCancel}>取消</Button>
    ];
    return (
      <WeaDialog
        title="关联非系统人员"
        visible={visible}
        style={{ width: 600 }}
        buttons={buttons}
        onCancel={onCancel}
      >
        <WeaSearchGroup col={1} needTigger title="" showGroup center>
          <WeaFormItem label="非系统人员" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
            <WeaBrowser
              title="非系统人员"
              type={162}
              viewAttr={3}
              isSingle={false}
              value={targetIds}
              valueSpan={targetNames}
              completeParams={{
                type: 162,
                fielddbtype: "browser.salaryExtEmp",
                f_weaver_belongto_usertype: "0"
              }}
              conditionDataParams={{
                type: "browser.salaryExtEmp",
                fielddbtype: "browser.salaryExtEmp",
                f_weaver_belongto_usertype: "0"
              }}
              dataParams={{
                type: "browser.salaryExtEmp",
                f_weaver_belongto_usertype: "0"
              }}
              destDataParams={{
                type: "browser.salaryExtEmp",
                f_weaver_belongto_usertype: "0"
              }}
              isMultCheckbox
              inputStyle={{ width: 375 }}
              onChange={(targetIds, targetNames) => this.setState({ targetIds, targetNames })}
            />
          </WeaFormItem>
        </WeaSearchGroup>
      </WeaDialog>
    );
  }
}

export default Index;
