import { observable, action, toJS } from "mobx";
import * as API from "../apis/DataShowService";
import { Modal, message } from "antd";
import { WeaTableNew, WeaForm, WeaLogView } from "comsMobx";
import isFunction from 'lodash/isFunction';
import {WeaLocaleProvider, WeaTools} from "ecCom";
import {getSearchFormHeight, checkHasOrganization, isCallBackFunction} from '../util/IntegrationUtil';

const { TableStore } = WeaTableNew;
const {getLabel} = WeaLocaleProvider;
const {Base64} = WeaTools;
const {LogStore} = WeaLogView;

export class DataShowStore {
    @observable hasRight = false;
    @observable rightLoading = true;
    @observable tableStore = new TableStore();
    @observable cacheDataTableStore = new TableStore();
    @observable searchForm = new WeaForm();
    @observable cacheDataSearchForm = new WeaForm();
    @observable newForm = new WeaForm();
    @observable newE7Form = new WeaForm();
    @observable source = "";
    @observable testForm = new WeaForm();
    @observable showDialog = false;
    @observable showSqlDialog = false;
    @observable showTestVersion = false;
    @observable status = {};
    @observable logStore = new LogStore();

    @action("清空store")
    cleanStore = () => {
        this.logStore = new LogStore();
        this.searchForm = new WeaForm();
        this.testForm = new WeaForm();
        this.newForm = new WeaForm();
        this.newE7Form = new WeaForm();
        this.hasRight = false;
        this.rightLoading = true;
        this.setState({
            buttonDisabled: false,
            tabButtonDisabled: false,
            selectedKey: "0",
            cacheDataSearchCondition: [],
            collectParams: {
                favname: `${getLabel(32303, "数据展现集成")}`,
                favouritetype: 1,
                objid: 0,
                link: "wui/engine.html#/integration/datashow",
                importantlevel: 1
            },
            showXml:true,
            showIframe:false,
            showTestFormDialog : false,
            showTextFormButton: false,
            showPreviewDialog : false,
            showsSqlTextFormDialog: false,
            showsSqlTextFormDialog2:false,
            selectedKey: 0,
            dataShowConditionInfo: [],
            dataShowFormFields: [],
            dataShowFormHiddenFields: [],
            dataShowE7FormFields: [],
            dataShowE7FormHiddenFields: [],
            rightMenus: [],
            showNewFormDialog: false,
            showNewE7FormDialog: false,
            WebserviceMethodList:[],
            WebserviceMethodParameterDatas:[],
            WeaTableEdit_SearchField:[],
            WeaTableEdit_SearchFieldData:[],
            WeaTableEdit_ListField:[],
            WeaTableEdit_ListFieldData:[],
            esbSearchDatas: [],
            esbShowDatas: [],
            // test页面
            type: '',
            testInitDatas: {},
            showIndexTestDialog: false,
            showIndexTestDialog2: false,
            subcompanyid: "",
            menus: [],
        });
    }

    @action
    doInit = () => {
        this.cleanStore();
        checkHasOrganization((result) => {
            this.setState({
                hasOrganization: result,
            })
        });
        this.getDataShowCondition({}, this.getDataShowInfo);
    };

    setState = (params = {}) => {
        let status = { ...this.status };
        Object.keys(params).forEach(key => {
            status[key] = params[key];
        });
        this.status = status;
    };

    //手动输入参数
    @observable sqlTextForm = {
        condition: [],
        form: new WeaForm(),
        loading: true,
    };

    //初始化sqlTextForm
    @action
    initSqlTestForm = () =>{
        this.sqlTextForm ={
            condition: [],
            form: new WeaForm(),
            loading: true,
        };
        this.status = {
            ...this.status, /*更新状态时，不能够覆盖其他的属性*/
            showsSqlTextFormDialog: false,
            showsSqlTextFormDialog2:false,
        };
    };

