import {
    observable,
    action,
    computed
} from 'mobx';
import * as api from '../apis/securitySetting';
import {
    authorized
} from '../apis/common';
import {
    WeaError, WeaTools
} from 'ecCom';
import {
    WeaTableNew,
    WeaSwitch,
    WeaForm,
} from 'comsMobx';
import {
    WeaHelpfulTip,
    WeaLocaleProvider,
} from 'ecCom';
import {
    Button,
    message,
    Row,
    Col,
    Modal,
} from 'antd'
import {
    transParams
} from '../util/index';
import HrmBaseStore from './baseStore';
import {
    cloneDeep,
    findIndex,
    last,
    remove
} from 'lodash';
import has from 'lodash/has';
import {
    i18n
} from '../public/i18n';
import { addContentPath } from '../util/index.js'
import loadjs from 'loadjs';

const getLabel = WeaLocaleProvider.getLabel;
const confirm = Modal.confirm;

const {
    TableStore
} = WeaTableNew;

export class HrmSecuritySetting extends HrmBaseStore {
    /********************* unobservable list *********************/
    authorizationInfo;
    single = '0';
    type;
    opId;
    inputNumProps = {
        min: 1,
        max: 10000
    };
    errorRef = {};

    imgerrorfun = (e) => {
        e.target.onerror = null;
        e.target.style.display = 'none';
    }

    imgOnLoad = e => {
        e.target.onerror = null;
        e.target.style.display = 'block';
    }

