ソースを参照

添加图片预览

zengjun 7 ヶ月 前
コミット
aaeca7e4c5
1 ファイル変更75 行追加57 行削除
  1. 75 57
      src/views/returned/register/index.vue

+ 75 - 57
src/views/returned/register/index.vue

@@ -93,7 +93,6 @@
                 label="仓库"
                 placeholder="选择仓库"
                 :model-value="getWarehouseName()"
-                v-model="params.warehouseCode"
                 @click="warehousePickerShow = true"
               />
               <van-popup
@@ -268,6 +267,7 @@
                         <van-col span="4">
                           <van-image
                             :key="`box-photos-${index}-${imgIndex}`"
+                            @click="previewImages(item.boxPhotos,imgIndex,'外箱图')"
                             width="100%"
                             height="50"
                             :src="i.src"
@@ -286,6 +286,7 @@
                         <van-col span="4">
                           <van-image
                             :key="`product-photos-${index}-${imgIndex}`"
+                            @click="previewImages(item.productPhotos,imgIndex,'内物图')"
                             width="100%"
                             height="50"
                             :src="i.src"
@@ -379,17 +380,20 @@
             <div style="max-height: 70vh; overflow-y: auto">
               <van-field
                 v-model="selectDetail.sku"
+                label="SKU"
                 placeholder="SKU"
                 clearable
               />
               <van-field
                 readonly
                 v-model="selectDetail.barCode"
+                label="商品条码"
                 placeholder="商品条码"
                 clearable
               />
               <van-field
                 v-model="selectDetail.tradeName"
+                label="商品名称"
                 placeholder="商品名称"
                 readonly
               />
@@ -465,6 +469,7 @@
               <van-field
                 autocomplete="off"
                 v-model="selectDetail.batchNumber"
+                label="批次号"
                 placeholder="批次号"
                 clearable
               />
