LiJinHuan
2023-04-26 8b05a8455721531d0f06991fbd6266bca28eeb59
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
import { LightningElement,api, track, wire } from 'lwc';
// {!RequireScript("/resource/CommonUtilJs")}
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import LightningConfirm from 'lightning/confirm';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class lexStockCancel extends LightningElement {
 
    @api recordId;
    IsLoading=true
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                console.log('str');
                console.log(str);
                this.recordId=str;
            }
        }
    }
 
 
    async connectedCallback(){
        console.log(this.recordId);
        await init({recordId:this.recordId}).then(result=>{
            console.log(result);
            if(result!=null){
 
                this.sumit().then(res=>{
                    console.log("关闭窗口");
                    this.IsLoading=false;
                    this.dispatchEvent(new CloseActionScreenEvent());
                }).catch(err=>{
                    console.log("error:");
                    console.log(err.message);
                    const event = new ShowToastEvent({
                        title: '提示信息',
                        message:"操作失败,提示信息:"+err.message,
                    });
                    this.dispatchEvent(event);
                    //alert("操作失败,提示信息:"+err.message);
                });
                console.log("end");
            }
        }).catch(err=>{
            console.log("error:");
            console.log(err.message);
            console.log("报错结束");
        }).finally(()=>{
            console.log("finally");
            
        });
        
    }
 
 
    async sumit(){
    
        // var reason = '{!Opportunity.Stock_cancel_reason__c}';
        // if (reason == null || reason == '') {
        //     alert('必须填写撤销备货理由。');
        //     return
        // }
 
        // // CHAN-BCS8T5 LHJ 20190604 Start
        // var stage = '{!Opportunity.Whether_Upload_Question_Document__c}';
        // if (stage == '0') {
        //     alert('请上传质疑函。');
        //     return;
        // }
        // // CHAN-BCS8T5 LHJ 20190604 End
 
        // if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) {
        //     return;
        // }
 
        // var rac = new sforce.SObject("Opportunity");
        // rac.Id = "{!Opportunity.Id}";
        // rac.Stock_apply_status__c = "撤销填写完毕";
        // var result = sforce.connection.update([rac]);
        // var messages = getConnectDMLErrorMessages(result);
        // if (messages.length > 0) {
        // alert(messages.join("\n"));
        // return;
        // }
 
        // var request = new sforce.ProcessSubmitRequest();
        // request.objectId = "{!Opportunity.Id}";
        // var processResults = sforce.connection.process([request]);
        // if (processResults[0].errors != null) {
        // var back = new sforce.SObject("Opportunity");
        // back.Id = "{!Opportunity.Id}";
        // back.Stock_apply_status__c = "批准";
        // var backResult = sforce.connection.update([back]);
        // backMessages = getConnectDMLErrorMessages(backResult);
        // if (backMessages.length > 0) {
        // alert(backMessages.join("\n"));
        // return;
        // }
 
        // var errmsg = processResults[0].errors.message.toString();
        // alert(errmsg);
        // return;
        // }
        // window.location.reload();
        // };
    }
}