buli
2023-05-26 0e9334dcee28f030b55d8b76749c666a88fd383d
force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js
@@ -4,6 +4,9 @@
import saveconfirm from '@salesforce/apex/LexRemoveBoxController.removeBoxConfirm';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
// import { NavigationMixin } from 'lightning/navigation';
//table css
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
const columns = [
  {
@@ -11,28 +14,30 @@
    fieldName: 'Name__c',
    wrapText:true,
    hideDefaultActions: true,
    // initialWidth: 350,
    initialWidth: 400,
  },
  {
    label: '规格',
    fieldName: 'ProductPacking_list_manual__c',
    hideDefaultActions: true,
    // initialWidth: 250,
    initialWidth: 50,
    cellAttributes: { alignment: "right" },
  },
  {
    label: 'CFDA状态',
    fieldName: 'CFDA_Status__c',
    hideDefaultActions: true,
    // initialWidth: 250,
    initialWidth: 200,
  },
  {
    label: '注册证编码号',
    fieldName: 'Report_Product_Approbation__c',
    hideDefaultActions: true,
    initialWidth: 250,
    initialWidth: 200,
  },
  {
    label: '注册证效期',
@@ -60,6 +65,7 @@
    label: 'BarCode',
    fieldName: 'Bar_Code__c',
    hideDefaultActions: true,
   
  }
  ,
@@ -92,7 +98,18 @@
  //加载框
  @track showSpinner = false
  renderedCallback() {
    if (!this.stylesLoaded) {
        Promise.all([loadStyle(this, WrappedHeaderTable)])
            .then(() => {
                console.log("Custom styles loaded");
                this.stylesLoaded = true;
            })
            .catch((error) => {
                console.error("Error loading custom styles");
            });
    }
}
  //初始化
  connectedCallback() {
@@ -110,13 +127,7 @@
        // this.data = JSON.parse(result.entity.codPageRecords);
        // this.showTable = true;
      } else {
        console.log('result.msg = ' + result.msg);
        const evt = new ShowToastEvent({
          title: '录入失败',
          message: result.msg,
          variant: 'error'
        });
        this.dispatchEvent(evt);
        this.showMyToast('初始化失败',result.msg,'error');
      }
    }).catch((error) => {
      console.log('error = ' + JSON.stringify(error));
@@ -155,12 +166,7 @@
        this.showTable = true;
      } else{
        console.log('result.msg = ' + result.msg);
        const evt = new ShowToastEvent({
          title: '获取失败',
          message: result.msg,
          variant: 'error'
        });
        this.dispatchEvent(evt);
        this.showMyToast('获取失败',result.msg,'error');
      }
    }).catch((error) => {
      console.log('error = ' + JSON.stringify(error));
@@ -200,23 +206,12 @@
         this.saveFLGbln = result.entity.saveFLGbln;
        //  this.showSpinner = false;
         if(this.saveFLGbln){
          const evt = new ShowToastEvent({
            title: '成功',
            message: result.msg,
            variant: 'Success'
          });
          this.dispatchEvent(evt);
          this.showMyToast(result.msg,'','success');
          this.showSpinner = false;
         }
      } else {
        console.log('result.msg = ' + result.msg);
        const evt = new ShowToastEvent({
          title: '失败',
          message: result.msg,
          variant: 'error'
        });
        this.dispatchEvent(evt);
        this.showMyToast('拆盒失败',result.msg,'error');
        this.showSpinner = false;
      }
    })
@@ -226,6 +221,22 @@
  }
  showMyToast(title, message, variant) {
    console.log('show custom message');
    var iconName = '';
    var content = '';
    if(variant == 'success'){
       iconName = 'utility:check';
    }else{
       iconName = 'utility:error';
    }
    if(message != ''){
       content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>';
    }else{
       content = '<h2><strong>'+title+'<strong/></h2>';
    }
    this.template.querySelector('c-common-toast').showToast(variant,content,iconName,10000);
   }