buli
2023-03-30 cb7617f2a39f5622bb0c6d21aac6d897497ab389
force-app/main/default/lwc/improvedForecastTime/improvedForecastTime.js
@@ -1,41 +1,37 @@
import { LightningElement, track  } from 'lwc';
import GetOppinformationcData from '@salesforce/apex/ImprovedForecastTimeController.GetOppinformationcData';
import getReason from '@salesforce/apex/ImprovedForecastTimeController.getReason';
import SaveData from '@salesforce/apex/ImprovedForecastTimeController.SaveData';
import SystemModstamp from '@salesforce/schema/Account.SystemModstamp';
import { LightningElement, track } from "lwc";
import GetOppinformationcData from "@salesforce/apex/ImprovedForecastTimeController.GetOppinformationcData";
import getReason from "@salesforce/apex/ImprovedForecastTimeController.getReason";
import SaveData from "@salesforce/apex/ImprovedForecastTimeController.SaveData";
import SystemModstamp from "@salesforce/schema/Account.SystemModstamp";
export default class ImprovedForecastTime extends LightningElement {
    //显示与隐藏
    isAdvance = false;  //选着 提前 的标识
    isDelay = false; //选着 延后 的标识
    RelateOption=[
        {label:"提前",value:"提前"},
        {label:"延后",value:"延后"},
    ]
    { label: "延后", value: "延后" }
  ];
        
    handleRelationFn(event){
        var value = event.target.value;
        this.opp.Date_InAdvance_Delay = value;
debugger
    debugger;
        // this.opp.Predicted_date_ChangeReason__c = '';
        //SWAG-CJR4PC【委托】调查-修改预测日提前理由错误 fy start
        this.opp.Predicted_date_ChangeReason = ''
        this.opp.Close_Forecasted_Date= '';
        this.opp.CloseDate= '';
    this.opp.Predicted_date_ChangeReason = "";
    this.opp.Close_Forecasted_Date = "";
    this.opp.CloseDate = "";
        //SWAG-CJR4PC【委托】调查-修改预测日提前理由错误 fy end
        if (value == "提前") {
            this.isAdvance = true;
            this.isDelay = false;
        }
        if (value == "延后") {
            this.isAdvance = false;
            this.isDelay = true;
        }
    }
    handleRelationFn1(event){
@@ -47,12 +43,12 @@
        var value = event.target.value;
        this.opp.Close_Forecasted_Date = value;
        this.flg=false;
        debugger
    debugger;
        this.CloseDateAssignment(value);
    }
    //给预测发货日赋值
    CloseDateAssignment(value){
        debugger
    debugger;
        var value=this.addDay(30,value);
        this.opp.CloseDate = value;
        this.flg=true;
@@ -60,18 +56,18 @@
    //加天数
    addDay(dayNumber, value1) {
        var date = new Date(value1);
        var ms = dayNumber * (1000 * 60 * 60 * 24)
    var ms = dayNumber * (1000 * 60 * 60 * 24);
 
        var newDate = new Date(date.getTime() + ms);
        var value=newDate.toLocaleDateString();
        var value2=value.split('/');
    var value2 = value.split("/");
        if(value2[1].length == 1){
            value2[1]='0'+value2[1];
      value2[1] = "0" + value2[1];
        }
        if(value2[2].length == 1){
            value2[2]='0'+value2[2];
      value2[2] = "0" + value2[2];
        }
        value=value2[0]+'-'+value2[1]+'-'+value2[2];
    value = value2[0] + "-" + value2[1] + "-" + value2[2];
        return value;
    } 
    handleRelationFn3(event){
@@ -79,55 +75,55 @@
        this.opp.CloseDate = value;
    }
    //从url上取得ID
    getQueryVariable(variable)
    {
  getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
      if (pair[0] == variable) {
        return pair[1];
        }
        return(false);
    }
    return false;
    }
    oppId = '';
  oppId = "";
    opp = {};
    Date_InAdvance_Delay = '';
  Date_InAdvance_Delay = "";
    
    AdvanceReasons = [];
    DelayReasons = [];
    //初始化
    connectedCallback(){
        this.oppId = this.getQueryVariable('id');
    this.oppId = this.getQueryVariable("id");
        GetOppinformationcData({ParamIdStr:this.oppId}).then(response=>{
    GetOppinformationcData({ ParamIdStr: this.oppId }).then((response) => {
            this.opp=JSON.parse(response);
            if(this.opp.Date_InAdvance_Delay == '提前'){
      if (this.opp.Date_InAdvance_Delay == "提前") {
                this.isAdvance = true;
                this.isDelay = false;
            }
            if(this.opp.Date_InAdvance_Delay == '延后'){
      if (this.opp.Date_InAdvance_Delay == "延后") {
                this.isAdvance = false;
                this.isDelay = true;
            }
        });
        
        getReason().then(response=>{
    getReason().then((response) => {
            var options = JSON.parse(response);
            this.AdvanceReasons = options['提前'];
            this.DelayReasons = options['延后'];
      this.AdvanceReasons = options["提前"];
      this.DelayReasons = options["延后"];
        });
    }
    //提示
    SaveShowText="保存成功";//提示框的文本
    Tongzhishow=false;  //提示显示的标识
    TongzhiIcon = 'standard:account' //提示框的图标
    IsLeftStyle = "" //提示框的样式
    BgColorStyle = ""
  TongzhiIcon = "standard:account"; //提示框的图标
  IsLeftStyle = ""; //提示框的样式
  BgColorStyle = "";
    //弹框提示 content 内容 error 是否是错误提示框  left 是否居左
    Alert(content,error = false,left = false){
@@ -142,9 +138,9 @@
            this.BgColorStyle = "background-color:#69e669";
        }
        if (left) {
            this.IsLeftStyle = "left: 0.25rem"
      this.IsLeftStyle = "left: 0.25rem";
        }else{
            this.IsLeftStyle = ""
      this.IsLeftStyle = "";
        }
    }
@@ -167,7 +163,7 @@
    }
    //保存数据逻辑
    saveFn(){
        debugger
    debugger;
        var myDate = new Date();                                        //今天日期
        var myDate1 = new Date(this.opp.Close_Forecasted_Check);        //当前预测日期
        var myDate2 = new Date(this.opp.Close_Forecasted_Date);  //改变的预测日期
@@ -201,42 +197,48 @@
        //20221226 lt DB202212359066增加限制-修改预测日最大日期 end
        
        console.warn('myDatevalue:='+myDate);
        console.warn('今天日期'+myDate3);
        console.warn('当前预测日期'+myDate4);
        console.warn('1111111111'+myDate2);
        console.warn('改变的预测日期'+myDate5);
    console.warn("myDatevalue:=" + myDate);
    console.warn("今天日期" + myDate3);
    console.warn("当前预测日期" + myDate4);
    console.warn("1111111111" + myDate2);
    console.warn("改变的预测日期" + myDate5);
        
        //SWAG-CJR4PC【委托】调查-修改预测日提前理由错误 fy start
        // if(this.opp.Date_InAdvance_Delay == undefined || this.opp.Predicted_date_ChangeReason == undefined || myDate5 == undefined){
        // if(this.opp.Date_InAdvance_Delay == '' ||this.opp.Date_InAdvance_Delay == undefined || this.opp.Predicted_date_ChangeReason == '' ||this.opp.Predicted_date_ChangeReason == undefined|| myDate5 == '' || myDate5 == undefined){
        if(!this.opp.Date_InAdvance_Delay || !this.opp.Predicted_date_ChangeReason ||  !this.opp.Close_Forecasted_Date){
    if (
      !this.opp.Date_InAdvance_Delay ||
      !this.opp.Predicted_date_ChangeReason ||
      !this.opp.Close_Forecasted_Date
    ) {
        //SWAG-CJR4PC【委托】调查-修改预测日提前理由错误 fy end
            this.Alert("请选择日期/理由。",false,true);
        }
        else if(this.opp.Date_InAdvance_Delay == '提前' && (myDate5 >= myDate4 || myDate5 < myDate3)){
            this.Alert("请选择 “提前” 于当前预测OCSM签约日的日期 且 不早于今天。",false,true);
        }
        else if(this.opp.Date_InAdvance_Delay == '延后' && myDate5 <= myDate4){
    } else if (
      this.opp.Date_InAdvance_Delay == "提前" &&
      (myDate5 >= myDate4 || myDate5 < myDate3)
    ) {
      this.Alert(
        "请选择 “提前” 于当前预测OCSM签约日的日期 且 不早于今天。",
        false,
        true
      );
    } else if (this.opp.Date_InAdvance_Delay == "延后" && myDate5 <= myDate4) {
            this.Alert("请选择 “延后” 于当前预测OCSM签约日的日期。",false,true);
        }
        else if(myDate7 < myDate5){
    } else if (myDate7 < myDate5) {
            this.Alert("预测发货日不能小于预测签约日。",false,true);
        }
        //20221226 lt DB202212359066增加限制-修改预测日最大日期 start
        else if(myDate5 > OrderDate){
            this.Alert("订货预测日请在未来三财年内。",false,true);
        }
        else if(myDate7 > ShipmentsDate){
    } else if (myDate7 > ShipmentsDate) {
            this.Alert("发货预测日请在未来四财年内。",false,true);
        }
        //20221226 lt DB202212359066增加限制-修改预测日最大日期 end
        else{
            this.OnLoading(true);
            SaveData({JsonData:JSON.stringify(this.opp)}).then((response)=>{
                if (response == '成功') {
        if (response == "成功") {
                    this.OnLoading(false);
                    this.Alert("保存成功",false,true); 
                    window.location.hash = "Refresh"+"=="+this.oppId;
@@ -246,5 +248,4 @@
            });
        }
    }
}