buli
2023-07-11 80a3f59e2d3df07805bc67e329300b8de90a5b3a
force-app/main/default/lwc/lexInventory/lexInventory.js
@@ -1,220 +1,193 @@
import { LightningElement, wire, api, track } from "lwc";
import oninit from "@salesforce/apex/LexInventoryController.init";
import { LightningElement, wire, api, track } from 'lwc';
import oninit from '@salesforce/apex/LexInventoryController.init';
// import sheetjs from '@salesforce/resourceUrl/sheetjs';
import barcodeEntry from "@salesforce/apex/LexInventoryController.searchConsumableorderdetails";
import save from "@salesforce/apex/LexInventoryController.save";
import datainit from "@salesforce/apex/LexInventoryListController.init";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { NavigationMixin } from "lightning/navigation";
import barcodeEntry from '@salesforce/apex/LexInventoryController.searchConsumableorderdetails';
import save from '@salesforce/apex/LexInventoryController.save';
import datainit from '@salesforce/apex/LexInventoryListController.init';
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: "iscount",
        label: '是否盘点',
        fieldName: 'iscount',
      hideDefaultActions: true,
      initialWidth: 80,
        initialWidth: 80
   },
   {
      label: "消耗品名称",
      fieldName: "Name__c",
        label: '消耗品名称',
        fieldName: 'Name__c',
      hideDefaultActions: true,
      // initialWidth: 400,
      wrapText:true
   },
   {
      label: "规格",
        label: '规格',
      initialWidth: 50,
      fieldName: "Packing_list_manual__c",
      cellAttributes: { alignment: "right" },
      hideDefaultActions: true,
        fieldName: 'Packing_list_manual__c',
        cellAttributes: { alignment: 'right' },
        hideDefaultActions: true
   },
   {
      label: "单位",
      fieldName: "boxPiece",
        label: '单位',
        fieldName: 'boxPiece',
      initialWidth: 50,
      hideDefaultActions: true,
        hideDefaultActions: true
   },
   {
      label: "有效期内库存",
      fieldName: "limitCount",
        label: '有效期内库存',
        fieldName: 'limitCount',
      initialWidth: 120,
      hideDefaultActions: true,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "过期库存",
        label: '过期库存',
      initialWidth: 100,
      fieldName: "overlimitCount",
        fieldName: 'overlimitCount',
      hideDefaultActions: true,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "盘点",
        label: '盘点',
      initialWidth: 50,
      fieldName: "Pandian",
        fieldName: 'Pandian',
      hideDefaultActions: true,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "丢失",
        label: '丢失',
      initialWidth: 50,
      fieldName: "Diff",
        fieldName: 'Diff',
      hideDefaultActions: true,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "寻回",
        label: '寻回',
      initialWidth: 50,
      fieldName: "refind",
        fieldName: 'refind',
      hideDefaultActions: true,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "差异原因",
        label: '差异原因',
      // fieldName: "DiffReason",
      initialWidth: 200,
      hideDefaultActions: true,
      type: "customDiffReason",
        type: 'customDiffReason',
      typeAttributes: {
         DiffReason: { fieldName: "DiffReason" },
         ProdId: { fieldName: "ProdId" },
         boxPiece: { fieldName: "boxPiece" }
      },
   },
            DiffReason: { fieldName: 'DiffReason' },
            ProdId: { fieldName: 'ProdId' },
            boxPiece: { fieldName: 'boxPiece' }
        }
    }
];
//调整明细
const column = [
   {
      label: "消耗品名称",
      fieldName: "Name__c",
        label: '消耗品名称',
        fieldName: 'Name__c',
      wrapText: true,
      hideDefaultActions: true,
        hideDefaultActions: true
        // initialWidth: 550
   },
   {
      label: "单位",
      fieldName: "Box_Piece__c",
        label: '单位',
        fieldName: 'Box_Piece__c',
      hideDefaultActions: true,
      initialWidth: 50,
        initialWidth: 50
   },
   {
      label: "BarCode",
      fieldName: "Bar_Code__c",
        label: 'BarCode',
        fieldName: 'Bar_Code__c',
      hideDefaultActions: true,
      wrapText: true,
       initialWidth: 500,
        wrapText: true
        // initialWidth: 300,
   },
   {
      label: "调整原因",
      fieldName: "DiffReason",
        label: '调整原因',
        fieldName: 'DiffReason',
      hideDefaultActions: true,
      wrapText: true,
   },
        wrapText: true
        // initialWidth:
    }
];
//盘点明细
const dcolumns = [
   {
      label: "消耗品名称",
      fieldName: "Name__c",
        label: '消耗品名称',
        fieldName: 'Name__c',
      hideDefaultActions: true,
      // initialWidth: 250,
      wrapText: true,
        wrapText: true
   },
   {
      label: "库存",
      fieldName: "Count_Sum__c",
        label: '库存',
        fieldName: 'Count_Sum__c',
      hideDefaultActions: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "盘点",
      fieldName: "inventory_sum__c",
        label: '盘点',
        fieldName: 'inventory_sum__c',
      hideDefaultActions: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "丢失",
      fieldName: "Diff__c",
        label: '丢失',
        fieldName: 'Diff__c',
      hideDefaultActions: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "寻回",
      fieldName: "Product_Refind__c",
        label: '寻回',
        fieldName: 'Product_Refind__c',
      hideDefaultActions: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" },
        cellAttributes: { alignment: 'right' }
   },
   {
      label: "差异原因",
      fieldName: "Lose_reason__c",
      hideDefaultActions: true,
   },
        label: '差异原因',
        fieldName: 'Lose_reason__c',
        hideDefaultActions: true
    }
];
//在库调整明细
const stockadjustcolumns = [
   {
      label: "消耗品名称",
      fieldName: "Name__c",
        label: '消耗品名称',
        fieldName: 'Name__c',
      wrapText: true,
      hideDefaultActions: true,
        hideDefaultActions: true
   },
   {
      label: "产品型号",
      fieldName: "Asset_Model_No__c",
      hideDefaultActions: true,
        label: '产品型号',
        fieldName: 'Asset_Model_No__c',
        hideDefaultActions: true
   },
   {
      label: "差异原因",
      fieldName: "Lose_reason__c",
        label: '差异原因',
        fieldName: 'Lose_reason__c',
      hideDefaultActions: true,
      initialWidth: 150,
        initialWidth: 150
   },
   {
      label: "是否丢失",
      type: "boolean",
      fieldName: "Lose_Flag__c",
      hideDefaultActions: true,
   },
        label: '是否丢失',
        type: 'boolean',
        fieldName: 'Lose_Flag__c',
        hideDefaultActions: true
    }
];
export default class LexInventory extends NavigationMixin(LightningElement) {
@@ -228,24 +201,24 @@
   @track accountName;
   @track agencyProType;
   @track userWorkLocation;
   @track accountid
   @track pandiandetailsMap
   @track reSet
   @track reSet1
    @track accountid;
    @track pandiandetailsMap;
    @track reSet;
    @track reSet1;
   @track showTable = false;
   @track showbutton = false;
   @track barcode = "";
    @track barcode = '';
   @track ConsumableorderdetailsRecordsview = [];
   @track consumableorderdetailsRecords = [];
   @track showcount = true;
   @track iSinventory = false
    @track iSinventory = false;
   @track numberDetail;
   @track hidecheckbox = true;
   //分页start
   @track sortBy = "";
   @track sortDirection = "asc";
    @track sortBy = '';
    @track sortDirection = 'asc';
   @track pageSize = 10;
   error;
   records;
@@ -261,7 +234,6 @@
   @track recordEnd = 0;
   //end
   //加载框
   // @track casesSpinner = true;
   @track showSpinner = true;
@@ -271,10 +243,10 @@
   //inventoryList
   @track isSummonsFlag;
   //展开栏
   activeSections = ["dataExpand"];
   columnHeader = ["消耗品名称", "单位", "barCode", "调整原因"];
    activeSections = ['dataExpand'];
    columnHeader = ['消耗品名称', '单位', 'BarCode', '调整原因'];
   //确认一览
   @track eSetId = "";
    @track eSetId = '';
   @track EditAble = false;
   @track selectedData;
   @track conId;
@@ -282,14 +254,13 @@
   @track adjustdata = [];
   @track detalipan = [];
   //导出csv 
   xlsDataHeader = ['消耗品名称', '单位', 'barCode', '调整原因'];
   //获取链接参数
   getQueryString(name) {
      console.log("getQueryString name " + name);
      let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        console.log('getQueryString name ' + name);
        let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
      let r = window.location.search.substr(1).match(reg);
      if (r != null) {
         return decodeURIComponent(r[2]);
@@ -300,24 +271,23 @@
        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');
                });
        }
    }
   connectedCallback() {
      console.log("===>初始化");
        console.log('===>初始化');
      //获取ESetid
      this.eSetId = this.getQueryString("eSetId");
      this.eSetId = this.eSetId == null ? "" : this.eSetId;
      console.log(" this.eSetId" + this.eSetId);
      if (this.eSetId == "") {
        this.eSetId = this.getQueryString('eSetId');
        this.eSetId = this.eSetId == null ? '' : this.eSetId;
        console.log(' this.eSetId' + this.eSetId);
        if (this.eSetId == '') {
         this.EditAble = false;
         this.init();
      } else {
@@ -325,29 +295,41 @@
         this.showcount = false;
         this.EditAble = true;
      }
   }
   init() {
      this.showSpinner = true;
      oninit()
         .then((result) => {
            console.log("1112" + JSON.stringify(result));
                console.log('1112' + JSON.stringify(result));
            result = JSON.parse(JSON.stringify(result));
            console.log("result.status = " + result.status);
            console.log("ConsumableorderdetailsRecordsview= " + result.entity.ConsumableorderdetailsRecordsview);
            this.ConsumableorderdetailsRecordsview = JSON.parse(result.entity.ConsumableorderdetailsRecordsview);
            this.consumableorderdetailsRecords = result.entity.consumableorderdetailsRecords;
            console.log("consumableorderdetailsRecords= " + result.entity.consumableorderdetailsRecords);
            console.log("传参类型", typeof this.consumableorderdetailsRecords);
            if (result.status == "Success") {
                console.log('result.status = ' + result.status);
                console.log(
                    'ConsumableorderdetailsRecordsview= ' +
                        result.entity.ConsumableorderdetailsRecordsview
                );
                this.ConsumableorderdetailsRecordsview = JSON.parse(
                    result.entity.ConsumableorderdetailsRecordsview
                );
                this.consumableorderdetailsRecords =
                    result.entity.consumableorderdetailsRecords;
                console.log(
                    'consumableorderdetailsRecords= ' +
                        result.entity.consumableorderdetailsRecords
                );
                console.log(
                    '传参类型',
                    typeof this.consumableorderdetailsRecords
                );
                if (result.status == 'Success') {
               this.data = [];
               this.data = this.ConsumableorderdetailsRecordsview[0];
               console.log("this.data ==>" + JSON.stringify(this.data));
                    console.log('this.data ==>' + JSON.stringify(this.data));
               for (let i in this.data) {
                  this.data[i]["key"] = this.data[i]["ProdId"] + this.data[i]["boxPiece"];
                  this.data[i]["Name__c"] = this.data[i].Prod.Name__c;
                  this.data[i]["Packing_list_manual__c"] = this.data[i].Prod.Packing_list_manual__c;
                        this.data[i]['key'] =
                            this.data[i]['ProdId'] + this.data[i]['boxPiece'];
                        this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
                        this.data[i]['Packing_list_manual__c'] =
                            this.data[i].Prod.Packing_list_manual__c;
               }
               this.accountName = result.entity.accountName;
               this.agencyProType = result.entity.agencyProType;
@@ -361,11 +343,11 @@
            }
         })
         .catch((error) => {
            console.log("error = " + JSON.stringify(error));
                console.log('error = ' + JSON.stringify(error));
            this.showSpinner = false;
         });
      //默认展开栏
      this.activeSections = ["dataExpand"];
        this.activeSections = ['dataExpand'];
      this.showTable = false;
      this.showbutton = false;
   }
@@ -378,19 +360,27 @@
      this.showSpinner = true;
      
      //查询有哪些选择了的然后check
      const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        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;
            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;
                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(
                    'selectedRows[j].ProdId+this.data[i]["boxPiece"]' +
                        selectedRows[j].ProdId +
                        selectedRows[j]['boxPiece']
                );
         }
      }
      // if(this.barcode == ''||this.barcode == null){
