import { LightningElement, track, wire, api } from 'lwc';
|
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
|
import initData from '@salesforce/apex/LexPaymentPlanLoadController.initData';
|
|
export default class lexPaymentPlanLoad extends LightningElement {
|
|
|
Term_Of_Payment = "一次性付款";
|
Is_Standard_Contract_Options = [{ label: '--无--', value: '' },
|
{ label: '是', value: '是' },
|
{ label: '否', value: '否' }];
|
|
Term_Of_Payment_Options = [{ label: '一次性付款', value: '一次性付款' },
|
{ label: '多次付款', value: '多次付款' }];
|
|
one_off_payment_agreed_period_options = [{ label: '15', value: '15' },
|
{ label: '30', value: '30' },
|
{ label: '60', value: '60' },
|
{ label: '90', value: '90' }];
|
|
Total_Payment_Time_Options = [{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' },
|
{ label: '5', value: '5' },
|
{ label: '6', value: '6' }];
|
|
Small_Repair_Time_Options = [{ label: '24', value: '24' },
|
{ label: '48', value: '48' },
|
{ label: '72', value: '72' }];
|
|
Big_Repair_Time_Options = [{ label: '7', value: '7' },
|
{ label: '10', value: '10' },
|
{ label: '15', value: '15' },
|
{ label: '20', value: '20' },
|
{ label: '25', value: '25' },
|
{ label: '30', value: '30' }];
|
|
Tour_Check_Options = [{ label: '0', value: '0' },
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' },
|
{ label: '3', value: '3' },
|
{ label: '4', value: '4' }];
|
|
Dedust_Options = [{ label: '0', value: '0' },
|
{ label: '1', value: '1' },
|
{ label: '2', value: '2' }];
|
|
First_Party_Contract_Number_Options = [{ 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'}];
|
|
Negotiate_Mean_Options = [{ label: '1', value: '1' },
|
{ label: '2', value: '2' }] ;
|
activeSections = ['paymentPlan', 'textInfo'];
|
|
tabPaymentPlan = true;
|
tabTextInfo = false;
|
payOnce = true;
|
payTwince = false;
|
//是否是"引合中"
|
statusDisable = false;
|
|
Payment_Plan_Sum_1_in_Word;
|
Payment_Plan_Sum_2_in_Word;
|
Payment_Plan_Sum_3_in_Word;
|
Payment_Plan_Sum_4_in_Word;
|
Payment_Plan_Sum_5_in_Word;
|
Payment_Plan_Sum_6_in_Word;
|
|
|
@api recordId;
|
|
|
@track PageMCEElement = {};
|
|
|
IsLoading=true;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
console.log(currentPageReference);
|
|
if(currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if(urlValue) {
|
let str = `${urlValue}`;
|
console.log("str");
|
console.log(str);
|
this.recordId = str;
|
|
}
|
}
|
|
}
|
|
connectedCallback() {
|
this.recordId = 'a0H0l000008onsq';
|
console.log('this.recordId:' + this.recordId);
|
initData({
|
recordId : this.recordId
|
}).then(result => {
|
console.log("initPageResult:");
|
console.log(result);
|
if (result.PageMCEElement == null) {
|
const event = new ShowToastEvent({
|
title: 'warning',
|
message: result.msg,
|
variant:'warning',
|
});
|
this.dispatchEvent(event);
|
}
|
this.PageMCEElement = result.PageMCEElement;
|
this.statusSave = result.statusSave;
|
|
this.initPages();
|
this.initDisabled();
|
|
console.log(this.PageMCEElement);
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
|
}).catch( error =>{
|
console.log(error);
|
});
|
}
|
|
initPages(){
|
if(!this.Contract_validMonth) {
|
this.Contract_validMonth = parseInt(this.PageMCEElement.Contract_Range__c);
|
}
|
|
if(!this.PageMCEElement.Is_Standard_Contract__c) {
|
this.PageMCEElement.Is_Standard_Contract__c = "";
|
}
|
if(!this.PageMCEElement.Term_Of_Payment__c) {
|
this.PageMCEElement.Term_Of_Payment__c="一次性付款";
|
this.payOnce = true;
|
this.payTwince = false;
|
} else if(this.PageMCEElement.Term_Of_Payment__c == "一次性付款") {
|
this.payOnce = true;
|
this.payTwince = false;
|
} else {
|
this.payTwince = true;
|
this.payOnce = false;
|
}
|
|
if(!(this.PageMCEElement.one_off_payment_agreed_period__c) && this.payOnce){
|
this.PageMCEElement.one_off_payment_agreed_period__c = "15";
|
}
|
|
if(!this.PageMCEElement.Total_Payment_Time__c) {
|
this.PageMCEElement.Total_Payment_Time__c = '1';
|
}
|
if(!this.PageMCEElement.Inspection_Time__c) {
|
this.PageMCEElement.Inspection_Time__c = '0';
|
}
|
if(!this.PageMCEElement.Tour_Check__c) {
|
this.PageMCEElement.Tour_Check__c = '0';
|
}
|
if(!this.PageMCEElement.Dedust__c) {
|
this.PageMCEElement.Dedust__c = '0';
|
}
|
if(!this.PageMCEElement.First_Party_Contract_Number__c) {
|
this.PageMCEElement.First_Party_Contract_Number__c = '2';
|
}
|
if(!this.PageMCEElement.Second_Party_Contract_Number__c) {
|
this.PageMCEElement.Second_Party_Contract_Number__c = '1';
|
}
|
if(!this.PageMCEElement.Negotiate_Mean__c) {
|
this.PageMCEElement.Negotiate_Mean__c = '1';
|
}
|
}
|
|
initDisabled() {
|
if(this.PageMCEElement.Status__c != '引合中'){
|
this.statusDisable = true;
|
}
|
}
|
//是否标准合同
|
handleIsStandardContract(event) {
|
this.PageMCEElement.Is_Standard_Contract__c = event.detail.value;
|
if (this.PageMCEElement.Is_Standard_Contract__c == '否') {
|
this.tabTextInfo = false;
|
}else{
|
this.tabTextInfo = true;
|
|
}
|
}
|
|
//一次或多次付款
|
handleTermOfPayment(event) {
|
this.PageMCEElement.Term_Of_Payment__c = event.detail.value;
|
if(this.PageMCEElement.Term_Of_Payment__c == '一次性付款') {
|
this.payOnce = true;
|
this.payTwince = false;
|
} else {
|
this.payTwince = true;
|
this.payOnce = false;
|
}
|
|
}
|
|
handleOneoff(event){
|
this.PageMCEElement.one_off_payment_agreed_period__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_Fifth__c = event.detail.value;
|
}
|
handleDateSixth(event){
|
this.PageMCEElement.Payment_Plan_Date_Sixth__c = event.detail.value;
|
}
|
|
|
//多次付款-金额
|
Convert_Amount(event) {
|
let Amount = event.target.value;
|
let plan_name = event.target.name;
|
console.log(Amount)
|
console.log(plan_name)
|
|
if(Amount == null || Amount== undefined || Amount.length == 0)
|
return;
|
let Amount_In_Words = this.smalltoBIG(Amount);
|
if(plan_name =='Payment_Plan_Sum_1') {
|
this.Payment_Plan_Sum_1_in_Word = Amount_In_Words;
|
this.PageMCEElement.Payment_Plan_Sum_First__c = Amount;
|
this.PageMCEElement.Payment_Plan_Sum_First_in_Word__c = Amount_In_Words;
|
} else if(plan_name == 'Payment_Plan_Sum_2') {
|
this.Payment_Plan_Sum_2_in_Word = Amount_In_Words;
|
this.PageMCEElement.Payment_Plan_Sum_Second__c = Amount;
|
this.PageMCEElement.Payment_Plan_Sum_Second_in_Word__c = Amount_In_Words;
|
} else if(plan_name == 'Payment_Plan_Sum_3') {
|
this.Payment_Plan_Sum_3_in_Word = Amount_In_Words;
|
this.PageMCEElement.Payment_Plan_Sum_Third__c = Amount;
|
this.PageMCEElement.Payment_Plan_Sum_Third_in_Word__c = Amount_In_Words;
|
} else if(plan_name == 'Payment_Plan_Sum_4') {
|
this.Payment_Plan_Sum_4_in_Word = Amount_In_Words;
|
this.PageMCEElement.Payment_Plan_Sum_Forth__c = Amount;
|
this.PageMCEElement.Payment_Plan_Sum_Forth_in_Word__c = Amount_In_Words;
|
} else if(plan_name == 'Payment_Plan_Sum_5') {
|
this.Payment_Plan_Sum_5_in_Word = Amount_In_Words;
|
this.PageMCEElement.Payment_Plan_Sum_Fifth__c = Amount;
|
this.PageMCEElement.Payment_Plan_Sum_Fifth_in_Word__c = Amount_In_Words;
|
} else{
|
this.Payment_Plan_Sum_6_in_Word = Amount_In_Words;
|
this.PageMCEElement.Payment_Plan_Sum_Sixth__c = Amount;
|
this.PageMCEElement.Payment_Plan_Sum_Sixth_in_Word__c = Amount_In_Words;
|
}
|
|
// alert(Amount_In_Words);
|
// event.target.name+_in_Word = Amount_In_Words;
|
// var Amount = j$(escapeVfId('allPage:allForm:allBlock:paymentPlan:Payment_Plan_Sum_'+number)).val();
|
// if(Amount == null || Amount== undefined || Amount.length == 0)
|
// return;
|
// var Amount_In_Words = smalltoBIG(Amount);
|
// j$(escapeVfId('allPage:allForm:allBlock:paymentPlan:Payment_Plan_Sum_' + number + '_in_Word')).text(Amount_In_Words);
|
// j$(escapeVfId('allPage:allForm:Payment_Plan_Sum_' + number + '_in_Word_Hidden')).val(Amount_In_Words);
|
// j$(escapeVfId('allPage:allForm:allBlock:paymentPlan:Payment_Plan_Sum_'+number)).val(toNumComma(Amount));
|
}
|
|
|
|
|
|
|
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;
|
}
|
|
handleNegotiateMean(event){
|
this.PageMCEElement.Negotiate_Mean__c = event.detail.value;
|
}
|
// 新增点检总次数(只在页面中显示)fxk 2021/9/2 Star
|
AllChecktime(){
|
var Allchecks;
|
console.log("Contract_validMonth");
|
console.log(this.Contract_validMonth);
|
if((this.PageMCEElement.Inspection_Time__c == '1' && this.Contract_validMonth < 9)
|
|| (this.PageMCEElement.Inspection_Time__c == '2' && this.Contract_validMonth < 6)
|
|| (this.PageMCEElement.Inspection_Time__c == '3' && this.Contract_validMonth < 4)
|
|| (this.PageMCEElement.Inspection_Time__c == '4' && this.Contract_validMonth < 3)){
|
Allchecks = '1';
|
}else{
|
if (this.ContractAllMonth - parseInt(this.Contract_validMonth / 12) * 12 >= 6 && this.PageMCEElement.Inspection_Time__c == '1'){
|
Allchecks = ((this.Contract_validMonth * Number(this.PageMCEElement.Inspection_Time__c))/12+1).toString();
|
}else{
|
Allchecks =((this.Contract_validMonth * Number(this.PageMCEElement.Inspection_Time__c))/12).toString();
|
}
|
}
|
console.log(Allchecks);
|
if (Allchecks!=null) {
|
this.PageMCEElement.Contract_Limit_Times__c = Allchecks;
|
}
|
}
|
|
/** 数字金额大写转换(可以处理整数,小数,负数) */
|
smalltoBIG(n){
|
let fraction = ['角', '分'];
|
let digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
let unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟'] ];
|
let head = n < 0? '欠': '';
|
n = n.replace(/\,/g,"");
|
n = Math.abs(n);
|
let s = '';
|
for (let 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 (let i = 0; i < unit[0].length && n > 0; i++) {
|
let p = '';
|
for (let 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(/^整$/, '零元整');
|
}
|
printJs() {
|
var Rs = this.statusSave;
|
console.log(this.statusSave)
|
alert(Rs);
|
if(Rs == 'Fin'){
|
this.dispatchEvent(new CloseActionScreenEvent());
|
if (this.printContract) {
|
// 打印医院合同配置
|
window.open('/apex/MCHPDF?id='+this.recordId, 'MCHPDF');
|
}else if (this.printAgent) {
|
//打印经销商合同
|
window.open('/apex/MCAgentPDF?id='+this.recordId, 'MCHPDF');
|
}else {
|
alert('1');
|
}
|
}else{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
|
|
|
|
}
|