19626
2023-04-21 2768cebeb80753586dcc25b352913c3b5b5b6cd1
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-04-20 15:04:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-20 18:01:37
 */
/*
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-04-20 15:04:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-20 17:11:01
 */
import { LightningElement } from 'lwc';
import save from '@salesforce/apex/lexPCLLostReportLwcController.save';
import jquery from '@salesforce/resourceUrl/jquery183minjs';
import blockUIcss from '@salesforce/resourceUrl/blockUIcss';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
import setBrand from '@salesforce/apex/lexPCLLostReportLwcController.setBrand';
export default class LexPCLLostReportPage extends LightningElement {
    connectedCallback(){
        Promise.all([
           loadScript(this,jquery),
           loadStyle(this,blockUIcss)
        ]).then(() =>{
            save().then(result=>{
                if(result){
                    this.showToast(result,"success");
                    window.unblockUI();
                    this.clearBrandMannualName();
                }
            setBrand({
 
            }).then({
                
            });
            })
        }).catch(error=>{
            console.log(error);
        });
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    saveJs() {
        blockme();
        save();
    }
    addBrandJs() {
        blockme();
        addBrand();
    }
    submitJS() {
        blockme();
        submit();
    }
    addProductJs(number) {
        blockme();
        addProduct(number);
    }
    RemoveJs(number) {
        blockme();
        Remove(number);
    }
    // add tcm 20211118 start
    searchJs(topNum, secondNum) {
        blockme();
        search(topNum, secondNum);
    }
    // add tcm 20211118 end
    setLostTotalAmount() {
        //console.log('setLostTotalAmount start:');
        var totalAmount = document.getElementById("allPage:allForm:allBlock:EditPage:LostReport:lstReport:LostTotalAmountOut:LostTotalAmount");
        var totalAmountHidden = document.getElementById("allPage:allForm:allBlock:LostTotalAmount");
        if (!!totalAmount && !!totalAmountHidden) {
            var tempLostAmount = 0.0;
            var i = 0;
            var brandCount = parseInt("{!brandCount}");
            //console.log(brandCount);
 
            for (var i = 0; i < brandCount; i++) {
                var brandAmountObject =
                    document.getElementById("allPage:allForm:allBlock:EditPage:LostBrands:" +
                        i + ":LostBrand:BrandContent:LostPriceOut:LostPrice");
                var brandCompanyObject =
                    document.getElementById("allPage:allForm:allBlock:EditPage:LostBrands:" +
                        i + ":LostBrand:BrandContent:Lost_By_CompanyOut:Lost_By_Company");
 
                if (!!brandAmountObject && !!brandCompanyObject) {
 
                    var brandCompanyText = brandCompanyObject.innerText;
                    var brandCompanyValue = brandCompanyObject.value;
 
 
                    if (!!brandCompanyText && brandCompanyText != '--无--' && !!brandCompanyValue) {
                        var brandAmount = localParseFloat(brandAmountObject.value);
                        //console.log('brandAmount:'+brandAmount);
                        tempLostAmount = tempLostAmount + brandAmount;
                    }
                }
            }
            totalAmount.innerHTML = toNumComma(tempLostAmount);
            totalAmountHidden.value = tempLostAmount;
        }
        //console.log('setLostTotalAmount end');
    }
    setBrandName(brandNumber) {
        blockme();
        setbrand(brandNumber);
    }
    setBrandMannualName(brandNumber) {
        blockme();
        setbrandmannual(brandNumber);
    }
    // 失单品牌不等于其他时,失单品牌(手动)清空并且不允许填写,失单品牌等于其他时,失单对手型号不可用  thh 2022-01-13 start
    clearBrandMannualName(){
        if(document.getElementById('allPage:allForm:allBlock:EditPage:LostBrands:0:LostBrand:BrandContent:Lost_By_CompanyOut:Lost_By_Company').value == '其他'){
            j$(escapeVfId('allPage:allForm:allBlock:EditPage:LostBrands:0:LostBrand:productTable:0:LostProduct')).attr("disabled", true);
        } else{
            document.getElementById('allPage:allForm:allBlock:EditPage:LostBrands:0:LostBrand:BrandContent:Lost_By_Company_MannualOut:Lost_By_Company_Mannual').value = '';
            j$(escapeVfId('allPage:allForm:allBlock:EditPage:LostBrands:0:LostBrand:BrandContent:Lost_By_Company_MannualOut:Lost_By_Company_Mannual')).attr("disabled", true);
        }
    }
    // 失单品牌不等于其他时,失单品牌(手动)清空并且不允许填写,失单品牌等于其他时,失单对手型号不可用  thh 2022-01-13 end
}