buli
2023-04-26 d6a096fadfe9c8f261f56a827cfceed663c36b8b
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
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import getUserId from '@salesforce/apex/RentalApplyControllerLWT.getUserId';
import init from '@salesforce/apex/SelectSubstituteControllerLWT.initClearReturnDeliverySlipButton';
import updateRaescList from '@salesforce/apex/SelectSubstituteControllerLWT.updateRaescList';
import selectRacById from '@salesforce/apex/SelectSubstituteControllerLWT.selectRacById';
import selectRaesdcId from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesdcId';
 
import { loadScript } from 'lightning/platformResourceLoader';
import { submitForApproval } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
 
export default class lexClearReturnDeliverySlip extends LightningElement {
 
    @api recordId;
    id;
    RentalApplyId;
    Status;
    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;
            }
        }
    }
 
 
 
    connectedCallback(){
        console.log(this.recordId);
        init({recordId:this.recordId}).then(result=>{
            console.log(result);
            if(result!=null){
                this.Rental_Apply_Equipment_Set__c=result;
                this.cancelSubmit().then(res=>{
                    this.IsLoading=false;
                    this.dispatchEvent(new CloseActionScreenEvent());
                });    
            }
        }).catch(err=>{
            console.log("error:");
            console.log(err);
        }).finally(()=>{
 
        });
    }
 
 
 
    async cancelSubmit(){
        console.log("hhh1");
        var raesId = this.recordId;
        console.log("hhh2");
        var result = await selectRaesdcId({recordId:this.recordId});
        console.log("hhh3");
        var objs = result;
        if (objs.length< 1) {
            // alert('没有需要清空的一览明细');
            const event = new ShowToastEvent({
                title: '提示信息',
                message:'没有需要清空的一览明细'
            });
            this.dispatchEvent(event);
        } else {
            console.log("hhh4");
            var result;
            console.log("hhh5");
            await updateRaescList({updateList:objs})
            .then(res=>{
                console.log(res);
                result=res;
            });
            console.log("hhh6");
            if (result.success==true) {
                console.log("hhh7");
                // success
                // alert("回寄运输单信息已清空");
                const event = new ShowToastEvent({
                    title: '提示信息',
                    message:"回寄运输单信息已清空"
                });
                this.dispatchEvent(event);
                setTimeout(function() {
                    location.href = "/"+this.recordId;
                }, 100);
            } else {
                console.log("hhh8");
                // alert("failed to update:" + result.errors.fields + " " + result[0].errors.message);
                const event = new ShowToastEvent({
                    title: '提示信息',
                    message:"failed to update:" + result.errors.fields + " " + result[0].errors.message
                });
                this.dispatchEvent(event);
            }
        }
    }
}