// import React from "react";
// import {inject, observer} from "mobx-react";
// import {Badge, Button,message} from "antd";
// import {toJS} from "mobx";
// import {WeaForm, WeaSwitch} from "comsMobx";
// import {checkTableFieldValueUnique}  from "../../apis/CommonService";
// import {
//     WeaBrowser,
//     WeaButton,
//     WeaDialog,
//     WeaDropdown,
//     WeaFormItem,
//     WeaInput,
//     WeaLocaleProvider,
//     WeaRightMenu,
//     WeaSearchGroup,
//     WeaSelect,
//     WeaTableEdit,
//     WeaTag,
//     WeaTools
// } from "ecCom";

// const { getKey } = WeaTools;
// const getLabel = WeaLocaleProvider.getLabel;

// const store = ["tencentMailStore"];


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



//     getBtns = () => {
//         let btns = []
//         btns = [
//           <Button type='primary' onClick={() => this.onRightMenuClick('BTN_SAVE')}>{getLabel(86,'保存')}</Button>
//           ,<Button type='primary' onClick={() => this.onRightMenuClick('BTN_SAVE_AND_OPEN')}>{getLabel(125540,'保存后详细设置')}</Button>
//           // ,<Button type='primary' onClick={() => this.onRightMenuClick('BTN_CHECK')}>{getLabel(32367,'有效性检查')}</Button>
//         ];

//         return btns;
//     }
//     getRightMenu() {
//         const {tencentMailStore} = this.props;
//         let btnArr = [
//             {
//                 key: 'BTN_SAVE',
//                 icon: <i className='icon-coms-Preservation'/>,
//                 content : `${getLabel(86,'保存')}`,
//                 onClick : () => this.onRightMenuClick('BTN_SAVE')
//             },
//             {
//                 key: 'BTN_SAVE_AND_OPEN',
//                 icon: <i className='icon-coms-Preservation'/>,
//                 content : `${getLabel(125540,'保存后详细设置')}`,
//                 onClick : () => this.onRightMenuClick('BTN_SAVE_AND_OPEN')
//             }
//         ]
//         return btnArr;
//     }
//     onRightMenuClick = (type,recordId) => {
//         const {tencentMailStore} = this.props;
//         const {newForm, status} = tencentMailStore;
//         const { TriggerFormHiddenFields } = toJS(tencentMailStore.status);
//         const formParams = newForm.getFormParams();

//         let checkParams = {
//             tableName: 'outerdatawfset',
//             fieldName: 'setname',
//             fieldValue: newForm.getFormParams().setname.replace(/^(\s*)|(\s*)$/g, ''),
//             idName: 'id',
//             idValue: tencentMailStore.settingRegisterID
//         };

//         if(type == 'BTN_SAVE'){
//             checkTableFieldValueUnique(checkParams).then(result => {
//                 if(result&&result.isNotUnique) {
//                     newForm.showError('setname',getLabel('129943','名称已存在'));
//                     return;
//                 }
//                 newForm.validateForm().then(f=>{
//                     if(f.isValid){
//                         var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
//                         var valdata = formParams.whitelist.split(',');
 
//                         for(let i=0;i<valdata.length;i++){
//                             if(valdata[i].trim()) {
//                                 if(reg.test(valdata[i]) == false){
//                                     newForm.showError('whitelist', 'Ip格式不正确')
//                                     return;
//                                 }
//                             }
//                         }

//                         tencentMailStore.getTriggerOperation({setname:newForm.getFormParams().setname,operate:'checkShowName',viewid:newForm.getFormParams().viewid},(result)=>{
//                         if(result&&result.errorMsg){
//                             message.error(result.errorMsg);
//                             return;
//                         }else{
//                             //合并hiddenfield参数
//                             let params = Object.assign(TriggerFormHiddenFields, newForm.getFormParams());
//                             params.operate = "add";
//                             tencentMailStore.getTriggerOperation(params);
//                         }
//                         });
//                     }else{
//                         f.showErrors();
//                         this.setState({date: new Date()});
//                     }
//                 }); 
//             });
//         }
//         if(type == 'BTN_SAVE_AND_OPEN'){
//             checkTableFieldValueUnique(checkParams).then(result => {
//                 if(result&&result.isNotUnique) {
//                     newForm.showError('setname',getLabel('129943','名称已存在'));
//                     return;
//                 }else {
//                     newForm.validateForm().then(f=>{
//                         if(f.isValid){
//                           var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
//                           var valdata = formParams.whitelist.split(',');
 
