import * as mobx from 'mobx';
import * as Api from '../apis/adareaset';
import {
    observable,
    action
} from 'mobx';
import {
    WeaForm,
    WeaTableNew
} from 'comsMobx';
import {
    Modal,
    message,
} from 'antd'
import {
    i18n
} from '../public/i18n';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
const toJS = mobx.toJS;
const {
    TableStore
} = WeaTableNew;

export class HrmAdAreaSet {
    @observable leftTreeDatas = [];
    @observable visible = false; //新建和编辑弹出框
    @observable visible1 = false;
    @observable visible2 = false;
    @observable visible3 = false;
    @observable visible4 = false;
    @observable dialogTitle = '';
    @observable importHistoryTitle = i18n.button.importHistoryQuery();
    @observable importResultTitle = i18n.label.importResult();
    @observable importLogTitle = i18n.button.getImportLog();
    @observable form = new WeaForm();
    @observable form1 = new WeaForm();
    @observable form2 = new WeaForm();
    @observable condition = [];
    @observable importCondition = [];
    @observable importLogCondition = [];
    @observable tableStore = new TableStore();
    @observable importHistoryStore = new TableStore();
    @observable importResultStore = new TableStore();
    @observable importLogStore = new TableStore();
    @observable isPanelShow = false; //高级搜索下拉面板是否显示
    @observable id = '' //左侧树节点id
    @observable countryId = ''; //国家id
    @observable provinceId = ''; //省份id
    @observable cityId = ''; //城市id
    @observable countyId = ''; //区县id
    @observable pid = '';
    @observable type = 'all'; //组织树当前层级的类型(默认为第一级)
    @observable selectedKey = '0'; //这里的selectedKey用来控制加载BriefInfo组件还是加载AreaTable组件
    @observable cancelFlag = 0; //区分封存和解封的标示
    @observable isDisplayBlock = 1; //表格默认显示“已封存”数据
    @observable briefInfo = []; //国家、省份、城市和区县基本信息
    @observable treeRefresh = false; //用来刷新左侧树
    @observable searchsBaseValue = ''; //搜索基本值
    @observable operation = ''; //页面中操作的类型
    @observable excelfile = ''; //导入文件id
    @observable curCountry = ''; //展示当前国家
    @observable curProvince = '';
    @observable curCity = '';
    @observable curCounty = '';
    @observable formType = ''; //用来区分新建保存还是编辑保存
    @observable newType = ''; //用来区分是新建国家还是新建省份、城市或区县
    @observable isTableLinkToTree = false; //判断是否是列表直接联动左侧树
    @observable isLeftTreeReady = false; //用来判断左侧树是否加载完成
    @observable cityName = '';
    @observable cityTwoName = '';
    @observable selectedRows = '';
    @observable isBatchSeal = true;
    @observable topMenu = []
    @observable rightMenu = [];
    @observable buttonSelect = [];
    @observable hasDpIcon = false;
    @observable batchKey = '0';
    @observable isDpIconNeedReset = true;
    @observable params = {};
    @observable importResultdatas = {};
    @observable isImportResultFinished = false;
    @observable newEditDialogLoading = true;
    @observable searchConditionLoading = true;
    @observable funcName = '';
    @observable date = '';
    @observable countryname = '';
    @observable provincename = '';
    @observable orgTreeShValue = '';
    @observable isOrgTreeShow = true;
    @observable mpLoading = true;

