liufumingren 81b663de63 fix: 打包报错修复与部署脚本 Windows 跨平台化
- 修复 TS1261 import 大小写(33 处)、TS2561 report_code→report_id、TS2339 类型标注
- deploy/rollback 支持 Windows: npm.cmd EINVAL(改用 node 直跑 npm-cli.js)、sshKey 绝对路径
- map.ts 兼容后端菜单老路径,强制指向 basicManagement newview(含投递计划/报表定义)
- report.deliveryPlan.copy 返回结构对齐后端 created/skipped,修正前端误报复制成功
2026-08-30 09:29:57 +08:00

325 lines
10 KiB
Vue

<template>
<div class="weighing-container" :style="{ height: containerHeight }">
<div class="weighing-panel">
<div class="panel-header">
<span class="panel-title">最近称重</span>
</div>
<div v-if="lastResult" class="panel-result">
<div class="result-title">{{ lastResult.wave_no || lastResult.waybill || '称重结果' }}</div>
<div class="result-weights">
<div class="weight-row">
<el-tag size="default" :type="weightWarnType" class="weight-tag">{{ lastResult.weighing_weight }} g</el-tag>
<span class="weight-label">称重</span>
</div>
<div class="weight-row" v-if="lastResult.total_weight != null">
<el-tag size="default" type="info" class="weight-tag">{{ lastResult.total_weight }} g</el-tag>
<span class="weight-label">系统</span>
</div>
</div>
<div class="result-meta" v-if="lastResult.order_id">
<span>订单 ID {{ lastResult.order_id }}</span>
</div>
<div class="result-meta" v-if="lastResult.wave_id">
<span>波次 {{ lastResult.wave_no }}</span>
<span class="meta-divider">|</span>
<span>{{ lastResult.store_name || '' }}</span>
<template v-if="lastResult.sys_logistics_name">
<span class="meta-divider">|</span>
<el-tag size="small" type="warning">{{ lastResult.sys_logistics_name }}</el-tag>
</template>
</div>
<div class="result-meta" v-if="lastResult.split_count > 1">
<span>拆单 {{ lastResult.split_count }} 个</span>
</div>
<div class="result-splits" v-if="lastResult.splits && lastResult.splits.length > 1">
<div
v-for="s in lastResult.splits"
:key="s.business_key"
class="split-row"
:class="{ 'has-waybill': s.waybill_code }"
>
<span class="split-key">{{ s.business_key }}</span>
<span class="split-weight">{{ s.weighing_weight }} g</span>
<span class="split-waybill" v-if="s.waybill_code">{{ s.waybill_code }}</span>
<span class="split-waybill empty" v-else>待分配</span>
</div>
</div>
</div>
<div v-else class="panel-empty">
点击右侧「运单称重」录入重量
</div>
</div>
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" :loading="loading" @click="loadList">刷新</el-button>
<el-button size="small" type="success" @click="openWeighingForm">运单称重</el-button>
<!-- <el-tag size="small" type="info">共 {{ pagination.total }} 条</el-tag> -->
</div>
<el-input
v-model="filterWaybill"
size="small"
style="width:200px"
placeholder="筛选运单号"
clearable
@keyup.enter="loadList"
@clear="loadList"
/>
</div>
<div class="upper-wrapper">
<upper-table
ref="upperTable"
title="称重记录"
table-id="order-weighing-records"
:data="tableData"
:columns="columns"
:table-size="tableSize"
:pagination="pagination"
:show-index="true"
:loading="loading"
:query-time="queryTime"
row-key="id"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="loadList"
>
<template #column-weighing_weight="{ row }">
<span v-if="row.weighing_weight != null">{{ row.weighing_weight }} g</span>
<span v-else style="color:#c0c4cc">未称重</span>
</template>
<template #column-updated_at="{ row }">
{{ formatTime(row.updated_at) }}
</template>
</upper-table>
</div>
</div>
<ExpressWeighingForm
v-model="weighingFormVisible"
:initial-waybill-code="filterWaybill"
@success="handleWeighingSuccess"
/>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import UpperTable from '@/components/UpperTable/index.vue'
import { useSettingsStore } from '@/stores/modules/settings'
import { orderPendingOrderList } from '@/api/order.pendingOrder/orderpendingOrder'
import { isOrderIndexApiSuccess } from '@/views/order/orderManagement/utils/order-index-helpers'
import ExpressWeighingForm, { type ExpressWeighingFormResult } from './ExpressWeighingForm.vue'
const settingsStore = useSettingsStore()
const upperTable = ref<any>(null)
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const containerHeight = computed(() =>
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
)
const columns = [
{ prop: 'waybill_no', label: '运单号', minWidth: '160', showOverflowTooltip: true },
{ prop: 'delivery_order_code', label: '订单号', minWidth: '160', showOverflowTooltip: true },
{ prop: 'weighing_weight', label: '重量', width: '120', align: 'center' },
{ prop: 'updated_at', label: '称重时间', width: '170', align: 'center' },
{ prop: 'id', label: 'ID', width: '80', sortable: true }
]
const tableData = ref<any[]>([])
const loading = ref(false)
const queryTime = ref(0)
const tableSize = ref<'small' | 'default' | 'large'>('small')
const filterWaybill = ref('')
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const lastResult = ref<any>(null)
const weighingFormVisible = ref(false)
const weightWarnType = computed(() => {
const actual = Number(lastResult.value?.weighing_weight)
const system = Number(lastResult.value?.total_weight)
if (!actual || !system) return 'success'
const diff = Math.abs(actual - system)
const threshold = system / 3
if (diff > threshold) return 'danger'
return 'success'
})
function isSuccess(res: any) {
return isOrderIndexApiSuccess(res)
}
function formatTime(v: string) {
if (!v) return '—'
try {
const d = new Date(v)
if (isNaN(d.getTime())) return v
const pad = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
} catch { return v }
}
async function loadList() {
if (loading.value) return
loading.value = true
const start = Date.now()
try {
const where: Record<string, unknown> = {}
const fw = filterWaybill.value.trim()
if (fw) where.waybill_no = { operator: 'contains', value: fw, type: 'text' }
const res: any = await orderPendingOrderList({
pagination: {
page: pagination.currentPage,
pageSize: pagination.pageSize
},
where
})
if (!isSuccess(res)) {
ElMessage.error(res?.message || '获取列表失败')
tableData.value = []
pagination.total = 0
return
}
const data = res?.data || {}
tableData.value = data.list || []
pagination.total = Number(data.pagination?.total ?? data.total ?? 0)
} catch {
tableData.value = []
pagination.total = 0
ElMessage.error('获取列表失败')
} finally {
queryTime.value = Date.now() - start
loading.value = false
}
}
function openWeighingForm() {
weighingFormVisible.value = true
}
function handleWeighingSuccess(detail: ExpressWeighingFormResult) {
lastResult.value = {
waybill: detail.waybill || detail.waybill_code || '',
order_id: detail.order_id,
weighing_weight: detail.weighing_weight,
wave_id: detail.wave_id,
wave_no: detail.wave_no,
business_key: detail.business_key || '',
total_weight: detail.total_weight,
split_count: detail.split_count ?? 0,
splits: detail.splits || [],
store_name: detail.store_name || '',
sys_logistics_name: detail.sys_logistics_name || ''
}
loadList()
}
function handlePageChange(page: number) { pagination.currentPage = page; loadList() }
function handlePageSizeChange(size: number) { pagination.pageSize = size; pagination.currentPage = 1; loadList() }
onMounted(() => { loadList() })
</script>
<style scoped lang="scss">
.weighing-container {
display: flex;
width: 100%;
background-color: #f0f2f5;
.weighing-panel {
flex: 0 0 280px;
width: 280px;
background: #fff;
border-right: 1px solid #e4e7ed;
display: flex;
flex-direction: column;
padding: 10px;
gap: 10px;
.panel-header {
.panel-title {
font-size: 13px;
font-weight: 600;
color: #303133;
}
}
.panel-empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-size: 12px;
color: #909399;
padding: 16px;
border: 1px dashed #e4e7ed;
border-radius: 4px;
}
.panel-result {
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 8px;
.result-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.result-weights {
margin-bottom: 4px;
.weight-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.weight-tag { font-size: 15px; font-weight: 700; }
.weight-label { font-size: 12px; color: #909399; }
}
.result-meta {
font-size: 12px; color: #909399; margin-bottom: 2px;
.meta-divider { margin: 0 6px; color: #dcdfe6; }
strong { color: #e6a23c; }
}
.result-splits {
margin-top: 6px;
.split-row {
display: flex; align-items: center; gap: 8px;
font-size: 12px; padding: 3px 6px; border-radius: 3px;
&.has-waybill { background: #f0f9eb; }
.split-key { font-weight: 600; min-width: 24px; color: #409eff; }
.split-weight { color: #e6a23c; min-width: 60px; }
.split-waybill { color: #67c23a; font-family: monospace; }
.split-waybill.empty { color: #c0c4cc; }
}
}
}
}
.main-content {
flex: 1;
display: flex;
flex-direction: column;
padding: 10px;
overflow: hidden;
min-width: 0;
.toolbar {
padding: 5px 8px;
border-bottom: 1px solid #ebeef5;
display: flex;
justify-content: space-between;
align-items: center;
background-color: #fff;
flex-shrink: 0;
.toolbar-left { display: flex; align-items: center; gap: 8px; }
}
.upper-wrapper {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
}
}
</style>