//import axios from 'axios';
import axios from "axios";

var qs = require('qs')
import bus from '../../components/common/bus'
import apiConfig from '@/config/index.js'
// import {Decimal} from './decimal.js';
var Decimal = require('decimal')
let moment = require('moment')
let common = {
    //  ctx: 'http://192.168.1.36:8080',
    //  ctxForm: "http://192.168.1.36:8890",
    // ctx: 'http://192.168.1.149:8080',
    // ctxForm: "http://192.168.1.79:8880",
    // ctx: 'http://192.168.1.95:8080/finance-backend',
    // ctxForm: "http://192.168.1.115:8080/activiti-web",
    ctx: eval('(' + apiConfig.ctx + ')'),
    ctxForm: eval('(' + apiConfig.ctxForm + ')'),
    excludeMeWhenSelectNextHandler: apiConfig.excludeMeWhenSelectNextHandler,
    excludeFormerHanlder: apiConfig.excludeFormerHanlder,
    dataList: {
        counterpartyType: 'FinanceInsGroup', //金融机构
        productTypeBF: 'YhlcCAT', //银行产品类型
        providBF: 'Limit', //银行周期
        providID: 'TyckLB', //同业存款周期
        ywzt: 'MainBody', //业务主体
        ywxs: 'MainModes', //业务形式
        expirationStatus: 'ProductStatus', //到期状态
        fxlb: 'Risk', //风险类别
        jsfs: 'Methods', //收益计算方式
        ccfx: 'TycjDirection', //拆借方向
        ywpz: 'TycjLBLB', //业务品种
        tzxm: 'FinanceIns', //投资项目  金融业务
        yewzt: 'BusinessStatus', //业务状态
        yewnr: 'Business', //业务内容
        prrYwpz: 'zysnhgLB', //质押式逆回购业务品种
        prrZyqz: 'zysnhgqz', //质押式逆回购质押券种
        prrJYfx: 'ZyshgDirection', //质押式回购交易方向
        pqrYwpz: 'PriceRep_BB', // 交易所质押式回购报价业务品种
        pqrJys: 'PriceRepExchange', // 交易所质押式回购报价交易所
        pqrJyfx: 'PriceRepDirection', //交易所质押式回购报价交易方向,
        zjzt: 'CashStatus', //资金状态
        prr: 'Status', //业务状态
        // jjjylx:"JjtzDirection",//基金交易类型
        jjjylx: 'FundDirection', //基金交易类型
        wtf: 'Entrustingparty', //委托方
        ckzt: 'Status_5',
        prrJypz: 'ZyshgLB', //质押式回购交易品种
        ilJypz: 'TycjLB', //同业拆借交易品种
        zhfl: 'AcctClass', //账户分类
        FeeType: 'FeeType', //收取方式
        aliDity: 'Status_1', //交易所国债逆回购 数据有效性
        bourse: 'StockExchange', //交易所国债逆回购 交易所
        etrrt: 'SHSENDRepLB', //交易所国债逆回购 交易品种
        etrrt1: 'periods', //交易所国债逆回购 期限(天)
        processName: 'processName', //审批流管理 模型描述
        shibor1: 'shibor1', //参考银行间质押式回购市场利率


        BModule: 'BModule', //模板类
        risk: 'invRiskLimLv', // 风险等级
        PrtlState: 'PrtlState', //合同状态
        PortSP: 'PortSP' //提供方、消费方
    },
    processtype: {
        role: 'create-role-process',
        user: 'create-user-process',
        limitrules: 'create-limitrules-process', //规则标准
        evaluation: 'create-evaluation-process', //授信评级

        BFbusinessPlanApproval: 'ZY-Yhlc-plan', //银行理财方案管理
        BFtype: 'ZY',
        BFproducttype: 'Yhlc',
        BFbusinessOperation: 'ZY-Yhlc-perform', //银行理财业务操作BF-accountManag
        BFaccountManag: 'ZY-Yhlc-mature', //F-accountManag

        ILbusinessPlanApproval: 'ZY-Tycj-plan',
        ILtype: 'ZY',
        ILproducttype: 'Tycj',
        ILbusinessOperation: 'ZY-Tycj-perform', //同业拆借业务操作
        ILaccountManag: 'ZY-Tycj-mature', //同业拆借台账

        BBbusinessPlanApproval: 'ZY-Zqyw-plan', //债券业务方案管理
        BBtype: 'ZY',
        BBproducttype: 'Zqyw',
        BBbusinessOperation: 'ZY-Zqyw-perform', //债券业务业务操作
        BBaccountManag: 'ZY-Zqyw-mature', //债券业务台账

        PRRbusinessPlanApproval: 'ZY-Zyshg-plan', //质押式逆回购方案管理
        PRRtype: 'ZY',
        PRRproducttype: 'Zyshg',
        PRRbusinessOperation: 'ZY-Zyshg-perform', //质押式逆回购业务操作
        PRRaccountManag: 'ZY-Zyshg-mature', //质押式逆回购台账

        CODbusinessPlanApproval: 'ZY-Tycd-plan', //同业存单方案管理
        CODtype: 'ZY',
        CODproducttype: 'Tycd',
        CODbusinessOperation: 'ZY-Tycd-perform', //同业存单务操作
        CODaccountManag: 'ZY-Tycd-mature', //同业存单台账

        IDbusinessPlanApproval: 'ZY-Tyck-plan', //同业存款方案管理
        IDtype: 'ZY',
        IDproducttype: 'Tyck',
        IDbusinessOperation: 'ZY-Tyck-perform', //同业存款业务操作
        IDaccountManag: 'ZY-Tyck-mature', //同业存款台账

        FIbusinessPlanApproval: 'ZY-Jjtz-plan', //基金投资方案管理
        FItype: 'ZY',
        FIproducttype: 'Jjtz',
        FIbusinessOperation: 'ZY-Jjtz-perform', //基金投资业务操作
        FIaccountManag: 'ZY-Jjtz-mature', //基金投资台账

        EIbusinessPlanApproval: 'WT-Yhlc-plan', //基金投资方案管理
        EItype: 'WT',
        EIproducttype: 'Yhlc',
        EIbusinessOperation: 'WT-Yhlc-perform', //基金投资业务操作
        EIaccountManag: 'WT-Yhlc-mature', //基金投资台账

        EIframeworkagreement: 'WT-Yhlc-kjxy', //协议框架
        EIprotocolnumber: 'WT-Yhlc-xybh', //协议框架
        EIsplittingoperation: 'WT-Yhlc-maturity', //投资到期审批 登记
        EIaccountingForFunds: 'WT-Yhlc-entry', //投资到期审批 入账

        RRPtype: 'ZY', //交易所国债逆回购
        RRPbusinessplanmanag: 'ZY-SENDRep-plan', //交易所国债逆回购 业务方案审批字段
        RRPproductType: 'SENDRep', //交易所国债逆回购 产品类型
        RRPbusinessOperation: 'ZY-SENDRep-perform', //交易所国债业务操作
        RRPaccountManag: 'ZY-SENDRep-mature', //交易所国债台账

        PQRtype: 'ZY',
        PQRproducttype: 'PriceRep', //交易所质押式报价回购
        PQRbusinessPlanManag: 'ZY-PriceRep-plan', //交易所质押式报价回购方案管理
        PQRbusinessOperation: 'ZY-PriceRep-perform', //交易所质押式报价回购业务操作
        PQRaccountManag: 'ZY-PriceRep-mature', //交易所质押式报价回购台账

        // --------------------------------货币基金XSTART-------------------------------------

        CURtype: 'ZY', //自营货币基金
        CURproductType: 'MoneyFund', //货币基金 产品类型
        CURbusinessplanmanag: 'ZY-MoneyFund-plan', //货币基金 业务方案审批字段
        CURbusinessOperation: 'ZY-MoneyFund-perform', //货币基金 业务操作
        CURaccountManag: 'ZY-MoneyFund-mature', //货币基金 台账

        CURtypeCopy: 'JT', //总部货币基金copy
        CURproductTypeCopy: 'MoneyFund', //货币基金 产品类型
        CURbusinessplanmanagCopy: 'JT-MoneyFund-plan', //货币基金 业务方案审批字段
        CURbusinessOperationCopy: 'JT-MoneyFund-perform', //货币基金 业务操作
        CURaccountManagCopy: 'JT-MoneyFund-mature', //货币基金 台账
        CURcapitalProcessCopy: 'JT-MoneyFund-capital', //资金业务
        CURcapitalWorthCopy: 'JT-MoneyFund-networth', //资产净值

        BONtype: 'ZY', // 自营债券基金
        BONproductType: 'BondFund', //债券基金 产品类型
        BONbusinessplanmanag: 'ZY-BondFund-plan', //债券基金 业务方案审批字段
        BONbusinessOperation: 'ZY-BondFund-perform', //债券基金 业务操作
        BONaccountManag: 'ZY-BondFund-mature', //债券基金 台账
        BONcapitalProcess: 'ZY-BondFund-capital', //资金业务
        BONcapitalWorth: 'ZY-BondFund-networth', //资产净值

        BONtypeCopy: 'JT', // 总部债券基金
        BONproductTypeCopy: 'BondFund', //债券基金 产品类型
        BONbusinessplanmanagCopy: 'JT-BondFund-plan', //债券基金 业务方案审批字段
        BONbusinessOperationCopy: 'JT-BondFund-perform', //债券基金 业务操作
        BONaccountManagCopy: 'JT-BondFund-mature', //债券基金 台账
        BONcapitalProcessCopy: 'JT-BondFund-capital', //资金业务
        BONcapitalWorthCopy: 'JT-BondFund-networth', //资产净值

        ZYCapitalOperate: 'ZY-CapitalOperate', //自营结算业务
        JTCapitalOperate: 'JT-CapitalOperate', //总部结算业务
        // -----------------------------货币基金END-----------------------------------------
        // 'capitalProcess':'capital-MoneyFund-process',//资金业务
        capitalProcess: 'ZY-MoneyFund-capital', //资金业务
        capitalWorth: 'ZY-MoneyFund-networth', //资产净值
        corportaion: 'capital-corportaion-process', //企业资金划拨
        interbank: 'capital-interbank-process', //同业资金划拨

        regulatory: 'create-indregl-process', //监管额度标准设定  Regulatory limit setting
        absProcessNumber: 'ZY-ABS-ledger', //ABS台账流程编号
        absRecycleNumber: 'ZY-ABS-recycle', //ABS资金回收编号
        preferredStockLedgerNumber: 'JT-PreferredStock-ledger', //优先股abs台账流程编号 错误的:ZY-PreferredStock-ledger
        preferredStockRecycleNumber: 'JT-PreferredStock-recycle', //优先股资金回收流程编号
        gpcmpylimit: 'create-gpcmpylimit-process', //集团额度标准设定

        networthProduct: 'ZY-NetValueFina-networth', //(自营)净值型理财资产净值审批流程 产品

        networthBook: 'ZY-NetValueFina-ledger', //(自营)净值型理财台账管理审批流程 台账
        networthBookAdd: 'ZY-NetValueFina-ledgeAdd', //新增时的流程类型
        networthRecycle: 'ZY-NetValueFina-recycle', //(自营)净值型理财资金回收流程审批 资金回收

        NetValueFina: 'NetValueFina', //净值型理财
        ZYNetValueFinaPlan: 'ZY-NetValueFina-plan', //自营净值型理财业务方案
        ZYNetValueFinaperform: 'ZY-NetValueFina-perform', // 净值型理财自营业务操作

        networthBookCopy: 'JT-NetValueFina-ledger', //(总部)净值型理财台账管理审批流程 台账
        networthBookAddCopy: 'JT-NetValueFina-ledgeAdd', //(总部)新增时的流程类型
        networthRecycleCopy: 'JT-NetValueFina-recycle', //(总部)净值型理财资金回收流程审批 资金回收
        JTNetValueFinaPlan: 'JT-NetValueFina-plan', //(总部)净值型理财业务方案
        JTNetValueFinaperform: 'JT-NetValueFina-perform', // 净值型理财自营业务操作


        depositMoney: 'capital-reserve-process' //存款准备金划拨
    },
    unit: [
        { name: '元', code: 'unit_1' },
        { name: '万元', code: 'unit_2' },
        { name: '亿元', code: 'unit_3' }
    ],
    httpPost: function(obj, success, error, example) {
        console.log(obj)
        //obj.url  请求地址
        //obj.data  请求数据
        //success   成功回调
        //error     失败回调
        // let defaultObj = {
        //     type:"post",

        // }
        obj.printMsg == undefined ? (obj.printMsg = true) : (obj.printMsg = obj.printMsg)
       if(obj.status === 'form'){
           obj.data = qs.stringify(obj.data)
           bus.$axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
       }else{
           bus.$axios.defaults.headers.post['Content-Type'] = 'application/json';
           obj.data = JSON.parse(JSON.stringify(obj.data))
       }
        obj.data = this.requestDeal(obj.data)
        if (!obj.type) {
            obj.type = 'post'
        }

        if (obj.url.indexOf('/finapi/') != -1) {
            //  obj.url = obj.url.replace("/api","");
            bus.$axios.defaults.baseURL = common.ctx
        } else if (obj.url.indexOf('/ms/') != -1) {
            //  obj.url = obj.url.replace("/ms","");
            bus.$axios.defaults.baseURL = common.ctxForm
        } else {
            // bus.$axios.defaults.baseURL = common.ctx
        }
        // if (bus.$store.getters.getLogin('token')) {
        //     var token = bus.$store.getters.getLogin('token')
        // } else {
        //     var token = null
        // }

        let header = {
            headers: {
                'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
            }
        }
        if (!obj.disableLoading) {
            var loading = bus.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0)'
            })
        }
        if (obj.type == 'post') {
            bus.$axios['post'](obj.url + '?t=' + Math.random(), obj.data, header)
                .then(function(response) {
                    console.log(response)
                    if (!obj.disableLoading) {
                        loading.close()
                    }
                    // if (response.data.code === 1 ||response.data.code == '1') {
                    //     bus.$message.success(response.data.message)
                    //      loading.close()
                    //      success(response.data.data)
                    //      return response
                        if (response.code === 1 ||response.code == '1') {
                            bus.$message.success(response.data.message)
                             loading.close()
                             success(response.data)
                             return response
                    } else {
                        if (obj.printMsg) {
                            if (response.message) {
                                if (eval(apiConfig.ENV_CONFIG) == 'dev' || eval(apiConfig.ENV_CONFIG) == 'test') {
                                    bus.$message({
                                        message: response.message,
                                        type: 'error'
                                    })
                                } else {
                                    bus.$notify.error(response.message.substring(0, 100))
                                }
                                if (typeof error === 'function') {
                                    error.call(example, response.message)
                                }
                            } else {
                                bus.$notify.error('接口请求失败')
                                if (typeof error === 'function') {
                                    error.call(example, '错误信息')
                                }
                            }
                        }
                    }
                })
                .catch(function(msgE) {
                    if (obj.printMsg) {
                
                    }
                    if (!obj.disableLoading) {
                        loading.close()
                    }
                    // error(msgE)
                })
        } else {
            bus.$axios['get'](obj.url + '?t=' + Math.random(), {
                params: obj.data,
                headers: header.headers
            })
                .then(function(response) {
                    if (!obj.disableLoading) {
                        loading.close()
                    }
                    if (response.code == 1) {
                        success(response.data)
                    } else {
                        if (obj.printMsg) {
                            if (response.message) {
                                if (eval(apiConfig.ENV_CONFIG) == 'dev' || eval(apiConfig.ENV_CONFIG) == 'test') {
                                    bus.$message({
                                        message: response.message,
                                        type: 'error'
                                    })
                                } else {
                                    bus.$notify.error(response.message.substring(0, 100))
                                }
                                if (typeof error === 'function') {
                                    error.call(example, response.message)
                                }
                            } else {
                                bus.$notify.error('接口请求失败')
                            }
                        }
                    }
                })
                .catch(function(msgE) {
                    if (obj.printMsg) {
                        bus.$notify.error('ERROR:' + msgE)
                    }
                    if (!obj.disableLoading) {
                        loading.close()
                    }
                    //console.log(msgE)
                    //bus.$notify.error(msgE);
                    // error(msgE)
                })
        }
    },
    postRequest: function(obj) {
        obj.printMsg == undefined ? (obj.printMsg = true) : (obj.printMsg = obj.printMsg)

        obj.data = JSON.parse(JSON.stringify(obj.data))
        obj.data = this.requestDeal(obj.data)
        if (obj.url.indexOf('/finapi/') != -1) {
            //  obj.url = obj.url.replace("/api","");
            bus.$axios.defaults.baseURL = common.ctx
        } else if (obj.url.indexOf('/ms/') != -1) {
            //  obj.url = obj.url.replace("/ms","");
            bus.$axios.defaults.baseURL = common.ctxForm
        } else {
            bus.$axios.defaults.baseURL = common.ctx
        }

        // if (bus.$store.getters.getLogin('token')) {
        //     var token = bus.$store.getters.getLogin('token')
        // } else {
        //     var token = null
        // }

        let header = {
            headers: {
                 'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
            }
        }
        if (!obj.disableLoading) {
            var loading = bus.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            })
        }
        return bus
            .$axios({
                method: 'post',
                url: `${obj.url}`, //?t=${Math.random()}
                data: obj.data,
                // timeout: 100000,
                headers: {
                    'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
                }
            })
            .then(function(response) {
                if (response.code == 1) {
                    loading.close()
                    return response
                } else {
                    bus.$message({
                        message: response.message,
                        type: 'error'
                    })
                    loading.close()
                    // bus.$notify.error('接口请求失败')
                }
            })
            .catch(function(msgE) {
                bus.$notify.error('ERROR:' + msgE)
                loading.close()
            })
    },
    postRequestHybid: function(obj, file, error) {
        obj.data = JSON.parse(JSON.stringify(obj.data))
        obj.data = this.requestDeal(obj.data)
        if (!obj.type) {
            obj.type = 'post'
        }

        if (obj.url.indexOf('/finapi/') != -1) {
            //  obj.url = obj.url.replace("/api","");
            bus.$axios.defaults.baseURL = common.ctx
        } else if (obj.url.indexOf('/ms/') != -1) {
            //  obj.url = obj.url.replace("/ms","");
            bus.$axios.defaults.baseURL = common.ctxForm
        } else {
            bus.$axios.defaults.baseURL = common.ctx
        }

        // if (bus.$store.getters.getLogin('token')) {
        //     var token = bus.$store.getters.getLogin('token')
        // } else {
        //     var token = null
        // }

        let header = {
            headers: {
                'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
            }
        }
        if (!obj.disableLoading) {
            var loading = bus.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            })
        }
        return bus
            .$axios({
                method: 'post',
                url: `${obj.url}`, //?t=${Math.random()}
                data: file,
                params: obj.data,
                // timeout: 100000,
                headers: {
                    'Content-Type': 'multipart/form-data',
                    Accept: 'application/json',
                    'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
                }
            })
            .then(function(response) {
                if (response.code === 1) {
                    bus.$message({
                        message: response.data.message,
                        type: 'success'
                    })
                    loading.close()
                    return response
                } else {
                    if (obj.printMsg) {
                        if (response.message) {
                            if (eval(apiConfig.ENV_CONFIG) == 'dev' || eval(apiConfig.ENV_CONFIG) == 'test') {
                                bus.$message({
                                    message: response.message,
                                    type: 'error'
                                })
                            } else {
                                bus.$notify.error(response.message.substring(0, 100))
                            }
                            if (typeof error === 'function') {
                                error(response.message)
                            }
                        } else {
                            bus.$notify.error('接口请求失败')
                        }
                    }
                }
            })
            .catch(function(msgE) {
                bus.$notify.error('ERROR:' + msgE)
                loading.close()
            })
    },
    getRequest: function(obj, error) {
        obj.printMsg == undefined ? (obj.printMsg = true) : (obj.printMsg = obj.printMsg)

        obj.data = JSON.parse(JSON.stringify(obj.data))
        obj.data = this.requestDeal(obj.data)
        if (obj.url.indexOf('/finapi/') != -1) {
            //  obj.url = obj.url.replace("/api","");
            bus.$axios.defaults.baseURL = common.ctx
        } else if (obj.url.indexOf('/ms/') != -1) {
            //  obj.url = obj.url.replace("/ms","");
            bus.$axios.defaults.baseURL = common.ctxForm
        } else {
            bus.$axios.defaults.baseURL = common.ctx
        }

        // if (bus.$store.getters.getLogin('token')) {
        //     var token = bus.$store.getters.getLogin('token')
        // } else {
        //     var token = null
        // }

        let header = {
            headers: {
                'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
            }
        }
        if (!obj.disableLoading) {
            var loading = bus.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            })
        }
        return bus
            .$axios({
                method: 'get',
                url: `${obj.url}`, //?t=${Math.random()}
                // data: obj.data,
                params: obj.data,
                // timeout: 100000,
                headers: {
                    'X-Token': 'REFCNkQ0MDM3OTk0MzNCMkNGRDREOTJENkJFMzcxNEQwOTgzRjUyQzRCNTZCRDQyMDg4RkIxMDZFOTk4MjJFNTRGM0Q4NTA3RDFDQTgwMjFDRDQwOEMyQTQxQTQ0NzQzMDI3REM4NkVCODI4OTVEMjM4N0U2MTRDQUM1ODhEMjlBQTY5MTBEMzgzNDc2MzQ1QTg1MTNGOUI1N0ExRTI4RjREODcxRTIwNjkxNTAyMzU5NDVFQUUwMDBDQjg3MzVDODZBODA0OERDM0FEN0QyNEJGMTJBNjQxRjIyMzNGNUUzNDc4ODA5QUU1MjFGQjFCRkI1NkYxMjIxNTk5M0ZDOUJDNjNBQTI4NzBFOTNFMzBFRkRFQzFCODE5QTEyOUJGRDg0MUE2OTgwM0QxRDNENEEwRDA0QjA2OUMyQkRDNjIyOTQ4MjA5NEUyRDZBRTc0QzJBREUyNTRCNzY0OTRCRDY5ODY2NUQ1REQ4MzQ4MDREMjA5RjQ2NDAzQzU5QTA2Q0ZBNjFGNEVGREREREEwNTAzMjQwNDYzRTFGOTA0REI4OTAzQTMwNDQ3NUIwMkM2QjJGODJFNTI0NEMzNTZDMEM0NDRBNzM1MUE0MUFCNjIzN0ZDMzIwQkVERUM2QzdCMTBCN0RBMDUyNjBGMTQxQjU0RDYzMThFMzNDODVGMDM='
                }
            })
            .then(function(response) {
                if (response.code == 1) {
                    loading.close()
                    return response
                } else {
                    if (obj.printMsg) {
                        if (response.message) {
                            if (eval(apiConfig.ENV_CONFIG) == 'dev' || eval(apiConfig.ENV_CONFIG) == 'test') {
                                bus.$message({
                                    message: response.message,
                                    type: 'error'
                                })
                            } else {
                                bus.$notify.error(response.message.substring(0, 100))
                            }
                            if (typeof error === 'function') {
                                error(response.message)
                            }
                        } else {
                            bus.$notify.error('接口请求失败')
                        }
                    }
                }
            })
            .catch(function(msgE) {
                bus.$notify.error('ERROR:' + msgE)
                loading.close()
            })
    },
    requestDeal(data) {
        if (data.constructor === Object) {
            let arr = ['size', 'scale', 'profitcalculate', 'sellshare', 'holdshare', 'scaleRedeem', 'buyshare', 'holdsharePurchase', 'scalePurchase', 'imputedInterest', 'interestDifferential', 'amount', 'drawAmount', 'totalAmount', 'realInterest', 'depositAmount', 'faceValue', 'offeringPrice', 'bookBalance', 'expireInvestmentReturn', 'expireFeeIncome', 'expireProfit', 'arrivalFunds', 'expectedInvestmentReturn', 'incomeCalculation', 'processingFeeIncome', 'outReturn', 'accruedInterest', 'subscribeScale', 'expireAmount', 'returnAmount', 'bondScale', 'thousandsIncome', 'netWorth', 'thousandsIncomePurchase', 'netWorthPurchase', 'arrivalaccount', 'arrivalprofit', 'balance', 'interest', 'chargeFee', 'returnFundsSum', 'freeMoney', 'supervisionQuota', 'commissionScale', 'expireInterest', 'availableQuota', 'zyLineCreditTwo', 'zySecondClassOccupyQuota', 'wtOccupyQuota', 'wtSecondClassFrozenQuota', 'wtFrozenQuota', 'groupLedgerOccupyQuota', 'limitedLedgerOccupyQuota', 'zySecondClassFrozenQuota', 'usedSumQuota', 'matures', 'actualTransactionAmount', 'tradeCommission', 'interestIncomeCalculation', 'excessInterestIncome', 'actualInterestIncome', 'holdshareTotal', 'netAssetValue', 'affirmShare', 'affirmScale', 'oddCorpus', 'occupationQuotaTotal', 'occupationQuotaFirst', 'occupationQuotaSecond', 'occupationQuota', 'corpus', 'poundage', 'contractScale'] //两位小数
            //4位小数offeringPrice

            let arr2 = ['thousandsIncome', 'netWorth', 'thousandsIncomePurchase', 'netWorthPurchase']

            arr.forEach(i => {
                if (data.hasOwnProperty(i)) {
                    if (typeof data[i] == 'string') {
                        if (data[i].indexOf(',') != -1) {
                            data[i] = data[i].replace(/,/g, '')
                        }
                    }
                    try {
                        data[i] = new Decimal(data[i]).mul(100)
                        if (typeof data[i].toNumber === 'function') {
                            data[i] = data[i].toNumber()
                        }
                    } catch (error) {
                        console.log(error)
                    }
                }
            })
        }

        return data
    },
    backDeal(data, tag) {
        data = JSON.parse(JSON.stringify(data))
        let arr = ['size', 'scale', 'profitcalculate', 'sellshare', 'holdshare', 'scaleRedeem', 'buyshare', 'holdsharePurchase', 'scalePurchase', 'imputedInterest', 'interestDifferential', 'amount', 'drawAmount', 'totalAmount', 'realInterest', 'depositAmount', 'faceValue', 'offeringPrice', 'bookBalance', 'expireInvestmentReturn', 'expireFeeIncome', 'expireProfit', 'arrivalFunds', 'expectedInvestmentReturn', 'incomeCalculation', 'processingFeeIncome', 'outReturn', 'accruedInterest', 'subscribeScale', 'expireAmount', 'returnAmount', 'bondScale', 'thousandsIncome', 'netWorth', 'thousandsIncomePurchase', 'netWorthPurchase', 'arrivalaccount', 'arrivalprofit', 'balance', 'interest', 'chargeFee', 'returnFundsSum', 'freeMoney', 'supervisionQuota', 'commissionScale', 'expireInterest', 'availableQuota', 'zyLineCreditTwo', 'zySecondClassOccupyQuota', 'wtOccupyQuota', 'wtSecondClassFrozenQuota', 'wtFrozenQuota', 'groupLedgerOccupyQuota', 'limitedLedgerOccupyQuota', 'zySecondClassFrozenQuota', 'usedSumQuota', 'matures', 'actualTransactionAmount', 'tradeCommission', 'interestIncomeCalculation', 'excessInterestIncome', 'actualInterestIncome', 'holdshareTotal', 'netAssetValue', 'affirmShare', 'affirmScale', 'occupationQuotaTotal', 'occupationQuotaFirst', 'occupationQuotaSecond', 'occupationQuota', 'corpus', 'poundage', 'contractScale', 'returnCorpusSum', 'payInterestSum', 'oddCorpus'] //两位小数
        arr.forEach(i => {
            if (data.hasOwnProperty(i)) {
                if (typeof data[i] == 'string') {
                    if (data[i].indexOf(',') != -1) {
                        data[i] = data[i].replace(/,/g, '')
                    }
                }
                data[i] = Number(data[i])
                let dcmlVal = new Decimal(data[i]).div(100)
                if (dcmlVal.toFixed) {
                    dcmlVal = new Decimal(data[i]).div(100).toFixed(2)
                } else {
                    dcmlVal = new Decimal(data[i])
                        .div(100)
                        .toNumber()
                        .toFixed(2)
                }
                data[i] = dcmlVal //(new Decimal(data[i]).div(100)).toFixed(2) //(data[i] /100).toFixed(2);
                if (tag) {
                    var intPart = data[i].toString().split('.')[0] // 获取整数部分

                    var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') // 将整数部分逢三一断
                    data[i] = intPartFormat + '.' + data[i].toString().split('.')[1]
                }
            }
        })

        return data
    },
    selectInit(url, back, params, str, error) {
        // params.status = 1;
        let obj = {
            url: url,
            data: params
        }

        this.httpPost(obj, success, error)
        function success(data) {
            back(data, str)
        }
    },
    treeList(data, obj, type) {
        //debugger
        //路由树结构
        if (!obj) {
            obj = {
                id: 'id', //当前id
                pid: 'parentId', //parent.id  的parent
                firstPid: 0, //第一层id应为
                label: 'name' //label
            }
        }

        var arr = []
        // data = data.rows;

        var menuNew = data.filter(item => {
            return item[obj.pid] == obj.firstPid //找到第一层
        })

        menuNew.forEach(item => {
            //循环第一层
            var pA = son(item)
            item.label = item[obj.label]
            item.key = 'key-' + item[obj.id]
            if (type != 0 && type != 1) {
                item.disabled = true
            } else {
                item.disabled = false
            }
            if (pA.length > 0) {
                item.children = pA
                arr.push(item)
            }
        })

        function son(item) {
            var newSon = data.filter(o => {
                o.label = o[obj.label]
                o.key = 'key-' + o[obj.id]
                return o[obj.pid] == item[obj.id]
            })
            if (newSon.length > 0) {
                newSon.forEach(b => {
                    var pA = son(b)
                    if (pA.length > 0) {
                        b.children = pA
                    }
                })
            }
            return newSon
        }

        return arr
    },
    menuResource(data, roleData, type) {
        //路由树+资源组合树；
        var arr = []

        var menuNew = data.filter(item => {
            return item.parentId == 0
        })

        menuNew.forEach(item => {
            var pA = son(item)
            item.label = item.name
            item.key = 'router-' + item.id
            if (type != 0 && type != 1) {
                item.disabled = true
            } else {
                item.disabled = false
            }
            if (pA.length > 0) {
                item.children = pA
                arr.push(item)
            }
        })
        function son(item) {
            var newSon = data.filter(o => {
                o.label = o.name
                o.key = 'router-' + o.id
                if (type != 0 && type != 1) {
                    item.disabled = true
                } else {
                    item.disabled = false
                }
                return o.parentId == item.id
            })
            if (newSon.length > 0) {
                //非叶子节点

                newSon.forEach(b => {
                    var pA = son(b)
                    if (pA.length > 0) {
                        b.children = pA
                    }
                })
            } else {
                //叶子节点  将有资源附着

                item.children = []
                roleData.forEach(element => {
                    if (element.routerId == item.id) {
                        let resourceNode = {
                            type: 'resource',
                            id: element.id,
                            label: element.name + 'resource-' + element.id,
                            key: 'resource-' + element.id
                        }
                        item.children.push(resourceNode)
                    }
                })
            }
            return newSon
        }

        return arr
    },
    pickerOptions: {
        shortcuts: [
            {
                text: '最近一周',
                onClick(picker) {
                    let end = new Date()
                    let start = new Date()
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
                    start = moment(start)
                        .utc(8)
                        .format('YYYY-MM-DD HH:mm:ss')
                    end = moment(end)
                        .utc(8)
                        .format('YYYY-MM-DD HH:mm:ss')
                    picker.$emit('pick', [start, end])
                }
            },
            {
                text: '最近一个月',
                onClick(picker) {
                    let end = new Date()
                    let start = new Date()
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
                    start = moment(start)
                        .utc(8)
                        .format('YYYY-MM-DD HH:mm:ss')
                    end = moment(end)
                        .utc(8)
                        .format('YYYY-MM-DD HH:mm:ss')
                    picker.$emit('pick', [start, end])
                }
            },
            {
                text: '最近三个月',
                onClick(picker) {
                    let end = new Date()
                    let start = new Date()
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
                    start = moment(start)
                        .utc(8)
                        .format('YYYY-MM-DD HH:mm:ss')
                    end = moment(end)
                        .utc(8)
                        .format('YYYY-MM-DD HH:mm:ss')
                    picker.$emit('pick', [start, end])
                }
            }
        ],
        disabledDate(time) {
            return time.getTime() > Date.now() //- 8.64e6
        }
    },
    timeDefaultShow(day, tag) {
        //用于返回日期数据
        var today = new Date()

        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
        let a = moment(targetday_milliseconds).utc(8)
        if (tag) {
            targetday_milliseconds = a.format('YYYY-MM-DD')
            console.log([
                targetday_milliseconds,
                moment(new Date())
                    .utc(8)
                    .format('YYYY-MM-DD')
            ])
            return [
                targetday_milliseconds,
                moment(new Date())
                    .utc(8)
                    .format('YYYY-MM-DD')
            ]
        } else {
            targetday_milliseconds = a.format('YYYY-MM-DD HH:mm:ss')
            return [
                targetday_milliseconds,
                moment(new Date())
                    .utc(8)
                    .format('YYYY-MM-DD HH:mm:ss')
            ]
        }
    },
    shilber(callBack, str) {
        var obj = {
            url: bus.$url.financialData.findLatest2,
            data: {}
        }
        this.httpPost(obj, success)
        function success(data) {
            let rows = data.rows
            var options = []

            if (rows.length > 0) {
                var row = rows[0]
                let dateTime = row.tradeDate.substring(4, 6) + '-' + row.tradeDate.substring(6, 8)

                rows.forEach(e => {
                    // if(e.substring(0,6)=='rateof'){
                    // var k = e.substring(6);
                    options.push({
                        value: e.term + ',' + e.rate + '%' + ',' + dateTime,
                        text: e.term + ',' + e.rate + '%' + ',' + dateTime,
                        dp: e.rate
                    })
                })
            }
            var dic = { 'O/N': 0, '1W': 1, '2W': 2, '1M': 3, '3M': 4, '6M': 5, '9M': 6, '1Y': 7 }
            options = options.sort(function(a, b) {
                var ka = a.value.substring(0, 2)
                var kb = b.value.substring(0, 2)
                return dic[ka] - dic[kb]
            })
            var objJson = {
                rows: options
            }

            callBack(objJson, str)
        }
    },
    shilber1(callBack, str) {
        var obj = {
            url: bus.$url.dictionary.findLatest3,
            data: {}
        }
        this.httpPost(obj, success)
        function success(data) {
            let rows = data.rows
            var options = []

            if (rows.length > 0) {
                //var row1 = rows[0]
                let dateTime = rows[0].tdate.substring(4, 6) + '-' + rows[0].tdate.substring(6, 8)

                rows.forEach(e => {
                    // if(e.substring(0,6)=='rateof'){
                    // var k = e.substring(6);
                    options.push({
                        value: e.f34112 + ',' + e.indicatorNum + '%' + ',' + dateTime,
                        text: e.f34112 + ',' + e.indicatorNum + '%' + ',' + dateTime,
                        dp: e.indicatorNum
                    })
                })
            }
            var dic = { 'R001': 0, 'R007': 1, 'R014': 2, 'R021': 3, 'R1M': 4, 'R2M': 5, 'R3M': 6, 'R4M': 7 }
            options = options.sort(function(a, b) {
                var ka = a.value.substring(0, 2)
                var kb = b.value.substring(0, 2)
                return dic[ka] - dic[kb]
            })
            var objJson = {
                rows: options
            }

            callBack(objJson, str)
        }
    },
    shilber3(callBack, str) {
        var obj = {
            url: bus.$url.workflowdef.getList,
            data: {}
        }
        this.httpPost(obj, success)
        function success(data) {
            let rows = data.data.rows
            debugger
            /*var options = []

            if (rows.length > 0) {
                var row = rows[0]
                let dateTime = row.tradeDate.substring(4, 6) + '-' + row.tradeDate.substring(6, 8)

                rows.forEach(e => {
                    // if(e.substring(0,6)=='rateof'){
                    // var k = e.substring(6);
                    options.push({
                        value: e.term + ',' + e.rate + '%' + ',' + dateTime,
                        text: e.term + ',' + e.rate + '%' + ',' + dateTime,
                        dp: e.rate
                    })
                })
            }
            var dic = { 'O/N': 0, '1W': 1, '2W': 2, '1M': 3, '3M': 4, '6M': 5, '9M': 6, '1Y': 7 }
            options = options.sort(function(a, b) {
                var ka = a.value.substring(0, 2)
                var kb = b.value.substring(0, 2)
                return dic[ka] - dic[kb]
            })
            var objJson = {
                rows: options
            }
*/
            callBack(rows, str)
        }
    },
    downLoad(data) {
        let str = '<a href="' + bus.$url.document.downLoad + '?documentCode=' + data.documentCode + '" style="display:none">下载</a>'
    },
    getSSS(data) {
        let val = moment(data).format('x')
        return val
    },
    setHHMMSS(data) {
        for (let item in data) {
            if (typeof data[item] == 'string') {
                if (data[item].indexOf('-') != -1) {
                    data[item] = data[item] + ' 00:00:00'
                }
            }
        }
        return data
    },
    headerTitle(content, title) {
        let str = `

         <el-popover
            placement="top-start"
            title="说明："
            width="200"
            trigger="hover"
            content="${content}">

    <span slot="reference">${title}<i  class="el-icon-warning redColor"></i></span>
        </el-popover>
      `
        return str
    },
    routerJump(to, back) {
        //oa跳转过来自动登录并存储信息
        let self = this
        let urls = null
        // var SMAP_SESSION_DATA =
        var obj1 = to.query
        var str = ''
        //   obj1.uid = '1'
        urls = bus.$url.loginMOA
        var obj = {
            url: urls,
            data: obj1
        }
        common.httpPost(obj, success)
        function success(data) {
            // data.businessKey =obj1.businessKey// 614;
            // data.processDefinitionKey = obj1.processDefinitionKey//'ZY-Tycj-mature';
            // data.taskid = obj1.taskid//'184525';
            // data.processInstanceId = obj1.processInstanceId//'184357';
            data.processDefinitionKey = data.processDefinitionKey || obj1.processDefinitionKey
            bus.$store.commit('setLogin', data)
            bus.$store.commit('setApprove', data)
            bus.$store.commit('callFromOtherSystem', 'yes')
            // let pKey = data.processDefinitionKey
            // if(obj1.processDefinitionKey=="ZY-Tycj-mature"){
            //   str = '/il-accountManag'
            return back('/dashboard')
            str = self.jumpStr(data)
            // }
            back(str)
        }
    },
    jumpStr(data) {
        var str = ''
        let pKey = data.processDefinitionKey
        if (pKey == 'create-role-process') {
            //角色
            str = '/roleAudit'
        } else if (pKey == 'create-user-process') {
            //用户
            str = '/userAudit'
        } else if (pKey == 'create-limitrules-process') {
            //规则标准
            str = '/regulationApproval'
        } else if (pKey == 'create-evaluation-process') {
            //授信评级
            str = '/evaluateLevelAppro'
        } else if (pKey == 'ZY-Yhlc-plan') {
            //银行理财方案管理
            str = '/BF-businessPlanApproval'
        } else if (pKey == 'ZY-Yhlc-perform') {
            //银行理财业务操作
            str = '/bf-businessoperationapproval'
        } else if (pKey == 'ZY-Yhlc-mature') {
            //银行理财台账
            str = '/bf-accountapproval'
        } else if (pKey == 'ZY-Tycj-plan') {
            //同业拆借
            str = '/il-businessplanapproval'
        } else if (pKey == 'ZY-Tycj-perform') {
            //同业拆借业务操作
            str = '/il-businessoperationapproval'
        } else if (pKey == 'ZY-Tycj-mature') {
            //同业拆借台账

            str = '/il-accountapproval'
        } else if (pKey == 'ZY-Zqyw-plan') {
            //债券业务方案管理
            str = '/bb-businessplanapproval'
        } else if (pKey == 'ZY-Zqyw-perform') {
            //债券业务业务操作
            str = '/bb-businessoperationapproval'
        } else if (pKey == 'ZY-Zqyw-mature') {
            //债券业务台账
            str = '/bb-accountapproval'
        } else if (pKey == 'ZY-Zyshg-plan') {
            //质押式逆回购方案管理
            str = '/prr-businessplanapproval'
        } else if (pKey == 'ZY-Zyshg-perform') {
            //质押式逆回购业务操作
            str = '/prr-businessoperationapproval'
        } else if (pKey == 'ZY-Zyshg-mature') {
            //质押式逆回购台账
            str = '/prr-accountapproval'
        } else if (pKey == 'ZY-Tycd-plan') {
            //同业存单方案管理
            str = '/cod-businessplanapproval'
        } else if (pKey == 'ZY-Tycd-perform') {
            //同业存单务操作
            str = '/cod-businessoperationapproval'
        } else if (pKey == 'ZY-Tycd-mature') {
            //同业存单台账
            str = '/cod-accountapproval'
        } else if (pKey == 'ZY-Tyck-plan') {
            //同业存款方案管理
            str = '/id-businessplanapproval'
        } else if (pKey == 'ZY-Tyck-perform') {
            //同业存款业务操作
            str = '/id-businessoperationapproval'
        } else if (pKey == 'ZY-Tyck-mature') {
            //同业存款台账
            str = '/id-accountapproval'
        } else if (pKey == 'ZY-Jjtz-plan') {
            //基金投资方案管理
            str = '/fi-businessplanapproval'
        } else if (pKey == 'ZY-Jjtz-perform') {
            //基金投资业务操作
            str = '/fi-businessoperationapproval'
        } else if (pKey == 'ZY-Jjtz-mature') {
            //基金投资台账
            str = '/fi-accountapproval'
        } else if (pKey == 'WT-Yhlc-plan') {
            //委投
            str = '/ei-businessplanapproval'
        } else if (pKey == 'WT-Yhlc-perform') {
            //委投
            str = '/ei-businessoperationapproval'
        } else if (pKey == 'WT-Yhlc-mature') {
            //委投
            str = '/ei-accountapproval'
        } else if (pKey == 'WT-Yhlc-kjxy') {
            //协议框架
            str = '/ei-frameworkagreementapproval'
        } else if (pKey == 'WT-Yhlc-xybh') {
            //协议编号
            str = '/ei-protocolnumberapproval'
        } else if (pKey == 'WT-Yhlc-maturity') {
            //投资到期审批登记
            str = '/ei-splittingoperation'
        } else if (pKey == 'WT-Yhlc-entry') {
            //投资到期审批入账
            str = '/ei-accountingForFundsApp'
        } else if (pKey == 'capital-corportaion-process') {
            //企业资金划拨审批
            str = '/EP-CapitalAllocationApproval'
        } else if (pKey == 'capital-interbank-process') {
            //同业资金划拨审批
            str = '/IB-CapitalAllocationApproval'
        } else if (pKey == 'capital-reserve-process') {
            //存款准备金划拨审批
            str = '/DM-CapitalAllocationApproval'
        } else if (pKey == 'JT-MoneyFund-pla') {
            //总部货币基金业务方案审批
            str = '/CURC-businessPlanApproval'
        } else if (pKey == 'JT-BondFund-pla') {
            //总部债券基金业务方案审批
            str = '/BONC-businessPlanApproval'
        } else if (pKey == 'JT-NetValueFina-ledger') {
            //净值型理财台账审批
            str = '/JT-parametermanagementApproval'
        } else if (pKey == 'ZY-CapitalOperate') {
            //自营资金操作业务审批
            str = '/CUR-fundsApproval'
        } else if (pKey == 'JT-PreferredStock-ledger') {
            //优先股台账审批
            str = '/preferredStockLedgerApproval'
        } else if (pKey == 'ZY-SENDRep-plan') {
            str = '/RRP-businessPlanApproval'
        } else if (pKey == 'ZY-PriceRep-plan') {
            str = '/PQR-businessPlanApproval'
        } else if (pKey == 'ZY-NetValueFina-ledger') {
            str = '/parametermanagementApproval'
        } else if (pKey == 'ZY-ABS-ledger') {
            str = '/assetsLedgerApproval'
        } else if (pKey == 'ZY-MoneyFund-plan') {
            str = '/CUR-businessPlanApproval'
        } else if (pKey == 'ZY-BondFund-plan') {
            str = '/BON-businessPlanApproval'
        } else if (pKey == 'ZY-Zqyw-perform') {
            str = '/BB-businessOperationApproval'
        } else if (pKey == 'WT-Yhlc-kjxy') {
            str = '/ei-frameworkagreementapproval'
        } else if (pKey == 'create-indregl-process') {
            str = '/regulatoryLimitSettingApproval'
        } else if (pKey == 'ZY-NetValueFina-networth') {
            str = '/netOperatingApproval'
        } else if (pKey == 'JT-NetValueFina-recycle') {
            str = '/JT-recoverymanagementApproval'
        } else if (pKey == 'capital-interbank-process') {
            str = '/IB-CapitalAllocationApproval'
        } else if (pKey == 'JT-PreferredStock-recycle') {
            str = '/preferredStockRecoveryMgApproval'
        } else if (pKey == 'ZY-NetValueFina-recycle') {
            str = '/recoverymanagementApproval'
        } else if (pKey == 'ZY-ABS-recycle') {
            str = '/capitalRecoveryApproval'
        } else if (pKey == 'JT-MoneyFund-perform') {
            str = '/CURC-businessOperationApproval'
        } else if (pKey == 'JT-BondFund-perform') {
            str = '/BONC-businessOperationApproval'
        } else if (pKey == 'ZY-Zqyw-mature') {
            str = '/BB-accountApproval'
        } else if (pKey == 'WT-Yhlc-plan') {
            str = '/EI-businessPlanApproval'
        } else if (pKey == 'create-gpcmpylimit-process') {
            str = '/groupAuthorizationLimitSettingApproval'
        } else if (pKey == 'ZY-SENDRep-perform') {
            str = '/RRP-businessOperationApproval'
        } else if (pKey == 'ZY-PriceRep-perform') {
            str = '/PQR-businessOperationApproval'
        } else if (pKey == 'ZY-MoneyFund-perform') {
            str = '/CUR-businessOperationApproval'
        } else if (pKey == 'ZY-BondFund-perform') {
            str = '/BON-businessOperationApproval'
        } else if (pKey == 'capital-reserve-process') {
            str = '/DM-CapitalAllocationApproval'
        } else if (pKey == 'JT-MoneyFund-mature') {
            str = '/CURC-accountApproval'
        } else if (pKey == 'JT-BondFund-mature') {
            str = '/BONC-accountApproval'
        } else if (pKey == 'WT-Yhlc-xybh') {
            str = '/EI-protocolNumberApproval'
        } else if (pKey == 'ZY-SENDRep-mature') {
            str = '/RRP-accountApproval'
        } else if (pKey == 'ZY-PriceRep-mature') {
            str = '/PQR-accountApproval'
        } else if (pKey == 'ZY-MoneyFund-mature') {
            str = '/CUR-accountApproval'
        } else if (pKey == 'ZY-BondFund-mature') {
            str = '/BON-accountApproval'
        } else if (pKey == 'JT-MoneyFund-networth') {
            str = '/CURC-accountWorthApproval'
        } else if (pKey == 'JT-BondFund-networth') {
            str = '/BONC-accountWorthApproval'
        } else if (pKey == 'WT-Yhlc-perform') {
            str = '/EI-businessOperationApproval'
        } else if (pKey == 'ZY-MoneyFund-networth') {
            str = '/CUR-accountWorthApproval'
        } else if (pKey == 'ZY-BondFund-networth') {
            str = '/BON-accountWorthApproval'
        } else if (pKey == 'WT-Yhlc-mature') {
            str = '/EI-accountApproval'
        }

        return str
    },
    keyLogin(to, back) {
        let self = this
        let urls = null
        // var SMAP_SESSION_DATA =
        var obj1 = to.query
        var str = ''
        //   obj1.uid = '1'
        urls = bus.$url.loginMOA
        var obj = {
            url: urls,
            data: obj1
        }
        common.httpPost(obj, success)
        function success(data) {
            bus.$store.commit('setLogin', data)
            back('/')
        }
    },
    getapp() {
        //获取oa跳转过后的存储参数
        var obj = {
            businessKey: bus.$store.getters.getLogin('businessKey'),
            processDefinitionKey: bus.$store.getters.getLogin('processDefinitionKey'),
            taskid: bus.$store.getters.getLogin('taskid'),
            processInstanceId: bus.$store.getters.getLogin('processInstanceId')
        }
        return obj
    },
    /**
     * 返回或者设置当前弹出页是否是由外部链接调用起来的
     * @param {*} yesOrNo
     */
    callFromOtherSystem(yesOrNo) {
        console.log('callFromOtherSystem:yesOrNo:' + yesOrNo)
        if (yesOrNo) {
            bus.$store.commit('callFromOtherSystem', yesOrNo)
        }
        console.log('callFromOtherSystem:yesOrNo->' + bus.$store.getters.getLogin('callFromOtherSystem'))
        return bus.$store.getters.getLogin('callFromOtherSystem')
    },
    checkCallDetailByOtherSystem(cb) {
        console.log('checkCallDetailByOtherSystem')
        var obj = this.getapp()
        if (obj.businessKey) {
            if (cb) {
                cb.call(null, obj, 2)
                // clear defer close window after audit windows
                this.callFromOtherSystem('yes')
            }
            bus.$store.commit('oaOut')
        }
    },
    shouldThisDialogClose() {
        let fromOA = this.callFromOtherSystem()
        if (console) {
            console.log('shouldThisDialogClose:callFromOtherSystem:' + fromOA)
        }
        if (fromOA == 'yes') {
            // close this window
            let CWRefreshURL = bus.$store.getters.getLogin('CWRefreshURL')
            if (console) {
                console.log('shouldThisDialogClose:CWRefreshURL:' + CWRefreshURL)
            }
            if (CWRefreshURL) {
                location.href = this.ctx + '/smap/redirect' + '?location=' + encodeURI(CWRefreshURL)
            }
        }
        // other close event source???
    },
    rateCom(_this, back) {
        var self = _this
        var obj = {
            url: self.$url.financialData.findLatest1,
            data: {}
        }
        self.common.httpPost(obj, success)
        function success(data) {
            //财务公司存款利率：
            var obj1 = {}
            data.rows.forEach(element => {
                if (element.org == '1') {
                    obj1[element.benchmark] = element.rate
                    obj1['tradeDate'] = element.tradeDate
                    if (!obj1.updateTime) {
                        obj1.updateTime = element.updateTime
                    }
                }
            })
            back(obj1)
        }
    },
    backNums(mpm) {
        if (!mpm) {
            return 0
        }

        if (typeof mpm == 'number') {
            return mpm
        } else {
            try {
                return mpm.replace(/,/g, '')
            } catch (error) {
                return Number(mpm)
            }
        }
    },
    getNowFormatDate() {
        var day = new Date()
        var Year = 0
        var Month = 0
        var Day = 0
        var CurrentDate = ''
        //初始化时间
        //Year       = day.getYear();//有火狐下2008年显示108的bug
        Year = day.getFullYear() //ie火狐下都可以
        Month = day.getMonth() + 1
        Day = day.getDate()
        CurrentDate += Year + '-'
        if (Month >= 10) {
            CurrentDate += Month + '-'
        } else {
            CurrentDate += '0' + Month + '-'
        }
        if (Day >= 10) {
            CurrentDate += Day
        } else {
            CurrentDate += '0' + Day
        }

        return CurrentDate
    }

}
export default common
