buli
2023-05-22 71b93327e8f3fb3bffffc7c033c1f782e7b6ab32
force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
@@ -4,11 +4,11 @@
 * @Author: chen jing wu
 * @Date: 2023-04-20 15:04:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-28 17:33:23
 * @LastEditTime: 2023-05-05 11:01:42
 */
const columns=[
    { "label" : "失单品牌", "apiName" : "LostBrandName__c" ,"fieldType":"picklist","objectName":"PCLLostProduct__c"},
    { "label" : "失单对手型号", "apiName" : "LostProduct__c" ,"fieldType":"lookup","objectName":"PCLLostProduct__c"},
    { "label" : "失单品牌", "apiName" : "LostBrandName__c" ,"fieldType":"picklist","objectName":"PCLLostProduct__c", "readOnly":true,"value":"--无--"},
    { "label" : "失单对手型号", "apiName" : "LostProduct__c" ,"fieldType":"lookup","objectName":"PCLLostProduct__c","disable":"false"},
    { "label" : "失单数量", "apiName" : "Quantity__c","fieldType":"text","objectName":"PCLLostProduct__c" },
    { "label" : "失单对手型号(手动)", "apiName" : "LostProductMannual__c","fieldType":"text","objectName":"PCLLostProduct__c" },
    { "label" : "失单产品类别", "apiName" : "ProductClass__c","fieldType":"picklist","objectName":"PCLLostProduct__c" },
@@ -35,6 +35,7 @@
import setbrand from '@salesforce/apex/lexPCLLostReportLwcController.setBrand';
import init from '@salesforce/apex/lexPCLLostReportLwcController.init';
import multiSelectCombobox from 'c/multiSelectCombobox'
import lexMultiSelectCombobox from 'c/lexmultiSelectCombobox';
import searchBrands from '@salesforce/apex/lexPCLLostReportLwcController.searchBrands';
import getNewLostBrand from '@salesforce/apex/lexPCLLostReportLwcController.getNewLostBrand';
import getLostReport from '@salesforce/apex/lexPCLLostReportLwcController.getLostReport';
@@ -43,9 +44,11 @@
    @track records;
    @api recordJson;
    @track columns=columns;
    // @track columns=columns;
    @track columns2=columns2;
    @api reasonValue;
    @track columnsArr = [columns];
    @track columns = columns;
    oppId = '0061000001R2xjWAAR';
    lostReportId = '';
    pageStatus = 'Create';
@@ -53,8 +56,10 @@
    submitFlag = '';
    searchResult;
    brandsCount = [""];
    columnsArrIndex = 0;
    @track LostReport = {
        LostBrands: [],
        LostBrands: [
        ],
        lostReport: {}
    };
    @track brandOptions = [];
@@ -93,12 +98,22 @@
            // const div = this.template.querySelector('[data-Id="initDiv"]');
            // console.log(success);
            // div.classList.add("mynewclass");
            this.LostReport.LostBrands[0].columns = columns;
            console.log(this.LostReport);
            const multiCombobox = this.template.querySelector('c-multi-select-combobox');
            multiCombobox.refreshOptions(this.brandOptions);
        }).catch(error=>{
            console.log("error");
            console.log(error);
        });
    }
    get isInit(){
        if(this.LostReport.LostBrands.length == 0){
            return false
        }else{
            return true;
        }
    }
    
@@ -153,7 +168,6 @@
    //         });
    //     });
    // }
    getParamValue(paramName) {
        // Use the URLSearchParams API to get the value of a query parameter
@@ -173,7 +187,9 @@
            lineNo: this.LostReport.LostBrands.length
        }).then(result=>{
            this.LostReport.LostBrands.push(result);
        })
            this.LostReport.LostBrands[this.LostReport.LostBrands - 1].columns = columns;
            // this.columnsArr.push(columns);
        });
    }
    submitJS() {
        submit().then(result=>{
@@ -218,8 +234,13 @@
    deleteBrandJs(event){
        var str = event.target.name;
        this.columnsArrIndex = 0;
        this.LostReport.LostBrands.splice(str,1);
        console.log(this.LostReport);
    }
     getMutiboxName(index){
        return `mutibox${index}`;
    }
    
    // add tcm 20211118 end
@@ -259,25 +280,41 @@
        });
    }
    setBrandMannualName(event) {
        var set = event;
        console.log(set);
        var index = event.target.name;
        const payload = event.detail.payload;
        const payloadType = event.detail.payloadType;
        if(payloadType === 'multi-select'){
            this.setDefaultBrand(payload.value,index);
            this.clearBrandMannualName(payload.value,index);
        }
    }
    setDefaultBrand(value,index){
        console.log("123");
        this.columnsArr[index][0].value = value;
        this.columns[0].value = value;
    }
   
    // 失单品牌不等于其他时,失单品牌(手动)清空并且不允许填写,失单品牌等于其他时,失单对手型号不可用  thh 2022-01-13 start
    clearBrandMannualName(value){
    clearBrandMannualName(value,index){
        if (value == '其他') {
            // this.template.querySelector('[data-id="LostProduct"]').setAttribute('disabled', true);
            this.template.querySelector('[data-id="LostProduct"]]').disabled = true;
            this.template.querySelector('[data-id="Lost_By_Company_Mannual"][name='+ index +']').disabled = false;
            // this.columns[1].disable = true;
            this.columnsArr[index][1].disable = true;
            console.log("213");
        } else {
            console.log("5435");
            this.template.querySelector('[data-id="Lost_By_Company_Mannual"]').value = '';
            this.template.querySelector('[data-id="Lost_By_Company_Mannual"][name='+ index +']').value = '';
            // this.template.querySelector('[data-id="Lost_By_Company_Mannual"]').setAttribute('disabled', true);
            this.template.querySelector('[data-id="Lost_By_Company_Mannual"]').disabled = true;
            this.template.querySelector('[data-id="Lost_By_Company_Mannual"][name='+ index +']').disabled = true;
            // this.columns[1].disable = false;
            this.columnsArr[index][1].disable = false;
        }
    }
    cancel() {
        // Navigate to the specified opportunity page using the NavigationMixin
        console.log("321");
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
@@ -298,5 +335,22 @@
    handleStatus1Change(){
        
    }
    handleBrandChange(value){
    }
    handleButtonClick() {
        var table = this.template.querySelector("c-lex-dynamic-table");
        console.log("end");
        if(table!=undefined)
        {
            var records = table.retrieveRecords();
            for(i=0;i < records.length;i++){
                this.LostReport.LostBrands[0].LostProducts
            }
        }
      }
    
}