import React from "react";
import {inject, observer} from "mobx-react";
import {Button} from "antd";
import {toJS} from "mobx";
import {WeaSwitch} from "comsMobx";
import {
    WeaTableEdit,
    WeaTableEditable,
    WeaSearchGroup,
    WeaInput,
    WeaFormItem,
    WeaTools,
    WeaRightMenu,
    WeaDialog,
    WeaLocaleProvider,
    WeaSelect,
} from "ecCom";
import * as IntegrationUtil from "../../util/IntegrationUtil";
import {checkTableFieldValueUnique}  from "../../apis/CommonService";

const {getKey} = WeaTools;
const getLabel = WeaLocaleProvider.getLabel;
const store = ["workflowFlowStore"];

@inject(...store)
@observer
export default class RegisterDML extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  getBtns = () => {
    const {workflowFlowStore} = this.props;
    const {buttonLoading, menus=[]} = toJS(workflowFlowStore.status);
    return menus && menus.map(item => <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@8thi7v@integrationWorkflowRegisterDMLButton${item.key}`} type="primary" disabled={buttonLoading} onClick={() => this.onRightMenuClick(item.key)}>
        {item.content}
    </Button>);
  };

  getRightMenu = () => {
    const {workflowFlowStore} = this.props;
    const {buttonLoading, menus=[]} = toJS(workflowFlowStore.status);
    return menus && menus.map(item => {
        return {
          ...item,
          disabled: buttonLoading,
          icon: <i className="icon-coms-Preservation"/>,
          onClick: () => this.onRightMenuClick(item.key),
        }
      });
  } 

  onRightMenuClick = (type) => {
    const {workflowFlowStore,saveCallBack} = this.props;
    const {newRegisterDMLForm, newRegisterDMLFormDMLTriggerConditionSetCustom, newRegisterDMLFormDMLValueSetCustom, dmlEditIndex} = workflowFlowStore;
    const {interfaceRegisterDMLFormHiddenFields,WeaTableEdit_DMLTriggerData,WeaTableEdit_DMLValueData} = toJS(workflowFlowStore.status);
    if (type == "BTN_SAVE" || type == "BTN_TEST") {
        const formParams = newRegisterDMLForm.getFormParams();
        if(formParams.dmltype === 'custom') {
          window.e9HideFormFieldKeys = ['dmltablename'];
        }
        let checkParams = {
            tableName: 'formactionset',
            fieldName: 'dmlactionname',
            fieldValue: formParams.actionname.replace(/^(\s*)|(\s*)$/g, ''),
            idName: 'id',
            idValue: dmlEditIndex
        };
        checkTableFieldValueUnique(checkParams).then(result => {
            if(result&&result.isNotUnique) {
                newRegisterDMLForm.showError('actionname',getLabel('129943','名称已存在'));
            }else {
                IntegrationUtil.onCheck(newRegisterDMLForm, () => {
                    // weatableeditable必填项的验证

                    if(!["insert", "custom"].includes(formParams.dmltype)) {
                      if(this.dmlTrigger && this.dmlTrigger.doValidate) {
                        if(!this.dmlTrigger.doValidate().pass) {
                            return;
                        }
                      }  
                    }

                    if(!["delete", "custom"].includes(formParams.dmltype)) {
                      if(this.dmlValue && this.dmlValue.doValidate) {
                        if(!this.dmlValue.doValidate().pass) {
                            return;
                        }
                      }  
                    }

                    let params = Object.assign(interfaceRegisterDMLFormHiddenFields, formParams
                        ,newRegisterDMLFormDMLTriggerConditionSetCustom.getFormParams(),newRegisterDMLFormDMLValueSetCustom.getFormParams());
                    params.dtinfo_WeaTableEdit_DMLValueData = ("delete" === formParams.dmltype ? '' : JSON.stringify(WeaTableEdit_DMLValueData));
                    params.dtinfo_WeaTableEdit_DMLTriggerData = ("insert" === formParams.dmltype ? '' : JSON.stringify(WeaTableEdit_DMLTriggerData));

                    if(params.actionid){
                        params.operate = "edit";
                    }else{
                        params.operate = "add";
                    }
                    workflowFlowStore.getInterfaceRegisterDMLOperation(params, saveCallBack, type);

                });
            }
        });
    }
  };

  getWeaSwitch = (form, condition, items) => {
    const {workflowFlowStore} = this.props;
    const {newRegisterDMLForm, status, dmlEditIndex} = workflowFlowStore;
    const {DMLTriggerConditionSet, DMLValueSet, interfaceRegisterDMLFormHiddenFields, interfaceRegisterDMLFormFields} = toJS(status);
    const {isFormInit} = newRegisterDMLForm;
    let bottomDis = 0;
    const formParams = form.getFormParams();

    form.isFormInit && isFormInit &&  condition.items && condition.items.map((field,index) => {
        if(field) {
            let wrapperCol = field.fieldcol;
            if(getKey(field)=='dmlmainsqltype'){
                wrapperCol=10
            }
            if(getKey(field)=='dmlsourceinfo') {
                bottomDis = 15;
            }else {
                bottomDis = 0;
            }
            if(getKey(field) === 'dmltablename') {
              if(form.getFormParams().dmltype === "custom") {
                field.viewAttr = 2;
              }
            } 
            items.push({
                com: (
                    <div style={{marginBottom: bottomDis}}>
                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@17o1rh@integrationWorkflowRegisterDMLForm${field.domkey[0]}`}
                        label={`${field.label}`}
                        labelCol={{span: `${field.labelcol}`}}
                        wrapperCol={{span: wrapperCol}}
                        error={form.getError(field)}
                        tipPosition="bottom"
                    >
                        <nobr>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@dgs1aa@integrationWorkflowRegisterDMLForm${field.domkey[0]}`}
                            fieldConfig={field}
                            form={form}
                            formParams={formParams}
                            onChange={(v)=> {
                                if(getKey(field) === 'formid') {
                                    let formid = form.getFormParams().formid;
                                    if(formid != formParams.formid) {
                                        let isBill = 0;
                                        if(formid<0) {
                                            isBill = 1;
                                        }
                                        workflowFlowStore.getInterfaceRegisterDMLOperation({ajaxMethod: 'getmaintablename', formid: formid,isbill:isBill});
                                        DMLValueSet.ColumnsConfig[2].com[0].browserConditionParam.dataParams.formid=formid;
                                        DMLValueSet.ColumnsConfig[2].com[0].browserConditionParam.dataParams.isbill=isBill;
                                        DMLTriggerConditionSet.ColumnsConfig[2].com[0].browserConditionParam.dataParams.formid=formid;
                                        DMLTriggerConditionSet.ColumnsConfig[2].com[0].browserConditionParam.dataParams.isbill=isBill;
                                        workflowFlowStore.setState({DMLValueSet:DMLValueSet});
                                        workflowFlowStore.setState({DMLTriggerConditionSet:DMLTriggerConditionSet});
                                    }
                                }else if(getKey(field) === 'dmltablename') {
                                    this.lianDong1();
                                }else if(['datasourceid', "tempdmltablename"].includes(getKey(field))) {
                                    if(getKey(field) === "datasourceid") {
                                        this.lianDong1();
                                    }else if(getKey(field) === "tempdmltablename") {
                                        let dmlformname = (v.tempdmltablename && v.tempdmltablename.valueObj && v.tempdmltablename.valueObj[0]) ? v.tempdmltablename.valueObj[0].name : "";
                                        let dmltablename = (v.tempdmltablename && v.tempdmltablename.valueObj && v.tempdmltablename.valueObj[0]) ? v.tempdmltablename.valueObj[0].other1 : "";
                                        form.updateFields({dmltablename});
                                        let params1 = Object.assign({}, interfaceRegisterDMLFormHiddenFields,{dmlformname});
                                        workflowFlowStore.setState({interfaceRegisterDMLFormHiddenFields: params1});
                                        this.lianDong1();
                                    }
                                    let datas = [...interfaceRegisterDMLFormFields], index = -1;
                                    if(datas[1] && datas[1].items) {
                                        index = datas[1].items.findIndex(data => data.domkey[0] === "dmltablename");
                                        if(index != -1) {
                                        const {datasourceid, tempdmltablename} = form.getFormParams();
                                        if((!datasourceid) && tempdmltablename) {
                                            datas[1].items[index].viewAttr = 1;
                                            datas[1].items[index].hasBorder = true;  
                                        }else {
                                            datas[1].items[index].viewAttr = 3;  
                                        }
                                        workflowFlowStore.setState({interfaceRegisterDMLFormFields: datas});
                                        }
                                    }
                                }else if(getKey(field) === 'dmlsourceinfo') {
                                    workflowFlowStore.liandongDMLSourceId(form);
                                }else if(getKey(field) === 'actionname') {
                                    let checkParams = {
                                        tableName: 'formactionset',
                                        fieldName: 'dmlactionname',
                                        fieldValue: form.getFormParams().actionname.replace(/^(\s*)|(\s*)$/g, ''),
                                        idName: 'id',
                                        idValue: dmlEditIndex
                                    };
                                    checkTableFieldValueUnique(checkParams).then(result => {
                                        if(result&&result.isNotUnique) {
                                        form.showError('actionname',getLabel('129943','名称已存在'));
                                        }
                                    });
                                }
                            }}
                        />
                            {getKey(field) === 'dmlmainsqltype' ? <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@fai7ir@integrationWorkflowRegisterDMLButton${field.domkey[0]}`} size="small" style={{marginLeft:10}} onClick={() => {window.location.href = `${window.ecologyContentPath || ""}/integration/docs/dmlaction/readme.docx`;}} >{getLabel(15593, "帮助文档")}</Button>:<span />}
                        </nobr>
                    </WeaFormItem>
                    </div>
                ),
                colSpan: 1,
                hide: form.isHide(field, (keys, allParams) => {
                    let bool = false;
                    getKey(field) === 'tempdmltablename' && allParams.datasourceid != '' && (bool = true);
                    return bool;
                })
            });
        }
    });
  }

  /**
   * 明细浏览按钮关联主表字段的相关联动处理
   */
  lianDong1=()=>{
    const {workflowFlowStore} = this.props;
    const {newRegisterDMLForm, status} = workflowFlowStore;
    const {DMLTriggerConditionSet, DMLValueSet} = toJS(status);
    let {datasourceid, dmltablename} = newRegisterDMLForm.getFormParams();
    DMLValueSet.ColumnsConfig[0].com[0].browserConditionParam.dataParams={dmltablename, datasourceid}
    DMLTriggerConditionSet.ColumnsConfig[0].com[0].browserConditionParam.dataParams={dmltablename, datasourceid}
    workflowFlowStore.setState({DMLValueSet:DMLValueSet, DMLTriggerConditionSet:DMLTriggerConditionSet});
  }

  /**
   * 初始渲染明细表
   * @param mainFieldListColumnsSet 明细表的配置数据
   * @param newForm
   */
  initColumnsSet=(columnsSet,columnsSetData,storeKey)=>{
    //转换规则逻辑  
    columnsSet[6].com[0].type = 'custom';
    columnsSet[6].com[0].render=(text, record, index, onEdit) => {

        if(storeKey=="WeaTableEdit_DMLValueData"){
            let extravalue = record['extravalue'];
            if(record.transttypevalue==1||record.transttypevalue==7){
                return (<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@3zm4xr`} onChange={(value)=>{let key='extravalue' ; onEdit({record, index,key , value})}} value={extravalue} fieldName={'extravalue'}  />)
            }else{
                return (<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@hcnt2i`} onChange={(value)=>{let key='extravalue' ; onEdit({record, index,key , value})}} value={''} fieldName={'extravalue'} style={{display:'none'}} />)
            }
        }else{
            let extravalue = record['extrawhere'];
            if(record.transttypewhere==1||record.transttypewhere==7){
                return (<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@9dvowo`} onChange={(value)=>{let key='extrawhere' ; onEdit({record, index,key , value})}} value={extravalue} fieldName={'extrawhere'}  />)
            }else{
                return (<WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@46i57s`} onChange={(value)=>{let key='extrawhere' ; onEdit({record, index,key , value})}} value={''} fieldName={'extrawhere'} style={{display:'none'}} />)
            }
        }
    }

    // 转换规则下拉框的渲染   transttypewhere
    columnsSet[5].com[0].type = 'custom';
    columnsSet[5].com[0].render=(text, record, index, onEdit) => {
        let key = 'WeaTableEdit_DMLValueData' === storeKey ? 'transttypevalue' : 'transttypewhere';
        let options = record.com && record.com[key] && record.com[key].length ? record.com[key][0].options || [] : [];

        return <WeaSelect 
          ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@hfzeph`} 
          value={record[key] || ''}
          options={options}
          onChange={value => onEdit({record, index, key, value})}
        />
    }
  }

  // 触发条件的onChange事件
  onChangeTriggerCondition = (datas) => {

    this.handleChangeTableValue(datas, 'dmltrigger');
  }

  // 编辑触发条件
  willEditTriggerCondition = (allDatas, editData) => {

    return this.willEdit(allDatas, editData, 'dmltrigger');
  }

  // 新增触发条件
  willAddTriggerCondition = (allDatas, addData) => {

    return this.willAdd(allDatas, addData, 'dmltrigger');
  }

  willEdit = (allDatas, editData, type) => {
    
    const {
      workflowFlowStore,
    } = this.props, {
      key,
      index,
    } = editData;
    const editRow = allDatas[index];
    
    if("fieldname" === key) {
    
      // 字段名称变化
      let fielddbtype = '';
      const {
        fieldname,
        wherefieldshow,
        dmlfieldshow,
      } = editRow;
      
      if(editData.browserDatas && editData.browserDatas.length) {
        fielddbtype = editData.browserDatas[0].fielddbtype;
      } 
      allDatas[index] = {
        ...allDatas[index],
        showtype: fielddbtype,
        ['dmlvalueset' == type ? "dmlfieldname" : "wherefieldname"]: fieldname+"="+fielddbtype+"="+('dmlvalueset' == type ? dmlfieldshow : wherefieldshow)
      }
    }  else if (["wherefieldnametemp", "dmlfieldnametemp"].includes(key)) {

        // 条件对应字段
        let jfieldname = '',
          jfielddbtype = '',
          bean = '',
          transformValue = '',
          extraValue = '';
        const {
          fieldname,
          showtype,
        } = editRow;
        let transformKey = 'dmlvalueset' == type ? "transttypevalue" : "transttypewhere";
        let extraKey = 'dmlvalueset' == type ? "extravalue" : "extrawhere";

        if(editData.browserDatas && editData.browserDatas.length) {
            jfieldname = editData.browserDatas[0].jfieldname;
            jfielddbtype = editData.browserDatas[0].jfielddbtype;
            bean = editData.browserDatas[0].bean;
            transformValue = editRow[transformKey];
            extraValue = editRow[extraKey];
        }
        allDatas[index] = {
            ...allDatas[index],
            ['dmlvalueset' == type ? "dmlfieldshow" : "wherefieldshow"]: jfieldname,
            ['dmlvalueset' == type ? "dmlshowtype" : "whereshowtype"]: jfielddbtype,
            ['dmlvalueset' == type ? "dmlfieldname" : "wherefieldname"]: fieldname+"="+showtype+"="+jfieldname,
            [transformKey]: transformValue,
            extravalue: extraValue,
        }
          
        // 调用接口动态获取转换规则下拉框的值
        if(bean){
            const {
              fieldhtmltype,
              fieldtype,  
            } = JSON.parse(bean);
            
            workflowFlowStore.getInterfaceRegisterDMLOperation({ajaxMethod: 'getDMLTransRulesList', fieldhtmltype, fieldtype, type},(options) => {
                if(options){
                    allDatas[index] = {
                        ...allDatas[index],
                        com: options,
                    }
                    if(type=='dmlvalueset'){
                        workflowFlowStore.setState({WeaTableEdit_DMLValueData: allDatas});
                    }else if(type=='dmltrigger'){
                        workflowFlowStore.setState({WeaTableEdit_DMLTriggerData: allDatas});
                    }
                }
            });
        } else {
            allDatas[index] = {
                ...allDatas[index],
                com: [],
            }
            if(type=='dmlvalueset'){
                workflowFlowStore.setState({WeaTableEdit_DMLValueData: allDatas});
            }else if(type=='dmltrigger'){
                workflowFlowStore.setState({WeaTableEdit_DMLTriggerData: allDatas});
            }
        }
    }

    return allDatas;
  }

  handleChangeTableValue = (datas, type) => {

    const {workflowFlowStore} = this.props;

    if ('dmlvalueset' === type) {
      workflowFlowStore.setState({WeaTableEdit_DMLValueData: datas});
    } else if ('dmltrigger' === type) {
      workflowFlowStore.setState({WeaTableEdit_DMLTriggerData: datas});
    }
  }

  willAdd = (allDatas=[], addData, type) => {
    let index = allDatas && allDatas.findIndex(item => item.id === addData.id);

    allDatas[index] = {
        ...allDatas[index],
        ['dmlvalueset' == type ? "transttypevalue" : "transttypewhere"]: '',
        ['dmlvalueset' == type ? "extravalue" : "extrawhere"]: '',
    }

    return allDatas;
  }

  // 赋值条件的onchange事件
  onChangeValueCondition = (datas) => {

    this.handleChangeTableValue(datas, 'dmlvalueset');
  }

  // 编辑赋值条件
  willEditValueCondition = (allDatas, editData) => {

    return this.willEdit(allDatas, editData, 'dmlvalueset');
  }

  // 新增赋值条件
  willAddValueCondition = (allDatas, addData) => {

    return this.willAdd(allDatas, addData, 'dmlvalueset');
  }

  getSearchs = () => {
    const {workflowFlowStore} = this.props;
    const {newRegisterDMLForm, newRegisterDMLFormDMLTriggerConditionSetCustom, newRegisterDMLFormDMLValueSetCustom, status} = workflowFlowStore;
    const {interfaceRegisterDMLFormFields, DMLTriggerConditionSet, DMLValueSet, WeaTableEdit_DMLValueData, WeaTableEdit_DMLTriggerData,} = toJS(status);
    const {isFormInit} = newRegisterDMLForm;
    const GroupTitle = [
        {id: "f1302008-75dd-11e8-adc0-fa7ae01bbebc", title: `${getLabel(81711, "基本信息")}`},
        {id: "f1302436-75dd-11e8-adc0-fa7ae01bbebc", title: `DML${getLabel(30747, "设置")}`},
        {id: "f1302684-75dd-11e8-adc0-fa7ae01bbebc", title: `${getLabel(384164, "条件设置")}`},
        {id: "f13028aa-75dd-11e8-adc0-fa7ae01bbebc", title: `${getLabel(21845, "赋值设置")}`},
        {id: "f1302ada-75dd-11e8-adc0-fa7ae01bbebc", title: `DML${getLabel(19010, "操作说明")}`}
    ];

    let group = [], i = 0;
    const formParams = newRegisterDMLForm.getFormParams();
    isFormInit &&
    interfaceRegisterDMLFormFields &&
    interfaceRegisterDMLFormFields.forEach(c => {
        let items = [];
        switch (c.id) {
            // 条件设置
            case GroupTitle[2].id:
              if('insert' != formParams.dmltype) {
                const DMLTriggerConditionSetCondition = DMLTriggerConditionSet.Custom[0];
                this.initColumnsSet(DMLTriggerConditionSet.ColumnsConfig, WeaTableEdit_DMLTriggerData, 'WeaTableEdit_DMLTriggerData');
                items.push({
                    com: (
                        <WeaTableEditable 
                            ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEditable@cv406q@${c.id}`} 
                            ref={el => this.dmlTrigger = el}
                            title={`DML where${getLabel('384164','条件设置')}`}
                            deleteConfirm="true"
                            showCopy={false}
                            tableProps={{showEmptyText: false,scroll: {"x": 750}}}
                            validator={{
                              rules: {
                                "fieldname": "required",
                                "wherefieldnametemp": "required"
                              }
                            }}
                            columns={DMLTriggerConditionSet.ColumnsConfig}
                            datas={WeaTableEdit_DMLTriggerData}
                            willEdit={this.willEditTriggerCondition}
                            willAdd={this.willAddTriggerCondition}
                            onChange={this.onChangeTriggerCondition}
                        />
                        ),
                        hide: newRegisterDMLForm.isHide(
                            DMLTriggerConditionSetCondition,
                            (keys, allParams) => {
                                return (
                                    allParams.dmltype === "insert" ||
                                    allParams.dmltype === "custom"
                                );
                            }
                        )
                    });
                    // 自定义触发条件
                    this.getWeaSwitch(
                        newRegisterDMLFormDMLTriggerConditionSetCustom,
                        DMLTriggerConditionSetCondition,
                        items
                    );
              }
              break;
            // 赋值设置
            case GroupTitle[3].id:
              const DMLValueSetField = DMLValueSet.Custom[0];
              if('delete' != formParams.dmltype) {
                this.initColumnsSet(DMLValueSet.ColumnsConfig, WeaTableEdit_DMLValueData, 'WeaTableEdit_DMLValueData');
                items.push({
                    com: (
                        <WeaTableEditable 
                            ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEditable@d9v5rj@${c.id}`} 
                            ref={el => this.dmlValue = el}
                            title={`DML${getLabel(21845, "赋值设置")}`}
                            tableProps={{showEmptyText: false,scroll: {"x": 750}}}
                            validator={{
                                rules: {
                                  "fieldname": "required",
                                  "dmlfieldnametemp": "required"
                                }
                            }}
                            deleteConfirm="true"
                            showCopy={false}
                            columns={DMLValueSet.ColumnsConfig}
                            datas={WeaTableEdit_DMLValueData}
                            willEdit={this.willEditValueCondition}
                            willAdd={this.willAddValueCondition}
                            onChange={this.onChangeValueCondition}
                        />
                    ),
                    hide: newRegisterDMLForm.isHide(
                      DMLValueSetField,
                        (keys, allParams) => {
                            return (
                                allParams.dmltype === "custom"
                            );
                        }
                    )
                });
              }
              this.getWeaSwitch(
                newRegisterDMLFormDMLValueSetCustom,
                DMLValueSetField,
                items
              );
              break;
            case GroupTitle[4].id:
                //添加DML操作说明
                items.push({
                    com: (
                        <div style={{marginLeft:-35}}>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10,color:'red'}}>1、{getLabel(27673,'请谨慎使用update，delete操作')}</span></div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>2、{getLabel(130498,'可以同步当前流程的主表或者明细表数据到其他数据表中')}</span></div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>3、{getLabel(130499,'如果DML类型为update、delete，那么必须有DML触发条件或者自定义触发条件，否则此DML不被执行')}</span></div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>4、{getLabel(27676,'对各数据库中大对象数据类型字段，以及二进制数据类型字段不做同步，具体如下')}：</span>
                                <div style={{marginLeft:30}}>SQLSERVER:binary,varbinary,image</div>
                                <div style={{marginLeft:30}}>ORACLE:raw,long raw,blob,clob,nclob,bfile,rowid</div>
                                <div style={{marginLeft:30}}>MYSQL:BLOB,ENUM,SET</div>
                                <div style={{marginLeft:30}}>DB2:GRAPHIC,VARGRAPHIC,LONG VARCHAR,CLOB,LONG VARGRAPHIC,DBCLOB,BLOB</div>
                                <div style={{marginLeft:30}}>SYSBASE:text,image</div>
                                <div style={{marginLeft:30}}>INFORMIX:text,byte</div>
                            </div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}>
                                <div style={{marginLeft:10}}>5、{getLabel('390178','对于自定义触发条件，具体格式如下:\n')}</div>
                                <div style={{marginLeft:30}}>{getLabel(390179, '      userid={?流程字段名称A} and lastname=\'{?流程字段名称B}\' and ....\n')}</div>
                                <div style={{marginLeft:30}}>{getLabel(390180, '      sql中，'+'以字段名开始(不能以where或者and开始)，{?流程字段名称*}将会被替换为流程中的对应字段的数据。具体sql格式，根据数据源数据库类型决定。')}</div>
                            </div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}>
                                <div style={{marginLeft:10}}>6、{getLabel('390181','对于自定义DML语句，具体格式如下：\n')}</div>
                                <div style={{marginLeft:30}}>{`      update hrmresource set lastname=\'{?${getLabel(27678, "流程字段名称")}A}\',mobile=\'{?${getLabel(27678, "流程字段名称")}}\' ... where userid={?${getLabel(27678, "流程字段名称")}C} and ...\n`}</div>
                                {/* <div style={{marginLeft:30}}>{getLabel(390182, '      update hrmresource set lastname=\'{?流程字段名称A}\',mobile=\'{?流程字段名称B}\' ... where userid={?流程字段名称C} and ...\n')}</div> */}
                                <div style={{marginLeft:30}}>{getLabel(390183, '      sql中，{?流程字段名称*}将会被替换为流程中的对应字段的数据。具体sql格式，根据数据源数据库类型,以及字段类型决定。')}</div>
                            </div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}>
                                <div style={{marginLeft:10}}>7、{getLabel('390184','对于转换规则中的自定义SQL,具体格式如下:\n')}</div>
                                <div style={{marginLeft:30}}>{`      oracle${getLabel('15024', "数据库")}：select lastname from hrmresource where id={?${getLabel(27678, "流程字段名称")}B} and ... \n`}</div>
                                {/* <div style={{marginLeft:30}}>{getLabel(390185, '      oracle数据库：select lastname from hrmresource where id={?流程字段名称B} and ... \n')}</div> */}
                                <div style={{marginLeft:30}}>{getLabel(390183, '      sql中，{?流程字段名称*}将会被替换为流程中的对应字段的数据。具体sql格式，根据数据源数据库类型,以及字段类型决定。')}</div>
                            </div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}>
                                <div style={{marginLeft:10}}>8、{getLabel('390186','由于各数据库中，日期数据类型不同，为保证数据正确同步，建议使用自定义DML语句，比如：\n')}</div>
                                <div style={{marginLeft:30}}>{`      oracle${getLabel('15024', "数据库")}：update hrmresource set b.birthday=to_date(\'{?${getLabel(27678, "流程字段名称")}A}\',\'YYYY-MM-DD\') ... where userid={?${getLabel(27678, "流程字段名称")}B} and ...`}</div>
                                {/* <div style={{marginLeft:30}}>{getLabel(390187, '      oracle数据库：update hrmresource set b.birthday=to_date(\'{?流程字段名称A}\',\'YYYY-MM-DD\') ... where userid={?流程字段名称B} and ...')}</div> */}
                            </div>
                            <div class='badge' style={{paddingLeft:5,paddingBottom:10}}>
                            <div style={{marginLeft:10}}>9、{getLabel(508540,'自定义DML语句类型为存储过程时，输入格式如下:')}</div>
                            <div style={{marginLeft:30}}>{`      ${getLabel(508541, "Oracle : procedurename(\'{?流程字段名称A}\',\'{?流程字段名称B}\'....)" )}`}</div>
                            <div style={{marginLeft:30}}>{`      ${getLabel(508542, "SQL SERVER: procedurename \'{?流程字段名称A}\',\'{?流程字段名称B}\'...." )}`}</div>
                            </div>
							<div class='badge' style={{paddingLeft:5,paddingBottom:10}}>
                            	<div style={{marginLeft:10}}>10、{getLabel(522896,'流程字段名称若为明细表，需要{?d.流程字段名称A}')}</div>
                            </div>
                        </div>
                    ),
                    colSpan: 1
                });
                break;
            default:
                this.getWeaSwitch(newRegisterDMLForm, c, items);
                break;
        }
        let center = false, title = c.title, needTigger = true;
        if (![GroupTitle[0].id, GroupTitle[1].id].includes(c.id) && c.id !== "") {
            center = false;
        } else {
            center = true;
        }

        if('insert' === formParams.dmltype && GroupTitle[2].id === c.id) {
          title = '';
          needTigger = false;
        }
        group.push(
            <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@unhm8j@integrationWorkflowRegisterDMLForm${c.id}`}
                center={center}
                col={1}
                needTigger={needTigger}
                title={title}
                showGroup={c.defaultshow}
                items={items}
            />
        );
        i++;
    });
    return group;
  };

  render() {
    const {workflowFlowStore} = this.props;
    const {flag} = workflowFlowStore;
    const {showRegisterDMLDialog, interfaceRegisterDMLFormHiddenFields} = workflowFlowStore.status;
    let title = getLabel('83316', '注册DML接口');
    if(interfaceRegisterDMLFormHiddenFields && interfaceRegisterDMLFormHiddenFields.actionid&&interfaceRegisterDMLFormHiddenFields.actionid>0) {
      title = getLabel('26473,82986', '编辑DML接口');
    }

    return (
      <div className="wea-integration-single">
        <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@sy5gl9`}
          title={title}
          icon="icon-coms-integration"
          iconBgcolor="#1a57a0"
          visible={showRegisterDMLDialog}
          hasScroll={true}
          style={{width: 900, height: 600}}
          onCancel={() => {
            workflowFlowStore.setState({showRegisterDMLDialog: false});
            workflowFlowStore.newRegisterDMLForm.reset();
          }}
          buttons={this.getBtns()}
          moreBtn={{
            datas: this.getRightMenu(),
            collectParams: []
          }}
        >
          <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@usm99l`} datas={this.getRightMenu()} collectParams={[]}>
            {flag && this.getSearchs()}
          </WeaRightMenu>
        </WeaDialog>
      </div>
    );
  }
}
