// 主菜单维护
import React from 'react';
import '../../assets/css/system.css';
import '../../assets/css/App.css';
import PropTypes from 'prop-types';
import { $http } from '../../containers/config/https';
import { Modal, Form, notification,Input,Icon, message, Select ,Table, DatePicker, Button, Spin,Row,Col,Tabs,InputNumber,Tooltip,Pagination,Cascader  } from 'antd';
import moment from 'moment';
import { compose } from 'redux';
const Option = Select.Option;
const TabPane = Tabs.TabPane
const FormItem = Form.Item;
const confirm = Modal.confirm;
const FormHandel = Form.create()(
    
    // eslint-disable-next-line
    class extends React.Component {
      constructor(props) {
        super(props);

        this.state = {
            Typeoptions:[],
            userInfo:{},
            AdmReasonDr:'',
            AdmType:'',
            TCID:'',
            TCSubID:'',
            TCData:[],
            TCSUBData:[],
            AdmReasonData:[],
            Exceptsdata: [], 
            Exceptstotal: 0, 
            Exceptsloading:true,
            // 列表数据
            data: [],
            UpData:[],
            UpExceptData:[],
            // 抽屉显示
            visible: false,
            // 主菜单分页数据
            total: 0,
            page: 1,
            pageSize: 100,
            flag: '',
            title: '',
            // 是否显示loading
            // 表格loading
            loading: true,
            HospitalData:[],
            ConfigTypeID:'',
            ConfigTypeItmID:'',
            ConfigTypeDesc:'',
            ConfigTypeItmDesc:'',
            SubStDate:'',
            SubEndDate:'',
            Discount:'',
            ShareFree:'',
            ShareFreeAmt:'',
            RegPre:'',
            PrioRity:'',
            DisCondition:'',
            AdmTypeData:[],
            DisConditionData:[],
            RegPreData:[],
            DisCountConfigTypeData:[],
            PrioRityData:[],
            divdisplay:'none',
            Notdivdisplay:'none',
            Buttondisplay:'',
            uplistkey:0,
            upExceptslistkey:0,
            HBCIHParRef:'',
            TypeValue:[],
            Buttondisabled:true,
        };
        this.columns = [
          {
            title: '分类',
            dataIndex: 'DisCountConfigType',
            align: "center"
        },
        {
            title: '项目名称',
            dataIndex: 'ChargeItem',
            align: "center",
            width: 180,
        },
        {
            title: '折扣比例系数',
            dataIndex: 'Discount',
            align: "center",
            width: 60,
        },
        {
            title: '记账比例系数',
            dataIndex: 'ShareFree',
            align: "center",
            width: 60,
        },
        {
            title: '指定金额',
            dataIndex: 'ShareFreeAmt',
            align: "center",
            width: 60,
        },
        {
            title: '生效日期',
            dataIndex: 'StDate',
            align: "center"
        },
        {
            title: '失效日期',
            dataIndex: 'StopDate',
            align: "center",
            
        },
        {
            title: '创建日期',
            dataIndex: 'CreateDate',
            align: "center"
        },
        {
            title: '创建时间',
            dataIndex: 'CreateTime',
            align: "center",
            defaultSortOrder: 'descend'
        },
        {
            title: '创建人',
            dataIndex: 'CreateUser',
            align: "center"
        }];
        this.Notcolumns = [
          {
              title: '分类',
              dataIndex: 'DisCountConfigType',
              align: "center"
          },
          {
              title: '项目名称',
              dataIndex: 'ChargeItem',
              align: "center",
              width: 180,
          },
          {
              title: '生效日期',
              dataIndex: 'StDate',
              align: "center"
          },
          {
              title: '失效日期',
              dataIndex: 'StopDate',
              align: "center",
              
          },
          {
              title: '创建日期',
              dataIndex: 'CreateDate',
              align: "center"
          },
          {
              title: '创建时间',
              dataIndex: 'CreateTime',
              align: "center",
              defaultSortOrder: 'descend'
          },
          {
              title: '创建人',
              dataIndex: 'CreateUser',
              align: "center"
          }
      ];
      
    }
    
// 查询折扣系数
FindDiscountConfigSubData = () => {
  let data = {}
      data = {
          params: [{
            HBCIHParRef: this.props.ListData.ID,
          }],
          pagination:[{
              pageSize: 10,
              currentPage: 1,
              sortColumn: "Code",
              sortOrder: "asc"
          }]
      }
  $http.post('urlS', this, {
    code: '05100035',
    data: data,
    success: function (res) {
      if (+res.errorCode === 0 && res.result.Data) {
        for(var i = 0; i < res.result.Data.length; i++) {
          res.result.Data[i].key = i
        }
        this.setState({uplistkey:res.result.Data.length+1})
        this.setState({data: res.result.Data, total: res.result.TotalCount, loading: false})
      } else {
          this.setState({data: [], total: 0, loading: false,uplistkey:1})
      }
    }
  })
}
   
// 查询折扣系数除外项目
FindDiscountConfigExceptsubData = () => {
  let data = {}
    data = {
        params: [{
          HBCIHParRef: this.props.ListData.ID,
        }],
        pagination:[{
            pageSize: 10,
             currentPage: 1,
             sortColumn: "Code",
             sortOrder: "asc"
        }]
    }
  $http.post('urlS', this, {
    code: '05100041',
    data: data,
    success: function (res) {
      if (+res.errorCode === 0 && res.result.Data) {
         for(var i = 0; i < res.result.Data.length; i++) {
           res.result.Data[i].key = i
         }
        this.setState({upExceptslistkey:res.result.Data.length+1})
        this.setState({Exceptsdata: res.result.Data, Exceptstotal: res.result.TotalCount, Exceptsloading: false})
      } else {
          this.setState({Exceptsdata: [], Exceptstotal: 0, Exceptsloading: false,upExceptslistkey:1})
      }
    }
  })
}
  setRowClassName = (record) => {
      return record.ID === this.state.selectrowid ? 'clickRowStyle' : '';
    }
    setExceptRowClassName = (record) => {
      return record.ID === this.state.selectExceptrowid ? 'clickRowStyle' : '';
    }
    disabledSubStopDate=(SubEndDate)=> {
      if (!this.state.SubStDate) {
        return true;
      }
      let data= this.state.SubStDate<moment().format('YYYY-MM-DD') ? moment().format('YYYY-MM-DD'):this.state.SubStDate
      return moment(SubEndDate).format('YYYY-MM-DD')< data;
    }
    disabledSubStartDate=(SubStDate)=> {
      return SubStDate < moment();
    }
    disabledStartDate=(SubStDate)=> {
      return SubStDate < moment();
    }
    disabledEndDate=(EndDate)=> {
      if (!this.state.StDate) {
        return true;
      }
      let data= this.state.StDate<moment().format('YYYY-MM-DD') ? moment().format('YYYY-MM-DD'):this.state.StDate
      return moment(EndDate).format('YYYY-MM-DD')< data;
    }
    onChangeDate=(field, value)=> {
      this.setState({
        [field]: moment(value).format('YYYY-MM-DD'),
      });
    }
    chkPrice=(field, value)=> {
      this.setState({
        [field]: value,
      });
    }
    ///各下拉框值
    handleChange=(field, value)=>{
      value =typeof value==='undefined'?'':value
      this.setState({
        [field]: value,
      });
    }
    onTypeChange = (value, selectedOptions) => {
      if(selectedOptions.length>1)
      {
          this.setState({ 
            ConfigTypeID: selectedOptions[0].value,
            ConfigTypeDesc:selectedOptions[0].label,
            ConfigTypeItmID: selectedOptions[1].value,
            ConfigTypeItmDesc:selectedOptions[1].label,
            TypeValue:[selectedOptions[0].value,selectedOptions[1].value]
          });
     }
     else if(selectedOptions.length===1)
      {
          this.setState({ 
            ConfigTypeID: selectedOptions[0].value,
            ConfigTypeDesc:selectedOptions[0].label,
            ConfigTypeItmID: '',
            ConfigTypeItmDesc:'',
            TypeValue:[selectedOptions[0].value,'']
          });
     }
     else{
          this.setState({ 
            ConfigTypeID: '',
            ConfigTypeDesc:'',
            ConfigTypeItmID: '',
            ConfigTypeItmDesc:'',
            TypeValue:[]
          });
     }
     
    
  }
  filter=(inputValue, path)=> {
    return (path.some(option => (option.label).toLowerCase().indexOf(inputValue.toLowerCase()) > -1));
  }
    ///费别，折扣条件，挂号优惠类型是单选关系
    Changeselect=(field, value)=>{
      value =typeof value==='undefined'?'':value
      this.setState({
        [field]: value,
      });
      if (field==="AdmReasonDr")
      {
          this.setState({
            RegPre: '',
            DisCondition:'',
          });
      }
      if (field==="RegPre")
      {
          this.setState({
            AdmReasonDr: '',
            DisCondition:'',
          });
      }
      if (field==="DisCondition")
      {
          this.setState({
            RegPre: '',
            AdmReasonDr:'',
          });
      }
      
    }
     handleUpdate=()=>{
        const { form: { validateFields } } = this.props;
          validateFields((errors, values) => {
            // 验证成功
            if (errors === null) {
              let data = {
                  params: []
              }
              let obj = {};
              obj.UpdateUserDr = this.state.userInfo.userId;
              obj.hospDr = this.state.HospID;
              obj.ID = this.props.ListData.ID;
              obj.AdmReasonDr=this.state.AdmReasonDr
              obj.AdmType=this.state.AdmType
              obj.PrioRity=this.state.PrioRity
              obj.RegPre=this.state.RegPre
              obj.DisCondition=this.state.DisCondition
              obj.StDate=this.state.StDate
              obj.EndDate=this.state.EndDate
              obj.UpData=this.state.UpData
              obj.UpExceptData=this.state.UpExceptData
              // 处理需要传递的obj
              data.params.push(obj);
              $http.post('urlADS', this, {
                code: '05100026',
                data: data,
                success: function (res) { 
                    if (+res.errorCode === 0) {
                      // 提示
                      message.success('折扣记账系数配置成功');
                      //this.handleCancel();
                    }
                },
                error:function (error) {
                    message.error( '折扣记账系数配置失败：' + error);
                }
            })
          }
              
          });
  
      }
    selectloadData = () => {
      let data = {}
      data = {
        params: [{
           code:'',
            className:''
        }]
      }
      $http.post('urlS', this, {
        code: '05100011',
          data: data,
          success: function (res) {
              //费别
              if (+res.errorCode === 0 && res.AdmReasonData) {
                for(var i = 0; i < res.AdmReasonData.length; i++) {
                  this.state.AdmReasonData.push(<Option value={res.AdmReasonData[i].ID} title='AdmReasonDr' key={i}>{res.AdmReasonData[i].Descripts}</Option>)
                }
              }
              //挂号优惠类型 
              if (+res.errorCode === 0 && res.RegPreData) {
                for(var i = 0; i < res.RegPreData.length; i++) {
                  this.state.RegPreData.push(<Option value={res.RegPreData[i].ID} title="RegPre" key={i+1} >{res.RegPreData[i].Descripts} </Option>)
                }
              }
              //医院
              if (+res.errorCode === 0 && res.HospData) {
                for(var i = 0; i < res.HospData.length; i++) {
                  ///本院和下级医院
                  if((this.state.userInfo.hospDr==res.HospData[i].ID)||(this.state.userInfo.hospDr==res.HospData[i].Hosp_Dr))
                  {
                    this.state.HospitalData.push(<Option value={res.HospData[i].ID} title="HospID" key={i+1} disabled={this.state.userInfo.hospDr === res.HospData[i].Hosp_Dr ? true : false}>{res.HospData[i].Descripts} </Option>)
                  }
                }
              }
              //就诊类型
              if (+res.errorCode === 0 && res.AdmTypeData) {
                for(var i = 0; i < res.AdmTypeData.length; i++) {
                  this.state.AdmTypeData.push(<Option value={res.AdmTypeData[i].ID} title="AdmType" key={i+1} >{res.AdmTypeData[i].Descripts} </Option>)
                }
              }
              //折扣条件
              if (+res.errorCode === 0 && res.DisConditionData) {
                for(var i = 0; i < res.DisConditionData.length; i++) {
                  this.state.DisConditionData.push(<Option value={res.DisConditionData[i].ID} title="DisCondition" key={i+1} >{res.DisConditionData[i].Descripts} </Option>)
                }
              }
              //优先级
              if (+res.errorCode === 0 && res.PrioRityData) {
                for(var i = 0; i < res.PrioRityData.length; i++) {
                  this.state.PrioRityData.push(<Option value={res.PrioRityData[i].ID} title="PrioRity" key={i+1} >{res.PrioRityData[i].Descripts} </Option>)
                }
              }
            }
          })
    }
    TypeloadData = () => {
      let data = {}
        data = {
          params: [{
             code:'',
              className:''
          }]
        }
        $http.post('urlS', this, {
          code: '05100032',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.result) {
                  this.setState({
                    Typeoptions: res.result,
                  })
                }
            }
          })
    }
      componentDidMount() {
        this.props.onRef(this);
        this.selectloadData()
        
      }
      // 设置行属性
    selectRow = (record) => {
      return {
          // 单击行选中
          onClick: () => {
              if(this.state.selectrowid===""){
                  this.setState({
                      selectrowid: record.ID,
                  });
              }else{
                  if(this.state.selectrowid!==record.ID){
                      this.setState({
                          selectrowid: record.ID,
                      });
                  }else{
                      this.setState({
                          selectrowid: "",
                      });
                  }
              }
              this.clearsubdata()

          },
          // 双击行编辑
          onDoubleClick: (event) => {
            if (record.ID!=='')
            {
                //存在表的记录是修改，添加到上面去保存
                this.setState({
                  Buttondisplay:'none',
                  HBCIHParRef:record.ID,
                  ConfigTypeID:record.DisCountConfigTypeDr,
                  ConfigTypeItmID:record.ChargeItemDr,
                  Discount:record.Discount,
                  ShareFree:record.ShareFree,
                  ShareFreeAmt:record.ShareFreeAmt,
                  SubStDate:record.StDate,
                  SubEndDate:record.StopDate,
                  Buttondisabled:record.StopDate!==""?true: false,
                  TypeValue:[record.DisCountConfigTypeDr,record.ChargeItemDr]
                })
                
            }
            else{
              //不是表的记录，直接删除
              const DelDataSource = this.state.data;      //列表数组
              DelDataSource.splice(event.target.getAttribute('data-index'), 1);//data-index为获取索引，后面的1为一次去除几行
              const DelDataUpData = this.state.UpData;    //列表数组
              DelDataUpData.splice(event.target.getAttribute('data-index'), 1);//data-index为获取索引，后面的1为一次去除几行
              this.setState({
                data: DelDataSource,
                UpData:DelDataUpData,
              });
            }
              this.setState({
                selectrowid: record.ID,
            });
            },
        }
    }
  // 设置除外项目行属性
  selectExceptRow = (record) => {
    //console.log(record)
      return {
          // 单击行选中
          onClick: () => {
            if(this.state.selectExceptrowid===""){
              this.setState({
                selectExceptrowid: record.ID,
              });
          }else{
              if(this.state.selectExceptrowid!==record.ID){
                  this.setState({
                    selectExceptrowid: record.ID,
                  });
              }else{
                  this.setState({
                    selectExceptrowid: "",
                  });
              }
          }
          this.clearsubdata()
              this.clearsubdata()
          },
          // 双击行编辑
          onDoubleClick: (event) => {
              if (record.ID!=='')
              {
                console.log(record)
                  //存在表的记录是修改，添加到上面去保存
                  this.setState({
                    Buttondisplay:'none',
                    HBCIHParRef:record.ID,
                    ConfigTypeID:record.DisCountConfigTypeDr,
                    ConfigTypeItmID:record.ChargeItemDr,
                    SubStDate:record.StDate,
                    SubEndDate:record.StopDate,
                    Buttondisabled:record.StopDate!==""?true: false,
                    TypeValue:[record.DisCountConfigTypeDr,record.ChargeItemDr]
                  })
                  
              }
              else{
                //不是表的记录，直接删除
                const DelDataSource = this.state.Exceptsdata;      //列表数组
                DelDataSource.splice(event.target.getAttribute('data-index'), 1);//data-index为获取索引，后面的1为一次去除几行
                const DelDataUpData = this.state.UpExceptData;    //列表数组
                DelDataUpData.splice(event.target.getAttribute('data-index'), 1);//data-index为获取索引，后面的1为一次去除几行
                this.setState({
                  Exceptsdata: DelDataSource,
                  UpExceptData:DelDataUpData,
                });
              }
              this.setState({
                selectExceptrowid: record.ID,
            });
            },
        }
    }
    clearsubdata=()=>{
      this.setState({
        Buttondisplay:'',
        HBCIHParRef:'',
        ConfigTypeID:'',
        ConfigTypeDesc:'',
        ConfigTypeItmID:'',
        ConfigTypeItmDesc:'',
        Discount:'',
        ShareFree:'',
        ShareFreeAmt:'',
        SubStDate:moment(new Date(new Date().setDate(new Date().getDate()+1))).format('YYYY-MM-DD'),
        SubEndDate:'',
        TypeValue:[],
        Buttondisabled:true,
      })
    }
      // 重置表单
      resetFields() {
        this.props.form.resetFields(); //清空所有
      }
      // 显示弹出层
      showModal = () => {
        this.setState({
          visible: true,
          divdisplay:"none",
          Notdivdisplay:"none",
          AdmReasonDr:'',
          AdmType:'',
          PrioRity:'',
          RegPre:'',
          DisCondition:'',
          EndDate:'',
          UpData: [],
          UpExceptData:[],
        });
        this.clearsubdata() //清除下面子表数据
        setTimeout(() => {
          this.TypeloadData()
          this.setState({
            divdisplay:this.props.divmentdisplay==="none"?"":"none",
            Notdivdisplay:'none',
            StDate:this.props.ListData.StDate ? moment(this.props.ListData.StDate, 'YYYY-MM-DD'): moment(new Date(new Date().setDate(new Date().getDate()+1))).format('YYYY-MM-DD'),
          });
        }, 0)
        setTimeout(() => {
          this.FindDiscountConfigSubData()
          this.FindDiscountConfigExceptsubData()
        }, 1)
      }
      // 取消
      handleCancel = () => {
        this.setState({
            visible: false,
        }, () => {
        });
      }
      onSelectMenu=(info)=>{
        this.state.HospitalID=info.item.props.eventKey
      }
      updivdisplay=()=>{
        this.setState({
          divdisplay: this.state.divdisplay==='none'?'':'none',
          Notdivdisplay:'none',
        });
        this.clearsubdata()
      }
      Notdivdisplay=()=>{
        this.setState({
          divdisplay: 'none',
          Notdivdisplay:this.state.Notdivdisplay==='none'?'':'none',
        });
        this.clearsubdata()
      }
      addTable=()=>{
        if ((this.state.ConfigTypeID!=='')&(this.state.ConfigTypeItmID===''))
        {
            message.config({
              top: '50%'
            });
            message.error( '请选择'+this.state.ConfigTypeDesc+"里面详细内容,或清空分类",0.8);
            return
        }
        if ((Number(this.state.Discount)===0)&(Number(this.state.ShareFree)===0)&(Number(this.state.ShareFreeAmt)===0))
        {
            message.config({
              top: '50%'
            });
            message.error( "折扣比例系数,记账比例系数,指定金额必输入一个",0.8);
            return
        }
        if (((Number(this.state.Discount)!==0)&(Number(this.state.ShareFree)!==0))||((Number(this.state.Discount)!==0)&(Number(this.state.ShareFreeAmt)!==0))||((Number(this.state.ShareFreeAmt)!==0)&(Number(this.state.ShareFree)!==0)))
        {
            message.config({
              top: '50%'
            });
            message.error( "折扣比例系数,记账比例系数,指定金额,只能输入一个",0.8);
            return
        }
        if(this.state.SubStDate==='')
        {
          message.config({
            top: '50%'
          });
          message.error( "开始日期不能为空",0.8);
          return
        }

        let obj = {};
        obj.DisCountConfigTypeDr = this.state.ConfigTypeID
        obj.DisCountConfigType = this.state.ConfigTypeDesc;
        obj.ChargeItemDr=this.state.ConfigTypeItmID
        obj.ChargeItem=this.state.ConfigTypeItmDesc
        obj.Discount=this.state.Discount
        obj.ShareFree=this.state.ShareFree
        obj.ShareFreeAmt=this.state.ShareFreeAmt
        obj.StDate=moment(this.state.SubStDate).format('YYYY-MM-DD')
        
        obj.StopDate=this.state.SubEndDate
        obj.ID=''
        var olddata =this.state.data;
        var key=Number(this.state.uplistkey)+1
        obj.key=key
        var oldUpData=this.state.UpData
        var objata=[]
        objata.push(obj)
        var Newdata=objata.concat(olddata)
        var NewUpData=objata.concat(oldUpData)
        this.setState({
          data:Newdata,
          UpData:NewUpData,
          uplistkey:key
        });
        this.clearsubdata()
      }
      //除外项目添加
      addExceptTable=()=>{
        if ((this.state.ConfigTypeID!=='')&(this.state.ConfigTypeItmID===''))
        {
            message.config({
              top: '50%'
            });
            message.error( '请选择'+this.state.ConfigTypeDesc+"里面详细内容,或清空分类",0.8);
            return
        }
        if (this.state.ConfigTypeItmID==='')
        {
            message.config({
              top: '50%'
            });
            message.error( '请选择'+this.state.ConfigTypeDesc+"里面详细内容",0.8);
            return
        }
        if(this.state.SubStDate==='')
        {
          message.config({
            top: '50%'
          });
          message.error( "开始日期不能为空",0.8);
          return
        }

        let obj = {};
        obj.DisCountConfigTypeDr = this.state.ConfigTypeID
        obj.DisCountConfigType = this.state.ConfigTypeDesc;
        obj.ChargeItemDr=this.state.ConfigTypeItmID
        obj.ChargeItem=this.state.ConfigTypeItmDesc
        obj.StDate=moment(this.state.SubStDate).format('YYYY-MM-DD')
        obj.StopDate=this.state.SubEndDate
        obj.ID=''
        var olddata =this.state.Exceptsdata;
        var key=Number(this.state.upExceptslistkey)+1
        obj.key=key
        var oldUpData=this.state.UpExceptData
        var objata=[]
        objata.push(obj)
        var Newdata=objata.concat(olddata)
        var NewUpData=objata.concat(oldUpData)
        this.setState({
          Exceptsdata:Newdata,
          UpExceptData:NewUpData,
          upExceptslistkey:key
        });
        this.clearsubdata()
      }
      //修改除外项目
      upExceptsData=()=>{
        const { form: { validateFields } } = this.props;
        validateFields((errors, values) => {
          // 验证成功
          if (errors === null) {
            let data = {
                params: []
            }
            let obj = {};
            obj.ID = this.state.HBCIHParRef
            obj.StopDate=this.state.SubEndDate
            obj.UpdateUserDr = this.state.userInfo.userId;
            // 处理需要传递的obj
            data.params.push(obj);
            $http.post('urlADS', this, {
              code: '05100042',
              data: data,
              success: function (res) { 
                  if (+res.errorCode === 0) {
                    // 提示
                    message.success('修改折扣记账系数除外项目成功');
                    //this.handleCancel();
                  }
              },
              error:function (error) {
                  message.error( '修改折扣记账系数除外项目失败：' + error);
              }
          })
        }
        });
      }
      addItmData=()=>{
        const { form: { validateFields } } = this.props;
        validateFields((errors, values) => {
          // 验证成功
          if (errors === null) {
            let data = {
                params: []
            }
            let obj = {};
            obj.ID = this.state.HBCIHParRef
            obj.StopDate=this.state.SubEndDate
            obj.UpdateUserDr = this.state.userInfo.userId;
            // 处理需要传递的obj
            data.params.push(obj);
            $http.post('urlADS', this, {
              code: '05100036',
              data: data,
              success: function (res) { 
                  if (+res.errorCode === 0) {
                    // 提示
                    message.success('折扣记账系数修改成功');
                    //this.handleCancel();
                  }
              },
              error:function (error) {
                  message.error( '折扣记账系数修改失败：' + error);
              }
          })
        }
        });
      }
      render() {
        const { getFieldDecorator } = this.props.form;
        this.state.userInfo=JSON.parse(window.sessionStorage.userData)
        var disabledflag=this.props.ListData ? this.props.ListData.ID?true: false: false
        return (
          <Modal
            visible={this.state.visible}
            style={{ top: 20}}
            title={this.props.title + "折扣记账系数配置菜单"}
            onCancel={this.handleCancel}
            width='900px'
            footer={[
              <Button key="okText" onClick={this.handleUpdate} style={{background: '#64A982'}}>保存</Button>,
              <Button key="onCancel" onClick={this.handleCancel}>返回</Button>
            ]}
          >
           <div style={{display: this.props.divmentdisplay}}>
          <Form layout="inline" style={{marginTop:"10px"}}>
            <FormItem>
              <Row className="testRowClassName">
              <Form.Item style={{ display: 'inline-block' }}>
                  {getFieldDecorator('HospID', {
                      initialValue:this.props.ListData? this.props.ListData.HospDr : '' ,
                      rules: [{ required: true,message: '请选择医院'  }]
                  })(
                      <Select 
                      showSearch 
                      style={{ width: 200, marginRight: '20px' }} 
                      optionFilterProp="children" 
                      placeholder="请选择医院" 
                      onChange={this.handleChange.bind(this, 'HospID')}
                      disabled={this.props.ListData ? this.props.ListData.ID?true: false: false}
                      filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                      >
                      {this.state.HospitalData}
                      </Select>
                  )}
                </Form.Item>
                <Form.Item style={{ display: 'inline-block' }}>

                  就诊类型  :
                  {getFieldDecorator('AdmType', {
                      initialValue:this.props.ListData.AdmType,
                      rules: [{ required: true,message: '请选择就诊类型'  }]
                  })(
                    <Select 
                          showSearch 
                          style={{ width: 100, marginRight: '20px' }} 
                          placeholder="请选择就诊类型" 
                          onChange={this.handleChange.bind(this, 'AdmType')}
                          disabled={this.props.ListData ? this.props.ListData.ID?true: false: false}
                        >
                          {this.state.AdmTypeData}
                        </Select>
                  )}
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                  优先级  :
                  {getFieldDecorator('PrioRity', {
                      initialValue:this.props.ListData.PrioRity,
                      rules: [{ message: '请优先级'  }]
                  })(
                    <Select 
                          showSearch 
                          style={{ width: 100, marginRight: '20px' }} 
                          placeholder="请优先级 " 
                          onChange={this.handleChange.bind(this, 'PrioRity')}
                          disabled={this.props.ListData ? this.props.ListData.ID?true: false: false}
                        >
                        
                        {this.state.PrioRityData}
                        </Select>
                  )}
                  </Form.Item>
              </Row>
            </FormItem>
          </Form>
          <Form layout="inline">
            <FormItem>
                  <Form.Item style={{ display: 'inline-block' }}>
                  <Tooltip title="注：费别，折扣条件，挂号优惠类型是单选关系,只能维护一个" type="sketch">
                  <span>
                    费别 : 
                        {getFieldDecorator('AdmReasonDr', {
                            initialValue:this.props.ListData.AdmReasonDr,
                            rules: [{message: '请选择费别' }]
                        })(    
                        <Select 
                            showSearch 
                            allowClear={true}
                            style={{ width: 150, marginRight: '20px' }} 
                            placeholder="请选择费别" 
                            optionFilterProp="children" 
                            onChange={this.Changeselect.bind(this, 'AdmReasonDr')}
                            filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                            disabled={((this.state.RegPre === '')&&(this.state.DisCondition==='')) ? disabledflag : true}
                            >
                            {this.state.AdmReasonData}
                        </Select>
                        )}
                        </span>
                    </Tooltip>
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                  <Tooltip title="注：费别，折扣条件，挂号优惠类型是单选关系,只能维护一个" type="sketch">
                  <span>
                    折扣条件 : 
                        {getFieldDecorator('DisCondition', {
                            initialValue:this.props.ListData.DisCondition,
                        })(
                        <Select 
                            showSearch 
                            allowClear={true}
                            style={{ width: 200, marginRight: '20px' }} 
                            placeholder="请选择折扣条件" 
                            optionFilterProp="children" 
                            onChange={this.Changeselect.bind(this, 'DisCondition')}
                            filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                            disabled={((this.state.RegPre === '')&&(this.state.AdmReasonDr==='')) ? disabledflag : true}
                            >
                            {this.state.DisConditionData}
                        </Select>
                        )}
                         </span>
                    </Tooltip>
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                  <Tooltip title="注：费别，折扣条件，挂号优惠类型是单选关系,只能维护一个" type="sketch">
                  <span>
                    挂号优惠类型 : 
                        {getFieldDecorator('RegPre', {
                            initialValue:this.props.ListData.RegPreDr,
                        })(
                        <Select 
                            showSearch 
                            allowClear={true}
                            style={{ width: 200}} 
                            placeholder="请选择挂号优惠类型" 
                            optionFilterProp="children" 
                            onChange={this.Changeselect.bind(this, 'RegPre')}
                            filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                            disabled={((this.state.DisCondition === '')&&(this.state.AdmReasonDr==='')) ? disabledflag : true}
                            
                            >
                            {this.state.RegPreData}
                        </Select>
                        )}
                         </span>
                    </Tooltip>
                  </Form.Item>
                </FormItem>
                <FormItem style={{ left: '30%', }}>
                <Form.Item>
                  {getFieldDecorator('StDate', {
                    initialValue:this.props.ListData.StDate ? moment(this.props.ListData.StDate, 'YYYY-MM-DD'): moment(new Date(new Date().setDate(new Date().getDate()+1)), 'YYYY-MM-DD'),
                    rules: [{ required: true}]      
                  })(
                      <DatePicker
                    style={{ width: 120, marginRight: '10px' }} 
                    placeholder="开始日期"
                    format="YYYY-MM-DD"
                    disabledDate={this.disabledStartDate}
                    showToday={false}
                    disabled={this.props.ListData ? this.props.ListData.ID?true: false: false}
                    onChange={this.onChangeDate.bind(this, 'StDate')} 
                    />
                    )}
                </Form.Item> 
                <Form.Item > 
                  {getFieldDecorator('EndDate', {
                    initialValue:this.props.ListData.StopDate ? moment(this.props.ListData.StopDate, 'YYYY-MM-DD'): null,
                            })(
                    <DatePicker
                    style={{ width: 120, marginRight: '10px' }} 
                    placeholder="结束日期"
                    format="YYYY-MM-DD"
                    showToday={false}
                    disabledDate={this.disabledEndDate}
                    disabled={this.props.ListData.StopDate ? true: false}
                    onChange={this.onChangeDate.bind(this, 'EndDate')} />
                    )}
                </Form.Item> 
                </FormItem>
              </Form>
              </div>
              <div style={{display: this.props.divSubdisplay}}>
              
              <Row>
                <Col span={8}>
                <p style={{fontSize:"12pt"}}>
                  <a onClick={() => this.updivdisplay()}>
                    <Icon type={this.state.divdisplay==='none'?"down-circle":"up-circle"} theme="twoTone" style={{ fontSize: '16px', color: '#08c' }}/>
                    折扣记账系数配置
                    </a>
                    </p>
                </Col>
                <Col span={8} offset={8}>
                <p style={{fontSize:"12pt"}}>
                  <a onClick={() => this.Notdivdisplay()} >
                    <Icon type={this.state.Notdivdisplay==='none'?"down-circle":"up-circle"} style={{ fontSize: '16px', color: '#08c'}}/>
                    不属于折扣内明细
                    </a>
                  </p>
                </Col>
              </Row>
              
              <div style={{display: this.state.divdisplay}}>
              {/* /////折扣记账系数配置 */}
              <Form>
              <FormItem>
                <Form.Item style={{ display: 'inline-block' }}>
                  类型 : 
                  <label>
                      <Cascader
                      value={this.state.TypeValue}
                      style={{width: 300, marginRight: '10px'}} 
                      placeholder="请选择分类" 
                      options={this.state.Typeoptions} 
                      onChange={this.onTypeChange} 
                      showSearch={this.filter}
                      disabled={this.state.HBCIHParRef!==""? true: false}
                      changeOnSelect/>
                  </label>
                </Form.Item>
                <Form.Item style={{ display: 'inline-block' }}>
                  <Tooltip title="注：折扣比例系数,记账比例系数,指定金额,是单选关系,只能维护一个" type="sketch">
                  <span>
                  折扣比例系数 : 
                                <InputNumber
                                 value={this.state.Discount}
                                  style={{width: 70, marginRight: '20px'}}
                                  formatter={value =>`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
                                  parser={value => value.replace(/\$\s?|(,*)/g, '')}
                                  onChange={this.chkPrice.bind(this, 'Discount')}
                                  disabled={this.state.HBCIHParRef!==""? true: false}
                                />
                              
                        </span>
                    </Tooltip>
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                  <Tooltip title="注：折扣比例系数,记账比例系数,指定金额,是单选关系,只能维护一个" type="sketch">
                    <span>
                      记账比例系数 : 
                                <InputNumber
                                  value={this.state.ShareFree}
                                  step={0.01}
                                  style={{width: 70, marginRight: '20px'}}
                                  formatter={value =>`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
                                  parser={value => value.replace(/\$\s?|(,*)/g, '')}
                                  onChange={this.chkPrice.bind(this, 'ShareFree')}
                                  disabled={this.state.HBCIHParRef!==""? true: false}
                                />
                      </span>
                    </Tooltip>
                  </Form.Item>
              </FormItem>
              <FormItem >
              <Form.Item style={{ display: 'inline-block' }}>
                <Tooltip title="注：折扣比例系数,记账比例系数,指定金额,是单选关系,只能维护一个" type="sketch">
                  <span>
                  指定金额 :
                                <InputNumber
                                  value={this.state.ShareFreeAmt}
                                  style={{width: 70, marginRight: '30px'}}
                                  formatter={value =>`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
                                  parser={value => value.replace(/\$\s?|(,*)/g, '')}
                                  onChange={this.chkPrice.bind(this, 'ShareFreeAmt')}
                                  disabled={this.state.HBCIHParRef!==""? true: false}
                                />
                        </span>
                    </Tooltip>
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                    {getFieldDecorator('SubStDate', {
                      initialValue:moment(this.state.SubStDate, 'YYYY-MM-DD'),
                      rules: [{ required: true}]      
                    })(
                        <DatePicker
                          style={{ width: 120, marginRight: '30px' }} 
                          placeholder="开始日期"
                          format="YYYY-MM-DD"
                          disabledDate={this.disabledSubStartDate}
                          showToday={false}
                          onChange={this.onChangeDate.bind(this, 'SubStDate')} 
                          disabled={this.state.HBCIHParRef!==""? true: false}
                          />
                      )}
                  </Form.Item> 
                  <Form.Item style={{ display: 'inline-block' }}> 
                    {getFieldDecorator('SubEndDate', {
                      initialValue:this.state.SubEndDate!=="" ? moment(this.state.SubEndDate, 'YYYY-MM-DD'):null,
                              })(
                      <DatePicker
                        style={{ width: 120, marginRight: '30px' }} 
                        placeholder="结束日期"
                        format="YYYY-MM-DD"
                        showToday={false}
                        disabledDate={this.disabledSubStopDate}
                        onChange={this.onChangeDate.bind(this, 'SubEndDate')} />
                      )}
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                    <div style={{display: this.state.Buttondisplay}}>
                      <Button style={{ marginLeft: '30px',color:'#ff00ff',left: '10%'}} icon="download"  onClick={this.addTable}>增加系数</Button>
                    </div>
                    <div style={{display: this.state.Buttondisplay==='none'?'':'none'}}>
                      <Button type="primary" disabled={this.state.Buttondisabled} style={{ marginLeft: '30px',left: '10%'}} onClick={this.addItmData}>保存</Button>
                    </div>
                  </Form.Item>
              </FormItem>
              <FormItem>
                    <Table
                      dataSource={this.state.data}
                      columns={this.columns}
                      pagination={false}
                      rowClassName={this.setRowClassName}
                      onRow={this.selectRow}
                      bordered
                      loading={this.state.loading}
                      
                    />
                    {/* 分页: total--总条数  defaultCurrent--默认的当前页 hideOnSinglePage--只有一页时隐藏分页器 */}
                    <Pagination
                      size="small"
                      showQuickJumper
                      showSizeChanger
                      defaultCurrent={1}
                      style={{textAlign: "right", marginTop: '13px'}}
                    />
                </FormItem>
              </Form>
              </div>
              <div style={{display: this.state.Notdivdisplay}}>
              {/* ///// 不属于折扣内明细*/}
              <Form>
              <FormItem>
                <Form.Item style={{ display: 'inline-block' }}>
                  类型 : 
                  <label>
                      <Cascader
                      value={this.state.TypeValue}
                      style={{width: 300, marginRight: '10px'}} 
                      placeholder="请选择分类" 
                      options={this.state.Typeoptions} 
                      onChange={this.onTypeChange} 
                      showSearch={this.filter}
                      disabled={this.state.HBCIHParRef!==""? true: false}
                      changeOnSelect/>
                  </label>
                </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                    {getFieldDecorator('SubStDate', {
                      initialValue:moment(this.state.SubStDate, 'YYYY-MM-DD'),
                      rules: [{ required: true}]      
                    })(
                        <DatePicker
                          style={{ width: 120, marginRight: '30px' }} 
                          placeholder="开始日期"
                          format="YYYY-MM-DD"
                          disabledDate={this.disabledSubStartDate}
                          showToday={false}
                          onChange={this.onChangeDate.bind(this, 'SubStDate')} 
                          disabled={this.state.HBCIHParRef!==""? true: false}
                          />
                      )}
                  </Form.Item> 
                  <Form.Item style={{ display: 'inline-block' }}> 
                    {getFieldDecorator('SubEndDate', {
                      initialValue:this.state.SubEndDate!=="" ? moment(this.state.SubEndDate, 'YYYY-MM-DD'):null,
                              })(
                      <DatePicker
                        style={{ width: 120, marginRight: '30px' }} 
                        placeholder="结束日期"
                        format="YYYY-MM-DD"
                        showToday={false}
                        disabledDate={this.disabledSubStopDate}
                        onChange={this.onChangeDate.bind(this, 'SubEndDate')} />
                      )}
                  </Form.Item>
                  <Form.Item style={{ display: 'inline-block' }}>
                    <div style={{display: this.state.Buttondisplay}}>
                      <Button style={{ marginLeft: '30px',color:'#ff00ff',left: '10%'}} icon="download"  onClick={this.addExceptTable}>增加项目</Button>
                    </div>
                    <div style={{display: this.state.Buttondisplay==='none'?'':'none'}}>
                      <Button type="primary" disabled={this.state.Buttondisabled} style={{ marginLeft: '30px',left: '10%'}} onClick={this.upExceptsData}>保存</Button>
                    </div>
                  </Form.Item>
              </FormItem>
              <FormItem>
                    <Table
                      dataSource={this.state.Exceptsdata}
                      columns={this.Notcolumns}
                      pagination={false}
                      rowClassName={this.setExceptRowClassName}
                      onRow={this.selectExceptRow}
                      bordered
                      loading={this.state.Exceptsloading}
                      
                    />
                    {/* 分页: total--总条数  defaultCurrent--默认的当前页 hideOnSinglePage--只有一页时隐藏分页器 */}
                    <Pagination
                      size="small"
                      showQuickJumper
                      showSizeChanger
                      defaultCurrent={1}
                      style={{textAlign: "right", marginTop: '13px'}}
                    />
                </FormItem>
              </Form>
              </div>
              </div>
          </Modal>
          );
      }
    }
  );
export default FormHandel;

FormHandel.propTypes = {
  // 验证userInfo的属性
  userInfo: PropTypes.object
}
