binxie
2024-01-16 1b08402678deb31bba4a347bfd388eba8360cbc1
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
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference, NavigationMixin} from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  splitApplyButton  from '@salesforce/apex/LexCancelConsumDetailsCtl.splitApplyButton';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
// 耗材备品配套一览 自定义按钮或链接:分单
export default class LexSplit_Apply extends NavigationMixin(LightningElement) {
    @api recordId;
    //只获取当前list选中的一览Id
    @api rentalApplyIds;
    IsLoading=true;
    //提示信息
    msg;
 
    connectedCallback(){
        console.log(this.recordId);
        console.log(JSON.stringify(this.rentalApplyIds));
        if (this.recordId && JSON.stringify(this.rentalApplyIds)) {
            console.log("-------分单--------",this.rentalApplyIds,JSON.stringify(this.rentalApplyIds))
            splitApplyButton({
                recordId: this.recordId
            }).then(res=>{
                this.IsLoading = false;
                console.log("-------分单----1111----",res,res.length);
                if(res && res.length == 1){
                    this.msg = '这个申请单只有一条耗材备品一览,不能分单';
                }else if(res.length == this.rentalApplyIds.length){
                    this.msg = '不能全选耗材备品一览分单';
                }else{
                    window.open("/apex/ConsumApplySplit?objId="+this.recordId+"&raesIds="+this.rentalApplyIds, 'ConsumApplySplit', 'width=800,height=300');
                    this.closeAction();
                }
            })
            
            // 
        }else{
            this.msg = '请选择耗材备品一览记录';
            this.IsLoading = false;
        }
    }
    closeAction() {
        //返回当前的备品申请
        window.open("/"+this.recordId,'_self');
    }
}