liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
/*
 * @Date: 2023-08-14 13:47:51
 * @Author: @zyh
 * @LastEditTime: 2023-08-25 10:27:32
 * @Descripttion: 
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference,NavigationMixin } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import  init  from '@salesforce/apex/lexUpdateDateController.init';
import  userCheck  from '@salesforce/apex/lexUpdateDateController.userCheck';
export default class LexUpdateDate extends NavigationMixin(LightningElement) {
    @api recordId;
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
 
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
 
    connectedCallback(){
        console.log(this.recordId);
        
        this.IsLoading = false;
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result.status2.slice(0,1) > 5,'=================1');
            console.log(result.status2.slice(0,1) ,'=================1-1');
            console.log(result.status2.slice(0,1) < 3,'=================2');
            if((result.status2.slice(0,1) >= 5 && result.status2 != '5.盖章完毕') || result.status2.slice(0,1) < 3){
                const evt = new ShowToastEvent({
                    title : '',
                    message : '当前合同不支持修改合同日期,不能申请改期',
                    variant : 'error',
                    mode : 'sticky'
                });
                this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
                console.log("当前合同不支持修改合同日期,不能申请改期");
                return;
            }
            userCheck({}).then(result => {
                if(result.adminId || result.Alias == '高文君' || result.Alias == '王良'){
                    let defaultValues = {
                        Maintenance_Contract__c : this.recordId
                    }
                    this[NavigationMixin.Navigate]({
                        type: 'standard__objectPage',
                        attributes: {
                            objectApiName: 'Maintenance_New_Update__c', // 要新建的对象API
                            actionName: 'new'
                        },
                        state:{
                            // defaultFieldValues:'Repair__c='+this.repairName// 要复制的字段API
                            // defaultFieldValues:this.dataFields// 要复制的字段API
                            defaultFieldValues:encodeDefaultFieldValues(defaultValues)// 要复制的字段API
                            
                        }
                    });
                    console.log('236===row' , defaultValues);
                }else {
                    const evt = new ShowToastEvent({
                        title : '',
                        message : '您没有修改合同日期的权限,不能申请改期',
                        variant : 'error',
                        mode : 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    return;
                }
            })
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
            
        });
    }
}