import { LightningElement,wire,track } from 'lwc';
|
import { CurrentPageReference } from 'lightning/navigation';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import init from '@salesforce/apex/LexArriveGoodsController.init';
|
import searchProduct from '@salesforce/apex/LexArriveGoodsController.searchProduct';
|
import arriveGoodsConfim from '@salesforce/apex/LexArriveGoodsController.arriveGoodsConfim';
|
import updateGoodsOfReturn from '@salesforce/apex/LexArriveGoodsController.updateGoodsOfReturn';
|
|
export default class LexArriveGoods extends NavigationMixin(LightningElement) {
|
//页面变量
|
@track arrType;
|
@track eSetId;
|
@track returnFLGbln = false;
|
@track saveFLGbln = false;
|
@track barcode;
|
@track arrController;
|
// @track accountId;
|
// @track accountName;
|
// @track userProType;
|
// @track userProTypestr;
|
// @track productType;
|
// @track engFlag = false;
|
// @track etFlag = false;
|
// @track userWorkLocation;
|
// @track inventoryOrderId;
|
// @track returnOrderId;
|
// @track arriveId;
|
// @track productList;
|
// @track orderProductCunMap;
|
// @track orderProductArrivedCunMap;
|
// @track orderWantArriveCunMap;
|
// @track overOrderCunMap;
|
// @track overOrderBARcodeCunMap;
|
@track showSpinner = true;
|
@track showPage = false;
|
//
|
// @track consumableorderdetailsRecordsUse;
|
// @track consumableInventoryUse;
|
// @track consumableorderdetails2Cancle;
|
// @track orderdetails2trMap;
|
// @track consumableorderdetails2Insert;
|
// @track consumableorderdetails2Nobox;
|
// @track consumableorderdetailsRecordsdummy;
|
// @track existIdMap;
|
// @track errorIdMap;
|
// @track allMap;
|
//消耗品订单
|
@track coc;
|
@track cocId;
|
//本次到货产品汇总
|
@track detailsSummary = [];
|
//到货明细
|
@track consumableorderdetailsRecords = [];
|
@track consumableorderdetailsRecordsview = [];
|
//返品明细
|
@track showGoodsofReturnList = [];
|
//入库明细
|
@track consumableInventory = [];
|
//错误明细
|
@track consumableorderdetailsRecordserror = [];
|
//报错提醒
|
@track errorMsgs = [];
|
@track warningMsgs = [];
|
|
//是否有警告
|
get hasWarning(){
|
if(this.warningMsgs == null || this.warningMsgs.length == 0){
|
return false;
|
}
|
if(this.warningMsgs.length > 0){
|
return true;
|
}
|
}
|
|
//是否有错误
|
get hasError(){
|
if(this.errorMsgs == null || this.errorMsgs.length == 0){
|
return false;
|
}
|
if(this.errorMsgs.length > 0){
|
return true;
|
}
|
}
|
|
//本次到货产品汇总cols
|
@track currentArrProdCols = [
|
{label:'产品型号' , fieldName:'assetModelNo', hideDefaultActions: true},
|
{label:'产品名称' , fieldName:'prodName', hideDefaultActions: true},
|
{label:'到货数量' , fieldName:'arrivedCount', hideDefaultActions: true},
|
{label:'到货金额' , fieldName:'arriveAmount', hideDefaultActions: true}
|
];
|
//到货明细cols
|
@track arrDetailCols = [
|
{label:'消耗品名称' , fieldName:'prodName', hideDefaultActions: true},
|
{label:'规格' , fieldName:'productPackingListManual', hideDefaultActions: true},
|
{label:'CFDA状态' , fieldName:'status', hideDefaultActions: true},
|
{label:'注册证编码号' , fieldName:'reportProductApprobation', hideDefaultActions: true},
|
{label:'注册证效期' , fieldName:'ReportProductExpirationDate', hideDefaultActions: true},
|
{label:'BarCode' , fieldName:'barCode', hideDefaultActions: true}
|
];
|
//返品明细cols
|
get returnDetailCols(){
|
var cols = [];
|
cols.push({label:'出库单',fieldName:'orderUrl',type:'url',typeAttributes:{label:{fieldName:'orderNo'},target: "_blank"},hideDefaultActions: true});
|
// cols.push({label:'出库单' , fieldName:'orderNo', hideDefaultActions: true});
|
cols.push({label:'出库日' , fieldName:'prodOutDate', hideDefaultActions: true});
|
cols.push({label:'消耗品名称' , fieldName:'prodName', hideDefaultActions: true});
|
cols.push({label:'出库目的' , fieldName:'summonsForDirctionDet', hideDefaultActions: true});
|
cols.push({label:'客户名' , fieldName:'hospitalName', hideDefaultActions: true});
|
cols.push({label:'经销商' , fieldName:'orderDealer', hideDefaultActions: true});
|
cols.push({label:'BarCode' , fieldName:'barCode', hideDefaultActions: true});
|
cols.push({label:'使用期限' , fieldName:'sterilizationLimit', hideDefaultActions: true});
|
cols.push({label:'单位' , fieldName:'boxPiece', hideDefaultActions: true});
|
cols.push({
|
label:'返品数量',
|
type: "customReturnGoodInput",
|
typeAttributes: {
|
inputValue: { fieldName: "returnCount" },
|
boxPrice: { fieldName: "boxPiece" },
|
recordId: { fieldName: "recordId" }
|
},
|
hideDefaultActions: true});
|
cols.push({
|
label:'返品原因',
|
type: "customTableInput",
|
typeAttributes: {
|
recordId: { fieldName: "recordId" },
|
inputValue: { fieldName: "returnReason" },
|
valueType: 'Text'
|
},
|
hideDefaultActions: true,initialWidth:70});
|
// cols.push({label:'返品原因' , fieldName:'returnReason', hideDefaultActions: true});
|
return cols;
|
}
|
//入库明细cols
|
get inDetailCols(){
|
var cols = [];
|
cols.push({label:'消耗品名称' , fieldName:'prodName', hideDefaultActions: true});
|
cols.push({label:'BarCode' , fieldName:'barCodeNo', hideDefaultActions: true});
|
cols.push({label:'使用期限' , fieldName:'sterilizationlimitDate', hideDefaultActions: true});
|
cols.push({label:'serialNoorLotNo' , fieldName:'serialNoorLotNo', hideDefaultActions: true});
|
cols.push({label:'tracingCode' , fieldName:'tracingCodeNo', hideDefaultActions: true});
|
if(this.returnFLGbln){
|
cols.push({label:'返品原因' , fieldName:'ReturnReason', hideDefaultActions: true});
|
}
|
return cols;
|
}
|
//错误明细cols
|
@track errorDetailCols = [
|
{label:'消耗品订单' , fieldName:'consumableOrderMinor', hideDefaultActions: true},
|
{label:'消耗品名称' , fieldName:'prodName', hideDefaultActions: true},
|
{label:'BarCode' , fieldName:'barCode', hideDefaultActions: true},
|
{label:'单位' , fieldName:'boxPiece', hideDefaultActions: true},
|
{label:'数量' , fieldName:'intMark', hideDefaultActions: true},
|
{label:'错误原因' , fieldName:'ErrorReason', hideDefaultActions: true}
|
];
|
|
// 获取参数
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
console.log('CurrentPageReference');
|
if (currentPageReference) {
|
this.arrType = currentPageReference.state?.ArrType;
|
this.eSetId = currentPageReference.state?.ESetId;
|
}
|
}
|
|
get showOrderDetail(){
|
if(this.eSetId != '' && this.eSetId != null){
|
return true;
|
}else{
|
return false;
|
}
|
}
|
|
//初始化
|
connectedCallback(){
|
init({arrType:this.arrType, eSetId:this.eSetId})
|
.then(result=>{
|
this.arrController = result.arrGoodCon;
|
console.log("this.arrController:"+this.arrController);
|
if(result.result == 'Success'){
|
this.saveFLGbln = result.saveFLGbln;
|
this.returnFLGbln = result.returnFLGbln;
|
this.coc = result.coc;
|
this.cocId = result.coc.Id;
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
this.showSpinner = false;
|
this.showPage = true;
|
}else{
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
this.showSpinner = false;
|
this.showPage = true;
|
console.log("error:"+result.errorMsg);
|
this.showMyToast('初始化页面失败',result.errorMsg,'error');
|
}
|
})
|
.catch(error=>{
|
this.showSpinner = false;
|
this.showPage = true;
|
console.log("error:"+error);
|
this.showMyToast('初始化页面失败',error,'error');
|
})
|
}
|
|
//barcode change
|
barcodeChange(event){
|
this.barcode = event.detail.value;
|
}
|
|
//根据barcode搜索
|
barcodeEntrys(){
|
this.showSpinner = true;
|
searchProduct({
|
barcode : this.barcode,
|
arrControllerStr : this.arrController
|
})
|
.then(result=>{
|
this.arrController = result.arrGoodCon;
|
if(result.result == 'Success'){
|
this.saveFLGbln = result.saveFLGbln;
|
this.returnFLGbln = result.returnFLGbln;
|
this.coc = result.coc;
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
this.detailsSummary = result.detailsSummary;
|
for(var i in this.detailsSummary){
|
if(this.detailsSummary[i].Prod != null){
|
this.detailsSummary[i]['recordId'] = this.detailsSummary[i].Prod.Id;
|
this.detailsSummary[i]['assetModelNo'] = this.detailsSummary[i].Prod.Asset_Model_No__c;
|
this.detailsSummary[i]['prodName'] = this.detailsSummary[i].Prod.Name__c;
|
console.log('this.detailsSummary:'+this.detailsSummary[i]['recordId']+'---'+this.detailsSummary[i]['prodName']);
|
}
|
}
|
console.log('this.detailsSummary:'+JSON.stringify(this.detailsSummary));
|
this.consumableorderdetailsRecords = result.consumableorderdetailsRecords;
|
for(var i in this.consumableorderdetailsRecords){
|
if(this.consumableorderdetailsRecords[i].Prod != null){
|
this.consumableorderdetailsRecords[i]['recordId'] = this.consumableorderdetailsRecords[i].Prod.Id;
|
this.consumableorderdetailsRecords[i]['prodName'] = this.consumableorderdetailsRecords[i].Prod.Name__c;
|
}
|
if(this.consumableorderdetailsRecords[i].esd != null){
|
this.consumableorderdetailsRecords[i]['productPackingListManual'] = this.consumableorderdetailsRecords[i].esd.ProductPacking_list_manual__c;
|
this.consumableorderdetailsRecords[i]['status'] = this.consumableorderdetailsRecords[i].esd.CFDA_Status__c;
|
this.consumableorderdetailsRecords[i]['reportProductApprobation'] = this.consumableorderdetailsRecords[i].esd.Report_Product_Approbation__c;
|
this.consumableorderdetailsRecords[i]['barCode'] = this.consumableorderdetailsRecords[i].esd.Bar_Code__c;
|
}
|
}
|
console.log('this.consumableorderdetailsRecords:'+JSON.stringify(this.consumableorderdetailsRecords));
|
this.showGoodsofReturnList = result.showGoodsofReturnList;
|
for(var i in this.showGoodsofReturnList){
|
if(this.showGoodsofReturnList[i].Prod != null){
|
this.showGoodsofReturnList[i]['recordId'] = this.showGoodsofReturnList[i].Prod.Id;
|
this.showGoodsofReturnList[i]['prodName'] = this.showGoodsofReturnList[i].Prod.Name__c;
|
}
|
if(this.showGoodsofReturnList[i].esd != null){
|
if(this.showGoodsofReturnList[i].esd.Consumable_Shipment_order__c == '' || this.showGoodsofReturnList[i].esd.Consumable_Shipment_order__c == null){
|
this.showGoodsofReturnList[i]['orderUrl'] = '/lexsummonscreat?ESetid='+this.showGoodsofReturnList[i].esd.Consumable_Sale_order__c;
|
this.showGoodsofReturnList[i]['orderNo'] = this.showGoodsofReturnList[i].esd.Consumable_Sale_order__r.Name;
|
}else{
|
this.showGoodsofReturnList[i]['orderUrl'] = '/lexsummonscreat?ESetid='+this.showGoodsofReturnList[i].esd.Consumable_Shipment_order__c;
|
this.showGoodsofReturnList[i]['orderNo'] = this.showGoodsofReturnList[i].esd.Consumable_Shipment_order__r.Name;
|
}
|
this.showGoodsofReturnList[i]['prodOutDate'] = this.showGoodsofReturnList[i].esd.Product_OutDate__c;
|
this.showGoodsofReturnList[i]['summonsForDirctionDet'] = this.showGoodsofReturnList[i].esd.SummonsForDirction_det__c;
|
this.showGoodsofReturnList[i]['hospitalName'] = this.showGoodsofReturnList[i].esd.HospItal_Name__c;
|
this.showGoodsofReturnList[i]['orderDealer'] = this.showGoodsofReturnList[i].esd.Order_Dealer_Info__c;
|
this.showGoodsofReturnList[i]['barCode'] = this.showGoodsofReturnList[i].esd.Bar_Code__c;
|
this.showGoodsofReturnList[i]['sterilizationLimit'] = this.showGoodsofReturnList[i].esd.Sterilization_limit__c;
|
this.showGoodsofReturnList[i]['boxPiece'] = this.showGoodsofReturnList[i].esd.Box_Piece__c;
|
this.showGoodsofReturnList[i]['returnCount'] = this.showGoodsofReturnList[i].esd.Rrturn_count__c;
|
console.log('returnCount:'+this.showGoodsofReturnList[i].esd.Rrturn_count__c);
|
this.showGoodsofReturnList[i]['returnReason'] = this.showGoodsofReturnList[i].esd.Return_reason__c;
|
}
|
}
|
console.log('this.showGoodsofReturnList:'+JSON.stringify(this.showGoodsofReturnList));
|
this.consumableInventory = result.consumableInventory;
|
for(var i in this.consumableInventory){
|
if(this.consumableInventory[i].Prod != null){
|
this.consumableInventory[i]['recordId'] = this.consumableInventory[i].Prod.Id;
|
this.consumableInventory[i]['prodName'] = this.consumableInventory[i].Prod.Name__c;
|
}
|
}
|
console.log('this.consumableInventory:'+JSON.stringify(this.consumableInventory));
|
this.consumableorderdetailsRecordserror = result.consumableorderdetailsRecordserror;
|
for(var i in this.consumableorderdetailsRecordserror){
|
if(this.consumableorderdetailsRecordserror[i].Prod != null){
|
this.consumableorderdetailsRecordserror[i]['recordId'] = this.consumableorderdetailsRecordserror[i].Prod.Id;
|
this.consumableorderdetailsRecordserror[i]['prodName'] = this.consumableorderdetailsRecordserror[i].Prod.Name__c;
|
}
|
if(this.consumableorderdetailsRecordserror[i].esd != null){
|
this.consumableorderdetailsRecordserror[i]['consumableOrderMinor'] = this.consumableorderdetailsRecordserror[i].esd.Consumable_order_minor__c;
|
this.consumableorderdetailsRecordserror[i]['barCode'] = this.consumableorderdetailsRecordserror[i].esd.Bar_Code__c;
|
this.consumableorderdetailsRecordserror[i]['boxPiece'] = this.consumableorderdetailsRecordserror[i].esd.Box_Piece__c;
|
}
|
}
|
console.log('this.consumableorderdetailsRecordserror:'+JSON.stringify(this.consumableorderdetailsRecordserror));
|
this.showSpinner = false;
|
this.showMyToast('获取成功','','success');
|
}else {
|
this.showSpinner = false;
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
console.log("error:"+result.errorMsg);
|
this.showMyToast('获取失败',result.errorMsg,'error');
|
}
|
})
|
.catch(error=>{
|
this.showSpinner = false;
|
console.log("error:"+error);
|
this.showMyToast('搜索失败',error,'error');
|
})
|
}
|
|
//返品数量change
|
returnCountChange(event){
|
var value = event.detail.data.value;
|
var boxPrice = event.detail.data.boxPrice;
|
var recordId = event.detail.data.recordId;
|
console.log("返品数量:"+value+boxPrice+"---"+recordId);
|
var showGood;
|
for(var i in this.showGoodsofReturnList){
|
if(this.showGoodsofReturnList[i]['recordId'] == recordId){
|
if(this.showGoodsofReturnList[i].canEdit){
|
this.showGoodsofReturnList[i].esd.Rrturn_count__c = 1;
|
this.showGoodsofReturnList[i]['returnCount'] = this.showGoodsofReturnList[i].esd.Rrturn_count__c;
|
}else{
|
this.showGoodsofReturnList[i].esd.Rrturn_count__c = value;
|
this.showGoodsofReturnList[i]['returnCount'] = this.showGoodsofReturnList[i].esd.Rrturn_count__c;
|
}
|
}
|
}
|
}
|
|
//返品原因change
|
returnReasonChange(event){
|
var recordId = event.detail.data.recordId;
|
var value = event.detail.data.value;
|
console.log("返品原因:"+value+"---"+recordId);
|
for(var i in this.showGoodsofReturnList){
|
if(this.showGoodsofReturnList[i]['recordId'] == recordId){
|
this.showGoodsofReturnList[i].esd.Return_reason__c = value;
|
this.showGoodsofReturnList[i]['returnReason'] = this.showGoodsofReturnList[i].esd.Return_reason__c;
|
}
|
}
|
}
|
|
// 到货确认
|
arriveGoodsConfim(){
|
this.showSpinner = true;
|
arriveGoodsConfim({arrControllerStr : this.arrController})
|
.then(result=>{
|
this.arrController = result.arrGoodCon;
|
if(result.result == 'Success'){
|
this.showSpinner = false;
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
var url = result.url;
|
const config = {
|
type: 'standard__webPage',
|
attributes: {
|
url: url
|
}
|
};
|
this[NavigationMixin.Navigate](config);
|
}else {
|
this.showSpinner = false;
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
console.log("error1:"+result.errorMsg);
|
this.showMyToast('到货确认失败',result.errorMsg,'error');
|
}
|
})
|
.catch(error=>{
|
this.showSpinner = false;
|
console.log("error2:"+error);
|
this.showMyToast('到货确认失败',error,'error');
|
})
|
}
|
|
// 登录返品
|
updateGoodsOfReturn(){
|
this.showSpinner = true;
|
updateGoodsOfReturn({arrControllerStr : this.arrController,showGoodsofReturnListStr : JSON.stringify(this.showGoodsofReturnList)})
|
.then(result=>{
|
this.showSpinner = false;
|
this.arrController = result.arrGoodCon;
|
if(result.result == 'Success'){
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
var url = result.url;
|
const config = {
|
type: 'standard__webPage',
|
attributes: {
|
url: url
|
}
|
};
|
this[NavigationMixin.Navigate](config);
|
}else {
|
this.showSpinner = false;
|
this.warningMsgs = result.warningMsgList;
|
this.errorMsgs = result.errorMsgList;
|
console.log("error1:"+result.errorMsg);
|
this.showMyToast('登录返品失败',result.errorMsg,'error');
|
}
|
})
|
.catch(error=>{
|
this.showSpinner = false;
|
console.log("error2:"+JSON.stringify(error));
|
this.showMyToast('登录返品失败',error,'error');
|
})
|
}
|
|
showMyToast(title,message,variant){
|
const evt = new ShowToastEvent({
|
title : title,
|
message: message,
|
variant: variant
|
});
|
this.dispatchEvent(evt);
|
}
|
}
|