    @action
    initTestFrom =() =>{
        this.status = {
            ...this.status, /*更新状态时，不能够覆盖其他的属性*/
            showTestFormDialog : false,
            showPreviewDialog : false,
            showTextFormButton: false,
            showIframe : false,
            showXml : true,
        };
    };

    @action
    initIndexTestDialog = ()=>{
        this.status = {
            ...this.status, /*更新状态时，不能够覆盖其他的属性*/
            testInitDatas: {},
            showIndexTestDialog:false,
            showIndexTestDialog2:false,
        };
    };

    // 缓存tab页每条数据 缓存管理设置 高级搜索
    @action
    getCacheManageCondition = (params={}, callBack=null) => {
      this.searchForm = new WeaForm();
      API.getDataShowCacheSetCondition(params).then(result => {
        if(result.status == "1") {
          this.setState({
            dataShowConditionInfo: result.condition || [],
            advanceHeight: getSearchFormHeight(result.condition), 
          });
          this.searchForm.initFormFields(result.condition);
          if(isCallBackFunction(callBack)) {
            callBack();
          }
        }
      })
    };

    // 缓存tab页每条数据 缓存管理设置 table页
    @action
    getCacheManageListInfo = (params={}) => {
      this.tableStore = new TableStore();
      params = Object.assign({}, this.searchForm.getFormParams(), params, {subcompanyid: this.status.subcompanyid});

      Promise.all([
        API.getDataShowCacheSetRightMenu(params),
        API.getDataShowCacheSetList(params),
      ]).then(([result1, result2]) => {
        if(result2.datas) {
          this.tableStore.getDatas(result2.datas, 1);
        }
        this.setState({
          rightMenus: result1.rightMenus || [],  
        })
      })
    }

    // 缓存tab页列表
    @action
    getCacheManageListTable = (params={}) => {
      this.tableStore = new TableStore();
      params = Object.assign({}, this.searchForm.getFormParams(), params, {subcompanyid: this.status.subcompanyid});

      API.getDataShowCacheSetList(params).then(result => {
        if(result.datas) {
          this.tableStore.getDatas(result.datas, 1);
        }
      })
    }

    // 缓存tab页的操作
    @action 
    getDataShowCacheOperation = (params={}) => {
      this.setState({
        tabButtonDisabled: true,
      })
      API.getDataShowCacheOperation(params).then(result => {
        if(result.status == "1") {
          if(result.msg) {
            message.success(result.msg);
          }

          if(["openCache", "closeCache"].includes(params.operate)) {
            this.getCacheManageListTable();
          } else {
            this.getCacheDataManageInfo();
            this.cleanCacheDetailDialogStore();
          }
        } else {
          if(result.msg) {
            message.error(result.msg);
          }
        }
        this.setState({
          tabButtonDisabled: false,
        })
      })
    }

    // 关闭弹窗清空新建的弹窗的内容
    @action
    cleanCacheDetailDialogStore = () => {
      this.setState({
        cacheDataManageDetailVisible: false,
        cacheDataDetailOperateInfo: "",
      })  
    }

    // 缓存数据管理 新建
    @action
    getCacheDataManageCondition = (params={}, callBack) => {
      this.cacheDataSearchForm = new WeaForm();
      API.getDataShowCacheDataCondition(params).then(result => {
        if(result.status) {
          this.setState({
            cacheDataSearchCondition: result.condition || [],
            cacheDataSearchAdvancedHeight: getSearchFormHeight(result.condition),
          })
          this.cacheDataSearchForm.initFormFields(result.condition);
          if(isCallBackFunction(callBack)) {
            callBack();
          }
        }
      })
    }

