摄像头逻辑进行修改,更改分辨率进行快速的读取识别
This commit is contained in:
@ -1,15 +1,49 @@
|
||||
<template>
|
||||
<div class="app-container mobile-optimized">
|
||||
<el-card class="main-card" shadow="never">
|
||||
|
||||
<el-card v-if="!isSessionActive" class="main-card idle-card" shadow="never">
|
||||
<div class="idle-content">
|
||||
<el-icon :size="60" color="#409EFF"><VideoPlay /></el-icon>
|
||||
<h2>库存盘点系统</h2>
|
||||
<p class="subtitle">请确保已连接扫描枪或摄像头</p>
|
||||
|
||||
<div class="idle-actions">
|
||||
<el-button type="primary" size="large" class="w-100" @click="startNewSession" :loading="btnLoading">
|
||||
开始新盘点
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
v-if="serverDraftCount > 0"
|
||||
type="warning"
|
||||
plain
|
||||
size="large"
|
||||
class="w-100"
|
||||
@click="resumeSession"
|
||||
:loading="btnLoading"
|
||||
>
|
||||
继续上次盘点
|
||||
<div class="btn-subtext">(云端已存: {{ serverDraftCount }} 项)</div>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="safe-tip">
|
||||
<el-icon><Cloudy /></el-icon>
|
||||
<span>数据实时同步至服务器,防止意外丢失</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card v-else class="main-card active-card" shadow="never" v-loading="loading">
|
||||
<template #header>
|
||||
<div class="header-row">
|
||||
<div class="title">
|
||||
<span>📷 库存盘点</span>
|
||||
<el-tag v-if="!showList" type="success" size="small" effect="dark">扫描中</el-tag>
|
||||
<el-tag v-else type="info" size="small">暂停</el-tag>
|
||||
<div class="title-box">
|
||||
<span class="title-text">📷 盘点作业中</span>
|
||||
<el-tag v-if="syncStatus === 'success'" type="success" size="small" effect="dark" round>已同步</el-tag>
|
||||
<el-tag v-else-if="syncStatus === 'syncing'" type="warning" size="small" effect="dark" round>同步中...</el-tag>
|
||||
<el-tag v-else type="danger" size="small" effect="dark" round>同步失败</el-tag>
|
||||
</div>
|
||||
<el-button type="primary" plain @click="openInventoryList" icon="List">
|
||||
查看清单/手动查找
|
||||
<el-button type="info" text bg size="small" @click="pauseSession" :icon="VideoPause">
|
||||
暂停/退出
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@ -17,43 +51,47 @@
|
||||
<div class="scanner-container">
|
||||
<div v-if="!showList" class="camera-active-box">
|
||||
<QrScanner @decode="onScanSuccess" />
|
||||
<div class="scan-overlay-tip">将条码对准取景框</div>
|
||||
<div class="scan-overlay-tip">请将条码对准取景框</div>
|
||||
</div>
|
||||
<div v-else class="camera-paused-box" @click="showList = false">
|
||||
<el-icon :size="60" color="#909399"><VideoPause /></el-icon>
|
||||
<p>正在查看清单<br>摄像头已暂停</p>
|
||||
<el-button type="primary" link>点击返回扫描</el-button>
|
||||
<el-icon :size="50" color="#909399"><List /></el-icon>
|
||||
<p>正在查看清单列表<br>摄像头已暂停</p>
|
||||
<el-button type="primary" link>点击返回继续扫描</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats-dashboard">
|
||||
<div class="stats-dashboard" @click="openInventoryList">
|
||||
<div class="stat-card">
|
||||
<div class="stat-val">{{ stats.total }}</div>
|
||||
<div class="stat-label">应盘总数</div>
|
||||
<div class="stat-label">总数</div>
|
||||
</div>
|
||||
<div class="stat-card success">
|
||||
<div class="stat-val">{{ stats.scanned }}</div>
|
||||
<div class="stat-label">已扫(相符)</div>
|
||||
<div class="stat-label">已盘</div>
|
||||
</div>
|
||||
<div class="stat-card error">
|
||||
<div class="stat-val">{{ stats.missing }}</div>
|
||||
<div class="stat-label">差异(未扫)</div>
|
||||
<div class="stat-label">差异</div>
|
||||
</div>
|
||||
<div class="stat-arrow">
|
||||
<el-icon><ArrowRight /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-actions">
|
||||
<el-button
|
||||
type="danger"
|
||||
size="large"
|
||||
class="finish-btn"
|
||||
@click="handleFinish"
|
||||
:loading="printing"
|
||||
:disabled="stats.total === 0"
|
||||
icon="Printer"
|
||||
>
|
||||
结束盘点并打印差异报告
|
||||
</el-button>
|
||||
<p class="printer-tip">目标打印机: 192.168.9.205</p>
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="12">
|
||||
<el-button type="primary" plain size="large" class="w-100 action-btn" @click="openInventoryList" :icon="Search">
|
||||
查看清单
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-button type="danger" size="large" class="w-100 action-btn" @click="openFinishDialog" :icon="Checked">
|
||||
结束盘点
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<p class="printer-tip">打印机 IP: 192.168.9.205</p>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
@ -61,8 +99,7 @@
|
||||
v-model="showList"
|
||||
title="📦 在库物品清单"
|
||||
direction="btt"
|
||||
size="90%"
|
||||
:with-header="true"
|
||||
size="85%"
|
||||
destroy-on-close
|
||||
class="inventory-drawer"
|
||||
>
|
||||
@ -70,48 +107,102 @@
|
||||
<div class="search-bar">
|
||||
<el-input
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索名称 / 规格 / 条码"
|
||||
placeholder="搜索名称 / 规格 / 条码..."
|
||||
prefix-icon="Search"
|
||||
clearable
|
||||
size="large"
|
||||
/>
|
||||
<el-select
|
||||
v-model="filterType"
|
||||
placeholder="类型"
|
||||
style="width: 100px; margin-left: 8px;"
|
||||
size="large"
|
||||
>
|
||||
<el-select v-model="filterType" placeholder="状态" style="width: 110px; margin-left: 8px;">
|
||||
<el-option label="全部" value="all" />
|
||||
<el-option label="采购" value="material" />
|
||||
<el-option label="半成品" value="semi" />
|
||||
<el-option label="成品" value="product" />
|
||||
<el-option label="已盘" value="scanned" />
|
||||
<el-option label="差异" value="missing" />
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="filteredList"
|
||||
height="100%"
|
||||
style="width: 100%; flex: 1;"
|
||||
stripe
|
||||
border
|
||||
row-key="uniqueKey"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="standard" label="规格" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="uuid" label="条码后6位" width="100">
|
||||
<el-table-column prop="name" label="物品名称" min-width="130" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.uuid ? '...' + scope.row.uuid.slice(-6) : '-' }}
|
||||
<div>{{ scope.row.name }}</div>
|
||||
<div style="font-size: 12px; color: #999;">{{ scope.row.standard }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="80" align="center" fixed="right">
|
||||
|
||||
<el-table-column prop="uuid" label="条码尾号" width="90" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.scanned" type="success" effect="dark">已盘</el-tag>
|
||||
<el-tag v-else type="danger" effect="plain">未扫</el-tag>
|
||||
{{ scope.row.uuid ? scope.row.uuid.slice(-6) : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="库存" width="70" align="center">
|
||||
<template #default="scope">
|
||||
<span style="font-weight: bold;">{{ parseFloat(scope.row.qty_stock) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="状态" width="70" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.scanned" type="success" size="small" effect="dark">OK</el-tag>
|
||||
<el-tag v-else type="danger" size="small" effect="plain">未扫</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog
|
||||
v-model="showFinishDialog"
|
||||
title="📊 盘点结算"
|
||||
width="90%"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
class="preview-dialog"
|
||||
>
|
||||
<div class="report-summary">
|
||||
<div class="summary-row">
|
||||
<span>盘点时间:</span>
|
||||
<span>{{ new Date().toLocaleTimeString() }}</span>
|
||||
</div>
|
||||
<div class="summary-stats">
|
||||
<div class="s-item">
|
||||
<div class="num">{{ stats.total }}</div>
|
||||
<div class="txt">总数</div>
|
||||
</div>
|
||||
<div class="s-item success">
|
||||
<div class="num">{{ stats.scanned }}</div>
|
||||
<div class="txt">实盘</div>
|
||||
</div>
|
||||
<div class="s-item error">
|
||||
<div class="num">{{ stats.missing }}</div>
|
||||
<div class="txt">丢失</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="missing-list-header">差异物品 (丢失清单)</div>
|
||||
<el-table :data="missingList" height="250" border size="small" style="margin-bottom: 10px;">
|
||||
<el-table-column prop="name" label="名称" show-overflow-tooltip />
|
||||
<el-table-column prop="qty_stock" label="账存" width="60" align="center" />
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="showFinishDialog = false">返回</el-button>
|
||||
<div class="footer-right">
|
||||
<el-button type="success" @click="generatePDF" :icon="Download" circle title="下载PDF" />
|
||||
<el-button type="primary" @click="confirmPrint" :loading="printing" :icon="Printer">
|
||||
打印报告
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -119,10 +210,17 @@
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { getAllStock, printStocktakeReport } from '@/api/inbound/stock'
|
||||
import QrScanner from '@/components/QrScanner/index.vue'
|
||||
import { ElMessage, ElNotification, ElMessageBox } from 'element-plus'
|
||||
import { Search, List, Printer, VideoPause } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search, VideoPlay, VideoPause, List, Printer, Checked, Download, ArrowRight, Cloudy } from '@element-plus/icons-vue'
|
||||
import jsPDF from 'jspdf'
|
||||
import 'jspdf-autotable'
|
||||
import request from '@/utils/request'
|
||||
import { useUserStore } from '@/stores/user' // 引入UserStore获取真实用户
|
||||
|
||||
// --- 类型定义 ---
|
||||
const userStore = useUserStore()
|
||||
const currentUser = userStore.username || 'admin' // 优先使用登录名
|
||||
|
||||
// --- 数据接口 ---
|
||||
interface StockItem {
|
||||
id: number
|
||||
name: string
|
||||
@ -130,71 +228,192 @@ interface StockItem {
|
||||
batch_no: string
|
||||
uuid: string
|
||||
bar_code: string
|
||||
qty_stock: number
|
||||
scanned: boolean
|
||||
category_type: 'material' | 'semi' | 'product'
|
||||
category_label: string
|
||||
uniqueKey: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
// --- 状态管理 ---
|
||||
// --- 状态变量 ---
|
||||
const loading = ref(false)
|
||||
const btnLoading = ref(false)
|
||||
const printing = ref(false)
|
||||
const showList = ref(false) // 控制抽屉显示
|
||||
const isSessionActive = ref(false) // 会话是否进行中
|
||||
const serverDraftCount = ref(0) // 服务器上的草稿数量
|
||||
const showList = ref(false) // 是否显示抽屉清单
|
||||
const showFinishDialog = ref(false) // 是否显示结算弹窗
|
||||
const syncStatus = ref<'success' | 'syncing' | 'failed'>('success')
|
||||
|
||||
const allData = ref<StockItem[]>([])
|
||||
const scannedSet = ref<Set<string>>(new Set())
|
||||
|
||||
const filterType = ref('all')
|
||||
const searchKeyword = ref('')
|
||||
const allData = ref<StockItem[]>([])
|
||||
|
||||
// --- API 封装 ---
|
||||
const api = {
|
||||
getDrafts: () => request({ url: '/v1/inbound/stock/draft/list', method: 'get', params: { user_id: currentUser } }),
|
||||
addDraft: (data: any) => request({ url: '/v1/inbound/stock/draft/add', method: 'post', data: { ...data, user_id: currentUser } }),
|
||||
clearDraft: () => request({ url: '/v1/inbound/stock/draft/clear', method: 'post', data: { user_id: currentUser } })
|
||||
}
|
||||
|
||||
// --- 初始化 ---
|
||||
const init = async () => {
|
||||
onMounted(async () => {
|
||||
await checkServerDraft()
|
||||
})
|
||||
|
||||
const checkServerDraft = async () => {
|
||||
try {
|
||||
const res: any = await api.getDrafts()
|
||||
if (res && res.length > 0) {
|
||||
serverDraftCount.value = res.length
|
||||
} else {
|
||||
serverDraftCount.value = 0
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('检查草稿失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
// --- 核心业务逻辑 ---
|
||||
|
||||
// 1. 开始新会话 (清空服务器草稿)
|
||||
const startNewSession = async () => {
|
||||
try {
|
||||
if (serverDraftCount.value > 0) {
|
||||
await ElMessageBox.confirm('服务器存在未完成的盘点记录,开始新盘点将清除它们,确定吗?', '新盘点', { type: 'warning' })
|
||||
}
|
||||
btnLoading.value = true
|
||||
await api.clearDraft() // 清空后端
|
||||
scannedSet.value.clear()
|
||||
await loadData() // 拉取库存
|
||||
isSessionActive.value = true
|
||||
} catch (e) {
|
||||
// cancel
|
||||
} finally {
|
||||
btnLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 恢复旧会话 (从服务器拉取草稿)
|
||||
const resumeSession = async () => {
|
||||
btnLoading.value = true
|
||||
try {
|
||||
// 先拉草稿
|
||||
const drafts: any = await api.getDrafts()
|
||||
const draftUUIDs = new Set(drafts.map((d: any) => d.uuid))
|
||||
|
||||
scannedSet.value = draftUUIDs
|
||||
await loadData() // 再拉库存,并匹配状态
|
||||
isSessionActive.value = true
|
||||
} catch (e) {
|
||||
ElMessage.error('恢复进度失败')
|
||||
} finally {
|
||||
btnLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 暂停 (无需做任何事,因为数据是实时同步的)
|
||||
const pauseSession = () => {
|
||||
isSessionActive.value = false
|
||||
checkServerDraft() // 更新一下待机界面的数量显示
|
||||
ElMessage.success('已退出,进度已安全保存在云端')
|
||||
}
|
||||
|
||||
// 4. 加载库存数据
|
||||
const loadData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getAllStock()
|
||||
const list: StockItem[] = []
|
||||
|
||||
const processItem = (item: any, type: 'material' | 'semi' | 'product', label: string) => {
|
||||
const processItem = (item: any, type: string) => {
|
||||
// 逻辑:只要 qty_stock > 0 就算在库
|
||||
const stock = parseFloat(item.stock_quantity || item.qty_stock || 0)
|
||||
if (stock <= 0) return
|
||||
|
||||
const name = item.material_name || item.product_name || item.name || '未知物品'
|
||||
return {
|
||||
const uuid = item.uuid || item.sku || ''
|
||||
|
||||
list.push({
|
||||
...item,
|
||||
name: name,
|
||||
standard: item.standard || '',
|
||||
batch_no: item.batch_no || item.batch_number || '',
|
||||
uuid: item.uuid || item.sku || '',
|
||||
uuid: uuid,
|
||||
bar_code: item.bar_code || item.barcode || '',
|
||||
scanned: false,
|
||||
category_type: type,
|
||||
category_label: label,
|
||||
qty_stock: stock,
|
||||
scanned: scannedSet.value.has(uuid), // 匹配草稿状态
|
||||
uniqueKey: `${type}_${item.id}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (res.materials) res.materials.forEach((i: any) => list.push(processItem(i, 'material', '采购件')))
|
||||
if (res.semis) res.semis.forEach((i: any) => list.push(processItem(i, 'semi', '半成品')))
|
||||
if (res.products) res.products.forEach((i: any) => list.push(processItem(i, 'product', '成品')))
|
||||
if (res.materials) res.materials.forEach((i: any) => processItem(i, 'material'))
|
||||
if (res.semis) res.semis.forEach((i: any) => processItem(i, 'semi'))
|
||||
if (res.products) res.products.forEach((i: any) => processItem(i, 'product'))
|
||||
|
||||
allData.value = list
|
||||
ElMessage.success(`加载成功,共 ${list.length} 件物品`)
|
||||
} catch (e) {
|
||||
ElMessage.error('库存加载失败,请重试')
|
||||
ElMessage.error('库存数据加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// --- 打开清单 (同时会自动触发 v-if 销毁摄像头) ---
|
||||
const openInventoryList = () => {
|
||||
showList.value = true
|
||||
// 5. 扫码成功处理 (实时同步到服务器)
|
||||
const onScanSuccess = async (code: string) => {
|
||||
if (!code) return
|
||||
const trimCode = code.trim()
|
||||
|
||||
const item = allData.value.find(i => i.uuid === trimCode || i.bar_code === trimCode)
|
||||
|
||||
if (item) {
|
||||
if (item.scanned) {
|
||||
ElMessage.warning('重复扫描')
|
||||
return
|
||||
}
|
||||
|
||||
// 前端先响应,不阻塞 UI
|
||||
item.scanned = true
|
||||
scannedSet.value.add(item.uuid)
|
||||
|
||||
if (navigator.vibrate) navigator.vibrate(100);
|
||||
ElMessage.success(`已确认:${item.name}`)
|
||||
|
||||
// 后台静默同步
|
||||
syncStatus.value = 'syncing'
|
||||
try {
|
||||
await api.addDraft({
|
||||
id: item.id,
|
||||
uuid: item.uuid,
|
||||
name: item.name,
|
||||
standard: item.standard,
|
||||
batch_no: item.batch_no,
|
||||
qty_stock: item.qty_stock
|
||||
})
|
||||
syncStatus.value = 'success'
|
||||
} catch (e) {
|
||||
console.error('同步失败', e)
|
||||
syncStatus.value = 'failed'
|
||||
}
|
||||
|
||||
} else {
|
||||
ElMessage.error(`未知条码: ${trimCode}`)
|
||||
if (navigator.vibrate) navigator.vibrate([200, 50, 200]);
|
||||
}
|
||||
}
|
||||
|
||||
// --- 过滤逻辑 ---
|
||||
// --- 计算属性 ---
|
||||
const filteredList = computed(() => {
|
||||
let result = allData.value
|
||||
if (filterType.value !== 'all') {
|
||||
result = result.filter(item => item.category_type === filterType.value)
|
||||
}
|
||||
if (filterType.value === 'scanned') result = result.filter(i => i.scanned)
|
||||
if (filterType.value === 'missing') result = result.filter(i => !i.scanned)
|
||||
if (searchKeyword.value) {
|
||||
const kw = searchKeyword.value.toLowerCase().trim()
|
||||
result = result.filter(item =>
|
||||
(item.name && item.name.toLowerCase().includes(kw)) ||
|
||||
(item.standard && item.standard.toLowerCase().includes(kw)) ||
|
||||
(item.uuid && item.uuid.toLowerCase().includes(kw)) ||
|
||||
(item.bar_code && item.bar_code.toLowerCase().includes(kw))
|
||||
const kw = searchKeyword.value.toLowerCase()
|
||||
result = result.filter(i =>
|
||||
i.name.toLowerCase().includes(kw) ||
|
||||
i.uuid.includes(kw) ||
|
||||
(i.standard && i.standard.toLowerCase().includes(kw)) // 增加对规格的搜索
|
||||
)
|
||||
}
|
||||
return result
|
||||
@ -206,91 +425,99 @@ const stats = computed(() => {
|
||||
return { total, scanned, missing: total - scanned }
|
||||
})
|
||||
|
||||
// --- 扫码逻辑 ---
|
||||
const onScanSuccess = (code: string) => {
|
||||
if (!code) return
|
||||
const trimCode = code.trim()
|
||||
const missingList = computed(() => {
|
||||
return allData.value.filter(i => !i.scanned)
|
||||
})
|
||||
|
||||
const item = allData.value.find(i => i.uuid === trimCode || i.bar_code === trimCode)
|
||||
|
||||
if (item) {
|
||||
if (item.scanned) {
|
||||
ElMessage.warning(`${item.name} 已扫过`)
|
||||
return
|
||||
}
|
||||
item.scanned = true
|
||||
|
||||
// 震动反馈 (如果设备支持)
|
||||
if (navigator.vibrate) navigator.vibrate(200);
|
||||
|
||||
ElNotification({
|
||||
title: '✅ 匹配成功',
|
||||
message: `${item.name}\n${item.standard}`,
|
||||
type: 'success',
|
||||
duration: 2000,
|
||||
position: 'top-left' // 移动端通常顶部提示更明显
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(`未找到: ${trimCode}`)
|
||||
if (navigator.vibrate) navigator.vibrate([100, 50, 100]);
|
||||
}
|
||||
// --- 界面交互 ---
|
||||
const openInventoryList = () => { showList.value = true }
|
||||
const openFinishDialog = () => {
|
||||
if (stats.value.total === 0) return
|
||||
showFinishDialog.value = true
|
||||
}
|
||||
|
||||
// --- 结束打印 ---
|
||||
const handleFinish = async () => {
|
||||
if (stats.value.total === 0) return
|
||||
// 生成 PDF (包含中文支持提示)
|
||||
const generatePDF = () => {
|
||||
const doc = new jsPDF()
|
||||
|
||||
// 提示:默认 jspdf 不支持中文,需要 addFont。
|
||||
// 这里使用英文表头以确保基础可用性,实际生产需自行引入中文字体文件
|
||||
doc.setFontSize(18)
|
||||
doc.text("Inventory Stocktake Report", 14, 22)
|
||||
|
||||
doc.setFontSize(11)
|
||||
doc.text(`Time: ${new Date().toLocaleString()}`, 14, 30)
|
||||
doc.text(`Total: ${stats.value.total} | Scanned: ${stats.value.scanned} | Missing: ${stats.value.missing}`, 14, 38)
|
||||
|
||||
const tableData = missingList.value.map(item => [
|
||||
item.uuid,
|
||||
item.name,
|
||||
item.standard,
|
||||
item.qty_stock.toString()
|
||||
])
|
||||
|
||||
;(doc as any).autoTable({
|
||||
head: [['UUID', 'Name', 'Spec', 'Stock']],
|
||||
body: tableData,
|
||||
startY: 45,
|
||||
theme: 'grid'
|
||||
})
|
||||
doc.save(`inventory_report_${Date.now()}.pdf`)
|
||||
}
|
||||
|
||||
// 打印并清除服务器草稿
|
||||
const confirmPrint = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`应盘: ${stats.value.total} | 差异: ${stats.value.missing}\n确认结束并打印?`,
|
||||
'结束盘点',
|
||||
{ confirmButtonText: '打印报告', cancelButtonText: '取消', type: 'warning', center: true }
|
||||
)
|
||||
|
||||
const missingItems = allData.value.filter(i => !i.scanned)
|
||||
const payload = {
|
||||
total: stats.value.total,
|
||||
scanned: stats.value.scanned,
|
||||
missing: stats.value.missing,
|
||||
missing_items: missingItems
|
||||
missing_items: missingList.value
|
||||
}
|
||||
|
||||
printing.value = true
|
||||
await printStocktakeReport(payload)
|
||||
ElMessage.success('打印指令已发送')
|
||||
ElMessage.success('已发送至打印机')
|
||||
|
||||
// 任务完成,清空服务器草稿
|
||||
await api.clearDraft()
|
||||
|
||||
scannedSet.value.clear()
|
||||
isSessionActive.value = false
|
||||
showFinishDialog.value = false
|
||||
checkServerDraft() // 刷新计数
|
||||
} catch (e) {
|
||||
if (e !== 'cancel') ElMessage.error('打印失败')
|
||||
ElMessage.error('打印失败')
|
||||
} finally {
|
||||
printing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 移动端容器适配 */
|
||||
.app-container.mobile-optimized {
|
||||
padding: 10px;
|
||||
max-width: 600px; /* 在平板/PC上限制宽度,保持手机观感 */
|
||||
max-width: 600px; /* 限制最大宽度,保持手机观感 */
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* 头部样式 */
|
||||
.header-row {
|
||||
/* 待机卡片 */
|
||||
.idle-card {
|
||||
min-height: 400px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
.header-row .title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
.idle-content { width: 100%; padding: 20px; }
|
||||
.subtitle { color: #909399; margin-bottom: 30px; }
|
||||
.idle-actions { display: flex; flex-direction: column; gap: 15px; }
|
||||
.btn-subtext { font-size: 12px; opacity: 0.8; margin-top: 2px; }
|
||||
.safe-tip { margin-top: 30px; font-size: 12px; color: #67c23a; display: flex; align-items: center; justify-content: center; gap: 5px; }
|
||||
|
||||
/* 头部 */
|
||||
.header-row { display: flex; justify-content: space-between; align-items: center; }
|
||||
.title-box { display: flex; align-items: center; gap: 8px; font-weight: bold; font-size: 16px; }
|
||||
|
||||
/* 扫描区域 */
|
||||
.scanner-container {
|
||||
@ -300,92 +527,55 @@ onMounted(() => {
|
||||
overflow: hidden;
|
||||
margin-bottom: 15px;
|
||||
position: relative;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.camera-active-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.camera-active-box { width: 100%; height: 100%; }
|
||||
.scan-overlay-tip {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
font-size: 12px;
|
||||
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
|
||||
padding: 10px 0;
|
||||
pointer-events: none;
|
||||
position: absolute; bottom: 15px; left: 0; width: 100%;
|
||||
text-align: center; color: rgba(255,255,255,0.9); font-size: 13px; pointer-events: none;
|
||||
text-shadow: 0 1px 3px rgba(0,0,0,0.8);
|
||||
}
|
||||
|
||||
.camera-paused-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: #f0f2f5;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
width: 100%; height: 100%; display: flex; flex-direction: column;
|
||||
justify-content: center; align-items: center; background: #f2f3f5; color: #909399; cursor: pointer;
|
||||
}
|
||||
|
||||
/* 统计仪表盘 */
|
||||
.stats-dashboard {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stat-card {
|
||||
flex: 1;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
padding: 15px 5px;
|
||||
text-align: center;
|
||||
border: 1px solid #ebeef5;
|
||||
}
|
||||
.stat-card .stat-val {
|
||||
font-size: 24px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.stat-card .stat-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
display: flex; align-items: center;
|
||||
background: #f8f9fa; border: 1px solid #ebeef5;
|
||||
border-radius: 8px; padding: 10px; margin-bottom: 20px;
|
||||
cursor: pointer; transition: all 0.2s; position: relative;
|
||||
}
|
||||
.stats-dashboard:active { background: #f0f2f5; }
|
||||
.stat-card { flex: 1; text-align: center; }
|
||||
.stat-val { font-size: 20px; font-weight: 800; line-height: 1.2; }
|
||||
.stat-label { font-size: 11px; color: #909399; }
|
||||
.stat-card.success .stat-val { color: #67c23a; }
|
||||
.stat-card.error .stat-val { color: #f56c6c; }
|
||||
.stat-arrow { width: 20px; color: #c0c4cc; }
|
||||
|
||||
/* 底部按钮 */
|
||||
.main-actions {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.finish-btn {
|
||||
height: 50px;
|
||||
font-size: 16px;
|
||||
border-radius: 25px; /* 圆角按钮更好点 */
|
||||
}
|
||||
.printer-tip {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 12px;
|
||||
}
|
||||
/* 底部操作 */
|
||||
.w-100 { width: 100%; }
|
||||
.action-btn { font-weight: bold; height: 48px; }
|
||||
.printer-tip { text-align: center; color: #c0c4cc; font-size: 12px; margin-top: 15px; }
|
||||
|
||||
/* 抽屉内容布局 */
|
||||
.drawer-content {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
}
|
||||
.search-bar {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
/* 抽屉样式 */
|
||||
.drawer-content { height: 100%; display: flex; flex-direction: column; padding: 10px; }
|
||||
.search-bar { display: flex; margin-bottom: 10px; }
|
||||
|
||||
/* 结算弹窗 */
|
||||
.report-summary {
|
||||
background: #f5f7fa; padding: 15px; border-radius: 6px; margin-bottom: 15px;
|
||||
}
|
||||
.summary-row { display: flex; justify-content: space-between; margin-bottom: 15px; color: #606266; font-size: 13px; }
|
||||
.summary-stats { display: flex; justify-content: space-between; text-align: center; }
|
||||
.s-item .num { font-size: 18px; font-weight: bold; }
|
||||
.s-item .txt { font-size: 12px; color: #909399; }
|
||||
.s-item.success .num { color: #67c23a; }
|
||||
.s-item.error .num { color: #f56c6c; }
|
||||
|
||||
.missing-list-header { font-weight: bold; margin-bottom: 8px; font-size: 13px; border-left: 3px solid #f56c6c; padding-left: 8px; }
|
||||
.dialog-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
|
||||
.footer-right { display: flex; gap: 10px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user