From ff58551ba28f475ad78c9eebbf543aee15ace8bf Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期五, 13 九月 2024 11:48:40 +0800
Subject: [PATCH] 换型损失设置添加时间范围

---
 /dev/null                                                                                                     |    4 --
 _Main/BL/Type_ChangeLossSetting/Attribute_StartDate.qbl                                                       |    7 +++
 _Main/BL/InfoMessages.qbl                                                                                     |    4 ++
 _Main/BL/Type_ChangeLossSettingExcel/Attribute_StartDate.qbl                                                  |    7 +++
 _Main/UI/MacroPlannerWebApp/Component_FormChangeLossSetting/Component_ListChangeLossSetting#568.def           |    2 
 _Main/BL/Type_ChangeLossSetting/Attribute_EndDate.qbl                                                         |    7 +++
 _Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl                                                |   10 ++++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Response_pnlActions_btnOk_OnClick.def |    2 
 _Main/BL/Type_ChangeLossSettingExcel/Attribute_EndDate.qbl                                                    |    7 +++
 _Main/BL/Type_ChangeLossSettingExcel/StaticMethod_CheckImport.qbl                                             |    8 +++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Component_pnlContent.def              |   22 +++++++++++
 _Main/UI/MacroPlannerWebApp/Views/Change_loss_setting_view.vw                                                 |   20 +++++++++
 12 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/_Main/BL/InfoMessages.qbl b/_Main/BL/InfoMessages.qbl
index e9c488a..84c6052 100644
--- a/_Main/BL/InfoMessages.qbl
+++ b/_Main/BL/InfoMessages.qbl
@@ -186,6 +186,10 @@
   {
     DefaultText: 'The required field is blank.'
   }
