This commit is contained in:
yin 2026-08-26 18:27:37 +08:00
parent 3ef327e0b8
commit 21d168cafc
16 changed files with 1254 additions and 278 deletions

View File

@ -1,40 +1,94 @@
#!/bin/bash
set -eu
# --- 配置 ---
USER="webdev"
IP="112.124.21.102" # 服务器 IP
BASE_PATH="/www/wwwroot/web" # 请修改为您的项目在服务器上的存放路径
RELEASE_NAME="v$(date +'%Y%m%d_%H%M%S')" # 生成版本号:如 v20260328_1445
BASE_PATH="/www/wwwroot/web" # 项目在服务器上的存放路径
RELEASE_NAME="v$(date +'%Y%m%d_%H%M%S')_$$" # 版本号(带 PID,避免并发/重复发布冲突)
LOCAL_DIST="./dist"
KEEP_RELEASES=5 # 服务器上保留的最近版本数
SITE_HOST="wms.wms.gztbyc.com" # 发版后健康检查域名
# SSH 密钥提示:请确保本地已将 id_ed25519.pub 添加到服务器的 ~/.ssh/authorized_keys
# 密钥内容:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICJtwa+MFLQEgkEbcGQ6dkQOiFydRvjVeidJ/7uBsF2e 3313488199@qq.com
SSH_KEY="$HOME/.ssh/id_ed25519_admin"
SSH_OPTS="-i $SSH_KEY -o StrictHostKeyChecking=no"
REMOTE_RELEASE="$BASE_PATH/releases/$RELEASE_NAME"
# 无论成功失败都清理本地临时压缩包
trap 'rm -f dist.tar.gz' EXIT
echo "🚀 开始发布版本: $RELEASE_NAME"
# 1. 本地打包
# 1. 本地打包(失败立即中止,防止把坏产物发到线上)
npm run build
# 2. 压缩并上传
tar -czf dist.tar.gz -C $LOCAL_DIST .
ssh $SSH_OPTS $USER@$IP "mkdir -p $BASE_PATH/releases/$RELEASE_NAME"
scp $SSH_OPTS dist.tar.gz $USER@$IP:$BASE_PATH/releases/$RELEASE_NAME
# 2. 校验本地产物完整性
if [ ! -f "$LOCAL_DIST/index.html" ] || [ ! -d "$LOCAL_DIST/assets" ]; then
echo "❌ 本地构建产物不完整(缺少 index.html 或 assets),中止发布"
exit 1
fi
# 3. 远程解压、更新软链接、清理旧版本
ssh $SSH_OPTS $USER@$IP << EOF
cd $BASE_PATH/releases/$RELEASE_NAME
tar -xzf dist.tar.gz
rm dist.tar.gz
# 原子化更新软链接:先创建临时链接再重命名(防止切换瞬间服务中断)
ln -sfn $BASE_PATH/releases/$RELEASE_NAME $BASE_PATH/current_new
mv -Tf $BASE_PATH/current_new $BASE_PATH/current
# 3. 压缩并上传到独立的新版本目录(全程不触碰当前运行目录)
tar -czf dist.tar.gz -C "$LOCAL_DIST" .
ssh $SSH_OPTS $USER@$IP "mkdir -p '$REMOTE_RELEASE'"
scp $SSH_OPTS dist.tar.gz $USER@$IP:"$REMOTE_RELEASE/dist.tar.gz"
# 只保留最近 5 个版本,删除更旧的
cd $BASE_PATH/releases && ls -t | tail -n +6 | xargs rm -rf
EOF
# 4. 远程:解压 → 校验 → 补齐旧资源 → 原子切换 → 健康检查 → 清理
ssh $SSH_OPTS $USER@$IP "RELEASE='$REMOTE_RELEASE' BASE='$BASE_PATH' KEEP=$KEEP_RELEASES HOST='$SITE_HOST' bash -s" << 'REMOTE_EOF'
set -euo pipefail
echo "✨ 发布成功!当前版本: $RELEASE_NAME"
cd "$RELEASE"
# 4.1 解压
tar -xzf dist.tar.gz
rm -f dist.tar.gz
# 4.2 完整性校验:新版本必须完整,残缺则取消切换(当前线上版本不受影响)
if [ ! -s index.html ]; then
echo "❌ 新版本 index.html 缺失或为空,取消切换"
exit 1
fi
missing=""
for ref in $(grep -oE '/assets/[A-Za-z0-9._-]+\.(js|css)' index.html | sort -u || true); do
[ -f ".$ref" ] || missing="$missing $ref"
done
if [ -n "$missing" ]; then
echo "❌ 新版本缺少以下资源,取消切换:$missing"
exit 1
fi
# 4.3 补齐旧版本静态资源(无感切换的关键)
# 把最近几个历史版本中、本版本缺失的文件(旧 chunk、hikvision、logo 等)合并进新版本,
# 保证切换后正在使用旧版本页面的用户,动态 import 旧资源依然能找到,不会 404。
for src in $(ls -td "$BASE"/releases/*/ 2>/dev/null | head -n "$((KEEP + 1))" || true); do
[ -d "$src" ] || continue
[ "$(readlink -f "$src" 2>/dev/null)" = "$(pwd)" ] && continue
cp -rn "$src/." "$RELEASE/" 2>/dev/null || true
done
# 4.4 原子切换软链接(先建临时链接再改名,切换瞬间服务不中断)
ln -sfn "$RELEASE" "$BASE/current_new"
mv -Tf "$BASE/current_new" "$BASE/current"
# 4.5 健康检查(仅提示,不阻断发布)
if command -v curl >/dev/null 2>&1; then
code="$(curl -skL -o /dev/null -w '%{http_code}' -H "Host: $HOST" "https://127.0.0.1/" 2>/dev/null || true)"
echo "ℹ️ 新版本首页 HTTP 状态码: ${code:-未知}"
fi
# 4.6 清理旧版本:只保留最近 KEEP 个,且绝不删除 current 指向的版本
CURRENT_TARGET="$(readlink -f "$BASE/current" 2>/dev/null || true)"
count=0
for d in $(ls -t "$BASE/releases" 2>/dev/null || true); do
count=$((count+1))
[ "$count" -le "$KEEP" ] && continue
target="$(readlink -f "$BASE/releases/$d" 2>/dev/null || echo "$BASE/releases/$d")"
[ "$target" = "$CURRENT_TARGET" ] && continue
rm -rf "$BASE/releases/$d"
done
REMOTE_EOF
echo "✨ 发布成功!当前版本: $RELEASE_NAME"

36
req.txt
View File

@ -1,36 +0,0 @@
stock.warehouse.search自动匹配商品,返回数据:
{
"flag": "success",
"code": 200,
"message": "ok",
"data": [
{
"id": 150181,
"item_code": null,
"goods_code": "581229",
"item_name": "自然派猪肉脯炭烧100g",
"sku_property": "",
"stock_unit": "个",
"quantity": 0,
"locked_quantity": 0,
"brand_name": null,
"item_type": "ZC",
"inbound_min_days": null,
"outbound_min_days": null,
"shelf_life_days": null,
"remaining_threshold_days": null,
"is_shelf_life_mgmt": false,
"gross_weight": "130.00",
"barcodes": [
"6945309363606"
],
"store_stock": {
"store_id": 1000195,
"store_remask": "盛昇"
},
"is_batch_mgmt_enabled": false
}
],
"total": 1,
"timestamp": 1781342370
}

View File

@ -1,22 +1,31 @@
#!/bin/bash
set -eu
USER="root"
IP="1.2.3.4" # 请修改为您的服务器实际 IP
BASE_PATH="/www/wwwroot/my-project" # 请修改为您的项目在服务器上的存放路径
USER="webdev"
IP="112.124.21.102" # 服务器 IP
BASE_PATH="/www/wwwroot/web" # 项目在服务器上的存放路径
# SSH 密钥提示:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICJtwa+MFLQEgkEbcGQ6dkQOiFydRvjVeidJ/7uBsF2e 3313488199@qq.com
# SSH 密钥提示:请确保本地已将 id_ed25519.pub 添加到服务器的 ~/.ssh/authorized_keys
# 密钥内容:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICJtwa+MFLQEgkEbcGQ6dkQOiFydRvjVeidJ/7uBsF2e 3313488199@qq.com
SSH_KEY="$HOME/.ssh/id_ed25519_admin"
SSH_OPTS="-i $SSH_KEY -o StrictHostKeyChecking=no"
echo "⏪ 正在回滚到上一个版本..."
ssh $USER@$IP << EOF
# 获取 releases 目录下按时间排序的倒数第二个版本
PREVIOUS_VERSION=$(ls -dt $BASE_PATH/releases/*/ | sed -n '2p')
if [ -z "$PREVIOUS_VERSION" ]; then
echo "❌ 找不到可回滚的历史版本"
exit 1
fi
ssh $SSH_OPTS $USER@$IP "BASE='$BASE_PATH' bash -s" << 'REMOTE_EOF'
set -euo pipefail
ln -sfn $PREVIOUS_VERSION $BASE_PATH/current
echo "✅ 已回滚至: $PREVIOUS_VERSION"
EOF
# 获取 releases 目录下按时间排序的倒数第二个版本(当前版本的上一版)
PREVIOUS_VERSION="$(ls -dt "$BASE"/releases/*/ 2>/dev/null | sed -n '2p' || true)"
if [ -z "$PREVIOUS_VERSION" ]; then
echo "❌ 找不到可回滚的历史版本"
exit 1
fi
# 原子切换软链接(与发版脚本一致,切换瞬间服务不中断)
ln -sfn "$PREVIOUS_VERSION" "$BASE/current_new"
mv -Tf "$BASE/current_new" "$BASE/current"
echo "✅ 已回滚至: $PREVIOUS_VERSION"
REMOTE_EOF

