/*
|
* @Description:
|
* @version:
|
* @Author: chen jing wu
|
* @Date: 2023-04-20 15:04:03
|
* @LastEditors: chen jing wu
|
* @LastEditTime: 2023-04-23 16:57:18
|
*/
|
/*
|
* @Description:
|
* @version:
|
* @Author: chen jing wu
|
* @Date: 2023-04-20 15:04:03
|
* @LastEditors: chen jing wu
|
* @LastEditTime: 2023-04-20 17:11:01
|
*/
|
import { api, wire,LightningElement } from 'lwc';
|
import save from '@salesforce/apex/lexPCLLostReportLwcController.save';
|
import jquery from '@salesforce/resourceUrl/jquery183minjs';
|
import blockUIcss from '@salesforce/resourceUrl/blockUIcss';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
|
import setBrand from '@salesforce/apex/lexPCLLostReportLwcController.setBrand';
|
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
|
import initForApex from '@salesforce/apex/lexPCLLostReportLwcController.initForApex';
|
export default class LexPCLLostReportPage extends LightningElement {
|
@api oppId;
|
@api lostReportId;
|
@api pageStatus;
|
@api lostType;
|
@api submitFlag;
|
brandCount;
|
constructor() {
|
super();
|
|
// Set the default values for properties using ternary operators
|
this.oppId = this.getParamValue('oppId') || '';
|
this.lostReportId = this.getParamValue('Id') || '';
|
this.pageStatus = this.getParamValue('pageStatus') || '';
|
this.lostType = this.getParamValue('lostType') || '';
|
this.submitFlag = this.getParamValue('submitFlag') || '';
|
}
|
connectedCallback(){
|
|
}
|
|
getParamValue(paramName) {
|
// Use the URLSearchParams API to get the value of a query parameter
|
const params = new URLSearchParams(window.location.search);
|
return params.get(paramName);
|
}
|
saveJs() {
|
this.blockMyself();
|
save();
|
}
|
addBrandJs() {
|
this.blockMyself();
|
addBrand();
|
}
|
submitJS() {
|
this.blockMyself();
|
submit();
|
}
|
addProductJs(number) {
|
this.blockMyself();
|
addProduct(number);
|
}
|
RemoveJs(number) {
|
this.blockMyself();
|
Remove(number);
|
}
|
// add tcm 20211118 start
|
searchJs(topNum, secondNum) {
|
this.blockMyself();
|
search(topNum, secondNum);
|
}
|
blockMyself(){
|
Promise.all([
|
loadScript(this,PleaseWaitDialog),
|
loadStyle(this,blockUIcss),
|
loadScript(this, jquery)
|
//loadScript(this, jq + "/dist/jquery.min.js")
|
]).then(() =>{
|
blockme();
|
}).catch(error => {
|
console.log("321");
|
console.log('Failed to load the JQuery : ' +error);
|
});
|
}
|
|
// add tcm 20211118 end
|
setLostTotalAmount() {
|
//console.log('setLostTotalAmount start:');
|
var totalAmount = this.template.querySelector('[data-id="LostTotalAmount"]');
|
var totalAmountHidden = this.template.querySelector('[data-id="LostTotalAmountHidden"]');
|
var brandAmountObjects = this.template.querySelectorAll('[data-id^="BrandContent:LostPriceOut"]');
|
var brandCompanyObjects = this.template.querySelectorAll('[data-id^="BrandContent:Lost_By_CompanyOut"]');
|
if (!!totalAmount && !!totalAmountHidden) {
|
var tempLostAmount = 0.0;
|
var brandCount = parseInt(this.brandCount);
|
//console.log(brandCount);
|
|
for (var i = 0; i < brandCount; i++) {
|
var brandAmountObject = brandAmountObjects[i];
|
var brandCompanyObject = brandCompanyObjects[i];
|
|
if (!!brandAmountObject && !!brandCompanyObject) {
|
var brandCompanyText = brandCompanyObject.innerText;
|
var brandCompanyValue = brandCompanyObject.value;
|
|
if (!!brandCompanyText && brandCompanyText !== '--无--' && !!brandCompanyValue) {
|
var brandAmount = parseFloat(brandAmountObject.value);
|
tempLostAmount = tempLostAmount + brandAmount;
|
}
|
}
|
}
|
totalAmount.innerHTML = toNumComma(tempLostAmount);
|
totalAmountHidden.value = tempLostAmount;
|
}
|
//console.log('setLostTotalAmount end');
|
}
|
setBrandName(brandNumber) {
|
this.blockMyself();
|
setbrand(brandNumber);
|
}
|
setBrandMannualName(brandNumber) {
|
this.blockMyself();
|
setbrandmannual(brandNumber);
|
}
|
// 失单品牌不等于其他时,失单品牌(手动)清空并且不允许填写,失单品牌等于其他时,失单对手型号不可用 thh 2022-01-13 start
|
clearBrandMannualName(){
|
if (this.template.querySelector('[id$="Lost_By_CompanyOut"]').value === '其他') {
|
this.template.querySelector('[id$="LostProduct"]').setAttribute('disabled', true);
|
} else {
|
this.template.querySelector('[id$="Lost_By_Company_MannualOut:Lost_By_Company_Mannual"]').value = '';
|
this.template.querySelector('[id$="Lost_By_Company_MannualOut:Lost_By_Company_Mannual"]').setAttribute('disabled', true);
|
}
|
}
|
cancel() {
|
// Navigate to the specified opportunity page using the NavigationMixin
|
this[NavigationMixin.Navigate]({
|
type: 'standard__recordPage',
|
attributes: {
|
recordId: this.oppId,
|
actionName: 'view'
|
}
|
});
|
}
|
}
|