//                           for(let i=0;i<valdata.length;i++){
//                             if(valdata[i].trim()) {
//                                 if(reg.test(valdata[i]) == false){
//                                     newForm.showError('whitelist', 'Ip格式不正确')
//                                     return;
//                                 }
//                             }
//                           }
                          
//                           tencentMailStore.getTriggerOperation({setname:newForm.getFormParams().setname,operate:'checkShowName',viewid:newForm.getFormParams().viewid},(result)=>{
//                             if(result&&result.errorMsg){
//                               message.error(result.errorMsg);
//                               return;
//                             }else{
//                               //合并hiddenfield参数
//                               let params = Object.assign(TriggerFormHiddenFields, newForm.getFormParams());
//                               params.operate = "add";
//                               tencentMailStore.getTriggerOperation(params,(result)=>{
//                                 tencentMailStore.newForm=new WeaForm();
//                                 tencentMailStore.getTriggerAddForm({ viewid: result.id });
//                                 tencentMailStore.setState({ showNewFormDialog: false });
//                                 tencentMailStore.getTriggerEditDetailForm({ viewid: result.id });
//                                 tencentMailStore.setState({ showNewDetailFormDialog: true, newDetailFormSelectedKey : 1 });
//                                 tencentMailStore.setSetRettingRegisterID(result.id);
//                               });
//                             }
//                           });
//                         }else{
//                             f.showErrors();
//                             this.setState({date: new Date()});
//                         }
//                     });
//                 }
//             })
//         }
//     }

//     getSearchs = () => {
//         const {tencentMailStore} = this.props;
//         const {newForm, status} = tencentMailStore;
//         const {TriggerFormFields} = toJS(status);
//         const {isFormInit} = newForm;
//         let group = [];
//         let i = 0;
//         const formParams = newForm.getFormParams();
//         isFormInit && TriggerFormFields && TriggerFormFields.map(c =>{
//             let items = [];

//             c.items.map(fields => {

//                 items.push({
//                     com:(
//                         <WeaFormItem
//                             label={`${fields.label}`}
//                             labelCol={{span: `${fields.labelcol}`}}
//                             wrapperCol={{span: `${fields.fieldcol}`}}
//                             error={newForm.getError(fields)}
//                             tipPosition="bottom"
//                         >

//                             <WeaSwitch fieldConfig={fields} form={newForm} formParams={formParams}  onChange={v=> {
//                                 if(getKey(fields) === 'workFlowId' ) {
//                                     tencentMailStore.newForm = new WeaForm();
//                                     tencentMailStore.getTriggerAddForm(newForm.getFormParams());
//                                     this.setState({TriggerFormFields: TriggerFormFields});
//                                 }else if(getKey(fields) === 'outermaintable') {
//                                     let outermaintable = newForm.getFormParams().outermaintable;
//                                     let datasourceid = newForm.getFormParams().datasourceid;
//                                     TriggerFormFields[0] && TriggerFormFields[0].items && TriggerFormFields[0].items.find(field => field.domkey[0] == 'keyfield') && (TriggerFormFields[0].items.find(field => field.domkey[0] == 'keyfield').browserConditionParam.dataParams={dmltablename:outermaintable,datasourceid:datasourceid});
//                                     TriggerFormFields[0] && TriggerFormFields[0].items && TriggerFormFields[0].items.find(field => field.domkey[0] == 'requestid') && (TriggerFormFields[0].items.find(field => field.domkey[0] == 'requestid').browserConditionParam.dataParams={dmltablename:outermaintable,datasourceid:datasourceid});
//                                     TriggerFormFields[0] && TriggerFormFields[0].items && TriggerFormFields[0].items.find(field => field.domkey[0] == 'FTriggerFlag') && (TriggerFormFields[0].items.find(field => field.domkey[0] == 'FTriggerFlag').browserConditionParam.dataParams={dmltablename:outermaintable,datasourceid:datasourceid});
//                                     TriggerFormFields[0] && TriggerFormFields[0].items && TriggerFormFields[0].items.find(field => field.domkey[0] == 'isupdatewfdataField') && (TriggerFormFields[0].items.find(field => field.domkey[0] == 'isupdatewfdataField').browserConditionParam.dataParams={dmltablename:outermaintable,datasourceid:datasourceid});

