// import React from "react";
// import {inject, observer} from "mobx-react";
// import { Button} from "antd";
// import {toJS} from "mobx";
// import {WeaForm, WeaLogView, WeaSwitch, WeaTableNew} from "comsMobx";
// import {WeaDialog, WeaLocaleProvider, WeaTools, WeaSearchGroup, WeaFormItem, WeaRightMenu,WeaTab,WeaNewScroll,WeaTop,WeaPopoverHrm} from "ecCom";
// import * as IntegrationUtil from "../../util/IntegrationUtil";
// import AppDataMappingEditDialog from "./AppDataMappingEditDialog";
// import AppDataMappingImportDialog from "./AppDataMappingImportDialog";
// import AppDataMappingImportResultDialog from "./AppDataMappingImportResultDialog";
// import uuid from 'uuid';
// import {checkTableFieldValueUnique}  from "../../apis/CommonService";

// const { getKey } = WeaTools;
// const getLabel = WeaLocaleProvider.getLabel;
// const { WeaTable } = WeaTableNew;
// const store = ["authenticationCenterStore"];

// @inject(...store)
// @observer
// export default class AppEditDetailDialog extends React.Component {
//   constructor (props) {
//     super(props);
//     this.state = {
//       topTab: [
//         {
//           color: "#000000",
//           groupid: "flowAll",
//           showcount: true,
//           title: `${getLabel(81711, "基本信息")}`,
//           viewcondition_dt: 0
//         }
//         ,{
//           color: "#000000",
//           groupid: "flowAll",
//           showcount: true,
//           title: `${getLabel(131274, "运行日志")}`,
//           viewcondition_dt: 2
//         }
//       ],
//       topTabAll: [
//         {
//           color: "#000000",
//           groupid: "flowAll",
//           showcount: true,
//           title: `${getLabel(81711, "基本信息")}`,
//           viewcondition_dt: 0
//         }
//         ,{
//           color: "#000000",
//           groupid: "flowAll",
//           showcount: true,
//           title: `${getLabel(381943, "数据映射")}`,
//           viewcondition_dt: 1
//         }
//         ,{
//           color: "#000000",
//           groupid: "flowAll",
//           showcount: true,
//           title: `${getLabel(131274, "运行日志")}`,
//           viewcondition_dt: 2
//         }
//       ],
//       collectParams: {
//         favname: `${getLabel(381908, "统一认证中心")}`,
//         favouritetype: 1,
//         objid: 0,
//         link: "wui/engine.html#/integration/AuthenticationCenter",
//         importantlevel: 1
//       }
//     }
//   }

//   render() {
//     const {authenticationCenterStore} = this.props;
//     const {status, registerAppEditForm, registerAppEditFormOrg, registerAppId, editDetailDialogSelectedKey, tableStore2, tableStore3} = authenticationCenterStore;
//     const {showSearchAd2, selectedKey, registerAppEditFormHiddenFields, registerAppEditFormCodition, appEditFormDetailDialogVisible} = toJS(status);
//     const {topTab, topTabAll, collectParams} = this.state;

