- setting.warehouse 新增 b2b_packing_quantity_check(默认关闭):开启后 B2B 备货完成 会校验「分箱数量合计 = 应备数量」与「总箱数 = 箱号数」,不符时返回 400 与差异明细; 仓库设置表单补充该开关与说明 - 待处理/配送 B2B 接口补充驼峰别名与图片参数简写 (pickupPlateNumber、pickupFileIds、file_ids、fileIds、pickup_images、orderItemId、boxNo), 配送 B2B 列表说明补充 images / pickup_images 字段结构 - 货主签约与外部仓库页面补充「对方角色」列与详情、我方/对方主体 ID、 待我确认状态;余额日志兼容 balance_before / balance_after 旧字段, 新增「对方主体ID」等值筛选,分页规格统一支持 200 条 - 新增《拣货单模板 148×210 设计与实施》文档及模板 JSON,供波次批量打印拣货单使用
1086 lines
35 KiB
Vue
1086 lines
35 KiB
Vue
<template>
|
||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||
<scan-box
|
||
ref="scanBox"
|
||
cache-key="shipper-signing"
|
||
width="220px"
|
||
title="签约筛选"
|
||
:auto-submit="false"
|
||
:preset-tree="presetTree"
|
||
:available-fields="availableFields"
|
||
:initial-conditions="{ use_status: 1 }"
|
||
@condition-change="handleConditionChange"
|
||
@reset="handleReset"
|
||
@condition-clear="handleConditionClear"
|
||
@submit="handleSubmit"
|
||
/>
|
||
|
||
<div class="main-content">
|
||
<div class="toolbar">
|
||
<div class="toolbar-left">
|
||
<order-toolbar-button-group
|
||
:buttons="toolbarButtons"
|
||
:resolve-disabled="resolveButtonDisabled"
|
||
:resolve-loading="resolveButtonLoading"
|
||
:resolve-label="resolveButtonLabel"
|
||
:layout-key="toolbarLayoutKey"
|
||
@action="handleToolbarButtonClick"
|
||
/>
|
||
<el-tag
|
||
v-if="currentSubject.company_name"
|
||
size="small"
|
||
type="primary"
|
||
effect="plain"
|
||
class="current-subject-tag"
|
||
>
|
||
当前仓库:{{ currentSubject.company_name }}
|
||
</el-tag>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="split-stack" ref="splitStackRef">
|
||
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
|
||
<upper-table
|
||
ref="tableRef"
|
||
title="货主签约列表"
|
||
default-align="center"
|
||
:enable-column-config="true"
|
||
table-id="shipper-signing-list"
|
||
:data="list"
|
||
:columns="columns"
|
||
:table-size="tableSize"
|
||
:loading="loading"
|
||
:pagination="pagination"
|
||
:page-sizes="[10, 20, 50, 100, 200]"
|
||
:show-index="true"
|
||
:show-selection="true"
|
||
:show-actions="true"
|
||
:query-time="queryTime"
|
||
row-key="id"
|
||
@current-change="handleRowClick"
|
||
@row-click="handleRowClick"
|
||
@page-change="handlePageChange"
|
||
@page-size-change="handleSizeChange"
|
||
@sort-change="handleSortChange"
|
||
@selection-change="handleSelectionChange"
|
||
>
|
||
<template #column-counterparty_name="{ row }">
|
||
<span>{{ row.remask || row.counterparty_name }}</span>
|
||
<span v-if="row.remask && row.remask !== row.counterparty_name" class="real-name">({{ row.counterparty_name }})</span>
|
||
</template>
|
||
<template #column-counterparty_role="{ row }">
|
||
<span :class="getStatusTextClass(row.counterparty_role === 'warehouse' ? 'primary' : 'warning')">
|
||
{{ getCounterpartyRoleLabel(row.counterparty_role) }}
|
||
</span>
|
||
</template>
|
||
<template #column-auth_status="{ row }">
|
||
<span :class="getStatusTextClass(getAuthStatusType(row.auth_status))">
|
||
{{ row.auth_status_label || getAuthStatusLabel(row.auth_status) }}
|
||
</span>
|
||
</template>
|
||
<template #column-needs_my_confirm="{ row }">
|
||
<span v-if="row.needs_my_confirm" :class="getStatusTextClass('warning')">待我确认</span>
|
||
<span v-else class="text-muted">—</span>
|
||
</template>
|
||
<template #column-use_status="{ row }">
|
||
<span :class="getStatusTextClass(row.use_status === 1 ? 'success' : 'info')">
|
||
{{ row.use_status === 1 ? '启用' : '禁用' }}
|
||
</span>
|
||
</template>
|
||
<template #column-auth_end="{ row }">
|
||
<span :class="{ 'text-danger': isExpired(row.auth_end) }">{{ row.auth_end || '—' }}</span>
|
||
</template>
|
||
<template #column-print_quantity="{ row }">
|
||
{{ row.print_quantity ?? '—' }}
|
||
</template>
|
||
<template #column-has_qimen_config="{ row }">
|
||
<span :class="getStatusTextClass(row.has_qimen_config ? 'success' : 'info')">
|
||
{{ row.has_qimen_config ? '已配置' : '未配置' }}
|
||
</span>
|
||
</template>
|
||
<template #column-actions="{ row }">
|
||
<div class="wave-operation-actions">
|
||
<el-button
|
||
v-if="row.needs_my_confirm"
|
||
size="small"
|
||
type="warning"
|
||
link
|
||
@click.stop="handleConfirmSign(row)"
|
||
>确认签约</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
link
|
||
@click.stop="handleRename(row)"
|
||
>修改备注</el-button>
|
||
<el-button
|
||
v-if="row.use_status === 1"
|
||
size="small"
|
||
type="danger"
|
||
link
|
||
@click.stop="handleUnbind(row, 0)"
|
||
>禁用</el-button>
|
||
<el-button
|
||
v-else
|
||
size="small"
|
||
type="success"
|
||
link
|
||
@click.stop="handleUnbind(row, 1)"
|
||
>启用</el-button>
|
||
</div>
|
||
</template>
|
||
<template #empty>
|
||
<div class="empty-tip">暂无签约货主数据</div>
|
||
</template>
|
||
</upper-table>
|
||
</div>
|
||
|
||
<template v-if="detailVisible">
|
||
<div
|
||
class="pane-resizer"
|
||
title="拖动调整列表与详情区域高度"
|
||
@mousedown="beginSplitDrag"
|
||
/>
|
||
<div class="lower-level" v-if="selectedRow" :style="lowerPaneStyle">
|
||
<div class="detail-header">
|
||
<el-tabs v-model="activeTab" class="detail-tab">
|
||
<el-tab-pane label="签约详情" name="details" />
|
||
</el-tabs>
|
||
</div>
|
||
|
||
<div class="detail-container">
|
||
<div v-if="activeTab === 'details'" class="detail-panel">
|
||
<!-- 签约主体 -->
|
||
<div class="section">
|
||
<div class="section-title">签约主体</div>
|
||
<el-descriptions :column="2" border size="small" class="detail-descriptions">
|
||
<el-descriptions-item v-if="currentSubject.company_name" label="当前仓库">
|
||
{{ currentSubject.company_name }}
|
||
<el-tag size="small" type="primary" effect="plain" style="margin-left:6px">仓库方</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="对方主体" :span="currentSubject.company_name ? 1 : 2">
|
||
{{ selectedRow.remask || selectedRow.counterparty_name || '—' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item
|
||
v-if="selectedRow.counterparty_name && selectedRow.remask"
|
||
label="对方全称"
|
||
:span="2"
|
||
>
|
||
{{ selectedRow.counterparty_name }}
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</div>
|
||
|
||
<!-- 签约信息 -->
|
||
<div class="section">
|
||
<div class="section-title">签约信息</div>
|
||
<el-descriptions :column="3" border size="small" class="detail-descriptions">
|
||
<el-descriptions-item label="签约ID">{{ selectedRow.id }}</el-descriptions-item>
|
||
<el-descriptions-item label="签约状态">
|
||
<span :class="getStatusTextClass(getAuthStatusType(selectedRow.auth_status))">
|
||
{{ selectedRow.auth_status_label || getAuthStatusLabel(selectedRow.auth_status) }}
|
||
</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="己方主体ID">{{ selectedRow.store_id ?? '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="对方主体ID">{{ selectedRow.warehouse_id ?? '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="对方角色">
|
||
<span :class="getStatusTextClass(selectedRow.counterparty_role === 'warehouse' ? 'primary' : 'warning')">
|
||
{{ getCounterpartyRoleLabel(selectedRow.counterparty_role) }}
|
||
</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="使用状态">
|
||
<span :class="getStatusTextClass(selectedRow.use_status === 1 ? 'success' : 'info')">
|
||
{{ selectedRow.use_status === 1 ? '启用' : '禁用' }}
|
||
</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="待我确认">
|
||
<span v-if="selectedRow.needs_my_confirm" :class="getStatusTextClass('warning')">是</span>
|
||
<span v-else>否</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="授权截止">
|
||
<span :class="{ 'text-danger': isExpired(selectedRow.auth_end) }">{{ selectedRow.auth_end || '—' }}</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="面单余额">{{ selectedRow.print_quantity ?? '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="奇门配置">
|
||
<span :class="getStatusTextClass(selectedRow.has_qimen_config ? 'success' : 'info')">
|
||
{{ selectedRow.has_qimen_config ? '已配置' : '未配置' }}
|
||
</span>
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="no-selection" v-else :style="lowerPaneStyle">
|
||
<div class="empty-tip">
|
||
<p>请从上方列表中选择一项查看详情</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 修改备注弹窗(面板结构 / 尺寸对齐「手工录入运单号」ManualWaybillForm) -->
|
||
<el-dialog
|
||
v-model="renameDialogVisible"
|
||
class="rename-sign-row-dialog"
|
||
width="min(560px, 92vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<div class="task-panel">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>修改备注</h2>
|
||
<p>设置该签约货主在本仓库内的展示名称</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="renameDialogVisible = false"
|
||
>
|
||
<svg viewBox="0 0 12 12" fill="none">
|
||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||
</svg>
|
||
</button>
|
||
</header>
|
||
|
||
<div class="task-panel__body">
|
||
<div class="task-panel__form">
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">签约主体</span>
|
||
<strong class="task-panel__field-value">{{ renameRow?.counterparty_name || '—' }}</strong>
|
||
</div>
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">当前备注</span>
|
||
<strong class="task-panel__field-value">{{ renameRow?.remask || '—' }}</strong>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">备注名称</span>
|
||
<div class="task-panel__field-control">
|
||
<el-input
|
||
v-model="renameForm.remask"
|
||
size="default"
|
||
placeholder="留空则使用货主全称"
|
||
clearable
|
||
@keyup.enter="handleRenameSubmit"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="task-panel__form-tip">
|
||
备注仅在本仓库内作为该货主的显示名称,不会影响货主主体信息;留空保存将恢复为货主全称。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">提交前请确认备注名称无误</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="renameDialogVisible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="renameLoading" @click="handleRenameSubmit">
|
||
保存
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 发起签约(仓库侧:当前仓库作为发起方,对方主体自动识别) -->
|
||
<el-dialog
|
||
v-model="signDialogVisible"
|
||
class="sign-row-dialog"
|
||
width="min(560px, 92vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<div class="task-panel">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>发起签约</h2>
|
||
<p>仓库侧发起签约,对方主体自动识别为仓库或货主</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="signDialogVisible = false"
|
||
>
|
||
<svg viewBox="0 0 12 12" fill="none">
|
||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||
</svg>
|
||
</button>
|
||
</header>
|
||
|
||
<div class="task-panel__body">
|
||
<div class="task-panel__form">
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">当前仓库</span>
|
||
<strong class="task-panel__field-value">{{ currentSubject.company_name || '—' }}</strong>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">对方主体</span>
|
||
<div class="task-panel__field-control">
|
||
<el-select
|
||
v-model="signForm.counterparty_id"
|
||
filterable
|
||
allow-create
|
||
default-first-option
|
||
clearable
|
||
:loading="counterpartyLoading"
|
||
placeholder="选择或输入对方主体ID"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in counterpartyOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="task-panel__form-tip">
|
||
提交后需由对方主体在对应页面「确认签约」;对方主体 ID 兼容仓库与货主。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">提交前请确认对方主体无误</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="signDialogVisible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="signSubmitting" @click="submitSign">提交</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, reactive, nextTick, onMounted, computed } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import {
|
||
storeWarehouseWarehouseList,
|
||
storeWarehouseWarehouseSign,
|
||
storeWarehouseWarehouseConfirmSign
|
||
} from '@/api/storewarehouse.warehouse/storeWarehouse'
|
||
import { storeWarehouseUnbind, storeWarehouseRename } from '@/api/storewarehouse.store/storeWarehouse'
|
||
import { loadWarehouses } from '@/api/index/index'
|
||
import ScanBox from '@/components/ScanBox/index.vue'
|
||
import UpperTable from '@/components/UpperTable/index.vue'
|
||
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
|
||
import type { ToolbarButtonConfig } from '@/components/ToolbarButtonGroup/types'
|
||
import { getStatusTextClass } from '@/utils/statusText'
|
||
import { useSettingsStore } from '@/stores/modules/settings'
|
||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
|
||
const settingsStore = useSettingsStore()
|
||
const containerHeight = computed(() => '100%' /* 高度由布局层(.app-router-page 的 flex:1)提供,不再自己算 vh */)
|
||
|
||
const {
|
||
splitStackRef,
|
||
beginSplitDrag,
|
||
lowerPaneStyle,
|
||
upperPaneStyle,
|
||
} = useVerticalSplitPane({ defaultLowerPercent: 35 })
|
||
|
||
const upperPaneFullStyle = computed(() => ({
|
||
flex: '1 1 auto',
|
||
minHeight: '0',
|
||
overflow: 'hidden',
|
||
}))
|
||
|
||
const detailVisible = ref(true)
|
||
|
||
const toolbarButtons: ToolbarButtonConfig[] = [
|
||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadList' },
|
||
{ key: 'sign', label: '发起签约', category: 'action', size: 'small', action: 'openSignDialog' },
|
||
{
|
||
key: 'toggleDetail',
|
||
label: '显示详情',
|
||
dynamicLabelKey: 'detailToggleLabel',
|
||
category: 'setting',
|
||
size: 'small',
|
||
action: 'toggleDetailVisible'
|
||
},
|
||
]
|
||
|
||
// ─── 工具栏状态管理 ──────────────────────────────────────────────────────────
|
||
const buttonLoadingMap = computed(() => ({
|
||
loading: loading.value
|
||
}))
|
||
|
||
const buttonDisabledMap = computed(() => ({}))
|
||
|
||
const buttonLabelMap = computed(() => ({
|
||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||
}))
|
||
|
||
const toolbarLayoutKey = computed(() =>
|
||
JSON.stringify({
|
||
loading: buttonLoadingMap.value,
|
||
disabled: buttonDisabledMap.value,
|
||
labels: buttonLabelMap.value
|
||
})
|
||
)
|
||
|
||
function resolveButtonLoading(loadingKey?: string) {
|
||
if (!loadingKey) return false
|
||
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
|
||
}
|
||
|
||
function resolveButtonDisabled(disabledKey?: string) {
|
||
if (!disabledKey) return false
|
||
return Boolean((buttonDisabledMap.value as Record<string, boolean>)[disabledKey])
|
||
}
|
||
|
||
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||
if (!dynamicLabelKey) return defaultLabel
|
||
return (buttonLabelMap.value as Record<string, string>)[dynamicLabelKey] || defaultLabel
|
||
}
|
||
|
||
function toggleDetailVisible() {
|
||
detailVisible.value = !detailVisible.value
|
||
}
|
||
|
||
const toolbarActionMap: Record<string, () => void> = {
|
||
loadList: () => { void loadList() },
|
||
openSignDialog: () => { void openSignDialog() },
|
||
toggleDetailVisible: () => toggleDetailVisible()
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
|
||
const columns = [
|
||
{ prop: 'counterparty_name', label: '对方主体', minWidth: 140 },
|
||
{ prop: 'counterparty_role', label: '对方角色', width: 100 },
|
||
{ prop: 'auth_status', label: '签约状态', width: 100 },
|
||
{ prop: 'needs_my_confirm', label: '待确认', width: 90 },
|
||
{ prop: 'use_status', label: '使用状态', width: 90 },
|
||
{ prop: 'print_quantity', label: '面单余额', width: 100 },
|
||
{ prop: 'has_qimen_config', label: '奇门配置', width: 100 },
|
||
{ prop: 'auth_end', label: '授权截止', width: 120 },
|
||
{ prop: 'actions', label: '操作', width: 200, fixed: 'right' }
|
||
]
|
||
|
||
const availableFields = [
|
||
{
|
||
label: '关键词',
|
||
value: 'keyword',
|
||
type: 'text',
|
||
group: '基础信息',
|
||
placeholder: '搜索对方主体名或备注'
|
||
},
|
||
{
|
||
label: '对方主体ID',
|
||
value: 'warehouse_id',
|
||
type: 'number',
|
||
group: '基础信息',
|
||
placeholder: '对方主体ID(兼容 counterparty_id)',
|
||
// 文档:warehouse_id(兼容 counterparty_id),等值匹配
|
||
operators: ['eq'],
|
||
defaultOperator: 'eq',
|
||
hideOperator: true
|
||
},
|
||
{
|
||
label: '签约状态',
|
||
value: 'auth_status',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '待审核', value: 1 },
|
||
{ label: '已通过', value: 2 },
|
||
{ label: '已拒绝', value: 3 },
|
||
{ label: '已解除', value: 4 },
|
||
{ label: '已过期', value: 5 }
|
||
]
|
||
},
|
||
{
|
||
label: '使用状态',
|
||
value: 'use_status',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '全部', value: undefined },
|
||
{ label: '启用', value: 1 },
|
||
{ label: '禁用', value: 0 }
|
||
]
|
||
}
|
||
]
|
||
|
||
const presetTree: any[] = []
|
||
|
||
const currentSubject = ref<{ store_id?: number; company_name?: string; role?: string }>({})
|
||
|
||
const loading = ref(false)
|
||
const queryTime = ref(0)
|
||
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
||
const list = ref<any[]>([])
|
||
const selectionRows = ref<any[]>([])
|
||
const selectedRow = ref<any>(null)
|
||
const tableRef = ref<any>(null)
|
||
const scanBox = ref<any>(null)
|
||
const activeTab = ref('details')
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const currentCondition = ref<any>({ use_status: 1 })
|
||
|
||
// ─── 发起签约(仓库侧:当前仓库在 store_id 方,对方主体自动识别) ─────────────
|
||
const signDialogVisible = ref(false)
|
||
const signSubmitting = ref(false)
|
||
const signForm = reactive<{ counterparty_id: number | string | undefined }>({ counterparty_id: undefined })
|
||
const counterpartyOptions = ref<Array<{ label: string; value: number }>>([])
|
||
const counterpartyLoading = ref(false)
|
||
|
||
/** 对方主体下拉:取 index.loadWarehouses(已是 value/label 形式),也允许直接输入主体ID */
|
||
async function loadCounterpartyOptions() {
|
||
if (counterpartyOptions.value.length) return
|
||
counterpartyLoading.value = true
|
||
try {
|
||
const res = (await loadWarehouses()) as any
|
||
const arr = res?.warehouses || res?.data?.warehouses || []
|
||
counterpartyOptions.value = (Array.isArray(arr) ? arr : [])
|
||
.map((item: any) => ({
|
||
value: Number(item?.value ?? item?.id),
|
||
label: String(item?.label ?? item?.name ?? item?.company_name ?? item?.value ?? '')
|
||
}))
|
||
.filter((opt) => Number.isFinite(opt.value) && opt.value > 0)
|
||
} catch {
|
||
counterpartyOptions.value = []
|
||
} finally {
|
||
counterpartyLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function openSignDialog() {
|
||
signForm.counterparty_id = undefined
|
||
signDialogVisible.value = true
|
||
void nextTick(() => loadCounterpartyOptions())
|
||
}
|
||
|
||
async function submitSign() {
|
||
const counterpartyId = Number(signForm.counterparty_id)
|
||
if (!Number.isFinite(counterpartyId) || counterpartyId <= 0) {
|
||
ElMessage.warning('请选择或输入有效的对方主体ID')
|
||
return
|
||
}
|
||
signSubmitting.value = true
|
||
try {
|
||
const res = (await storeWarehouseWarehouseSign({ counterparty_id: counterpartyId })) as any
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
/* 仓库侧 sign 与货主侧 store.sign 不同:入参只有 counterparty_id,没有 temp_code/预览流程,
|
||
一次调用即出结果。响应 data.mode:initiate=已新建或更新申请;
|
||
already_exists 时用 data.exists_status 区分 1=待确认 / 2=已签约(已签约时 mode 也可能是 already_confirmed) */
|
||
const data = res?.data || {}
|
||
const mode = String(data.mode || '')
|
||
const name = data?.contract?.counterparty_name || ''
|
||
const existsStatus = Number(data.exists_status ?? data?.contract?.auth_status)
|
||
if (mode === 'already_exists' || mode === 'already_confirmed') {
|
||
if (existsStatus === 2) {
|
||
ElMessage.warning(`与「${name}」已签约,无需重复发起`)
|
||
} else {
|
||
ElMessage.warning(`与「${name}」的签约申请已存在,请等待对方确认`)
|
||
}
|
||
} else {
|
||
ElMessage.success(data.action === 'update' ? '已更新签约申请' : '签约申请已提交')
|
||
}
|
||
signDialogVisible.value = false
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '发起签约失败')
|
||
}
|
||
} catch {
|
||
ElMessage.error('发起签约失败')
|
||
} finally {
|
||
signSubmitting.value = false
|
||
}
|
||
}
|
||
|
||
async function loadList() {
|
||
loading.value = true
|
||
const startTime = Date.now()
|
||
try {
|
||
const params: any = {
|
||
page: pagination.currentPage,
|
||
page_size: pagination.pageSize,
|
||
...currentCondition.value
|
||
}
|
||
|
||
const res = await storeWarehouseWarehouseList(params) as any
|
||
if (res?.data) {
|
||
const payload = res.data
|
||
list.value = payload.list || []
|
||
pagination.total = payload.pagination?.total || payload.total || 0
|
||
pagination.currentPage = payload.pagination?.page || payload.page || pagination.currentPage
|
||
pagination.pageSize = payload.pagination?.pageSize || payload.page_size || pagination.pageSize
|
||
if (payload.current_subject) {
|
||
currentSubject.value = payload.current_subject
|
||
}
|
||
}
|
||
} catch {
|
||
ElMessage.error('获取货主签约列表失败')
|
||
} finally {
|
||
queryTime.value = Date.now() - startTime
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function isExpired(dateStr: string | null): boolean {
|
||
if (!dateStr) return false
|
||
const d = new Date(dateStr)
|
||
if (isNaN(d.getTime())) return false
|
||
return d < new Date()
|
||
}
|
||
|
||
function handleConditionChange(condition: any) {
|
||
const where: any = {}
|
||
if (condition) {
|
||
Object.keys(condition).forEach(k => {
|
||
const c = condition[k]
|
||
if (c && typeof c === 'object' && !Array.isArray(c) && c.value !== undefined) {
|
||
if (c.value !== '' && c.value !== null && c.value !== undefined) {
|
||
where[k] = c.value
|
||
}
|
||
} else if (c !== '' && c !== null && c !== undefined) {
|
||
where[k] = c
|
||
}
|
||
})
|
||
}
|
||
currentCondition.value = where
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleSubmit() {
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleConditionClear() {
|
||
currentCondition.value = {}
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleReset() {
|
||
currentCondition.value = {}
|
||
pagination.currentPage = 1
|
||
if (scanBox.value?.reset) {
|
||
scanBox.value.reset()
|
||
} else if (scanBox.value?.clear) {
|
||
scanBox.value.clear()
|
||
}
|
||
loadList()
|
||
}
|
||
|
||
function handlePageChange(page: number) {
|
||
pagination.currentPage = page
|
||
loadList()
|
||
}
|
||
|
||
function handleSizeChange(size: number) {
|
||
pagination.pageSize = size
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleRowClick(row: any) {
|
||
selectedRow.value = row
|
||
}
|
||
|
||
function handleSortChange(_sort: { prop: string; order: string }) {
|
||
// 预留排序事件处理
|
||
}
|
||
|
||
function handleSelectionChange(rows: any[]) {
|
||
selectionRows.value = rows || []
|
||
}
|
||
|
||
function getAuthStatusType(status: number): string {
|
||
const map: Record<number, string> = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info', 5: 'danger' }
|
||
return map[status] || 'info'
|
||
}
|
||
|
||
function getAuthStatusLabel(status: number): string {
|
||
const map: Record<number, string> = { 1: '待审核', 2: '已通过', 3: '已拒绝', 4: '已解除', 5: '已过期' }
|
||
return map[status] || '未知'
|
||
}
|
||
|
||
/** 对方主体角色(文档 counterparty_role):warehouse=外部合作仓库,store=货主 */
|
||
function getCounterpartyRoleLabel(role?: string): string {
|
||
if (role === 'warehouse') return '仓库方'
|
||
if (role === 'store') return '货主方'
|
||
return '—'
|
||
}
|
||
|
||
// ─── 修改备注(弹窗表单,对齐「手工录入运单号」) ─────────────────────────────
|
||
const renameDialogVisible = ref(false)
|
||
const renameLoading = ref(false)
|
||
const renameRow = ref<any>(null)
|
||
const renameForm = reactive({ remask: '' })
|
||
|
||
function handleRename(row: any) {
|
||
renameRow.value = row
|
||
/* 与改造前一致:默认填当前备注,没有备注时填货主全称 */
|
||
renameForm.remask = String(row?.remask ?? row?.counterparty_name ?? '')
|
||
renameDialogVisible.value = true
|
||
}
|
||
|
||
async function handleRenameSubmit() {
|
||
const row = renameRow.value
|
||
if (!row?.id) {
|
||
ElMessage.warning('缺少签约关系 ID,无法修改备注')
|
||
return
|
||
}
|
||
const remask = renameForm.remask.trim()
|
||
renameLoading.value = true
|
||
try {
|
||
const res = await storeWarehouseRename({ id: row.id, remask }) as any
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
ElMessage.success('修改备注成功')
|
||
renameDialogVisible.value = false
|
||
loadList()
|
||
if (selectedRow.value && selectedRow.value.id === row.id) {
|
||
selectedRow.value.remask = remask
|
||
}
|
||
} else {
|
||
ElMessage.error(res?.message || '修改备注失败')
|
||
}
|
||
} catch {
|
||
/* 请求层已提示错误 */
|
||
} finally {
|
||
renameLoading.value = false
|
||
}
|
||
}
|
||
|
||
// ─── 操作 ────────────────────────────────────────────────────────────────────
|
||
async function handleConfirmSign(row: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确认与「${row.counterparty_name || row.warehouse_name || row.remask || row.id}」的签约申请吗?`,
|
||
'确认签约',
|
||
{ type: 'warning', buttonSize: 'small' }
|
||
)
|
||
} catch { return }
|
||
try {
|
||
// 本页为仓库视角(当前仓库在 store_id 方),确认签约走仓库侧接口
|
||
const res = (await storeWarehouseWarehouseConfirmSign({ id: row.id })) as any
|
||
if (res?.flag === 'success' || res?.code === 200 || res?.data?.mode === 'confirm') {
|
||
ElMessage.success('签约已确认')
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '确认签约失败')
|
||
}
|
||
} catch { ElMessage.error('确认签约失败') }
|
||
}
|
||
|
||
async function handleUnbind(row: any, targetStatus: number) {
|
||
const actionLabel = targetStatus === 0 ? '禁用' : '启用'
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确认要${actionLabel}与「${row.counterparty_name || row.warehouse_name || row.remask || row.id}」的签约关系吗?`,
|
||
`${actionLabel}签约`,
|
||
{ type: targetStatus === 0 ? 'warning' : 'info', confirmButtonText: actionLabel, cancelButtonText: '取消', buttonSize: 'small' }
|
||
)
|
||
} catch { return }
|
||
try {
|
||
const res = await storeWarehouseUnbind({ id: row.id, warehouse_use_status: targetStatus }) as any
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
ElMessage.success(`${actionLabel}成功`)
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || `${actionLabel}失败`)
|
||
}
|
||
} catch { ElMessage.error('操作失败') }
|
||
}
|
||
|
||
onMounted(() => {
|
||
loadList()
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use "@/styles/list-page.scss";
|
||
@use "@/styles/status-text.scss";
|
||
|
||
/* 工具栏「当前仓库」标签:与左侧按钮组垂直居中对齐(toolbar-left 默认 align-items:flex-start) */
|
||
.current-subject-tag {
|
||
align-self: center;
|
||
margin-left: 8px;
|
||
}
|
||
|
||
/* 详情区外壳与 storage/entry_owner 一致:不留上/下间距,左右 10px,
|
||
面板自身 padding: 6px 10px 8px(合计内容缩进 20px) */
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
padding: 0 10px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
overflow: auto;
|
||
flex: 1;
|
||
min-height: 0;
|
||
|
||
/* 签约详情:分区标题 + 带边框描述列表(对齐 stock/external_stock「基本信息」新设计) */
|
||
.detail-panel {
|
||
flex: 1;
|
||
min-height: 0;
|
||
padding: 6px 10px 8px;
|
||
box-sizing: border-box;
|
||
overflow: auto;
|
||
|
||
.section {
|
||
margin-bottom: 12px;
|
||
|
||
&:last-child {
|
||
margin-bottom: 0;
|
||
}
|
||
}
|
||
|
||
.section-title {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
margin-bottom: 10px;
|
||
padding-left: 8px;
|
||
border-left: 3px solid #409eff;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.detail-descriptions :deep(.el-descriptions__label) {
|
||
width: 110px;
|
||
background: #fafbfc;
|
||
font-weight: 500;
|
||
}
|
||
}
|
||
}
|
||
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
color: #909399;
|
||
padding: 16px;
|
||
}
|
||
|
||
.real-name {
|
||
color: #999;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.wave-operation-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 4px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.text-muted {
|
||
color: #c0c4cc;
|
||
}
|
||
|
||
.text-danger {
|
||
color: #f56c6c;
|
||
}
|
||
|
||
/* 修改备注弹窗:面板结构 / 尺寸对齐「手工录入运单号」(ManualWaybillForm) */
|
||
.task-panel {
|
||
background: #fff;
|
||
color: #303133;
|
||
|
||
&__head {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 12px;
|
||
padding: 16px;
|
||
}
|
||
|
||
&__titles {
|
||
flex: 1;
|
||
min-width: 0;
|
||
|
||
h2 {
|
||
margin: 0;
|
||
font-size: 18px;
|
||
line-height: 24px;
|
||
font-weight: 400;
|
||
color: #303133;
|
||
}
|
||
|
||
p {
|
||
margin: 4px 0 0;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
}
|
||
}
|
||
|
||
&__close {
|
||
width: 24px;
|
||
height: 24px;
|
||
flex: none;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: none;
|
||
border-radius: 4px;
|
||
background: transparent;
|
||
color: #909399;
|
||
cursor: pointer;
|
||
transition: color 0.2s;
|
||
|
||
svg {
|
||
width: 12px;
|
||
height: 12px;
|
||
}
|
||
|
||
&:hover {
|
||
color: #409eff;
|
||
}
|
||
}
|
||
|
||
&__body {
|
||
padding: 12px 16px 0;
|
||
}
|
||
|
||
&__form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
|
||
&__field {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
min-height: 40px;
|
||
padding: 8px 12px;
|
||
border: 1px solid #ebeef5;
|
||
border-radius: 4px;
|
||
background: #fafafa;
|
||
|
||
/* 输入行:去掉灰色容器,与静态信息行区分 */
|
||
&--input {
|
||
align-items: flex-start;
|
||
min-height: 0;
|
||
/* 右 0 让输入框右边顶到容器右边缘 */
|
||
padding: 4px 0 0 12px;
|
||
border: none;
|
||
border-radius: 0;
|
||
background: transparent;
|
||
|
||
.task-panel__field-label {
|
||
padding-top: 7px;
|
||
|
||
&.is-required::before {
|
||
top: 7px;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 标签列固定宽度:输入框左边缘与上方静态信息行的标签列对齐 */
|
||
&__field-label {
|
||
position: relative;
|
||
flex: 0 0 88px;
|
||
width: 88px;
|
||
padding-left: 10px;
|
||
box-sizing: border-box;
|
||
font-size: 12px;
|
||
line-height: 20px;
|
||
color: #606266;
|
||
text-align: left;
|
||
white-space: nowrap;
|
||
|
||
&.is-required::before {
|
||
content: '*';
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0;
|
||
line-height: 20px;
|
||
color: #f56c6c;
|
||
}
|
||
}
|
||
|
||
&__field-value {
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
color: #303133;
|
||
text-align: right;
|
||
word-break: break-all;
|
||
}
|
||
|
||
&__field-control {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
&__form-tip {
|
||
margin: 8px 0 0;
|
||
padding: 8px 12px;
|
||
border-radius: 4px;
|
||
background: #f4f4f5;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
}
|
||
|
||
&__foot {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
padding: 16px;
|
||
}
|
||
|
||
&__hint {
|
||
font-size: 12px;
|
||
color: #909399;
|
||
}
|
||
|
||
&__actions {
|
||
display: flex;
|
||
align-items: center;
|
||
/* 与工具栏按钮组(OrderToolbarButtonGroup)保持一致:gap 6px */
|
||
gap: 6px;
|
||
|
||
:deep(.el-button) {
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
}
|
||
}
|
||
}
|
||
</style>
|
||
|
||
<style lang="scss">
|
||
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
|
||
.el-dialog.rename-sign-row-dialog {
|
||
padding: 0;
|
||
overflow: hidden;
|
||
|
||
.el-dialog__header {
|
||
display: none;
|
||
}
|
||
|
||
.el-dialog__body {
|
||
padding: 0;
|
||
}
|
||
}
|
||
</style>
|