84
server.txt Normal file
View File

@ -0,0 +1,84 @@
server
{
listen 80;
listen 443 ssl;
listen 443 quic;
http2 on;
server_name wms.wms.gztbyc.com;
index index.html index.htm default.htm default.html;
root /www/wwwroot/web/current;
include /www/server/panel/vhost/nginx/extension/wms.wms.gztbyc.com/*.conf;
#CERT-APPLY-CHECK--START
# 用于SSL证书申请时的文件验证相关配置 -- 请勿删除并保持这段设置在优先级高的位置
include /www/server/panel/vhost/nginx/well-known/wms.wms.gztbyc.com.conf;
#CERT-APPLY-CHECK--END
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#HTTP_TO_HTTPS_START
set $isRedcert 1;
if ($server_port != 443) {
set $isRedcert 2;
}
if ( $uri ~ /\.well-known/ ) {
set $isRedcert 1;
}
if ($isRedcert != 1) {
rewrite ^(/.*)$ https://$host$1 permanent;
}
#HTTP_TO_HTTPS_END
ssl_certificate /www/server/panel/vhost/cert/wms.wms.gztbyc.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/wms.wms.gztbyc.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_tickets on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
add_header Alt-Svc 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"';
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/html_wms.wms.gztbyc.com.conf;
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
#禁止在证书验证目录放入敏感文件
if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
return 403;
}
location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
access_log /www/wwwlogs/wms.wms.gztbyc.com.log;
error_log /www/wwwlogs/wms.wms.gztbyc.com.error.log;
}

View File

@ -5,6 +5,8 @@ const v = '1.0'
/** order.wave.batchList 的 where 白名单(禁止 warehouse_id / warehouseId) */
export type WaveBatchListWhere = {
wave_id?: number | string
/** 货主(店铺)ID 筛选 */
store_id?: number | string
wave_no?: string
wave_type?: number
wave_status?: number

View File

@ -74,6 +74,8 @@ export type SettingWarehouseSubjectConfig = SettingWarehouseSenderConfig & {
group_wave_prefix?: string
/** 自动分配快递排除备注:订单备注命中任一关键字时,跳过自动分配快递 */
auto_allocate_express_exclude_remarks?: string[]
/** 默认库位(库位ID,未配置时为 null) */
default_location_id?: number | null
[key: string]: unknown
}
@ -148,6 +150,15 @@ export function normalizeWarehouseSubjectConfig(
base.group_order_pack_max_minutes =
Number.isFinite(groupPackMax) && groupPackMax > 0 ? Math.trunc(groupPackMax) : 40
// 默认库位(库位ID,未配置时为 null)
const locIdRaw = base.default_location_id
if (locIdRaw === undefined || locIdRaw === null || locIdRaw === '') {
base.default_location_id = null
} else {
const locId = Number(locIdRaw)
base.default_location_id = Number.isFinite(locId) ? Math.trunc(locId) : null
}
return base as SettingWarehouseSubjectConfig
}

View File

@ -72,15 +72,32 @@ export const stockoutListItems = (data: StockoutListItemsParams) => {
// ── storage.stockout.toOrder ──
export type StockoutToOrderReceiverInfo = {
/** 收件人姓名(必填) */
name?: string
/** 收件人移动电话(与 tel 至少一项) */
mobile?: string
/** 收件人固定电话(与 mobile 至少一项) */
tel?: string
province?: string
city?: string
area?: string
town?: string
detailAddress?: string
/** 收件人公司名称 */
company?: string
/** 收件人电子邮箱 */
email?: string
/** 国家二字码 */
countryCode?: string
/** 收件人证件号 */
receiver_id?: string
/** 邮编 */
zipCode?: string
/** 省份(必填) */
province?: string
/** 城市(必填) */
city?: string
/** 区/县(必填) */
area?: string
/** 镇/街道(必填) */
town?: string
/** 详细地址(必填) */
detailAddress?: string
}
export type StockoutToOrderParams = {
@ -88,7 +105,10 @@ export type StockoutToOrderParams = {
id: number
/** 新订单号,不传自动生成(SK 前缀) */
delivery_order_code?: string
/** 收件人信息,不传时新订单收货信息为空 */
/**
* 收件人信息,不传时回填出库单已存的收件人字段。
* 收货信息必填:name、(tel/mobile) 至少一项、省市区镇详细地址,缺失则报错不能转订单
*/
receiverInfo?: StockoutToOrderReceiverInfo
}
@ -235,3 +255,91 @@ export const stockoutListLogs = (data: StockoutListLogsParams) => {
data: data
})
}
// ── storage.stockout.updateInfo ──
export type StockoutUpdateInfoParams = {
/** 出库单ID(必填) */
id: number
/** 收件人姓名 */
name?: string
/** 收件人固定电话 */
tel?: string
/** 收件人移动电话 */
mobile?: string
/** 收件人公司名称 */
company?: string
/** 收件人电子邮箱 */
email?: string
/** 邮编 */
zipCode?: string
/** 国家二字码 */
countryCode?: string
/** 省份 */
province?: string
/** 城市 */
city?: string
/** 区/县 */
area?: string
/** 镇/街道 */
town?: string
/** 详细地址 */
detailAddress?: string
/** 收件人证件号 */
receiver_id?: string
/** 快递公司编码,传入后自动解析 express_name */
express_code?: string
/** 来源平台编码 */
source_platform_code?: string
/** 来源平台名称 */
source_platform_name?: string
}
export type StockoutUpdateInfoResponse = {
/** 更新后的出库单完整记录(wms_order_stockout 表字段,含 receiver_*、express_*、source_platform_* 等) */
data?: Record<string, unknown>
}
/** 修改出库单信息:收件人(name/tel/mobile/company/email 等)、地址、快递编码、来源平台。未传入的字段不修改;仅 CREATED/PENDING 状态允许修改 */
export const stockoutUpdateInfo = (data: StockoutUpdateInfoParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.updateInfo',
v,
timestamp: new Date().getTime()
},
data: data
})
}
// ── storage.stockout.cancel ──
export type StockoutCancelParams = {
/** 出库单ID(必填) */
id: number
}
export type StockoutCancelResponse = {
/** 出库单ID */
id: number
/** 出库单号 */
stockout_order_code: string
/** 取消后状态(CANCELLED) */
order_status: string
}
/** 取消出库单:仅 CREATED/PENDING 状态允许取消;事务内释放库存锁定并写操作日志(STOCKOUT_CANCEL);TRANSFERRED/COMPLETED 状态禁止取消 */
export const stockoutCancel = (data: StockoutCancelParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.cancel',
v,
timestamp: new Date().getTime()
},
data: data
})
}

