Bläddra i källkod

change: crm包裹处理页面. 接口更换.

peter 3 dagar sedan
förälder
incheckning
e9a52fe872
1 ändrade filer med 130 tillägg och 24 borttagningar
  1. 130 24
      src/pages/shipping-tracking2/index.vue

+ 130 - 24
src/pages/shipping-tracking2/index.vue

@@ -51,7 +51,6 @@
             导出Excel
           </el-button>
           <el-button
-            disabled
             class="custom-button"
             type="primary"
             size="small"
@@ -117,7 +116,8 @@
               ></el-checkbox>
             </div>
             <div v-if="col.prop === 'Owner'">
-              {{ scope.row.Owner.name }}
+              <!--               {{ scope.row.Owner.name }} -->
+              {{ getName(scope.row.Owner.id) }}
             </div>
 
             <div v-if="col.prop === 'Client_Label_Links'">
@@ -173,6 +173,17 @@
                 @change="scope.row.editFlag = true"
               ></el-input>
             </div>
+            <!-- <div
+              v-if="
+                [
+                  'Total_Quantity_Carton',
+                  'Total_Cube',
+                  'Total_Weight',
+                ].includes(col.prop)
+              "
+            >
+              {{ scope.row[col.prop] }}
+            </div> -->
           </template>
         </el-table-column>
       </el-table>
@@ -281,6 +292,32 @@ const columnList = [
   { label: 'Shipping Country', prop: 'Shipping_Country', width: 120 },
 ]
 
+let userList = ref(new Map())
+let getUserList = () => {
+  request
+    .post('/common/getPublicListsAll8', {
+      select_query:
+        'select id,first_name,last_name,state from users where first_name is not null',
+    })
+    .then((resp: any) => {
+      const res = resp.data.result || {}
+      if (Array.isArray(res.data) && res.data.length) {
+        // userList.value = res.data
+        res.data.forEach((i: any) => {
+          userList.value.set(i.id, i)
+        })
+      }
+      console.log(userList.value, 'userList.value')
+    })
+}
+getUserList()
+let getName = (id: string) => {
+  const temp = userList.value.get(id) || {}
+  let firstName = temp.first_name || ''
+  let lastName = temp.last_name || ''
+  return firstName + ' ' + lastName
+}
+
 // 这两个变量是用来记录 当前筛选tab的, 在保存成功之后刷新数据时重新选上这个tab.
 let currentTypeResearch = ref(1)
 let currentTabResearch = ref('')
@@ -407,21 +444,68 @@ let getList = (type = 1) => {
       ],
     }
   }
+  let sql =
+    'select ' +
+    columnList.map((i: any) => `Shipping_Tracking.${i.prop}`).join(',') +
+    ',Summary_of_Carton_Dimension ' +
+    ' from Shipping_Tracking '
 
+  let whereSQL =
+    "  (Package_Type='SGL Package' and Confirm_send_to_Starshipit=true) "
+  if (type === 2) {
+    sql += ' where (Tracking_No is null or Courier is null) and' + whereSQL
+  } else if (soRef.value) {
+    sql = sql + ` where (SO_Reference like '%${soRef.value}%') and` + whereSQL
+  } else if (containerNumber.value) {
+    sql +=
+      ` where (Container_Number like '%${containerNumber.value}%') and` +
+      whereSQL
+  } else {
+    sql += ' where ' + whereSQL
+  }
+  // console.log(sql, 'sql')
   request