//     return <WeaDialog
//       title={(registerAppEditFormHiddenFields && registerAppEditFormHiddenFields.id) ? getLabel('82178','编辑应用') : getLabel('382079','注册应用')}
//       onCancel={()=> authenticationCenterStore.setState({appEditFormDetailDialogVisible: false})}
//       visible={appEditFormDetailDialogVisible}
//       style={{width: 900, height: 600}}
//       hasScroll
//       moduleName="integration"
//       buttons={(registerAppEditFormHiddenFields && registerAppEditFormHiddenFields.id == "") || editDetailDialogSelectedKey == 0
//          ? [<Button type="primary" onClick={()=> this.onRightMenuClick('BTN_SAVE')}>{getLabel(86,'保存')}</Button>] : []}
//       moreBtn={{datas: this.getRightMenu(), collectParams: collectParams}}
//     >
//       <WeaPopoverHrm />
//       <WeaRightMenu
//         datas={this.getRightMenu()}
//         collectParams={collectParams}
//       >
//         {
//           registerAppEditFormHiddenFields && registerAppEditFormHiddenFields.id 
//             ? <WeaTab
//                 datas={['6', '7'].includes(registerAppEditFormOrg.getFormParams().account_rules) ? topTabAll : topTab}
//                 keyParam="viewcondition_dt" 
//                 selectedKey={editDetailDialogSelectedKey}
//                 searchType={editDetailDialogSelectedKey == 1 ? ['advanced'] : []}
//                 advanceHeight={80}
//                 buttons={editDetailDialogSelectedKey == 1 ? this.getTabButton() : []}
//                 searchsAd={this.getAdvancedSearch()}
//                 showSearchAd={showSearchAd2}
//                 buttonsAd={this.getTabButtonsAd()}
//                 setShowSearchAd={() => {authenticationCenterStore.setState({ showSearchAd2: !showSearchAd2 })}}
//                 hideSearchAd={() => {authenticationCenterStore.setState({ showSearchAd2: false })}}
//                 onChange={v => {
//                   if(v == 1) {
//                     authenticationCenterStore.searchForm2 = new WeaForm();
//                     authenticationCenterStore.getRegisterAppDataMappingCondition();
//                     authenticationCenterStore.getRegisterAppDataMappingRightMenu();
//                     authenticationCenterStore.getRegisterAppDataMappingList({id: registerAppId});
//                   }else if(v == 2) {
//                     authenticationCenterStore.getRegisterAppLoginLogList({id: registerAppId});
//                   }else {
//                     authenticationCenterStore.getRegisterAppEditForm({id: registerAppId});
//                   }
//                   authenticationCenterStore.setEditDetailDialogSelectedKey(v);
//                 }}
//               /> 
//             : ""
//         }
//         <WeaNewScroll height={(registerAppEditFormHiddenFields && registerAppEditFormHiddenFields.id) ? 550 : 600}>
//           {
//             registerAppEditFormHiddenFields && registerAppEditFormHiddenFields.id
//               ? editDetailDialogSelectedKey == 0 
//                 ? this.getForm(registerAppEditForm, registerAppEditFormCodition)
//                 : <WeaTable
//                     key={editDetailDialogSelectedKey}
//                     comsWeaTableStore={editDetailDialogSelectedKey == 1 ? tableStore2 : tableStore3}
//                     hasOrder={true}
//                     needScroll={true}
//                     onOperatesClick={this.onOperatesClick.bind(this)}
//                     // uniqueId={true}
//                   />
//               : this.getForm(registerAppEditForm, registerAppEditFormCodition)
//           }
//         </WeaNewScroll>
//         <AppDataMappingEditDialog/>
//         <AppDataMappingImportDialog/>
//         <AppDataMappingImportResultDialog/>
//       </WeaRightMenu>
//     </WeaDialog>
//   }

//   getAdvancedSearch = () => {
//     const { authenticationCenterStore } = this.props;
//     const {searchForm2, status} = authenticationCenterStore;
//     const {showSearchAd, selectedKey, condition2} = toJS(status);
//     let btns = [];
//     btns = IntegrationUtil.getAdvancedSearchs(
//       searchForm2,
//       condition2,
//       false,
//       2
//     );
//     return btns;
//   };

//   getTabButtonsAd() {
//     const { authenticationCenterStore } = this.props;
//     let searchFun = () => {
//       authenticationCenterStore.getRegisterAppDataMappingList({id: authenticationCenterStore.registerAppId});
//       authenticationCenterStore.setState({showSearchAd2: false});
//     };
//     let resetFun = () => authenticationCenterStore.searchForm2.reset();
//     let cancelFun = () => authenticationCenterStore.setState({showSearchAd2: false});
//     return IntegrationUtil.getSearchBtns(searchFun, resetFun, cancelFun);
//   }

//   getTabButton = () => {
//     const {authenticationCenterStore} = this.props;
//     let {rightMenus2, rowSelectIds2} = toJS(authenticationCenterStore.status);
//     let btnArr = [];
//     let rightDis = 0;
//     if(!rightMenus2){return btnArr}
//     for (let j = 0, len = rightMenus2.length; j < len; j++) {
//       if (j == 4)  break;
//       if(j == 2) rightDis = 15;
//       let m = rightMenus2[j];
//       btnArr.push(
//         <Button style={{marginRight:rightDis}} type="primary" disabled={m.menuIcon === 'icon-coms-delete' && toJS(authenticationCenterStore.tableStore2.selectedRowKeys).length === 0} onClick={() => this.onRightMenuClick(m.type)}>{`${m.menuName}`}</Button>
//       );
//     }
//     return btnArr;
//   };

