| | |
| | | import { LightningElement, wire, api, track } from 'lwc'; |
| | | 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 categoryAllload from "@salesforce/apex/LexInventoryViewController.categoryAllload"; |
| | | import { NavigationMixin } from "lightning/navigation"; |
| | | |
| | | //table css |
| | | import { loadStyle } from "lightning/platformResourceLoader"; |
| | | import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable"; |
| | | |
| | | |
| | | export default class LexinventoryViewLWC extends NavigationMixin(LightningElement) { |
| | | //分页start |
| | | @track sortBy = ""; |
| | | //@track sortDirection = "asc"; |
| | | @track pageSize = 5; |
| | | @track pageSize = 10; |
| | | error; |
| | | records; |
| | | currentPageToken = 0; |
| | |
| | | @track pageNumber = 1; |
| | | @track paginationVisibility = false; |
| | | @track totalPages = 1; |
| | | pageSizeOptions = [5, 10, 25, 50, 75, 100]; |
| | | pageSizeOptions = [10,25,50,100]; |
| | | @track recordStart = 0; |
| | | @track recordEnd = 0; |
| | | //end |
| | |
| | | @track showSpinners = false; |
| | | //医院特价 |
| | | @track hasHos = false; |
| | | |
| | | //表头样式 |
| | | stylesLoaded = false; |
| | | |
| | | |
| | | @track columns = [ |
| | |
| | | type: "Name", |
| | | sortable: true, |
| | | hideDefaultActions: true, |
| | | initialWidth: 250, |
| | | // initialWidth: 300, |
| | | wrapText: true, |
| | | cellAttributes: { alignment: "left" } |
| | | }, |
| | | { |
| | | label: "第三分类", |
| | | fieldName: "Category3__c", |
| | | initialWidth: 90, |
| | | cellAttributes: { alignment: "left" }, |
| | | hideDefaultActions: true, |
| | | sortable: true, |
| | | wrapText: true, |
| | |
| | | { |
| | | label: "第四分类", |
| | | fieldName: "Category4__c", |
| | | cellAttributes: { alignment: "left" }, |
| | | initialWidth: 90, |
| | | hideDefaultActions: true, |
| | | wrapText: true, |
| | | sortable: true, |
| | |
| | | { |
| | | label: "第五分类", |
| | | fieldName: "Category5__c", |
| | | cellAttributes: { alignment: "left" }, |
| | | initialWidth: 90, |
| | | hideDefaultActions: true, |
| | | wrapText: true, |
| | | sortable: true, |
| | |
| | | { |
| | | label: "规格", |
| | | fieldName: "packing_list", |
| | | cellAttributes: { alignment: "right" }, |
| | | initialWidth: 55, |
| | | wrapText: true, |
| | | hideDefaultActions: true, |
| | | }, |
| | | { |
| | | label: "单位", |
| | | fieldName: "BoxPiece", |
| | | cellAttributes: { alignment: "left" }, |
| | | initialWidth: 55, |
| | | wrapText: true, |
| | | hideDefaultActions: true, |
| | | }, |
| | | { |
| | | label: "注册证编码号", |
| | | fieldName: "approbation_No", |
| | | cellAttributes: { alignment: "left" }, |
| | | wrapText: true, |
| | | initialWidth: 100, |
| | | initialWidth: 155, |
| | | hideDefaultActions: true, |
| | | }, |
| | | { |
| | | label: "注册有效期", |
| | | fieldName: "expiration_Date", |
| | | cellAttributes: { alignment: "left" }, |
| | | wrapText: true, |
| | | hideDefaultActions: true, |
| | | initialWidth: 150 |
| | | initialWidth: 100 |
| | | }, |
| | | { |
| | | label: "CFDA状态", |
| | | fieldName: "SFDA_Status__c", |
| | | cellAttributes: { alignment: "left" }, |
| | | initialWidth: 95, |
| | | wrapText: true, |
| | | hideDefaultActions: true, |
| | | }, |
| | | { |
| | | label: "使用期限", |
| | | fieldName: "guaranteeperiod", |
| | | cellAttributes: { alignment: "left" }, |
| | | hideDefaultActions: true, |
| | | initialWidth: 100 |
| | | initialWidth: 105 |
| | | }, |
| | | { |
| | | label: "有效期内库存", |
| | | fieldName: "limitCount", |
| | | label:'有效期内库存', |
| | | type: "customInventoryColor", |
| | | // sortable: true, |
| | | cellAttributes: {alignment: "right" }, |
| | | typeAttributes: { |
| | | value: { fieldName:"limitCount"}, |
| | | upperlimit: { fieldName: "upperlimit" }, |
| | | lowerlimit: { fieldName: "lowerlimit" }, |
| | | boxPrice:{ fieldName: "BoxPiece" }, |
| | | }, |
| | | hideDefaultActions: true, |
| | | sortable: true, |
| | | initialWidth:150 |
| | | }, |
| | | |
| | | { |
| | | label: "过期库存", |
| | | fieldName: "overlimitCount", |
| | | hideDefaultActions: true, |
| | | cellAttributes: { alignment: "right" }, |
| | | initialWidth:80 |
| | | } |
| | | ]; |
| | | defaultSortDirection = "asc"; |
| | |
| | | sortedBy; |
| | | |
| | | |
| | | |
| | | renderedCallback() { |
| | | if (!this.stylesLoaded) { |
| | | Promise.all([loadStyle(this, WrappedHeaderTable)]) |
| | | .then(() => { |
| | | console.log("Custom styles loaded"); |
| | | this.stylesLoaded = true; |
| | | }) |
| | | .catch((error) => { |
| | | console.error("Error loading custom styles"); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | connectedCallback() { |
| | | this.loader = true; |
| | | this.init(); |
| | |
| | | sortOrderLWC: this.sortDirection |
| | | }).then((result) => { |
| | | result = JSON.parse(JSON.stringify(result)); |
| | | console.log("result.pageRecords = " + JSON.stringify(result.entity.pageRecords)); |
| | | console.log("result.consumableorderdetailsRecords = " + JSON.stringify(result.entity.consumableorderdetailsRecords)); |
| | | console.log("result.status = " + result.status); |
| | | console.log("result = " + JSON.stringify(result)); |
| | | console.log("result 1= " + JSON.stringify(result.entity)); |
| | |
| | | this.category5Options = option3ValueTemp; |
| | | this.hasHos = result.entity.hasHos; |
| | | console.log('this.hasHos'+this.hasHos); |
| | | //颜色标记 |
| | | |
| | | //hasHos = true 医院特价 |
| | | if (this.hasHos) { |
| | | let object1 = { |
| | | label: "医院特价", |
| | | fieldName: "hospitalSpecialOffer__c", |
| | | hideDefaultActions: true, |
| | | type:'boolean' |
| | | type:'boolean', |
| | | cellAttributes: { alignment: "left" }, |
| | | initialWidth:80 |
| | | |
| | | }; |
| | | this.columns.push(object1); |
| | | console.log(' this.columns'+ this.columns); |
| | |
| | | } |
| | | this.showSpinner = false; |
| | | } else { |
| | | this.loader = false; |
| | | console.log("Error:" + result.errorMsg); |
| | | const evt = new ShowToastEvent({ |
| | | title: "解析失败", |
| | | message: result.errorMsg, |
| | | variant: "error" |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | this.showSpinner = false; |
| | | // this.showToast("Error",'Error', result.msg); |
| | | this.showMyToast('初始化失败',result.msg,'error'); |
| | | } |
| | | }).catch((error) => { |
| | | this.loader = false; |
| | |
| | | } |
| | | } else { |
| | | console.log("result = " + JSON.stringify(result)); |
| | | this.showToast("Error", result.msg); |
| | | this.showMyToast(result.msg,'','error'); |
| | | } |
| | | }).catch((error) => { |
| | | console.log("error" + JSON.stringify(error)); |
| | |
| | | console.log('this.totalPages = ' + this.totalPages); |
| | | this.paginationVisibility = this.totalPages > 1 ? true : false; |
| | | console.log('this.sortDirection = ' + this.sortDirection); |
| | | const evt = new ShowToastEvent({ |
| | | title: "搜索成功", |
| | | message: result.msg, |
| | | variant: "Success" |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | // this.showToast("Success",'搜索成功', result.msg); |
| | | this.showMyToast('搜索成功',result.msg,'success'); |
| | | this.data = result.entity.pageRecords; |
| | | console.log('搜索Data==>'+JSON.stringify(this.data)); |
| | | for (var i in this.data) { |
| | |
| | | console.log('this.data = ' + JSON.stringify(this.data)); |
| | | this.showTable = true; |
| | | } else { |
| | | const evt = new ShowToastEvent({ |
| | | title: "", |
| | | message: result.msg, |
| | | variant: "Success" |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | // this.showToast("Error",'Error', result.msg); |
| | | this.showMyToast('搜索失败',result.msg,'error'); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | |
| | | orderDetZaikuListLWC: JSON.stringify(this.orderDetZaikuList), |
| | | accountName: this.accountName, |
| | | agencyProType: this.agencyProType, |
| | | userWorkLocation: this.userWorkLocation |
| | | userWorkLocation: this.userWorkLocation, |
| | | pageSizeLWC: this.pageSize, |
| | | pageTokenLWC: this.currentPageToken, |
| | | }) |
| | | .then((result) => { |
| | | console.log("result搜索 = " + JSON.stringify(result)); |
| | | result = JSON.parse(JSON.stringify(result)); |
| | | if (result.status == "Success") { |
| | | |
| | | 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.data = result.entity.pageRecords; |
| | | |
| | | for (var i in this.data) { |
| | |
| | | } |
| | | this.showSpinner = false; |
| | | this.showTable = true; |
| | | const evt = new ShowToastEvent({ |
| | | title: "搜索成功", |
| | | message: result.msg, |
| | | variant: "Success" |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | this.showMyToast('搜索成功',result.msg,'success'); |
| | | // this.showToast("Success",'搜索成功', result.msg); |
| | | this.showSpinner = false; |
| | | } else { |
| | | const evt = new ShowToastEvent({ |
| | | title: "", |
| | | message: result.msg, |
| | | variant: "Success" |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | // this.showToast("Error", 'Error',result.msg); |
| | | this.showMyToast('搜索失败',result.msg,'error'); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | |
| | | get nextButtonDisabled() { |
| | | return this.nextPageToken === undefined; |
| | | } |
| | | showMyToast(title, message, variant) { |
| | | console.log('show custom message'); |
| | | var iconName = ''; |
| | | var content = ''; |
| | | if(variant == 'success'){ |
| | | iconName = 'utility:check'; |
| | | }else{ |
| | | iconName = 'utility:error'; |
| | | } |
| | | if(message != ''){ |
| | | 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); |
| | | |
| | | |
| | | |
| | | // showToast(type,title,msg) { |
| | | // this.showSpinner = false; |
| | | // let mode = ''; |
| | | // if (type.toLowerCase() != 'success') { |
| | | // mode = 'sticky'; |
| | | // } else { |
| | | // mode = 'dismissable'; |
| | | // } |
| | | // const event = new ShowToastEvent({ |
| | | // title: title, |
| | | // variant: type, |
| | | // message: msg, |
| | | // mode: mode |
| | | // }); |
| | | // this.dispatchEvent(event); |
| | | // } |
| | | } |
| | | } |