+  InfoMessage MP_ChangeLossSetting_DateCoincide
+  {
+    DefaultText: '鏃ユ湡鍖洪棿閲嶅悎.'
+  }
   InfoMessage MP_ChangeLossSetting_Exist
   {
     DefaultText: 'The same data already exists.'
diff --git a/_Main/BL/Type_ChangeLossSetting/Attribute_EndDate.qbl b/_Main/BL/Type_ChangeLossSetting/Attribute_EndDate.qbl
new file mode 100644
index 0000000..8df6afc
--- /dev/null
+++ b/_Main/BL/Type_ChangeLossSetting/Attribute_EndDate.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute EndDate
+{
+  #keys: '3[415136.0.1132170029][415136.0.1132170028][415136.0.1132170030]'
+  ValueType: Date
+}
diff --git a/_Main/BL/Type_ChangeLossSetting/Attribute_StartDate.qbl b/_Main/BL/Type_ChangeLossSetting/Attribute_StartDate.qbl
new file mode 100644
index 0000000..17015a8
--- /dev/null
+++ b/_Main/BL/Type_ChangeLossSetting/Attribute_StartDate.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute StartDate
+{
+  #keys: '3[415136.0.1132170019][415136.0.1132170018][415136.0.1132170020]'
+  ValueType: Date
+}
diff --git a/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl b/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl
index b5ed7dc..4db4239 100644
--- a/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl
+++ b/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl
@@ -7,6 +7,8 @@
   Unit unit,
   Product_MP product1,
   Product_MP product2,
+  Date startdate,
+  Date enddate,
   Number number
 ) as Boolean
 {
@@ -21,11 +23,17 @@
     if( product1 = product2 ){
       feedback := Translations::MP_ChangeLossSetting_SameProduct();
     }
-    if( exists( owner, ChangeLossSetting, cls, cls <> old and cls.Unit() = unit 
+    if( startdate > enddate ){
+      feedback := Translations::MP_LibCal_Event_ValidDatePeriod();
+    }
+    if( exists( owner, ChangeLossSetting, cls, cls <> old and cls.Unit() = unit and not ( cls.StartDate() > enddate or cls.EndDate() < startdate )
                 and ( ( cls.ProductFirst() = product1 and cls.ProductSecond() = product2 ) 
                       or ( cls.ProductFirst() = product2 and cls.ProductSecond() = product1 ) ) ) ){
       feedback := Translations::MP_ChangeLossSetting_Exist()
     }
+    if( exists( owner, ChangeLossSetting, cls, cls <> old and not ( cls.StartDate() > enddate or cls.EndDate() < startdate ) ) ){
+      feedback := Translations::MP_ChangeLossSetting_DateCoincide()
+    }
     
     return feedback = '';
   *]
diff --git a/_Main/BL/Type_ChangeLossSettingExcel/Attribute_EndDate.qbl b/_Main/BL/Type_ChangeLossSettingExcel/Attribute_EndDate.qbl
new file mode 100644
index 0000000..54fa971
--- /dev/null
+++ b/_Main/BL/Type_ChangeLossSettingExcel/Attribute_EndDate.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute EndDate
+{
+  #keys: '3[415136.0.1132074698][415136.0.1132074697][415136.0.1132074699]'
+  ValueType: Date
+}
diff --git a/_Main/BL/Type_ChangeLossSettingExcel/Attribute_StartDate.qbl b/_Main/BL/Type_ChangeLossSettingExcel/Attribute_StartDate.qbl
new file mode 100644
index 0000000..05a1f29
--- /dev/null
+++ b/_Main/BL/Type_ChangeLossSettingExcel/Attribute_StartDate.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute StartDate
+{
+  #keys: '3[415136.0.1132074695][415136.0.1132074694][415136.0.1132074696]'
+  ValueType: Date
+}
diff --git a/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_CheckImport.qbl b/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_CheckImport.qbl
index a7c0e18..de86c3f 100644
--- a/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_CheckImport.qbl
+++ b/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_CheckImport.qbl
@@ -10,7 +10,9 @@
     if( exists( macroplan, ChangeLossSettingExcel, excel, excel.Product1() = '' 
                 or excel.Product2() = '' 
                 or excel.Unit() = '' 
-                or excel.ChangeLossNumber() = '' ) ){
+                or excel.ChangeLossNumber() = ''
+                or not excel.StartDate().IsFinite()
+                or not excel.EndDate().IsFinite() ) ){
       error( Translations::MP_ChangeLossSettingExcel_Import_NullInputRequiredField() );
     }
     //瀵煎叆鐨勬暟閲忓皬浜�0
@@ -29,6 +31,10 @@
     if( exists( macroplan, ChangeLossSettingExcel, excel, excel.Product1() = excel.Product2() ) ){
       error( Translations::MP_ChangeLossSetting_SameProduct() );
     }
+    //瀵煎叆鐨勬椂闂村尯闂存牎楠�
+    if( exists( macroplan, ChangeLossSettingExcel, excel, excel.StartDate() > excel.EndDate() ) ){
+      error( Translations::MP_LibCal_Event_ValidDatePeriod() );
+    }
     //閲嶅瀵煎叆鏍¢獙
     //if( selectduplicates( owner, LaneExcel, excel, excel.StartFrom(), 
     //                      excel.EndTo(), 
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Component_pnlContent.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Component_pnlContent.def
index 44c4b7d..94aa80b 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Component_pnlContent.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Component_pnlContent.def
@@ -98,9 +98,31 @@
         DataBinding: 'dhDialogData.Data.ChangeLossNr'
         Label: 'Change loss number'
         Min: '0'
+        Taborder: 5
+      ]
+    }
+    Component dsStartDate
+    {
+      #keys: '[415136.0.1132411785]'
+      BaseType: 'WebDateSelector'
+      Properties:
+      [
+        DataBinding: 'dhDialogData.Data.StartDate'
+        Label: 'Start date'
         Taborder: 3
       ]
     }
