Explorar el Código

feat:添加编辑接口

AmandaG hace 4 meses
padre
commit
9ebd7b2ade

+ 82 - 11
src/views/DestinationDelivery/src/components/CreateNewBooking/src/CreateNewbooking.vue

@@ -17,6 +17,8 @@ const { query } = value
 const { a } = query
 
 const CreateNewBOokingSearch = ref('')
+const status = ref('')
+const booking = ref('')
 const DateValue = ref('')
 const bookingTableRef = ref()
 const VesselName = ref([])
@@ -47,6 +49,7 @@ const ContactNumber = ref('')
 const instructions = ref('')
 const modetypeValue = ref('Truck')
 const Requirements = ref('')
+const Modification = ref()
 const selectedAddressList = ref()
 const isselectedAddress = ref(null)
 const checkShipmentsSubmitInfo = ref({})
@@ -69,6 +72,20 @@ const isNotSubmit = computed(() => {
     return true
   }
 
+  if(a != undefined) {
+    if(
+      selectedAddressList.value == undefined ||
+      modetypeValue.value == '' ||
+      DateValue.value == '' ||
+      Modification.value == null ||
+      Modification.value == ''
+    ) {
+      return true
+    } else {
+      return false
+    }
+  }
+
   if(
     Object.keys(checkShipmentsSubmitInfo.value).length == 0 ||
     selectedAddressList.value == undefined ||
@@ -77,6 +94,7 @@ const isNotSubmit = computed(() => {
   ) {
     return true
   }
+
   return false;
 })
 
@@ -175,10 +193,15 @@ const changeAddressRadio = () => {
   selectedAddressList.value = ManageAddressList.value[Addressradio.value]
 }
 // 页面初始化
+let checkShipments = []
+let checkShipmentsSubmit = []
+let checkShipmentsdata = []
+let checkShipmentsInfo = {}
+let checkShipmentsSubmitInfoData = {}
 const getInitBookingData = () => {
   $api
   .InitCreateBooking({
-    a: a != undefined ? a: ''
+    serial_no: a != undefined ? a: ''
   })
   .then((res: any) => {
     if (res.code === 200) {
@@ -188,6 +211,51 @@ const getInitBookingData = () => {
       }
       if(res.data.msg.includes('success')) {
         bookingTableRef.value.getTableData(res.data.data.tableData)
+        if(a) {
+          status.value = res.data.data.status
+          booking.value = res.data.data.booking_no
+          Requirements.value = res.data.data.special_requirements
+          modetypeValue.value = res.data.data.delivery_mode
+          DateValue.value = res.data.data.created_time
+          Modification.value = res.data.data.modify_reason
+          const address1 = res.data.data.delivery_address.split('\n')[0]
+          checkShipments = res.data.data.tableData.map(item => ({ consignee_id: item.consignee_id }))
+          checkShipmentsdata = Object.keys(checkShipments?.[0])
+          checkShipmentsSubmit = Object.keys(res.data.data.tableData?.[0])
+          checkShipmentsdata.forEach((item) => {
+            Object.assign(checkShipmentsInfo, {
+              [item]: checkShipments.map((row) => row[item] )
+            })
+          })
+          checkShipmentsSubmit.forEach((item) => {
+            if(item == 'serial_no') return
+            Object.assign(checkShipmentsSubmitInfoData, {
+              [item]: res.data.data.tableData.map((row) => {
+                if(row[item] == null){
+                  return ''
+                } else {
+                  return row[item]
+                }
+              } )
+            })
+          })
+          $api
+          .getAddressBookList({
+            ...checkShipmentsInfo,
+          })
+          .then((res: any) => {
+            if (res.code === 200) {
+              ManageAddressList.value = res.data
+              ManageAddressList.value.forEach((item, index) => {
+                if(item.location_name === address1) {
+                  selectedAddressList.value = item
+                  isselectedAddress.value = index
+                  Addressradio.value = index
+                }
+              })
+            }
+          })
+        }
       }
     }
   })
@@ -226,7 +294,6 @@ const areAllDateRangesSame = (date: any) => {
       } else {
         isConsistent.value = true
         RecommendateList.value = date.map(item => ({Hbol: item.Hbol}))
-        console.log(RecommendateList.value)
         return false
       }
   });