View File

@ -57,6 +57,7 @@
class="barcode-qty-input"
:disabled="!createResult?.id"
title="本次扫码录入数量(一次性使用,扫描后自动重置为1)"
@keyup.enter="handleScanQtyEnter"
/>
</div>
</el-form-item>
@ -266,7 +267,7 @@
</el-table-column>
<el-table-column prop="quantity" label="数量" width="130">
<template #default="{ row }">
<el-input-number v-model="row.quantity" :min="1" :max="999999" size="small" class="inline-number" @change="() => handleAutoSave(row)" />
<el-input-number v-model="row.quantity" :min="1" :max="999999" size="small" class="inline-number" @change="() => handleAutoSave(row)" @keyup.enter="() => handleAutoSave(row)" />
</template>
</el-table-column>
<el-table-column prop="product_status" label="产品状态" width="100">
@ -295,6 +296,7 @@
<span
class="remark-option-delete"
title="删除该备注选项"
@mousedown.stop.prevent
@click.stop.prevent="removeRemarkOption(opt)"
>×</span>
</span>
@ -495,7 +497,7 @@
maxlength="500"
show-word-limit
placeholder="输入新的备注内容,保存后进入下拉选项并应用到当前商品行"
@keyup.enter.ctrl="confirmAddRemarkOption"
@keyup.enter="confirmAddRemarkOption"
/>
<template #footer>
<el-button size="small" @click="remarkAddVisible = false">取消</el-button>
@ -605,7 +607,7 @@ const {
beginSplitDrag,
lowerPaneStyle,
upperPaneStyle,
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
} = useVerticalSplitPane({ defaultLowerPercent: 65 })
// 货主选择(来源:returnUnpack.create 返回 + 条码查询商品返回)
const selectedStoreId = ref<number | null>(null)
@ -1106,6 +1108,11 @@ function normalizeScanQty(): number {
return Math.min(999, Math.floor(n))
}
/** 数量输入框回车:聚焦回商品条码输入框,便于连续扫码 */
function handleScanQtyEnter() {
detailBarcodeRef.value?.focus()
}
async function quickAddDetail(item: any) {
const unpackId = createResult.value?.id
if (!unpackId) return
@ -1696,7 +1703,7 @@ function handleKeydown(e: KeyboardEvent) {
const isTyping = tag === 'INPUT' || tag === 'TEXTAREA' || el?.isContentEditable === true
const inSelect = el?.closest?.('.el-select') != null
const inDetailTable = el?.closest?.('.detail-table') != null
const isNumberInput = tag === 'INPUT' && (el?.className?.includes('el-input-number') ?? false)
const isNumberInput = tag === 'INPUT' && el?.closest?.('.el-input-number') != null
// 表单(弹窗)打开时:交给弹窗自身的快捷键处理,页面快捷键不生效
if (stockPickerVisible.value || quickAddPickerVisible.value || detailFormVisible.value) {
@ -1704,11 +1711,12 @@ function handleKeydown(e: KeyboardEvent) {
}
// ===== 扫码缓冲收集(§6):识别一段快速连续输入 + 回车 =====
// 受控确认弹窗 / 摄像头弹窗打开时不收集扫码(避免干扰,Enter 仍走下方确认逻辑)
// 受控确认弹窗 / 摄像头弹窗打开时不收集扫码(避免干扰,Enter 仍走下方确认逻辑);
// 数量输入框(el-input-number)内也不收集,避免手动输入数字+回车被误判为扫码枪输入
const scanCollectDisabled = cameraSettingsVisible.value
|| cancelConfirmVisible.value || submitConfirmVisible.value
|| deleteConfirmVisible.value || removeDetailConfirmVisible.value
if (!scanCollectDisabled) {
if (!scanCollectDisabled && !isNumberInput) {
if (isScanPrintableChar(e)) {
const now = Date.now()
if (now - scanSegmentStart > SCAN_SEGMENT_GAP_MS) {
@ -1760,7 +1768,7 @@ function handleKeydown(e: KeyboardEvent) {
return
}
// 回车/空格:表单打开时=该表单的确认动作;未打开表单时(不在输入框/下拉/按钮内)=提交确认
// 回车/空格:仅用于表单项确认(受控确认弹窗打开时=该表单的确认动作),不再全局触发提交
if (e.key === 'Enter' || e.code === 'Space' || e.key === ' ') {
if (isTyping || inSelect || tag === 'BUTTON') return
@ -1775,12 +1783,7 @@ function handleKeydown(e: KeyboardEvent) {
return
}
// 3) 无任何表单打开:提交确认
const record = createResult.value?.record
if (createResult.value?.id && record?.status === 'unpacking') {
e.preventDefault()
handleSubmit()
}
// 3) 不在输入框且无弹窗:不响应全局回车(回车仅由各表单项的 @keyup.enter 处理)
return
}
@ -1997,7 +2000,8 @@ async function handleSaveDetail(row: any) {
id: unpackId,
detail_id: row.id,
quantity: row.quantity,
remark: row.remark ? String(row.remark).trim() : undefined,
// 备注清空时传空字符串而非 undefined:undefined 会被 JSON 序列化丢弃,后端无法将备注置空
remark: String(row.remark ?? '').trim(),
})
if (isOk(res)) {
ElMessage.success('明细保存成功')

View File

@ -1417,7 +1417,7 @@ onBeforeUnmount(() => {
})
async function initializePage() {
await Promise.all([loadWarehouseSettings(), loadData()])
await Promise.all([loadWarehouseSettings(), loadData(), loadWaveStoreOptions()])
}
async function loadWarehouseSettings() {
@ -1510,6 +1510,23 @@ function handleOnlyTodoChange() {
void loadData()
}
/** 将货主列表注入 ScanBox「货主」字段的 options */
async function loadWaveStoreOptions() {
const storeField = availableFieldsRef.find((field: any) => field.value === 'store_id')
if (storeField && Array.isArray(storeField.options) && storeField.options.length > 0) return
try {
const res: any = await indexApi.loadStores()
const stores = Array.isArray(res?.stores) ? res.stores : []
const options = stores.map((item: any) => ({
label: item.label || item.name || String(item.value || item.id),
value: item.value ?? item.id
}))
if (storeField) storeField.options = options
} catch (error) {
console.error('load wave store options failed:', error)
}
}
function buildWhereConditions(rawConditions: Record<string, any>) {
const where: Record<string, any> = {}
Object.keys(rawConditions || {}).forEach((key) => {

View File

@ -858,7 +858,7 @@ onBeforeUnmount(() => {
})
async function initializePage() {
await Promise.all([loadWarehouseSettings(), loadData()])
await Promise.all([loadWarehouseSettings(), loadData(), loadWaveStoreOptions()])
}
async function loadWarehouseSettings() {
@ -948,6 +948,23 @@ function handleOnlyTodoChange() {
void loadData()
}
/** 将货主列表注入 ScanBox「货主」字段的 options */
async function loadWaveStoreOptions() {
const storeField = availableFieldsRef.find((field: any) => field.value === 'store_id')
if (storeField && Array.isArray(storeField.options) && storeField.options.length > 0) return
try {
const res: any = await indexApi.loadStores()
const stores = Array.isArray(res?.stores) ? res.stores : []
const options = stores.map((item: any) => ({
label: item.label || item.name || String(item.value || item.id),
value: item.value ?? item.id
}))
if (storeField) storeField.options = options
} catch (error) {
console.error('load wave store options failed:', error)
}
}
function buildWhereConditions(rawConditions: Record<string, any>) {
const where: Record<string, any> = {}
Object.keys(rawConditions || {}).forEach((key) => {

View File

@ -104,6 +104,13 @@ export const waveUpperTableDefaults = {
export const waveAvailableFields = [
// ===== 波次信息 =====
waveScanBasicField({ label: '波次号', value: 'wave_no', type: 'text' }),
waveScanBasicField({
label: '货主',
value: 'store_id',
type: 'select',
// options 由页面加载货主列表后动态注入(indexApi.loadStores)
options: []
}),
waveScanBasicField({
label: '波次类型',
value: 'wave_type',
@ -355,6 +362,7 @@ export const waveStrategyColumns = [
export const waveBatchColumns = applyWaveListCopyActions([
// { prop: 'wave_id', label: '波次ID', minWidth: 160, fixed: 'left' },
{ prop: 'wave_no', label: '波次编号', minWidth: 180, fixed: 'left' },
{ prop: 'store_name', label: '货主', minWidth: 120 },
{ prop: 'wave_type', label: '波次类型', minWidth: 96 },
{ prop: 'wave_status', label: '波次状态', minWidth: 110 },
{ prop: 'total_orders', label: '总订单数', minWidth: 110 },
@ -402,7 +410,8 @@ export const waveWhereAllowedFieldList = [
'total_orders_max',
'processed_orders_min',
'processed_orders_max',
'source'
'source',
'store_id'
] as const
export const waveWhereAllowedFields = new Set<string>(waveWhereAllowedFieldList)

View File

@ -1,105 +1,233 @@
<template>
<div v-loading="loading" class="stockout-log-container">
<el-timeline v-if="logs.length">
<el-timeline-item
v-for="(log, index) in logs"
:key="log.id ?? index"
:timestamp="log.created_at"
:type="log.type"
size="large"
<div class="log-container">
<el-button-group class="toolbar-btn-group">
<el-button
type="primary"
size="small"
:icon="Refresh"
@click="fetchStockoutLogs"
title="刷新"
:loading="loading"
:disabled="!props.id"
class="toolbar-btn"
>
<div class="log-content">
<span class="operator">{{ log.operator_name }}</span>
<span class="action">{{ log.action }}</span>
<el-tag v-if="log.platform_name" size="small" type="info" class="platform">
{{ log.platform_name }}
</el-tag>
<p v-if="log.remark" class="remark">{{ log.remark }}</p>
</div>
</el-timeline-item>
</el-timeline>
<el-empty v-else-if="!loading" description="暂无操作日志" />
刷新
</el-button>
</el-button-group>
<div ref="tableHostRef" class="table-host">
<el-table
:data="tableData"
border
stripe
size="small"
style="width: 100%"
:height="tableHeight"
v-loading="loading"
>
<el-table-column prop="created_at" label="时间" width="250" />
<el-table-column prop="operator_name" label="操作人" width="120" />
<el-table-column prop="operation_name" label="操作名称" min-width="140" />
<el-table-column prop="platform_name" label="操作平台" min-width="120" />
<el-table-column prop="message" label="日志内容" min-width="200" show-overflow-tooltip />
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button
@click="viewData(scope.row)"
type="primary"
link
size="small"
v-if="scope.row.external_log_id"
>
查看报文
</el-button>
<el-button
@click="backData(scope.row)"
type="primary"
link
size="small"
v-if="scope.row.operation_code === 'UPDATE'"
>
修改前快照
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@size-change="handlePageSizeChange"
@current-change="handlePageChange"
/>
</div>
<el-drawer
v-model="showRequestData"
direction="rtl"
:with-header="false"
size="800px"
class="el-drawers"
>
<RequestData
v-if="showRequestData"
:id="requestId"
:type="requestType"
/>
</el-drawer>
</div>
</template>
<script setup lang="ts">
import { ref, watch, onActivated } from 'vue'
import { ref, reactive, watch } from 'vue'
import { useResizeObserver } from '@vueuse/core'
import { Refresh } from '@element-plus/icons-vue'
import { stockoutListLogs } from '@/api/storage.stockout/stockout'
import RequestData from '@/components/RequestData/index.vue'
const props = defineProps<{
id: string | number
id?: number | string
}>()
const logs = ref<any[]>([])
const loading = ref(false)
const tableData = ref<any[]>([])
const showRequestData = ref(false)
const requestId = ref(0)
const requestType = ref('')
const tableHostRef = ref<HTMLElement | null>(null)
const tableHeight = ref(280)
// 操作编码 → 时间线节点颜色
const OPERATION_COLOR_MAP: Record<string, string> = {
STOCKOUT_CONFIRM: 'success',
STOCKOUT_TO_ORDER: 'warning',
STOCKOUT_CANCEL: 'danger',
STOCKOUT_UPDATE_INFO: 'info'
}
const normalizeLog = (item: any, index: number) => ({
id: item.id ?? index,
created_at: item.created_at || '',
operator_name: item.operator_name || '—',
action: item.operation_name || item.operation_code || '',
remark: item.message || '',
platform_name: item.platform_name || '',
type: OPERATION_COLOR_MAP[item.operation_code] || 'primary'
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
const loadLogs = async () => {
if (!props.id) {
logs.value = []
return
useResizeObserver(tableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
tableHeight.value = Math.floor(h)
}
})
watch(() => props.id, (newVal) => {
if (newVal) {
pagination.page = 1
fetchStockoutLogs()
} else {
tableData.value = []
pagination.total = 0
}
requestAnimationFrame(() => {
const el = tableHostRef.value
if (el) {
const h = el.getBoundingClientRect().height
if (h >= 100) tableHeight.value = Math.floor(h)
}
})
}, { immediate: true })
async function handlePageChange(page: number) {
pagination.page = page
await fetchStockoutLogs()
}
async function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
await fetchStockoutLogs()
}
async function fetchStockoutLogs() {
if (!props.id) return
loading.value = true
try {
const res: any = await stockoutListLogs({ id: Number(props.id), page: 1, pageSize: 50 })
// 兼容 { data: { list } } 与 { list } 两种包装
const res: any = await stockoutListLogs({
id: Number(props.id),
page: pagination.page,
pageSize: pagination.pageSize
})
// 兼容 { data: { list, pagination } } 与 { list, pagination } 两种包装
const data =
res?.data && typeof res.data === 'object' && Array.isArray(res.data.list) ? res.data : res
const list = Array.isArray(data?.list) ? data.list : []
logs.value = list.map(normalizeLog)
} catch (e) {
console.error('加载出库单操作日志失败', e)
logs.value = []
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
tableData.value = (Array.isArray(data?.list) ? data.list : []).map((item: any) => ({
...item,
operator_name: item.operator_name || '—',
operation_name: item.operation_name || item.operation_code || '',
message: item.message || '',
platform_name: item.platform_name || ''
}))
pagination.page = data?.pagination?.page ?? pagination.page
pagination.pageSize = data?.pagination?.pageSize ?? pagination.pageSize
pagination.total = data?.pagination?.total ?? 0
} else {
tableData.value = []
pagination.total = 0
}
} catch (error) {
console.error('获取出库单操作日志失败', error)
tableData.value = []
pagination.total = 0
} finally {
loading.value = false
}
}
watch(() => props.id, loadLogs, { immediate: true })
function viewData(row: any) {
requestId.value = Number(row.external_log_id) || 0
requestType.value = row.external_log_type
showRequestData.value = true
}
// KeepAlive 缓存下重新进入 tab 时刷新日志
onActivated(loadLogs)
function backData(_row: any) {
}
</script>
<style scoped lang="scss">
.stockout-log-container {
padding: 20px;
.log-container {
height: 100%;
overflow-y: auto;
width: 100%;
padding: 6px 10px;
overflow: hidden;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.log-content {
.operator {
font-weight: bold;
margin-right: 10px;
}
.action {
color: #409eff;
}
.platform {
margin-left: 10px;
}
.remark {
margin-top: 5px;
color: #909399;
font-size: 13px;
}
}
.toolbar-btn-group {
flex-shrink: 0;
margin-bottom: 6px;
}
.table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.pagination-container {
flex-shrink: 0;
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 8px;
padding-top: 4px;
}
:deep(.el-drawer__body) {
height: 100%;
padding: 0;
}
</style>

View File

@ -2,55 +2,77 @@
<div class="stockout-details-container">
<el-form :model="form" label-width="120px" class="details-form">
<el-row :gutter="30">
<el-col :span="12">
<el-form-item
v-for="field in detailpanel"
:key="field.prop"
:label="field.label"
:prop="field.prop"
>
<template v-if="field.type === 'select'">
<el-select
v-model="(form as any)[field.prop]"
:placeholder="'请选择' + field.label"
style="width: 100%"
:disabled="field.disabled"
>
<el-option
v-for="item in availableFields.find(f => f.value === field.prop)?.options || []"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template v-else-if="field.type === 'textarea'">
<el-input
v-model="(form as any)[field.prop]"
type="textarea"
:rows="3"
:disabled="field.disabled"
:placeholder="'请输入' + field.label"
<el-col :span="12" v-for="field in detailpanel" :key="field.prop">
<el-form-item :label="field.label" :prop="field.prop">
<!-- 快递编码:下拉(与“修改出库单信息”一致) -->
<el-select
v-if="field.prop === 'express_code'"
v-model="(form as any)[field.prop]"
placeholder="请选择快递"
clearable
filterable
style="width:100%"
>
<el-option
v-for="opt in detailExpressOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</template>
</el-select>
<!-- 来源平台编码:下拉(与“修改出库单信息”一致) -->
<el-select
v-else-if="field.prop === 'source_platform_code'"
v-model="(form as any)[field.prop]"
placeholder="请选择来源平台"
clearable
filterable
style="width:100%"
@change="handleDetailPlatformChange"
>
<el-option
v-for="opt in detailPlatformOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
<!-- 其他字段 -->
<template v-else>
<el-input
v-model="(form as any)[field.prop]"
:disabled="field.disabled"
:placeholder="'请输入' + field.label"
/>
<template v-if="field.type === 'select'">
<el-select
v-model="(form as any)[field.prop]"
:placeholder="'请选择' + field.label"
style="width: 100%"
:disabled="field.disabled"
>
<el-option
v-for="item in availableFields.find(f => f.value === field.prop)?.options || []"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template v-else-if="field.type === 'textarea'">
<el-input
v-model="(form as any)[field.prop]"
type="textarea"
:rows="3"
:disabled="field.disabled"
:placeholder="'请输入' + field.label"
/>
</template>
<template v-else>
<el-input
v-model="(form as any)[field.prop]"
:disabled="field.disabled"
:placeholder="'请输入' + field.label"
/>
</template>
</template>
</el-form-item>
</el-col>
<el-col :span="12">
<div class="image-placeholder">
<div class="placeholder-content">
<el-icon :size="48" color="#909399"><Picture /></el-icon>
<p>出库单图片/附件区</p>
</div>
</div>
</el-col>
</el-row>
</el-form>
@ -71,8 +93,9 @@
import { ref, watch, onMounted } from 'vue'
import { availableFields, detailpanel } from '../stockout-config'
import { ElMessage } from 'element-plus'
import { Picture, Check, Refresh } from '@element-plus/icons-vue'
import { Check, Refresh } from '@element-plus/icons-vue'
import * as stockoutApi from '@/api/storage.stockout/stockout'
import * as indexApi from '@/api/index/index'
const props = defineProps<{
id: string | number,
@ -87,50 +110,117 @@ const form = ref<any>({})
const saveLoading = ref(false)
// ── 快递 / 来源平台下拉选项(与“修改出库单信息”一致)──
const detailExpressOptions = ref<Array<{ label: string; value: string }>>([])
const detailPlatformOptions = ref<Array<{ label: string; value: string }>>([])
async function loadDetailSelectOptions() {
try {
const [expressRes, platformRes]: any = await Promise.all([
indexApi.getExpressList({ systemOnly: 'true' }),
indexApi.getPlatformList({ systemOnly: 'true' })
])
const expressRaw = expressRes?.data?.list || expressRes?.data || []
detailExpressOptions.value = (Array.isArray(expressRaw) ? expressRaw : [])
.map((item: any) => {
const code = String(item?.express_code || item?.code || item?.express?.code || '').trim()
const name = String(item?.name || item?.express_name || item?.express?.name || '').trim()
return { value: code, label: name ? `${code} - ${name}` : code }
})
.filter((o) => !!o.value)
const platformRaw = platformRes?.data?.list || platformRes?.data || []
detailPlatformOptions.value = (Array.isArray(platformRaw) ? platformRaw : [])
.map((item: any) => {
const code = String(item?.code || item?.platform_code || '').trim()
const name = String(item?.name || item?.platform_name || '').trim()
return { value: code, label: name ? `${code} - ${name}` : code }
})
.filter((o) => !!o.value)
} catch {
detailExpressOptions.value = []
detailPlatformOptions.value = []
}
}
/** 选中来源平台编码时自动带出平台名称 */
function handleDetailPlatformChange(val: string) {
if (!val) return
const opt = detailPlatformOptions.value.find((o) => o.value === val)
if (opt) {
const sep = opt.label.indexOf(' - ')
form.value.source_platform_name = sep > -1 ? opt.label.slice(sep + 3) : opt.label
}
}
/** 行数据(receiver_* 前缀)→ 表单字段名(storage.stockout.updateInfo 参数名) */
function mapRowToForm(row: any) {
if (!row) return {}
return {
id: row.id,
stockout_order_code: row.stockout_order_code,
order_status: row.order_status,
name: row.receiver_name ?? '',
mobile: row.receiver_mobile ?? '',
tel: row.receiver_tel ?? '',
company: row.receiver_company ?? '',
email: row.receiver_email ?? '',
zipCode: row.receiver_zip_code ?? '',
countryCode: row.receiver_country_code ?? '',
receiver_id: row.receiver_id ?? '',
province: row.receiver_province ?? '',
city: row.receiver_city ?? '',
area: row.receiver_area ?? '',
town: row.receiver_town ?? '',
detailAddress: row.receiver_detail_address ?? '',
express_code: row.express_code ?? '',
source_platform_code: row.source_platform_code ?? '',
source_platform_name: row.source_platform_name ?? ''
}
}
const handleSave = async () => {
try {
saveLoading.value = true
const id = form.value.id || props.id
if (!id) {
ElMessage.warning('缺少出库单ID')
return
}
const payload: any = { id: Number(id) }
if (form.value.express_code !== undefined) {
payload.express_code = form.value.express_code || undefined
}
if (form.value.express_codes !== undefined) {
const codes = typeof form.value.express_codes === 'string'
? form.value.express_codes.split(/[,;\n]+/).map((s: string) => s.trim()).filter(Boolean)
: form.value.express_codes
payload.express_codes = codes?.length ? codes : undefined
}
await stockoutApi.stockoutUpdateExpress(payload)
ElMessage.success('运单信息保存成功')
emit('refresh')
} catch (error) {
ElMessage.error('保存失败')
} finally {
saveLoading.value = false
try {
const id = form.value.id || props.id
if (!id) {
ElMessage.warning('缺少出库单ID')
return
}
saveLoading.value = true
// 只提交非空的可编辑字段(未传入字段后端不修改)
const payload: any = { id: Number(id) }
for (const field of detailpanel) {
if (field.disabled) continue
const v = form.value[field.prop]
if (v !== undefined && v !== null && String(v).trim() !== '') {
payload[field.prop] = v
}
}
await stockoutApi.stockoutUpdateInfo(payload)
ElMessage.success('出库单信息保存成功')
emit('refresh')
} catch (error) {
ElMessage.error('保存失败')
} finally {
saveLoading.value = false
}
}
const handleReset = () => {
if (props.row) {
form.value = { ...props.row }
}
form.value = mapRowToForm(props.row)
ElMessage.info('表单已重置')
}
watch(() => props.row, (newRow) => {
if (newRow) {
form.value = { ...newRow }
form.value = mapRowToForm(newRow)
}
// 加载快递/平台下拉选项,回填的编码自动选中匹配选项
void loadDetailSelectOptions()
}, { immediate: true })
onMounted(() => {
if (props.row) {
form.value = { ...props.row }
form.value = mapRowToForm(props.row)
}
})
</script>
@ -158,27 +248,6 @@ onMounted(() => {
scrollbar-width: none;
}
.image-placeholder {
width: 100%;
height: 400px;
background-color: #f5f7fa;
border: 1px dashed #dcdfe6;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
.placeholder-content {
text-align: center;
color: #909399;
p {
margin-top: 10px;
font-size: 14px;
}
}
}
.bottom {
flex-shrink: 0;
text-align: right;

View File

@ -85,6 +85,25 @@
>
转销售订单
</el-button>
<!-- <el-button
v-if="row.order_status === 'CREATED' || row.order_status === 'PENDING'"
type="warning"
link
size="small"
@click.stop="openUpdateInfoDialog(row)"
>
修改
</el-button> -->
<el-button
v-if="row.order_status === 'CREATED' || row.order_status === 'PENDING'"
type="danger"
link
size="small"
:loading="row._cancelLoading"
@click.stop="handleSingleRowCancel(row)"
>
取消
</el-button>
</template>
<template #empty>
@ -149,13 +168,13 @@
:close-on-click-modal="false"
>
<div class="to-order-dialog">
<el-alert
<!-- <el-alert
type="info"
:closable="false"
show-icon
:title="`将出库单「${toOrderTargetRow?.stockout_order_code || toOrderTargetRow?.id || ''}」转为正式销售订单,转单成功后原出库单将置为已作废。`"
style="margin-bottom: 16px;"
/>
/> -->
<el-form :model="toOrderForm" label-width="110px">
<el-form-item label="新订单号">
@ -225,6 +244,190 @@
<el-button type="primary" :loading="toOrderLoading" @click="handleToOrderSubmit">确认转单</el-button>
</template>
</el-dialog>
<el-dialog
v-model="updateInfoDialogVisible"
title="修改出库单信息"
width="680px"
align-center
append-to-body
destroy-on-close
:close-on-click-modal="false"
>
<div class="update-info-dialog">
<!-- <el-alert
type="info"
:closable="false"
show-icon
:title="`修改出库单「${updateInfoTargetRow?.stockout_order_code || updateInfoTargetRow?.id || ''}」的信息,留空的字段不修改。`"
style="margin-bottom: 16px;"
/> -->
<el-form :model="updateInfoForm" label-width="100px">
<el-divider content-position="left">收件人信息</el-divider>
<el-row :gutter="12">
<el-col :span="12">
<el-form-item label="姓名">
<el-input v-model="updateInfoForm.name" placeholder="收件人姓名" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="手机号">
<el-input v-model="updateInfoForm.mobile" placeholder="手机号" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="12">
<el-col :span="12">
<el-form-item label="电话">
<el-input v-model="updateInfoForm.tel" placeholder="固定电话(可选)" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公司">
<el-input v-model="updateInfoForm.company" placeholder="收件人公司(可选)" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="12">
<el-col :span="12">
<el-form-item label="邮箱">
<el-input v-model="updateInfoForm.email" placeholder="电子邮箱(可选)" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="邮编">
<el-input v-model="updateInfoForm.zipCode" placeholder="邮编(可选)" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="12">
<el-col :span="12">
<el-form-item label="证件号">
<el-input v-model="updateInfoForm.receiver_id" placeholder="收件人证件号(可选)" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="国家">
<el-input v-model="updateInfoForm.countryCode" placeholder="国家二字码(可选)" clearable />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">地址信息</el-divider>
<el-row :gutter="12">
<el-col :span="8">
<el-form-item label="省份">
<el-input v-model="updateInfoForm.province" placeholder="省份" clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="城市">
<el-input v-model="updateInfoForm.city" placeholder="城市" clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="区县">
<el-input v-model="updateInfoForm.area" placeholder="区县" clearable />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="乡镇">
<el-input v-model="updateInfoForm.town" placeholder="镇/街道(可选)" clearable />
</el-form-item>
<el-form-item label="详细地址">
<el-input v-model="updateInfoForm.detailAddress" type="textarea" :rows="2" placeholder="详细地址" clearable />
</el-form-item>
<el-divider content-position="left">快递与平台(可选)</el-divider>
<el-row :gutter="12">
<el-col :span="12">
<el-form-item label="快递">
<el-select
v-model="updateInfoForm.express_code"
placeholder="请选择快递"
clearable
filterable
style="width:100%"
>
<el-option
v-for="opt in updateInfoExpressOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="来源平台">
<el-select
v-model="updateInfoForm.source_platform_code"
placeholder="请选择来源平台"
clearable
filterable
style="width:100%"
@change="handleSourcePlatformChange"
>
<el-option
v-for="opt in updateInfoPlatformOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="来源平台名称">
<el-input v-model="updateInfoForm.source_platform_name" placeholder="来源平台名称(自动带出,可修改)" clearable />
</el-form-item>
</el-form>
</div>
<template #footer>
<el-button @click="updateInfoDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="updateInfoLoading" @click="handleUpdateInfoSubmit">保存修改</el-button>
</template>
</el-dialog>
<el-dialog
v-model="updateExpressDialogVisible"
title="更新运单号"
width="520px"
align-center
append-to-body
destroy-on-close
:close-on-click-modal="false"
>
<div class="update-express-dialog">
<!-- <el-alert
type="info"
:closable="false"
show-icon
:title="`更新出库单「${updateExpressTargetRow?.stockout_order_code || updateExpressTargetRow?.id || ''}」的运单号。`"
style="margin-bottom: 16px;"
/> -->
<el-form :model="updateExpressForm" label-width="100px">
<el-form-item label="运单号">
<el-input v-model="updateExpressForm.express_code" placeholder="运单号" clearable />
</el-form-item>
<el-form-item label="运单号列表">
<el-input
v-model="updateExpressForm.express_codes"
type="textarea"
:rows="3"
placeholder="多个运单号用逗号或换行分隔(可选)"
/>
</el-form-item>
</el-form>
</div>
<template #footer>
<el-button @click="updateExpressDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="updateExpressLoading" @click="handleUpdateExpressSubmit">确认更新</el-button>
</template>
</el-dialog>
</div>
</template>
@ -241,7 +444,7 @@ import { safeInvoke } from '@/utils/safe-invoke'
import * as XLSX from 'xlsx'
import * as indexApi from '@/api/index/index'
import * as stockoutApi from '@/api/storage.stockout/stockout' //现有的对应API
import type { StockoutToOrderParams } from '@/api/storage.stockout/stockout'
import type { StockoutToOrderParams, StockoutUpdateInfoParams } from '@/api/storage.stockout/stockout'
import {
availableFields,
entryColums,
@ -354,6 +557,16 @@ function resetToOrderForm() {
function openToOrderDialog(row: any) {
toOrderTargetRow.value = row
resetToOrderForm()
// 回填当前行已有收货信息(storage.stockout.list 的 receiver_* → receiverInfo)
toOrderForm.receiverInfo.name = String(row?.receiver_name ?? '')
toOrderForm.receiverInfo.mobile = String(row?.receiver_mobile ?? '')
toOrderForm.receiverInfo.tel = String(row?.receiver_tel ?? '')
toOrderForm.receiverInfo.zipCode = String(row?.receiver_zip_code ?? '')
toOrderForm.receiverInfo.province = String(row?.receiver_province ?? '')
toOrderForm.receiverInfo.city = String(row?.receiver_city ?? '')
toOrderForm.receiverInfo.area = String(row?.receiver_area ?? '')
toOrderForm.receiverInfo.town = String(row?.receiver_town ?? '')
toOrderForm.receiverInfo.detailAddress = String(row?.receiver_detail_address ?? '')
toOrderDialogVisible.value = true
}
@ -394,6 +607,229 @@ async function handleToOrderSubmit() {
}
}
// ── 修改出库单信息(storage.stockout.updateInfo)──
const updateInfoDialogVisible = ref(false)
const updateInfoLoading = ref(false)
const updateInfoTargetRow = ref<any>(null)
const updateInfoForm = reactive({
name: '',
tel: '',
mobile: '',
company: '',
email: '',
zipCode: '',
countryCode: '',
province: '',
city: '',
area: '',
town: '',
detailAddress: '',
receiver_id: '',
express_code: '',
source_platform_code: '',
source_platform_name: ''
})
function resetUpdateInfoForm() {
updateInfoForm.name = ''
updateInfoForm.tel = ''
updateInfoForm.mobile = ''
updateInfoForm.company = ''
updateInfoForm.email = ''
updateInfoForm.zipCode = ''
updateInfoForm.countryCode = ''
updateInfoForm.province = ''
updateInfoForm.city = ''
updateInfoForm.area = ''
updateInfoForm.town = ''
updateInfoForm.detailAddress = ''
updateInfoForm.receiver_id = ''
updateInfoForm.express_code = ''
updateInfoForm.source_platform_code = ''
updateInfoForm.source_platform_name = ''
}
function openUpdateInfoDialog(row: any) {
updateInfoTargetRow.value = row
resetUpdateInfoForm()
// 回填当前行已有数据(列表字段 receiver_* → 表单字段)
updateInfoForm.name = String(row?.receiver_name ?? '')
updateInfoForm.tel = String(row?.receiver_tel ?? '')
updateInfoForm.mobile = String(row?.receiver_mobile ?? '')
updateInfoForm.company = String(row?.receiver_company ?? '')
updateInfoForm.email = String(row?.receiver_email ?? '')
updateInfoForm.zipCode = String(row?.receiver_zip_code ?? '')
updateInfoForm.countryCode = String(row?.receiver_country_code ?? '')
updateInfoForm.province = String(row?.receiver_province ?? '')
updateInfoForm.city = String(row?.receiver_city ?? '')
updateInfoForm.area = String(row?.receiver_area ?? '')
updateInfoForm.town = String(row?.receiver_town ?? '')
updateInfoForm.detailAddress = String(row?.receiver_detail_address ?? '')
updateInfoForm.receiver_id = String(row?.receiver_id ?? '')
updateInfoForm.express_code = String(row?.express_code ?? '')
updateInfoForm.source_platform_code = String(row?.source_platform_code ?? '')
updateInfoForm.source_platform_name = String(row?.source_platform_name ?? '')
// 加载快递/平台下拉选项(后端编码列表),回填值自动选中对应编码选项
void loadUpdateInfoSelectOptions()
updateInfoDialogVisible.value = true
}
// ── 修改出库单信息下拉选项(快递 / 来源平台)──
const updateInfoExpressOptions = ref<Array<{ label: string; value: string }>>([])
const updateInfoPlatformOptions = ref<Array<{ label: string; value: string }>>([])
async function loadUpdateInfoSelectOptions() {
try {
const [expressRes, platformRes]: any = await Promise.all([
indexApi.getExpressList({ systemOnly: 'true' }),
indexApi.getPlatformList({ systemOnly: 'true' })
])
const expressRaw = expressRes?.data?.list || expressRes?.data || []
updateInfoExpressOptions.value = (Array.isArray(expressRaw) ? expressRaw : [])
.map((item: any) => {
const code = String(item?.express_code || item?.code || item?.express?.code || '').trim()
const name = String(item?.name || item?.express_name || item?.express?.name || '').trim()
return { value: code, label: name ? `${code} - ${name}` : code }
})
.filter((o) => !!o.value)
const platformRaw = platformRes?.data?.list || platformRes?.data || []
updateInfoPlatformOptions.value = (Array.isArray(platformRaw) ? platformRaw : [])
.map((item: any) => {
const code = String(item?.code || item?.platform_code || '').trim()
const name = String(item?.name || item?.platform_name || '').trim()
return { value: code, label: name ? `${code} - ${name}` : code }
})
.filter((o) => !!o.value)
} catch {
updateInfoExpressOptions.value = []
updateInfoPlatformOptions.value = []
}
}
/** 选中来源平台编码时自动带出平台名称 */
function handleSourcePlatformChange(val: string) {
if (!val) return
const opt = updateInfoPlatformOptions.value.find((o) => o.value === val)
if (opt) {
const sep = opt.label.indexOf(' - ')
updateInfoForm.source_platform_name = sep > -1 ? opt.label.slice(sep + 3) : opt.label
}
}
async function handleUpdateInfoSubmit() {
const row = updateInfoTargetRow.value
if (!row) return
// 只提交非空字段(未传入的字段后端不修改)
const payload: StockoutUpdateInfoParams = { id: row.id }
for (const [k, v] of Object.entries(updateInfoForm)) {
if (String(v || '').trim() !== '') {
;(payload as Record<string, any>)[k] = v
}
}
updateInfoLoading.value = true
try {
const res: any = await stockoutApi.stockoutUpdateInfo(payload)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
ElMessage.success('出库单信息修改成功')
updateInfoDialogVisible.value = false
loadData()
} else {
ElMessage.error(res?.message || '修改失败')
}
} catch (e: any) {
ElMessage.error(e?.message || '修改失败')
} finally {
updateInfoLoading.value = false
}
}
/** 单行取消出库单(storage.stockout.cancel) */
async function handleSingleRowCancel(row: any) {
try {
await ElMessageBox.confirm(
`确定要取消出库单「${row.stockout_order_code || row.id}」吗?取消后将释放库存锁定。`,
'取消出库单',
{ type: 'warning', confirmButtonText: '确认取消', cancelButtonText: '返回' }
)
} catch {
return
}
row._cancelLoading = true
try {
const res: any = await stockoutApi.stockoutCancel({ id: row.id })
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
ElMessage.success('出库单已取消')
loadData()
} else {
ElMessage.error(res?.message || '取消失败')
}
} catch (e: any) {
ElMessage.error(e?.message || '取消失败')
} finally {
row._cancelLoading = false
}
}
// ── 更新运单号(storage.stockout.updateExpress)──
const updateExpressDialogVisible = ref(false)
const updateExpressLoading = ref(false)
const updateExpressTargetRow = ref<any>(null)
const updateExpressForm = reactive({
express_code: '',
express_codes: ''
})
function openUpdateExpressDialog() {
const rows = selectionRows.value
if (!rows.length) {
ElMessage.warning('请先选择要更新运单号的出库单')
return
}
if (rows.length > 1) {
ElMessage.warning('请选择单个出库单更新运单号')
return
}
const row = rows[0]
updateExpressTargetRow.value = row
updateExpressForm.express_code = String(row?.express_code ?? '')
updateExpressForm.express_codes = Array.isArray(row?.express_codes)
? row.express_codes.join('\n')
: String(row?.express_codes ?? '')
updateExpressDialogVisible.value = true
}
async function handleUpdateExpressSubmit() {
const row = updateExpressTargetRow.value
if (!row) return
const payload: any = { id: row.id }
const code = updateExpressForm.express_code.trim()
if (code) payload.express_code = code
const codes = updateExpressForm.express_codes
.split(/[,;\n]+/)
.map((s: string) => s.trim())
.filter(Boolean)
if (codes.length) payload.express_codes = codes
updateExpressLoading.value = true
try {
const res: any = await stockoutApi.stockoutUpdateExpress(payload)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
ElMessage.success('运单号更新成功')
updateExpressDialogVisible.value = false
loadData()
} else {
ElMessage.error(res?.message || '更新失败')
}
} catch (e: any) {
ElMessage.error(e?.message || '更新失败')
} finally {
updateExpressLoading.value = false
}
}
// ── 工具栏状态 ──
const buttonLoadingMap = computed(() => ({
loading: loading.value,
@ -439,6 +875,7 @@ const toolbarActionMap: Record<string, () => void> = {
toggleDetailVisible: () => toggleDetailVisible(),
handleCreateStockout: () => handleCreateStockout(),
handleImport: () => handleImport(),
handleUpdateExpress: () => openUpdateExpressDialog(),
handleOpenPrintDialog: () => { void handleOpenPrintDialog() },
confirmBatchCancel: () => { void confirmBatchCancel() }
}
@ -786,8 +1223,21 @@ async function confirmBatchCancel() {
}
try {
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个出库单吗?`, '确认', { type: 'warning' })
// 调用 API
ElMessage.success('批量作废成功')
let successCount = 0
let failCount = 0
for (const row of selectionRows.value) {
try {
const res: any = await stockoutApi.stockoutCancel({ id: row.id })
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
successCount += 1
} else {
failCount += 1
}
} catch {
failCount += 1
}
}
ElMessage.success(`批量作废完成:成功 ${successCount} 条${failCount ? `,失败 ${failCount} 条` : ''}`)
loadData()
} catch (e) {}
}

View File

@ -35,12 +35,20 @@ export const stockoutToolbarButtons: ToolbarButtonConfig[] = [
// size: 'small',
// action: 'handleCreateStockout'
// },
// {
// key: 'import',
// label: '导入',
// category: 'action',
// size: 'small',
// action: 'handleImport'
// },
{
key: 'import',
label: '导入',
key: 'updateExpress',
label: '更新运单号',
category: 'action',
size: 'small',
action: 'handleImport'
disabledKey: 'hasNoSelection',
action: 'handleUpdateExpress'
},
{
key: 'print',
@ -111,12 +119,14 @@ export const statusConfig: Record<string, { text: string; tagType: string }> = {
PROCESSING: { text: '出库中', tagType: 'primary' },
COMPLETED: { text: '已完成', tagType: 'success' },
CANCELLED: { text: '已作废', tagType: 'danger' },
TRANSFERRED: { text: '已转订单', tagType: 'warning' },
// 兼容旧小写
created: { text: '已创建', tagType: '' },
pending: { text: '待出库', tagType: 'warning' },
processing: { text: '出库中', tagType: 'primary' },
completed: { text: '已完成', tagType: 'success' },
cancelled: { text: '已作废', tagType: 'danger' }
cancelled: { text: '已作废', tagType: 'danger' },
transferred: { text: '已转订单', tagType: 'warning' }
}
// sync_status 实际值(接口返回大写;兼容旧小写与拼写)
@ -169,6 +179,20 @@ export function formatExpressCodes(row: any): string {
return unique.map(escapeHtml).join('<br/>')
}
// 转单订单号列:从 extend_props.transferred_order_code 提取(转销售订单后的新订单号)
export function formatTransferredOrderCode(row: any): string {
const code = row?.extend_props?.transferred_order_code
return String(code ?? '').trim() || '--'
}
// 省市区列:拼接 省/市/区县/乡镇,空则 --
export function formatReceiverRegion(row: any): string {
const parts = [row?.receiver_province, row?.receiver_city, row?.receiver_area, row?.receiver_town]
.map((v) => String(v ?? '').trim())
.filter(Boolean)
return parts.join(' ') || '--'
}
export const entryColums = [
{ prop: 'stockout_order_code', label: '出库单号', width: '220', fixed: 'left', copyAction: 'copy' as const },
{ prop: 'order_status', label: '出库状态', width: '100' },
@ -176,12 +200,18 @@ export const entryColums = [
{ prop: 'sync_message', label: '同步消息', minWidth: '140', showOverflowTooltip: true },
{ prop: 'order_type', label: '单据类型', width: '100' },
{ prop: 'source_type', label: '来源类型', width: '100' },
{ prop: 'store_name', label: '货主', minWidth: '140', formatter: (row: any) => String(row?.store_name || '').trim() || '--' },
{ prop: 'source_platform_name', label: '来源平台', width: '130', formatter: (row: any) => String(row?.source_platform_name || '').trim() || '--' },
{ prop: 'extend_props', label: '转单订单号', width: '180', formatter: (row: any) => formatTransferredOrderCode(row) },
{ prop: 'qimen_owner_code', label: '奇门货主编码', width: '140' },
{ prop: 'qimen_warehouse_code', label: '奇门仓库编码', width: '140' },
{ prop: 'express_codes', label: '运单号', width: '140', formatter: (row: any) => formatExpressCodes(row) },
{ prop: 'express_code', label: '快递编码', width: '110' },
{ prop: 'express_name', label: '快递名称', width: '110' },
{ prop: 'total_order_lines', label: '订单行数', width: '90' },
{ prop: 'receiver_name', label: '收件人', width: '110', formatter: (row: any) => String(row?.receiver_name || '').trim() || '--' },
{ prop: 'receiver_mobile', label: '手机号', width: '120', formatter: (row: any) => String(row?.receiver_mobile || '').trim() || '--' },
{ prop: 'receiver_province', label: '省市区', minWidth: '180', formatter: (row: any) => formatReceiverRegion(row) },
{ prop: 'remark', label: '备注', minWidth: '150' },
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
{ prop: 'created_at', label: '创建时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.created_at) },
@ -230,7 +260,8 @@ export const availableFields: StockoutScanFieldConfig[] = [
{ value: 'PENDING', label: '待出库' },
{ value: 'PROCESSING', label: '出库中' },
{ value: 'COMPLETED', label: '已完成' },
{ value: 'CANCELLED', label: '已作废' }
{ value: 'CANCELLED', label: '已作废' },
{ value: 'TRANSFERRED', label: '已转订单' }
]
}),
stockoutScanWorkflowField({
@ -254,15 +285,26 @@ export const availableFields: StockoutScanFieldConfig[] = [
}),
]
// 详情面板表单配置
// 详情面板表单配置(修改出库单信息:storage.stockout.updateInfo 字段)
export const detailpanel = [
{ prop: 'stockout_order_code', label: '出库单号', type: 'input', disabled: true },
{ prop: 'order_status', label: '出库状态', type: 'select', disabled: true },
{ prop: 'express_code', label: '运单号', type: 'input', disabled: false },
{ prop: 'express_codes', label: '运单号列表', type: 'textarea', disabled: false },
{ prop: 'qimen_owner_code', label: '奇门货主编码', type: 'input', disabled: true },
{ prop: 'qimen_warehouse_code', label: '奇门仓库编码', type: 'input', disabled: true },
{ prop: 'remark', label: '备注', type: 'textarea' },
{ prop: 'name', label: '收件人姓名', type: 'input', disabled: false },
{ prop: 'mobile', label: '手机号', type: 'input', disabled: false },
{ prop: 'tel', label: '电话', type: 'input', disabled: false },
{ prop: 'company', label: '公司', type: 'input', disabled: false },
{ prop: 'email', label: '邮箱', type: 'input', disabled: false },
{ prop: 'zipCode', label: '邮编', type: 'input', disabled: false },
{ prop: 'countryCode', label: '国家', type: 'input', disabled: false },
{ prop: 'receiver_id', label: '证件号', type: 'input', disabled: false },
{ prop: 'province', label: '省份', type: 'input', disabled: false },
{ prop: 'city', label: '城市', type: 'input', disabled: false },
{ prop: 'area', label: '区县', type: 'input', disabled: false },
{ prop: 'town', label: '乡镇', type: 'input', disabled: false },
{ prop: 'detailAddress', label: '详细地址', type: 'textarea', disabled: false },
{ prop: 'express_code', label: '快递编码', type: 'input', disabled: false },
{ prop: 'source_platform_code', label: '来源平台编码', type: 'input', disabled: false },
{ prop: 'source_platform_name', label: '来源平台名称', type: 'input', disabled: false },
]
export const productColumns = [

View File

@ -417,6 +417,14 @@ const FALLBACK_FIELDS: NormalizedField[] = [
default: [],
required: false,
description: '订单备注命中任一关键字时,跳过自动分配快递,默认 [](不排除任何订单)'
},
{
key: 'default_location_id',
label: '默认库位ID',
type: 'number',
min: 0,
precision: 0,
description: '默认库位(库位ID,未配置时为 null;须属于当前仓库且未删除、已启用)'
}
]