buli
2023-04-25 5ae6900f38713063c21c8985aafc8abbe8a77256
force-app/main/default/lwc/lexOverdueStock/lexOverdueStock.js
@@ -5,54 +5,49 @@
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
//过期库存一览
const columns = [
    {
      label: '是否盘点',
        label: '是否销存',
      fieldName: 'iscount',
      type: 'checkbox',
      hideDefaultActions: true,
      initialWidth: 250,
        hideDefaultActions: true
        // initialWidth: 250,
    },
    {
      label: '消耗品名称',
      fieldName: 'prodname',
      type: 'prodname',
      initialWidth: 350,
        // initialWidth: 350,
      hideDefaultActions: true
    },
    {
      label: '单位',
      fieldName: 'boxPiece',
      hideDefaultActions: true,
      initialWidth: 250,
        initialWidth: 250
    },
    {
      label: '过期数量',
      fieldName: 'overlimitCount',
      hideDefaultActions: true,
      initialWidth: 250,
        initialWidth: 250
    },
    {
      label: '销存数量',
      fieldName: 'pandian',
      hideDefaultActions: true,
      initialWidth: 250,
        initialWidth: 250
    //   cellAttributes: { alignment: 'center' }
    }
  ];
  //过期库存一览
//销存明细
const column = [
    {
      label: '消耗品名称',
      fieldName: 'Name__c',
      type: 'Name',
      initialWidth : 300,
        // initialWidth : 300,
      hideDefaultActions: true,
      cellAttributes: { alignment: 'left' }
    },
@@ -73,8 +68,7 @@
      fieldName: 'Sterilization_limit__c',
      hideDefaultActions: true,
      initialWidth : 250
    }
    ,
    },
    {
      label: '销存原因',
      fieldName: 'diffReason',
@@ -83,43 +77,42 @@
    }
  ];
export default class LexOverdueStock extends NavigationMixin (LightningElement ){
    columns = columns
    column = column
    columns = columns;
    column = column;
    @track data =[];
    @track overduePageRecords = [];
    @track iSinventory = false
    @track iSinventory = false;
    //加载框
    // @track casesSpinner = true;
    @track showSpinner =true;
    //显示口
    @track showbutton = false
    @track showbutton = false;
    @track showTable = false;
    @track showTables = false;
    //销存一览数据
    @track accountName
    @track agencyProType
    @track userWorkLocation
    @track barcode = ''
    @track orderDetZaiku
    @track accountName;
    @track agencyProType;
    @track userWorkLocation;
    @track barcode = '';
    @track orderDetZaiku;
    @track selectedRows = [];
    @track codPageRecordsLWC
    @track Id
    @track codPageRecordsLWC;
    @track Id;
    @track overdueList = [];
    //初始化
    connectedCallback() {
        console.log('初始化');
        this.showSpinner = true;
        init().then((result) => {
        init()
            .then((result) => {
            result = JSON.parse(JSON.stringify(result));
            console.log('result ='+JSON.stringify(result));
            console.log('result 1='+result.entity.codPageRecords);
            if(result.status = 'Success'){
                if ((result.status = 'Success')) {
                this.data = JSON.parse(result.entity.codPageRecords);
                this.codPageRecordsLWC = result.entity.codPageRecords;
                console.log('this.data'+this.data);
@@ -138,7 +131,8 @@
                });
                this.dispatchEvent(evt);
              }
        }).catch((error) => {
            })
            .catch((error) => {
            console.log('error = ' + JSON.stringify(error));
          });
    }
@@ -154,18 +148,33 @@
            userWorkLocationLWC:this.userWorkLocation,
            barcodeLWC:this.barcode,
            codPageRecordsLWC:this.codPageRecordsLWC
        }).then((result)=>{
        })
            .then((result) => {
            result = JSON.parse(JSON.stringify(result));
            if (result.status == 'Success') {
            this.overduePageRecords = JSON.parse(result.entity.overduePageRecords);
                    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(JSON.stringify( this.overduePageRecords ));
            for(let i in this.overduePageRecords){
                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;
                        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));
@@ -176,7 +185,7 @@
            }
          }
          this.showSpinner = false;
          this.showTables = true;
                    // this.showTables = true;
          this.showTable = true;
        }else{
          console.log('result.msg = ' + result.msg);
@@ -186,13 +195,12 @@
            variant: 'error'
          });
          this.dispatchEvent(evt);
                    this.showSpinner = false;
        }
        }).catch((error) => {
            })
            .catch((error) => {
            console.log('error = ' + JSON.stringify(error));
          });
    }
     //获取当前输入值
  handleChange(event) {
@@ -222,14 +230,18 @@
  
  saveConfirm() {
    console.log('进入销存确认');
    var el = this.template.querySelector('c-lex-custom-lightning-datatable');
        var el = this.template.querySelector(
            'c-lex-custom-lightning-datatable'
        );
    var selected = el.getSelectedRows();
    this.selectedData = selected;
    console.log('选中数据' + JSON.stringify(this.selectedData));
    save({
      iSinventory: this.iSinventory,
      saveCodPageRecords:  JSON.stringify(this.selectedData)
    }).then((result) => {
            saveCodPageRecords: JSON.stringify(this.selectedData),
            saveoverdueList: JSON.stringify(this.overdueList)
        })
            .then((result) => {
        result = JSON.parse(JSON.stringify(result));
        console.log('result保存 = ' + JSON.stringify(result));
        if (result.status == 'Success') {
@@ -255,11 +267,4 @@
        console.log('error = ' + JSON.stringify(error));
      });
  }
}