import { LightningElement, wire, api, track } from 'lwc'; import oninit from '@salesforce/apex/LexInventoryController.init'; import barcodeEntry from '@salesforce/apex/LexInventoryController.searchConsumableorderdetails'; import saveConfirm from '@salesforce/apex/LexInventoryController.save'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { NavigationMixin } from 'lightning/navigation'; //库存盘点主页面数据 const columns = [ { label: '是否盘点', fieldName: 'iscount', type: 'checkbox', cellAttributes: { alignment: 'left' } }, { label: '消耗品名称', fieldName: 'Name__c', type: 'Name', cellAttributes: { alignment: 'left' } }, { label: '规格', fieldName: 'Packing_list_manual__c', hideDefaultActions: true }, { label: '单位', fieldName: 'boxPiece', hideDefaultActions: true }, { label: '有效期内库存', fieldName: 'limitCount', hideDefaultActions: true }, { label: '过期库存', fieldName: 'overlimitCount', hideDefaultActions: true, initialWidth: 100 }, { label: '盘点', fieldName: 'Pandian', hideDefaultActions: true, initialWidth: 100 }, { label: '丢失', fieldName: 'Diff', hideDefaultActions: true, initialWidth: 100 }, { label: '寻回 ', fieldName: 'refind', hideDefaultActions: true, initialWidth: 150 }, { label: '差异原因', // fieldName: "DiffReason", hideDefaultActions: true, type: 'customDiffReason', typeAttributes: { DiffReason: { fieldName: 'DiffReason' }, ProdId: { fieldName: 'ProdId' } } } ]; //调整明细 const column = [ { label: '消耗品名称', fieldName: 'Name__c', type: 'Name', cellAttributes: { alignment: 'left' } }, { label: '单位', fieldName: 'Box_Piece__c', hideDefaultActions: true }, { label: 'barcode', fieldName: 'Bar_Code__c', hideDefaultActions: true, initialWidth: 150 }, { label: '调整原因', fieldName: 'DiffReason', hideDefaultActions: true } ]; //盘点明细 const dcolumns = [ { label: '消耗品名称', fieldName: 'Name__c', type: 'Name', cellAttributes: { alignment: 'left' } }, { label: '库存', fieldName: 'Box_Piece__c', hideDefaultActions: true }, { label: '盘点', fieldName: 'Bar_Code__c', hideDefaultActions: true, initialWidth: 150 }, { label: '丢失', fieldName: 'DiffReason', hideDefaultActions: true }, { label: '寻回', fieldName: 'DiffReason', hideDefaultActions: true }, , { label: '差异原因', fieldName: 'DiffReason', hideDefaultActions: true } ]; //在库调整明细 const stockadjustcolumns = [ { label: '消耗品名称', fieldName: 'Name__c', type: 'Name', cellAttributes: { alignment: 'left' } }, { label: '产品型号', fieldName: 'Box_Piece__c', hideDefaultActions: true }, { label: '差异原因', fieldName: 'Bar_Code__c', hideDefaultActions: true, initialWidth: 150 }, { label: '是否丢失', fieldName: 'DiffReason', hideDefaultActions: true } ]; export default class LexInventoryCount extends NavigationMixin( LightningElement ) { columns = columns; column = column; stockadjustcolumns = stockadjustcolumns; dcolumns = dcolumns; @track data = []; @track codPageRecords = []; @track accountName; @track agencyProType; @track userWorkLocation; @track showTable = false; @track showbutton = false; @track barCode; @track ConsumableorderdetailsRecordsview = []; @track consumableorderdetailsRecords = []; @track showTable = false; @track barcode; @track showcount = true; @track iSinventory; @track numberDetail; //加载框 @track casesSpinner = true; //row @track selectedRows = []; //inventoryList @track isSummonsFlag; //展开栏 activeSections = ['dataExpand']; columnHeader = ['消耗品名称', '单位', 'barCode', '调整原因']; //确认一览 @track eSetId = ''; @track EditAble = false; @track selectedData; @track conId; @track detailData = []; @track adjustdata = []; //获取链接参数 getQueryString(name) { 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]); } return null; } connectedCallback() { console.log('===>初始化'); //获取ESetid this.eSetId = this.getQueryString('eSetId'); this.eSetId = this.eSetId == null ? '' : this.eSetId; console.log(' this.eSetId' + this.eSetId); this.EditAble = false; this.showcount = true; oninit() .then((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( 'this.ConsumableorderdetailsRecordsview[0] = ' + JSON.stringify( this.ConsumableorderdetailsRecordsview[0] ) ); console.log( 'this.ConsumableorderdetailsRecordsview[0].length = ' + this.ConsumableorderdetailsRecordsview[0].length ); // let cloneData = []; // for (let i in this.ConsumableorderdetailsRecordsview[0]) { // cloneData.push(JSON.parse(this.ConsumableorderdetailsRecordsview[0][i])); // } // console.log('cloneData = ' + typeof cloneData); // console.log('cloneData = ' + cloneData); // this.data = cloneData; this.data = []; this.data = this.ConsumableorderdetailsRecordsview[0]; console.log('this.data ==>' + JSON.stringify(this.data)); for (let i in this.data) { 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; this.userWorkLocation = result.entity.userWorkLocation; this.casesSpinner = false; this.showTable = true; } else { console.log('Error:' + result.errorMsg); const evt = new ShowToastEvent({ title: '解析失败', message: result.errorMsg, variant: 'error' }); this.dispatchEvent(evt); } }) .catch((error) => { console.log('error = ' + JSON.stringify(error)); }); //默认展开栏 this.activeSections = ['dataExpand']; this.showTable = false; this.showbutton = false; //init } //录入barcode barcodeEntrys() { this.showTable = false; this.showbutton = false; console.log('进入录入'); console.log( 'this.consumableorderdetailsRecords===>' + this.consumableorderdetailsRecords ); if ( this.barcode == '' || this.barcode == null || this.barcode == 'undefined' ) { this.connectedCallback(); } barcodeEntry({ accountName: this.accountName, agencyProType: this.agencyProType, userWorkLocation: this.userWorkLocation, barcode: this.barcode, consumableorderdetailsRecordsLWC: this.consumableorderdetailsRecords }) .then((result) => { // result = JSON.parse(JSON.stringify(result)); 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.data = JSON.parse( result.entity.consumableorderdetailsRecords ); for (var i in this.data) { 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; } for (var i in this.data) { if (this.data[i]['check']) { this.selectedRows.push(this.data[i].ProdId); console.log('selectedRows:' + this.selectedRows); } } this.iSinventory = result.entity.iSinventory; console.log('iSinventory:' + this.iSinventory); this.showTable = true; this.showbutton = true; console.log( ' this.codPageRecords=11111 ' + result.entity.codPageRecords ); console.log('result录入= ' + JSON.stringify(result)); console.log( 'result主页数据= ' + result.entity.consumableorderdetailsRecords ); }) .catch((error) => { console.log('error = ' + JSON.stringify(error)); }); } //获取当前输入值 handleChange(event) { let value = event.detail.value; console.log('value' + value); this.barcode = value; } getSelectedRows(event) { const selectedRows = event.detail.selectedRows; console.log('this.selectedRows = ' + this.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].Id == selectedRows[j].Id) { this.data[i]['check'] = true; } } } } //导出为csv exportData() { console.log('导出'); // Prepare a html table let doc = '
' + element + ' | '; }); doc += '|||
---|---|---|---|
' + record.Name__c + ' | '; doc += '' + record.Box_Piece__c + ' | '; doc += '' + record.Bar_Code__c + ' | '; doc += '' + record.DiffReason + ' | '; doc += '