    @action
    getRight() {
        this.mpLoading = true;
        Api.getHasRight(this.params).then((res) => {
            if (res.api_status) {
                this.topMenu = [];
                this.rightMenu = [];
                this.buttonSelect = [];
                res.topMenu && this.setTopMenu(res.topMenu);
                res.rightMenu && this.setRightMenu(res.rightMenu);
                if (res.buttonSelect) {
                    this.setButtonSelect(res.buttonSelect);
                } else {
                    this.buttonSelectReset();
                }
                res.hasDpIcon && this.setDpIcon(res.hasDpIcon);
                this.mpLoading = false;
            } else {
                message.error(res.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    getForm() {
        this.setNewEditDialogLoadingStatus(true);
        Api[this.funcName](this.params).then(res => {
            if (res.api_status) {
                this.setNewEditDialogLoadingStatus(false);
                res.condition && this.setCondition(res.condition);
                res.condition && this.form.initFormFields(res.condition);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    //获取导入表单
    getAreaImportForm() {
        Api.getAreaImportForm(this.params).then((res) => {
            if (res.api_status) {
                res.condition && this.setImportCondition(res.condition);
                this.setVisibleForImport(true);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    validatePosition = () => {
        const needValidateFields = ["citylongitude","citylatitude"];
        const formParams = this.form.getFormParams();

        if (formParams.citylongitude) {
            return needValidateFields.every(key => parseInt(formParams[key]).toString().length < 6)
        }else{
            return true;
        }
       
    }

    add() {
        this.form.validateForm().then(f => {
            if (f.isValid) {
                if (!this.validatePosition()) {
                    message.warning(getLabel(513120,"经纬度整数位最大不超过5位！"));
                    return 
                }
                Api[this.funcName](this.params).then((res) => {
                    if (res.api_status) {
                        if (res.message) {
                            if (res.sign == '1') {
                                message.success(res.message);
                            } else {
                                message.warning(res.message);
                            }
                        }
                        this.refresh();
                        this.setVisible(false);
                    } else {
                        message.warning(data.message);
                    }
                }, error => {
                    message.warning(error.message);
                })
            } else {
                f.showErrors();
                this.setDate(new Date());
            }
        });

    }

    edit() {
        this.form.validateForm().then(f => {
            if (f.isValid) {
                if (!this.validatePosition()) {
                    message.warning(getLabel(513120,"经纬度整数位最大不超过5位！"));
                    return 
                }
                Api[this.funcName](this.params).then((res) => {
                    if (res.api_status) {
                        if (res.message) {
                            if (res.sign == '1') {
                                message.success(res.message);
                            } else {
                                message.warning(res.message);
                            }
                        }
                        this.refresh();
                        this.setVisible(false);
                    } else {
                        message.warning(data.message);
                    }
                }, error => {
                    message.warning(error.message);
                })
            } else {
                f.showErrors();
                this.setDate(new Date());
            }
        });
    }

    delete() {
        Api[this.funcName](this.params).then((res) => {
            if (res.api_status) {
                this.refresh();
                this.selectedRows && this.selectedRowsReset();
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    getTable() {
        this.tableStore = new TableStore();
        Api[this.funcName](this.params).then((res) => {
            if (res.api_status) {
                res.sessionkey && this.tableStore.getDatas(res.sessionkey, 1);
                if (this.isTableLinkToTree) {
                    this.setTreeRefresh();
                    this.tableLinkToTreeStatusReset();
                }
                this.setOperation('getRight'); //先出现表格，再出现功能按钮
                this.getRight();
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    getSearchCondition() {
        Api.getSearchCondition(this.params).then((res) => {
            if (res.api_status) {
                this.setScLoadingStatus(false);
                res.condition && this.setCondition(res.condition);
                res.condition && this.form2.initFormFields(res.condition);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    getImportLogSearchCondition() {
        Api.getImportLogSearchCondition(this.params).then((res) => {
            if (res.api_status) {
                res.searchCondition && this.setImportLogCondition(res.searchCondition);
                res.searchCondition && this.form1.initFormFields(res.searchCondition);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    //封存和解封
    sealOrUnseal() {
        Api.doblock(this.params).then((res) => {
            if (res.api_status) {
                this.refresh();
                this.selectedRows && this.selectedRowsReset();
                //封存和解封切换
                this.setOperation('getRight');
                this.type !== 'all' && this.selectedKey == '0' && this.getRight();
            } else {
                let msg = (this.params.cancelFlag == '0') ? '解封成功' : '封存成功';
                message.warning(msg);
            }
        }, error => {
            message.warning(error.message);
        })

    }

    //国家、省份、城市和区县基本信息
    getBriefInfo() {
        Api.getAreaDetail(this.params).then((res) => {
            if (res.api_status) {
                let type = this.type;
                res.datas && this.setBriefInfo(res.datas);
                res.datas && this.setBreadcrumb(res.datas);
                if (res.pid) {
                    type == 'province' && this.setCountryId(res.pid);
                    type == 'city' && this.setProvinceId(res.pid);
                    type == 'citytwo' && this.setCityId(res.pid);
                }
                //先出现基本信息，再出现功能按钮
                this.setOperation('getRight');
                this.getRight();
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    //设置WeaTop组件的title
    setBreadcrumb(datas) {
        datas.map(data => {
            (data.label == i18n.label.nationalAbbr() || data.label == i18n.label.ownedCountry()) && this.setCurCountry(data.value);
            (data.label == i18n.label.provinceAbbr() || data.label == i18n.label.province()) && this.setCurProvince(data.value);
            data.label == i18n.label.city() && this.setCurCity(data.value);
            data.label == i18n.label.cityTwo() && this.setCurCounty(data.value);
        });
    }

    //导入文件提交
    importInfoSubmit() {
        if (!this.excelfile) {
            message.warning(i18n.message.pleaseUploadFile());
            return;
        }
        Api.saveAreaImport(this.params).then((res) => {
            if (res.api_status) {
                if (res.pid) {
                    this.setPid(res.pid);
                }
                if (res.pid == undefined || !res.pid) {
                    this.setPid('');
                }
                this.setOperation('import_info');
                this.getImportResult();
                this.setVisibleForImportResult(true);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    //获取导入结果信息
    getImportResult() {
        Api.getImportResultDetail(this.params).then((res) => {
            if (res.api_status) {
                this.setVisibleForImportResult(true);
                res.datas && this.setImportResultDatas(res.datas);
                res.datas.sessionkey && this.importResultStore.getDatas(res.datas.sessionkey, 1);
                this.refresh();
                res.datas.title && this.setImportResultTitle(res.datas.title);
                this.setImportResultStatus(true);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    //历史导入信息查询
    getImportHistory() {
        Api.getImportHistory(this.params).then((res) => {
            if (res.api_status) {
                res.sessionkey && this.importHistoryStore.getDatas(res.sessionkey, 1);
                this.setImportHistoryTitle(i18n.button.importHistoryQuery());
                this.setVisibleForImportHistory(true);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    getImportLogDetail() {
        Api.getImportLogDetail(this.params).then((res) => {
            if (res.api_status) {
                res.datas.sessionkey && this.importLogStore.getDatas(res.datas.sessionkey, 1);
                this.setImportLogTitle(i18n.button.getImportLog());
                this.setVisibleForImportLog(true);
            } else {
                message.warning(data.message);
            }
        }, error => {
            message.warning(error.message);
        })
    }

    //设置弹出框打开关闭的状态
    setVisible(b) {
        this.visible = b;
        if (!b) {
            this.formReset();
            this.conditionReset();
            this.newEditDialogLoadingReset();
        }
    }

    //获取调用不同接口的参数
    paramsDistribution() {
        let type = this.type;
        let operation = this.operation;
        let selectedKey = this.selectedKey;
        let newType = this.newType;
        let formType = this.formType;
        let selectedRows = this.selectedRows;

        //新建
        if (operation == 'new') {
            newType == 'country' && this.setParams({});
            newType == 'province' && this.setParams({
                countryid: this.countryId
            });
            newType == 'city' && this.setParams({
                provinceid: this.provinceId
            });
            newType == 'citytwo' && this.setParams({
                cityid: this.cityId
            });
        }
        //编辑
        if (operation == 'edit') {
            (type == 'all' || (type == 'country' && selectedKey == '0')) && this.setParams({
                countryid: this.countryId
            });
            ((type == 'country' && selectedKey == '1') || (type == 'province' && selectedKey == '0')) && this.setParams({
                provinceid: this.provinceId
            });
            ((type == 'province' && selectedKey == '1') || (type == 'city' && selectedKey == '0') || type == 'citytwo') && this.setParams({
                cityid: this.cityId
            });
            ((type == 'city' && selectedKey == '1') || type == 'citytwo') && this.setParams({
                citytwoid: this.countyId
            });
        }
        //保存
        if (operation == 'save_new') {
            if (type == 'all') {
                this.setParams({ ...this.form.getFormParams()
                });
            }
            if (type == 'country') {
                if (selectedKey == '0') {
                    if (formType == 'new' && newType == 'country') {
                        this.setParams({ ...this.form.getFormParams()
                        });
                    }
                    if (formType == 'new' && newType == 'province') {
                        this.setParams({
                            countryid: this.countryId,
                            ...this.form.getFormParams()
                        })
                    }
                } else {
                    this.setParams({
                        countryid: this.countryId,
                        ...this.form.getFormParams()
                    })
                }
            }
            if (type == 'province') {
                if (selectedKey == '0') {
                    if (formType == 'new' && newType == 'province') {
                        this.setParams({
                            countryid: this.countryId,
                            ...this.form.getFormParams()
                        })
                    }
                    if (formType == 'new' && newType == 'city') {
                        this.setParams({
                            provinceid: this.provinceId,
                            ...this.form.getFormParams()
                        })
                    }
                } else {
                    this.setParams({
                        provinceid: this.provinceId,
                        ...this.form.getFormParams()
                    })
                }
            }
            if (type == 'city') {
                if (selectedKey == '0') {
                    if (formType == 'new' && newType == 'city') {
                        this.setParams({
                            provinceid: this.provinceId,
                            ...this.form.getFormParams()
                        });
                    }
                    if (formType == 'new' && newType == 'citytwo') {
                        this.setParams({
                            cityid: this.cityId,
                            ...this.form.getFormParams()
                        })
                    }
                } else {
                    this.setParams({
                        cityid: this.cityId,
                        ...this.form.getFormParams()
                    })
                }
            }
            if (type == 'citytwo') {
                this.setParams({
                    cityid: this.cityId,
                    ...this.form.getFormParams()
                })
            }
        }
        if (operation == 'save_edit') {
            if (type == 'all') {
                this.setParams({
                    countryid: this.countryId,
                    ...this.form.getFormParams()
                })
            }
            if (type == 'country') {
                if (selectedKey == '0') {
                    this.setParams({
                        countryid: this.countryId,
                        ...this.form.getFormParams()
                    })
                } else {
                    this.setParams({
                        id: this.provinceId,
                        ...this.form.getFormParams()
                    })
                }
            }
            if (type == 'province') {
                if (selectedKey == '0') {
                    this.setParams({
                        id: this.provinceId,
                        ...this.form.getFormParams()
                    })
                } else {
                    this.setParams({
                        id: this.cityId,
                        ...this.form.getFormParams()
                    })
                }
            }
            if (type == 'city') {
                if (selectedKey == '0') {
                    this.setParams({
                        id: this.cityId,
                        ...this.form.getFormParams()
                    })
                } else {
                    this.setParams({
                        id: this.countyId,
                        ...this.form.getFormParams()
                    })
                }
            }
            if (type == 'citytwo') {
                this.setParams({
                    id: this.countyId,
                    ...this.form.getFormParams()
                })
            }
        }
        //删除 
        if (operation == 'delete') {
            (type == 'all' || (type == 'country' && selectedKey == '0')) && this.setParams({
                ids: this.countryId
            });
            ((type == 'country' && selectedKey == '1') || (type == 'province' && selectedKey == '0')) && this.setParams({
                ids: this.provinceId
            });
            ((type == 'province' && selectedKey == '1') || (type == 'city' && selectedKey == '0')) && this.setParams({
                ids: this.cityId
            });
            ((type == 'city' && selectedKey == '1') || type == 'citytwo') && this.setParams({
                ids: this.countyId
            });
        }
        //批量删除
        if (operation == 'batch_delete') {
            this.setParams({
                ids: this.selectedRows
            });
        }
        //基本搜索和高级搜索  
        if (operation == 'search') {
            type == 'all' && this.setParams({
                type: 'country'
            }); //国家列表高级搜索
            type == 'country' && this.setParams({
                type: 'province'
            }); //省份列表基本搜索
            type == 'province' && this.setParams({
                type: 'city'
            }); //城市列表基本搜索
            type == 'city' && this.setParams({
                type: 'citytwo'
            }); //区县列表基本搜索
        }
        //获取功能权限
        if (operation == 'getRight') {
            type == 'all' && this.setParams({
                type: 'all'
            });
            type == 'country' && this.setParams({
                type: 'country',
                tab: selectedKey,
                id: this.countryId
            });
            type == 'province' && this.setParams({
                type: 'province',
                tab: selectedKey,
                id: this.provinceId
            });
            type == 'city' && this.setParams({
                type: 'city',
                tab: selectedKey,
                id: this.cityId
            });
            type == 'citytwo' && this.setParams({
                type: 'citytwo',
                tab: selectedKey,
                id: this.countyId
            });
        }
        //获取国家、省份、城市和区县基本信息表单参数
        if (operation == 'getBriefInfo') {
            type == 'country' && this.setParams({
                countryid: this.countryId
            }); //国家基本信息
            type == 'province' && this.setParams({
                provinceid: this.provinceId
            }); //省份基本信息
            type == 'city' && this.setParams({
                cityid: this.cityId
            }); //城市基本信息
            type == 'citytwo' && this.setParams({
                citytwoid: this.countyId
            }); //区县基本信息
        }
        //获取国家、省份、城市和区县列表的参数
        if (operation == 'getTable') {
            let form2 = this.form2;
            if (type == 'all') {
                if (this.isEmptyObject(form2.getFormParams())) {
                    this.setParams({ ...this.form2.getFormParams(),
                        countryname: this.countryname,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                } else {
                    this.setParams({ ...this.form2.getFormParams(),
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                }
            }

            if (type == 'country') {
                if (this.isEmptyObject(form2.getFormParams())) {
                    this.setParams({ ...this.form2.getFormParams(),
                        provincename: this.provincename,
                        countryid: this.countryId,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                } else {
                    this.setParams({ ...this.form2.getFormParams(),
                        countryid: this.countryId,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                }
            }
            if (type == 'province') {
                if (this.isEmptyObject(form2.getFormParams())) {
                    this.setParams({
                        provinceid: this.provinceId,
                        cityname: this.cityName,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                } else {
                    this.setParams({
                        provinceid: this.provinceId,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                }
            }
            if (type == 'city') {
                if (this.isEmptyObject(form2.getFormParams())) {
                    this.setParams({
                        cityid: this.cityId,
                        cityname: this.cityTwoName,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                } else {
                    this.setParams({
                        cityid: this.cityId,
                        isDisplayBlock: this.isDisplayBlock,
                        batchKey: this.batchKey
                    });
                }

            }
        }
        //封存 批量封存， 解封 批量解封
        if (operation == 'sealOrUnseal') {
            if ((type == 'all' && !selectedRows) || (type == 'country' && selectedKey == '0')) {
                this.setParams({
                    type: 'country',
                    ids: this.countryId,
                    cancelFlag: this.cancelFlag
                });
            }
            if (type == 'all' && selectedRows) {
                this.setParams({
                    type: 'country',
                    ids: this.selectedRows,
                    cancelFlag: this.cancelFlag
                });
            }
            if ((type == 'country' && selectedKey == '1' && !selectedRows) || (type == 'province' && selectedKey == '0')) {
                this.setParams({
                    type: 'province',
                    ids: this.provinceId,
                    cancelFlag: this.cancelFlag
                });
            }
            if (type == 'country' && selectedRows) {
                this.setParams({
                    type: 'province',
                    ids: this.selectedRows,
                    cancelFlag: this.cancelFlag
                });
            }
            if ((type == 'province' && selectedKey == '1' && !selectedRows) || (type == 'city' && selectedKey == '0')) {
                this.setParams({
                    type: 'city',
                    ids: this.cityId,
                    cancelFlag: this.cancelFlag
                });
            }
            if (type == 'province' && selectedRows) {
                this.setParams({
                    type: 'city',
                    ids: this.selectedRows,
                    cancelFlag: this.cancelFlag
                });
            }
            if ((type == 'city' && selectedKey == '1' && !selectedRows) || type == 'citytwo') {
                this.setParams({
                    type: 'citytwo',
                    ids: this.countyId,
                    cancelFlag: this.cancelFlag
                });
            }
            if (type == 'city' && selectedRows) {
                this.setParams({
                    type: 'citytwo',
                    ids: this.selectedRows,
                    cancelFlag: this.cancelFlag
                });
            }
        }
        //获取导入表单参数
        if (operation == 'import') {
            type == 'all' && this.setParams({
                type: 'country'
            });
            type == 'country' && this.setParams({
                type: 'province'
            });
            type == 'province' && this.setParams({
                type: 'city'
            });
            type == 'city' && this.setParams({
                type: 'citytwo'
            });
        }
        //历史导入提交
        if (operation == 'import_submit') {
            this.setParams({
                importtype: 'area',
                excelfile: this.excelfile
            });
        }
        //获取导入结果
        if (operation == 'import_info') {
            this.setParams({
                pid: this.pid
            })
        }
        //查询历史导入信息
        if (operation == 'import_info_query') {
            this.setParams({})
        }
        //导入日志
        if (operation == 'import_log') {
            this.setParams({ ...this.form1.getFormParams()
            })
        }
        //导入日志 - 高级搜索
        if (operation == 'import_log_searchCondition') {
            this.setParams({})
        }
    }

    isEmptyObject(obj) {
        for (let key in obj) {
            if (!obj[key]) return true;
            return false;
        }
        return true;
    }

    //相关操作后，确定页面中哪些组件需要更新
    refresh() {
        let type = this.type;
        let selectedKey = this.selectedKey;
        let formType = this.formType;

        this.setTreeRefresh();
        this.setOperation('getTable');

        if (type == 'all') {
            this.setFuncName('getCountryList');
            this.getTable();
        }
        if (type == 'country' && selectedKey == '1') {
            this.setFuncName('getProvinceList');
            this.getTable();
        }
        if (type == 'province' && selectedKey == '1') {
            this.setFuncName('getCityList');
            this.getTable();
        }
        if (type == 'city' && selectedKey == '1') {
            this.setFuncName('getCityTwoList');
            this.getTable();
        }
        //基本信息编辑后，刷新当前基本信息
        if (type !== 'all' && selectedKey == '0' && formType == 'edit') {
            this.setOperation('getBriefInfo');
            this.getBriefInfo();
        }
    }

    //更新表单参数
    updateFields(val) {
        let type = this.type;
        type == 'all' && this.form2.updateFields({
            countryname: {
                value: val
            }
        });
        type == 'country' && this.form2.updateFields({
            provinceName: {
                value: val
            }
        });
    }

    //设置当前所在tab页的key值并调用接口获取数据
    setSelectedKey(selectedKey) {
        let type = this.type;

        this.selectedKey = selectedKey;
        this.batchKeyReset();
        this.isPanelShow && this.setPanelStatus(false);
        this.form2.reset();
        //重置基本搜索框
        type == 'province' && this.cityNameReset();
        type == 'city' && this.cityTwoNameReset();

        if (selectedKey == '0') {
            this.setOperation('getBriefInfo');
            this.getBriefInfo();
        } else if (selectedKey == '1') {
            this.setOperation('getTable');
            if (type == 'country') { //加载下一级表格数据
                this.setSearchsBaseValue(this.form2.getFormParams().provinceName);
                this.setFuncName('getProvinceList');
                this.getTable();
            }
            if (type == 'province') {
                this.setFuncName('getCityList');
                this.getTable();
            }
            if (type == 'city') {
                this.setFuncName('getCityTwoList');
                this.getTable();
            }
        }
    }

    //设置弹出框的标题
    setDialogTitle(title) {
        this.dialogTitle = title;
    }

    //设置生成表单的condition
    setCondition(condition) {
        this.condition = condition;
    }

    setImportLogCondition(condition) {
        this.importLogCondition = condition;
    }

    setImportCondition(condition) {
        this.importCondition = condition;
    }

    //设置当前左侧树点击后的id值
    setId(id) {
        this.id = id;
    }

    //设置国家id
    setCountryId(countryId) {
        this.countryId = countryId;
    }

    //设置省份id
    setProvinceId(provinceId) {
        this.provinceId = provinceId;
    }

    //设置城市id
    setCityId(cityId) {
        this.cityId = cityId;
    }

    //设置区县id
    setCountyId(countyId) {
        this.countyId = countyId;
    }

    //设置组织树当前层级的类型
    setType(type) {
        this.type = type;
    }

    //设置获取“高级搜索”表单的参数
    setScType(scType) {
        this.scType = scType;
    }

    //设置区分封存和解封的标识
    setCancelFlag(cancelFlag) {
        this.cancelFlag = cancelFlag;
    }

    //设置表格中是否显示已封存的数据
    setDisplayBlockStatus() {
        this.isDisplayBlock = (this.isDisplayBlock == 1) ? 0 : 1;
    }
    //设置国家、省份、城市和区县信息
    setBriefInfo(datas) {
        this.briefInfo = datas;
    }

    //用来刷新左侧树
    setTreeRefresh() {
        this.treeRefresh = !this.treeRefresh;
    }

    //设置搜索基本值
    setSearchsBaseValue(value) {
        this.searchsBaseValue = value;
    }

    //设置页面中功能操作的类型
    setOperation(operation) {
        this.operation = operation;
        this.paramsDistribution();
    }

    //设置导入文件id
    setExcelFile(id) {
        this.excelfile = id;
    }

    //设置导入弹出框是否可视
    setVisibleForImport(bool) {
        this.visible1 = bool;
        !bool && this.excelfileReset();
    }

    //设置历史导入记录弹出框是否可视
    setVisibleForImportHistory(bool) {
        this.visible2 = bool;
    }

    setVisibleForImportResult(bool) {
        this.visible3 = bool;
    }

    setVisibleForImportLog(bool) {
        this.visible4 = bool;
        !bool && this.form1.reset();
    }

    //设置历史导入记录title
    setImportHistoryTitle(title) {
        this.importHistoryTitle = title;
    }

    //设置当前国家
    setCurCountry(curCountry) {
        this.curCountry = curCountry;
    }

    setCurProvince(curProvince) {
        this.curProvince = curProvince;
    }

    setCurCity(curCity) {
        this.curCity = curCity;
    }

    setCurCounty(curCounty) {
        this.curCounty = curCounty;
    }

    setFormType(formType) {
        this.formType = formType;
    }

    setNewType(newType) {
        this.newType = newType;
    }

    setTableLinkToTreeStatus(bool) {
        this.isTableLinkToTree = bool;
    }

    setPanelStatus(bool) {
        this.isPanelShow = bool;
        if (!bool) {
            this.scLoadingReset();
        }
    }

    setLeftTreeStatus(b) {
        this.isLeftTreeReady = b;
    }

    setCityName(cityName) {
        this.cityName = cityName;
    }

    setCityTwoName(cityTwoName) {
        this.cityTwoName = cityTwoName;
    }

    setSelectRows(selectedRows) {
        this.selectedRows = selectedRows;
    }

    setIsBatchSealStatus(bool) {
        this.isBatchSeal = bool;
    }

    setTopMenu(topMenu) {
        this.topMenu = topMenu;
    }

    setRightMenu(rightMenu) {
        this.rightMenu = rightMenu;
    }

    setButtonSelect(buttonSelect) {
        this.buttonSelect = buttonSelect;
    }

    setDpIcon(bool) {
        this.hasDpIcon = bool;
    }

    setBatchKey(batchKey) {
        this.batchKey = batchKey;
    }

    setDpIconNeedResetStatus(bool) {
        this.isDpIconNeedReset = bool;
    }

    setParams(params) {
        this.params = params;
    }

    setImportResultDatas(datas) {
        this.importResultdatas = datas;
    }

    setImportResultTitle(title) {
        this.importResultTitle = title;
    }

    setImportResultStatus(bool) {
        this.isImportResultFinished = bool;
    }

    setPid(id) {
        this.pid = id;
    }

    setImportLogTitle(title) {
        this.importLogTitle = title;
    }

    setNewEditDialogLoadingStatus(bool) {
        this.newEditDialogLoading = bool;
    }

    setFuncName(funcName) {
        this.funcName = funcName;
    }

    setDate(date) {
        this.date = date;
    }

    setScLoadingStatus(bool) {
        this.searchConditionLoading = bool;
    }

    setCountryName(countryname) {
        this.countryname = countryname;
    }

    setProvinceName(provincename) {
        this.provincename = provincename;
    }

    setOrgTreeShValue(val) {
        this.orgTreeShValue = val;
    }

    setOrgTreeStatus() {
        this.isOrgTreeShow = !this.isOrgTreeShow;
    }

    //重置国家id
    countryIdReset() {
        this.countryId = '';
    }

    //重置省份id
    provinceIdReset() {
        this.provinceId = '';
    }

    //重置城市id
    cityIdReset() {
        this.cityId = '';
    }

    //重置区县id
    countyIdReset() {
        this.countyId = '';
    }

    //tab页selected值重置
    selectedKeyReset() {
        this.selectedKey = '0';
    }

    typeReset() {
        this.type = 'all';
    }
    //重置condition
    conditionReset() {
        this.condition = [];
    }

    //显示封存数据
    dpIconStatusReset() {
        this.isDisplayBlock = 1;
    }

    //重置excelfile
    excelfileReset() {
        this.excelfile = '';
    }

    cityNameReset() {
        this.cityName = '';
    }

    cityTwoNameReset() {
        this.cityTwoName = '';
    }

    selectedRowsReset(selectedRows) {
        this.selectedRows = '';
    }

    formReset() {
        this.form = new WeaForm();
    }

    formTwoReset() {
        this.form2 = new WeaForm();
    }

    newEditDialogLoadingReset() {
        this.newEditDialogLoading = true;
    }

    tableLinkToTreeStatusReset() {
        this.isTableLinkToTree = false;
    }

    scLoadingReset() {
        this.searchConditionLoading = true;
    }

    countrynameReset() {
        this.countryname = '';
    }

    provincenameReset() {
        this.provincename = '';
    }

    batchKeyReset() {
        this.batchKey = '0';
    }

    buttonSelectReset() {
        this.buttonSelect = [];
    }

    orgTreeShValueReset() {
        this.orgTreeShValue = '';
    }
}