//   getForm = (form, datas) => {
//     const formParams = form.getFormParams();
//     const {isFormInit} = form;
//     let group = [];

//     isFormInit && datas && datas.forEach(c => {
//       let items = [];
//       c.items && c.items.map(fields => {
//         let domkey = fields.domkey[0];
//         items.push({
//           com: (
//             <WeaFormItem
//               label={`${fields.label}`}
//               labelCol={{span: `${fields.labelcol}`}}
//               wrapperCol={{span: `${fields.fieldcol}`}}
//               error={form.getError(fields)}
//               tipPosition="bottom"
//             >
//               <nobr>
//                 <WeaSwitch fieldConfig={fields} form={form} formParams={formParams} onChange={v => {
//                   if(getKey(fields) === 'appid') {
//                     let checkParams = {
//                       tableName: 'weaver_sso_app',
//                       fieldName: 'appid',
//                       fieldValue: form.getFormParams().appid.replace(/^(\s*)|(\s*)$/g, ''),
//                       idName: 'id',
//                       idValue: ''
//                     };
//                     checkTableFieldValueUnique(checkParams).then(result => {
//                       if(result && result.isNotUnique) {
//                         form.showError('appid',getLabel('387654','标识已存在'));
//                       }
//                     });
//                   }
//                 }}/>
//                 {/*{getKey(fields)==='account_rules'&&formParams.account_rules>5?<Button type="primary" style={{marginLeft:5}}>{getLabel(86,'数据映射')}</Button>:""}*/}
//                 {getKey(fields) === "appid" && <Button type="primary" disabled={fields.viewAttr == 1} style={{marginLeft: 40}} onClick={v => form.updateFields({appid: uuid()})}>{getLabel('15413','生成')}</Button>}
//                 {getKey(fields) === "app_secret_" && <Button type="primary" disabled={fields.viewAttr == 1} style={{marginLeft: 40}} onClick={v => form.updateFields({app_secret_: IntegrationUtil.getAppSecret(true, 6, 16)})}>{getLabel('15413','生成')}</Button>}
//               </nobr>
//             </WeaFormItem>),
//           colSpan: 1,
//           hide: form.isHide(fields, (key, allParams) => {
//             let hide = false;
//             'app_secret_' == domkey && allParams.auth_type_ == "CAS" && (hide = true);
//             'definebroswerType' == domkey && allParams.account_rules !== '7' && (hide = true);
//             ["appid", "app_secret_", "appname", "allow_ip", "account_rules", "definebroswerType"].includes(domkey) && allParams.auth_type_ == "" && (hide = true);
//             return hide;
//           })
//         })
//       })
//       group.push(<WeaSearchGroup center={true} col={1} needTigger={true} title={c.title} showGroup={c.defaultshow} items={items}/>)
//     })
//     return group;
//   }

//   getRightMenu = () => {
//     const {authenticationCenterStore} = this.props;
//     let {rightMenus2,rowSelectIds2} = toJS(authenticationCenterStore.status);
//     let btnArr = [];
//     if(authenticationCenterStore.editDetailDialogSelectedKey==0) {
//       btnArr=[
//         {
//           key: 'BTN_SAVE',
//           icon: <i className='icon-coms-Preservation'/>,
//           content : `${getLabel(86,'保存')}`,
//           onClick : () => {this.onRightMenuClick('BTN_SAVE')}
//         }
//       ];
//     }else if(authenticationCenterStore.editDetailDialogSelectedKey==1) {
//       btnArr = [];
//       rightMenus2&&rightMenus2.map(m => {
//         var btn= {
//           key: m.type,
//           icon: <i className={m.menuIcon} />,
//           content: m.menuName,
//           onClick: () => this.onRightMenuClick(m.type),
//           disabled: m.menuIcon==='icon-coms-delete' && rowSelectIds2.length === 0
//         } ;
//         btnArr.push(btn);
//       });
//       btnArr.push({
//         key: "BTN_COLUMN",
//         icon: <i className="icon-coms-Custom" />,
//         content: `${getLabel(32535, "显示列定制")}`,
//         onClick: () => this.onRightMenuClick("BTN_COLUMN")
//       });
//     }

//     return btn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){3}))|:)))(%.+)?\s*$/;
//     let regV4 = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/