@@ -677,7 +682,7 @@ import {
   showLoadingToast,
   closeToast,
   showConfirmDialog,
-  showDialog,
+  showImagePreview,
 } from 'vant'
 import { getHeader, goBack } from '@/utils/android'
 import {
@@ -713,7 +718,8 @@ const maxDate = ref(new Date((new Date().getFullYear() + 50, 0, 1)))
 
 const showInitialPage = ref(true)
 const expressNo = ref(null)
-const warehouse = ref(useStore.warehouse)
+const store = useStore()
+const warehouse = store.warehouse
 // 当前选择的货主
 
 const title = computed(() => {
@@ -753,12 +759,6 @@ onMounted(() => {
   const endOfCenturyYear = currentCentury + 99
   maxDate.value = new Date(endOfCenturyYear, 0, 1)
 
-  console.log(`on mounted1:${warehouse.value} : ${useStore.warehouse}`)
-  if (!warehouse.value) {
-    warehouse.value = ref(useStore.warehouse)
-    console.log(`on mounted2:${warehouse.value} : ${useStore.warehouse}`)
-  }
-
   getOwner().then((res) => {
     const { data } = res
     owners.value = data.map((item) => {
@@ -827,11 +827,6 @@ function getBoxItems(detail) {
   if (!boxPhotos || boxPhotos.length === 0) {
     return []
   }
-  boxFiles.value.forEach((item) => {
-    console.log(item)
-    console.log(boxPhotos.includes(item.fileName))
-  })
-  console.log(boxFiles.value.filter((_) => true))
   return boxFiles.value.filter((item) => boxPhotos.includes(item.fileName))
 }
 
@@ -879,7 +874,6 @@ const qualityInspection = ref(null)
 
 // 初始化质检状态
 function initQualityInspection(owner) {
-  console.log(owner)
   getQualityInspection(owner).then((res) => {
     qualityInspection.value = res.data
   })
@@ -997,9 +991,7 @@ function initDetail() {
 // 承运商选择
 const logisticPickerShow = ref(false)
 const selectedLogistic = (row) => {
-  console.log(row)
   const { selectedOptions } = row
-  console.log(selectedOptions)
   logisticPickerShow.value = false
   params.value.logisticsName = selectedOptions[0].text
 }
@@ -1017,12 +1009,10 @@ const selectedOwner = (row) => {
 
 // 仓库选择
 const warehousePickerShow = ref(false)
-const warehouseName = ref('')
 const selectedWarehouse = (row) => {
-  const { selectedValues, selectedOptions } = row
+  const { selectedOptions } = row
   warehousePickerShow.value = false
-  params.value.warehouseCode = selectedValues
-  warehouseName.value = selectedOptions[0].text
+  params.value.warehouseCode = selectedOptions[0].value
 }
 
 // 店铺选择
@@ -1045,9 +1035,10 @@ function getOwnerName(owner) {
 
 // 仓库名
 function getWarehouseName() {
-  console.log(warehousesMap)
-  console.log(warehouse.value)
-  return warehousesMap.value[warehouse.value]
+  console.log(warehousesMap.value)
+  console.log(params.value.warehouseCode)
+  console.log(warehousesMap.value[params.value.warehouseCode])
+  return warehousesMap.value[params.value.warehouseCode]
 }
 
 // 输入快递单号
@@ -1136,7 +1127,7 @@ function matchOrder(expressNo) {
       showNotify({ type: 'success', message: '匹配到原单信息' })
       params.value.upstreamNo = upstreamNo
       params.value.ownerCode = ownerCode
-      params.value.warehouseCode = warehouse.value
+      params.value.warehouseCode = warehouse
       params.value.storeName = shopName
       params.value.logisticsName = logisticName
       params.value.buyerName = handlerLongText(recipientName)
@@ -1144,6 +1135,7 @@ function matchOrder(expressNo) {
       params.value.originalNo = '原单退回'
       params.value.sendNo = null
       initQualityInspection(params.value.ownerCode)
+      getStoreOptionsBy(ownerCode)
       if (!details || details.length === 0) {
         return
       }
@@ -1233,17 +1225,18 @@ function matchAsn(expressNo) {
     params.value.returnNo = expressNo
     params.value.upstreamNo = upstreamNo
     params.value.ownerCode = ownerCode
-    params.value.warehouseCode = warehouse.value
+    params.value.warehouseCode = warehouse
     params.value.storeName = shopName
     params.value.logisticsName = logisticName
     params.value.buyerName = handlerLongText(recipientName)
     params.value.buyerPhone = handlerLongText(phone)
-    params.value.originalNo = ''
+    params.value.originalNo = null
     params.value.sendNo = null
-    matchCarrier(expressNo)
     params.value.details = []
-    initDetail()
+    matchCarrier(expressNo)
+    getStoreOptionsBy(ownerCode)
     initQualityInspection(params.value.ownerCode)
+    initDetail()
   })
 }
 
@@ -1287,13 +1280,12 @@ function initExpressNo(no) {
 
 // 重置提交 恢复到扫描快递单号页面
 function init(showInputPage = true) {
-  warehouseName.value = null
   ownerName.value = null
   clearImageFileCache()
   params.value = {
     orderUpstream: null,
     returnNo: null,
-    warehouseCode: null,
+    warehouseCode: warehouse,
     logisticsName: null,
     storeName: null,
     orderUpSteam: null,
@@ -1353,7 +1345,7 @@ async function queryBarcode() {
     message: '查询商品信息中.....',
   })
   const barcode = scancode.value
-  const { ownerCode,details } = params.value
+  const { ownerCode, details } = params.value
   if (ownerCode) {
     const result = await queryOwnerBarcode(ownerCode, barcode)
     if (result) {
@@ -1371,12 +1363,7 @@ async function queryBarcode() {
   }
 }
 
-/**
- * 更具货主查询商品条码
- * @param ownerCode
- * @param barcode
- * @returns {Promise<boolean>}
- */
+// 根据获取查询信息
 async function queryOwnerBarcode(ownerCode, barcode) {
   try {
     console.log('queryOwnerBarcode')
@@ -1396,11 +1383,6 @@ async function queryOwnerBarcode(ownerCode, barcode) {
   return false
 }
 
-/**
- * 查询对应的
- * @param barcode
- * @returns {Promise<boolean>}
- */
 async function queryBarcodeBy(barcode) {
   try {
     const results = await searchBarcode({ barcode })
@@ -1426,7 +1408,11 @@ function addDetailByBasSku(basSku) {
   const { sku, barCode, ownerCode, tradeName, accessories } = basSku
   selectDetailIndex.value = -1
   selectDetail.value.sku = sku
-  if (!params.value.ownerCode || params.value.details.length === 0 ) {
+  if (
+    !params.value.ownerCode ||
+    !params.value.details ||
+    params.value.details.length === 0
+  ) {
     params.value.ownerCode = ownerCode
     initQualityInspection(params.value.ownerCode)
     getStoreOptionsBy(params.value.ownerCode)
@@ -1492,7 +1478,7 @@ const manufactureTimeConfirm = async (result) => {
   const formattedDay = day.padStart(2, '0')
   const manufactureTime = `${year}-${formattedMonth}-${formattedDay}`
   const { sku } = selectDetail.value
-  const { owner: ownerCode } = params.value
+  const { ownerCode } = params.value
   const isValid = await checkValidateDate(
     ownerCode,
     sku,
@@ -1566,7 +1552,8 @@ const addDetails = async () => {
     return
   }
   const searchIndex = params.value.details.findIndex((item) => {
-    const { sku, batchNumber, qualityStatus, validityTime, manufactureTime } = item
+    const { sku, batchNumber, qualityStatus, validityTime, manufactureTime } =
+      item
     return (
       sku === detailSku &&
       batchNumber === detailBatchNumber &&
@@ -1582,7 +1569,8 @@ const addDetails = async () => {
     })
       .then(() => {
         const { number } = params.value.details[searchIndex]
-        params.value.details[searchIndex].number = Number(detailNumber) + Number(number)
+        params.value.details[searchIndex].number =
+          Number(detailNumber) + Number(number)
         showNotify({ type: 'success', message: '合并成功' })
       })
       .catch(() => {
@@ -1637,14 +1625,15 @@ function selectOwner({ selectedValues }) {
   getStoreOptionsBy(ownerCode)
   // 货主
 }
-const ownerRef=ref(null)
 
-function showOwnerSelectFunc(){
+const ownerRef = ref(null)
+
+function showOwnerSelectFunc() {
   ownerRef.value?.show(1)
 }
 
 // 指定货主
-const onOwner = (item,type)=>{
+const onOwner = (item, type) => {
   params.value.ownerCode = item.code
   getStoreOptionsBy(item.code)
 }
@@ -2053,16 +2042,45 @@ window.onRefresh = async () => {
   console.log('window.onRefresh')
 }
 
-function clearImageFileCache(){
-  if(productFiles.value && productFiles.value.length > 0) {
-    productFiles.value.map(item=> item.src)
-      .forEach(item=>URL.revokeObjectURL(item))
+function clearImageFileCache() {
+  if (productFiles.value && productFiles.value.length > 0) {
+    productFiles.value
+      .map((item) => item.src)
+      .forEach((item) => URL.revokeObjectURL(item))
   }
-  if(boxFiles.value && boxFiles.value.length > 0) {
-    boxFiles.value.map(item=> item.src)
-      .forEach(item=>URL.revokeObjectURL(item))
+  if (boxFiles.value && boxFiles.value.length > 0) {
+    boxFiles.value
+      .map((item) => item.src)
+      .forEach((item) => URL.revokeObjectURL(item))
   }
+}
 
+function previewImages(filenames, index, type) {
+  let list = []
+  if (type === '外箱图') {
+    list = boxFiles.value
+  } else if (type === '内物图') {
+    list = productFiles.value
+  }
+  console.log(filenames)
+  console.log(list)
+  const images = []
+  for (let i = 0; i < list.length; i++) {
+    const item = list[i]
+    const { src, fileName } = item
+    if (filenames.includes(fileName)) {
+      images.push(src)
+    }
+  }
+  console.log(images)
+  if(!images || images.length === 0) {
+    return
+  }
+  console.log(images)
+  showImagePreview({
+    images: images,
+    startPosition: index,
+  })
 }
 </script>