@@ -286,8 +353,6 @@ const changeDatePicker = (val:any) => {
       recommendateWarning.value = 'This date for following shipments is outside recommended period.'
       isConsistent.value = false
     } else {
-      console.log(specialDates.value)
-      console.log(val)
       if(!specialDates.value.includes(val)) {
         isRecommendDate.value = true
         recommendateWarning.value = 'This date is outside our recommended period.'
@@ -302,11 +367,14 @@ const SubmitBooking = () => {
   const datetwo = date[1] + '/' + date[2] + '/' + date[1]
   $api
   .SaveBookingList({
+    serial_no: a != undefined ? a : '',
     ...checkShipmentsSubmitInfo.value,
     ...selectedAddressList.value,
+    ...checkShipmentsSubmitInfoData,
     delivery_mode: modetypeValue.value,
     delivery_date: datetwo,
-    special_requirements: Requirements.value
+    special_requirements: Requirements.value,
+    modify_reason: Modification.value
   })
   .then((res: any) => {
     if (res.code === 200 && res.data.msg == 'success') {
@@ -339,15 +407,15 @@ onMounted(() => {
     </div>
     <div class="booking-info">
       <div class="booking-no">
-        <span class="no">Booking No.B83131200164</span>
-        <v-tag class="tag" type="Pending Approval">Pending Approval</v-tag>
+        <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" />
     <!-- Select Shipments -->
     <div class="select_shipments">
-      <div><span class="stars_red">*</span>Select Shipments</div>
-      <div class="flex shipments_search">
+      <div style="margin-bottom: 16px;"><span class="stars_red">*</span>Select Shipments</div>
+      <div class="flex shipments_search" v-if="a == undefined">
         <el-input
           placeholder="Enter Booking/HBL/PO/Carrier Booking No. "
           v-model="CreateNewBOokingSearch"
@@ -462,6 +530,8 @@ onMounted(() => {
         <el-button :disabled="isNotClickAddress" class="el-button--grey" @click="handleclickbutton('Special Equipment')">Special Equipment</el-button>
       </div>
       <el-input :disabled="isNotClickAddress" v-model="Requirements" placeholder="Eenter any additional requirements or notes..." type="textarea" style="margin-top: 8px;" :rows="4"></el-input>
+      <div v-if="a!= undefined" class="delivery_type_title" style="margin-top: 16px;"><span class="stars_red">*</span>Modification Reason</div>
+      <el-input v-if="a!=undefined" :disabled="isNotClickAddress" v-model="Modification" placeholder="Eenter any additional requirements or notes..." type="textarea" style="margin-top: 8px;" :rows="4"></el-input>
     </div>
     <el-dialog
       v-model="ManageVisible"
@@ -694,7 +764,7 @@ onMounted(() => {
   color: var(--color-danger);
 }
 .shipments_search {
-  margin: 16px 0 8px 0;
+  margin: 0 0 8px 0;
 }
 :deep(.log_input .el-input__wrapper) {
   box-shadow: 0 0 0 1px var(--color-select-border) inset;
@@ -817,6 +887,7 @@ onMounted(() => {
 .radio_title {
   font-size: 14px;
   font-weight: 700;
+  margin-top: -7px;
 }
 .radio_content_text {
   color: var(--color-neutral-2);
@@ -837,7 +908,7 @@ onMounted(() => {
   margin-right: 0;
   height: fit-content;
   line-height: 32px;
-  align-items: baseline;
+  align-items: start;
 }
 .el-button--blue {
   width: 24px;

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

@@ -3,6 +3,13 @@ import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
 import { formatTimezone } from '@/utils/tools'
 import { ref, onMounted } from 'vue'
+import { useRouter } from 'vue-router'
+
+const router = useRouter()
+const { currentRoute } = router
+const { value } = currentRoute
+const { query } = value
+const { a } = query
 
 const tableLoadingTable = ref(false)
 const tableLoadingColumn = ref(false)
@@ -65,10 +72,16 @@ const getTableColumns = async () => {
   tableLoadingColumn.value = true
   await $api.BookingTableColumn().then((res: any) => {
     if (res.code === 200) {
-      tableData.value.columns = [
-        { type: 'checkbox', width: 50, fixed: 'left' },
-        ...handleColumns(res.data.TrackingTableColumns)
-      ]
+      if(a == undefined) {
+        tableData.value.columns = [
+          { type: 'checkbox', width: 50, fixed: 'left' },
+          ...handleColumns(res.data.TrackingTableColumns)
+        ]
+      }else {
+        tableData.value.columns = [
+          ...handleColumns(res.data.TrackingTableColumns)
+        ]
+      }
     }
   })
   nextTick(() => {

+ 1 - 1
src/views/DestinationDelivery/src/components/TableView/src/TableView.vue

@@ -317,7 +317,7 @@ const handelEdit = (row: any) => {
   console.log(row)
   router.push({
     path: '/destination-delivery/CreateNewBooking',
-    query: { a: row._serial_no }
+    query: { a: row._serial_no}
   })
 }