    itemRender = {
        //密码最小长度
        minpasslen: (field, textAreaProps, form, formParams) => {
            return (
                <div className='cust'>
                    <div className='basic'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@skiwzu`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                </div>
            )
        },
        passwordReuse: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ibxm1j`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    {
                        formParams.passwordReuse === '1' &&
                        <div className='child'>
                            <div className='lbl'>{`${i18n.label.modifyPassword()}, `}</div>
                            <div className='lbl'>{i18n.label.newPassCannotdo().replace('{param}', '')}</div>
                            <div className='inputNum' style={{ margin: '0 10px' }}>
                                <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@40w1pi`} tipPosition='bottom' ref={dom => this.setErrorRef('passwordReuseNum', dom)} error={form.getError(fieldMap['passwordReuseNum'])}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@jzvgo8`} fieldConfig={{ ...fieldMap['passwordReuseNum'], ...textAreaProps }}
                                        form={form} formParams={formParams} />
                                </WeaError>
                            </div>
                            <div className='lbl'>{i18n.label.samePassWithBefore().replace('{param}', '')}</div>
                        </div>
                    }
                </div>
            )
        },
        passwordReuseNum: (field, textAreaProps, form, formParams) => null,
        //密码复杂度
        passwordComplexity: (field, textAreaProps, form, formParams) => this.itemRender.minpasslen(field, textAreaProps, form, formParams),
        //密码变更提醒
        valid: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@7ahirz`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    {
                        formParams.valid === '1' && //密码变更提醒启用时显示提醒周期
                        (
                            <React.Fragment ecId={`${this && this.props && this.props.ecId || ''}_undefined@k5klvs`}>
                                <div className='child'>
                                    <div className='lbl'>{fieldMap['remindperiod'].label}</div>
                                    <div className='inputNum'>
                                        <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@mo6uve`} tipPosition='bottom' ref={dom => this.setErrorRef('remindperiod', dom)} error={form.getError(fieldMap['remindperiod'])}>
                                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@kg5rtd`} fieldConfig={{ ...fieldMap['remindperiod'], ...textAreaProps, otherParams: this.inputNumProps }}
                                                form={form} formParams={formParams} />
                                        </WeaError>
                                    </div>
                                    <div className='lbl'>{i18n.label.day()}</div>
                                </div>
                                <div className='child'>
                                    <div className='lbl'>{fieldMap['remindperTime'].label}</div>
                                    <div className='inputNum'>
                                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@mqnrkm`} fieldConfig={{ ...fieldMap['remindperTime'], ...textAreaProps }}
                                            form={form} formParams={formParams} />
                                    </div>
                                </div>
                            </React.Fragment>
                        )
                    }
                </div>
            )
        },
        //移除提醒周期的默认组件
        remindperiod: (field, textAreaProps, form, formParams) => null,
        remindperTime: (field, textAreaProps, form, formParams) => null,
        //强制修改密码
        PasswordChangeReminder: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@sny1tj`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    {
                        formParams.PasswordChangeReminder === '1' && //强制修改密码启用时显示同一密码使用周期以及提醒周期
                        <div className='child'>
                            <div className='lbl'>{i18n.label.useSamePassword()}</div>
                            <div className='inputNum'>
                                <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@tatpm3`} tipPosition='bottom' ref={dom => this.setErrorRef('ChangePasswordDays', dom)} error={form.getError(fieldMap['ChangePasswordDays'])}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@o7s61w`} fieldConfig={{ ...fieldMap['ChangePasswordDays'], ...textAreaProps, otherParams: this.inputNumProps }}
                                        form={form} formParams={formParams} />
                                </WeaError>
                            </div>
                            <div className='lbl'>{fieldMap['ChangePasswordDays'].label}</div>
                            <div className='lbl'>{`,${i18n.label.preCompulsoryRevision()}`}</div>
                            <div className='inputNum'>
                                <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@y3mak1`} tipPosition='bottom' ref={dom => this.setErrorRef('DaysToRemind', dom)} error={form.getError(fieldMap['DaysToRemind'])}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@4vn51f`} fieldConfig={{ ...fieldMap['DaysToRemind'], ...textAreaProps, otherParams: this.inputNumProps }}
                                        form={form} formParams={formParams} />
                                </WeaError>
                            </div>
                            <div className='lbl'>{fieldMap['DaysToRemind'].label}</div>
                        </div>
                    }
                </div>
            )
        },
        //初始密码有效期
        initialPwdValidity: (field, textAreaProps, form, formParams) => {
            return (
                <div className='initialPwdValidity'>
                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@65oy1u`} fieldConfig={{ ...field, ...textAreaProps }}
                        form={form} formParams={formParams} />
                    <span>{i18n.label.day()}</span>
                </div>
            )
        },
        //长时间未登录自动锁定
        unRegPwdLock: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ji4t14`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    {
                        formParams.unRegPwdLock === '1' && //密码变更提醒启用时显示提醒周期
                        <div className='child'>
                            <div className={window.e9_locale.userLanguage === 8 ? 'inputNum_en' : 'inputNum'} style={{ marginLeft: 10 }}>
                                <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@lsec82`} tipPosition='bottom' ref={dom => this.setErrorRef('unRegPwdLockDays', dom)} error={form.getError(fieldMap['unRegPwdLockDays'])}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@7zltmt`} fieldConfig={{ ...fieldMap['unRegPwdLockDays'], ...textAreaProps, otherParams: this.inputNumProps }}
                                        form={form} formParams={formParams} />
                                </WeaError>
                            </div>
                            <div className='lbl'>{`${i18n.label.day()}${i18n.label.noLogin()} , ${i18n.label.accountAutomaticLocking()}`}</div>
                            <div className='lbl'><a onClick={() => this.openDialog()}>{i18n.label.whiteList()}</a></div>
                            <div className='lbl'><WeaHelpfulTip title={fieldMap['unRegPwdLockDays'].helpfulTip} /></div>
                        </div>
                    }
                </div>
            )
        },
        //多少天未登录账号自动锁定
        unRegPwdLockDays: (field, textAreaProps, form, formParams) => null,
        //移除同一密码使用周期的默认组件
        ChangePasswordDays: (field, textAreaProps, form, formParams) => null,
        //移除同一密码使用周期提醒默认组件
        DaysToRemind: (field, textAreaProps, form, formParams) => null,
        //账号锁定
        openPasswordLock: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@1wkgkc`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    {
                        formParams.openPasswordLock === '1' && //账号锁定启用时显示累计次数等信息
                        <div className='child'>
                            <div className='lbl'>{fieldMap['sumPasswordLock'].label}</div>
                            <div className='inputNum'>
                                <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@3xwjuv`} tipPosition='bottom' ref={dom => this.setErrorRef('sumPasswordLock', dom)} error={form.getError(fieldMap['sumPasswordLock'])}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@f910ff`} fieldConfig={{ ...fieldMap['sumPasswordLock'], ...textAreaProps, otherParams: this.inputNumProps }}
                                        form={form} formParams={formParams} />
                                </WeaError>
                            </div>
                            <div className='lbl'>{i18n.label.lockAccount()}</div>
                            <div>
                                <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@hra8o6`} fieldConfig={{ ...fieldMap['needPasswordLockMin'], ...textAreaProps }}
                                    form={form} formParams={formParams} />
                            </div>
                            <div className='lbl'>{i18n.label.locking()}</div>
                            <div className='inputNum'>
                                <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@31bn09`} tipPosition='bottom' ref={dom => this.setErrorRef('passwordLockMin', dom)} error={form.getError(fieldMap['passwordLockMin'])}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@2q2puq`} fieldConfig={{ ...fieldMap['passwordLockMin'], ...textAreaProps, otherParams: this.inputNumProps, viewAttr: (formParams.needPasswordLockMin === '1' ? '2' : '1'), hasBorder: true }}
                                        form={form} formParams={formParams} />
                                </WeaError>
                            </div>
                            <div className='lbl'>{i18n.label.unlockingInMinutes()}</div>
                        </div>
                    }
                </div>
            )
        },
        //移除密码错误累计次数锁定账户的默认组件
        sumPasswordLock: (field, textAreaProps, form, formParams) => null,
        //移除锁定账户的默认组件
        needPasswordLockMin: (field, textAreaProps, form, formParams) => null,
        //移除自动解锁账户的默认组件
        passwordLockMin: (field, textAreaProps, form, formParams) => null,
        //禁止在网段外登录
        forbidLogin: (field, textAreaProps, form, formParams) => {
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@32jm01`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    {
                        formParams.forbidLogin === '1' && //禁止在网段外登录启用时显示设置网段按钮
                        <div className='child'><p>{i18n.label.beforeActive()}<a onClick={this.redirectToNetworkSettingTab}>{i18n.label.setNetworkStrategy()}</a></p></div>
                    }
                </div>
            )
        },
        //找回密码方式
        forgotpasswordmode: (field, textAreaProps, form, formParams) => {
            if (formParams.needforgotpassword === '1') {
                return (
                    <div className='cust'>
                        <div className='basic'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@1bu8xw`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //忘记密码短信和邮件验证码失效时间(秒)
        forgotpasswordExpiration: (field, textAreaProps, form, formParams) => {
            if (formParams.needforgotpassword === '1') {
                return (
                    <div className='cust'>
                        <div style={{ width: 150 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@xzy42b`} fieldConfig={{ ...field, ...textAreaProps, otherParams: this.inputNumProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //找回密码时同步解除账号锁定
        forgotpasswordrelieve: (field, textAreaProps, form, formParams) => {
            if (formParams.needforgotpassword === '1') {
                return (
                    <div className='cust'>
                        <div style={{ width: 150 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@78y2e3`} fieldConfig={{ ...field, ...textAreaProps, otherParams: this.inputNumProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //验证码
        needvalidate: (field, textAreaProps, form, formParams) => {
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@cjgun8`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                </div>
            )
        },
        //验证码类型
        validatetype: (field, textAreaProps, form, formParams) => {
            if (formParams.needvalidate === '1') {
                return (
                    <div className='cust'>
                        <div className='select'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@mn0o3d`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //验证码位数
        validatenum: (field, textAreaProps, form, formParams) => this.itemRender.validatetype(field, textAreaProps, form, formParams),
        //预览
        preview: (field, textAreaProps, form, formParams) => {
            if (formParams.needvalidate === '1') {
                return (
                    <div className='cust'>
                        <img border="1" align='absmiddle' src={addContentPath(this.verificationCode)} onClick={() => this.refreshVerificationCode()} onLoad={e => this.imgOnLoad(e)} onError={e => this.imgerrorfun(e)} title={i18n.label.preview()} />
                    </div>
                )
            } else {
                return null;
            }
        },
        //外部用户接口校验码
        checkkey: (field, textAreaProps, form, formParams) => this.itemRender.minpasslen(field, textAreaProps, form, formParams),
        //非在职人员信息查看控制
        checkUnJob: (field, textAreaProps, form, formParams) => {
            return (
                <div className='cust'>
                    <div className='switch'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@xmnpgz`} fieldConfig={{ ...field, ...textAreaProps, helpfulTip: i18n.label.leaveStaffHelper() }}
                            form={form} formParams={formParams} />
                    </div>
                </div>
            )
        },
        //动态密码保护-默认启用方式
        needdynapassdefault: (field, textAreaProps, form, formParams) => {
            if (formParams.needdynapass === '1') {
                const params = {
                    needdynapass: formParams['needdynapass'],
                    needdynapassdefault: formParams['needdynapassdefault']
                }
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@t3nyaw`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                        <div className='button'>
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@hrzcr6`} onClick={() => this.sync('syndynapassdefault', params)}>{i18n.button.sync()}</Button>
                        </div>
                        <div className='helpful'>
                            <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@9vevid`} title={i18n.label.syncDynamicPasswordHelper()} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //动态密码保护-动态密码长度
        // dynapasslen: (field, textAreaProps, form, formParams) => {
        //     if (formParams.needdynapass === '1') {
        //         return (
        //             <div className='cust'>
        //                 <div className='select1'>
        //                     <WeaSwitch fieldConfig={{...field, ...textAreaProps}} 
        //                         form={form} formParams={formParams}/>
        //                 </div>
        //             </div>
        //         )
        //     } else {
        //         return null;
        //     }
        // },
        // //动态密码保护-动态密码内容
        // dypadcon: (field, textAreaProps, form, formParams) => this.itemRender.dynapasslen(field, textAreaProps, form, formParams),
        // //动态密码保护-动态密码有效期
        // validitySec: (field, textAreaProps, form, formParams) => this.itemRender.dynapasslen(field, textAreaProps, form, formParams),
        //动态密码保护-登录时需要登录密码
        needpassword: (field, textAreaProps, form, formParams) => {
            if (formParams.needdynapass === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@z5gthz`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            }
            return null;
        },
        //动态密码保护-免密时间(分钟)
        secondDynapassValidityMin: (field, textAreaProps, form, formParams) => {
            if (formParams.secondNeedDynapass === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ctrr87`} fieldConfig={{ ...field, ...textAreaProps, otherParams: { helpfulTip: field.helpfulTip } }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //动态令牌-允许作为登录辅助校验
        needusbDt: (field, textAreaProps, form, formParams) => {
            return (
                <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ms8d5o`} fieldConfig={{ ...field, ...textAreaProps }}
                    form={form} formParams={formParams}
                    onChange={this.onNeedusbDtChangeHandle} />
            )
        },
        //动态令牌-默认启用方式
        needusbdefaultDt: (field, textAreaProps, form, formParams) => {
            if (formParams.needusbDt === '1') {
                const params = {
                    needusbDt: formParams['needusbDt'],
                    needusbdefaultDt: formParams['needusbdefaultDt']
                }
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@zluj1w`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                        <div className='button'>
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@amwkni`} onClick={() => this.sync('synusbsetdefaultDt', params)}>{i18n.button.sync()}</Button>
                        </div>
                        <div className='helpful'>
                            <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@16o2x3`} title={i18n.label.syncDynamicPasswordHelper()} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //动态令牌-免密时间(分钟)
        secondValidityDtMin: (field, textAreaProps, form, formParams) => {
            if (formParams.secondNeedusbDt === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@9d5fto`} fieldConfig={{ ...field, ...textAreaProps, otherParams: { helpfulTip: field.helpfulTip } }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //二次验证密码-免密时间(分钟)
        secondPasswordMin: (field, textAreaProps, form, formParams) => {
            // if (formParams.secondPassword === '1') {
            return (
                <div className='cust'>
                    <div className='select1'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@h3fon1`} fieldConfig={{ ...field, ...textAreaProps, otherParams: { helpfulTip: field.helpfulTip } }}
                            form={form} formParams={formParams} />
                    </div>
                </div>
            )
            // } else {
            //     return null;
            // }
        },
        //CA扫码登录-云服务地址
        addressCA: (field, textAreaProps, form, formParams) => {
            const params = {
                needdynapass: formParams['needdynapass'],
                needdynapassdefault: formParams['addressCA']
            }
            return (
                <div className='cust'>
                    <div className='select1'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@2p46se`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    <div className='button'>
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@0v9nzo`} onClick={() => this.testConnect(params)}>{i18n.button.testConnect()}</Button>
                    </div>
                </div>
            )
        },
        //CA扫码登录-默认启用方式
        CADefault: (field, textAreaProps, form, formParams) => {
            if (formParams.mobileScanCA === '1') {
                const params = {
                    needdynapass: formParams['mobileScanCA'],
                    needdynapassdefault: formParams['CADefault']
                }
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@td9xsz`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                        <div className='button'>
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ywmja6`} onClick={() => this.sync('synDefaultCA', params)}>{i18n.button.sync()}</Button>
                        </div>
                        <div className='helpful'>
                            <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@1abp52`} title={i18n.label.syncCAHelper()} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },


        SEGMENT_STRATEGY_DEFAULT: (field, textAreaProps, form, formParams) => {
            if (formParams['SEGMENT_STRATEGY'] === '1') {
                const params = {
                    segmentStrategyDefault: formParams['SEGMENT_STRATEGY_DEFAULT']
                }
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@z5o82t`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                        <div className='button'>
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@b1mv6k`} onClick={() => { this.sync('synSegmentStrategy', params) }}>{i18n.button.sync()}</Button>
                        </div>
                        <div className='helpful'>
                            <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@de8q3a`} title={getLabel('532032', '同步默认方式到所有使用网段策略的人')} />
                        </div>
                    </div>
                )
            } else {
                return null
            }
        },
        //PC端强制扫码登录
        qrCodeDefault: (field, textAreaProps, form, formParams) => {
            if (formParams['qrCode'] === '1') {
                const params = {
                    qrCodeDefault: formParams['qrCodeDefault']
                }
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@z5o82t`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                        <div className='button'>
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@b1mv6k`} onClick={() => { this.sync('synQRCode', params) }}>{i18n.button.sync()}</Button>
                        </div>
                        <div className='helpful'>
                            <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@de8q3a`} title={getLabel('526473', '同步默认方式到所有使用PC强制扫码登录的人')} />
                        </div>
                    </div>
                )
            } else {
                return null
            }
        },
        //CA扫码登录-免密时间(分钟)
        secondValidityCAMin: (field, textAreaProps, form, formParams) => {
            if (formParams.secondCA === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@fzg2md`} fieldConfig={{ ...field, ...textAreaProps, otherParams: { helpfulTip: field.helpfulTip } }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //契约锁-云服务地址
        addressCL: (field, textAreaProps, form, formParams) => {
            const params = {
                needdynapass: formParams['needdynapass'],
                needdynapassdefault: formParams['addressCL']
            }
            return (
                <div className='cust'>
                    <div className='select1'>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@1q3jeb`} fieldConfig={{ ...field, ...textAreaProps }}
                            form={form} formParams={formParams} />
                    </div>
                    <div className='button'>
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@tnq62a`} onClick={() => this.testConnect(params)}>{i18n.button.testConnect()}</Button>
                    </div>
                </div>
            )
        },
        //契约锁-免密时间(分钟)
        secondValidityCLMin: (field, textAreaProps, form, formParams) => {
            if (formParams.secondCL === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@284ea3`} fieldConfig={{ ...field, ...textAreaProps, otherParams: { helpfulTip: field.helpfulTip } }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        //网段策略-起始ip
        inceptipaddressA: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            const {
                ipAddressType
            } = form.getFormParams();
            if (ipAddressType === 'IPv6') {
                return null
            }
            return (
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@gzvbx1`} gutter={16} className="ipAddress">
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@cc9075`} span={6}><div className="num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@lm6bmg`} fieldConfig={field} form={form} /></div><div className="point">.</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@tqwnlj`} span={6}><div className="num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@buufyf`} fieldConfig={fieldMap['inceptipaddressB']} form={form} /></div><div className="point">.</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@k4nan6`} span={6}><div className="num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@3k0b2c`} fieldConfig={fieldMap['inceptipaddressC']} form={form} /></div><div className="point">.</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@0c0p31`} span={6}><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@3edgvo`} fieldConfig={fieldMap['inceptipaddressD']} form={form} /></Col>
                </Row>
            )
        },
        inceptipaddressB: (field, textAreaProps, form, formParams) => null,
        inceptipaddressC: (field, textAreaProps, form, formParams) => null,
        inceptipaddressD: (field, textAreaProps, form, formParams) => null,
        //网段策略-结束ip
        endipaddressA: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            const {
                ipAddressType
            } = form.getFormParams();
            if (ipAddressType === 'IPv6') {
                return null
            }
            return (
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@80k5tn`} gutter={16} className="ipAddress">
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@3pq6io`} span={6}><div className="num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@zijink`} fieldConfig={field} form={form} /></div><div className="point">.</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@anzgf0`} span={6}><div className="num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@prwbc1`} fieldConfig={fieldMap['endipaddressB']} form={form} /></div><div className="point">.</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@qw040d`} span={6}><div className="num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@st54rv`} fieldConfig={fieldMap['endipaddressC']} form={form} /></div><div className="point">.</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@nlaazp`} span={6}><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@qa3w47`} fieldConfig={fieldMap['endipaddressD']} form={form} /></Col>
                </Row>
            )
        },
        endipaddressB: (field, textAreaProps, form, formParams) => null,
        endipaddressC: (field, textAreaProps, form, formParams) => null,
        endipaddressD: (field, textAreaProps, form, formParams) => null,

        //IPv6起始ip
        inceptipaddress0: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            const {
                ipAddressType
            } = form.getFormParams();
            if (ipAddressType === 'IPv4') {
                return null
            }
            return (
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@hxszo3`} gutter={16} className="ipAddress ipv6">
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@bik4w0`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@fu0ww9`} fieldConfig={field} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@levkk2`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@rl6d6u`} fieldConfig={fieldMap['inceptipaddress1']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@0soje7`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@6v88rq`} fieldConfig={fieldMap['inceptipaddress2']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@61i9ym`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@524g9d`} fieldConfig={fieldMap['inceptipaddress3']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@ek3sdw`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@58nj1a`} fieldConfig={fieldMap['inceptipaddress4']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@a7r25s`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@wpwlvr`} fieldConfig={fieldMap['inceptipaddress5']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@i9mpax`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@75cs96`} fieldConfig={fieldMap['inceptipaddress6']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@n7pgle`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@e69s2g`} fieldConfig={fieldMap['inceptipaddress7']} form={form} /></div></Col>
                </Row>
            )
        },
        inceptipaddress1: (field, textAreaProps, form, formParams) => null,
        inceptipaddress2: (field, textAreaProps, form, formParams) => null,
        inceptipaddress3: (field, textAreaProps, form, formParams) => null,
        inceptipaddress4: (field, textAreaProps, form, formParams) => null,
        inceptipaddress5: (field, textAreaProps, form, formParams) => null,
        inceptipaddress6: (field, textAreaProps, form, formParams) => null,
        inceptipaddress7: (field, textAreaProps, form, formParams) => null,
        //IPv6结束ip
        endipaddress0: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;
            const {
                ipAddressType
            } = form.getFormParams();
            if (ipAddressType === 'IPv4') {
                return null
            }
            return (
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@m2bwd9`} gutter={16} className="ipAddress ipv6">
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@hxp3jf`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@bivmz9`} fieldConfig={field} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@kuibsa`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@xpteaw`} fieldConfig={fieldMap['endipaddress1']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@0jiw17`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@q897ww`} fieldConfig={fieldMap['endipaddress2']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@k4t1wv`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@dajcz4`} fieldConfig={fieldMap['endipaddress3']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@ugzows`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@yyy0c1`} fieldConfig={fieldMap['endipaddress4']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@6vpyii`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@lo8rev`} fieldConfig={fieldMap['endipaddress5']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@0yr3tv`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@lnf5pe`} fieldConfig={fieldMap['endipaddress6']} form={form} /></div><div className="v6point">:</div></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@e3b6cg`} span={3}><div className="v6num"><WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@proxoy`} fieldConfig={fieldMap['endipaddress7']} form={form} /></div></Col>
                </Row>
            )
        },
        endipaddress1: (field, textAreaProps, form, formParams) => null,
        endipaddress2: (field, textAreaProps, form, formParams) => null,
        endipaddress3: (field, textAreaProps, form, formParams) => null,
        endipaddress4: (field, textAreaProps, form, formParams) => null,
        endipaddress5: (field, textAreaProps, form, formParams) => null,
        endipaddress6: (field, textAreaProps, form, formParams) => null,
        endipaddress7: (field, textAreaProps, form, formParams) => null,
        //弱密码禁止保存
        weakPasswordDisable: (field, textAreaProps, form, formParams) => {
            return (
                <React.Fragment ecId={`${this && this.props && this.props.ecId || ''}_undefined@mggzfc`}>
                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@s2cf8j`} fieldConfig={{ ...field, ...textAreaProps }}
                        form={form} formParams={formParams} />
                    <span style={{ marginLeft: 10 }}>
                        <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@nxakke`} title={getLabel(515421, "开启后，修改密码时弱密码将无法成功保存")} />
                    </span>
                </React.Fragment>
            )
        },
        //启用初始密码
        defaultPasswordEnable: (field, textAreaProps, form, formParams) => {
            const {
                fieldMap
            } = form;

            const { defaultPasswordEnable } = formParams;

            return (
                <React.Fragment ecId={`${this && this.props && this.props.ecId || ''}_undefined@c73ohs`}>
                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@jloymj`} fieldConfig={{ ...field, ...textAreaProps }}
                        form={form} formParams={formParams} />
                    <span style={{ margin: "0 10px" }}>
                        <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@59579s`} title={getLabel(516216, "开启后可将人员密码批量重置为初始密码，导入人员时密码默认为初始密码。")} />
                    </span>
                    {
                        (defaultPasswordEnable === "1") && (
                            <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@pydd0i`} tipPosition='bottom' ref={dom => this.setErrorRef('defaultPassword', dom)} error={form.getError(fieldMap['defaultPassword'])}>
                                <div style={{ display: "inline-block", width: 260 }}>
                                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@9zpkrp`} fieldConfig={{ ...fieldMap['defaultPassword'], ...textAreaProps }}
                                        form={form} formParams={formParams} />
                                </div>
                            </WeaError>
                        )
                    }
                </React.Fragment>
            )
        },
        defaultPassword: () => null,
        secondNeedDynapass: (field, textAreaProps, form, formParams) => {
            const { fieldMap } = form;
            return (
                <div className='cust'>
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ndi7xe`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} onChange={this.onFormItemChangeHandle} />
                    </div>
                    {
                        formParams.secondNeedDynapass == '1' &&
                        <div className='child-checkbox' style={{ marginLeft: 16 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@golwey`} fieldConfig={{ ...fieldMap['secondDynapassDefault'], textAreaProps, otherParams: { content: fieldMap['secondDynapassDefault'].label } }} form={form} formParams={formParams} onChange={this.onChangeHandle} />
                        </div>
                    }
                </div>
            )
        },
        secondDynapassDefault: () => null,
        secondNeedusbDt: (field, textAreaProps, form, formParams) => {
            const { fieldMap } = form;
            return (
                <div className='cust'>
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ooiqh3`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} onChange={this.onSecondNeedusbDtChangeHandle} />
                    </div>
                    {
                        formParams.secondNeedusbDt == '1' &&
                        <div className='child-checkbox' style={{ marginLeft: 16 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@028582`} fieldConfig={{ ...fieldMap['secondUsbDtDefault'], textAreaProps, otherParams: { content: fieldMap['secondUsbDtDefault'].label } }} form={form} formParams={formParams} onChange={this.onChangeHandle} />
                        </div>
                    }
                </div>
            )
        },
        secondUsbDtDefault: () => null,
        secondPasswordMin: (field, textAreaProps, form, formParams) => {
            const { fieldMap } = form;
            return (
                <div className='cust'>
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@jeiroe`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} />
                    </div>
                    <div className='child-checkbox' style={{ marginLeft: 16 }}>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@xawzyw`} fieldConfig={{ ...fieldMap['secondPasswordDefault'], textAreaProps, otherParams: { content: fieldMap['secondPasswordDefault'].label } }} form={form} formParams={formParams} onChange={this.onChangeHandle} />
                    </div>
                </div>
            )
        },
        secondPasswordDefault: () => null,
        mobileScanCA: (field, textAreaProps, form, formParams) => {
            return (
                <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@qh3ooi`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} onChange={this.onCAChangeHandle} />
            )
        },
        secondCA: (field, textAreaProps, form, formParams) => {
            const { fieldMap } = form;
            return (
                <div className='cust'>
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@zsguwu`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} onChange={this.onFormItemChangeHandle} />
                    </div>
                    {
                        formParams.secondCA == '1' &&
                        <div className='child-checkbox' style={{ marginLeft: 16 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@e18p0i`} fieldConfig={{ ...fieldMap['secondCADefault'], textAreaProps, otherParams: { content: fieldMap['secondCADefault'].label } }} form={form} formParams={formParams} onChange={this.onChangeHandle} />
                        </div>
                    }
                </div>
            )
        },
        secondCADefault: () => null,
        //CA-免密时间(分钟)
        secondCAValidityMin: (field, textAreaProps, form, formParams) => {
            if (formParams.secondCA === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ues1q1`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        secondCL: (field, textAreaProps, form, formParams) => {
            const { fieldMap } = form;
            return (
                <div className='cust'>
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@bl2itq`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} onChange={this.onFormItemChangeHandle} />
                    </div>
                    {
                        formParams.secondCL == '1' && fieldMap['secondCLDefault'] &&
                        <div className='child-checkbox' style={{ marginLeft: 16 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@arb1ai`} fieldConfig={{ ...fieldMap['secondCLDefault'], textAreaProps, otherParams: { content: fieldMap['secondCLDefault'].label } }} form={form} formParams={formParams} onChange={this.onChangeHandle} />
                        </div>
                    }
                </div>
            )
        },
        secondCLDefault: () => null,
        secondFace: (field, textAreaProps, form, formParams) => {
            const { fieldMap } = form;
            return (
                <div className='cust'>
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@p9jw95`} fieldConfig={{ ...field, textAreaProps }} form={form} formParams={formParams} onChange={this.onFormItemChangeHandle} />
                    </div>
                    {
                        formParams.secondFace == '1' &&
                        <div className='child-checkbox' style={{ marginLeft: 16 }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@xw10d1`} fieldConfig={{ ...fieldMap['secondFaceDefault'], textAreaProps, otherParams: { content: fieldMap['secondFaceDefault'].label } }} form={form} formParams={formParams} onChange={this.onChangeHandle} />
                        </div>
                    }
                </div>
            )
        },
        //人脸-免密时间(分钟)
        secondFaceValidityMin: (field, textAreaProps, form, formParams) => {
            if (formParams.secondFace === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@w4w4e5`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        secondFaceDefault: () => null,
        needCLdefault:(field, textAreaProps, form, formParams)=>{
            if (formParams.needCL === '1') {
                const params = {
                    needCLdefault: formParams['needCLdefault']
                }
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@w4w4e5`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                        <div className='button'>
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ywmja6`} onClick={() => this.sync('synDefaultCL', params)}>{i18n.button.sync()}</Button>
                        </div>
                        <div className='helpful'>
                            <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@1abp52`} title={getLabel('535309','同步默认方式到所有使用契约锁验证的人')} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        secondCLValidityMin:(field, textAreaProps, form, formParams)=>{
            if (formParams.secondCL === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@w4w4e5`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        clAuthtype: (field, textAreaProps, form, formParams) => {
            return (
                <div >
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@3rujlh`} fieldConfig={{ ...field, ...textAreaProps }} form={form} formParams={formParams}
                           onChange={(data)=>{ form.updateFields({clAuthTypeDefault: 'FACE'})}}/>
                    </div>
                </div>
            )
        },
        clAuthTypeDefault: (field, textAreaProps, form, formParams) => {
            return (
                <div >
                    <div className=''>
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@3rujlh`} fieldConfig={{ ...field, ...textAreaProps, options: field.options.filter((v)=>{return formParams.clAuthtype.indexOf(v.key)>=0}) }} form={form} formParams={formParams}/>
                    </div>
                </div>
            )
        },
        appKey:(field, textAreaProps, form, formParams)=>{
            if (formParams.needCL === '1'||formParams.secondCL === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@w4w4e5`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        appSecret:(field, textAreaProps, form, formParams)=>{
            if (formParams.needCL === '1'||formParams.secondCL === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@w4w4e5`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        },
        addressCL:(field, textAreaProps, form, formParams)=>{
            if (formParams.needCL === '1'||formParams.secondCL === '1') {
                return (
                    <div className='cust'>
                        <div className='select1'>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@w4w4e5`} fieldConfig={{ ...field, ...textAreaProps }}
                                form={form} formParams={formParams} />
                        </div>
                    </div>
                )
            } else {
                return null;
            }
        }
    }

    cascadedItems = [
        'secondDynapassDefault',
        'secondUsbDtDefault',
        'secondPasswordDefault',
        'secondCADefault',
        'secondCLDefault',
        'secondFaceDefault'
    ]

    @action onChangeHandle = data => {
        const [obj] = Object.entries(data);
        const [k, v] = obj;
        const { value } = v;
        if (value == '1') {
            this.cascadedItems.map(key => {
                if (k != key)
                    this.formTarget.settingForm.updateFields({
                        [key]: {
                            value: '0'
                        }
                    });
            })
        }
        this.onSecondNeedusbDtChangeHandle(data);
        this.onCAChangeHandle(data);
    }

    editorDialogRightMenu = [];
    getDialogOpButtons = () => {
        let buttons = [<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ojwnam`} type='primary' op="save" onClick={() => this.save()}>{i18n.button.save()}</Button>];
        this.editorDialogRightMenu.length = 0;

        buttons.map((btn, index) => {
            const {
                props
            } = btn;
            this.editorDialogRightMenu.push({
                key: index.toString(),
                content: props.children,
                icon: <i className={this.menuIconCollection[props.op]} />,
                onClick: props.onClick
            });
        })
        return buttons;
    }
    /********************* unobservable list *********************/

    /********************* dialog info setting *********************/
    /********************* dialog info setting *********************/

    /********************* observable list *********************/
    @observable spinning = false;
    @observable table = new TableStore();
    @observable refreshForm = new Date().getTime();
    @observable refreshTab = new Date().getTime();
    @observable verificationCode = '/weaver/weaver.file.MakeValidateCode?seriesnum_=' + new Date().getTime();

    @observable tabConfig = {
        tabs: [],
        keyParam: 'viewCondition',
        activeTabKey: '1'
    }

    dialogParams = {
        ...this.dialogPropsDef,
        onCancel: () => {
            this.dialogParams.visible = false;
        }
    }
    /********************* observable list *********************/

    /********************* computed list *********************/
    @computed get tableMultiRemoveable () {
        return this.table.selectedRowKeys.length == 0;
    }
    /********************* computed list *********************/

    /********************* action list *********************/
    @action setErrorRef = (key, dom) => {
        this.errorRef[key] = dom;
    }

    @action getTab = (module) => {
        switch (module) {
            case 'setting':
                return [{
                    color: '#000000',
                    groupid: 'basic',
                    title: i18n.label.basicSetting,
                    viewCondition: '1',
                    topButtonDef: [{
                        comType: 'button',
                        type: 'primary',
                        onClickHandle: this.save,
                        label: i18n.button.save,
                        icon: this.menuIconCollection.save
                    }]
                }];
            case 'advance':
                return [{
                    color: '#000000',
                    groupid: 'advance',
                    title: i18n.label.advanceSetting,
                    viewCondition: '2',
                    topButtonDef: [{
                        comType: 'button',
                        type: 'primary',
                        onClickHandle: this.save,
                        label: i18n.button.save,
                        icon: this.menuIconCollection.save
                    }]
                }];
            case 'network':
                return [{
                    color: '#000000',
                    groupid: 'network',
                    title: i18n.label.networkStrategy,
                    viewCondition: '3',
                    searchType: ['base', 'advanced'],
                    searchKey: 'inceptipaddress',
                    doSearch: (params) => this.getNetworkSetting(params),
                    topButtonDef: [{
                        comType: 'button',
                        type: 'primary',
                        onClickHandle: () => this.getNetworkSegmentStrategyForm(),
                        label: i18n.button.create,
                        icon: this.menuIconCollection.create
                    }, {
                        comType: 'button',
                        type: 'primary',
                        onClickHandle: this.multiRemove,
                        label: i18n.button.multiDelete,
                        icon: this.menuIconCollection.remove,
                        checkAction: 'tableMultiRemoveable'
                    }]
                }];
            case 'db':
                return [{
                    color: '#000000',
                    groupid: 'advance',
                    title: i18n.label.dbEncryption,
                    viewCondition: '4',
                    topButtonDef: [{
                        comType: 'button',
                        type: 'primary',
                        onClickHandle: this.save,
                        label: i18n.button.save,
                        icon: this.menuIconCollection.save
                    }]
                }];
            default:
                return [];
        }
    }

    @action setTabConfig = () => {
        if ((this.single === '0' || (this.single === '1' && (this.type == null || this.type === 'setting'))) && this.authorizationInfo.hasRightOtherSettings) {
            this.tabConfig.tabs.push(...this.getTab('setting'));
        }
        if ((this.single === '0' || (this.single === '1' && (this.type == null || this.type === 'advance'))) && this.authorizationInfo.hasRightOtherSettings) {
            if (this.single === '1') {
                let tabInfo = cloneDeep(this.getTab('advance')[0]);
                if (this.tabConfig.tabs.length == 0)
                    tabInfo.title = '';
                tabInfo.tabButtonDef = [{
                    comType: '',
                    icon: this.menuIconCollection.save,
                    label: i18n.button.save,
                    rightMenuIcon: this.menuIconCollection.save,
                    onClickHandle: () => this.save()
                }];
                delete tabInfo.topButtonDef;
                this.tabConfig.tabs.push(tabInfo);
            } else {
                this.tabConfig.tabs.push(...this.getTab('advance'));
            }
        }
        if ((this.single === '0' || (this.single === '1' && (this.type == null || this.type === 'network'))) && this.authorizationInfo.hasRightNetworkSegmentStrategy) {
            if (this.single === '1') {
                let tabInfo = cloneDeep(this.getTab('network')[0]);
                if (this.tabConfig.tabs.length == 0)
                    tabInfo.title = '';
                tabInfo.tabButtonDef = tabInfo.topButtonDef;
                delete tabInfo.topButtonDef;
                tabInfo.tabButtonDef[0].icon = 'icon-coms-Add-to-hot';
                tabInfo.tabButtonDef[1].icon = 'icon-coms-form-delete-hot';
                this.tabConfig.tabs.push(tabInfo);
            } else
                this.tabConfig.tabs.push(...this.getTab('network'));
        }
        if ((this.single === '0' || (this.single === '1' && (this.type == null || this.type === 'db'))) && this.authorizationInfo.hasDBSettings) {
            this.tabConfig.tabs.push(...this.getTab('db'));
        }
        const {
            tabs
        } = this.toJS(this.tabConfig);
        if (tabs.length > 0) {
            this.setActiveTab(tabs[0].viewCondition);
        }
    }

    @action initData = (single = '0', type) => {
        loadjs(["/js/hrm/wst_ca_sdk.js","/js/rsa/jsencrypt.js", "/js/rsa/rsa.js"], { returnPromise: true });
        this.opId = null;
        this.single = single;
        this.type = type;
        this.tabConfig.tabs = [];
        authorized('securitysetting').then((data) => {
            if (data.status === '1') {
                this.authorizationInfo = data;
                this.containerInitFinished = {
                    init: true,
                    authorized: data.hasRightOtherSettings || data.hasRightNetworkSegmentStrategy || data.hasDBSettings
                }
                this.setTabConfig();
            }
        }, error => {
            this.containerInitFinished = {
                init: true,
                authorized: false
            }
        });
    }

    @action setActiveTab = (key) => {
        if (this.spinning)
            return;
        this.tabConfig.activeTabKey = key || this.tabConfig.tabs[0].viewCondition;
        const tabIndex = this.getTabIndex(this.tabConfig.tabs, key);
        if (tabIndex < 0) return;
        switch (key) {
            case '3':
                this.getNetworkSegmentStrategyCondition();
                break;
            default:
                this.spinning = true;
                this.getFormData(key).then(data => {
                    if (data.status === '1') {
                        if (key === '1') {
                            data.formField.map(field => {
                                field.items.map(item => {
                                    if (item.helpfulTip) {
                                        if (item.helpfulTip.length > 25) {
                                            item.helpfulTipProps = {
                                                width: 300
                                            }
                                        }
                                        if (item.helpfulTip.length < 15) {
                                            item.helpfulTipProps = {
                                                width: 170
                                            }
                                        }
                                    }
                                });
                            });
                            const item = cloneDeep(last(data.formField[2].items));
                            data.formField[2].items.splice(-1, 0, {
                                ...item,
                                label: i18n.label.preview(),
                                domkey: ['preview']
                            })
                            // data.formField[2].items.push({
                            //     ...item,
                            //     label: i18n.label.preview(),
                            //     domkey: ['preview']
                            // });
                        }
                        this.setFormData('settingForm', data.conditions || data.formField);
                        if (this.formTarget.settingForm.isFormInit) {
                            this.refreshForm = new Date().getTime();
                            this.refreshTab = new Date().getTime();
                        }
                    } else {
                        message.error(data.message);
                    }
                    this.spinning = false;
                }, error => this.spinning = false)
                break;
        }
    }

    @action getFormData = (id) => {
        switch (id) {
            case '1':
                return api.getBasicSetting();
            case '2':
                return api.getAdvanceSetting();
            case '4':
                return api.getDBPasswordAlterForm();
        }
    }

    @action redirectToNetworkSettingTab = () => {
        const {
            tabs
        } = this.toJS(this.tabConfig);
        const idx = findIndex(tabs, {
            viewCondition: '3'
        })
        if (idx >= 0)
            this.setActiveTab('3');
        else
            message.error(i18n.message.authFailed());
    }

    @action refreshVerificationCode = () => {
        this.verificationCode = `/weaver/weaver.file.MakeValidateCode?seriesnum_=${new Date().getTime()}`;
    }

    @action sync = (type, params) => {
        api.syncSecuritySetting({
            cmd: type,
            ...params
        }).then(data => {
            if (data.status === '1') {
                message.success(i18n.message.opSuccess());
            } else
                message.error(data.message);
        }, error => {
            message.error(i18n.message.actionError());
        });
    }

    @action testConnect = (params) => {
        message.warning('coding......');
    }

    setBasicFormHideFormValid = () => {
        window.e9HideFormFieldKeys = [];
        const formParams = this.formTarget.settingForm.getFormParams();
        if (formParams.valid != null && formParams.valid === '1') {
            remove(window.e9HideFormFieldKeys, 'remindperiod');
        } else {
            window.e9HideFormFieldKeys.push('remindperiod');
        }
        if (formParams.passwordReuse != null && formParams.passwordReuse === '1') {
            remove(window.e9HideFormFieldKeys, 'passwordReuseNum');
        } else {
            window.e9HideFormFieldKeys.push('passwordReuseNum');
        }
        if (formParams.PasswordChangeReminder != null && formParams.PasswordChangeReminder === '1') {
            ['ChangePasswordDays', 'DaysToRemind'].map(d => {
                remove(window.e9HideFormFieldKeys, d);
            });
        } else {
            window.e9HideFormFieldKeys.push(...['ChangePasswordDays', 'DaysToRemind']);
        }
        if (formParams.openPasswordLock != null && formParams.openPasswordLock === '1') {
            ['sumPasswordLock', 'needPasswordLockMin', 'passwordLockMin'].map(d => {
                remove(window.e9HideFormFieldKeys, d);
            });
            if (formParams.needPasswordLockMin == null || formParams.needPasswordLockMin == '' || formParams.needPasswordLockMin === '0') {
                window.e9HideFormFieldKeys.push('passwordLockMin');
            }
        } else {
            window.e9HideFormFieldKeys.push(...['sumPasswordLock', 'needPasswordLockMin', 'passwordLockMin']);
        }
        if (formParams.needforgotpassword != null && formParams.needforgotpassword === '1') {
            ['forgotpasswordmode', 'forgotpasswordExpiration', 'forgotpasswordrelieve'].map(d => {
                remove(window.e9HideFormFieldKeys, d);
            });
        } else {
            window.e9HideFormFieldKeys.push(...['forgotpasswordmode', 'forgotpasswordExpiration', 'forgotpasswordrelieve']);
        }
        if (formParams.needvalidate != null && formParams.needvalidate === '1') {
            ['validatetype', 'validatenum'].map(d => {
                remove(window.e9HideFormFieldKeys, d);
            });
        } else {
            window.e9HideFormFieldKeys.push(...['validatetype', 'validatenum']);
        }
        if (formParams.unRegPwdLock !== '1') {
            window.e9HideFormFieldKeys.push('unRegPwdLockDays');
        }
        if (formParams.defaultPasswordEnable !== "1") {
            window.e9HideFormFieldKeys.push('defaultPassword');
        }
    }

    setAdvanceFormHideFormValid = () => {
        window.e9HideFormFieldKeys = [];
        const formParams = this.formTarget.settingForm.getFormParams();
        if (formParams.needdynapass != null && formParams.needdynapass === '1') {
            ['needdynapassdefault', 'dynapasslen', 'dypadcon', 'validitySec'].map(d => {
                remove(window.e9HideFormFieldKeys, d);
            })
        } else {
            window.e9HideFormFieldKeys.push(...['needdynapassdefault', 'dynapasslen', 'dypadcon', 'validitySec']);
        }
        if (formParams.secondNeedDynapass != null && formParams.secondNeedDynapass === '1') {
            remove(window.e9HideFormFieldKeys, 'secondDynapassValidityMin');
        } else {
            window.e9HideFormFieldKeys.push('secondDynapassValidityMin');
        }
        if (formParams.needusbDt != null && formParams.needusbDt === '1') {
            remove(window.e9HideFormFieldKeys, 'needusbdefaultDt');
        } else {
            window.e9HideFormFieldKeys.push('needusbdefaultDt');
        }
        if (formParams.secondNeedusbDt != null && formParams.secondNeedusbDt === '1') {
            remove(window.e9HideFormFieldKeys, 'secondValidityDtMin');
        } else {
            window.e9HideFormFieldKeys.push('secondValidityDtMin');
        }
        if (formParams.secondPassword != null && formParams.secondPassword === '1') {
            remove(window.e9HideFormFieldKeys, 'secondPasswordMin');
        } else {
            window.e9HideFormFieldKeys.push('secondPasswordMin');
        }
        if (formParams.mobileScanCA != null && formParams.mobileScanCA === '1') {
            remove(window.e9HideFormFieldKeys, 'CADefault');
        } else {
            window.e9HideFormFieldKeys.push('CADefault');
        }
        if (formParams.secondCA != null && formParams.secondCA === '1') {
            remove(window.e9HideFormFieldKeys, 'secondCAValidityMin');
        } else {
            window.e9HideFormFieldKeys.push('secondCAValidityMin');
        }
        if (formParams.secondFace != null && formParams.secondFace === '1') {
            remove(window.e9HideFormFieldKeys, 'secondFaceValidityMin');
        } else {
            window.e9HideFormFieldKeys.push('secondFaceValidityMin');
        }

        if (formParams['SEGMENT_STRATEGY_DEFAULT'] === '1') {
            remove(window.e9HideFormFieldKeys, 'SEGMENT_STRATEGY_DEFAULT')
        } else {
            window.e9HideFormFieldKeys.push('SEGMENT_STRATEGY_DEFAULT')
        }

        if (formParams.secondCA != null && formParams.secondCA === '1') {
            remove(window.e9HideFormFieldKeys, 'secondValidityCAMin');
        } else {
            window.e9HideFormFieldKeys.push('secondValidityCAMin');
        }
        if (formParams.secondCL != null && formParams.secondCL === '1') {
            remove(window.e9HideFormFieldKeys, 'secondValidityCLMin');
        } else {
            window.e9HideFormFieldKeys.push('secondValidityCLMin');
        }
    }

    setNetworkSetting = () => {
        window.e9HideFormFieldKeys = [];
        const formParams = this.formTarget.networkForm.getFormParams();
        const {
            ipAddressType
        } = formParams;

        const add = (values) => {
            values.map(v => {
                const skey = `inceptipaddress${v}`;
                const ekey = `endipaddress${v}`;
                window.e9HideFormFieldKeys.push(skey);
                window.e9HideFormFieldKeys.push(ekey);
            })
        }
        if (ipAddressType === 'IPv4') {
            const vals = ['0', '1', '2', '3', '4', '5', '6', '7'];
            add(vals);
        } else {
            const vals = ['A', 'B', 'C', 'D'];
            add(vals);
        }
    }

    checkInitPassword = () => {
        const formParams = this.formTarget.settingForm.getFormParams();
        const { minpasslen, passwordComplexity, weakPasswordDisable, defaultPassword, defaultPasswordEnable } = formParams;

        if (defaultPasswordEnable != "1")
            return true;

        if (defaultPassword.length < minpasslen) {
            message.warning(getLabel('516720', '初始密码长度不能小于{params}').replace("{params}", minpasslen));
            return false;
        }

        const judge = (regExps) => {
            return regExps.every(regExp => regExp.test(defaultPassword))
        }
        if (passwordComplexity == '1') {
            const regExps = [/[a-z]+/, /[A-Z]+/, /\d+/];
            if (!judge(regExps)) {
                message.warning(getLabel('516218', "初始密码不符合要求，必须包含字母大写、字母小写、数字！请重新输入！"));
                return false;
            }
        }
        if (passwordComplexity == '2') {
            const regExps = [/[a-zA-Z_]+/, /\W+/, /\d+/];
            if (!judge(regExps)) {
                message.warning(getLabel('516275', "初始密码不符合要求，必须包含字母、数字、特殊字符！请重新输入！"));
                return false;
            }
        }
        if (passwordComplexity == '3') {
            const regExps = [/[a-zA-Z_]+/, /\d+/];
            if (!judge(regExps)) {
                message.warning(getLabel('516276', "初始密码不符合要求，必须包含字母、数字！请重新输入！"));
                return false;
            }
        }

        return true;

    }

    isWeakPassword = (password) => {
        return new Promise((resolve, reject) => {
             api.isWeakPassword({ password }).then(datas => {
                        const { weakPasswordDisable, isWeakPassword } = datas;

                        this.weakPasswordDisable = weakPasswordDisable;

                        if (isWeakPassword) {
                            message.warning(getLabel('516217', '初始密码为弱密码！'));
                            reject();
                        } else {
                            resolve();
                        }
                    }).catch(() => {
                        reject();//接口异常
                    })
            })
    }

    @action saveBasicSetting = () => {
        const formParams = this.formTarget.settingForm.getFormParams();
        this.setBasicFormHideFormValid();
        this.formTarget.settingForm.validateForm().then(f => {
            if (f.isValid) {
                const { defaultPasswordEnable } = formParams;
                const save = () => {
                    const params = transParams(formParams);
                    Object.assign(params,{defaultPassword:window.__RSAEcrypt__.rsa_data_encrypt(params.defaultPassword)})
                    api.saveBasicSetting(params).then(data => {
                        if (data.status === '1') {
                            this.refreshVerificationCode();
                            message.success(i18n.message.saveSuccess());
                        } else
                            message.error(data.message);
                    }, error => {
                        message.error(i18n.message.saveFailed());
                    });
                }

                if (defaultPasswordEnable != "1") {
                    save();
                } else {
                    const isPass = this.checkInitPassword();
                    if (isPass) {
                        const {
                            weakPasswordDisable,
                            defaultPassword
                        } = formParams;
                        if (weakPasswordDisable === "1") {
                            this.isWeakPassword(window.__RSAEcrypt__.rsa_data_encrypt(defaultPassword)).then(() => {
                            save();})
                        } else {
                            save();
                        }
                    }
                }


            } else {
                f.showErrors();
                const fields = this.formTarget.settingForm.fieldMap;
                [...Object.keys(fields)].map(k => {
                    const e = this.formTarget.settingForm.getError(fields[k]);
                    if (e != null && e != '') {
                        this.errorRef[k] && (this.errorRef[k].error = e) && this.errorRef[k].showError();
                    }
                })
                this.showError = new Date().getTime();
            }
        });
    }

    @action saveAdvanceSetting = () => {
        this.setAdvanceFormHideFormValid();
        this.formTarget.settingForm.validateForm().then(f => {
            if (f.isValid) {
                api.saveAdvanceSetting(this.formTarget.settingForm.getFormParams()).then(data => {
                    if (data.status === '1') {
                        message.success(i18n.message.saveSuccess());
                        this.setActiveTab('2');
                    } else
                        message.error(data.message);
                }, error => {
                    message.error(i18n.message.saveFailed());
                });
            } else {
                f.showErrors();
                this.showError = new Date().getTime();
            }
        });
    }

    @action multiRemove = (params) => {
        let content;
        if (!_.has(params, 'id')) {
            params = {
                id: this.table.selectedRowKeys
            }
            content = i18n.confirm.deleteSelected();
        } else {
            content = i18n.confirm.delete();
        }
        this.confirmInfo({
            content,
            onOk: () => {
                api.removeNetworkSegmentStrategy(params).then(data => {
                    if (data.status === '1') {
                        message.success(i18n.message.deleteSuccess());
                        this.getNetworkSetting();
                    } else
                        message.error(data.message);
                }, error => { });
            }
        });
    }

    @action saveNetworkSetting = (id) => {
        if (this.spinning)
            return;
        this.setNetworkSetting();
        this.formTarget.networkForm.validateForm().then(f => {
            if (f.isValid) {
                let params = transParams(this.formTarget.networkForm.getFormParams());
                params = {
                    ...params,
                    id: this.opId
                }
                this.spinning = true;
                api.saveNetworkSegmentStrategy(params).then(data => {
                    if (data.status === '1') {
                        message.success(i18n.message.saveSuccess());
                        this.getNetworkSetting();
                        this.dialogParams.onCancel();
                    } else
                        message.error(data.message);
                    this.spinning = false;
                }, error => {
                    this.spinning = false;
                });
            } else {
                f.showErrors();
                const {
                    ipAddressType
                } = this.formTarget.networkForm.getFormParams();
                this.showError = new Date().getTime();

                if (ipAddressType === 'IPv4') {
                    const s = f.getError(f.fieldMap.inceptipaddressB) || f.getError(f.fieldMap.inceptipaddressC) || f.getError(f.fieldMap.inceptipaddressD) || ''
                    const e = f.getError(f.fieldMap.endipaddressB) || f.getError(f.fieldMap.endipaddressC) || f.getError(f.fieldMap.endipaddressD) || '';
                    if (s != '') {
                        f.showError('inceptipaddressA', s);
                    }
                    if (e != '') {
                        f.showError('endipaddressA', e);
                    }
                } else {
                    const s = f.getError(f.fieldMap.inceptipaddress1) || f.getError(f.fieldMap.inceptipaddress2) || f.getError(f.fieldMap.inceptipaddress3) || f.getError(f.fieldMap.inceptipaddress4) || f.getError(f.fieldMap.inceptipaddress5) || f.getError(f.fieldMap.inceptipaddress6) || f.getError(f.fieldMap.inceptipaddress7) || '';
                    const e = f.getError(f.fieldMap.endipaddress1) || f.getError(f.fieldMap.endipaddress2) || f.getError(f.fieldMap.endipaddress3) || f.getError(f.fieldMap.endipaddress4) || f.getError(f.fieldMap.endipaddress5) || f.getError(f.fieldMap.endipaddress6) || f.getError(f.fieldMap.endipaddress7);
                    if (s != '')
                        f.showError('inceptipaddress0', s);
                    else if (e != '')
                        f.showError('endipaddress0', e);
                }
            }
        });
    }

    @action saveDb = () => {
        if (this.spinning)
            return;
        this.formTarget.settingForm.validateForm().then(f => {
            if (f.isValid) {
                const formParams = this.formTarget.settingForm.getFormParams();
                this.spinning = true;
                api.saveDBPasswordAlter(this.formTarget.settingForm.getFormParams()).then(data => {
                    if (data.status === '1') {
                        message.success(i18n.message.saveSuccess());
                    } else
                        message.error(data.message);
                    this.spinning = false;
                }, error => {
                    this.spinning = false;
                });
            } else {
                f.showErrors();
                this.showError = new Date().getTime();
            }
        });
    }

    @action save = (id) => {
        switch (this.tabConfig.activeTabKey) {
            case '1':
                this.saveBasicSetting();
                break;
            case '2':
                this.saveAdvanceSetting();
                break;
            case '3':
                this.saveNetworkSetting(id);
                break;
            case '4':
                this.saveDb();
                break;
            default:
                break;
        }
    }

    @action getNetworkSegmentStrategyCondition = () => {
        this.spinning = true;
        api.getNetworkSegmentStrategyCondition().then((data) => {
            if (data.status === '1') {
                this.setFormData('conditionForm', data.formField);
                this.getNetworkSetting();
                this.refreshTab = new Date().getTime();
            }
            this.spinning = false;
        }, error => this.spinning = false);
    }

    @action getNetworkSetting = (params) => {
        this.table = new TableStore();
        api.getNetworkSegmentStrategyList(params).then(data => {
            if (data.status === '1') {
                this.table.getDatas(data.sessionkey, 1);
            } else
                message.error(data.message);
        }, error => { });
    }

    @action getNetworkSegmentStrategyForm = (params) => {
        api.getNetworkSegmentStrategyForm(params).then(data => {
            if (data.status === '1') {
                data.formField.map(c => {
                    c.items.map(item => {
                        const {
                            domkey,
                            rules,
                        } = item;

                        if (['inceptipaddressD', 'endipaddressD', 'inceptipaddress7', 'endipaddress7'].includes(domkey[0])) {
                            item.viewAttr = 3
                        } else {
                            item.viewAttr = 2;
                        }
                    });
                });
                this.setFormData('networkForm', data.formField);
                if (this.formTarget.networkForm.isFormInit) {
                    this.opId = (params && params.id ? params.id : null);
                    const title = (this.opId ? i18n.label.editNetworkStrategy() : i18n.label.createNetworkStrategy());
                    this.dialogParams.title = title;
                    this.dialogParams.style = {
                        width: 700,
                        height: 195
                    };
                    this.dialogParams.visible = true;
                }
            } else
                message.error(data.message);
        }, error => { });
    }
    /********************* Dialog *********************/
    DIALOG = {
        hasScroll: true,
        icon: 'icon-coms-hrm',
        iconBgcolor: '#217346',
        onCancel: () => this.closeDialog(),
        moreBtn: {
            datas: []
        },
    }

    mainDialogStyle = {
        width: 700,
        height: 550
    }

    subDialogStyle = {
        width: 700,
        height: 350
    }

    subDialogBtns = [
        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@xz3vgx`} type='primary' onClick={() => this.addWhiteList()}>{i18n.button.save()}</Button>
    ]

    @observable dialog = {
        visible: false,
        title: '',
    }

    @observable subDialog = {
        visible: false,
        title: '',
    }

    @action openDialog = () => {
        if (!this.dialog.visible) {
            this.getTableInfo();
            this.dialog.title = i18n.label.whiteList();
            this.dialog.visible = true;
        } else {
            this.getFormInfo();
            this.subDialog.title = i18n.label.addWhiteList();
            this.subDialog.visible = true;
        }
    }

    @action closeDialog = () => {
        if (this.subDialog.visible) {
            this.subDialog.visible = false;
        } else {
            this.dialog.visible = false;
        }
    }

    /********************* Table *********************/
    TABLE = {
        hasOrder: true,
        needScroll: true,
        scroll: {
            y: 400
        }
    }

    @observable tableObj = {
        comsWeaTableStore: new TableStore(),
    }

    @action getTableInfo = () => {
        api.getWhiteList().then(data => {
            const {
                sessionkey,
            } = data;

            this.tableObj.comsWeaTableStore = new TableStore();
            this.tableObj.comsWeaTableStore.getDatas(sessionkey, 1);
        }, error => { })
    }

    /***************** ButtonIcons *****************/
    buttonIcons = [{
        buttonType: 'add',
        type: 'primary',
        onClick: () => this.addInfoToTable()
    }, {
        buttonType: 'del',
        type: 'primary',
        onClick: () => this.delInfoFromTable()
    }];

    @computed get delIconState () {
        const {
            comsWeaTableStore
        } = this.tableObj, {
            selectedRowKeys
        } = comsWeaTableStore;

        return selectedRowKeys.length === 0
    }

    addInfoToTable = () => {
        this.openDialog();
    }

    delInfoFromTable = () => {
        const callback = () => {
            const callback = () => {
                this.getTableInfo();
            }
            this.delLogic(callback);
        }

        this.delConfirm(callback);

    }

    delConfirm = (callback) => {
        confirm({
            title: getLabel('131329', '信息确认'),
            content: getLabel('385625', '确定要删除选择的记录吗？'),
            okText: getLabel('33703', '确定'),
            cancelText: getLabel('32694', '取消'),
            onOk () {
                callback && callback();
            },
            onCancel () {
                return false;
            },
        });
    }

    delLogic = (callback) => {
        const {
            comsWeaTableStore
        } = this.tableObj, {
            selectedRowKeys
        } = comsWeaTableStore;

        api.deleteWhiteList({
            ids: selectedRowKeys.toString()
        }).then(data => {
            const {
                sign
            } = data;
            if (sign === '1') {
                message.success(data.message);
                callback && callback();
            } else {
                message.warning(data.message);
            }
        }, error => { })
    }

    /***************** ConfigurableForm *****************/
    linkage = {
        resourceId: {
            activeKey: 'objectType',
            activeValue: '1'
        },
        subcompanyId: {
            activeKey: 'objectType',
            activeValue: '2'
        },
        departmentId: {
            activeKey: 'objectType',
            activeValue: '3'
        },
        isIncludeSub: {
            activeKey: 'objectType',
            activeValue: '2,3'
        },
        roleId: {
            activeKey: 'objectType',
            activeValue: '4'
        },
        roleLevel: {
            activeKey: 'objectType',
            activeValue: '4'
        },
        jobtitleId: {
            activeKey: 'objectType',
            activeValue: '7'
        },
        jobtitleLevel: {
            activeKey: 'objectType',
            activeValue: '7'
        },
        subcomIdOfJob: {
            activeKey: 'jobtitleLevel',
            activeValue: '1'
        },
        deptIdOfJob: {
            activeKey: 'jobtitleLevel',
            activeValue: '2'
        },
        seclevel: {
            activeKey: 'objectType',
            activeValue: '2,3,4,5'
        }
    }
    @observable configurableForm = {
        form: new WeaForm(),
        conditions: [],
        loading: false,
    }

    @action getFormInfo = () => {
        this.configurableForm.loading = true;

        api.getWhiteListForm().then(data => {
            const {
                conditions
            } = data;

            this.modifyCondition(conditions);

            this.configurableForm.form = new WeaForm();
            this.configurableForm.conditions = conditions;
            this.configurableForm.form.initFormFields(conditions);
            this.configurableForm.loading = false;
        }, error => { })
    }

    modifyCondition = (conditions) => {
        conditions.forEach(c => {
            c.items.forEach(item => {
                const {
                    domkey,
                } = item;

                const key = domkey[0];
                if (key === 'seclevel') {
                    Object.assign(item, {
                        rules: 'scopeRequired',
                        startValue: 10,
                        endValue: 100,
                    });
                }
            })
        });
    }

    onFormChange = (datas) => {
        const {
            form
        } = this.configurableForm;
        if (datas.hasOwnProperty('objectType')) {
            const objectType = datas.objectType.value;
            if (objectType !== '7') {
                form.updateFields({
                    jobtitleLevel: '0'
                });
            }
        }
    }

    addWhiteList = () => {
        const callback = () => {
            const callback = () => {
                this.closeDialog();
                this.getTableInfo();
            }
            this.saveForm(callback)
        }
        this.setNoNeedValidateFields();
        this.validateForm('configurableForm', callback)
    }

    setNoNeedValidateFields = () => {
        window.e9HideFormFieldKeys = [];

        const getNeedValidateFieldKey = (conditions) => {
            const keys = [];
            conditions.map(c => {
                c.items.map(item => {
                    const {
                        viewAttr,
                        domkey
                    } = item;

                    if (viewAttr === 3) {
                        keys.push(domkey[0])
                    }
                });
            });
            return keys
        }

        const getNoNeedValidateKeys = (allKeys, needValidateKeys) => {
            const noNeedValidateKeys = allKeys.filter(key => !needValidateKeys.includes(key));
            return noNeedValidateKeys;
        }

        const {
            form,
            conditions
        } = this.configurableForm, {
            objectType,
            jobtitleLevel
        } = form.getFormParams();

        const allValidateKeys = getNeedValidateFieldKey(conditions);

        let noNeedValidateKeys;
        if (objectType === '1') {
            noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['resourceId']);
        }
        if (objectType === '2') {
            noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['subcompanyId', 'seclevel']);
        }
        if (objectType === '3') {
            noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['departmentId', 'seclevel']);
        }
        if (objectType === '4') {
            noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['roleId', 'seclevel']);
        }
        if (objectType === '7') {
            if (jobtitleLevel === '0') {
                noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['jobtitleId']);
            } else if (jobtitleLevel === '1') {
                noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['jobtitleId', 'subcomIdOfJob']);
            } else {
                noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['jobtitleId', 'deptIdOfJob']);
            }
        }
        if (objectType === '5') {
            noNeedValidateKeys = getNoNeedValidateKeys(allValidateKeys, ['seclevel']);
        }

        window.e9HideFormFieldKeys = noNeedValidateKeys;
    }

    validateForm = (formType, callback) => {
        this[formType].form.validateForm().then(f => {
            if (f.isValid) {
                callback && callback();
            } else {
                f.showErrors();
            }
        })
    }

    saveForm = (callback) => {
        api.addWhiteList({
            ...this.configurableForm.form.getFormParams()
        }).then(data => {
            const {
                sign,
            } = data;

            if (sign === '1') {
                callback && callback();
            } else {
                message.warning(data.message);
            }
        }, error => { })
    }

    @action onSecondNeedusbDtChangeHandle = v => {
        v.secondNeedusbDt && v.secondNeedusbDt.value == '1' && this.formTarget.settingForm.updateFields({
            needusbDt: {
                value: '1'
            }
        });
        this.onFormItemChangeHandle(v);
    }

    @action onNeedusbDtChangeHandle = v => {
        v.needusbDt.value == '0' && this.formTarget.settingForm.updateFields({
            secondNeedusbDt: {
                value: '0'
            }
        });
    }

    @action onCAChangeHandle = v => {
        v.mobileScanCA && v.mobileScanCA.value == '0' && this.formTarget.settingForm.updateFields({
            secondCA: {
                value: '0'
            },
            secondCADefault: {
                value: '0'
            }
        });
    }

    @action onFormItemChangeHandle = v => {
        has(v, 'secondNeedDynapass') && v.secondNeedDynapass.value == '0' && this.formTarget.settingForm.updateFields({ secondDynapassDefault: { value: '0' } });
        has(v, 'secondNeedusbDt') && v.secondNeedusbDt.value == '0' && this.formTarget.settingForm.updateFields({ secondUsbDtDefault: { value: '0' } });
        has(v, 'secondCA') && v.secondCA.value == '0' && this.formTarget.settingForm.updateFields({ secondCADefault: { value: '0' } });
        has(v, 'secondCL') && v.secondCL.value == '0' && this.formTarget.settingForm.updateFields({ secondCLDefault: { value: '0' } });
        has(v, 'secondFace') && v.secondFace.value == '0' && this.formTarget.settingForm.updateFields({ secondFaceDefault: { value: '0' } });
    }
}