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';
|
const columns = [
|
{
|
label: '消耗品名称',
|
fieldName: 'Name__c',
|
type: 'Name',
|
sortable: true,
|
cellAttributes: { alignment: 'left' }
|
},
|
{
|
label: '第三分类',
|
fieldName: 'Category3__c',
|
hideDefaultActions: true,
|
sortable: true
|
},
|
{
|
label: '第四分类',
|
fieldName: 'Category4__c',
|
hideDefaultActions: true,
|
sortable: true
|
},
|
{
|
label: '第五分类',
|
fieldName: 'Category5__c',
|
hideDefaultActions: true
|
},
|
|
{
|
label: '规格',
|
fieldName: 'packing_list',
|
hideDefaultActions: true,
|
initialWidth: 100
|
},
|
{
|
label: '单位',
|
fieldName: 'BoxPiece',
|
hideDefaultActions: true,
|
initialWidth: 100
|
},
|
{
|
label: '注册证编码号',
|
fieldName: 'approbation_No',
|
hideDefaultActions: true,
|
initialWidth: 100
|
},
|
{
|
label: '注册有效期',
|
fieldName: 'expiration_Date',
|
hideDefaultActions: true,
|
initialWidth: 150
|
},
|
{
|
label: 'CFDA状态',
|
fieldName: 'SFDA_Status__c',
|
hideDefaultActions: true
|
},
|
{
|
label: '使用期限',
|
fieldName: 'guaranteeperiod',
|
hideDefaultActions: true
|
},
|
{
|
label: '有效期内库存',
|
fieldName: 'limitCount',
|
hideDefaultActions: true,
|
sortable: true
|
},
|
{
|
label: '过期库存',
|
fieldName: 'overlimitCount',
|
hideDefaultActions: true
|
}
|
];
|
|
export default class LexinventoryViewLWC extends 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 optionscatone = [];
|
@track options2 = [];
|
@track options3 = [];
|
|
columns = columns;
|
defaultSortDirection = 'asc';
|
sortDirection = 'asc';
|
sortedBy;
|
|
// 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.optionscatone = 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;
|
for (var key in result.entity.category5OptionMap) {
|
let object = {};
|
object['label'] = result.entity.category5OptionMap[key];
|
object['value'] = key;
|
this.options3.push(object);
|
}
|
|
console.log(' this.data=====>' + this.data);
|
|
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: '解析失败',
|
message: result.errorMsg,
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
}
|
})
|
.catch((error) => {
|
console.log('error = ' + JSON.stringify(error));
|
});
|
}
|
|
get options2() {
|
return this.options2;
|
}
|
get options3() {
|
return this.options3;
|
}
|
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;
|
} else {
|
this.rowNumberOffset = 0;
|
}
|
}
|
|
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;
|
console.log('进入搜索11111111111111');
|
console.log('进入搜索');
|
console.log('this.Name = ' + this.Name);
|
searchOrder({
|
category1: this.Name,
|
Category3: this.CategoryThree,
|
Category4: '',
|
Category5: '',
|
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));
|
if (result.status == 'Success') {
|
const evt = new ShowToastEvent({
|
title: '搜索成功',
|
message: result.msg,
|
variant: 'Success'
|
});
|
this.dispatchEvent(evt);
|
this.pageRecords = 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));
|
});
|
}
|
inventoryCount() {
|
console.log('111库存盘点');
|
this[NavigationMixin.Navigate]({
|
type: 'standard__webPage',
|
attributes: {
|
url: '/lexInventoryCount'
|
}
|
});
|
}
|
clearAll() {
|
this.Name = '';
|
this.value = '无';
|
this.template.querySelectorAll('lightning-combobox').forEach((each) => {
|
each.value = null;
|
});
|
}
|
}
|