|
|
<template> <div class="pda-container"> <!-- 头部栏 --> <div class="header-bar"> <div class="header-left" @click="$router.back()"> <i class="el-icon-arrow-left"></i> <span>其他出库</span> </div> <div class="header-right" @click="$router.push({ path: '/' })"> 首页 </div> </div>
<!-- 搜索框 --> <div class="search-container"> <el-input clearable v-model="searchCode" placeholder="请扫描出库单或关联单号" prefix-icon="el-icon-search" @keyup.enter.native="handleSearch" ref="searchInput" /> </div>
<!-- 出库单列表 --> <div class="content-area"> <div v-for="(item, index) in outboundList" :key="index" class="outbound-card" @click="goToOutboundPage(item)" > <div class="card-title"> <span class="title-label">出库单号</span> <span class="title-value">{{ item.outboundNo }}</span> </div>
<div class="card-details"> <div class="detail-item"> <div class="detail-label">关联订单</div> <div class="detail-value">{{ item.relatedNo }}</div> </div> <div class="detail-item"> <div class="detail-label">标签张数</div> <div class="detail-value"> <span class="qualified">{{ item.availableLabels }}</span><span class="total">{{ item.totalLabels }}</span> </div> </div> <div class="detail-item"> <div class="detail-label">物料总数</div> <div class="detail-value"> <span class="qualified">{{ item.availableQty }}</span><span class="total">{{ item.totalQty }}</span> </div> </div> </div> </div>
<!-- 空状态 --> <div v-if="outboundList.length === 0 && !loading" class="empty-state"> <i class="el-icon-box"></i> <p>暂无待出库单据</p> </div>
<!-- 加载状态 --> <div v-if="loading" class="loading-state"> <i class="el-icon-loading"></i> <p>加载中...</p> </div> </div> </div></template>
<script>import { getOtherOutboundList } from "@/api/other-outbound/other-outbound.js";import { getCurrentWarehouse } from '@/utils'import moment from 'moment';
export default { data() { return { searchCode: '', outboundList: [], loading: false }; }, methods: { formatDate(date) { return date ? moment(date).format('YYYY-MM-DD') : ''; },
// 处理搜索
handleSearch() { if (this.searchCode.trim()) { this.searchOutboundList(this.searchCode.trim()); } else { this.loadOutboundList(); } },
// 加载其他出库单列表
loadOutboundList() { const currentWarehouse = getCurrentWarehouse(); if (!currentWarehouse) { this.$message.error('请先选择仓库'); return; } this.loading = true; const params = { warehouseId: currentWarehouse, site: localStorage.getItem('site'), status: '待出库', }; getOtherOutboundList(params).then(({ data }) => { this.loading = false; if (data && data.code === 0) { this.outboundList = data.data || []; } else { this.$message.error(data.msg || '获取数据失败'); } }).catch(error => { this.loading = false; console.error('获取其他出库单列表失败:', error); this.$message.error('获取数据失败'); }); },
// 搜索特定出库单
searchOutboundList(searchCode) { const currentWarehouse = getCurrentWarehouse(); if (!currentWarehouse) { this.$message.error('请先选择仓库'); return; } this.loading = true; const params = { warehouseId: currentWarehouse, searchCode: searchCode, site: localStorage.getItem('site'), status: '待出库' }; getOtherOutboundList(params).then(({ data }) => { this.loading = false; if (data && data.code === 0) { if (data.data.length === 0) { this.$message.warning('未找到匹配的出库单'); } this.outboundList = data.data || []; } else { this.$message.error(data.msg || '查询失败'); } }).catch(error => { this.loading = false; console.error('搜索失败:', error); this.$message.error('查询失败'); }); },
// 跳转到出库页面
goToOutboundPage(item) { this.$router.push({ name: 'otherOutboundDetail', params: { buNo: item.buNo, outboundNo: item.outboundNo, relatedNo: item.relatedNo } }); } },
mounted() { // 聚焦搜索框
this.$nextTick(() => { if (this.$refs.searchInput) { this.$refs.searchInput.focus(); } });
// 加载数据
this.loadOutboundList(); }};</script>
<style scoped>.pda-container { width: 100vw; height: 100vh; display: flex; flex-direction: column; background: #f5f5f5;}
/* 头部栏 */.header-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: #17B3A3; color: white; height: 40px; min-height: 40px;}
.header-left { display: flex; align-items: center; cursor: pointer; font-size: 16px; font-weight: 500;}
.header-left i { margin-right: 8px; font-size: 18px;}
.header-right { cursor: pointer; font-size: 16px; font-weight: 500;}
/* 搜索容器 */.search-container { padding: 12px 16px; background: white;}
/* 内容区域 */.content-area { flex: 1; overflow-y: auto; padding: 12px 16px;}
/* 出库卡片 */.outbound-card { background: white; border-radius: 8px; margin-bottom: 12px; padding: 16px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); cursor: pointer; transition: all 0.2s ease;}
.outbound-card:hover { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); transform: translateY(-1px);}
.outbound-card:active { transform: translateY(0);}
/* 卡片标题 */.card-title { margin-bottom: 12px;}
.title-label { font-size: 12px; color: #666; display: block; margin-bottom: 4px;}
.title-value { font-size: 16px; font-weight: bold; color: #333; margin-left: 20px;}
/* 卡片详情 */.card-details { display: flex; justify-content: space-between; align-items: flex-start; gap: 4px;}
.detail-item { flex: 1; text-align: center; min-width: 60px; max-width: 60px;}
.detail-label { font-size: 11px; color: #666; margin-bottom: 4px; line-height: 1.2; margin-left: -12px;}
.detail-value { font-size: 13px; color: #333; line-height: 1.2; margin-left: -12px;}
.detail-value .qualified { color: #17B3A3; font-weight: 500;}
.detail-value .total { color: #333; font-weight: 500;}
.detail-value .total::before { content: '/'; color: #333;}
/* 空状态 */.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: #999;}
.empty-state i { font-size: 48px; margin-bottom: 16px;}
.empty-state p { font-size: 14px; margin: 0;}
/* 加载状态 */.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: #17B3A3;}
.loading-state i { font-size: 24px; margin-bottom: 12px; animation: spin 1s linear infinite;}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); }}
.loading-state p { font-size: 14px; margin: 0;}
/* 响应式设计 */@media (max-width: 360px) { .header-bar { padding: 8px 12px; }
.search-container { padding: 8px 12px; }
.content-area { padding: 8px 12px; }
.outbound-card { padding: 12px; }
.card-details { flex-wrap: wrap; gap: 6px; }
.detail-item { flex: 0 0 48%; margin-bottom: 6px; min-width: 50px; }}</style>
|