//     let datas = value.split(',');
//     for(let i = 0; i < datas.length; i++) {
//       if(!reg.test(datas[i].trim()) && (!regV4.test(datas[i].trim()))) {
//         return false;
//       }
//     }
//     return true;
//   }

//   onRightMenuClick = (type) => {
//     const {authenticationCenterStore} = this.props;
//     const {registerAppEditForm, status, editDetailDialogSelectedKey, tableStore2} = authenticationCenterStore;
//     const {rowSelectIds2, registerAppEditFormHiddenFields} = toJS(authenticationCenterStore.status);
//     const formParams = registerAppEditForm.getFormParams();

//     if(type === "BTN_COLUMN") {
//       if(editDetailDialogSelectedKey == 1) {
//         authenticationCenterStore.tableStore2.setColSetVisible(true);
//         authenticationCenterStore.tableStore2.tableColSet(true);
//       }
//     }

//     if(type == 'BTN_SAVE'){
//       if(formParams.auth_type_ == "CAS") {
//         window.e9HideFormFieldKeys = ["app_secret_"];
//       }
//       let checkParams = {
//         tableName: 'weaver_sso_app',
//         fieldName: 'appid',
//         fieldValue: formParams.appid.replace(/^(\s*)|(\s*)$/g, ''),
//         idName: 'id',
//         idValue: ''
//       };
//       checkTableFieldValueUnique(checkParams).then(result => {
//         if(result && result.isNotUnique && registerAppEditFormHiddenFields.id == "") {
//           registerAppEditForm.showError('appid',getLabel('387654','标识已存在'));
//         }else {
//           let value = formParams.allow_ip;
//           let ipv6 = this.ipv6Test(value.trim());
//           IntegrationUtil.onCheck(registerAppEditForm,function () {
//             if(value.trim() == '' || (value.trim() && ipv6)) {
//               let params = Object.assign({id: registerAppEditFormHiddenFields.id || "", operation: registerAppEditFormHiddenFields.id ? "edit" : "add"}, formParams);
//               authenticationCenterStore.getRegisterAppOperation(params);
//             }else {
//               registerAppEditForm.showError('allow_ip',getLabel('382232','应用服务器地址非法'));
//             }
//           });
//         }
//       });
//     }

//     if(type == 'rb_1'){
//       //注册数据映射
//       this.doDataMappingEditById({randomField0: '',appid: formParams.appid});
//     }

//     if(type == 'rb_2'){
//       //导入
//       authenticationCenterStore.registerAppDataMappingImportForm.reset();
//       let id=authenticationCenterStore.registerAppId;
//       let params = Object.assign({id: id, operation:"import"}, formParams);
//       authenticationCenterStore.getRegisterAppDataMappingImportForm(params);
//       authenticationCenterStore.setState({ appEditFormDetailDataMappingImportDialogVisible: true });

//     }

//     if(type == 'rb_3'){
//       //删除
//       if(toJS(tableStore2.selectedRowKeys).length>0) {
//         authenticationCenterStore.confirmModal(`${getLabel(385625, '确定要删除选择的记录吗？')}`, authenticationCenterStore.getRegisterAppDataMappingOperation, {operation:'delete', id: toJS(tableStore2.selectedRowKeys)});
//       }
//     }
//   }

//   onOperatesClick = (record, index, operate) => {
//     const { authenticationCenterStore } = this.props;
//     const { selectedKey } = toJS(authenticationCenterStore.status);
//     if (operate.index == "0") {
//       this.doDataMappingEditById(record);
//     }
//     if (operate.index == "1") {
//       //删除
//       authenticationCenterStore.confirmModal(`${getLabel(15097, '确定要删除吗？')}`, authenticationCenterStore.getRegisterAppDataMappingOperation, {operation:'delete',id: record.randomField0});
//     }
//   };

//   doDataMappingEditById(record) {
//     const { authenticationCenterStore } = this.props;
//     const { registerAppEditForm } = authenticationCenterStore;
//     authenticationCenterStore.registerAppDataMappingEditForm.reset();
//     authenticationCenterStore.setOperateDataMappingIndex(record.randomField0);
//     authenticationCenterStore.getRegisterAppDataMappingEditForm({ id: record.randomField0,appid:record.appid ,account_rules:registerAppEditForm.getFormParams().account_rules});
//     authenticationCenterStore.setState({ appEditFormDetailDataMappingDialogVisible: true });
//   }

// }