-    .post('/common/getPublicListsAll', conditions)
+    .post('/common/getPublicListsAll8', { select_query: sql })
     .then((resp: any) => {
-      console.log(resp, 'resp')
+      // console.log(resp, 'resp')
       const res = resp.data.result || {}
       if (Array.isArray(res.data) && res.data.length) {
         list.value = res.data.map((i: any) => {
+          let a: any[] = []
+          // i.Summary_of_Carton_Dimension =
+          // 'Quantity:20,Length:20,Width:30,Height:40,Weight:50,Cube:0.48;Quantity:21,Width:30,Height:40,Weight:50,Cube:0.48;'
+          if (
+            i.Summary_of_Carton_Dimension &&
+            i.Summary_of_Carton_Dimension.length
+          ) {
+            a = i.Summary_of_Carton_Dimension.split(';')
+              .filter((j: any) => j !== '')
+              .map((j: string) => {
+                let obj: any = {}
+                j.split(',').forEach((k: string) => {
+                  let [key, value] = k.split(':')
+                  if (key && value) {
+                    obj[key.trim()] = value.trim()
+                  }
+                })
+                return obj
+              })
+
+            // 顺便排序一下, 把quantity最大的那行排第一位
+            a.sort((x: any, y: any) => {
+              return parseInt(y.Quantity || 0) - parseInt(x.Quantity || 0)
+            })
+          }
           return {
             ...i,
             editFlag: false,
+            showSummary: false,
+            Summary_of_Carton_Dimension: a,
             Courier: i.Courier || '',
             Tracking_No: i.Tracking_No || '',
           }
         })
+
         const temp = res.data
           .filter(
             (i: any) =>
@@ -485,32 +569,44 @@ let exportFunc = () => {
     let result = {
       ...cloneDeep(i),
       Urgent: `${i.Urgent}`,
-      Owner: i.Owner.name,
+      Owner: getName(i.Owner.id),
     }
     delete result.id
     delete result.editFlag
 
     // 关键:根据 columnList 顺序构建导出对象
-    let ordered: { [label: string]: any } = {}
-    columnList.forEach((col) => {
+    let ordered: any = {}
+    columnList.forEach((col: any) => {
       ordered[col.label] = result[col.prop]
     })
+    let temp = result.Summary_of_Carton_Dimension.length
+      ? result.Summary_of_Carton_Dimension[0]
+      : {}
+    // 把箱规的数量, 长度, 宽度, 高度, 重量, 体积等信息放到最后
+    ordered['Quantity'] = temp.Length || '-'
+    ordered['Length'] = temp.Length || '-'
+    ordered['Width'] = temp.Width || '-'
+    ordered['Height'] = temp.Height || '-'
     return ordered
   })
 
   const sheet1 = XLSX.utils.json_to_sheet(sheetData, {
-    header: columnList.map((i) => i.label),
+    header: columnList
+      .map((i) => i.label)
+      .concat(['Quantity', 'Length', 'Width', 'Height']),
   })
 
   const wb = XLSX.utils.book_new()
 
-  sheet1['!cols'] = columnList.map((i) => {
-    if (['Artwork_Links', 'Client_Label_Links'].includes(i.prop)) {
-      return { wpx: 400 }
-    } else {
-      return { wpx: i.width ? i.width + 30 : 110 }
-    }
-  })
+  sheet1['!cols'] = columnList
+    .map((i) => {
+      if (['Artwork_Links', 'Client_Label_Links'].includes(i.prop)) {
+        return { wpx: 400 }
+      } else {
+        return { wpx: i.width ? i.width + 30 : 110 }
+      }
+    })
+    .concat([{ wpx: 140 }, { wpx: 140 }, { wpx: 140 }, { wpx: 140 }])
 
   XLSX.utils.book_append_sheet(wb, sheet1, 'sheet1')
   let name = currentTab.value || '未输入箱规'
@@ -530,20 +626,30 @@ const commit = () => {
   })
   // console.log(data, 'data')
   let data2 = data.filter((i) => i.editFlag)
-  // console.log(data2, 'data2')
-  /*loading.value = true
-  zoho.CRM.API.updateRecord({
-    Entity: 'Shipping_Tracking',
-    Trigger: ['workflow'],
-    APIData: data2.map((i) => {
+  console.log(
+    data2.map((i) => {
       return {
         id: i.id,
         Courier: i.Courier,
         Tracking_No: i.Tracking_No,
       }
     }),
-  })
-    .then((res: any) => {
+    'data2',
+  )
+  loading.value = true
+  request
+    .post(
+      'shipping_tracking/updateShippingTracking',
+      data2.map((i) => {
+        return {
+          id: i.id,
+          Courier: i.Courier,
+          Tracking_No: i.Tracking_No,
+        }
+      }),
+    )
+    .then((resp: any) => {
+      const res = resp.data.result || {}
       if (
         Array.isArray(res.data) &&
         res.data.length &&
@@ -597,7 +703,7 @@ const commit = () => {
     })
     .finally(() => {
       loading.value = false
-    })*/
+    })
 }
 </script>
 <style lang="scss" scoped>