+    Component dsEndDate
+    {
+      #keys: '[415136.0.1132411840]'
+      BaseType: 'WebDateSelector'
+      Properties:
+      [
+        DataBinding: 'dhDialogData.Data.EndDate'
+        Label: 'End date'
+        Taborder: 4
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Response_pnlActions_btnOk_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Response_pnlActions_btnOk_OnClick.def
index a93df84..5def9ee 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Response_pnlActions_btnOk_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditChangeLossSetting/Response_pnlActions_btnOk_OnClick.def
@@ -6,7 +6,7 @@
   DefinitionID: 'Responsedef_WebButton_OnClick'
   Precondition:
   [*
-    return ChangeLossSetting::ValidateInput( feedback, MacroPlan, dhDialogData.Data().WrappedInstance(), ddlUnit.Data(), ddlProduct1.Data(), ddlProduct2.Data(), [Number]npChangeLossNr.Number() );
+    return ChangeLossSetting::ValidateInput( feedback, MacroPlan, dhDialogData.Data().WrappedInstance(), ddlUnit.Data(), ddlProduct1.Data(), ddlProduct2.Data(), dsStartDate.Date(), dsEndDate.Date(), [Number]npChangeLossNr.Number() );
   *]
   QuillAction
   {
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormChangeLossSetting/Component_ListChangeLossSetting\043568.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormChangeLossSetting/Component_ListChangeLossSetting\043568.def"
index d1ab712..13d921e 100644
--- "a/_Main/UI/MacroPlannerWebApp/Component_FormChangeLossSetting/Component_ListChangeLossSetting\043568.def"
+++ "b/_Main/UI/MacroPlannerWebApp/Component_FormChangeLossSetting/Component_ListChangeLossSetting\043568.def"
@@ -28,7 +28,7 @@
       ]
       Properties:
       [
-        Columns: '[{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Unit.ID","title":"Unit","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"Unit.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ProductFirst.ID","title":"Product1","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ProductFirst.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ProductSecond.ID","title":"Product2","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ProductSecond.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ChangeLossNr","title":"ChangeLossNr","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"ChangeLossNr"}}]'
+        Columns: '[{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Unit.ID","title":"Unit","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"Unit.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ProductFirst.ID","title":"Product1","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ProductFirst.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ProductSecond.ID","title":"Product2","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ProductSecond.ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"StartDate","title":"StartDate","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"StartDate"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"EndDate","title":"EndDate","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"EndDate"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ChangeLossNr","title":"ChangeLossNr","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"ChangeLossNr"}}]'
         ContextMenu: 'listContextMenuChangeLossSetting'
         Taborder: 2
       ]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def b/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def
deleted file mode 100644
index c7f3361..0000000
--- a/_Main/UI/MacroPlannerWebApp/Component_FormForecasts/Component_listContextMenuSD.def
+++ /dev/null
@@ -1,4 +0,0 @@
-Quintiq file version 2.0
-Component listContextMenuSD #extension
-{
-}
diff --git a/_Main/UI/MacroPlannerWebApp/Views/Change_loss_setting_view.vw b/_Main/UI/MacroPlannerWebApp/Views/Change_loss_setting_view.vw
index 0d6a63f..d72a303 100644
--- a/_Main/UI/MacroPlannerWebApp/Views/Change_loss_setting_view.vw
+++ b/_Main/UI/MacroPlannerWebApp/Views/Change_loss_setting_view.vw
@@ -60,12 +60,30 @@
               subtotals: ''
               width: 150
             }
+            column_StartDate
+            {
+              columnId: 'StartDate'
+              dataPath: 'StartDate'
+              dataType: 'date'
+              index: 3
+              subtotals: ''
+              width: 150
+            }
+            column_EndDate
+            {
+              columnId: 'EndDate'
+              dataPath: 'EndDate'
+              dataType: 'date'
+              index: 4
+              subtotals: ''
+              width: 150
+            }
             column_ChangeLossNr
             {
               columnId: 'ChangeLossNr'
               dataPath: 'ChangeLossNr'
               dataType: 'number'
-              index: 3
+              index: 5
               subtotals: ''
               width: 150
             }

--
Gitblit v1.9.3