| | |
| | | <template> |
| | | <div class="app-container weighbridge-page"> |
| | | <!-- 页头 --> |
| | | <div class="page-head"> |
| | | <div class="head-text"> |
| | | <h2>无人值守地磅</h2> |
| | | <p>自动采集皮重、毛重,红外防作弊,匹配采购/销售订单并推送 ERP。</p> |
| | | </div> |
| | | <el-button type="primary" :icon="VideoPlay" @click="openWeigh">开始自动称重</el-button> |
| | | </div> |
| | | |
| | | <!-- 概览 --> |
| | | <div class="stat-row"> |
| | | <div class="stat"> |
| | | <span class="stat-label">过磅记录</span> |
| | | <span class="stat-value">{{ total }}<i>条</i></span> |
| | | <div class="overview-row"> |
| | | <div class="overview-card"> |
| | | <div class="label">今日过磅车次</div> |
| | | <div class="value">{{ overview.todayCount || 0 }}</div> |
| | | </div> |
| | | <div class="stat"> |
| | | <span class="stat-label">本页异常</span> |
| | | <span class="stat-value warn">{{ pageAbnormal }}<i>条</i></span> |
| | | <div class="overview-card"> |
| | | <div class="label">待完成称重</div> |
| | | <div class="value warning">{{ overview.pendingCount || 0 }}</div> |
| | | </div> |
| | | <div class="stat"> |
| | | <span class="stat-label">本页未匹配订单</span> |
| | | <span class="stat-value">{{ pageUnmatched }}<i>条</i></span> |
| | | <div class="overview-card"> |
| | | <div class="label">今日红外异常/作弊</div> |
| | | <div class="value danger">{{ overview.cheatCount || 0 }}</div> |
| | | </div> |
| | | <div class="stat"> |
| | | <span class="stat-label">本页待推送 ERP</span> |
| | | <span class="stat-value">{{ pagePendingErp }}<i>条</i></span> |
| | | <div class="overview-card"> |
| | | <div class="label">待上传ERP</div> |
| | | <div class="value">{{ overview.erpPendingCount || 0 }}</div> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- 查询 --> |
| | | <div class="filter-card"> |
| | | <span class="filter-label">车牌号</span> |
| | | <el-input |
| | | v-model="query.plateNumber" |
| | | placeholder="请输入车牌号" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | style="width: 240px" |
| | | @keyup.enter="handleSearch" |
| | | @clear="handleSearch" |
| | | /> |
| | | <el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button> |
| | | <el-button :icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </div> |
| | | |
| | | <!-- 表格 --> |
| | | <div class="table-card"> |
| | | <el-table :data="rows" v-loading="loading" border stripe row-key="id"> |
| | | <el-table-column prop="weighNo" label="磅单号" min-width="170" /> |
| | | <el-table-column prop="plateNumber" label="车牌号" width="110" /> |
| | | <el-table-column prop="carrierName" label="承运商" min-width="130" show-overflow-tooltip /> |
| | | <el-table-column prop="weightTime" label="称重时间" width="170" /> |
| | | <el-table-column prop="tareWeight" label="皮重(kg)" width="100" align="right" /> |
| | | <el-table-column prop="grossWeight" label="毛重(kg)" width="100" align="right" /> |
| | | <el-table-column label="净重(kg)" width="100" align="right"> |
| | | <template #default="{ row }">{{ netOf(row) }}</template> |
| | | </el-table-column> |
| | | <el-table-column label="红外检测" width="110" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag v-if="row.infraredStatus" :type="row.infraredStatus === 'normal' ? 'success' : 'danger'" effect="plain" size="small"> |
| | | {{ row.infraredStatus === 'normal' ? '正常' : '偏移报警' }} |
| | | </el-tag> |
| | | <span v-else class="muted-cell">—</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="订单匹配" width="120" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="row.orderMatched ? 'success' : 'info'" effect="plain" size="small"> |
| | | {{ row.orderMatched ? (row.orderNo || '已匹配') : '未匹配' }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ERP" width="100" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="row.erpPushStatus === 'success' ? 'success' : 'info'" effect="plain" size="small"> |
| | | {{ row.erpPushStatus === 'success' ? '已上传' : '待上传' }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="190" fixed="right" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-button link type="primary" :icon="Printer" @click="printTicket(row)">磅单</el-button> |
| | | <el-button |
| | | v-if="row.erpPushStatus !== 'success'" |
| | | link |
| | | type="success" |
| | | :icon="Upload" |
| | | :loading="pushingId === row.id" |
| | | @click="pushErp(row)" |
| | | >推送 ERP</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <template #empty> |
| | | <div class="table-empty">暂无过磅记录,点击右上角“开始自动称重”创建第一条</div> |
| | | </template> |
| | | </el-table> |
| | | |
| | | <el-pagination |
| | | v-model:current-page="query.current" |
| | | v-model:page-size="query.size" |
| | | :total="total" |
| | | :page-sizes="[10, 20, 50]" |
| | | layout="total, sizes, prev, pager, next" |
| | | class="pager" |
| | | @current-change="load" |
| | | @size-change="handleSearch" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- 自动称重 --> |
| | | <el-dialog v-model="dialog" title="自动称重" width="640px" destroy-on-close> |
| | | <el-alert |
| | | title="红外检测阈值为 5%,车辆未完全上磅会自动报警并标记异常" |
| | | type="info" |
| | | :closable="false" |
| | | show-icon |
| | | class="weigh-tip" |
| | | /> |
| | | <el-form ref="formRef" :model="form" :rules="rules" label-width="110px" class="weigh-form"> |
| | | <el-row :gutter="16"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="车牌号" prop="plateNumber"> |
| | | <el-input v-model="form.plateNumber" placeholder="请输入车牌号" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="承运商"> |
| | | <el-input v-model="form.carrierName" placeholder="用于匹配订单与绩效" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="16"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="皮重(kg)" prop="tareWeight"> |
| | | <el-input-number v-model="form.tareWeight" :min="0" :controls="false" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="毛重(kg)" prop="grossWeight"> |
| | | <el-input-number v-model="form.grossWeight" :min="0" :controls="false" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="16"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="车辆偏移(%)"> |
| | | <el-input-number v-model="form.positionOffset" :min="0" :max="100" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="地磅编号"> |
| | | <el-input v-model="form.weighbridgeNumber" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="货物名称"> |
| | | <el-input v-model="form.cargoName" /> |
| | | </el-form-item> |
| | | <div class="net-preview"> |
| | | 预计净重:<b>{{ netPreview }}</b> kg |
| | | <el-tabs v-model="activeTab" @tab-change="handleTabChange"> |
| | | <!-- ==================== 自动称重 ==================== --> |
| | | <el-tab-pane label="自动称重" name="auto"> |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">车牌号:</span> |
| | | <el-input v-model="recordQuery.plateNumber" style="width: 130px" placeholder="请输入" clearable |
| | | @keyup.enter="loadRecord" /> |
| | | <span class="search_title ml10">磅单号:</span> |
| | | <el-input v-model="recordQuery.recordNo" style="width: 150px" placeholder="请输入" clearable |
| | | @keyup.enter="loadRecord" /> |
| | | <span class="search_title ml10">承运商:</span> |
| | | <el-input v-model="recordQuery.carrierName" style="width: 130px" placeholder="请输入" clearable |
| | | @keyup.enter="loadRecord" /> |
| | | <span class="search_title ml10">状态:</span> |
| | | <el-select v-model="recordQuery.weighStatus" style="width: 120px" placeholder="全部" clearable |
| | | @change="loadRecord"> |
| | | <el-option label="待皮重" value="0" /> |
| | | <el-option label="待毛重" value="1" /> |
| | | <el-option label="已完成" value="2" /> |
| | | </el-select> |
| | | <span class="search_title ml10">作弊标记:</span> |
| | | <el-select v-model="recordQuery.cheatFlag" style="width: 110px" placeholder="全部" clearable |
| | | @change="loadRecord"> |
| | | <el-option label="正常" value="0" /> |
| | | <el-option label="作弊嫌疑" value="1" /> |
| | | </el-select> |
| | | <el-button type="primary" style="margin-left: 10px" @click="loadRecord">搜索</el-button> |
| | | </div> |
| | | <div> |
| | | <el-button type="primary" @click="openFirstWeight">皮重称重</el-button> |
| | | <el-button @click="openVerifyDialog">扫码核验磅单</el-button> |
| | | </div> |
| | | </div> |
| | | <el-table :data="recordList" border stripe v-loading="recordLoading" style="width: 100%"> |
| | | <el-table-column type="index" label="序号" width="60" align="center" /> |
| | | <el-table-column prop="recordNo" label="磅单号" width="160" align="center" /> |
| | | <el-table-column prop="plateNumber" label="车牌号" width="110" align="center" /> |
| | | <el-table-column prop="carrierName" label="承运商" width="140" show-overflow-tooltip /> |
| | | <el-table-column prop="cargoName" label="货物" width="110" show-overflow-tooltip /> |
| | | <el-table-column label="关联订单" min-width="180"> |
| | | <template #default="{ row }"> |
| | | <template v-if="row.orderNo"> |
| | | <el-tag size="small" :type="row.orderType === '0' ? 'success' : 'warning'"> |
| | | {{ row.orderType === '0' ? '采购' : (row.orderType === '1' ? '销售' : '未匹配') }} |
| | | </el-tag> |
| | | <span class="order-no">{{ row.orderNo }}</span> |
| | | <div v-if="row.orderParty" class="sub-text">{{ row.orderParty }}</div> |
| | | </template> |
| | | <span v-else class="sub-text">-</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="tareWeight" label="皮重(kg)" width="110" align="center" /> |
| | | <el-table-column prop="grossWeight" label="毛重(kg)" width="110" align="center" /> |
| | | <el-table-column prop="netWeight" label="净重(kg)" width="110" align="center" /> |
| | | <el-table-column label="偏差率" width="100" align="center"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.orderDeviation != null" :class="deviationClass(row.orderDeviation)"> |
| | | {{ row.orderDeviation }}% |
| | | </span> |
| | | <span v-else class="sub-text">-</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="红外/作弊" width="120" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag v-if="row.cheatFlag === '1'" type="danger" size="small">作弊嫌疑</el-tag> |
| | | <el-tag v-else-if="row.irStatus === '2'" type="warning" size="small">位置偏移</el-tag> |
| | | <el-tag v-else type="success" size="small">正常</el-tag> |
| | | <div v-if="row.positionOffset != null" class="sub-text">偏移{{ row.positionOffset }}cm</div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ERP" width="110" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="row.erpSyncStatus === '1' ? 'success' : 'info'" size="small"> |
| | | {{ row.erpSyncStatus === '1' ? '已上传' : '待上传' }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="称重状态" width="100" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="row.weighStatus === '2' ? 'success' : 'warning'" size="small"> |
| | | {{ weighStatusText(row.weighStatus) }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="称重时间" width="170" align="center"> |
| | | <template #default="{ row }">{{ formatDateTime(row.secondWeightTime || row.firstWeightTime) }}</template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="300" align="center" fixed="right"> |
| | | <template #default="{ row }"> |
| | | <el-button v-if="row.weighStatus !== '2'" link type="primary" @click="openSecondWeight(row)"> |
| | | 毛重称重 |
| | | </el-button> |
| | | <el-button link type="primary" @click="openInfraredDialog(row)">红外检测</el-button> |
| | | <el-button link type="primary" @click="openPrintDialog(row)">打印磅单</el-button> |
| | | <el-button v-if="row.erpSyncStatus !== '1'" link type="primary" @click="syncErp(row)">上传ERP</el-button> |
| | | <el-button link type="primary" @click="openDetail(row)">详情</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-tab-pane> |
| | | |
| | | <!-- ==================== 手工过磅记录 ==================== --> |
| | | <el-tab-pane label="手工过磅记录" name="manual"> |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">车牌号:</span> |
| | | <el-input v-model="manualQuery.plateNumber" style="width: 200px" placeholder="请输入车牌号" clearable |
| | | @keyup.enter="loadManual" /> |
| | | <el-button type="primary" style="margin-left: 10px" @click="loadManual">搜索</el-button> |
| | | </div> |
| | | <div> |
| | | <el-button type="primary" @click="openManualForm()">新增记录</el-button> |
| | | </div> |
| | | </div> |
| | | <el-table :data="manualList" border stripe v-loading="manualLoading" style="width: 100%"> |
| | | <el-table-column type="index" label="序号" width="60" align="center" /> |
| | | <el-table-column prop="plateNumber" label="车牌号" width="130" align="center" /> |
| | | <el-table-column prop="weightTime" label="称重时间" width="180" align="center"> |
| | | <template #default="{ row }">{{ formatDateTime(row.weightTime) }}</template> |
| | | </el-table-column> |
| | | <el-table-column prop="tareWeight" label="皮重(kg)" width="110" align="center" /> |
| | | <el-table-column prop="grossWeight" label="毛重(kg)" width="110" align="center" /> |
| | | <el-table-column prop="positionOffset" label="偏离度" width="100" align="center" /> |
| | | <el-table-column prop="driverName" label="司机" width="110" align="center" /> |
| | | <el-table-column prop="contactPhone" label="联系电话" width="130" align="center" /> |
| | | <el-table-column prop="cargoName" label="货物名称" width="130" /> |
| | | <el-table-column prop="weighbridgeNumber" label="地磅编号" width="110" align="center" /> |
| | | <el-table-column label="操作" width="140" align="center" fixed="right"> |
| | | <template #default="{ row }"> |
| | | <el-button link type="primary" @click="openManualForm(row)">编辑</el-button> |
| | | <el-button link type="danger" @click="removeManual(row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-tab-pane> |
| | | |
| | | <!-- ==================== ERP上传日志 ==================== --> |
| | | <el-tab-pane label="ERP上传日志" name="erpLog"> |
| | | <el-table :data="erpLogList" border stripe v-loading="erpLogLoading" style="width: 100%"> |
| | | <el-table-column type="index" label="序号" width="60" align="center" /> |
| | | <el-table-column prop="recordNo" label="磅单号" width="170" align="center" /> |
| | | <el-table-column label="同步状态" width="110" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="row.syncStatus === '1' ? 'success' : 'warning'" size="small"> |
| | | {{ row.syncStatus === '1' ? '成功' : '待上传' }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="syncTime" label="同步时间" width="180" align="center"> |
| | | <template #default="{ row }">{{ formatDateTime(row.syncTime) }}</template> |
| | | </el-table-column> |
| | | <el-table-column prop="remark" label="说明" min-width="220" show-overflow-tooltip /> |
| | | <el-table-column prop="responseBody" label="ERP返回" min-width="240" show-overflow-tooltip /> |
| | | <el-table-column label="操作" width="100" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-button link type="primary" @click="viewErpPayload(row)">查看报文</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | |
| | | <!-- ==================== 皮重称重 ==================== --> |
| | | <el-dialog v-model="firstWeightDialog" title="第一次称重(皮重)" width="720px" @close="resetFirstWeight"> |
| | | <el-form ref="firstWeightRef" :model="firstWeightForm" :rules="firstWeightRules" label-position="top"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="车牌号(车牌识别):" prop="plateNumber"> |
| | | <el-input v-model="firstWeightForm.plateNumber" placeholder="请输入车牌号" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="地磅编号:"> |
| | | <el-input v-model="firstWeightForm.weighbridgeCode" placeholder="如 DB-01" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="皮重自动采集(kg):" prop="tareWeight"> |
| | | <el-input-number v-model="firstWeightForm.tareWeight" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="承运商:"> |
| | | <el-input v-model="firstWeightForm.carrierName" placeholder="可留空自动带出" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="司机:"> |
| | | <el-input v-model="firstWeightForm.driverName" placeholder="司机姓名" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="联系电话:"> |
| | | <el-input v-model="firstWeightForm.driverPhone" placeholder="联系电话" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="货物名称:"> |
| | | <el-input v-model="firstWeightForm.cargoName" placeholder="如 原煤" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="订单号(采购/销售合同号):"> |
| | | <el-input v-model="firstWeightForm.orderNo" placeholder="输入后自动匹配订单" clearable |
| | | @blur="autoMatchOrder" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="订单重量(kg):"> |
| | | <el-input-number v-model="firstWeightForm.orderWeight" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="预约到场时间(用于准时率统计):"> |
| | | <el-date-picker v-model="firstWeightForm.appointmentTime" type="datetime" style="width: 100%" |
| | | value-format="YYYY-MM-DD HH:mm:ss" placeholder="计划到场时间" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-alert v-if="orderMatchMessage" :title="orderMatchMessage" :type="orderMatchSuccess ? 'success' : 'warning'" |
| | | :closable="false" show-icon style="margin-bottom: 12px" /> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="红外对射状态:"> |
| | | <el-select v-model="firstWeightForm.irStatus" style="width: 100%"> |
| | | <el-option label="正常" value="0" /> |
| | | <el-option label="遮挡" value="1" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="车辆偏移量(cm):"> |
| | | <el-input-number v-model="firstWeightForm.positionOffset" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="允许偏移阈值(cm):"> |
| | | <el-input-number v-model="firstWeightForm.offsetLimit" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-alert title="车辆未完全上磅或偏移超限时,系统将标记作弊嫌疑并提示报警,防止压磅作弊。" |
| | | type="info" :closable="false" show-icon /> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="dialog = false">取消</el-button> |
| | | <el-button type="primary" :loading="saving" @click="submit">完成称重</el-button> |
| | | <el-button @click="firstWeightDialog = false">取消</el-button> |
| | | <el-button type="primary" :loading="submitLoading" @click="submitFirstWeight">确认采集皮重</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 电子磅单 --> |
| | | <el-dialog v-model="ticketDialog" title="电子磅单" width="520px"> |
| | | <div class="ticket"> |
| | | <h2>无人值守电子磅单</h2> |
| | | <p class="ticket-no">磅单号:{{ ticket.weighNo }}</p> |
| | | <el-descriptions :column="2" border> |
| | | <el-descriptions-item label="车牌">{{ ticket.plateNumber }}</el-descriptions-item> |
| | | <el-descriptions-item label="承运商">{{ ticket.carrierName || '—' }}</el-descriptions-item> |
| | | <el-descriptions-item label="皮重">{{ ticket.tareWeight }} kg</el-descriptions-item> |
| | | <el-descriptions-item label="毛重">{{ ticket.grossWeight }} kg</el-descriptions-item> |
| | | <el-descriptions-item label="净重">{{ ticket.netWeight }} kg</el-descriptions-item> |
| | | <el-descriptions-item label="订单">{{ ticket.orderNo || '未匹配' }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | <img v-if="qrUrl" :src="qrUrl" class="qr" alt="磅单二维码" /> |
| | | <p class="qr-tip">扫描二维码可核验本次磅单</p> |
| | | <!-- ==================== 毛重称重 ==================== --> |
| | | <el-dialog v-model="secondWeightDialog" title="第二次称重(毛重)" width="620px"> |
| | | <el-descriptions :column="2" border size="small" style="margin-bottom: 14px"> |
| | | <el-descriptions-item label="磅单号">{{ currentRecord.recordNo }}</el-descriptions-item> |
| | | <el-descriptions-item label="车牌号">{{ currentRecord.plateNumber }}</el-descriptions-item> |
| | | <el-descriptions-item label="皮重">{{ currentRecord.tareWeight }} kg</el-descriptions-item> |
| | | <el-descriptions-item label="承运商">{{ currentRecord.carrierName || '-' }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | <el-form label-position="top"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="毛重自动采集(kg):"> |
| | | <el-input-number v-model="secondWeightForm.grossWeight" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="红外对射状态:"> |
| | | <el-select v-model="secondWeightForm.irStatus" style="width: 100%"> |
| | | <el-option label="正常" value="0" /> |
| | | <el-option label="遮挡" value="1" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="车辆偏移量(cm):"> |
| | | <el-input-number v-model="secondWeightForm.positionOffset" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="净重(kg):"> |
| | | <el-input :model-value="computedNetWeight" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="secondWeightDialog = false">取消</el-button> |
| | | <el-button type="primary" :loading="submitLoading" @click="submitSecondWeight">确认采集毛重并完成过磅</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- ==================== 红外检测 ==================== --> |
| | | <el-dialog v-model="infraredDialog" title="红外偏移检测" width="480px"> |
| | | <el-form label-position="top"> |
| | | <el-form-item label="磅单号:"> |
| | | <el-input :model-value="currentRecord.recordNo" disabled /> |
| | | </el-form-item> |
| | | <el-form-item label="红外对射状态:"> |
| | | <el-select v-model="infraredForm.irStatus" style="width: 100%"> |
| | | <el-option label="正常" value="0" /> |
| | | <el-option label="遮挡" value="1" /> |
| | | <el-option label="位置偏移" value="2" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="车辆偏移量(cm):"> |
| | | <el-input-number v-model="infraredForm.positionOffset" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-alert v-if="infraredResult.message" :title="infraredResult.message" |
| | | :type="infraredResult.alarm ? 'error' : 'success'" :closable="false" show-icon /> |
| | | <template #footer> |
| | | <el-button @click="infraredDialog = false">关闭</el-button> |
| | | <el-button type="primary" @click="submitInfrared">检测</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- ==================== 打印磅单 ==================== --> |
| | | <el-dialog v-model="printDialog" title="磅单打印" width="520px"> |
| | | <div ref="printArea" class="ticket"> |
| | | <div class="ticket-title">无人值守地磅称重单</div> |
| | | <div class="ticket-no">磅单号:{{ printData.recordNo }}</div> |
| | | <div class="ticket-body"> |
| | | <div class="ticket-left"> |
| | | <p><span>车牌号:</span>{{ printData.plateNumber }}</p> |
| | | <p><span>承运商:</span>{{ printData.carrierName || '-' }}</p> |
| | | <p><span>货物:</span>{{ printData.cargoName || '-' }}</p> |
| | | <p><span>订单号:</span>{{ printData.orderNo || '-' }}</p> |
| | | <p><span>皮重:</span>{{ printData.tareWeight }} kg</p> |
| | | <p><span>毛重:</span>{{ printData.grossWeight }} kg</p> |
| | | <p class="net"><span>净重:</span>{{ printData.netWeight }} kg</p> |
| | | <p><span>称重时间:</span>{{ formatDateTime(printData.secondWeightTime) }}</p> |
| | | <p><span>地磅编号:</span>{{ printData.weighbridgeCode || '-' }}</p> |
| | | </div> |
| | | <div class="ticket-right"> |
| | | <img v-if="qrCodeUrl" :src="qrCodeUrl" alt="磅单二维码" class="qr-img" /> |
| | | <div class="qr-tip">扫码核验磅单</div> |
| | | </div> |
| | | </div> |
| | | <div class="ticket-footer">本磅单由无人值守系统自动生成,扫描二维码可核验真伪</div> |
| | | </div> |
| | | <template #footer> |
| | | <el-button @click="ticketDialog = false">关闭</el-button> |
| | | <el-button type="primary" :icon="Printer" @click="print">打印磅单</el-button> |
| | | <el-button @click="printDialog = false">关闭</el-button> |
| | | <el-button type="primary" @click="doPrint">打印磅单</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- ==================== 扫码核验 ==================== --> |
| | | <el-dialog v-model="verifyDialog" title="扫码核验磅单" width="560px"> |
| | | <el-form label-position="top"> |
| | | <el-form-item label="二维码内容:"> |
| | | <el-input v-model="verifyCode" type="textarea" :rows="3" placeholder="扫码枪扫描或手工粘贴二维码内容" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-alert v-if="verifyResult.message" :title="verifyResult.message" |
| | | :type="verifyResult.valid ? 'success' : 'error'" :closable="false" show-icon /> |
| | | <el-descriptions v-if="verifyResult.record" :column="2" border size="small" style="margin-top: 12px"> |
| | | <el-descriptions-item label="磅单号">{{ verifyResult.record.recordNo }}</el-descriptions-item> |
| | | <el-descriptions-item label="车牌号">{{ verifyResult.record.plateNumber }}</el-descriptions-item> |
| | | <el-descriptions-item label="净重">{{ verifyResult.record.netWeight }} kg</el-descriptions-item> |
| | | <el-descriptions-item label="承运商">{{ verifyResult.record.carrierName || '-' }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | <template #footer> |
| | | <el-button @click="verifyDialog = false">关闭</el-button> |
| | | <el-button type="primary" @click="doVerify">核验</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- ==================== 详情 ==================== --> |
| | | <el-dialog v-model="detailDialog" title="过磅详情" width="760px"> |
| | | <el-descriptions :column="3" border size="small"> |
| | | <el-descriptions-item label="磅单号">{{ detail.recordNo }}</el-descriptions-item> |
| | | <el-descriptions-item label="车牌号">{{ detail.plateNumber }}</el-descriptions-item> |
| | | <el-descriptions-item label="承运商">{{ detail.carrierName || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="货物">{{ detail.cargoName || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="订单类型"> |
| | | {{ detail.orderType === '0' ? '采购' : (detail.orderType === '1' ? '销售' : '-') }} |
| | | </el-descriptions-item> |
| | | <el-descriptions-item label="订单号">{{ detail.orderNo || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="来往单位">{{ detail.orderParty || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="订单重量">{{ detail.orderWeight || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="偏差率">{{ detail.orderDeviation != null ? detail.orderDeviation + '%' : '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="皮重">{{ detail.tareWeight }}</el-descriptions-item> |
| | | <el-descriptions-item label="毛重">{{ detail.grossWeight }}</el-descriptions-item> |
| | | <el-descriptions-item label="净重">{{ detail.netWeight }}</el-descriptions-item> |
| | | <el-descriptions-item label="红外状态">{{ irStatusText(detail.irStatus) }}</el-descriptions-item> |
| | | <el-descriptions-item label="偏移量">{{ detail.positionOffset != null ? detail.positionOffset + ' cm' : '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="作弊标记"> |
| | | <el-tag :type="detail.cheatFlag === '1' ? 'danger' : 'success'" size="small"> |
| | | {{ detail.cheatFlag === '1' ? '作弊嫌疑' : '正常' }} |
| | | </el-tag> |
| | | </el-descriptions-item> |
| | | <el-descriptions-item label="作弊原因" :span="3">{{ detail.cheatReason || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="皮重时间">{{ formatDateTime(detail.firstWeightTime) }}</el-descriptions-item> |
| | | <el-descriptions-item label="毛重时间">{{ formatDateTime(detail.secondWeightTime) }}</el-descriptions-item> |
| | | <el-descriptions-item label="ERP状态">{{ detail.erpSyncStatus === '1' ? '已上传' : '待上传' }}</el-descriptions-item> |
| | | <el-descriptions-item label="打印次数">{{ detail.printCount || 0 }}</el-descriptions-item> |
| | | <el-descriptions-item label="二维码内容" :span="2">{{ detail.qrCode || '-' }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | <template #footer> |
| | | <el-button @click="detailDialog = false">关闭</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- ==================== 手工记录弹窗 ==================== --> |
| | | <el-dialog v-model="manualDialog" :title="manualForm.id ? '编辑过磅记录' : '新增过磅记录'" width="720px" |
| | | @close="resetManualForm"> |
| | | <el-form ref="manualFormRef" :model="manualForm" :rules="manualRules" label-position="top"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="车牌号:" prop="plateNumber"> |
| | | <el-input v-model="manualForm.plateNumber" placeholder="请输入车牌号" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="称重时间:" prop="weightTime"> |
| | | <el-date-picker v-model="manualForm.weightTime" type="datetime" style="width: 100%" |
| | | value-format="YYYY-MM-DD HH:mm:ss" placeholder="选择时间" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="地磅编号:"> |
| | | <el-input v-model="manualForm.weighbridgeNumber" placeholder="请输入地磅编号" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="皮重(kg):" prop="tareWeight"> |
| | | <el-input-number v-model="manualForm.tareWeight" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="毛重(kg):" prop="grossWeight"> |
| | | <el-input-number v-model="manualForm.grossWeight" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="偏离度:"> |
| | | <el-input-number v-model="manualForm.positionOffset" :precision="2" :min="0" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="司机姓名:"> |
| | | <el-input v-model="manualForm.driverName" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="联系电话:"> |
| | | <el-input v-model="manualForm.contactPhone" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="货物名称:"> |
| | | <el-input v-model="manualForm.cargoName" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="备注:"> |
| | | <el-input v-model="manualForm.remark" type="textarea" :rows="2" placeholder="请输入备注" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="manualDialog = false">取消</el-button> |
| | | <el-button type="primary" @click="submitManual">确认</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, getCurrentInstance, onMounted, reactive, ref } from "vue"; |
| | | import { computed, onMounted, reactive, ref } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import QRCode from "qrcode"; |
| | | import { Search, Refresh, Printer, Upload, VideoPlay } from "@element-plus/icons-vue"; |
| | | import { autoWeigh, listWeighbridgeSystem, pushWeighbridgeToErp } from "@/api/environmentAccess/unattendedWeighbridgeSystem"; |
| | | import { |
| | | addWeighbridgeSystem, |
| | | delWeighbridgeSystem, |
| | | firstWeighbridgeWeight, |
| | | getWeighbridgeOverview, |
| | | getWeighbridgePrintInfo, |
| | | getWeighbridgeRecord, |
| | | getWeighbridgeSystem, |
| | | infraredCheck, |
| | | listWeighbridgeErpLog, |
| | | listWeighbridgeRecord, |
| | | listWeighbridgeSystem, |
| | | matchWeighbridgeOrder, |
| | | secondWeighbridgeWeight, |
| | | syncWeighbridgeErp, |
| | | updateWeighbridgeRecord, |
| | | updateWeighbridgeSystem, |
| | | verifyWeighbridgeQr, |
| | | } from "@/api/environmentAccess/unattendedWeighbridgeSystem.js"; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const rows = ref([]); |
| | | const loading = ref(false); |
| | | const saving = ref(false); |
| | | const pushingId = ref(null); |
| | | const total = ref(0); |
| | | const dialog = ref(false); |
| | | const ticketDialog = ref(false); |
| | | const ticket = ref({}); |
| | | const qrUrl = ref(""); |
| | | const formRef = ref(null); |
| | | |
| | | const query = reactive({ plateNumber: "", current: 1, size: 20 }); |
| | | const emptyForm = { |
| | | plateNumber: "", |
| | | carrierName: "", |
| | | tareWeight: null, |
| | | grossWeight: null, |
| | | positionOffset: 0, |
| | | weighbridgeNumber: "WB-01", |
| | | cargoName: "", |
| | | const activeTab = ref("auto"); |
| | | const overview = ref({}); |
| | | const submitLoading = ref(false); |
| | | |
| | | const formatDateTime = (val) => { |
| | | if (!val) return "-"; |
| | | return String(val).replace("T", " ").substring(0, 19); |
| | | }; |
| | | const form = reactive({ ...emptyForm }); |
| | | const weighStatusText = (status) => ({ "0": "待皮重", "1": "待毛重", "2": "已完成" }[status] || "-"); |
| | | const irStatusText = (status) => ({ "0": "正常", "1": "遮挡", "2": "位置偏移" }[status] || "-"); |
| | | const deviationClass = (value) => { |
| | | const num = Number(value); |
| | | if (num <= 1) return "text-success"; |
| | | if (num <= 3) return "text-warning"; |
| | | return "text-danger"; |
| | | }; |
| | | |
| | | const rules = { |
| | | // ==================== 自动称重记录 ==================== |
| | | const recordQuery = reactive({ plateNumber: "", recordNo: "", carrierName: "", weighStatus: "", cheatFlag: "" }); |
| | | const recordList = ref([]); |
| | | const recordLoading = ref(false); |
| | | |
| | | const loadOverview = () => { |
| | | getWeighbridgeOverview().then((res) => { |
| | | overview.value = res.data || {}; |
| | | }); |
| | | }; |
| | | const loadRecord = () => { |
| | | recordLoading.value = true; |
| | | listWeighbridgeRecord({ ...recordQuery, current: 1, size: 300 }) |
| | | .then((res) => { |
| | | recordList.value = res.data?.records || []; |
| | | }) |
| | | .finally(() => { |
| | | recordLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // ==================== 皮重称重 ==================== |
| | | const firstWeightDialog = ref(false); |
| | | const firstWeightRef = ref(); |
| | | const firstWeightForm = ref({}); |
| | | const firstWeightRules = { |
| | | plateNumber: [{ required: true, message: "请输入车牌号", trigger: "blur" }], |
| | | tareWeight: [{ required: true, message: "请输入皮重", trigger: "change" }], |
| | | grossWeight: [{ required: true, message: "请输入毛重", trigger: "change" }], |
| | | tareWeight: [{ required: true, message: "请输入皮重", trigger: "blur" }], |
| | | }; |
| | | const orderMatchMessage = ref(""); |
| | | const orderMatchSuccess = ref(false); |
| | | |
| | | const openFirstWeight = () => { |
| | | firstWeightForm.value = { irStatus: "0", offsetLimit: 30, positionOffset: 0 }; |
| | | orderMatchMessage.value = ""; |
| | | orderMatchSuccess.value = false; |
| | | firstWeightDialog.value = true; |
| | | }; |
| | | const resetFirstWeight = () => { |
| | | firstWeightRef.value?.resetFields(); |
| | | firstWeightForm.value = {}; |
| | | }; |
| | | const autoMatchOrder = () => { |
| | | const orderNo = firstWeightForm.value.orderNo; |
| | | if (!orderNo) { |
| | | orderMatchMessage.value = ""; |
| | | return; |
| | | } |
| | | matchWeighbridgeOrder(orderNo).then((res) => { |
| | | const data = res.data || {}; |
| | | orderMatchSuccess.value = !!data.matched; |
| | | orderMatchMessage.value = data.matched |
| | | ? `${data.message}:${data.orderParty || ''}(${data.projectName || '无项目'})` |
| | | : data.message; |
| | | }); |
| | | }; |
| | | const submitFirstWeight = () => { |
| | | firstWeightRef.value.validate((valid) => { |
| | | if (!valid) return; |
| | | submitLoading.value = true; |
| | | firstWeighbridgeWeight(firstWeightForm.value) |
| | | .then((res) => { |
| | | const record = res.data || {}; |
| | | if (record.cheatFlag === "1") { |
| | | ElMessage({ message: `红外检测异常:${record.cheatReason}`, type: "error", duration: 6000 }); |
| | | } else { |
| | | proxy.$modal.msgSuccess(`皮重采集成功,磅单号 ${record.recordNo}`); |
| | | } |
| | | firstWeightDialog.value = false; |
| | | loadRecord(); |
| | | loadOverview(); |
| | | if (record.cheatFlag !== "1") { |
| | | openSecondWeight(record); |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | submitLoading.value = false; |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | const netPreview = computed(() => { |
| | | const t = Number(form.tareWeight); |
| | | const g = Number(form.grossWeight); |
| | | if (!t || !g || g <= t) return "—"; |
| | | return (g - t).toFixed(2); |
| | | // ==================== 毛重称重 ==================== |
| | | const secondWeightDialog = ref(false); |
| | | const secondWeightForm = reactive({ grossWeight: null, irStatus: "0", positionOffset: 0 }); |
| | | const currentRecord = ref({}); |
| | | const computedNetWeight = computed(() => { |
| | | const tare = Number(currentRecord.value.tareWeight || 0); |
| | | const gross = Number(secondWeightForm.grossWeight || 0); |
| | | if (!gross) return ""; |
| | | return (gross - tare).toFixed(2); |
| | | }); |
| | | |
| | | function netOf(row) { |
| | | if (row.netWeight !== null && row.netWeight !== undefined) return Number(row.netWeight).toFixed(2); |
| | | if (row.grossWeight !== null && row.tareWeight !== null) { |
| | | return (Number(row.grossWeight) - Number(row.tareWeight)).toFixed(2); |
| | | } |
| | | return "—"; |
| | | } |
| | | |
| | | const pageAbnormal = computed(() => rows.value.filter(r => r.infraredStatus && r.infraredStatus !== "normal").length); |
| | | const pageUnmatched = computed(() => rows.value.filter(r => !r.orderMatched).length); |
| | | const pagePendingErp = computed(() => rows.value.filter(r => r.erpPushStatus !== "success").length); |
| | | |
| | | async function load() { |
| | | loading.value = true; |
| | | try { |
| | | const res = await listWeighbridgeSystem({ ...query }); |
| | | const data = res?.data ?? res; |
| | | rows.value = data?.records || []; |
| | | total.value = Number(data?.total) || 0; |
| | | } catch (e) { |
| | | rows.value = []; |
| | | total.value = 0; |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | } |
| | | |
| | | function handleSearch() { |
| | | query.current = 1; |
| | | load(); |
| | | } |
| | | |
| | | function resetQuery() { |
| | | query.plateNumber = ""; |
| | | handleSearch(); |
| | | } |
| | | |
| | | function openWeigh() { |
| | | Object.assign(form, emptyForm); |
| | | dialog.value = true; |
| | | } |
| | | |
| | | async function submit() { |
| | | try { |
| | | await formRef.value.validate(); |
| | | } catch (e) { |
| | | const openSecondWeight = (row) => { |
| | | currentRecord.value = { ...row }; |
| | | secondWeightForm.grossWeight = null; |
| | | secondWeightForm.irStatus = "0"; |
| | | secondWeightForm.positionOffset = row.positionOffset != null ? Number(row.positionOffset) : 0; |
| | | secondWeightDialog.value = true; |
| | | }; |
| | | const submitSecondWeight = () => { |
| | | if (!secondWeightForm.grossWeight) { |
| | | proxy.$modal.msgWarning("请输入毛重"); |
| | | return; |
| | | } |
| | | if (Number(form.grossWeight) <= Number(form.tareWeight)) { |
| | | proxy.$modal.msgError("毛重必须大于皮重"); |
| | | submitLoading.value = true; |
| | | secondWeighbridgeWeight({ |
| | | id: currentRecord.value.id, |
| | | grossWeight: secondWeightForm.grossWeight, |
| | | irStatus: secondWeightForm.irStatus, |
| | | positionOffset: secondWeightForm.positionOffset, |
| | | }) |
| | | .then((res) => { |
| | | const record = res.data || {}; |
| | | if (record.cheatFlag === "1") { |
| | | ElMessage({ message: `红外检测异常:${record.cheatReason}`, type: "error", duration: 6000 }); |
| | | } else { |
| | | proxy.$modal.msgSuccess(`过磅完成,净重 ${record.netWeight} kg`); |
| | | } |
| | | secondWeightDialog.value = false; |
| | | loadRecord(); |
| | | loadOverview(); |
| | | if (record.weighStatus === "2") { |
| | | openPrintDialog(record); |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | submitLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // ==================== 红外检测 ==================== |
| | | const infraredDialog = ref(false); |
| | | const infraredForm = reactive({ irStatus: "0", positionOffset: 0 }); |
| | | const infraredResult = ref({}); |
| | | |
| | | const openInfraredDialog = (row) => { |
| | | currentRecord.value = { ...row }; |
| | | infraredForm.irStatus = row.irStatus || "0"; |
| | | infraredForm.positionOffset = row.positionOffset != null ? Number(row.positionOffset) : 0; |
| | | infraredResult.value = {}; |
| | | infraredDialog.value = true; |
| | | }; |
| | | const submitInfrared = () => { |
| | | infraredCheck({ |
| | | recordId: currentRecord.value.id, |
| | | positionOffset: infraredForm.positionOffset, |
| | | irStatus: infraredForm.irStatus, |
| | | }).then((res) => { |
| | | infraredResult.value = res.data || {}; |
| | | loadRecord(); |
| | | loadOverview(); |
| | | }); |
| | | }; |
| | | |
| | | // ==================== 打印磅单 ==================== |
| | | const printDialog = ref(false); |
| | | const printData = ref({}); |
| | | const qrCodeUrl = ref(""); |
| | | const printArea = ref(); |
| | | |
| | | const openPrintDialog = (row) => { |
| | | getWeighbridgePrintInfo(row.id).then(async (res) => { |
| | | const data = res.data || {}; |
| | | printData.value = data.record || {}; |
| | | qrCodeUrl.value = await QRCode.toDataURL(data.qrCode || "", { width: 180, margin: 1 }); |
| | | printDialog.value = true; |
| | | loadRecord(); |
| | | }); |
| | | }; |
| | | const doPrint = () => { |
| | | const html = printArea.value?.innerHTML || ""; |
| | | const win = window.open("", "_blank", "width=520,height=680"); |
| | | if (!win) { |
| | | proxy.$modal.msgWarning("浏览器拦截了打印窗口,请允许弹窗后重试"); |
| | | return; |
| | | } |
| | | saving.value = true; |
| | | try { |
| | | const res = await autoWeigh({ ...form }); |
| | | const result = res?.data || {}; |
| | | dialog.value = false; |
| | | if (result.cheatFlag) { |
| | | proxy.$modal.msgWarning("称重完成,红外检测发现车辆偏移,已标记异常"); |
| | | } else { |
| | | proxy.$modal.msgSuccess("称重完成,磅单已生成"); |
| | | } |
| | | load(); |
| | | } catch (e) { |
| | | proxy.$modal.msgError("称重失败,请稍后重试"); |
| | | } finally { |
| | | saving.value = false; |
| | | } |
| | | } |
| | | win.document.write(`<!DOCTYPE html><html><head><title>磅单打印</title> |
| | | <style> |
| | | body{font-family:"Microsoft YaHei",Arial,sans-serif;padding:16px;} |
| | | .ticket{border:1px solid #333;padding:14px;} |
| | | .ticket-title{text-align:center;font-size:20px;font-weight:bold;margin-bottom:6px;} |
| | | .ticket-no{text-align:right;font-size:12px;margin-bottom:8px;} |
| | | .ticket-body{display:flex;justify-content:space-between;} |
| | | .ticket-left p{margin:4px 0;font-size:13px;} |
| | | .ticket-left p span{display:inline-block;width:76px;color:#555;} |
| | | .ticket-left p.net{font-weight:bold;font-size:15px;} |
| | | .qr-img{width:150px;height:150px;} |
| | | .qr-tip{text-align:center;font-size:12px;color:#666;} |
| | | .ticket-footer{margin-top:10px;font-size:12px;color:#666;text-align:center;} |
| | | </style></head><body><div class="ticket">${html}</div></body></html>`); |
| | | win.document.close(); |
| | | win.focus(); |
| | | setTimeout(() => { |
| | | win.print(); |
| | | }, 300); |
| | | }; |
| | | |
| | | async function pushErp(row) { |
| | | pushingId.value = row.id; |
| | | try { |
| | | await pushWeighbridgeToErp(row.id); |
| | | proxy.$modal.msgSuccess("称重数据已推送至 ERP"); |
| | | load(); |
| | | } catch (e) { |
| | | proxy.$modal.msgError("ERP 推送失败"); |
| | | } finally { |
| | | pushingId.value = null; |
| | | } |
| | | } |
| | | // ==================== 扫码核验 ==================== |
| | | const verifyDialog = ref(false); |
| | | const verifyCode = ref(""); |
| | | const verifyResult = ref({}); |
| | | |
| | | async function printTicket(row) { |
| | | const netWeight = row.netWeight ?? ( |
| | | row.grossWeight != null && row.tareWeight != null |
| | | ? Number(row.grossWeight) - Number(row.tareWeight) |
| | | : "" |
| | | const openVerifyDialog = () => { |
| | | verifyCode.value = ""; |
| | | verifyResult.value = {}; |
| | | verifyDialog.value = true; |
| | | }; |
| | | const doVerify = () => { |
| | | if (!verifyCode.value) { |
| | | proxy.$modal.msgWarning("请扫描或粘贴二维码内容"); |
| | | return; |
| | | } |
| | | verifyWeighbridgeQr(verifyCode.value.trim()).then((res) => { |
| | | verifyResult.value = res.data || {}; |
| | | }); |
| | | }; |
| | | |
| | | // ==================== ERP ==================== |
| | | const syncErp = (row) => { |
| | | ElMessageBox.confirm(`确认将磅单 ${row.recordNo} 上传至 ERP?`, "上传ERP", { type: "info" }).then(() => { |
| | | syncWeighbridgeErp(row.id).then((res) => { |
| | | const data = res.data || {}; |
| | | if (data.success) { |
| | | proxy.$modal.msgSuccess(data.message); |
| | | } else { |
| | | ElMessage({ message: data.message, type: "warning", duration: 6000 }); |
| | | } |
| | | loadRecord(); |
| | | loadErpLog(); |
| | | loadOverview(); |
| | | }); |
| | | }).catch(() => {}); |
| | | }; |
| | | |
| | | const erpLogList = ref([]); |
| | | const erpLogLoading = ref(false); |
| | | const loadErpLog = () => { |
| | | erpLogLoading.value = true; |
| | | listWeighbridgeErpLog({ current: 1, size: 200 }) |
| | | .then((res) => { |
| | | erpLogList.value = res.data?.records || []; |
| | | }) |
| | | .finally(() => { |
| | | erpLogLoading.value = false; |
| | | }); |
| | | }; |
| | | const viewErpPayload = (row) => { |
| | | ElMessageBox.alert( |
| | | `<div style="max-height:400px;overflow:auto;white-space:pre-wrap;font-size:12px">${row.requestBody || ""}</div>`, |
| | | "上传报文", |
| | | { dangerouslyUseHTMLString: true } |
| | | ); |
| | | const weighNo = cleanQrValue(row.weighNo) || `WB${formatQrTime(row.weightTime)}${String(row.id || 0).padStart(3, "0")}`; |
| | | ticket.value = { ...row, weighNo, netWeight }; |
| | | // 始终根据当前记录重建二维码,避免历史 qrCode 中残留字符串 "null"。 |
| | | const content = [ |
| | | weighNo, |
| | | cleanQrValue(row.plateNumber), |
| | | cleanQrValue(netWeight), |
| | | cleanQrValue(row.weightTime), |
| | | cleanQrValue(row.carrierName), |
| | | cleanQrValue(row.weighbridgeNumber), |
| | | ].join("|"); |
| | | qrUrl.value = await QRCode.toDataURL(content, { width: 180, margin: 1 }); |
| | | ticketDialog.value = true; |
| | | } |
| | | }; |
| | | |
| | | function cleanQrValue(value) { |
| | | return value == null || String(value).toLowerCase() === "null" ? "" : String(value); |
| | | } |
| | | // ==================== 详情 ==================== |
| | | const detailDialog = ref(false); |
| | | const detail = ref({}); |
| | | const openDetail = (row) => { |
| | | getWeighbridgeRecord(row.id).then((res) => { |
| | | detail.value = res.data || {}; |
| | | detailDialog.value = true; |
| | | }); |
| | | }; |
| | | |
| | | function formatQrTime(value) { |
| | | const digits = cleanQrValue(value).replace(/\D/g, ""); |
| | | return (digits || String(Date.now())).slice(0, 14).padEnd(14, "0"); |
| | | } |
| | | // ==================== 手工过磅记录 ==================== |
| | | const manualQuery = reactive({ plateNumber: "" }); |
| | | const manualList = ref([]); |
| | | const manualLoading = ref(false); |
| | | const manualDialog = ref(false); |
| | | const manualFormRef = ref(); |
| | | const manualForm = ref({}); |
| | | const manualRules = { |
| | | plateNumber: [{ required: true, message: "请输入车牌号", trigger: "blur" }], |
| | | weightTime: [{ required: true, message: "请选择称重时间", trigger: "change" }], |
| | | tareWeight: [{ required: true, message: "请输入皮重", trigger: "blur" }], |
| | | grossWeight: [{ required: true, message: "请输入毛重", trigger: "blur" }], |
| | | }; |
| | | |
| | | function print() { |
| | | const t = ticket.value; |
| | | const rowsHtml = [ |
| | | ["车牌", t.plateNumber], |
| | | ["承运商", t.carrierName || "—"], |
| | | ["皮重", `${t.tareWeight ?? "—"} kg`], |
| | | ["毛重", `${t.grossWeight ?? "—"} kg`], |
| | | ["净重", `${t.netWeight ?? "—"} kg`], |
| | | ["订单", t.orderNo || "未匹配"], |
| | | ["称重时间", t.weightTime || "—"], |
| | | ].map(([k, v]) => `<tr><th>${k}</th><td>${v}</td></tr>`).join(""); |
| | | |
| | | const html = `<!DOCTYPE html><html><head><meta charset="utf-8"><title>电子磅单 ${t.weighNo || ""}</title> |
| | | <style> |
| | | body{font-family:"Microsoft YaHei",Arial,sans-serif;padding:32px;color:#1b2733} |
| | | h1{text-align:center;font-size:22px;letter-spacing:4px;margin:0 0 8px} |
| | | .no{text-align:center;color:#666;font-size:13px;margin-bottom:22px} |
| | | table{width:100%;border-collapse:collapse;font-size:14px} |
| | | th,td{border:1px solid #d9dde3;padding:10px 12px;text-align:left} |
| | | th{width:28%;background:#f5f7fa;font-weight:500;color:#5c6b7a} |
| | | .qr{text-align:center;margin-top:24px} |
| | | .qr img{width:170px;height:170px} |
| | | .tip{text-align:center;color:#98a4b0;font-size:12px;margin-top:6px} |
| | | </style></head><body> |
| | | <h1>无人值守电子磅单</h1> |
| | | <div class="no">磅单号:${t.weighNo || "—"}</div> |
| | | <table>${rowsHtml}</table> |
| | | <div class="qr"><img src="${qrUrl.value}" alt="二维码"></div> |
| | | <div class="tip">扫描二维码可核验本次磅单</div> |
| | | </body></html>`; |
| | | |
| | | const w = window.open("", "_blank", "width=760,height=860"); |
| | | if (!w) { |
| | | proxy.$modal.msgWarning("请允许弹出窗口后重试打印"); |
| | | return; |
| | | const loadManual = () => { |
| | | manualLoading.value = true; |
| | | listWeighbridgeSystem({ ...manualQuery, current: 1, size: 300 }) |
| | | .then((res) => { |
| | | manualList.value = res.data?.records || []; |
| | | }) |
| | | .finally(() => { |
| | | manualLoading.value = false; |
| | | }); |
| | | }; |
| | | const openManualForm = (row) => { |
| | | if (row) { |
| | | getWeighbridgeSystem(row.id).then((res) => { |
| | | manualForm.value = { ...res.data }; |
| | | manualDialog.value = true; |
| | | }); |
| | | } else { |
| | | const now = new Date(); |
| | | const pad = (n) => String(n).padStart(2, "0"); |
| | | manualForm.value = { |
| | | weightTime: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`, |
| | | }; |
| | | manualDialog.value = true; |
| | | } |
| | | w.document.write(html); |
| | | w.document.close(); |
| | | w.focus(); |
| | | setTimeout(() => w.print(), 300); |
| | | } |
| | | }; |
| | | const resetManualForm = () => { |
| | | manualFormRef.value?.resetFields(); |
| | | manualForm.value = {}; |
| | | }; |
| | | const submitManual = () => { |
| | | manualFormRef.value.validate((valid) => { |
| | | if (!valid) return; |
| | | if (Number(manualForm.value.grossWeight) <= Number(manualForm.value.tareWeight)) { |
| | | proxy.$modal.msgError("毛重必须大于皮重"); |
| | | return; |
| | | } |
| | | const api = manualForm.value.id ? updateWeighbridgeSystem : addWeighbridgeSystem; |
| | | api(manualForm.value).then(() => { |
| | | proxy.$modal.msgSuccess("保存成功"); |
| | | manualDialog.value = false; |
| | | loadManual(); |
| | | }); |
| | | }); |
| | | }; |
| | | const removeManual = (row) => { |
| | | ElMessageBox.confirm(`确定删除车牌「${row.plateNumber}」的过磅记录吗?`, "删除提示", { type: "warning" }).then(() => { |
| | | delWeighbridgeSystem([row.id]).then(() => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | loadManual(); |
| | | }); |
| | | }).catch(() => {}); |
| | | }; |
| | | |
| | | onMounted(load); |
| | | const handleTabChange = (name) => { |
| | | if (name === "auto") loadRecord(); |
| | | if (name === "manual") loadManual(); |
| | | if (name === "erpLog") loadErpLog(); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | loadOverview(); |
| | | loadRecord(); |
| | | loadManual(); |
| | | loadErpLog(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | $line: #e3e8ed; |
| | | $paper: #f4f6f8; |
| | | $text: #1b2733; |
| | | $muted: #5c6b7a; |
| | | $brand: #2c51d9; |
| | | $alert: #e0a02e; |
| | | |
| | | .weighbridge-page { |
| | | background: $paper; |
| | | min-height: calc(100vh - 84px); |
| | | } |
| | | |
| | | /* 页头 */ |
| | | .page-head { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | gap: 20px; |
| | | padding: 20px 22px; |
| | | background: linear-gradient(150deg, #14191f 0%, #1e252c 100%); |
| | | border-radius: 6px; |
| | | margin-bottom: 16px; |
| | | |
| | | h2 { |
| | | margin: 0 0 6px; |
| | | font-size: 20px; |
| | | font-weight: 700; |
| | | color: #fff; |
| | | letter-spacing: 0.03em; |
| | | } |
| | | |
| | | p { |
| | | margin: 0; |
| | | font-size: 13px; |
| | | color: rgba(234, 240, 245, 0.66); |
| | | } |
| | | |
| | | :deep(.el-button--primary) { |
| | | background: #fff; |
| | | border-color: #fff; |
| | | color: #14191f; |
| | | font-weight: 600; |
| | | |
| | | &:hover { |
| | | background: #e9eef5; |
| | | border-color: #e9eef5; |
| | | color: #14191f; |
| | | .overview-row { |
| | | display: flex; |
| | | gap: 14px; |
| | | margin-bottom: 16px; |
| | | .overview-card { |
| | | flex: 1; |
| | | background: #f7f9fc; |
| | | border-radius: 6px; |
| | | padding: 14px 18px; |
| | | .label { |
| | | color: #909399; |
| | | font-size: 13px; |
| | | } |
| | | .value { |
| | | font-size: 24px; |
| | | font-weight: 600; |
| | | color: #303133; |
| | | margin-top: 6px; |
| | | &.warning { |
| | | color: #e6a23c; |
| | | } |
| | | &.danger { |
| | | color: #f56c6c; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /* 概览 */ |
| | | .stat-row { |
| | | display: grid; |
| | | grid-template-columns: repeat(4, minmax(0, 1fr)); |
| | | gap: 14px; |
| | | margin-bottom: 16px; |
| | | } |
| | | |
| | | .stat { |
| | | position: relative; |
| | | background: #fff; |
| | | border: 1px solid $line; |
| | | border-radius: 6px; |
| | | padding: 14px 18px 12px; |
| | | |
| | | &::before { |
| | | content: ""; |
| | | position: absolute; |
| | | left: 0; |
| | | top: 0; |
| | | bottom: 0; |
| | | width: 3px; |
| | | background: #c7d0da; |
| | | .ml10 { |
| | | margin-left: 10px; |
| | | } |
| | | } |
| | | |
| | | .stat-label { |
| | | display: block; |
| | | font-size: 12.5px; |
| | | color: $muted; |
| | | margin-bottom: 8px; |
| | | } |
| | | |
| | | .stat-value { |
| | | font-family: "MyCustomFont", "Helvetica Neue", Arial, sans-serif; |
| | | font-size: 26px; |
| | | font-weight: 700; |
| | | color: $text; |
| | | line-height: 1; |
| | | |
| | | i { |
| | | font-style: normal; |
| | | .sub-text { |
| | | color: #909399; |
| | | font-size: 12px; |
| | | color: #98a4b0; |
| | | margin-left: 4px; |
| | | font-family: "Microsoft YaHei", Arial, sans-serif; |
| | | font-weight: 400; |
| | | } |
| | | |
| | | &.warn { |
| | | color: $alert; |
| | | } |
| | | } |
| | | |
| | | /* 查询 */ |
| | | .filter-card { |
| | | display: flex; |
| | | align-items: center; |
| | | gap: 10px; |
| | | padding: 14px 18px; |
| | | background: #fff; |
| | | border: 1px solid $line; |
| | | border-radius: 6px; |
| | | margin-bottom: 16px; |
| | | |
| | | .filter-label { |
| | | .order-no { |
| | | margin-left: 6px; |
| | | font-size: 13px; |
| | | color: $muted; |
| | | } |
| | | } |
| | | |
| | | /* 表格 */ |
| | | .table-card { |
| | | background: #fff; |
| | | border: 1px solid $line; |
| | | border-radius: 6px; |
| | | padding: 14px 16px; |
| | | } |
| | | |
| | | .pager { |
| | | justify-content: flex-end; |
| | | margin-top: 14px; |
| | | } |
| | | |
| | | .table-empty { |
| | | padding: 26px 0; |
| | | color: #a7b2bd; |
| | | font-size: 13px; |
| | | } |
| | | |
| | | .muted-cell { |
| | | color: #a7b2bd; |
| | | } |
| | | |
| | | /* 弹窗 */ |
| | | .weigh-tip { |
| | | margin-bottom: 16px; |
| | | } |
| | | |
| | | .weigh-form { |
| | | :deep(.el-form-item) { |
| | | margin-bottom: 16px; |
| | | .text-success { |
| | | color: #67c23a; |
| | | } |
| | | } |
| | | |
| | | .net-preview { |
| | | margin: 4px 0 0 110px; |
| | | padding: 10px 14px; |
| | | background: #f3f6fa; |
| | | border: 1px dashed #d5dde4; |
| | | border-radius: 4px; |
| | | font-size: 13px; |
| | | color: $muted; |
| | | |
| | | b { |
| | | font-family: "MyCustomFont", "Helvetica Neue", Arial, sans-serif; |
| | | font-size: 18px; |
| | | color: $brand; |
| | | margin: 0 4px; |
| | | .text-warning { |
| | | color: #e6a23c; |
| | | } |
| | | } |
| | | |
| | | /* 磅单 */ |
| | | .ticket { |
| | | text-align: center; |
| | | |
| | | h2 { |
| | | margin: 0 0 8px; |
| | | font-size: 18px; |
| | | letter-spacing: 0.16em; |
| | | color: $text; |
| | | .text-danger { |
| | | color: #f56c6c; |
| | | } |
| | | |
| | | .ticket-no { |
| | | margin: 0 0 16px; |
| | | font-size: 12.5px; |
| | | color: $muted; |
| | | } |
| | | |
| | | :deep(.el-descriptions__label) { |
| | | width: 90px; |
| | | color: $muted; |
| | | } |
| | | } |
| | | |
| | | .qr { |
| | | width: 170px; |
| | | height: 170px; |
| | | margin: 20px auto 0; |
| | | display: block; |
| | | } |
| | | |
| | | .qr-tip { |
| | | margin: 6px 0 0; |
| | | font-size: 12px; |
| | | color: #98a4b0; |
| | | } |
| | | |
| | | @media (max-width: 900px) { |
| | | .stat-row { |
| | | grid-template-columns: repeat(2, minmax(0, 1fr)); |
| | | } |
| | | |
| | | .page-head { |
| | | flex-direction: column; |
| | | align-items: flex-start; |
| | | .ticket { |
| | | border: 1px solid #333; |
| | | padding: 14px; |
| | | .ticket-title { |
| | | text-align: center; |
| | | font-size: 20px; |
| | | font-weight: bold; |
| | | margin-bottom: 6px; |
| | | } |
| | | .ticket-no { |
| | | text-align: right; |
| | | font-size: 12px; |
| | | margin-bottom: 8px; |
| | | } |
| | | .ticket-body { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | .ticket-left p { |
| | | margin: 4px 0; |
| | | font-size: 13px; |
| | | span { |
| | | display: inline-block; |
| | | width: 76px; |
| | | color: #555; |
| | | } |
| | | &.net { |
| | | font-weight: bold; |
| | | font-size: 15px; |
| | | } |
| | | } |
| | | .ticket-right { |
| | | text-align: center; |
| | | .qr-img { |
| | | width: 150px; |
| | | height: 150px; |
| | | } |
| | | .qr-tip { |
| | | font-size: 12px; |
| | | color: #666; |
| | | } |
| | | } |
| | | } |
| | | .ticket-footer { |
| | | margin-top: 10px; |
| | | font-size: 12px; |
| | | color: #666; |
| | | text-align: center; |
| | | } |
| | | } |
| | | } |
| | | </style> |