binxie
2023-06-16 da42e2995c00293af89c71fe5ba6e16cbb77e1b3
force-app/main/default/lwc/lexOverdueStock/lexOverdueStock.js
@@ -60,6 +60,7 @@
      label: '消耗品名称',
      fieldName: 'Name__c',
      type: 'Name',
    wrapText: true,
      // initialWidth : 300,
      hideDefaultActions: true,
      cellAttributes: { alignment: 'left' }
@@ -75,7 +76,7 @@
      fieldName: 'Bar_Code__c',
      wrapText: true,
      hideDefaultActions: true,
      initialWidth : 500,
    // initialWidth: 500,
    },
    {
      label: '使用期限',
@@ -88,6 +89,7 @@
      label: '销存原因',
      fieldName: 'diffReason',
      hideDefaultActions: true,
    wrapText: true,
      initialWidth: 160
    }
  ];
@@ -150,6 +152,9 @@
                this.accountName = result.entity.accountName;
                this.agencyProType = result.entity.agencyProType;
                this.userWorkLocation = result.entity.userWorkLocation;
        for (var i in this.data) {
          this.data[i]["key"] = this.data[i]["prodid"] + this.data[i]["boxPiece"];
        }
                this.showTable = true;
                // this.casesSpinner = false;
                this.showSpinner = false;
