ZN
9 天以前 796c6f914284aacd7b4abdaf50e6ff06df7faf71
feat(扫码弹窗): 优化扫码列表显示并调整API调用

- 新增detailManagement API用于获取扫码详情
- 替换detailManagementByCustom为detailManagement API调用
- 优化扫码列表显示字段,增加产品高度、美元单价等信息
- 添加时间格式化函数,美化时间显示格式
- 注释导出表格按钮功能
- 调整字段映射关系,如productName替换productCategory
已修改2个文件
109 ■■■■■ 文件已修改
src/api/inventoryManagement/receiptManagement.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/components/ScanListPopup.vue 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/inventoryManagement/receiptManagement.js
@@ -51,6 +51,13 @@
    params: query,
  });
}
export function detailManagement(query) {
    return request({
      url: "/stockInventory/getById",
      method: "get",
        params:query,
    });
}
// 采购入库-详情
export function stockinDetail(query) {
  return request({
src/pages/components/ScanListPopup.vue
@@ -25,13 +25,13 @@
                >
                    {{ isScanning ? '扫码中...' : '继续扫码' }}
                </up-button>
                <up-button
                    type="success"
                    size="small"
                    @click="exportToCSV"
                >
                    导出表格
                </up-button>
<!--                <up-button -->
<!--                    type="success" -->
<!--                    size="small" -->
<!--                    @click="exportToCSV"-->
<!--                >-->
<!--                    导出表格-->
<!--                </up-button>-->
                <up-button 
                    type="error" 
                    size="small" 
@@ -56,7 +56,7 @@
                    >
                        <view class="item-header">
                            <text class="item-index">#{{ index + 1 }}</text>
                            <text class="item-time">{{ item.scanTime }}</text>
                            <text class="item-time">{{  formatTime(item.scanTime) }}</text>
                            <view class="item-delete" @click="deleteItem(index)">
                                <up-icon name="trash" size="16" color="#f56c6c"></up-icon>
                            </view>
@@ -69,35 +69,43 @@
                            </view>
                            <view class="item-row">
                                <text class="item-label">产品名称:</text>
                                <text class="item-value">{{ item.productCategory || '-' }}</text>
                                <text class="item-value">{{ item.productName || '-' }}</text>
                            </view>
                          <view class="item-row">
                            <text class="item-label">产品高度:</text>
                            <text class="item-value">{{ item.height || '-' }}</text>
                          </view>
                          <view class="item-row">
                            <text class="item-label">单位:</text>
                            <text class="item-value">{{ item.specificationModelUnit || '-' }}</text>
                          </view>
                            <view class="item-row">
                                <text class="item-label">产品高度:</text>
                                <text class="item-value">{{ item.specificationModelUnit || '-' }}</text>
                            </view>
                            <view class="item-row">
                                <text class="item-label">单价(美元)/件:</text>
                                <text class="item-label">单价(人民币)/件:</text>
                                <text class="item-value">{{ item.taxInclusiveUnitPrice || '-' }}</text>
                            </view>
                          <view class="item-row">
                            <text class="item-label">单价(美元)/件:</text>
                            <text class="item-value">{{ item.dollarPrice || '-' }}</text>
                          </view>
                            <view class="item-row">
                                <text class="item-label">入库数量/件:</text>
                                <text class="item-value">{{ item.inboundNum || '-' }}</text>
                                <text class="item-value">{{ item.qualitity || '-' }}</text>
                            </view>
                            <view class="item-row">
                                <text class="item-label">每件数量/支:</text>
                                <text class="item-value">{{ item.boxNum || '-' }}</text>
                            </view>
                            <view class="item-row">
                                <text class="item-label">纸箱规格:</text>
                                <text class="item-value">{{ item.cartonSpecifications || '-' }}</text>
                                <text class="item-label">规格型号:</text>
                                <text class="item-value">{{ item.model || '-' }}</text>
                            </view>
                            <view class="item-row">
                                <text class="item-label">入库人:</text>
                                <text class="item-value">{{ item.createBy || '-' }}</text>
                                <text class="item-value">{{ item.createUserName || '-' }}</text>
                            </view>
                            <view class="item-row">
                                <text class="item-label">入库时间:</text>
                                <text class="item-value">{{ item.inboundDate || '-' }}</text>
                                <text class="item-value">{{ item.createTime || '-' }}</text>
                            </view>
                        </view>
                    </view>
@@ -106,17 +114,17 @@
        </view>
    </uni-popup>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { stockinDetail, detailManagementByCustom, exportScanList } from '@/api/inventoryManagement/receiptManagement'
import { stockinDetail, detailManagementByCustom,detailManagement, exportScanList } from '@/api/inventoryManagement/receiptManagement'
import config from '@/config'
import { getToken } from '@/utils/auth'
import request from '@/utils/request'
const baseUrl = config.imgUrl
const emit = defineEmits(['scan', 'close']);
// 弹窗显示状态
const popupRef = ref();
const isScanning = ref(false);
@@ -165,18 +173,17 @@
        });
        return;
    }
    let barcodeList = barcode.split(",");
    let barcodeId = barcodeList[0];
    let type = barcodeList[1];
    let detailApi = null;
    if (type == 1) {
        detailApi = stockinDetail;
    } else if (type == 2) {
        detailApi = detailManagementByCustom;
        detailApi = detailManagement;
    }
    if (!detailApi) {
        uni.showToast({
            title: "请扫描正确的二维码",
@@ -185,8 +192,9 @@
        });
        return;
    }
    // 检查是否已存在
  console.log("scanList",scanList)
    const existingIndex = scanList.findIndex(item => item.barcodeId === barcodeId && item.type === type);
    if (existingIndex !== -1) {
        uni.showToast({
@@ -196,17 +204,18 @@
        });
        return;
    }
    try {
        uni.showLoading({
            title: '获取产品信息中...',
            mask: true
        });
        console.log('barcodeId',barcodeId);
        const resp = await detailApi({ id: barcodeId });
        console.log('resp',resp );
        uni.hideLoading();
        if (resp.code != 200) {
            uni.showToast({
                title: resp.msg,
@@ -215,7 +224,7 @@
            });
            return;
        }
        if (!resp.data) {
            uni.showToast({
                title: '商品不存在',
@@ -224,7 +233,7 @@
            });
            return;
        }
        // 添加到列表
        const scanTime = new Date().toLocaleString('zh-CN', {
            year: 'numeric',
@@ -234,7 +243,7 @@
            minute: '2-digit',
            second: '2-digit'
        });
        scanList.push({
            barcodeId: barcodeId,
            type: type,
@@ -242,16 +251,16 @@
            ...resp.data,
            specificationModelUnit: (resp.data.specificationModel || '') + (resp.data.unit || '')
        });
        uni.showToast({
            title: '扫码成功',
            icon: 'success',
            duration: 1500
        });
        // 触发扫码事件
        emit('scan', resp.data);
    } catch (error) {
        uni.hideLoading();
        uni.showToast({
@@ -320,16 +329,16 @@
            barcodeId: item.barcodeId,
            type: item.type,
            scanTime: item.scanTime,
            productCategory: item.productCategory,
          productName: item.productName,
            specificationModel: item.specificationModel,
            unit: item.unit,
            specificationModelUnit: item.specificationModelUnit,
            taxInclusiveUnitPrice: item.taxInclusiveUnitPrice,
            inboundNum: item.inboundNum,
            qualitity: item.qualitity,
            boxNum: item.boxNum,
            cartonSpecifications: item.cartonSpecifications,
            createBy: item.createBy,
            inboundDate: item.inboundDate,
            model: item.model,
            createUserName: item.createUserName,
            createTime: item.createTime,
            url: item.url
        }));
@@ -443,6 +452,15 @@
    }
};
// 时间格式化函数
// 时间格式化函数
const formatTime = (timestamp) => {
  if (!timestamp) return '';
  const time = timestamp.toString().length === 10 ? timestamp * 1000 : timestamp;
  const date = new Date(time);
  return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;
};
// 弹窗打开事件
const handleOpen = () => {
    // 弹窗打开时的处理