@@ -410,95 +400,151 @@
         pageTokenLWC: this.currentPageToken,
         sortFieldLWC: this.sortBy,
         sortOrderLWC: this.sortDirection
      })
         .then((result) => {
            result = JSON.parse(JSON.stringify(result));
            console.log("result ===>" + JSON.stringify(result));
            if (result.status == "Success1") {
                console.log('result ===>' + JSON.stringify(result));
                if (result.status == 'Success1') {
                  //分页start
                  this.nextPageToken = result.entity.paginatedAccounts.nextPageToken;
                  this.totalRecords = result.entity.paginatedAccounts.totalRecords;
                  this.recordStart = result.entity.paginatedAccounts.recordStart;
                    this.nextPageToken =
                        result.entity.paginatedAccounts.nextPageToken;
                    this.totalRecords =
                        result.entity.paginatedAccounts.totalRecords;
                    this.recordStart =
                        result.entity.paginatedAccounts.recordStart;
                  this.recordEnd = result.entity.paginatedAccounts.recordEnd;
                  this.totalPages = Math.ceil(result.entity.paginatedAccounts.totalRecords / this.pageSize);
                    this.totalPages = Math.ceil(
                        result.entity.paginatedAccounts.totalRecords /
                            this.pageSize
                    );
                  console.log('this.totalPages = ' + this.totalPages);
                  this.paginationVisibility = this.totalPages > 1 ? true : false;
                    this.paginationVisibility =
                        this.totalPages > 1 ? true : false;
                  console.log('this.sortDirection = ' + this.sortDirection);
                  //分页end
                  this.codPageRecords = JSON.parse(result.entity.codPageRecords);
                    this.codPageRecords = JSON.parse(
                        result.entity.codPageRecords
                    );
                  for (var i in this.codPageRecords) {
                     this.codPageRecords[i]["Name__c"] = this.codPageRecords[i].Prod.Name__c;
                     this.codPageRecords[i]["Box_Piece__c"] = this.codPageRecords[i].orderdetails2.Box_Piece__c;
                     this.codPageRecords[i]["Bar_Code__c"] = this.codPageRecords[i].orderdetails2.Bar_Code__c;
                        this.codPageRecords[i]['Name__c'] =
                            this.codPageRecords[i].Prod.Name__c;
                        this.codPageRecords[i]['Box_Piece__c'] =
                            this.codPageRecords[i].orderdetails2.Box_Piece__c;
                        this.codPageRecords[i]['Bar_Code__c'] =
                            this.codPageRecords[i].orderdetails2.Bar_Code__c;
                  }
                  this.pageCodeRecords = result.entity.pageCodeRecords;
                  for (var i in this.pageCodeRecords) {
                     this.pageCodeRecords[i]["Name__c"] = this.pageCodeRecords[i].Prod.Name__c;
                     this.pageCodeRecords[i]["Box_Piece__c"] = this.pageCodeRecords[i].orderdetails2.Box_Piece__c;
                     this.pageCodeRecords[i]["Bar_Code__c"] = this.pageCodeRecords[i].orderdetails2.Bar_Code__c;
                        this.pageCodeRecords[i]['Name__c'] =
                            this.pageCodeRecords[i].Prod.Name__c;
                        this.pageCodeRecords[i]['Box_Piece__c'] =
                            this.pageCodeRecords[i].orderdetails2.Box_Piece__c;
                        this.pageCodeRecords[i]['Bar_Code__c'] =
                            this.pageCodeRecords[i].orderdetails2.Bar_Code__c;
                  }
                  this.data = JSON.parse(result.entity.consumableorderdetailsRecords);
                    this.data = JSON.parse(
                        result.entity.consumableorderdetailsRecords
                    );
                  for (var i in this.data) {
                     this.data[i]["key"] = this.data[i]["ProdId"] + this.data[i]["boxPiece"];
                     this.data[i]["Name__c"] = this.data[i].Prod.Name__c;
                     this.data[i]["Packing_list_manual__c"] = this.data[i].Prod.Packing_list_manual__c;
                     if (this.data[i]["check"]) {
                        this.selectedRows.push(this.data[i].ProdId + this.data[i]["boxPiece"]);
                        console.log("selectedRows:" + this.selectedRows);
                        this.data[i]['key'] =
                            this.data[i]['ProdId'] + this.data[i]['boxPiece'];
                        this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
                        this.data[i]['Packing_list_manual__c'] =
                            this.data[i].Prod.Packing_list_manual__c;
                        if (this.data[i]['check']) {
                            this.selectedRows.push(
                                this.data[i].ProdId + this.data[i]['boxPiece']
                            );
                            console.log('selectedRows:' + this.selectedRows);
                     }
                  }
                  this.iSinventory = result.entity.iSinventory;
                  this.pandiandetailsMap = result.entity.pandiandetailsMap;
                  this.reSet = result.entity.reSet1;
                  console.log("iSinventory:" + this.iSinventory);
                    console.log('iSinventory:' + this.iSinventory);
                  this.showTable = true;
                  this.showbutton = true;
                  this.showSpinner = false;
                  console.log("result录入= " + JSON.stringify(result));
            }
            else {
               if (result.status == "Sucess") {
                    console.log('result录入= ' + JSON.stringify(result));
                } else {
                    if (result.status == 'Sucess') {
                  //分页start
                  this.nextPageToken = result.entity.paginatedAccounts.nextPageToken;
                  this.totalRecords = result.entity.paginatedAccounts.totalRecords;
                  this.recordStart = result.entity.paginatedAccounts.recordStart;
                  this.recordEnd = result.entity.paginatedAccounts.recordEnd;
                  this.totalPages = Math.ceil(result.entity.paginatedAccounts.totalRecords / this.pageSize);
                        this.nextPageToken =
                            result.entity.paginatedAccounts.nextPageToken;
                        this.totalRecords =
                            result.entity.paginatedAccounts.totalRecords;
                        this.recordStart =
                            result.entity.paginatedAccounts.recordStart;
                        this.recordEnd =
                            result.entity.paginatedAccounts.recordEnd;
                        this.totalPages = Math.ceil(
                            result.entity.paginatedAccounts.totalRecords /
                                this.pageSize
                        );
                  console.log('this.totalPages = ' + this.totalPages);
                  this.paginationVisibility = this.totalPages > 1 ? true : false;
                  console.log('this.sortDirection = ' + this.sortDirection);
                        this.paginationVisibility =
                            this.totalPages > 1 ? true : false;
                        console.log(
                            'this.sortDirection = ' + this.sortDirection
                        );
                  //分页end
                  this.codPageRecords = JSON.parse(result.entity.codPageRecords);
                        this.codPageRecords = JSON.parse(
                            result.entity.codPageRecords
                        );
                  for (var i in this.codPageRecords) {
                     this.codPageRecords[i]["Name__c"] = this.codPageRecords[i].Prod.Name__c;
                     this.codPageRecords[i]["Box_Piece__c"] = this.codPageRecords[i].orderdetails2.Box_Piece__c;
                     this.codPageRecords[i]["Bar_Code__c"] = this.codPageRecords[i].orderdetails2.Bar_Code__c;
                            this.codPageRecords[i]['Name__c'] =
                                this.codPageRecords[i].Prod.Name__c;
                            this.codPageRecords[i]['Box_Piece__c'] =
                                this.codPageRecords[
                                    i
                                ].orderdetails2.Box_Piece__c;
                            this.codPageRecords[i]['Bar_Code__c'] =
                                this.codPageRecords[
                                    i
                                ].orderdetails2.Bar_Code__c;
                  }
                  this.pageCodeRecords = result.entity.pageCodeRecords;
                  for (var i in this.pageCodeRecords) {
                     this.pageCodeRecords[i]["Name__c"] = this.pageCodeRecords[i].Prod.Name__c;
                     this.pageCodeRecords[i]["Box_Piece__c"] = this.pageCodeRecords[i].orderdetails2.Box_Piece__c;
                     this.pageCodeRecords[i]["Bar_Code__c"] = this.pageCodeRecords[i].orderdetails2.Bar_Code__c;
                            this.pageCodeRecords[i]['Name__c'] =
                                this.pageCodeRecords[i].Prod.Name__c;
                            this.pageCodeRecords[i]['Box_Piece__c'] =
                                this.pageCodeRecords[
                                    i
                                ].orderdetails2.Box_Piece__c;
                            this.pageCodeRecords[i]['Bar_Code__c'] =
                                this.pageCodeRecords[
                                    i
                                ].orderdetails2.Bar_Code__c;
                  }
                  this.data = JSON.parse(result.entity.consumableorderdetailsRecords);
                        this.data = JSON.parse(
                            result.entity.consumableorderdetailsRecords
                        );
                  for (var i in this.data) {
                     this.data[i]["key"] = this.data[i]["ProdId"] + this.data[i]["boxPiece"];
                     this.data[i]["Name__c"] = this.data[i].Prod.Name__c;
                     this.data[i]["Packing_list_manual__c"] = this.data[i].Prod.Packing_list_manual__c;
                     if (this.data[i]["check"]) {
                        this.selectedRows.push(this.data[i].ProdId + this.data[i]["boxPiece"]);
                        console.log("selectedRows:" + this.selectedRows);
                            this.data[i]['key'] =
                                this.data[i]['ProdId'] +
                                this.data[i]['boxPiece'];
                            this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
                            this.data[i]['Packing_list_manual__c'] =
                                this.data[i].Prod.Packing_list_manual__c;
                            if (this.data[i]['check']) {
                                this.selectedRows.push(
                                    this.data[i].ProdId +
                                        this.data[i]['boxPiece']
                                );
                                console.log(
                                    'selectedRows:' + this.selectedRows
                                );
                     }
                  }
                  this.iSinventory = result.entity.iSinventory;
                  this.pandiandetailsMap = result.entity.pandiandetailsMap;
                        this.pandiandetailsMap =
                            result.entity.pandiandetailsMap;
                  this.reSet = result.entity.reSet;
                  console.log("iSinventory:" + this.iSinventory);
                        console.log('iSinventory:' + this.iSinventory);
                  this.showTable = true;
                  this.showbutton = true;
                  this.showSpinner = false;
                  console.log("result录入= " + JSON.stringify(result));
                        console.log('result录入= ' + JSON.stringify(result));
               } else {
                  console.log('Error:' + result.msg);
                  this.showMyToast(result.msg,'','error');
@@ -508,30 +554,36 @@
            }
         })
         .catch((error) => {
            console.log("error = " + JSON.stringify(error));
                console.log('error = ' + JSON.stringify(error));
         });
   }
   //获取当前输入值
   handleChange(event) {
      let value = event.detail.value;
      console.log("value" + value);
        console.log('value' + value);
      this.barcode = value;
   }
   getSelectedRows(event) {
         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 selectedRowsEvent) {
                if (
                    this.data[i].ProdId + this.data[i]['boxPiece'] ==
                    selectedRowsEvent[j].ProdId +
                        selectedRowsEvent[j]['boxPiece']
                ) {
                    this.selectedRows.push(
                        selectedRowsEvent[j].ProdId + this.data[i]['boxPiece']
                    );
          }
      const selectedRows = event.detail.selectedRows;
      console.log("this.selectedRows = " + JSON.stringify(selectedRows));
      for (var i in selectedRows) {
         this.selectedRows.push(selectedRows[i].ProdId+this.data[i]["boxPiece"]);
      }
            // for (var i in selectedRowsEvent) {
            //     this.selectedRows.push(selectedRowsEvent[i].ProdId+this.data[i]["boxPiece"]);
            // }
   }
    }
   //导出为csv
   exportData() {
      // Prepare a html table
@@ -539,28 +591,32 @@
      // Add styles for the table
      doc += '<style>';
      doc += 'table, th, td {';
      doc += '    border: 1px solid black;';
        doc += '    border: 1px solid;';
      doc += '    border-collapse: collapse;';
        doc += '    font-weight: normal;';
        doc += '    text-align: left;';
      doc += '}';
      doc += '</style>';
      // Add all the Table Headers
      doc += '<tr>';
      this.columnHeader.forEach(element => {
         doc += '<th>' + element + '</th>'
        this.columnHeader.forEach((element) => {
            doc += '<th style="font-weight: bold";>' + element + '</th>';
      });
      doc += '</tr>';
      // Add the data rows
      this.codPageRecords.forEach(record => {
        this.codPageRecords.forEach((record) => {
         doc += '<tr>';
         doc += '<th>' + record.Name__c + '</th>';
         doc += '<th>' + record.Box_Piece__c + '</th>';
         doc += '<th>' + record.Bar_Code__c + '</th>';
         doc += '<th>' + record.DiffReason + '</th>';
            doc += '<td>' + record.Name__c + '</td>';
            doc += '<td>' + record.Box_Piece__c + '</td>';
            doc += '<td>' + record.Bar_Code__c + '</td>';
            doc += '<td>' + record.DiffReason + '</td>';
         doc += '</tr>';
      });
      doc += '</table>';
      console.log('doc' + doc);
      var element = 'data:application/vnd.ms-excel,' + encodeURIComponent(doc);
        var bom = '\uFEFF';
        var element =
            'data:application/vnd.ms-excel,' + encodeURIComponent(bom + doc);
      let downloadElement = document.createElement('a');
      downloadElement.href = element;
      downloadElement.target = '_self';
@@ -570,43 +626,57 @@
      downloadElement.click();
   }
   //自定义dataType
   diffreasons(event) {
      const numberDetail = event.detail;
      // this.numberDetail = numberDetail;
      console.log("numberDetail" + JSON.stringify(numberDetail));
        console.log('numberDetail' + JSON.stringify(numberDetail));
      for (var i in this.data) {
         console.log('this.data[i]["key"]' + this.data[i]["key"]);
         console.log('numberDetail.data.ProdId+numberDetail.data.boxPiece' + numberDetail.data.ProdId + numberDetail.data.boxPiece);
            console.log('this.data[i]["key"]' + this.data[i]['key']);
            console.log(
                'numberDetail.data.ProdId+numberDetail.data.boxPiece' +
                    numberDetail.data.ProdId +
                    numberDetail.data.boxPiece
            );
         if (this.data[i]["key"] == numberDetail.data.ProdId + numberDetail.data.boxPiece) {
            this.data[i]["DiffReason"] = numberDetail.data.DiffReason;
            if (
                this.data[i]['key'] ==
                numberDetail.data.ProdId + numberDetail.data.boxPiece
            ) {
                this.data[i]['DiffReason'] = numberDetail.data.DiffReason;
         }
      }
      console.log(" this.data==>" + JSON.stringify(this.data));
        console.log(' this.data==>' + JSON.stringify(this.data));
   }
   saveConfirm() {
      console.log("进入盘点确认");
        console.log('进入盘点确认');
      console.log('reSet' + this.reSet);
      this.showSpinner = true;
      console.log('pandiandetailsMap' + this.pandiandetailsMap);
      //查询有哪些选择了的然后check
      const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        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;
            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;
                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(
                    'selectedRows[j].ProdId+this.data[i]["boxPiece"]' +
                        selectedRows[j].ProdId +
                        selectedRows[j]['boxPiece']
                );
         }
      }
@@ -628,19 +698,19 @@
      })
         .then((result) => {
            result = JSON.parse(JSON.stringify(result));
            console.log("result = " + JSON.stringify(result));
            console.log("111111");
                console.log('result = ' + JSON.stringify(result));
                console.log('111111');
            if (result.status == "Success") {
               let url = "/lexinventory?ESetid=" + result.entity.eSetId;
                if (result.status == 'Success') {
                    let url = '/lexinventory?ESetid=' + result.entity.eSetId;
               this[NavigationMixin.Navigate]({
                  type: "standard__webPage",
                        type: 'standard__webPage',
                  attributes: {
                     url: url,
                  },
                            url: url
                        }
               });
               this.showSpinner = false;
               console.log("Id" + this.eSetId);
                    console.log('Id' + this.eSetId);
               // this.EditAble = true;
               // this.showcount = false;
            } else {
@@ -649,15 +719,15 @@
            }
         })
         .catch((error) => {
            console.log("error = " + JSON.stringify(error));
                console.log('error = ' + JSON.stringify(error));
            this.showSpinner = false;
         });
   }
   inits() {
      this.showSpinner = true
        this.showSpinner = true;
      datainit({
         eSetId: this.eSetId,
            eSetId: this.eSetId
      })
         .then((result) => {
            result = JSON.parse(JSON.stringify(result));
@@ -666,45 +736,59 @@
            for (var i in result.entity.qs) {
               this.conId = result.entity.qs[i].Id;
            }
            console.log("this.conId" + typeof this.conId);
            this.detailData = JSON.parse(result.entity.consumableorderdetailsRecords);
                console.log('this.conId' + typeof this.conId);
                this.detailData = JSON.parse(
                    result.entity.consumableorderdetailsRecords
                );
            if (result.entity.ConsumableorderdetailsRecordsError != null) {
               this.adjustdata = JSON.parse(
                  result.entity.ConsumableorderdetailsRecordsError
               );
               for (let i in this.detailData) {
                  this.detailData[i].Name__c = this.detailData[i].Prod.Name__c;
                  this.detailData[i].Count_Sum__c = this.detailData[i].orderdetails1.Count_Sum__c;
                  this.detailData[i].inventory_sum__c = this.detailData[i].orderdetails1.inventory_sum__c;
                  this.detailData[i].Diff__c = this.detailData[i].orderdetails1.Diff__c;
                  this.detailData[i].Product_Refind__c = this.detailData[i].orderdetails1.Product_Refind__c;
                  this.detailData[i].Lose_reason__c = this.detailData[i].orderdetails1.Lose_reason__c;
                        this.detailData[i].Name__c =
                            this.detailData[i].Prod.Name__c;
                        this.detailData[i].Count_Sum__c =
                            this.detailData[i].orderdetails1.Count_Sum__c;
                        this.detailData[i].inventory_sum__c =
                            this.detailData[i].orderdetails1.inventory_sum__c;
                        this.detailData[i].Diff__c =
                            this.detailData[i].orderdetails1.Diff__c;
                        this.detailData[i].Product_Refind__c =
                            this.detailData[i].orderdetails1.Product_Refind__c;
                        this.detailData[i].Lose_reason__c =
                            this.detailData[i].orderdetails1.Lose_reason__c;
               }
               for (let i in this.adjustdata) {
                  this.adjustdata[i].Name__c = this.adjustdata[i].Prod.Name__c;
                  this.adjustdata[i].Asset_Model_No__c = this.adjustdata[i].Prod.Asset_Model_No__c;
                  this.adjustdata[i].Lose_reason__c = this.adjustdata[i].orderdetails2.Lose_reason__c;
                  this.adjustdata[i].Lose_Flag__c = this.adjustdata[i].orderdetails2.Lose_Flag__c;
                        this.adjustdata[i].Name__c =
                            this.adjustdata[i].Prod.Name__c;
                        this.adjustdata[i].Asset_Model_No__c =
                            this.adjustdata[i].Prod.Asset_Model_No__c;
                        this.adjustdata[i].Lose_reason__c =
                            this.adjustdata[i].orderdetails2.Lose_reason__c;
                        this.adjustdata[i].Lose_Flag__c =
                            this.adjustdata[i].orderdetails2.Lose_Flag__c;
               }
            }
            this.showSpinner = false;
            console.log("result盘点Id" + JSON.stringify(this.conId));
            console.log("调整明细" + JSON.stringify(this.adjustdata));
                console.log('result盘点Id' + JSON.stringify(this.conId));
                console.log('调整明细' + JSON.stringify(this.adjustdata));
         })
         .catch((error) => {
            console.log("error = " + JSON.stringify(error));
                console.log('error = ' + JSON.stringify(error));
            this.showSpinner = false;
         });
   }
   //分页
   handlePrevious() {
      this.currentPageToken = Number(this.currentPageToken) - Number(this.pageSize);
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
      this.barcodeEntrys();
   }
   handleNext() {
      console.log('111');
      this.currentPageToken = Number(this.currentPageToken) + Number(this.pageSize);
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
      this.barcodeEntrys();
   }
   handleFirst() {
@@ -713,7 +797,8 @@
   }
   handleLast() {
      this.currentPageToken = this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
      this.barcodeEntrys();
   }
@@ -732,10 +817,11 @@
   }
   handleLoad2() {
        console.log('handleLoad2')
        console.log('handleLoad2');
        try {
            const style2 = document.createElement('style');
            style2.innerText = '.hehe-layoutItem  .slds-form-element__label {padding : 0px}';
            style2.innerText =
                '.hehe-layoutItem  .slds-form-element__label {padding : 0px}';
            this.template.querySelector('.hideHelpText').appendChild(style2);
        } catch (error) {
            console.log(error);
@@ -751,10 +837,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);
   }
}