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
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import init from '@salesforce/apex/LexNewSICustomNewController.init';
import getISOPList from '@salesforce/apex/LexNewSICustomNewController.getISOPList';
import getProfileName from '@salesforce/apex/LexNewSICustomNewController.getProfileName';
 
export default class lexNewSICustomNew extends NavigationMixin(LightningElement) {
    @api recordId;
    
    IsLoading=true;
    //提示信息
    msg;
    hasError;
    records;
    recordTypeId;
    async connectedCallback(){
        console.log(this.recordId);
        await init({recordId:this.recordId}).then(res=>{
            console.log(1);
            console.log(res);
            this.recordTypeId=res.RecordTypeId;
            this.main().then(res=>{
                this.IsLoading=false;
                if(this.msg==''){
 
                    this.dispatchEvent(new CloseActionScreenEvent());
                    this.closeAction();
                }
                
            })
        })
 
    }
 
    async main(){
        console.log("in main");
        var records = new Array();
        if(this.recordTypeId=='012100000006KMeAAM'){
            records = await getISOPList({recordId:this.recordId});
        }
        var RecordTypeid = this.recordTypeId;
        if(RecordTypeid=='012100000006KMeAAM'&&records.length!=0){
            // alert("存在已有的SI需求表,不能新建SI需求表");
            this.msg="存在已有的SI需求表,不能新建SI需求表";
        }else if(await getProfileName() !='2S'){
        // 添加新建需求表的限制
 
            // alert("非营业部人员不能创建需求表");
            this.msg="非营业部人员不能创建需求表";
        }else if(RecordTypeid!='012100000006KMeAAM'){
            // alert("非SI询价,不能新建SI需求表");
            this.msg="非SI询价,不能新建SI需求表";
        } else if(RecordTypeid=='012100000006KMeAAM'&&records.length==0){
            window.top.location.href="/apex/ISO_DemandOperAndDemonsNew?OppoerID="+this.recordId;
        }
    }
    closeAction() {
        //返回当前的备品申请
        window.open("/"+this.recordId,'_self');
    }
}