@@ -168,17 +173,34 @@
        console.log('code'+this.barcode);
        console.log(' this.accountName'+ this.accountName);
        console.log(' this.barcode'+ this.barcode);
        if(this.barcode == ''||this.barcode==null){
          this.showMyToast('获取失败','请输入BarCode号','error');
          this.showSpinner = false;
    const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
    console.log('selectedRows========> ' + JSON.stringify(selectedRows));
    for (var i in this.data) {
      this.data[i]["check"] = false;
        }
    for (var i in this.data) {
      for (var j in selectedRows) {
        if (this.data[i].prodid + this.data[i]["boxPiece"] == selectedRows[j].prodid + selectedRows[j]["boxPiece"]) {
          this.data[i]["check"] = true;
        }
        // console.log('this.data[i].ProdId+this.data[i]["boxPiece"]'+this.data[i].ProdId+this.data[i]["boxPiece"]);
        console.log('selectedRows[j].prodid+this.data[i]["boxPiece"]' + selectedRows[j].prodid + selectedRows[j]["boxPiece"]);
      }
      console.log('data===>'+  JSON.stringify(this.data));
    }
    // this.selectedRows = [];
    // if(this.barcode == ''||this.barcode==null){
    //   this.showMyToast('获取失败','请输入BarCode号','error');
    //   this.showSpinner = false;
    // }
        barcodeEntry({
            accountNameLWC: this.accountName,
            agencyProTypeLWC: this.agencyProType,
            userWorkLocationLWC:this.userWorkLocation,
            barcodeLWC:this.barcode,
            codPageRecordsLWC:this.codPageRecordsLWC
      codPageRecordsLWC:  JSON.stringify(this.data)
        }).then((result)=>{
            result = JSON.parse(JSON.stringify(result));
            if (result.status == 'Success') {
@@ -199,17 +221,56 @@
           this.data = JSON.parse(result.entity.codPageRecords);
           console.log(' this.data'+ JSON.stringify(this.data));
           for (var i in this.data) {
          this.data[i]["key"] = this.data[i]["prodid"] + this.data[i]["boxPiece"];
        }
        for (var i in this.data) {
            if (this.data[i]['check']) {
              this.selectedRows.push(this.data[i].prodid);
              console.log('selectedRows:' + this.selectedRows);
            this.selectedRows.push(this.data[i].prodid + this.data[i]["boxPiece"]);
            console.log("selectedRows:" + this.selectedRows);
            }
          }
          this.showSpinner = false;
          // this.showTables = true;
          this.showTable = true;
        }else{
          this.showMyToast('获取失败',result.msg,'error');
        if (result.status == 'Success1') {
          this.overduePageRecords = JSON.parse(result.entity.overduePageRecords);
          this.overdueList = result.entity.overdueList;
          this.iSinventory = result.entity.iSinventory;
          console.log('result录入' + JSON.stringify(result));
          console.log('overdueList==>' + JSON.stringify(this.overdueList));
          for (let i in this.overduePageRecords) {
            if (this.overduePageRecords[i].Prod != null) {
              this.overduePageRecords[i]['Name__c'] = this.overduePageRecords[i].Prod.Name__c;
            }
            this.overduePageRecords[i]['Bar_Code__c'] = this.overduePageRecords[i].orderdetails2.Bar_Code__c;
            this.overduePageRecords[i]['Box_Piece__c'] = this.overduePageRecords[i].orderdetails2.Box_Piece__c;
            this.overduePageRecords[i]['Sterilization_limit__c'] = this.overduePageRecords[i].orderdetails2.Sterilization_limit__c;
          }
          this.data = JSON.parse(result.entity.codPageRecords);
          console.log(' this.data' + JSON.stringify(this.data));
          for (var i in this.data) {
            this.data[i]["key"] = this.data[i]["prodid"] + this.data[i]["boxPiece"];
          }
          for (var i in this.data) {
            if (this.data[i]['check']) {
              this.selectedRows.push(this.data[i].prodid + this.data[i]["boxPiece"]);
              console.log("selectedRows:" + this.selectedRows);
            }
          }
          this.showSpinner = false;
          // this.showTables = true;
          this.showTable = true;
        }else {
          console.log('Error:' + result.msg);
          this.showMyToast(result.msg,'','error');
          this.showSpinner = false;
          this.showTable = true;
        }
        // this.showMyToast('获取失败', result.msg, 'error');
        // this.showSpinner = false;
        }
        }).catch((error) => {
@@ -225,34 +286,42 @@
    console.log('this.barcode'+this.barcode);
  }
  getSelectedRows(event) {
    console.log('打勾');
    const selectedRows = event.detail.selectedRows;
    console.log('this.selectedRows = ' + this.selectedRows);
    for (var i in this.data) {
      this.data[i]['check'] = false;
         let selectedRowsEvent = event.detail.selectedRows;
          this.selectedRows = [];
          for (var i in selectedRowsEvent) {
              this.selectedRows.push(selectedRowsEvent[i].prodid+this.data[i]["boxPiece"]);
    }
    for (var i in this.data) {
      for (var j in selectedRows) {
        console.log('this.selectedRows111 = ' + selectedRows[j].prodid);
        console.log('this.selectedRows1112 = ' + this.data[i].prodid );
        if (this.data[i].prodid == selectedRows[j].prodid) {
          this.data[i]['check'] = true;
        }
      }
    }
        console.log('this.selectedRows==>'+this.selectedRows);
  }
  //保存
  saveConfirm() {
    console.log('进入销存确认');
    this.showSpinner = true;
    var el = this.template.querySelector('c-lex-custom-lightning-datatable');
    var selected = el.getSelectedRows();
    this.selectedData = selected;
    console.log('选中数据' + JSON.stringify(this.selectedData));
    console.log('this.overdueList'+this.overdueList);
       //查询有哪些选择了的然后check
      const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
      console.log('selectedRows========> ' + JSON.stringify(selectedRows));
      for (var i in this.data) {
         this.data[i]["check"] = false;
      }
      for (var i in this.data) {
         for (var j in selectedRows) {
            if (this.data[i].prodid+this.data[i]["boxPiece"] == selectedRows[j].prodid+ selectedRows[j]["boxPiece"]) {
               this.data[i]["check"] = true;
            }
            // console.log('this.data[i].ProdId+this.data[i]["boxPiece"]'+this.data[i].ProdId+this.data[i]["boxPiece"]);
            console.log('selectedRows[j].prodid+this.data[i]["boxPiece"]'+selectedRows[j].prodid+selectedRows[j]["boxPiece"]);
         }
      }
    // var el = this.template.querySelector('c-lex-custom-lightning-datatable');
    // var selected = el.getSelectedRows();
    // this.selectedData = selected;
    // console.log('选中数据' + JSON.stringify(this.selectedData));
    // console.log('this.overdueList' + this.overdueList);
    save({
      iSinventory: this.iSinventory,
      saveCodPageRecords:  JSON.stringify(this.selectedData),
      saveCodPageRecords: JSON.stringify(this.data),
      // saveoverdueList:JSON.stringify(this.overdueList)
      saveoverdueList:this.overdueList
    }).then((result) => {