<apex:page standardController="Lost_cancel_report__c"
           showHeader="false"  sidebar="false" id="LostReportCreate" title="新建询价失单/取消报告" >
    <apex:includeLightning />
    <div style="width:100%;height:100%;" id="CreateLostReport" />
    <script>
    init();
    function init(){
        console.log(getParam('RecordType'));
        if(getParam('RecordType') == '01210000000R4hH'){
            cancelReport();
            return;
        }
        if(getParam('RecordType') == '01210000000R4hM'){
            lostReport();
            return;
        }
        if(getParam('RecordType') != null){
            lostPartReport();
            return;
        }else{
            alert('报告记录类型选择错误，请重新选择！');
            window.open('/006/o','_self');
            return;
        }
    }
    function cancelReport() {
        // 这里 上线时需要改成
        var str = '/a1U/e?nooverride=1';
        if(getParam('RecordType') != null){
            str += '&RecordType='+getParam('RecordType');
        }
        if(getParam('CF00N10000004lbGT') != null){
            str += '&CF00N10000004lbGT='+getParam('CF00N10000004lbGT');
        }
        if(getParam('CF00N10000004lbGT_lkid') != null){
            str += '&CF00N10000004lbGT_lkid='+getParam('CF00N10000004lbGT_lkid');
        }
        if(getParam('CF00N10000006QShg') != null){
            str += '&CF00N10000006QShg='+getParam('CF00N10000006QShg');
        }

        if(getParam('CF00N10000006QShg_lkid') != null){
            str += '&CF00N10000006QShg_lkid='+getParam('CF00N10000006QShg_lkid');
        }
        if(getParam('CF00N10000006QShq') != null){
            str += '&CF00N10000006QShq='+getParam('CF00N10000006QShq');
        }
        if(getParam('CF00N10000006QShq_lkid') != null){
            str += '&CF00N10000006QShq_lkid='+getParam('CF00N10000006QShq_lkid');
        }
        if(getParam('CF00N10000006QShb') != null){
            str += '&CF00N10000006QShb='+getParam('CF00N10000006QShb');
        }
         console.log('CF00N10000006QShb:' + getParam('CF00N10000006QShb'));
        if(getParam('CF00N10000006QShb_lkid') != null){
            str += '&CF00N10000006QShb_lkid='+getParam('CF00N10000006QShb_lkid');
        }
        if(getParam('retURL') != null){
            str += '&retURL='+getParam('retURL');
        }
        window.open(str,'_self');
    }
    //失单
    function lostReport(){
        // 这是询价的ID；
        var opportunityid = getParam('CF00N10000004lbGT_lkid');
        console.log(opportunityid);
      	var str = '/apex/PCLLostReportPage?pageStatus=Create'  +'&oppId='+opportunityid +'&lostType=' +  '失单';
        window.open(str,'_self');

    }
    //部分失单
    function lostPartReport(){
        // 这是询价的ID；
        var opportunityid = getParamFromUrl('CF00N10000004lbGT_lkid');
        console.log(opportunityid);
        var str = '/apex/PCLLostReportPage?pageStatus=Create'  +'&oppId='+opportunityid +'&lostType=' + '部分失单';
        window.open(str,'_self');
        
    }

    function getParam(paramName) {
        paramValue = "", isFound = !1;
        if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
            arrSource = decodeURI(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
            while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
                }
        return paramValue == "" && (paramValue = null), paramValue;
    }
    
    </script>
    <script type="text/javascript">
    </script>
</apex:page>