    @action
    getCacheDataManageInfo = (params={}) => {
      this.cacheDataTableStore = new TableStore();
      params = Object.assign({}, this.cacheDataSearchForm.getFormParams(), {id: this.status.cacheDataOperateInfo ? this.status.cacheDataOperateInfo.showname : ""}, params);

      Promise.all([
        API.getDataShowCacheDataList(params),
        API.getDataShowCacheDataRightMenu(params)  
      ]).then(([result1, result2]) => {
        if(result1.datas) {
          this.cacheDataTableStore.getDatas(result1.datas, 1);
        } 
        this.setState({
          menus: result2.rightMenus || [], 
          cacheDataDialogTitle: result2.tablename || "",
        })
      })
    }

    // 缓存数据管理新建页面
    @action
    getDataShowCacheDataForm = (params={}) => {
      this.newForm = new WeaForm();
      API.getDataShowCacheDataForm(params).then(result => {
        if(result.status == "1") {
          this.setState({
            dataShowFormFields: result.condition || [],
            cacheDetailMenus: result.rightMenus || [],
          })
          this.newForm.initFormFields(result.condition);
        }  
      })
    }

    //获取首页的测试信息
    getIndexTest= (id, from) => {
        let type = "INDEX_TEST";
        this.setState({ type });

        this.getDataShowEditForm({id}, () => {
            this.getIndexTestInfo(id, from)
        });
    };

    // 重构
    getIndexTestInfo = (id, from) => {
        const {
            WebserviceMethodParameterDatas=[],
            WeaTableEdit_MergedFieldData=[],
            dataShowFormHiddenFields,
        } = this.status;

        //是否带有表单参数或人员参数
        let is_easysql = this.checkIsEasySql(this.newForm, WebserviceMethodParameterDatas, WeaTableEdit_MergedFieldData);
        if (!is_easysql) {
            const {
                datafrom,
                showname,
                showtype,
                showclass,
                sqltext,
                searchById,
                customhref,
                detailpageurl,
                sqltext1,
                searchByName,
                searchById1,
            } = this.newForm.getFormParams();

            let datas = WeaTableEdit_MergedFieldData && WeaTableEdit_MergedFieldData.map(data => {
                let transSQL = data.new_transql ? data.new_transql : '';
                return Object.assign({}, data, {new_transql: Base64.encode(transSQL)});
            });

            let checkParams = {
                datafrom,
                showname,
                showtype,
                showclass,
                sqltext: Base64.encode(sqltext),
                searchById: Base64.encode(searchById),
                customhref,
                detailpageurl,
                sqltext1: Base64.encode(sqltext1),
                searchByName:  Base64.encode(searchByName),
                searchById1: Base64.encode(searchById1),
                datas: JSON.stringify(WebserviceMethodParameterDatas),
                dtinfo_MergedFieldData: JSON.stringify(datas),
            };
            //查询参数form
            API.getSqlTextForm(checkParams).then(result => {
                if (result.status === '1') {
                    this.sqlTextForm.condition = result.condition;
                    this.sqlTextForm.form.initFormFields(result.condition);
                    
                    if('new' === from) {
                        this.setState({showsSqlTextFormDialog2: true});
                    } else {
                        this.setState({showsSqlTextFormDialog: true});
                    }
                }
            });
        } else {
            API.getIndexTest(id).then(result=>{
                if (result.ext === 'true') {
                    if (result.status) {
                        //获取首页测试的form数据
                        this.getDataShowTestForm(this.newForm.getFormParams(), dataShowFormHiddenFields, WebserviceMethodParameterDatas, this.status.type);
                    } else {
                        this.setState({
                            testInitDatas: result.data.base,
                        });

                        if('new' === from) {
                            this.setState({showIndexTestDialog2: true});
                        } else {
                            this.setState({showIndexTestDialog: true});
                        }
                    }
                }
            });
        }
    }

