import { LightningElement,wire,track,api} from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import print from '@salesforce/apex/NewPaymentPlanLoadLWCController.print';
|
import init from '@salesforce/apex/NewPaymentPlanLoadLWCController.init';
|
import save from '@salesforce/apex/NewPaymentPlanLoadLWCController.save';
|
|
export default class newPaymentPlanLoadLWC extends LightningElement {
|
@api recordId;
|
PageMCEElement = {
|
Id: '',
|
Phone_Number__c: '',
|
Status__c: '',
|
old_Is_RecognitionModel__c: '',
|
Engineer_Name__c: '',
|
Is_Standard_Contract__c: '',
|
Term_Of_Payment__c: '',
|
one_off_payment_agreed_period__c: '',
|
Total_Payment_Time__c: '',
|
Payment_Plan_Date_First__c: '',
|
Payment_Plan_Date_Second__c: '',
|
Payment_Plan_Date_Third__c: '',
|
Payment_Plan_Date_Forth__c: '',
|
Payment_Plan_Date_Fivth__c: '',
|
Payment_Plan_Date_Sixth__c: '',
|
Payment_Plan_Sum_First__c: '',
|
Payment_Plan_Sum_Second__c: '',
|
Payment_Plan_Sum_Third__c: '',
|
Payment_Plan_Sum_Forth__c: '',
|
Payment_Plan_Sum_Fivth__c: '',
|
Payment_Plan_Sum_Sixth__c: '',
|
Small_Repair_Time__c: '',
|
Big_Repair_Time__c: '',
|
Live_Technical_Support_Time__c: '',
|
Tour_Check__c: '',
|
Dedust__c: '',
|
First_Party_Contract_Number__c: '',
|
Second_Party_Contract_Number__c: '',
|
Contract_Amount__c: '',
|
Total_Contract_Amount_In_Words__c: '',
|
Payment_Plan_Sum_First_in_Word__c: '',
|
Payment_Plan_Sum_Second_in_Word__c: '',
|
Payment_Plan_Sum_Third_in_Word__c: '',
|
Payment_Plan_Sum_Forth_in_Word__c: '',
|
Payment_Plan_Sum_Fivth_in_Word__c: '',
|
Payment_Plan_Sum_Sixth_in_Word__c: '',
|
Negotiate_Mean__c: '',
|
Amount_Warranty_Coverage_In_Word__c: '',
|
Amount_Warranty_Coverage__c: '',
|
Inspection_Time__c :''
|
};
|
printContract;
|
printAgent;
|
agreeUpperLimit;
|
ContractAllMonth;
|
statusSave;
|
activeSections = ['paymentPlan', 'TextInformation'];
|
showTabOne = true;
|
showTabTwice = false;
|
showTabOnce = true;
|
// 页面disable
|
dis1;
|
dis2;
|
dis3;
|
dis4;
|
dis5;
|
dis6;
|
dis7;
|
dis8;
|
dis9;
|
dis10;
|
dis11;
|
dis12;
|
dis13;
|
dis14;
|
dis15;
|
dis16;
|
dis17;
|
dis18;
|
dis19;
|
dis21;
|
dis22;
|
dis23;
|
dis24;
|
dis25;
|
dis26;
|
dis27;
|
dis28;
|
dis29;
|
dis30;
|
//是否为标准合同
|
get IsStandardContractoptions() {
|
return[{ label: '--无--', value: '' },
|
{ label: '是', value: '是' },
|
{ label: '否', value: '否' }];
|
}
|
|
// 付款方式
|
TermOfPaymentoptions = [{ label: '一次性付款', value: '一次性付款' },
|
{ label: '多次付款', value: '多次付款' }];
|
|
//一次性付款
|
oneoffpaymentagreedperiodOptions = [{ label: '15', value: '15' },
|
{ label: '30', value: '30' },
|
{ label: '60', value: '60' }];
|
//多次付款
|
TotalPaymentTimeOption = [
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' },
|
{ label: '5', value: '5' },
|
{ label: '6', value: '6' }];
|
//小修理时限:
|
SmallRepairTimeOptions = [{ label: '5', value: '5' },
|
{ label: '7', value: '7' },
|
{ label: '10', value: '10' }];
|
//大修理时限:
|
BigRepairTimeOptions = [{ label: '7', value: '7' },
|
{ label: '10', value: '10' },
|
{ label: '15', value: '15' },
|
{ label: '20', value: '20' },
|
{ label: '25', value: '25' },
|
{ label: '30', value: '30' }];
|
//现场技术支持时限:
|
LiveTechnicalSupportTimeOptions = [{ label: '24', value: '24' },
|
{ label: '48', value: '48' },
|
{ label: '72', value: '72' }];
|
//巡回:
|
TourCheckOptions = [{ label: '0', value: '0' },
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' }];
|
//点检1
|
InspectionTimeOptions = [
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' }];
|
|
//除尘
|
DedustOptions = [{ label: '0', value: '0' },
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' }];
|
//合同份数:甲方:
|
FirstPartyContractNumberOptions = [
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' },
|
{ label: '5', value: '5' },
|
{ label: '6', value: '6' },
|
{ label: '7', value: '7' },
|
{ label: '8', value: '8' },
|
{ label: '9', value: '9' },
|
{ label: '10', value: '10' }];
|
//合同份数:乙方:
|
SecondPartyContractNumberOptions = [
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' },
|
{ label: '5', value: '5' },
|
{ label: '6', value: '6' },
|
{ label: '7', value: '7' },
|
{ label: '8', value: '8' },
|
{ label: '9', value: '9' },
|
{ label: '10', value: '10' }];
|
// 协商方式
|
NegotiateMeanOptions = [
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' }];
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback(){
|
this.recordId = 'a0H1000001DV1cp';
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
if (result.PageMCE == null) {
|
const event = new ShowToastEvent({
|
title: 'warning',
|
message: result.status,
|
variant:'warning',
|
});
|
this.dispatchEvent(event);
|
}
|
this.PageMCEElement.Status__c = result.PageMCE.Status__c;
|
this.ContractAllMonth = result.Contract_validMonth;
|
this.statusSave = result.statusSave;
|
this.PageMCEElement.old_Is_RecognitionModel__c = result.PageMCE.old_Is_RecognitionModel__c;
|
this.PageMCEElement.Engineer_Name__c = result.PageMCE.Engineer_Name__c;
|
this.PageMCEElement.Is_Standard_Contract__c = result.PageMCE.Is_Standard_Contract__c;
|
this.PageMCEElement.Term_Of_Payment__c = result.PageMCE.Term_Of_Payment__c;
|
this.PageMCEElement.one_off_payment_agreed_period__c = result.PageMCE.one_off_payment_agreed_period__c;
|
this.PageMCEElement.Total_Payment_Time__c = result.PageMCE.Total_Payment_Time__c;
|
this.PageMCEElement.Payment_Plan_Date_First__c = result.PageMCE.Payment_Plan_Date_First__c;
|
this.PageMCEElement.Payment_Plan_Date_Second__c = result.PageMCE.Payment_Plan_Date_Second__c;
|
this.PageMCEElement.Payment_Plan_Date_Third__c = result.PageMCE.Payment_Plan_Date_Third__c;
|
this.PageMCEElement.Payment_Plan_Date_Forth__c = result.PageMCE.Payment_Plan_Date_Forth__c;
|
this.PageMCEElement.Payment_Plan_Date_Fivth__c = result.PageMCE.Payment_Plan_Date_Fivth__c;
|
this.PageMCEElement.Payment_Plan_Date_Sixth__c = result.PageMCE.Payment_Plan_Date_Sixth__c;
|
this.PageMCEElement.Payment_Plan_Sum_First__c = result.PageMCE.Payment_Plan_Sum_First__c;
|
this.PageMCEElement.Payment_Plan_Sum_Second__c = result.PageMCE.Payment_Plan_Sum_Second__c;
|
this.PageMCEElement.Payment_Plan_Sum_Third__c = result.PageMCE.Payment_Plan_Sum_Third__c;
|
this.PageMCEElement.Payment_Plan_Sum_Forth__c = result.PageMCE.Payment_Plan_Sum_Forth__c;
|
this.PageMCEElement.Payment_Plan_Sum_Fivth__c = result.PageMCE.Payment_Plan_Sum_Fivth__c;
|
this.PageMCEElement.Payment_Plan_Sum_Sixth__c = result.PageMCE.Payment_Plan_Sum_Sixth__c;
|
this.PageMCEElement.Small_Repair_Time__c = result.PageMCE.Small_Repair_Time__c;
|
this.PageMCEElement.Big_Repair_Time__c = result.PageMCE.Big_Repair_Time__c;
|
this.PageMCEElement.Live_Technical_Support_Time__c = result.PageMCE.Live_Technical_Support_Time__c;
|
this.PageMCEElement.Tour_Check__c = result.PageMCE.Tour_Check__c;
|
this.PageMCEElement.Phone_Number__c = result.PageMCE.Phone_Number__c;
|
this.PageMCEElement.Dedust__c = result.PageMCE.Dedust__c;
|
this.PageMCEElement.First_Party_Contract_Number__c = result.PageMCE.First_Party_Contract_Number__c;
|
this.PageMCEElement.Second_Party_Contract_Number__c = result.PageMCE.Second_Party_Contract_Number__c;
|
this.PageMCEElement.Contract_Amount__c = result.PageMCE.Contract_Amount__c;
|
this.PageMCEElement.Total_Contract_Amount_In_Words__c = result.PageMCE.Total_Contract_Amount_In_Words__c;
|
this.PageMCEElement.Payment_Plan_Sum_First_in_Word__c = result.PageMCE.Payment_Plan_Sum_First_in_Word__c;
|
this.PageMCEElement.Payment_Plan_Sum_Second_in_Word__c = result.PageMCE.Payment_Plan_Sum_Second_in_Word__c;
|
this.PageMCEElement.Payment_Plan_Sum_Third_in_Word__c = result.PageMCE.Payment_Plan_Sum_Third_in_Word__c;
|
this.PageMCEElement.Payment_Plan_Sum_Forth_in_Word__c = result.PageMCE.Payment_Plan_Sum_Forth_in_Word__c;
|
this.PageMCEElement.Payment_Plan_Sum_Fivth_in_Word__c = result.PageMCE.Payment_Plan_Sum_Fivth_in_Word__c;
|
this.PageMCEElement.Payment_Plan_Sum_Sixth_in_Word__c = result.PageMCE.Payment_Plan_Sum_Sixth_in_Word__c;
|
this.PageMCEElement.Negotiate_Mean__c = result.PageMCE.Negotiate_Mean__c;
|
this.PageMCEElement.Inspection_Time__c = result.PageMCE.Inspection_Time__c;
|
this.PageMCEElement.Amount_Warranty_Coverage__c = (result.PageMCE.Contract_Amount__c*1.3).toString();
|
this.PageMCEElement.Amount_Warranty_Coverage_In_Word__c = this.smalltoBIG(this.PageMCEElement.Amount_Warranty_Coverage__c);
|
this.AllChecktime();
|
this.Initdisabled();
|
}).catch(error => {
|
console.log("error");
|
console.log(error.message());
|
});
|
}
|
handleIsStandardContract(event) {
|
console.log('执行');
|
this.PageMCEElement.Is_Standard_Contract__c = event.detail.value;
|
if (this.PageMCEElement.Is_Standard_Contract__c == '否') {
|
this.showTabOne = false;
|
}else{
|
this.showTabOne = true;
|
}
|
this.AllChecktime();
|
}
|
handleTermOfPayment(event) {
|
this.PageMCEElement.Term_Of_Payment__c = event.detail.value;
|
if (this.PageMCEElement.Term_Of_Payment__c == '多次付款') {
|
this.showTabOnce = false;
|
this.showTabTwice = true;
|
}else{
|
this.showTabOnce = true;
|
this.showTabTwice = false;
|
}
|
}
|
handleOneoff(event) {
|
this.PageMCEElement.one_off_payment_agreed_period__c = event.detail.value;
|
}
|
handleSmallRepairTime(event) {
|
this.PageMCEElement.Small_Repair_Time__c = event.detail.value;
|
}
|
handleBigRepairTime(event) {
|
this.PageMCEElement.Big_Repair_Time__c = event.detail.value;
|
}
|
handleLiveTechnicalSupportTime(event) {
|
this.PageMCEElement.Live_Technical_Support_Time__c = event.detail.value;
|
}
|
handleTourCheck(event) {
|
this.PageMCEElement.Tour_Check__c = event.detail.value;
|
}
|
handleInspectionTime(event) {
|
this.PageMCEElement.Inspection_Time__c = event.detail.value;
|
this.AllChecktime();
|
}
|
handleDedust(event) {
|
this.PageMCEElement.Dedust__c = event.detail.value;
|
}
|
handleFirstPartyContractNumber(event) {
|
this.PageMCEElement.First_Party_Contract_Number__c = event.detail.value;
|
}
|
handleSecondPartyContractNumber(event) {
|
this.PageMCEElement.Second_Party_Contract_Number__c = event.detail.value;
|
}
|
|
handleTotalPaymentTime(event) {
|
this.PageMCEElement.Total_Payment_Time__c = event.detail.value;
|
}
|
// 多次付款列
|
handleDateFirst(event){
|
this.PageMCEElement.Payment_Plan_Date_First__c = event.detail.value;
|
}
|
handleDateSecond(event){
|
this.PageMCEElement.Payment_Plan_Date_Second__c = event.detail.value;
|
}
|
handleDateThird(event){
|
this.PageMCEElement.Payment_Plan_Date_Third__c = event.detail.value;
|
}
|
handleDateForth(event){
|
this.PageMCEElement.Payment_Plan_Date_Forth__c = event.detail.value;
|
}
|
handleDateFivth(event){
|
this.PageMCEElement.Payment_Plan_Date_Fivth__c = event.detail.value;
|
}
|
handleDateSixth(event){
|
this.PageMCEElement.Payment_Plan_Date_Sixth__c = event.detail.value;
|
}
|
handleSumFirst(event){
|
this.PageMCEElement.Payment_Plan_Sum_First__c = event.detail.value;
|
this.PageMCEElement.Payment_Plan_Sum_First_in_Word__c = this.smalltoBIG(this.PageMCEElement.Payment_Plan_Sum_First__c);
|
}
|
handleSumSecond(event){
|
this.PageMCEElement.Payment_Plan_Sum_Second__c = event.detail.value;
|
this.PageMCEElement.Payment_Plan_Sum_Second_in_Word__c = this.smalltoBIG(this.PageMCEElement.Payment_Plan_Sum_Second__c);
|
}
|
handleSumThird(event){
|
this.PageMCEElement.Payment_Plan_Sum_Third__c = event.detail.value;
|
this.PageMCEElement.Payment_Plan_Sum_Third_in_Word__c = this.smalltoBIG(this.PageMCEElement.Payment_Plan_Sum_Third__c);
|
}
|
handleSumForth(event){
|
this.PageMCEElement.Payment_Plan_Sum_Forth__c = event.detail.value;
|
this.PageMCEElement.Payment_Plan_Sum_Forth_in_Word__c = this.smalltoBIG(this.PageMCEElement.Payment_Plan_Sum_Forth__c);
|
}
|
handleSumFivth(event){
|
this.PageMCEElement.Payment_Plan_Sum_Fivth__c = event.detail.value;
|
this.PageMCEElement.Payment_Plan_Sum_Fivth_in_Word__c = this.smalltoBIG(this.PageMCEElement.Payment_Plan_Sum_Fivth__c);
|
}
|
handleSumSixth(event){
|
this.PageMCEElement.Payment_Plan_Sum_Sixth__c = event.detail.value;
|
this.PageMCEElement.Payment_Plan_Sum_Sixth_in_Word__c = this.smalltoBIG(this.PageMCEElement.Payment_Plan_Sum_Sixth__c);
|
}
|
handleNegotiateMean(event){
|
this.PageMCEElement.Negotiate_Mean__c = event.detail.value;
|
}
|
handleEngineerName(event){
|
this.PageMCEElement.Engineer_Name__c = event.detail.value;
|
}
|
handlephoneNumber(event){
|
// this.phoneNumber = event.detail.value;
|
this.PageMCEElement.Phone_Number__c = event.detail.value;
|
}
|
handlePrint(event){
|
print().then(result =>{
|
this.printContract = result.printContract;
|
this.printAgent = result.printAgent;
|
this.agreeUpperLimit = result.agreeUpperLimit;
|
if (result.statusSave == 'Denied') {
|
const event = new ShowToastEvent({
|
title: 'warning',
|
message: result.status,
|
variant:'warning',
|
});
|
this.dispatchEvent(event);
|
}
|
}).catch(error => {
|
console.log("error");
|
console.log(error.message());
|
});;
|
}
|
handlesave(event){
|
|
save({
|
PageMCEElement:this.PageMCEElement
|
}).then(result =>{
|
if (result.statusSave == 'Denied') {
|
const event = new ShowToastEvent({
|
title: 'warning',
|
message: result.status,
|
variant:'warning',
|
});
|
this.dispatchEvent(event);
|
}
|
}).catch(error => {
|
console.log("error"+error.message());
|
});
|
}
|
|
|
/** 数字金额大写转换(可以处理整数,小数,负数) */
|
smalltoBIG(n)
|
{
|
|
var fraction = ['角', '分'];
|
var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟'] ];
|
var head = n < 0? '欠': '';
|
n = n.replace(/\,/g,"");
|
n = Math.abs(n);
|
var s = '';
|
for (var i = 0; i < fraction.length; i++){
|
s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
|
}
|
s = s || '整';
|
n = Math.floor(n);
|
for (var i = 0; i < unit[0].length && n > 0; i++) {
|
var p = '';
|
for (var j = 0; j < unit[1].length && n > 0; j++) {
|
p = digit[n % 10] + unit[1][j] + p;
|
n = Math.floor(n / 10);
|
}
|
s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
|
}
|
return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');
|
}
|
Initdisabled(){
|
if(this.PageMCEElement.Status__c != '引合中'){
|
this.dis1 = true;
|
this.dis2 = true;
|
this.dis3 = true;
|
this.dis4 = true;
|
this.dis5 = true;
|
this.dis6 = true;
|
this.dis7 = true;
|
this.dis8 = true;
|
this.dis9 = true;
|
this.dis10 = true;
|
this.dis11 = true;
|
this.dis12 = true;
|
this.dis13 = true;
|
this.dis14 = true;
|
this.dis15 = true;
|
this.dis16 = true;
|
this.dis17 = true;
|
this.dis18 = true;
|
this.dis19 = true;
|
this.dis20 = true;
|
this.dis21 = true;
|
this.dis22 = true;
|
this.dis23 = true;
|
this.dis24 = true;
|
this.dis25 = true;
|
this.dis26 = true;
|
this.dis27 = true;
|
this.dis28 = true;
|
this.dis29 = true;
|
this.dis30 = true;
|
}
|
if (this.PageMCEElement.old_Is_RecognitionModel__c == 'true' && this.PageMCEElement.Term_Of_Payment__c == '多次付款') {
|
this.dis28 = true;
|
}
|
}
|
|
CloseJs() {
|
if(this.statusSave == 'Fin'){
|
window.opener.top.location.href = '/'+this.recordId;
|
window.close();
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
|
// 新增点检总次数(只在页面中显示)fxk 2021/9/2 Star
|
AllChecktime(){
|
var Allchecks;
|
if(( this.PageMCEElement.Inspection_Time__c == '1' && this.ContractAllMonth < 9)
|
|| ( this.PageMCEElement.Inspection_Time__c == '2' && this.ContractAllMonth < 6)
|
|| ( this.PageMCEElement.Inspection_Time__c == '3' && this.ContractAllMonth < 4)
|
|| ( this.PageMCEElement.Inspection_Time__c == '4' && this.ContractAllMonth < 3)){
|
Allchecks = '1';
|
}else{
|
if (this.ContractAllMonth - parseInt(this.ContractAllMonth / 12) * 12 >= 6 && this.PageMCEElement.Inspection_Time__c == '1'){
|
Allchecks = ((this.ContractAllMonth * Number( this.PageMCEElement.Inspection_Time__c))/12+1).toString();
|
}else{
|
Allchecks =((this.ContractAllMonth * Number( this.PageMCEElement.Inspection_Time__c))/12).toString();
|
}
|
}
|
if (Allchecks!=null) {
|
this.PageMCEElement.Inspection_Time__c = Allchecks;
|
}
|
}
|
|
|
PrintJs() {
|
if(this.statusSave == 'Fin'){
|
this.dispatchEvent(new CloseActionScreenEvent());
|
if (this.printContract == 'true') {
|
//HWAG-BHT7XX 2019/11/26 START
|
if(this.agreeUpperLimit == 'true'){
|
// 打印医院限次合同配置
|
window.open('/apex/NewMCHPDFLimit?id='+this.recordId, 'MCHLimitPDF');
|
window.close();
|
}else{
|
// 打印医院合同配置
|
window.open('/apex/NewMCHPDF?id='+this.recordId, 'MCHPDF');
|
window.close();
|
}
|
//HWAG-BHT7XX 2019/11/26 END
|
}else if (this.printAgent == 'true') {
|
if(this.agreeUpperLimit == 'true'){
|
//打印经销商限次合同
|
window.open('/apex/NewMCAgentPDFLimit?id='+this.recordId, 'MCAgentLimitPDF');
|
window.close()
|
}else{
|
//打印经销商合同
|
window.open('/apex/NewMCAgentPDF?id='+this.recordId, 'MCHPDF');
|
window.close();
|
}
|
}else {
|
alert('1');
|
}
|
}else{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
|
|
}
|