高章伟
2022-03-18 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<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);
        alert('这是失单报告,现在正在修改中,询价:'+opportunityid);
        /*$Lightning.use("c:???", function () {
                $Lightning.createComponent("c:???",
                    {
                    这里传3个参数,第4个参数ID为空,所以为空不传输;
                    1、页面flag"新建";
                    2、recordType 失单,部分失单记录类型,
                       如果是失单,那么就传输失单 01210000000R4hM
                       在apex里面保存时,可以使用 询价失单报告 和 询价部分失单报告
                       记录类型根据赋值,
                    3、询价ID,因为是新建的,所以必然需要赋值失单报告的询价ID;
 
                    },
                    "CreateLostReport",
                    function (cmp) {
                        console.log('Component created, do something cool here');
                    });
            });
            */
            var stateObject = {};  
            var title = "新建询价失单报告";  
            var newUrl = window.location.href+"&Ids="+opportunityid;
             newUrl += "&LostType=0";
             newUrl += "&Flag=0"
            history.pushState(stateObject,title,newUrl);  
 
            // window.location.href = window.location.href+"&Ids="+opportunityid;
            $Lightning.use("c:LostSingleApp", function () {
            $Lightning.createComponent("c:lostSingle",
                    {Id:"123"},
                    "CreateLostReport",
                    function (cmp) {
                        console.log('Component created, do something cool here');
                    });
            });
 
    }
    //部分失单
    function lostPartReport(){
        // 这是询价的ID;
        var opportunityid = getParamFromUrl('CF00N10000004lbGT_lkid');
        console.log(opportunityid);
        alert('这是部分失单报告,现在正在修改中,询价:'+opportunityid);
        /*$Lightning.use("c:???", function () {
                $Lightning.createComponent("c:???",
                    {
                    这里传3个参数,第4个参数ID为空,所以为空不传输;
                    1、页面flag"新建";
                    2、recordType 失单,部分失单记录类型,
                       如果是部分失单,那么就传部分失单,
                       如果是空,那么就传空,这个是给失单报告默认值设值使用;
                       在apex里面保存时,可以使用 询价失单报告 和 询价部分失单报告
                       记录类型根据赋值,取消是跳转到
                    3、询价ID,因为是新建的,所以必然需要赋值失单报告的询价ID;
 
                    },
                    "CreateLostReport",
                    function (cmp) {
                        console.log('Component created, do something cool here');
                    });
            });
            */
            var stateObject = {};  
            var title = "新建询价失单报告";  
            var newUrl = window.location.href+"&Ids="+opportunityid;
             newUrl += "&LostType=1";
             newUrl += "&Flag=0"
            history.pushState(stateObject,title,newUrl);  
 
            $Lightning.use("c:LostSingleApp", function () {
            $Lightning.createComponent("c:lostSingle",
                    {},
                    "CreateLostReport",
                    function (cmp) {
                        console.log('Component created, do something cool here');
                    });
            });
    }
 
    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>