    //是否带有表单参数和人员参数
    checkIsEasySql = (newForm,WebserviceMethodParameterDatas,WeaTableEdit_MergedFieldData) => {
        let is_easysql = true;
        let formParams = newForm.getFormParams();
        // datafrom 数据来源  0-webservice  1-数据库  2-自定义页面 3-存储过程
        // showclass 展现类型 1-浏览框  2-查询页面
        // showtype 展现方式  1-列表式  2-树形； 3-自定义页面
        //webservice
        for (let i = 0; i < WebserviceMethodParameterDatas.length; i++) {
            //表单参数
            if ((/[$]+[_a-zA-Z0-9]+[$]/).test(WebserviceMethodParameterDatas[i].paramvalue) && formParams.datafrom==='0'&& formParams.showclass !== '2') {
                is_easysql = false;
            }
            //人员参数
            if((/[{?]+[_a-zA-Z0-9]+[}]/).test(WebserviceMethodParameterDatas[i].paramvalue) && formParams.datafrom==='0'){
                is_easysql = false;
            }
        }
        //存储过程
        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.sqltext1)&& formParams.datafrom==='3' && formParams.showclass !== '2' ){
            is_easysql = false;
        }
        //存储过程
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.sqltext1)&& formParams.datafrom==='3'){
            is_easysql = false;
        }

        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.searchByName)&& formParams.datafrom==='3' && formParams.showclass !== '2' ) {
            is_easysql = false;
        }
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.searchByName)&& formParams.datafrom==='3') {
            is_easysql = false;
        }

        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.searchById1)&& formParams.datafrom==='3' && formParams.showclass !== '2') {
            is_easysql = false;
        }
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.searchById1)&& formParams.datafrom==='3') {
            is_easysql = false;
        }
        //自定义地址
        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.customhref)&& formParams.datafrom==='2' && formParams.showclass !== '2') {
            is_easysql = false;
        }
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.customhref)&& formParams.datafrom==='2') {
            is_easysql = false;
        }
        //链接地址
        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.detailpageurl)&& formParams.showclass !== '2') {
            is_easysql = false;
        }
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.detailpageurl)) {
            is_easysql = false;
        }
        //数据库
        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.sqltext)&& formParams.datafrom==='1'&& formParams.showclass !== '2') {
            is_easysql = false;
        }
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.sqltext)&& formParams.datafrom==='1') {
            is_easysql = false;
        }
        if ((/[$]+[_a-zA-Z0-9]+[$]/).test(formParams.searchById)&& formParams.datafrom==='1'&& formParams.showclass !== '2') {
            is_easysql = false;
        }
        if ((/[{?]+[_a-zA-Z0-9]+[}]/).test(formParams.searchById)&& formParams.datafrom==='1') {
            is_easysql = false;
        }
        //流程联动字段
        if (formParams.showtype !== '2') {
            for (let i = 0; i < WeaTableEdit_MergedFieldData.length; i++) {
                let data = WeaTableEdit_MergedFieldData[i];
                if (data.new_wokflowfieldname && (/[$]+[_a-zA-Z0-9]+[$]/).test(data.new_wokflowfieldname) && formParams.showclass !== '2'){
                    is_easysql = false;
                }
                if (data.new_wokflowfieldname && (/[{?]+[_a-zA-Z0-9]+[}]/).test(data.new_wokflowfieldname)){
                    is_easysql = false;
                }
            }
        }

        return is_easysql;
    };

    getDataShowList = () => {
        let formParams = (this.searchForm && this.searchForm.getFormParams()) || {};
        let typename = this.source ? {typename: this.source} : {};
        let params = Object.assign({}, formParams, typename, {subcompanyid: this.status.subcompanyid});
        API.getDataShowList(params).then(result => {
          if(result.ret&&result.ret=="noright"){
            this.hasRight=false;
          }else{
            this.hasRight=true;
          }
          this.rightLoading = false;
          if (result.sessionkey) {
            this.tableStore.getDatas(result.sessionkey,1);
          } else {
            this.status = { ...this.status, isAlertPage: true };
          }
        });
    };

    getDataShowRightMenu = (params={}) => {
        params = Object.assign({}, params, {subcompanyid: this.status.subcompanyid});
        API.getDataShowRightMenu(params).then(result => {
            this.setState({
                rightMenus: result.rightMenus || [],
            });
        });
    };

    getDataShowInfo = (params1={}, params2={}) => {
        this.tableStore = new TableStore();
        let typename = this.source ? {typename: this.source} : {};
        params1 = Object.assign({}, this.searchForm.getFormParams(), typename, {subcompanyid: this.status.subcompanyid});
        params2 = Object.assign({}, params2, {subcompanyid: this.status.subcompanyid});
        Promise.all([
            API.getDataShowList(params1),
            API.getDataShowRightMenu(params2),
        ]).then(([result1, result2]) => {
            if(result1.ret && result1.ret == "noright") {
                this.hasRight = false;
                this.rightLoading = false;
            }else if(result1.status == 1) {
                this.tableStore.getDatas(result1.sessionkey, 1);
                this.setState({
                    rightMenus: result2.rightMenus || [],
                });
                this.hasRight = true;
                this.rightLoading = false;
            }
        })
    }

    @action
    getDataShowCondition = (params={}, callBack=null) => {
        this.searchForm = new WeaForm();
        params = Object.assign({}, params, {subcompanyid: this.status.subcompanyid});
        API.getDataShowCondition(params).then(result => {
            if(result.status == "1") {
                this.setState({
                    advanceHeight: getSearchFormHeight(result.condition), 
                    dataShowConditionInfo: result.condition || [],
                });
                this.searchForm.initFormFields(result.condition);
            }
            if(isCallBackFunction(callBack)) {
                callBack();
            }
        });
    };

    //获取测试的form数据
    @action
    getDataShowTestForm = (params,dataShowFormHiddenFields, WebserviceMethodParameterDatas,type) => {
        let showname = params.showname? params.showname : '';
        let formparams ={};

        // datafrom 数据来源  0-webservice  1-数据库  2-自定义页面 3-存储过程
        // showclass 展现类型 1-浏览框  2-查询页面
        // showtype 展现方式  1-列表式  2-树形； 3-自定义页面
        if (params.showclass=='2') {//查询页面需要iframe框展现
            formparams ={
                datafrom:params.datafrom,
                showname:showname,
                operate:'showPage',
            };
        }else if (params.datafrom=='0' && params.showclass!='2') {//如果数据来源是webservice，且展现类型不是查询页面的话
            let params1 = Object.assign(dataShowFormHiddenFields, params);
            params1.dtinfo_WebserviceMethodParameterDatas = JSON.stringify(WebserviceMethodParameterDatas);

            formparams ={
                operate:'getForm',
                showname:showname,
                showtype:params.showtype,
                datafrom:params.datafrom,
                datas : params1.dtinfo_WebserviceMethodParameterDatas,
                wsurl: params.wsurl,
                detailpageurl:params.detailpageurl,
                wsworkname: params.wsworkname,
                wsoperation: params.wsoperation,
                characterset:params.characterset,
            };
         } else {
            formparams ={
                operate:'getForm',
                datafrom:params.datafrom,
                showname:showname,
                showtype:params.showtype,
                datasourceid: params.datasourceid,
                detailpageurl:params.detailpageurl,
                customhref :params.customhref,
                characterset:params.characterset,
            };
        }

        API.getDataShowTestForm(formparams).then(result => {
            if (result && result.status == '1') {
               if (params.showclass=='2') {//如果展现类型是查询页面，则预览页面显示查询页面
                    this.testForm.initFormFields(result.condition);
                    this.status = {
                        ...this.status,
                        dataShowTestFormFields: result.condition,
                        showIframe:true,
                    };
                    if (type == 'INDEX_TEST') {
                        this.status.showTestFormDialog=true
                    }
                    if (type == 'BTN_TEST') {
                        this.status.showPreviewDialog=true
                    }

                    this.testForm.updateFields({
                        customerurl:`${window.ecologyContentPath || ""}/spa/inte/static/index.html#/main/inte/tab/${result.hiddenFields.id}`
                    });
                    this.status.dataShowFormHiddenFields = result.hiddenFields;

               } else if (params.datafrom=='0' && params.showclass!='2'|| params.datafrom=='2') {//如果数据来源是webservice或自定义页面，且展现类型不是查询页面的话
                    this.testForm.initFormFields(result.condition);
                    this.status = {
                        ...this.status,
                        dataShowTestFormFields: result.condition,
                        showXml:false,/* false 表示显示XML页面*/
                    };
                    if (type == 'INDEX_TEST') {
                        this.status.showTestFormDialog=true
                    }
                    if (type == 'BTN_TEST') {
                        this.status.showPreviewDialog=true
                    }

               } else {
                   this.testForm.initFormFields(result.condition);
                   this.status = {
                       ...this.status,
                       dataShowTestFormFields: result.condition,
                   };
                   if (type == 'INDEX_TEST') {
                       this.status.showTestFormDialog = true
                   }
                   if (type == 'BTN_TEST') {
                       this.status.showPreviewDialog = true
                   }
               }
            }
        })
    };

    @action
    getDataShowEditForm = (params={}, callBack) => {
        this.newForm = new WeaForm();
        this.setState({
            formLoading: false,
            buttonDisabled: true,
        });

        if(params && params.id == "") {
            params = Object.assign({}, params, {subcompanyid: this.status.subcompanyid});
        }
        API.getDataShowEditForm(params).then(result => {
            if(result.condition && result.condition[0] && result.condition[0].items) {
              result.condition[0].items.forEach((item, index) => {
                if(['sqltext', 'searchById', 'customhref', 'sqltext1', 'searchByName', 'searchById1'].includes(item.domkey[0])) {
                  result.condition[0].items[index].maxRows = 4;
                  result.condition[0].items[index].minRows = 4;
                }
              })
            }
            if(result.WeaTableEdit_MergedSearchFieldAndListField) {
                result.WeaTableEdit_MergedSearchFieldAndListField.forEach((v, index) => {
                if(v.dataIndex === "new_transql") {
                  result.WeaTableEdit_MergedSearchFieldAndListField[index].com[0].maxRows = 4;
                  result.WeaTableEdit_MergedSearchFieldAndListField[index].com[0].minRows = 2;
                }
              })
            }
            this.setState({
                dataShowFormFields: result.condition,
                dataShowFormHiddenFields: result.hiddenFields,
                WeaTableEdit_WebserviceParameterSet: result.WeaTableEdit_WebserviceParameterSet,
                WeaTableEdit_ESBShowParameterSet: result.WeaTableEdit_ESBShowParameterSet || [],
                WeaTableEdit_ESBSearchParameterSet: result.WeaTableEdit_ESBSearchParameterSet || [],
                WebserviceMethodParameterDatas: result.WebserviceMethodParameterDatas,
                esbShowDatas: result.ESBShowParameterDatas || [],
                WeaTableEdit_MergedSearchFieldAndListField: result.WeaTableEdit_MergedSearchFieldAndListField,
                WeaTableEdit_MergedFieldData: result.WeaTableEdit_MergedFieldData,
                menus: result.rightMenus || [],
            });
            this.newForm.initFormFields(result.condition);
            let datas = [], specialDatas = [];
            if(this.newForm.getFormParams().isSupportPaging == 0) {
              result.ESBSearchParameterDatas && result.ESBSearchParameterDatas.forEach(v => {
                if(!["pageNo", "startNo", "endNo", "pagesize"].includes(v.paramname.trim())) {
                  datas.push(v);
                }else {
                  specialDatas.push(v);
                }
              })
            }else {
              datas = [...(result.ESBSearchParameterDatas || [])];
              specialDatas = [];
            } 
            this.setState({
              esbSearchDatas: datas,
              specialDatas,
              formLoading: true,
              buttonDisabled: false,
            });
            this.getOpenPyhStatus();
            if(callBack && typeof(callBack) === "function") {
              callBack(result);
            }
        });
    };

    @action
    getDataShowEditForm4E7 = (params) => {
        this.setState({
            buttonDisabled: true,
        })
        API.getDataShowEditForm4E7(params).then(result => {
            this.setState({
                dataShowE7FormFields: result.condition,
                dataShowE7FormHiddenFields: result.hiddenFields,
                menus: result.rightMenus || [],
                buttonDisabled: false,
            })

            this.newE7Form.initFormFields(result.condition);
        });
    };

    @action
    getDataShowOperation4E7 = (params) => {
        this.setState({
            buttonDisabled: true,
        })
        API.getDataShowOperation4E7(params).then(result => {
            this.getDataShowList();
            this.setState({showNewE7FormDialog: false, buttonDisabled: false});
        });
    };

    @action
    getDataShowOperation = (params={}, callBack) => {
        this.setState({
            buttonDisabled: true,
        })
        API.getDataShowOperation(params).then(result => {
            if(params.operator) {
                if (params.operator=="checkShowName"){
                }else if (params.operator=="getregisteinfo"){
                    const {dataShowFormFields} = toJS(this.status);
                    dataShowFormFields[0].items[dataShowFormFields[0].items.findIndex(v => v.domkey[0] === 'wsoperation')].options=result.WebserviceMethodList;
                    this.setState({dataShowFormFields: dataShowFormFields});
                    this.setState({WebserviceMethodList: result.WebserviceMethodList});
                }else if (params.operator == "getmethodinfo") {
                    this.setState({WebserviceMethodParameterDatas: result.WebserviceMethodParameterDatas});
                }else if (params.operator == "getSearchEsbinfo") {
                    let datas = [], specialDatas = [];
                    if(this.newForm.getFormParams().isSupportPaging == 0) {
                      result.ESBSearchParameterDatas && result.ESBSearchParameterDatas.forEach(v => {
                        if(!["pageNo", "startNo", "endNo", "pagesize"].includes(v.paramname.trim())) {
                          datas.push(v);
                        }else {
                          specialDatas.push(v);
                        }
                      })
                    }else {
                      datas = [...(result.ESBSearchParameterDatas || [])];
                      specialDatas = [];
                    } 
                    this.setState({esbSearchDatas: datas, specialDatas});
                }else if (params.operator == "getEsbinfo") {
                    this.setState({esbShowDatas: result.ESBShowParameterDatas});
                }else if (params.operator == 'save') {
                    if(result.status == 1) {
                        if('BTN_TEST' === params.type) {
                            if(params.id) {
                                this.getIndexTestInfo(params.id, 'new');
                            } else {
                                this.getIndexTest(result.id, 'new');
                            }
                        } else {
                            message.success(getLabel(22619, '保存成功'));
                            this.setState({
                                showNewFormDialog: false,
                            });
                        }
                        this.getDataShowList();
                    }
                }else if (params.operator == 'delete') {
                    message.success(getLabel(20461, '删除成功'));
                    this.getDataShowList();
                    this.setState({showNewFormDialog: false});
                }
            } else {
                this.getDataShowList();
                this.setState({showNewFormDialog: false});
            }
            this.setState({
                buttonDisabled: false,
            })
            callBack && isFunction(callBack) && callBack(result);
        });
    };

    @action
    getOpenPyhStatus = () => {
        const {
           showclass, 
           showtype, 
           datafrom,
           datasourceid,
        } = this.newForm.getFormParams();
  
        this.getDataShowOperation({
           operator: "isOpenPyh",
           showclass,
           showtype,
           datafrom,
           datasourceid,
        }, (res) => {
            this.setState({showOpenPyh: res.result});
        })
    }
}


