Przeglądaj źródła

fix:修改recommend date为空时的Bug

AmandaG 4 miesięcy temu
rodzic
commit
da2fd94c63

+ 58 - 37
src/views/DestinationDelivery/src/components/CreateNewBooking/src/CreateNewbooking.vue

@@ -29,6 +29,7 @@ const isetaFocused = ref(false)
 const ManageVisible = ref(false)
 const AddNewAddressVisible = ref(false)
 const NoPermissionVisible = ref(false)
+const CancelRulesVisible = ref(false)
 const NoEligibleVisible = ref(false)
 const isDisabled = ref(false)
 const SaveedVisible = ref(false)
@@ -262,22 +263,15 @@ const getInitBookingData = () => {
 }
 // 查询Shipments
 const SearchShipment = () => {
-  $api
-  .BookingTableSearch({
-    serial_no: a != undefined ? a: '',
+  let obj = {
     text_search: CreateNewBOokingSearch.value,
     vessel: VesselNametest.value,
-    eta_start: ETATimeList.value.length != 0 ? ETATimeList.value[0] : '',
-    eta_end: ETATimeList.value.length != 0 ? ETATimeList.value[1] : '',
-    ata_start: ATATimeList.value.length != 0 ? ATATimeList.value[0] : '',
-    ata_end: ATATimeList.value.length != 0 ? ATATimeList.value[1] : ''
-
-  })
-  .then((res: any) => {
-    if (res.code === 200) {
-      console.log(res.data)
-    }
-  })
+    eta_start: ETATimeList.value != null ? ETATimeList.value[0] : '',
+    eta_end: ETATimeList.value != null ? ETATimeList.value[1] : '',
+    ata_start: ATATimeList.value != null ? ATATimeList.value[0] : '',
+    ata_end: ATATimeList.value != null ? ATATimeList.value[1] : ''
+  }
+  bookingTableRef.value.searchTableData(obj)
 }
 
 // 选择shipments获取address book
@@ -300,29 +294,31 @@ const areAllDateRangesSame = (date: any) => {
 }
 // 遍历日期
 const getDateRangeArray = (startDateStr, endDateStr) => {
-  const parseDate = (str) => {
-    const [year, month, day] = str.split('.').map(Number);
-    return new Date(year, month - 1, day); // 月份从0开始计数
-  };
+  if(startDateStr != '' && endDateStr != '') {
+    const parseDate = (str) => {
+      const [year, month, day] = str.split('.').map(Number);
+      return new Date(year, month - 1, day); // 月份从0开始计数
+    };
 
-  const startDate = parseDate(startDateStr);
-  const endDate = parseDate(endDateStr);
+    const startDate = parseDate(startDateStr);
+    const endDate = parseDate(endDateStr);
 
-  const dateArray = [];
-  const currentDate = new Date(startDate);
-  
-  while (currentDate <= endDate) {
-    // 格式化为 YYYY.MM.DD
-    const formattedDate = [
-      currentDate.getFullYear(),
-      (currentDate.getMonth() + 1).toString().padStart(2, '0'),
-      currentDate.getDate().toString().padStart(2, '0')
-    ].join('.');
-    dateArray.push(formattedDate);
-    currentDate.setDate(currentDate.getDate() + 1);
-  }
+    const dateArray = [];
+    const currentDate = new Date(startDate);
+    
+    while (currentDate <= endDate) {
+      // 格式化为 YYYY.MM.DD
+      const formattedDate = [
+        currentDate.getFullYear(),
+        (currentDate.getMonth() + 1).toString().padStart(2, '0'),
+        currentDate.getDate().toString().padStart(2, '0')
+      ].join('.');
+      dateArray.push(formattedDate);
+      currentDate.setDate(currentDate.getDate() + 1);
+    }
 
-  return dateArray;
+    return dateArray;
+  }
 }
 const selectChangeEvent = (val: any, date: any, submitInfo: any) => {
   checkShipmentsSubmitInfo.value = submitInfo
@@ -401,17 +397,17 @@ onMounted(() => {
       <div v-if="a == undefined">Create New Booking</div>
       <div v-else>Modify Booking</div>
       <div class="flex">
-        <el-button class="el-button--default create-button"><span class="font_family icon-icon_return_b"></span> Cancel</el-button>
+        <el-button @click="CancelRulesVisible = true" class="el-button--default create-button"><span class="font_family icon-icon_return_b"></span> Cancel</el-button>
         <el-button :disabled="isNotSubmit" @click="SubmitBooking" class="el-button--main create-button"><span class="font_family icon-icon_submit_b"></span> Submit</el-button>
       </div>
     </div>
-    <div class="booking-info">
+    <div class="booking-info" v-if="a != undefined">
       <div class="booking-no">
         <span class="no">Booking No.{{ booking }}</span>
         <v-tag class="tag" type="Pending Approval">{{ status }}</v-tag>
       </div>
     </div>
-    <el-divider style="margin: 8px 0" />
+    <el-divider v-if="a != undefined" style="margin: 8px 0" />
     <!-- Select Shipments -->
     <div class="select_shipments">
       <div style="margin-bottom: 16px;"><span class="stars_red">*</span>Select Shipments</div>
@@ -687,6 +683,31 @@ onMounted(() => {
         </div>
       </template>
     </el-dialog>
+    <!-- 取消保存 -->
+    <el-dialog v-model="CancelRulesVisible" width="480">
+      <div style="font-weight: 400">You have unsaved changes.</div>
+      <div style="font-weight: 400">Are you sure you want to leave this page?</div>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button type="default" @click="CancelRulesVisible = false" style="width: 100px"
+            >Cancel</el-button
+          >
+          <el-button class="el-button--warning" @click="router.back()" style="width: 100px">
+            OK
+          </el-button>
+        </div>
+      </template>
+      <template #header>
+        <div class="cancel_header">
+          <span class="iconfont_icon iconfont_warning">
+            <svg class="iconfont icon_warning" aria-hidden="true">
+              <use xlink:href="#icon-icon_tipsfilled_b"></use>
+            </svg>
+          </span>
+          Unsaved Changes
+        </div>
+      </template>
+    </el-dialog>
     <!-- 當選擇非建議日期内的date時給出的提示 -->
     <el-dialog v-model="isRecommendDate" width="480">
       <div>{{ recommendateWarning }}</div>

+ 17 - 3
src/views/DestinationDelivery/src/components/CreateNewBooking/src/components/NewbookingTable.vue

@@ -15,8 +15,6 @@ const tableLoadingTable = ref(false)
 const tableLoadingColumn = ref(false)
 const isNotActivated = ref(false)
 
-const recommendedDate = ref([])
-
 const tableData = ref<VxeGridProps<any>>({
   border: true,
   round: true,
@@ -93,6 +91,21 @@ const getTableData = (val: any) => {
   tableData.value.data = val
 }
 
+// 搜索表格数据
+const searchTableData = (val: any) => {
+  tableLoadingTable.value = true
+  $api
+  .BookingTableSearch({
+    ...val
+  })
+  .then((res: any) => {
+    if (res.code === 200) {
+      tableLoadingTable.value = false
+      tableData.value.data = res.data.data
+    }
+  })
+}
+
 const emits = defineEmits(['selectChangeEvent'])
 // 选中
 let checkShipments = []
@@ -172,7 +185,8 @@ onMounted(() => {
   getTableColumns()
 })
 defineExpose({
-  getTableData
+  getTableData,
+  searchTableData
 })
 
 </script>