buli
2023-07-11 80a3f59e2d3df07805bc67e329300b8de90a5b3a
force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js
@@ -5,52 +5,51 @@
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
// import { NavigationMixin } from 'lightning/navigation';
//table css 
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
import { loadStyle } from 'lightning/platformResourceLoader';
import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
const columns = [
  {
    label: '消耗品名称',
    fieldName: 'Name__c',
    wrapText:true,
    hideDefaultActions: true,
    initialWidth: 400,
        hideDefaultActions: true
        // initialWidth: 400,
  },
  {
    label: '规格',
    fieldName: 'ProductPacking_list_manual__c',
    hideDefaultActions: true,
    initialWidth: 50,
    cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
  },
  {
    label: 'CFDA状态',
    fieldName: 'CFDA_Status__c',
    hideDefaultActions: true,
    initialWidth: 200,
        initialWidth: 100,
        wrapText: true
  },
  {
    label: '注册证编码号',
    fieldName: 'Report_Product_Approbation__c',
    hideDefaultActions: true,
    initialWidth: 200,
        wrapText: true
  },
  {
    label: '注册证效期',
    fieldName: 'Report_Product_Expiration__c',
    hideDefaultActions: true,
    // initialWidth: 250,
        initialWidth: 110,
        wrapText: true
  },
  {
    label: 'BarCode',
    fieldName: 'Bar_Code__c',
    hideDefaultActions: true,
    wrapText:true,
    initialWidth:400,
        wrapText: true
        // initialWidth:600,
  }
];
@@ -59,25 +58,22 @@
    label: '消耗品名称',
    fieldName: 'Name__c',
    hideDefaultActions: true,
        wrapText: true
  },
  {
    label: 'BarCode',
    fieldName: 'Bar_Code__c',
    hideDefaultActions: true,
  }
  ,
        wrapText: true
        // initialWidth:600,
    },
  {
    label: '错误原因',
    fieldName: 'ErrorReason',
    hideDefaultActions: true,
        wrapText: true
  }
];
export default class LexRemoveBox extends LightningElement {
  columns = columns;
@@ -87,26 +83,26 @@
  @track errorDetail = [];
  // 显示
  @track showTable = false
  @track accountName
  @track userWorkLocation
  @track agencyProType
  @track barcode = ''
  @track saveFLGbln = false
    @track showTable = false;
    @track accountName;
    @track userWorkLocation;
    @track agencyProType;
    @track barcode = '';
    @track saveFLGbln = false;
  @track dataSize = 0;
  //加载框
  @track showSpinner = false
    @track showSpinner = false;
  renderedCallback() {
    if (!this.stylesLoaded) {
        Promise.all([loadStyle(this, WrappedHeaderTable)])
            .then(() => {
                console.log("Custom styles loaded");
                    console.log('Custom styles loaded');
                this.stylesLoaded = true;
            })
            .catch((error) => {
                console.error("Error loading custom styles");
                    console.error('Error loading custom styles');
            });
    }
}
@@ -116,10 +112,11 @@
    console.log('初始化');
    this.showTable = false;
    init().then((result) => {
        init()
            .then((result) => {
      result = JSON.parse(JSON.stringify(result));
      console.log('result =' + JSON.stringify(result));
      if (result.status = 'Success') {
                if ((result.status = 'Success')) {
        console.log('result');
        this.agencyProType = result.entity.agencyProType;
        this.userWorkLocation = result.entity.userWorkLocation;
@@ -129,7 +126,8 @@
      } else {
        this.showMyToast('初始化失败',result.msg,'error');
      }
    }).catch((error) => {
            })
            .catch((error) => {
      console.log('error = ' + JSON.stringify(error));
    });
  }
@@ -140,27 +138,40 @@
      userWorkLocation: this.userWorkLocation,
      agencyProType: this.agencyProType,
      barcode: this.barcode
    }).then((result) => {
        })
            .then((result) => {
      result = JSON.parse(JSON.stringify(result));
      console.log('result =' + JSON.stringify(result));
      if (result.status == 'Success') {
        console.log('成功');
        this.data = JSON.parse(result.entity.ConsumableorderdetailsRecordsdummy);
        this.errorDetail = JSON.parse(result.entity.ConsumableorderdetailsRecordserror);
                    this.data = JSON.parse(
                        result.entity.ConsumableorderdetailsRecordsdummy
                    );
                    this.errorDetail = JSON.parse(
                        result.entity.ConsumableorderdetailsRecordserror
                    );
        this.dataSize = result.entity.dataSize;
        console.log('this.dataSize'+this.dataSize);
        for (let i in this.data) {
          this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
          this.data[i]['ProductPacking_list_manual__c'] = this.data[i].esd.ProductPacking_list_manual__c;
          this.data[i]['CFDA_Status__c'] = this.data[i].esd.CFDA_Status__c;
          this.data[i]['Report_Product_Approbation__c'] = this.data[i].esd.Report_Product_Approbation__c;
          this.data[i]['Report_Product_Expiration__c'] = this.data[i].esd.Report_Product_Expiration__c;
          this.data[i]['Bar_Code__c'] = this.data[i].esd.Bar_Code__c;
                        this.data[i]['ProductPacking_list_manual__c'] =
                            this.data[i].esd.ProductPacking_list_manual__c;
                        this.data[i]['CFDA_Status__c'] =
                            this.data[i].esd.CFDA_Status__c;
                        this.data[i]['Report_Product_Approbation__c'] =
                            this.data[i].esd.Report_Product_Approbation__c;
                        this.data[i]['Report_Product_Expiration__c'] =
                            this.data[i].esd.Report_Product_Expiration__c;
                        this.data[i]['Bar_Code__c'] =
                            this.data[i].esd.Bar_Code__c;
        }
        for (let i in this.errorDetail) {
          this.errorDetail[i]['Name__c'] = this.errorDetail[i].Prod.Name__c;
          this.errorDetail[i]['Bar_Code__c'] = this.errorDetail[i].esd.Bar_Code__c;
          this.errorDetail[i]['ErrorReason'] = this.errorDetail[i].ErrorReason;
                        this.errorDetail[i]['Name__c'] =
                            this.errorDetail[i].Prod.Name__c;
                        this.errorDetail[i]['Bar_Code__c'] =
                            this.errorDetail[i].esd.Bar_Code__c;
                        this.errorDetail[i]['ErrorReason'] =
                            this.errorDetail[i].ErrorReason;
        }
        this.showTables = true;
        this.showTable = true;
@@ -168,10 +179,10 @@
        console.log('result.msg = ' + result.msg);
        this.showMyToast('获取失败',result.msg,'error');
      }
    }).catch((error) => {
            })
            .catch((error) => {
      console.log('error = ' + JSON.stringify(error));
    });
  }
  //获取当前输入值
  handleChange(event) {
@@ -182,7 +193,7 @@
  }
  saveConfirm() {
    console.log('进入确认');
    let msg = "确认拆盒吗";
        let msg = '确认拆盒吗';
    if (this.dataSize>0) {
        if (confirm(msg) == true) {
            this.removeBox();
@@ -190,7 +201,6 @@
    } else {
        this.removeBox();
    }
  }
  removeBox(){
    this.showSpinner = true;
@@ -199,7 +209,8 @@
      accountName: this.accountName,
      userWorkLocation: this.userWorkLocation,
      agencyProType: this.agencyProType
    }).then((result) => {
        })
            .then((result) => {
      result = JSON.parse(JSON.stringify(result));
      console.log('result保存 = ' + JSON.stringify(result));
      if (result.status == 'Success') {
@@ -218,8 +229,6 @@
      .catch((error) => {
        console.log('error = ' + JSON.stringify(error));
      });
  }
  showMyToast(title, message, variant) {
    console.log('show custom message');
@@ -231,14 +240,17 @@
       iconName = 'utility:error';
    }
    if(message != ''){
       content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>';
            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);
        this.template
            .querySelector('c-common-toast')
            .showToast(variant, content, iconName, 10000);
   }
}