//                                     tencentMailStore.setState({TriggerFormFields: TriggerFormFields});

//                                 }else if(getKey(fields) === 'isview') {
//                                     if (newForm.getFormParams().isview == "1") {
//                                         newForm.updateFields({ datarecordtype: "1", isupdatewfdata: "1" });
//                                         TriggerFormFields[0].items[8].options[0].selected = true;
//                                         TriggerFormFields[0].items[8].options[1].selected = false;
//                                         TriggerFormFields[0].items[8].viewAttr = "1";
//                                         TriggerFormFields[0].items[8].hasBorder = true;

//                                         TriggerFormFields[0].items[13].options[0].selected = true;
//                                         TriggerFormFields[0].items[13].options[1].selected = false;
//                                         TriggerFormFields[0].items[13].viewAttr = "1";
//                                         TriggerFormFields[0].items[13].hasBorder = true;
//                                     } else {
//                                         if(newForm.getFormParams().isalways != "1") {
//                                             TriggerFormFields[0].items[13].viewAttr = "2";
//                                             TriggerFormFields[0].items[13].hasBorder = false;
//                                         }
//                                         TriggerFormFields[0].items[8].viewAttr = "2";
//                                         TriggerFormFields[0].items[8].hasBorder = false;
//                                     }
//                                     tencentMailStore.setState({TriggerFormFields: TriggerFormFields});
//                                 }else if(getKey(fields) === 'setname') {
//                                     let checkParams = {
//                                         tableName: 'outerdatawfset',
//                                         fieldName: 'setname',
//                                         fieldValue: newForm.getFormParams().setname.replace(/^(\s*)|(\s*)$/g, ''),
//                                         idName: 'id',
//                                         idValue: tencentMailStore.settingRegisterID
//                                     };
//                                     checkTableFieldValueUnique(checkParams).then(result => {
//                                         if(result&&result.isNotUnique) {
//                                             newForm.showError('setname',getLabel('129943','名称已存在'));
//                                         }
//                                     });
//                                 }else if(getKey(fields) === 'isalways') {
//                                     if(newForm.getFormParams().isalways=="1") {
//                                         newForm.updateFields({isupdatewfdata:"1"});
//                                         TriggerFormFields[0].items && TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata') && (TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata').options[0].selected = true);
//                                         TriggerFormFields[0].items && TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata') && (TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata').options[1].selected = false);
//                                         TriggerFormFields[0].items && TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata') && (TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata').viewAttr = 1);
//                                         TriggerFormFields[0].items && TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata') && (TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata').hasBorder = true);
//                                     }else {
//                                         if(newForm.getFormParams().isview != "1") {
//                                             TriggerFormFields[0].items && TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata') && (TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata').viewAttr = 2);
//                                             TriggerFormFields[0].items && TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata') && (TriggerFormFields[0].items.find(v => v.domkey[0]=='isupdatewfdata').hasBorder = false);
//                                         }
//                                     }
//                                     tencentMailStore.setState({ TriggerFormFields: TriggerFormFields });
//                                 }
//                             }} />
//                         </WeaFormItem>),
//                     colSpan:1,
//                     hide: newForm.isHide(fields, (keys, allParams) => {
//                         let bool = false;
//                         if(allParams.isview=="1"){
//                             if(getKey(fields) === 'requestid' || getKey(fields) === 'FTriggerFlag'
//                                 || getKey(fields) === 'FTriggerFlagValue' || getKey(fields) === 'isupdatewfdataField'){
//                                 bool=true;
//                             }
//                         }
//                         getKey(fields) === 'updateisnextnode' && allParams.isupdatewfdata == '1' && (bool = true);
//                         getKey(fields) === 'requestid' && allParams.datarecordtype == '1' && (bool = true);
//                         getKey(fields) === 'FTriggerFlag' && allParams.datarecordtype == '1' && (bool = true);
//                         getKey(fields) === 'FTriggerFlagValue' && allParams.datarecordtype == '1' && (bool = true);
//                       getKey(fields) === 'successback' && allParams.datarecordtype == '1' && (bool = true);
//                       getKey(fields) === 'failback' && allParams.datarecordtype == '1' && (bool = true);

