From d6a096fadfe9c8f261f56a827cfceed663c36b8b Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期三, 26 四月 2023 17:23:28 +0800 Subject: [PATCH] backup0421 --- force-app/main/default/lwc/lexinventoryViewLWC/lexinventoryViewLWC.js | 724 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 400 insertions(+), 324 deletions(-) diff --git a/force-app/main/default/lwc/lexinventoryViewLWC/lexinventoryViewLWC.js b/force-app/main/default/lwc/lexinventoryViewLWC/lexinventoryViewLWC.js index b24100b..74c92c3 100644 --- a/force-app/main/default/lwc/lexinventoryViewLWC/lexinventoryViewLWC.js +++ b/force-app/main/default/lwc/lexinventoryViewLWC/lexinventoryViewLWC.js @@ -1,344 +1,420 @@ import { LightningElement, wire, api, track } from 'lwc'; -import oninit from '@salesforce/apex/LexInventoryViewController.init'; -import { ShowToastEvent } from 'lightning/platformShowToastEvent'; -import searchOrder from '@salesforce/apex/LexInventoryViewController.searchConsumableorderdetails'; -import { NavigationMixin } from 'lightning/navigation'; +import oninit from "@salesforce/apex/LexInventoryViewController.init"; +import oninit2 from "@salesforce/apex/LexInventoryViewController.init2"; +import { ShowToastEvent } from "lightning/platformShowToastEvent"; +import searchOrder from "@salesforce/apex/LexInventoryViewController.searchConsumableorderdetails"; +import { NavigationMixin } from "lightning/navigation"; const columns = [ - { - label: '娑堣�楀搧鍚嶇О', - fieldName: 'Name__c', - type: 'Name', - sortable: true, - initialWidth: 250, - cellAttributes: { alignment: 'left' } - }, - { - label: '绗笁鍒嗙被', - fieldName: 'Category3__c', - hideDefaultActions: true, - sortable: true, - initialWidth: 90 - }, - { - label: '绗洓鍒嗙被', - fieldName: 'Category4__c', - hideDefaultActions: true, - sortable: true, - initialWidth: 90 - }, - { - label: '绗簲鍒嗙被', - fieldName: 'Category5__c', - hideDefaultActions: true, - initialWidth: 90 - }, + { + label: "娑堣�楀搧鍚嶇О", + fieldName: "Name__c", + type: "Name", + sortable: true, + initialWidth : 250, + hideDefaultActions: true, + wrapText:true, + cellAttributes: { alignment: "left" } + }, + { + label: "绗笁鍒嗙被", + fieldName: "Category3__c", + hideDefaultActions: true, + sortable: true, + wrapText:true, + initialWidth: 90 + }, + { + label: "绗洓鍒嗙被", + fieldName: "Category4__c", + hideDefaultActions: true, + wrapText:true, + sortable: true, + initialWidth: 90 + }, + { + label: "绗簲鍒嗙被", + fieldName: "Category5__c", + hideDefaultActions: true, + wrapText:true, + initialWidth: 90 + }, - { - label: '瑙勬牸', - fieldName: 'packing_list', - hideDefaultActions: true - }, - { - label: '鍗曚綅', - fieldName: 'BoxPiece', - hideDefaultActions: true - }, - { - label: '娉ㄥ唽璇佺紪鐮佸彿', - fieldName: 'approbation_No', - initialWidth: 180, - hideDefaultActions: true - }, - { - label: '娉ㄥ唽鏈夋晥鏈�', - fieldName: 'expiration_Date', - hideDefaultActions: true, - initialWidth: 150 - }, - { - label: 'CFDA鐘舵��', - fieldName: 'SFDA_Status__c', - hideDefaultActions: true, - initialWidth: 100 - }, - { - label: '浣跨敤鏈熼檺', - fieldName: 'guaranteeperiod', - hideDefaultActions: true, - initialWidth: 100 - }, - { - label: '鏈夋晥鏈熷唴搴撳瓨', - fieldName: 'limitCount', - hideDefaultActions: true, - sortable: true, - initialWidth: 100 - }, - { - label: '杩囨湡搴撳瓨', - fieldName: 'overlimitCount', - hideDefaultActions: true, - initialWidth: 100 - } + { + label: "瑙勬牸", + fieldName: "packing_list", + wrapText:true, + hideDefaultActions: true, + }, + { + label: "鍗曚綅", + fieldName: "BoxPiece", + wrapText:true, + hideDefaultActions: true, + }, + { + label: "娉ㄥ唽璇佺紪鐮佸彿", + fieldName: "approbation_No", + wrapText:true, + initialWidth : 180, + hideDefaultActions: true, + }, + { + label: "娉ㄥ唽鏈夋晥鏈�", + fieldName: "expiration_Date", + wrapText:true, + hideDefaultActions: true, + initialWidth: 150 + }, + { + label: "CFDA鐘舵��", + fieldName: "SFDA_Status__c", + hideDefaultActions: true, + initialWidth: 100 + }, + { + label: "浣跨敤鏈熼檺", + fieldName: "guaranteeperiod", + hideDefaultActions: true, + initialWidth: 100 + }, + { + label: "鏈夋晥鏈熷唴搴撳瓨", + fieldName: "limitCount", + hideDefaultActions: true, + sortable: true, + initialWidth: 100 + }, + { + label: "杩囨湡搴撳瓨", + fieldName: "overlimitCount", + hideDefaultActions: true, + initialWidth: 100 + } ]; -export default class LexinventoryViewLWC extends NavigationMixin( - LightningElement -) { - @track pageRecords = []; - @track data = []; - @track message = ''; - @track Name; - @track CategoryThree; - @track CategoryFour; - @track CategoryFive; - @track orderDetZaikuList = []; - @track accountName; - @track agencyProType; - @track userWorkLocation; - @track value = ''; - @track showTable = false; - @track hidecheckboxcolumn = true; - @track check = false; - // @track options1 = []; - // @track options2 = []; - // @track options3 = []; +export default class LexinventoryViewLWC extends NavigationMixin(LightningElement) { + //鍒嗛〉start + // @track sortBy = ""; + // @track sortDirection = "asc"; + // @track pageSize = 10; + // error; + // records; + // currentPageToken = 0; + // nextPageToken = this.pageSize; + // @track loader = false; + // @track pageNumber = 1; + // @track paginationVisibility = false; + // @track totalPages = 1; + // @api pageSizeOptions = [10, 25, 50, 75, 100]; + //end - columns = columns; - defaultSortDirection = 'asc'; - sortDirection = 'asc'; - sortedBy; + @track data = []; + @track message = ""; + @track Name; + @track CategoryThree; + @track CategoryFour; + @track CategoryFive; + @track orderDetZaikuList = []; + @track accountName; + @track agencyProType; + @track userWorkLocation; + @track value = ""; + @track showTable = false; + @track hidecheckboxcolumn = true; + @track check = false; + //鍔犺浇 + @track showSpinner = false; - // columns = columns; - connectedCallback() { - oninit() - .then((result) => { - result = JSON.parse(JSON.stringify(result)); - console.log('result.status = ' + result.status); - console.log('result = ' + JSON.stringify(result)); - console.log('result 1= ' + JSON.stringify(result.entity)); - console.log( - 'result 2= ' + JSON.stringify(result.entity.pageRecords) - ); - console.log( - 'result.entity.categoryOptionMap 2= ' + - JSON.stringify(result.entity.categoryOptionMap) - ); - console.log( - 'result.entity.categoryOptionMap 2= ' + - JSON.stringify(result.entity.category4OptionMap) - ); - console.log( - 'result.entity.categoryOptionMap 2= ' + - JSON.stringify(result.entity.category5OptionMap) - ); - if (result.status == 'Success') { - // this.pageRecords = result.entity.pageRecords; - this.data = result.entity.pageRecords; - for (var i in this.data) { - this.data[i]['Name__c'] = this.data[i].Prod.Name__c; - this.data[i]['Category3__c'] = - this.data[i].Prod.Category3__c; - this.data[i]['Category4__c'] = - this.data[i].Prod.Category3__c; - this.data[i]['Category5__c'] = - this.data[i].Prod.Category3__c; - this.data[i]['SFDA_Status__c'] = - this.data[i].Prod.SFDA_Status__c; - } - console.log(); - this.showTable = true; - this.orderDetZaikuList = result.entity.orderDetZaikuList; - this.accountName = result.entity.accountName; - this.agencyProType = result.entity.agencyProType; - this.userWorkLocation = result.entity.userWorkLocation; - let option1ValueTemp = []; - for (var key in result.entity.categoryOptionMap) { - let object = {}; - object['label'] = result.entity.categoryOptionMap[key]; - object['value'] = key; - option1ValueTemp.push(object); - } - this.options1 = option1ValueTemp; - console.log( - ' this.optionscatone===>' + - JSON.stringify(this.optionscatone) - ); - let option2ValueTemp = []; - for (var key in result.entity.category4OptionMap) { - let object = {}; - object['label'] = result.entity.category4OptionMap[key]; - object['value'] = key; - option2ValueTemp.push(object); - } - this.options2 = option2ValueTemp; - let option3ValueTemp = []; - for (var key in result.entity.category5OptionMap) { - let object = {}; - object['label'] = result.entity.category5OptionMap[key]; - object['value'] = key; - option3ValueTemp.push(object); - } - this.options3 = option3ValueTemp; + columns = columns; + defaultSortDirection = "asc"; + sortDirection = "asc"; + sortedBy; - console.log(' this.data=====>' + this.data); + // columns = columns; - console.log('this.accountName=====>' + this.accountName); - - console.log( - 'this.agencyProType=====>' + this.agencyProType - ); - console.log( - 'this.userWorkLocationt=====>' + this.userWorkLocation - ); - console.log( - 'orderDetZaikuList=====>' + this.orderDetZaikuList - ); - } else { - console.log('Error:' + result.errorMsg); - const evt = new ShowToastEvent({ - title: '瑙f瀽澶辫触', - message: result.errorMsg, - variant: 'error' - }); - this.dispatchEvent(evt); - } - }) - .catch((error) => { - console.log('error = ' + JSON.stringify(error)); - }); - } - sortBy(field, reverse, primer) { - const key = primer - ? function (x) { - return primer(x[field]); - } - : function (x) { - return x[field]; - }; - - return function (a, b) { - a = key(a); - b = key(b); - return reverse * ((a > b) - (b > a)); - }; - } - - onHandleSort(event) { - const { fieldName: sortedBy, sortDirection } = event.detail; - const cloneData = [...this.data]; - - cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)); - this.data = cloneData; - this.sortDirection = sortDirection; - this.sortedBy = sortedBy; - } - handlePaginatorChange(event) { - this.recordsToDisplay = event.detail.recordsToDisplay; - this.preSelected = event.detail.preSelected; - if (this.recordsToDisplay && this.recordsToDisplay > 0) { - this.rowNumberOffset = this.recordsToDisplay[0].rowNumber - 1; + connectedCallback() { + console.log('zhj init') + // { + // pageSizeLWC: this.pageSize, + // pageTokenLWC: this.currentPageToken, + // sortFieldLWC: this.sortBy, + // sortOrderLWC: this.sortDirection + // } + oninit().then((result) => { + result = JSON.parse(JSON.stringify(result)); + console.log("result.status = " + result.status); + console.log("result = " + JSON.stringify(result)); + console.log("result 1= " + JSON.stringify(result.entity)); + console.log("result 2= " + JSON.stringify(result.entity.pageRecords)); + console.log("result.entity.categoryOptionMap 2= " +JSON.stringify(result.entity.categoryOptionMap)); + console.log("result.entity.categoryOptionMap 2= " +JSON.stringify(result.entity.category4OptionMap)); + console.log("result.entity.categoryOptionMap 2= " +JSON.stringify(result.entity.category5OptionMap)); + if (result.status == "Success") { + this.data = result.entity.pageRecords; + for (var i in this.data) { + this.data[i]["Name__c"] = this.data[i].Prod.Name__c; + this.data[i]["Category3__c"] = this.data[i].Prod.Category3__c; + this.data[i]["Category4__c"] = this.data[i].Prod.Category3__c; + this.data[i]["Category5__c"] = this.data[i].Prod.Category3__c; + this.data[i]["SFDA_Status__c"] = this.data[i].Prod.SFDA_Status__c; + } + console.log(); + this.showTable = true; + this.orderDetZaikuList = result.entity.orderDetZaikuList; + this.accountName = result.entity.accountName; + this.agencyProType = result.entity.agencyProType; + this.userWorkLocation = result.entity.userWorkLocation; + let option1ValueTemp = []; + for (var key in result.entity.categoryOptionMap) { + let object = {}; + object['label'] = result.entity.categoryOptionMap[key]; + object['value'] = key; + option1ValueTemp.push(object); + } + this.options1 = option1ValueTemp; + console.log( ' this.optionscatone===>'+JSON.stringify(this.optionscatone)); + let option2ValueTemp = []; + for (var key in result.entity.category4OptionMap) { + let object = {}; + object["label"] = result.entity.category4OptionMap[key]; + object["value"] = key; + option2ValueTemp.push(object); + } + this.options2 = option2ValueTemp; + let option3ValueTemp = []; + for (var key in result.entity.category5OptionMap) { + let object = {}; + object["label"] = result.entity.category5OptionMap[key]; + object["value"] = key; + option3ValueTemp.push(object); + } + this.options3 = option3ValueTemp; } else { - this.rowNumberOffset = 0; + console.log("Error:" + result.errorMsg); + const evt = new ShowToastEvent({ + title: "瑙f瀽澶辫触", + message: result.errorMsg, + variant: "error" + }); + this.dispatchEvent(evt); } - } - - handleChange(event) { - let fieldName = event.target.getAttribute('data-field'); - let value = event.detail.value; - console.log('======>fieldName' + fieldName); - console.log('======>value' + value); - switch (fieldName) { - case 'Name': - this.Name = value; - break; - case 'CategoryThree': - this.CategoryThree = value; - break; - case 'CategoryFour': - this.CategoryFour = value; - break; - case 'CategoryFive': - this.CategoryFive = value; - break; - default: - console.log('no data'); + }) + .catch((error) => { + console.log("error = " + JSON.stringify(error)); + }); + } + sortBy(field, reverse, primer) { + const key = primer + ? function (x) { + return primer(x[field]); } - } + : function (x) { + return x[field]; + }; - searchOrderDetail() { - this.showTable = false; - console.log('杩涘叆鎼滅储11111111111111'); - console.log('杩涘叆鎼滅储'); - console.log('this.CategoryThree = ' + this.CategoryThree); - console.log('this.CategoryFive = ' + this.CategoryFive); - searchOrder({ - category1: this.Name, - Category3: this.CategoryThree, - Category4: this.CategoryFour, - Category5: this.CategoryFive, - orderDetZaikuListLWC: JSON.stringify(this.orderDetZaikuList), - accountName: this.accountName, - agencyProType: this.agencyProType, - userWorkLocation: this.userWorkLocation - }) - .then((result) => { - result = JSON.parse(JSON.stringify(result)); - console.log('result鎼滅储 = ' + JSON.stringify(result)); - console.log( - 'result鎼滅储鍒楄〃= ' + - JSON.stringify(result.entity.pageRecords) - ); - if (result.status == 'Success') { - const evt = new ShowToastEvent({ - title: '鎼滅储鎴愬姛', - message: result.msg, - variant: 'Success' - }); - this.dispatchEvent(evt); - this.data = result.entity.pageRecords; - this.showTable = true; - } else { - const evt = new ShowToastEvent({ - title: '', - message: result.msg, - variant: 'Success' - }); - this.dispatchEvent(evt); - this.pageRecords = []; - console.log(' this.data===>= ' + this.pageRecords); - } - }) - .catch((error) => { - console.log('error = ' + JSON.stringify(error)); - }); - } + return function (a, b) { + a = key(a); + b = key(b); + return reverse * ((a > b) - (b > a)); + }; + } - inventoryCount() { - console.log('111搴撳瓨鐩樼偣'); - this[NavigationMixin.Navigate]({ - type: 'standard__webPage', - attributes: { - url: '/lexInventoryCount' - } - }); - } + onHandleSort(event) { + const { fieldName: sortedBy, sortDirection } = event.detail; + const cloneData = [...this.data]; - handleExpired() { - this[NavigationMixin.Navigate]({ - type: 'standard__webPage', - attributes: { - url: '/lexOverdueStock' - } - }); + cloneData.sort(this.sortBy(sortedBy, sortDirection === "asc" ? 1 : -1)); + this.data = cloneData; + this.sortDirection = sortDirection; + this.sortedBy = sortedBy; + } + handlePaginatorChange(event) { + this.recordsToDisplay = event.detail.recordsToDisplay; + this.preSelected = event.detail.preSelected; + if (this.recordsToDisplay && this.recordsToDisplay > 0) { + this.rowNumberOffset = this.recordsToDisplay[0].rowNumber - 1; + } else { + this.rowNumberOffset = 0; } + } - clearAll() { - this.Name = ''; - this.value = '鏃�'; - this.template.querySelectorAll('lightning-combobox').forEach((each) => { - each.value = null; - }); + handleChange(event) { + let fieldName = event.target.getAttribute("data-field"); + let value = event.detail.value; + console.log("======>fieldName" + fieldName); + console.log("======>value" + value); + switch (fieldName) { + case "Name": + this.Name = value; + break; + case "CategoryThree": + this.CategoryThree = value; + break; + case "CategoryFour": + this.CategoryFour = value; + break; + case "CategoryFive": + this.CategoryFive = value; + break; + default: + console.log("no data"); } + } + + searchOrderDetail() { + this.showTable = false; + this.showSpinner = true; + console.log("杩涘叆鎼滅储11111111111111"); + console.log("杩涘叆鎼滅储"); + console.log("this.CategoryThree = " + this.CategoryThree); + console.log("this.CategoryFive = " + this.CategoryFive); + searchOrder({ + category1: this.Name, + Category3: this.CategoryThree, + Category4: this.CategoryFour, + Category5: this.CategoryFive, + orderDetZaikuListLWC: JSON.stringify(this.orderDetZaikuList), + accountName: this.accountName, + agencyProType: this.agencyProType, + userWorkLocation: this.userWorkLocation + }) + .then((result) => { + result = JSON.parse(JSON.stringify(result)); + console.log("result鎼滅储 = " + JSON.stringify(result)); + console.log("result鎼滅储鍒楄〃= " + JSON.stringify(result.entity.pageRecords)); + if (result.status == "Success") { + const evt = new ShowToastEvent({ + title: "鎼滅储鎴愬姛", + message: result.msg, + variant: "Success" + }); + this.dispatchEvent(evt); + this.data = result.entity.pageRecords; + for (var i in this.data) { + this.data[i]["Name__c"] = this.data[i].Prod.Name__c; + this.data[i]["Category3__c"] = this.data[i].Prod.Category3__c; + this.data[i]["Category4__c"] = this.data[i].Prod.Category3__c; + this.data[i]["Category5__c"] = this.data[i].Prod.Category3__c; + this.data[i]["SFDA_Status__c"] = this.data[i].Prod.SFDA_Status__c; + } + + this.showTable = true; + this.showSpinner = false; + } else { + const evt = new ShowToastEvent({ + title: "", + message: result.msg, + variant: "Success" + }); + this.dispatchEvent(evt); + } + }) + .catch((error) => { + console.log("error = " + JSON.stringify(error)); + }); + } + + inventoryCount(){ + console.log('111搴撳瓨鐩樼偣'); + this[NavigationMixin.Navigate]({ + type: 'standard__webPage', + attributes: { + url: '/lexInventoryCount' + } + }); } + +handleExpired(){ + console.log('杩囨湡搴撳瓨鍛㈤攢瀛�'); + this[NavigationMixin.Navigate]({ + type: 'standard__webPage', + attributes: { + url:'/lexoverdueStock' + } + }); + + } + removeBox(){ + this[NavigationMixin.Navigate]({ + type: 'standard__webPage', + attributes: { + url:'/lexremovebox' + } + }); + + } + cancelremoveBox(){ + this[NavigationMixin.Navigate]({ + type: 'standard__webPage', + attributes: { + url:'/lexCancelRemoveBox' + } + }); + + } + + clearAll() { + this.showSpinner = true; + this.showTable = false; + this.Name = ''; + this.CategoryThree = ''; + this.CategoryFour = ''; + this.CategoryFive = ''; + this.template.querySelectorAll("lightning-combobox").forEach((each) => { + each.value = null; + }); + console.log(' this.CategoryThree'+ this.CategoryThree); + console.log('鏁版嵁鍒楄〃'+this.data); + searchOrder({ + category1: this.Name, + Category3: this.CategoryThree, + Category4: this.CategoryFour, + Category5: this.CategoryFive, + orderDetZaikuListLWC: JSON.stringify(this.orderDetZaikuList), + accountName: this.accountName, + agencyProType: this.agencyProType, + userWorkLocation: this.userWorkLocation + }) + .then((result) => { + console.log("result鎼滅储 = " + JSON.stringify(result)); + result = JSON.parse(JSON.stringify(result)); + if (result.status == "Success") { + this.data = result.entity.pageRecords; + + for (var i in this.data) { + this.data[i]["Name__c"] = this.data[i].Prod.Name__c; + this.data[i]["Category3__c"] = this.data[i].Prod.Category3__c; + this.data[i]["Category4__c"] = this.data[i].Prod.Category3__c; + this.data[i]["Category5__c"] = this.data[i].Prod.Category3__c; + this.data[i]["SFDA_Status__c"] = this.data[i].Prod.SFDA_Status__c; + } + this.showSpinner = false; + this.showTable = true; + const evt = new ShowToastEvent({ + title: "鎼滅储鎴愬姛", + message: result.msg, + variant: "Success" + }); + this.dispatchEvent(evt); + this.showSpinner = false; + } else { + const evt = new ShowToastEvent({ + title: "", + message: result.msg, + variant: "Success" + }); + this.dispatchEvent(evt); + } + }) + .catch((error) => { + console.log("error = " + JSON.stringify(error)); + }); + } + + + + + + +} \ No newline at end of file -- Gitblit v1.9.1