//                         getKey(fields) === 'isupdatewfdataField' && allParams.isupdatewfdata == '1' && (bool = true);
//                         return bool;
//                     })
//                 });

//             });


//             if(i==1) {
//                 //说明
//                 items.push({
//                     com: (
//                         <div >
//                             <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>1、{getLabel('386907','该流程自动触发时，将根据外部主表条件搜索外部主表，有多少条记录即触发多少条流程；流程主字段的值来源于外部主表，而每条流程的各明细值将分别根据明细表条件搜索明细表得到的结果进行赋值；主表中必须包含主键(默认为id)')}</span></div>
//                             <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>2、{getLabel(386908,'条件以“where”开头，如：“where fieldname1=1 and fieldname2=\'value2\'”；回写设置以“set”开头，如：“set flag=1,isok=true”，FtriggerFlag和requestid字段自动更新，不能在此设置')}</span></div>
//                             <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>3、{getLabel(386909,'流程触发时如果需要回写外部主表，需要设置是否回写、流程ID字段、标志字段、标志字段需要回写的值(字符型)，回写数据时，默认标志字段=1：表示已触发，流程ID字段=0：表示流程创建人对应的外部字段值为空，流程ID字段=-1：表示外部字段保存的人员信息在oa中不存在，流程ID')}</span></div>
//                             <div class='badge' style={{paddingLeft:5,paddingBottom:10}}><span style={{marginLeft:10}}>4、{getLabel(386910,'外部明细表数据如需与主表数据关联，可将外部明细表条件设置为“where \'明细表.字段\'=\'主表.字段\'”')}</span></div>

//                         </div>
//                     ),
//                     hide: newForm.isHide(newForm,(keys, allParams) => {
//                         return ( false );
//                     })
//                 });

//             }



//             group.push(<WeaSearchGroup center={i<1?true:false}  col={1}  needTigger={true} title={c.title} showGroup={c.defaultshow} items={items}/>);
//             i++;




//         });
//         return group;
//     }

//     render() {
//         const {tencentMailStore} = this.props;
//         const {showNewFormDialog} = toJS(tencentMailStore.status);
//         return (

//             <div className='wea-integration-single'>
//               <WeaDialog
//                   title={ `${getLabel( '365,33720' ,'新建流程触发集成')}` }
//                   icon='icon-coms-integration'
//                   iconBgcolor='#1a57a0'
//                   visible={showNewFormDialog}
//                   hasScroll={true}
//                   style={{width: 900, height: 600}}
//                   onCancel={()=> {
//                       tencentMailStore.setState({showNewFormDialog : false});
//                       tencentMailStore.newForm.reset();
//                   }}
//                   buttons={this.getBtns()}
//                   moreBtn={{
//                       datas : this.getRightMenu(),
//                       collectParams: []
//                   }}
//               >
//                 <WeaRightMenu
//                     datas={this.getRightMenu()}
//                     collectParams={[]}>


//                     {this.getSearchs()}


//                 </WeaRightMenu>
//               </WeaDialog>
//             </div>
//         )
//     }
// }
