- 新增 TaskProgressFloatWidget;TaskProgressDialog 增加 minimizable 与 minimize 事件,运行中可「收起后台」,浮窗继续轮询并支持点击还原窗口, 运单页「更新揽收状态」已接入 - UpperTable 新增 #pagination-info 插槽(支持「已选 N 项」等精简文案), 运单号列对齐方式透传给 WaybillCodeActions - 盘点、入库、出库、收货、波次、订单明细、库存详情、仓库与店铺等 20+ 处 日志/明细列表由 el-table 迁移至 UpperTable,统一分页、行选择、 虚拟滚动、状态文本样式与列插槽 - 拆包录像列表、出库单详情表单、运单称重弹窗等按 task-panel 结构统一; 运单轨迹浮层支持拖动并复用 task-panel 标题与关闭样式 - 补充相关样式,修正内嵌表格高度与分页区布局,避免卡片阴影与高度塌陷
3933 lines
134 KiB
Vue
3933 lines
134 KiB
Vue
<template>
|
||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||
<scan-box
|
||
ref="scanBox"
|
||
cache-key="store-stores"
|
||
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"
|
||
/>
|
||
</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="store-stores-list"
|
||
:data="list"
|
||
:columns="columns"
|
||
:table-size="tableSize"
|
||
:loading="loading"
|
||
:pagination="pagination"
|
||
: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.store_name || row.remask || row.counterparty_name }}</span>
|
||
<span
|
||
v-if="(row.store_name || row.remask) && row.counterparty_name && (row.store_name || row.remask) !== row.counterparty_name"
|
||
class="real-name"
|
||
>({{ row.counterparty_name }})</span>
|
||
</template>
|
||
<template #column-current_subject_role="{ row }">
|
||
<span :class="getStatusTextClass(row.current_subject_role === 'warehouse' ? 'primary' : 'warning')">
|
||
{{ row.current_subject_role === 'warehouse' ? '仓库方' : '货主方' }}
|
||
</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.auth_status === 1" :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-is_auth_valid="{ row }">
|
||
<span :class="getStatusTextClass(row.is_auth_valid ? 'success' : 'warning')">
|
||
{{ row.is_auth_valid ? '有效' : '无效' }}
|
||
</span>
|
||
</template>
|
||
<template #column-print_quantity="{ row }">
|
||
<span v-if="balanceVisible">{{ row.print_quantity ?? 0 }}</span>
|
||
<span v-else>***</span>
|
||
</template>
|
||
<template #column-remaining_days="{ row }">
|
||
<span :class="row.remaining_days <= 7 && row.remaining_days > 0 ? 'text-warning' : ''">
|
||
{{ row.remaining_days > 0 ? row.remaining_days + '天' : '—' }}
|
||
</span>
|
||
</template>
|
||
<template #column-has_qimen_config="{ row }">
|
||
<span
|
||
:class="getStatusTextClass(row.has_qimen_config ? 'success' : 'info')"
|
||
@click.stop="openQimenDialog(row)"
|
||
style="cursor:pointer"
|
||
>
|
||
{{ row.has_qimen_config ? '已配置' : '未配置' }}
|
||
</span>
|
||
</template>
|
||
<template #column-actions="{ row }">
|
||
<div class="wave-operation-actions">
|
||
<el-button
|
||
v-if="row.auth_status === 1"
|
||
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
|
||
size="small"
|
||
type="warning"
|
||
link
|
||
@click.stop="openAdjustBalanceDialog(row)"
|
||
>调整余额</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
link
|
||
@click.stop="openCreateUserDialog(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>
|
||
<el-button
|
||
size="small"
|
||
type="info"
|
||
link
|
||
@click.stop="openPolicyDialog(row)"
|
||
>策略配置</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="success"
|
||
link
|
||
@click.stop="handleGenerateBindCode(row)"
|
||
>加群授权</el-button>
|
||
<el-button
|
||
v-if="row.current_subject_role === 'warehouse'"
|
||
size="small"
|
||
type="warning"
|
||
link
|
||
@click.stop="openQimenDialog(row)"
|
||
>接口配置</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-tab-pane label="余额变动" name="balanceLogs" />
|
||
<el-tab-pane label="操作日志" name="logs" />
|
||
</el-tabs>
|
||
</div>
|
||
|
||
<div class="detail-container">
|
||
<div v-if="activeTab === 'balanceLogs'" class="balance-log-panel store-detail-pane">
|
||
<div class="header-actions">
|
||
<div class="left-actions">
|
||
<el-button size="small" type="primary" :loading="balanceLogLoading" @click="loadBalanceLogs">刷新</el-button>
|
||
<el-select
|
||
v-model="balanceLogFilter"
|
||
size="small"
|
||
placeholder="流水类型"
|
||
clearable
|
||
@change="handleBalanceLogFilterChange"
|
||
>
|
||
<el-option label="充值" value="recharge" />
|
||
<el-option label="消费" value="consumption" />
|
||
</el-select>
|
||
<el-date-picker
|
||
v-model="balanceLogDateRange"
|
||
type="datetimerange"
|
||
size="small"
|
||
range-separator="至"
|
||
start-placeholder="开始时间"
|
||
end-placeholder="结束时间"
|
||
value-format="YYYY-MM-DD HH:mm:ss"
|
||
@change="handleBalanceLogFilterChange"
|
||
/>
|
||
<el-button
|
||
v-if="hasPermission('storeWarehouse.store.exportPrintQuantityLogs')"
|
||
size="small"
|
||
type="primary"
|
||
plain
|
||
:loading="exportLoading"
|
||
@click="handleExportBalanceLogs"
|
||
>导出</el-button>
|
||
</div>
|
||
</div>
|
||
<div ref="balanceLogTableHostRef" class="table-host">
|
||
<upper-table
|
||
ref="balanceLogTableRef"
|
||
table-id="store-balance-logs"
|
||
:data="balanceLogList"
|
||
:columns="balanceLogColumns"
|
||
:show-selection="true"
|
||
table-size="small"
|
||
:loading="balanceLogLoading"
|
||
:virtual-threshold="100000"
|
||
:pagination="balanceLogPagination"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
@page-change="handleBalanceLogPageChange"
|
||
@page-size-change="handleBalanceLogSizeChange"
|
||
>
|
||
<!-- 已选数量放左下角(UpperTable 分页区左侧) -->
|
||
<template #pagination-info="{ count }">已选 {{ count }} 项</template>
|
||
|
||
<template #column-created_at="{ row }">
|
||
{{ formatDate(getBalanceLogTime(row)) || '—' }}
|
||
</template>
|
||
<template #column-before_quantity="{ row }">
|
||
{{ getBalanceLogBefore(row) ?? '—' }}
|
||
</template>
|
||
<template #column-after_quantity="{ row }">
|
||
{{ getBalanceLogAfter(row) ?? '—' }}
|
||
</template>
|
||
<template #column-delta="{ row }">
|
||
<span :class="getBalanceLogDeltaClass(getBalanceLogDelta(row))">{{ formatBalanceLogDelta(getBalanceLogDelta(row)) }}</span>
|
||
</template>
|
||
<template #column-change_type_label="{ row }">
|
||
{{ row.change_type_label || getBalanceLogChangeType(row) || '—' }}
|
||
</template>
|
||
<template #column-business_type_label="{ row }">
|
||
{{ row.business_type_label || getBalanceLogBusinessType(row) || '—' }}
|
||
</template>
|
||
<template #column-business_id="{ row }">
|
||
{{ getBalanceLogBusinessId(row) ?? '—' }}
|
||
</template>
|
||
<template #column-operator="{ row }">
|
||
{{ getBalanceLogOperator(row) || '—' }}
|
||
</template>
|
||
<template #column-reason="{ row }">
|
||
{{ getBalanceLogReason(row) || '—' }}
|
||
</template>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">暂无余额变动记录</div>
|
||
</template>
|
||
</upper-table>
|
||
</div>
|
||
</div>
|
||
<KeepAlive v-else>
|
||
<component
|
||
:is="activeComponent"
|
||
class="store-detail-pane"
|
||
:id="selectedRow?.id"
|
||
:row="selectedRow"
|
||
:getAuthStatusType="getAuthStatusType"
|
||
:getAuthStatusLabel="getAuthStatusLabel"
|
||
:formatDate="formatDate"
|
||
/>
|
||
</KeepAlive>
|
||
</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-store-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?.store_name || 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>
|
||
|
||
<el-form
|
||
ref="renameFormRef"
|
||
:model="renameForm"
|
||
:rules="renameRules"
|
||
class="task-panel__form-fields"
|
||
@submit.prevent
|
||
>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">备注名称</span>
|
||
<el-form-item prop="remask">
|
||
<el-input
|
||
v-model="renameForm.remask"
|
||
size="default"
|
||
placeholder="留空则使用货主默认名称"
|
||
clearable
|
||
maxlength="50"
|
||
show-word-limit
|
||
@keyup.enter="handleRenameSubmit"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</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="policyDialog.visible"
|
||
class="policy-config-dialog"
|
||
width="min(880px, 96vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
:close-on-click-modal="false"
|
||
@close="resetPolicyDialog"
|
||
>
|
||
<div class="task-panel task-panel--policy">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>策略配置</h2>
|
||
<p>货主:{{ policyDialog.contractRow?.store_name || policyDialog.contractRow?.remask || policyDialog.contractRow?.counterparty_name || '—' }}</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="policyDialog.visible = 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 v-loading="policyDialog.loading" class="task-panel__body task-panel__body--scroll">
|
||
<el-form :model="policyDialog.formData" class="task-panel__form" @submit.prevent>
|
||
<!-- 签约信息 -->
|
||
<div class="task-panel__grid">
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">货主</span>
|
||
<strong class="task-panel__field-value">
|
||
{{ policyDialog.contractRow?.store_name || policyDialog.contractRow?.counterparty_name || '—' }}
|
||
</strong>
|
||
</div>
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">面单余额</span>
|
||
<strong
|
||
class="task-panel__field-value"
|
||
:class="{ 'is-danger': (policyDialog.contractRow?.print_quantity ?? 0) <= 0 }"
|
||
>
|
||
{{ policyDialog.contractRow?.print_quantity ?? '—' }}
|
||
</strong>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 结构化策略配置表单 -->
|
||
<div v-if="policyDialog.fields.length > 0" class="task-panel__grid">
|
||
<div
|
||
v-for="field in policyDialog.fields"
|
||
:key="field.key"
|
||
class="task-panel__field"
|
||
:class="field.type === 'flag' || field.type === 'integer' ? 'task-panel__field--control' : 'task-panel__field--input'"
|
||
>
|
||
<span class="task-panel__field-label">
|
||
{{ field.name }}
|
||
<el-tooltip v-if="field.description" :content="field.description" placement="top">
|
||
<el-icon class="task-panel__field-help"><QuestionFilled /></el-icon>
|
||
</el-tooltip>
|
||
</span>
|
||
<div
|
||
class="task-panel__field-form"
|
||
:class="{ 'task-panel__field-form--row': field.type === 'flag' || field.type === 'integer' }"
|
||
>
|
||
<!-- 快递类字段(默认快递 / 出库单默认快递等):使用快递接口列表 -->
|
||
<el-select
|
||
v-if="isExpressSelectField(field)"
|
||
v-model="policyDialog.formData[field.key]"
|
||
size="default"
|
||
clearable
|
||
filterable
|
||
:placeholder="field.placeholder || '请选择默认快递'"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in policyExpressOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
<!-- 默认平台:使用平台列表 -->
|
||
<el-select
|
||
v-else-if="field.key === 'default_platform_code'"
|
||
v-model="policyDialog.formData[field.key]"
|
||
size="default"
|
||
clearable
|
||
filterable
|
||
placeholder="请选择默认平台"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in policyPlatformOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
<!-- enum 类型 -->
|
||
<el-select
|
||
v-else-if="field.type === 'enum'"
|
||
v-model="policyDialog.formData[field.key]"
|
||
size="default"
|
||
clearable
|
||
style="width: 100%"
|
||
>
|
||
<template v-if="field.key === 'receive_mode'">
|
||
<el-option label="标准模式" value="standard" />
|
||
<el-option label="严格模式" value="strict" />
|
||
<el-option label="手动模式" value="manual" />
|
||
</template>
|
||
<template v-else-if="field.key === 'sku_visibility'">
|
||
<el-option label="全部可见" value="all" />
|
||
<el-option label="白名单" value="whitelist" />
|
||
<el-option label="黑名单" value="blacklist" />
|
||
</template>
|
||
<el-option
|
||
v-for="opt in field.options"
|
||
v-else
|
||
:key="getEnumOptionValue(opt)"
|
||
:label="getEnumOptionLabel(opt)"
|
||
:value="getEnumOptionValue(opt)"
|
||
/>
|
||
</el-select>
|
||
<!-- flag 类型 -->
|
||
<el-switch
|
||
v-else-if="field.type === 'flag'"
|
||
v-model="policyDialog.formData[field.key]"
|
||
:active-value="1"
|
||
:inactive-value="0"
|
||
active-text="是"
|
||
inactive-text="否"
|
||
/>
|
||
<!-- integer 类型(支持可选小数精度) -->
|
||
<el-input-number
|
||
v-else-if="field.type === 'integer'"
|
||
v-model="policyDialog.formData[field.key]"
|
||
:min="field.min ?? 0"
|
||
:max="field.max ?? 1000000"
|
||
:precision="field.precision ?? 0"
|
||
:step="field.step ?? (field.precision ? 0.01 : 1)"
|
||
controls-position="right"
|
||
style="width: 100%"
|
||
/>
|
||
<!-- string / 其他类型 -->
|
||
<el-input
|
||
v-else
|
||
v-model="policyDialog.formData[field.key]"
|
||
size="default"
|
||
:maxlength="field.maxLength"
|
||
show-word-limit
|
||
:placeholder="field.placeholder || field.description || '请输入'"
|
||
style="width: 100%"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 降级:字段元信息加载失败时显示 JSON 编辑器 -->
|
||
<div v-else class="task-panel__field task-panel__field--input task-panel__field--textarea task-panel__field--full">
|
||
<span class="task-panel__field-label">
|
||
JSON
|
||
<el-tooltip content="后端 policy_config 为自由结构 object,直接编辑 JSON 提交" placement="top">
|
||
<el-icon class="task-panel__field-help"><QuestionFilled /></el-icon>
|
||
</el-tooltip>
|
||
</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="policyDialog.jsonText"
|
||
type="textarea"
|
||
:rows="10"
|
||
resize="none"
|
||
placeholder='暂无策略配置,输入 JSON 对象后保存,例如:{"key": "value"}'
|
||
:class="{ 'is-error-textarea': policyDialog.jsonError }"
|
||
spellcheck="false"
|
||
style="font-family: monospace; font-size: 13px"
|
||
@blur="validatePolicyJson"
|
||
/>
|
||
<div v-if="policyDialog.jsonError" class="task-panel__field-error">{{ policyDialog.jsonError }}</div>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
|
||
<p class="task-panel__form-tip">
|
||
{{ policyDialog.fields.length > 0
|
||
? '字段留空表示使用系统默认;修改后对该货主后续单据生效。'
|
||
: '留空保存将清除策略配置;必须是合法的 JSON 对象 {}。' }}
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">提交前请确认默认快递与收货策略</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="policyDialog.visible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="policyDialog.saving" @click="submitPolicyConfig">保存策略</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 奇门接口配置管理弹窗 -->
|
||
<el-dialog
|
||
v-model="qimenDialog.visible"
|
||
:title="`接口配置管理 — ${qimenDialog.contractRow?.store_name || qimenDialog.contractRow?.remask || qimenDialog.contractRow?.counterparty_name || ''}`"
|
||
width="80%"
|
||
align-center
|
||
:close-on-click-modal="false"
|
||
@close="resetQimenDialog"
|
||
>
|
||
<div>
|
||
<div style="display:flex;justify-content:flex-end;margin-bottom:10px">
|
||
<el-button size="small" type="primary" @click="openQimenForm(null)">
|
||
<el-icon><Plus /></el-icon> 新增配置
|
||
</el-button>
|
||
<el-button size="small" @click="loadQimenConfigs" style="margin-left:8px">
|
||
<el-icon><Refresh /></el-icon> 刷新
|
||
</el-button>
|
||
</div>
|
||
<el-table :data="qimenDialog.list" v-loading="qimenDialog.loading" size="small" border>
|
||
<el-table-column
|
||
v-for="col in qimenTableColumns.filter(c => !['self_app_key', 'qimen_customer_id', 'qimen_warehouse_code', 'callback_url'].includes(c.prop))"
|
||
:key="col.prop"
|
||
:prop="col.prop"
|
||
:label="col.label"
|
||
:min-width="col.minWidth"
|
||
:width="col.width"
|
||
align="center"
|
||
/>
|
||
<el-table-column label="货主编码" min-width="150" align="center">
|
||
<template #default="{ row }">
|
||
<div class="appkey-cell">
|
||
<span class="appkey-text">{{ row.qimen_customer_id || '—' }}</span>
|
||
<el-button
|
||
v-if="row.qimen_customer_id"
|
||
size="small"
|
||
type="primary"
|
||
link
|
||
@click="copyText(row.qimen_customer_id)"
|
||
>
|
||
复制
|
||
</el-button>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="qimen_warehouse_code" label="仓库编码" width="110" align="center" />
|
||
<el-table-column prop="callback_url" label="回调地址" min-width="200" align="center" />
|
||
<el-table-column prop="self_app_key" label="APPKEY" min-width="200" align="center">
|
||
<template #default="{ row }">
|
||
<div class="appkey-cell">
|
||
<span class="appkey-text">{{ row.self_app_key || '—' }}</span>
|
||
<el-button
|
||
v-if="row.self_app_key"
|
||
size="small"
|
||
type="primary"
|
||
link
|
||
@click="copyText(row.self_app_key)"
|
||
>
|
||
复制
|
||
</el-button>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="APPSECRET" min-width="130" align="center">
|
||
<template #default="{ row }">
|
||
<div class="appsecret-cell">
|
||
<template v-if="visibleSecrets[row.id || row.interface_type_id]">
|
||
<span class="appsecret-text">{{ row.self_app_secret || '—' }}</span>
|
||
<el-button
|
||
v-if="row.self_app_secret"
|
||
size="small"
|
||
type="primary"
|
||
link
|
||
@click="copyText(row.self_app_secret)"
|
||
>
|
||
复制
|
||
</el-button>
|
||
</template>
|
||
<el-button
|
||
v-else-if="row.self_app_secret"
|
||
size="small"
|
||
type="warning"
|
||
link
|
||
@click="toggleSecret(row)"
|
||
>
|
||
显示
|
||
</el-button>
|
||
<span v-else>—</span>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="状态" width="70" align="center">
|
||
<template #default="{ row }">
|
||
<span :class="getStatusTextClass(row.is_enabled ? 'success' : 'info')">
|
||
{{ row.is_enabled ? '启用' : '停用' }}
|
||
</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button size="small" type="primary" link @click="openQimenForm(row)">编辑</el-button>
|
||
<el-button
|
||
v-if="row.interface_code === 'QM_WMS'"
|
||
size="small"
|
||
type="success"
|
||
link
|
||
@click="copyQmWmsConfig(row)"
|
||
>复制配置</el-button>
|
||
<el-button
|
||
v-if="row.interface_code === 'OPEN_API'"
|
||
size="small"
|
||
type="success"
|
||
link
|
||
@click="copyOpenApiConfig(row)"
|
||
>复制配置</el-button>
|
||
<el-button size="small" type="danger" link @click="handleDeleteQimenConfig(row)">删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
<template #empty>
|
||
<el-empty description="暂无奇门配置" :image-size="50" />
|
||
</template>
|
||
</el-table>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<el-button size="small" @click="qimenDialog.visible = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 新增 / 编辑接口配置:独立表单(面板结构对齐「手工录入运单号」) -->
|
||
<el-dialog
|
||
v-model="qimenDialog.formVisible"
|
||
class="qimen-config-dialog"
|
||
width="min(720px, 94vw)"
|
||
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>{{ qimenDialog.editingConfig ? '编辑配置' : '新增配置' }}</h2>
|
||
<p>
|
||
{{ qimenDialog.contractRow?.store_name || qimenDialog.contractRow?.remask || qimenDialog.contractRow?.counterparty_name || '当前签约货主' }}
|
||
· 维护接口对接参数
|
||
</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="qimenDialog.formVisible = 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">
|
||
<el-form :model="qimenForm" class="task-panel__form-fields" @submit.prevent>
|
||
<!-- 接口类型 -->
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">接口类型</span>
|
||
<el-form-item>
|
||
<el-select
|
||
v-if="qimenDialog.editingConfig"
|
||
:model-value="qimenForm.interface_code"
|
||
disabled
|
||
style="width:100%"
|
||
>
|
||
<el-option
|
||
v-for="t in qimenDialog.availableTypes"
|
||
:key="t.interface_code"
|
||
:label="`${t.interface_name}(${t.interface_code})`"
|
||
:value="t.interface_code"
|
||
/>
|
||
<el-option
|
||
v-if="qimenForm.interface_code && !qimenDialog.availableTypes.some(t => t.interface_code === qimenForm.interface_code)"
|
||
:label="`${qimenDialog.editingConfig?.interface_name || qimenForm.interface_code}(${qimenForm.interface_code})`"
|
||
:value="qimenForm.interface_code"
|
||
/>
|
||
</el-select>
|
||
<el-select
|
||
v-else
|
||
v-model="qimenForm.interface_code"
|
||
placeholder="请选择接口类型"
|
||
style="width:100%"
|
||
@change="handleInterfaceTypeChange"
|
||
>
|
||
<el-option
|
||
v-for="t in selectableTypes"
|
||
:key="t.interface_code"
|
||
:label="`${t.interface_name}(${t.interface_code})`"
|
||
:value="t.interface_code"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<!-- 类型标识(自动生成,只读展示) -->
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">类型标识</span>
|
||
<strong
|
||
class="task-panel__field-value"
|
||
:class="{ 'is-muted': !qimenForm.interface_code }"
|
||
>
|
||
{{ qimenForm.interface_code || '选择接口类型后自动显示' }}
|
||
</strong>
|
||
</div>
|
||
|
||
<!-- 应用名称 -->
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">应用名称</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.app_name" placeholder="请输入应用名称(必填)" />
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<!-- QM_WMS 专属字段 -->
|
||
<template v-if="isQmWmsFormType">
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">ERP</span>
|
||
<el-form-item>
|
||
<el-select
|
||
v-model="qimenForm.qimen_app_key"
|
||
filterable
|
||
clearable
|
||
placeholder="请选择ERP"
|
||
style="width:100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in qimenAppOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">货主编码</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.qimen_customer_id" placeholder="奇门货主编码(必填)">
|
||
<template #append>
|
||
<el-button @click="generateQimenCustomerCode">随机生成</el-button>
|
||
</template>
|
||
</el-input>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">仓库编码</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.qimen_warehouse_code" placeholder="奇门仓库编码">
|
||
<template #append>
|
||
<el-button @click="generateQimenWarehouseCode">随机生成</el-button>
|
||
</template>
|
||
</el-input>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">API 版本</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.api_version" placeholder="默认 1.0" />
|
||
</el-form-item>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- OPEN_API:回调地址 -->
|
||
<template v-else-if="qimenForm.interface_code === 'OPEN_API'">
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">回调地址</span>
|
||
<el-form-item>
|
||
<div class="callback-url-row">
|
||
<el-input
|
||
v-model="qimenForm.callback_url"
|
||
placeholder="API 回调通知 URL(可选),订单状态变更时将推送至此地址"
|
||
maxlength="500"
|
||
show-word-limit
|
||
style="flex:1"
|
||
/>
|
||
<el-button size="small" type="primary" link @click="openCallbackDoc">
|
||
<el-icon><Link /></el-icon> 调试文档
|
||
</el-button>
|
||
</div>
|
||
</el-form-item>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- 其他类型或未选类型时的兼容字段 -->
|
||
<template v-else-if="!qimenForm.interface_code && qimenDialog.editingConfig">
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">ERP</span>
|
||
<el-form-item>
|
||
<el-select
|
||
v-model="qimenForm.qimen_app_key"
|
||
filterable
|
||
clearable
|
||
placeholder="请选择ERP(如适用)"
|
||
style="width:100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in qimenAppOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">货主编码</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.qimen_customer_id" placeholder="奇门货主编码(如适用)">
|
||
<template #append>
|
||
<el-button @click="generateQimenCustomerCode">随机生成</el-button>
|
||
</template>
|
||
</el-input>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">仓库编码</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.qimen_warehouse_code" placeholder="奇门仓库编码(如适用)" />
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">API 版本</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.api_version" placeholder="默认 1.0" />
|
||
</el-form-item>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- 联系信息 -->
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">联系人</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.contact_person" placeholder="可选" />
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">联系电话</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.contact_phone" placeholder="可选" />
|
||
</el-form-item>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">邮箱</span>
|
||
<el-form-item>
|
||
<el-input v-model="qimenForm.email" placeholder="可选" />
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<!-- 启用状态 -->
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">是否启用</span>
|
||
<el-form-item>
|
||
<el-switch
|
||
v-model="qimenForm.is_enabled"
|
||
:active-value="1"
|
||
:inactive-value="0"
|
||
active-text="启用"
|
||
inactive-text="停用"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
|
||
<p class="task-panel__form-tip">
|
||
保存后立即生效;启用状态将影响该签约货主的接口调用。
|
||
</p>
|
||
<p v-if="qimenForm.interface_code === 'OPEN_API'" class="task-panel__form-tip">
|
||
OPEN_API 类型无需填写奇门字段,系统将自动生成 AppKey 与 AppSecret。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">提交前请确认接口类型与对接参数</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="qimenDialog.formVisible = false">取消</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
:loading="qimenDialog.formLoading"
|
||
@click="submitQimenForm"
|
||
>
|
||
{{ qimenDialog.editingConfig ? '保存修改' : '确认新增' }}
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 面单余额设置弹窗(面板结构 / 尺寸对齐「手工录入运单号」ManualWaybillForm) -->
|
||
<el-dialog
|
||
v-model="adjustBalanceDialog.visible"
|
||
class="adjust-balance-dialog"
|
||
width="min(560px, 92vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
@close="resetAdjustBalanceDialog"
|
||
>
|
||
<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="adjustBalanceDialog.visible = 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 v-loading="adjustBalanceDialog.fetchLoading" 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">
|
||
{{ adjustBalanceDialog.contractRow?.store_name || adjustBalanceDialog.contractRow?.remask || adjustBalanceDialog.contractRow?.counterparty_name || '—' }}
|
||
</strong>
|
||
</div>
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">当前面单余额</span>
|
||
<strong class="task-panel__field-value">
|
||
{{ formatAdjustBalanceDisplayQty(adjustBalanceForm.current_print_quantity) }}
|
||
</strong>
|
||
</div>
|
||
|
||
<el-form
|
||
ref="adjustBalanceFormRef"
|
||
:model="adjustBalanceForm"
|
||
:rules="adjustBalanceRules"
|
||
class="task-panel__form-fields"
|
||
@submit.prevent
|
||
>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">目标余额</span>
|
||
<el-form-item prop="target_quantity">
|
||
<div class="adjust-balance-number-field">
|
||
<el-input-number
|
||
v-model="adjustBalanceForm.target_quantity"
|
||
placeholder="请输入目标面单余额(将覆盖当前余额)"
|
||
:style="{ width: '100%' }"
|
||
controls-position="right"
|
||
/>
|
||
<div
|
||
v-if="adjustBalanceDeltaHint.text"
|
||
class="adjust-balance-delta-hint"
|
||
:class="`is-${adjustBalanceDeltaHint.kind}`"
|
||
>
|
||
{{ adjustBalanceDeltaHint.text }}
|
||
</div>
|
||
</div>
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">调整原因</span>
|
||
<el-form-item prop="reason">
|
||
<el-input
|
||
v-model="adjustBalanceForm.reason"
|
||
type="textarea"
|
||
:rows="3"
|
||
resize="none"
|
||
maxlength="500"
|
||
show-word-limit
|
||
placeholder="请输入人工调整缘由(必填)"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</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="adjustBalanceDialog.visible = false">取消</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
:loading="adjustBalanceDialog.loading"
|
||
:disabled="adjustBalanceDialog.fetchLoading"
|
||
@click="submitAdjustBalance"
|
||
>
|
||
确认设置
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 代开户弹窗:面板结构 / 双列栅格对齐「新建波次策略」 -->
|
||
<el-dialog
|
||
v-model="openAccountDialog.visible"
|
||
class="open-account-dialog"
|
||
width="min(880px, 96vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
:close-on-click-modal="false"
|
||
@close="resetOpenAccountDialog"
|
||
>
|
||
<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="openAccountDialog.visible = 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 task-panel__body--scroll">
|
||
<el-form
|
||
ref="openAccountFormRef"
|
||
:model="openAccountForm"
|
||
:rules="openAccountFormRules"
|
||
class="task-panel__form"
|
||
@submit.prevent
|
||
>
|
||
<!-- 登录账号:整行(含随机生成按钮) -->
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--full">
|
||
<span class="task-panel__field-label is-required">登录账号</span>
|
||
<div class="task-panel__field-form">
|
||
<el-form-item prop="username">
|
||
<div class="task-panel__inline">
|
||
<el-input
|
||
v-model="openAccountForm.username"
|
||
size="default"
|
||
placeholder="登录账号(全局唯一)"
|
||
style="flex: 1"
|
||
/>
|
||
<el-button size="small" @click="generateRandomUsername">
|
||
<el-icon><Refresh /></el-icon> 随机生成
|
||
</el-button>
|
||
</div>
|
||
</el-form-item>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__grid">
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">初始密码</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="openAccountForm.password"
|
||
size="default"
|
||
placeholder="留空则自动随机生成 12 位密码"
|
||
show-word-limit
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">真实姓名</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.real_name" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--full">
|
||
<span class="task-panel__field-label is-required">公司全称</span>
|
||
<div class="task-panel__field-form">
|
||
<el-form-item prop="company_name">
|
||
<el-input
|
||
v-model="openAccountForm.company_name"
|
||
size="default"
|
||
placeholder="公司全称(全局唯一,1-200 字符)"
|
||
maxlength="200"
|
||
show-word-limit
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">营业执照号</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.business_license" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">所属行业</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.industry" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">联系人</span>
|
||
<div class="task-panel__field-form">
|
||
<el-form-item prop="contact_person">
|
||
<el-input
|
||
v-model="openAccountForm.contact_person"
|
||
size="default"
|
||
placeholder="联系人姓名(1-50 字符)"
|
||
maxlength="50"
|
||
show-word-limit
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">联系电话</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.contact_phone" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">法人代表</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.legal_person" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">联系邮箱</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.contact_email" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--full">
|
||
<span class="task-panel__field-label">公司地址</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input v-model="openAccountForm.address" size="default" placeholder="可选" show-word-limit />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--control">
|
||
<span class="task-panel__field-label">初始面单余额</span>
|
||
<div class="task-panel__field-form task-panel__field-form--row">
|
||
<el-input-number
|
||
v-model="openAccountForm.print_quantity"
|
||
:min="0"
|
||
:precision="0"
|
||
controls-position="right"
|
||
placeholder="默认 0"
|
||
style="width: 100%"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">授权开始日期</span>
|
||
<div class="task-panel__field-form">
|
||
<el-date-picker
|
||
v-model="openAccountForm.auth_start"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
size="default"
|
||
placeholder="默认当天"
|
||
style="width: 100%"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">授权结束日期</span>
|
||
<div class="task-panel__field-form">
|
||
<el-date-picker
|
||
v-model="openAccountForm.auth_end"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
size="default"
|
||
placeholder="可选"
|
||
style="width: 100%"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">货主备注名</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="openAccountForm.store_remask"
|
||
size="default"
|
||
placeholder="最长 50 字符"
|
||
maxlength="50"
|
||
show-word-limit
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">仓库备注名</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="openAccountForm.warehouse_remask"
|
||
size="default"
|
||
placeholder="最长 50 字符"
|
||
maxlength="50"
|
||
show-word-limit
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--textarea task-panel__field--full">
|
||
<span class="task-panel__field-label">申请原因</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="openAccountForm.apply_reason"
|
||
type="textarea"
|
||
:rows="2"
|
||
resize="none"
|
||
size="default"
|
||
maxlength="2000"
|
||
show-word-limit
|
||
placeholder="默认“仓库代开户”"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
|
||
<p class="task-panel__form-tip">
|
||
初始密码留空将自动生成 12 位随机密码;公司全称全局唯一;授权开始日期默认当天,申请原因默认“仓库代开户”。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">提交前请确认登录账号与公司全称</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="openAccountDialog.visible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="openAccountDialog.loading" @click="submitOpenAccount">
|
||
确认开户
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 创建用户弹窗(面板结构 / 尺寸对齐「手工录入运单号」ManualWaybillForm) -->
|
||
<el-dialog
|
||
v-model="createUserDialog.visible"
|
||
class="create-user-dialog"
|
||
width="min(560px, 92vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
@close="resetCreateUserDialog"
|
||
>
|
||
<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="createUserDialog.visible = 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">{{ createUserForm.store_label || '—' }}</strong>
|
||
</div>
|
||
|
||
<el-form
|
||
ref="createUserFormRef"
|
||
:model="createUserForm"
|
||
:rules="createUserFormRules"
|
||
class="task-panel__form-fields"
|
||
@submit.prevent
|
||
>
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">用户名</span>
|
||
<el-form-item prop="username">
|
||
<el-input
|
||
v-model="createUserForm.username"
|
||
size="default"
|
||
placeholder="3-50位字母/数字/下划线,全局唯一"
|
||
clearable
|
||
maxlength="50"
|
||
show-word-limit
|
||
@keyup.enter="submitCreateUser"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
|
||
<p class="task-panel__form-tip">
|
||
用户名将作为登录账号,需 3-50 位字母、数字或下划线;账号已存在时将直接为该货主授权。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">创建成功后会返回初始密码(仅新建账号)</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="createUserDialog.visible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="createUserDialog.loading" @click="submitCreateUser">
|
||
确认创建
|
||
</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 余额变动导出进度弹窗 -->
|
||
<AsyncExportProgressDialog
|
||
:visible="exportDialogVisible"
|
||
title="导出面单余额变更日志"
|
||
:loading="exportLoading"
|
||
:progress-percent="exportProgressPercent"
|
||
:progress-status="exportProgressStatus"
|
||
:status-label="exportStatusLabel"
|
||
:task-id="exportTaskProgress.taskId"
|
||
:message="exportTaskProgress.message"
|
||
:error="exportTaskProgress.error"
|
||
:meta="exportTaskProgress"
|
||
:update-time="exportTaskProgress.updateTime"
|
||
@update:visible="exportDialogVisible = $event"
|
||
/>
|
||
|
||
<!-- 签约货主列表导出进度(storeWarehouse.store.export + exportTaskProgress) -->
|
||
<AsyncExportProgressDialog
|
||
:visible="listExportDialogVisible"
|
||
title="导出签约货主列表"
|
||
:loading="listExportLoading"
|
||
:progress-percent="listExportProgressPercent"
|
||
:progress-status="listExportProgressStatus"
|
||
:status-label="listExportStatusLabel"
|
||
:task-id="listExportTaskProgress.taskId"
|
||
:message="listExportTaskProgress.message"
|
||
:error="listExportTaskProgress.error"
|
||
:meta="listExportTaskProgress"
|
||
:update-time="listExportTaskProgress.updateTime"
|
||
@update:visible="listExportDialogVisible = $event"
|
||
/>
|
||
|
||
<!-- 生成加群授权码弹窗(面板结构 / 尺寸对齐「手工录入运单号」ManualWaybillForm) -->
|
||
<el-dialog
|
||
v-model="bindCodeDialog.visible"
|
||
class="bind-code-dialog"
|
||
width="min(560px, 92vw)"
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
@close="resetBindCodeDialog"
|
||
>
|
||
<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="bindCodeDialog.visible = 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 v-loading="bindCodeDialog.loading" 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">{{ bindCodeDialog.storeName || '—' }}</strong>
|
||
</div>
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">有效期</span>
|
||
<strong class="task-panel__field-value">5 分钟</strong>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">授权码</span>
|
||
<div class="bind-code-control">
|
||
<div v-if="bindCodeDialog.code" class="bind-code-row">
|
||
<span class="bind-code-value">{{ bindCodeDialog.code }}</span>
|
||
<el-button size="small" type="primary" plain @click="copyBindCode">一键复制</el-button>
|
||
</div>
|
||
<span v-else class="bind-code-placeholder">暂无授权码,请关闭后重试</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="task-panel__form-tip">
|
||
将授权码发送给货主,在群内与机器人对话时发送即可完成加群绑定;授权码 5 分钟内有效。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">复制后请及时发送给货主</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="bindCodeDialog.visible = false">关闭</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, reactive, onMounted, computed, watch, nextTick } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import type { FormInstance, FormRules } from 'element-plus'
|
||
import { Plus, Refresh, QuestionFilled, Link } from '@element-plus/icons-vue'
|
||
import { storeWarehouseList, storeWarehouseUnbind,
|
||
storeWarehouseRename, storeWarehouseGetPolicyConfig, storeWarehouseGetPolicyConfigFields,
|
||
storeWarehouseSavePolicyConfig, saveApiConfig, storeWarehouseDeleteQimenConfig,
|
||
storeWarehouseAdjustPrintQuantity, storeWarehouseQueryPrintQuantityLogs, listApiConfig,
|
||
storeWarehouseOpenAccount, storeWarehouseConfirmSign,
|
||
storeWarehouseExportPrintQuantityLogs,
|
||
storeWarehouseExportPrintQuantityLogsTaskProgress,
|
||
storeWarehouseExport,
|
||
storeWarehouseExportTaskProgress,
|
||
storeWarehouseCreateUser
|
||
} from '@/api/storewarehouse.store/storeWarehouse'
|
||
import { listInterfaceTypes, getExpressList, getPlatformList, getQimenAppList, loadStores } 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 Detail from './component/detail.vue'
|
||
import Log from './component/log.vue'
|
||
import { useSettingsStore } from '@/stores/modules/settings'
|
||
import { useUserStore } from '@/stores/modules/user'
|
||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree, qimenFormDefault, qimenFormItems, qimenTableColumns, adjustBalanceDialogDefault, adjustBalanceFormDefault, adjustBalanceFormItems, openAccountDialogDefault, openAccountFormDefault, createUserDialogDefault, createUserFormDefault, storeToolbarButtons } from './store-config.ts'
|
||
import { inboxBindCode } from '@/api/inbox/inbox'
|
||
|
||
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
||
const settingsStore = useSettingsStore()
|
||
const userStore = useUserStore()
|
||
const hasPermission = (perm: string) => userStore.checkPermission(perm)
|
||
const containerHeight = computed(() => '100%' /* 高度由布局层(.app-router-page 的 flex:1)提供,不再自己算 vh */)
|
||
|
||
const {
|
||
splitStackRef,
|
||
beginSplitDrag,
|
||
lowerPaneStyle,
|
||
upperPaneStyle,
|
||
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
|
||
|
||
const upperPaneFullStyle = computed(() => ({
|
||
flex: '1 1 auto',
|
||
minHeight: '0',
|
||
overflow: 'hidden',
|
||
}))
|
||
|
||
const detailVisible = ref(true)
|
||
|
||
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 balanceLogTableRef = ref<any>(null)
|
||
const balanceLogTableHostRef = ref<HTMLElement | null>(null)
|
||
|
||
/** 切页后把表格滚动位置归零 */
|
||
function resetBalanceLogScroll() {
|
||
nextTick(() => {
|
||
balanceLogTableRef.value?.getTableRef?.()?.setScrollTop?.(0)
|
||
})
|
||
}
|
||
const scanBox = ref<any>(null)
|
||
|
||
const activeTab = ref('balanceLogs')
|
||
const componentMap: Record<string, any> = {
|
||
details: Detail,
|
||
logs: Log
|
||
}
|
||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||
|
||
const balanceLogLoading = ref(false)
|
||
const balanceLogList = ref<any[]>([])
|
||
const balanceLogPagination = reactive({
|
||
currentPage: 1,
|
||
pageSize: 20,
|
||
total: 0
|
||
})
|
||
|
||
/** 余额变动表格列(序号列已移除) */
|
||
const balanceLogColumns = [
|
||
{ prop: 'created_at', label: '变动时间', minWidth: 160, showOverflowTooltip: true },
|
||
{ prop: 'before_quantity', label: '变动前', minWidth: 90, align: 'right' },
|
||
{ prop: 'after_quantity', label: '变动后', minWidth: 90, align: 'right' },
|
||
{ prop: 'delta', label: '变动值', minWidth: 90, align: 'right' },
|
||
{ prop: 'change_type_label', label: '变动类型', minWidth: 120 },
|
||
{ prop: 'business_type_label', label: '业务类型', minWidth: 120 },
|
||
{ prop: 'business_id', label: '业务ID', minWidth: 100, align: 'right' },
|
||
{ prop: 'operator', label: '操作人', minWidth: 120 },
|
||
{ prop: 'reason', label: '原因', minWidth: 220, showOverflowTooltip: true }
|
||
]
|
||
|
||
/** 余额变动筛选:''=无, 'recharge'=充值(增加), 'consumption'=消费(减少) */
|
||
const balanceLogFilter = ref('')
|
||
|
||
/** 余额变动时间范围筛选 */
|
||
const balanceLogDateRange = ref<string[] | null>(null)
|
||
|
||
function handleBalanceLogFilterChange() {
|
||
balanceLogPagination.currentPage = 1
|
||
void loadBalanceLogs()
|
||
}
|
||
|
||
// ─── 余额变动导出 ────────────────────────────────────────────────────────────
|
||
function buildBalanceLogExportPayload() {
|
||
const storeId = selectedStoreId.value
|
||
if (storeId === undefined || storeId === null) return null
|
||
const whereFilter: Record<string, any> = {}
|
||
if (balanceLogFilter.value === 'recharge') {
|
||
whereFilter.change_quantity = { operator: 'gt', value: 0 }
|
||
} else if (balanceLogFilter.value === 'consumption') {
|
||
whereFilter.change_quantity = { operator: 'lt', value: 0 }
|
||
}
|
||
if (balanceLogDateRange.value && balanceLogDateRange.value.length === 2) {
|
||
whereFilter.created_at = {
|
||
operator: 'between',
|
||
value: balanceLogDateRange.value
|
||
}
|
||
}
|
||
const payload: Record<string, any> = { store_id: storeId }
|
||
if (Object.keys(whereFilter).length > 0) {
|
||
payload.where = whereFilter
|
||
}
|
||
return payload
|
||
}
|
||
|
||
const {
|
||
exportLoading,
|
||
exportDialogVisible,
|
||
exportTaskProgress,
|
||
exportProgressPercent,
|
||
exportProgressStatus,
|
||
exportStatusLabel,
|
||
submitExportTaskWithMode
|
||
} = useAsyncExportTask({
|
||
storageKey: 'store:stores:balanceLogExportTaskId',
|
||
submitExport: (payload) => storeWarehouseExportPrintQuantityLogs(payload as any),
|
||
queryProgress: (params) => storeWarehouseExportPrintQuantityLogsTaskProgress(params as any)
|
||
})
|
||
|
||
async function handleExportBalanceLogs() {
|
||
const payload = buildBalanceLogExportPayload()
|
||
if (!payload) {
|
||
ElMessage.warning('请先选择一个货主')
|
||
return
|
||
}
|
||
await submitExportTaskWithMode(payload, undefined)
|
||
}
|
||
|
||
const selectedStoreId = computed<number | string | undefined>(() => {
|
||
return resolveStoreIdFromRow(selectedRow.value)
|
||
})
|
||
|
||
watch(
|
||
() => activeTab.value,
|
||
(tab) => {
|
||
if (tab !== 'balanceLogs') return
|
||
balanceLogPagination.currentPage = 1
|
||
void loadBalanceLogs()
|
||
}
|
||
)
|
||
|
||
watch(
|
||
() => selectedRow.value?.id,
|
||
() => {
|
||
if (activeTab.value !== 'balanceLogs') return
|
||
balanceLogPagination.currentPage = 1
|
||
void loadBalanceLogs()
|
||
}
|
||
)
|
||
|
||
// 全局控制所有行的面单余额显示/隐藏
|
||
const balanceVisible = ref(false)
|
||
const toggleBalance = () => {
|
||
balanceVisible.value = !balanceVisible.value
|
||
}
|
||
|
||
function toggleDetailVisible() {
|
||
detailVisible.value = !detailVisible.value
|
||
}
|
||
|
||
const toolbarButtons = storeToolbarButtons
|
||
|
||
const buttonLoadingMap = computed(() => ({
|
||
loading: loading.value,
|
||
listExportLoading: listExportLoading.value
|
||
}))
|
||
|
||
const buttonDisabledMap = computed(() => ({}))
|
||
|
||
const buttonLabelMap = computed(() => ({
|
||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情',
|
||
balanceToggleLabel: balanceVisible.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
|
||
}
|
||
|
||
const toolbarActionMap: Record<string, () => void> = {
|
||
loadList: () => {
|
||
void loadList()
|
||
},
|
||
openOpenAccountDialog: () => openOpenAccountDialog(),
|
||
handleExportSelected: () => { void handleExportSelected() },
|
||
handleExportAll: () => { void handleExportAll() },
|
||
toggleBalance: () => toggleBalance(),
|
||
toggleDetailVisible: () => toggleDetailVisible()
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
|
||
const columns = ref(defaultColumns)
|
||
const availableFields = reactive(defaultAvailableFields)
|
||
const presetTree = ref<any[]>(defaultPresetTree)
|
||
|
||
const currentCondition = ref<any>({ use_status: 1 })
|
||
|
||
// ─── 签约货主列表导出(storeWarehouse.store.export + exportTaskProgress) ──
|
||
// 下拉选项:导出选中(按勾选签约ID导出)/ 导出全部(按当前筛选条件全量导出)
|
||
const {
|
||
exportLoading: listExportLoading,
|
||
exportDialogVisible: listExportDialogVisible,
|
||
exportTaskProgress: listExportTaskProgress,
|
||
exportProgressPercent: listExportProgressPercent,
|
||
exportProgressStatus: listExportProgressStatus,
|
||
exportStatusLabel: listExportStatusLabel,
|
||
submitExportTask: listExportSubmit,
|
||
resumeExportTaskFromStorage: listExportResume,
|
||
hasPendingExportTask: listExportHasPending
|
||
} = useAsyncExportTask({
|
||
storageKey: 'store:stores:listExportTaskId',
|
||
submitExport: (payload) => storeWarehouseExport(payload as any),
|
||
queryProgress: (params) => storeWarehouseExportTaskProgress(params as any)
|
||
})
|
||
|
||
async function handleExportSelected() {
|
||
if (!selectionRows.value.length) {
|
||
ElMessage.warning('请先勾选要导出的货主')
|
||
return
|
||
}
|
||
if (listExportHasPending()) {
|
||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||
listExportResume()
|
||
return
|
||
}
|
||
const ids = selectionRows.value
|
||
.map((row: any) => Number(row?.id))
|
||
.filter((id: number) => Number.isFinite(id) && id > 0)
|
||
if (!ids.length) {
|
||
ElMessage.warning('选中的记录无有效签约ID')
|
||
return
|
||
}
|
||
await listExportSubmit({
|
||
...(currentCondition.value || {}),
|
||
// ⚠️ 文档(storeWarehouse.store.export)的 id 只声明 number(“仅导出该签约关系”);
|
||
// 多选时传数组属前端扩展,若后端不支持可能被忽略(退化为按筛选条件全量导出)→ 待后端确认
|
||
id: ids.length === 1 ? ids[0] : ids
|
||
})
|
||
}
|
||
|
||
async function handleExportAll() {
|
||
if (!list.value.length) {
|
||
ElMessage.warning('当前无数据可导出')
|
||
return
|
||
}
|
||
if (listExportHasPending()) {
|
||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||
listExportResume()
|
||
return
|
||
}
|
||
await listExportSubmit({ ...(currentCondition.value || {}) })
|
||
}
|
||
|
||
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 storeWarehouseList(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
|
||
}
|
||
} catch (e) {
|
||
ElMessage.error('获取列表失败')
|
||
} finally {
|
||
queryTime.value = Date.now() - startTime
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function handleConditionChange(condition: any) {
|
||
const where: any = {}
|
||
if (condition) {
|
||
Object.keys(condition).forEach(k => {
|
||
const c = condition[k]
|
||
// 处理 ScanBox 规范格式:{ value, operator, type }
|
||
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 handleSortChange(_sort: { prop: string; order: string }) {
|
||
// 预留排序事件处理
|
||
}
|
||
|
||
function handleSelectionChange(rows: any[]) {
|
||
selectionRows.value = rows || []
|
||
}
|
||
|
||
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
|
||
if (activeTab.value === 'balanceLogs') {
|
||
balanceLogPagination.currentPage = 1
|
||
void loadBalanceLogs()
|
||
}
|
||
}
|
||
|
||
function resolveStoreIdFromRow(row: any): number | string | undefined {
|
||
if (!row || typeof row !== 'object') return undefined
|
||
const candidates = [row.store_id, row.storeId, row.counterparty_id, row.counterpartyId]
|
||
for (const candidate of candidates) {
|
||
if (candidate === null || candidate === undefined || candidate === '') continue
|
||
return candidate
|
||
}
|
||
return undefined
|
||
}
|
||
|
||
function toFiniteNumber(value: unknown): number | undefined {
|
||
if (value === null || value === undefined || value === '') return undefined
|
||
const n = Number(value)
|
||
return Number.isFinite(n) ? n : undefined
|
||
}
|
||
|
||
function getBalanceLogTime(row: any): string {
|
||
return String(row?.created_at || row?.create_time || row?.createdAt || row?.change_time || row?.updated_at || '')
|
||
}
|
||
|
||
function getBalanceLogBefore(row: any): number | undefined {
|
||
return (
|
||
toFiniteNumber(row?.balance_before) ??
|
||
toFiniteNumber(row?.before_quantity) ??
|
||
toFiniteNumber(row?.before_print_quantity) ??
|
||
toFiniteNumber(row?.old_quantity) ??
|
||
toFiniteNumber(row?.print_quantity_before) ??
|
||
toFiniteNumber(row?.previous_quantity)
|
||
)
|
||
}
|
||
|
||
function getBalanceLogAfter(row: any): number | undefined {
|
||
return (
|
||
toFiniteNumber(row?.balance_after) ??
|
||
toFiniteNumber(row?.after_quantity) ??
|
||
toFiniteNumber(row?.after_print_quantity) ??
|
||
toFiniteNumber(row?.new_quantity) ??
|
||
toFiniteNumber(row?.print_quantity_after) ??
|
||
toFiniteNumber(row?.current_quantity)
|
||
)
|
||
}
|
||
|
||
function getBalanceLogDelta(row: any): number | undefined {
|
||
const direct =
|
||
toFiniteNumber(row?.change_quantity) ??
|
||
toFiniteNumber(row?.delta_quantity) ??
|
||
toFiniteNumber(row?.quantity_delta) ??
|
||
toFiniteNumber(row?.diff_quantity)
|
||
if (direct !== undefined) return direct
|
||
const before = getBalanceLogBefore(row)
|
||
const after = getBalanceLogAfter(row)
|
||
if (before === undefined || after === undefined) return undefined
|
||
return after - before
|
||
}
|
||
|
||
function getBalanceLogOperator(row: any): string {
|
||
return String(
|
||
row?.operator_name ||
|
||
row?.creator_name ||
|
||
row?.created_by_name ||
|
||
row?.operator ||
|
||
row?.user_name ||
|
||
row?.operator_id ||
|
||
row?.created_by ||
|
||
''
|
||
)
|
||
}
|
||
|
||
function getBalanceLogReason(row: any): string {
|
||
return String(row?.reason || row?.change_reason || row?.remark || row?.memo || '')
|
||
}
|
||
|
||
function getBalanceLogChangeType(row: any): string {
|
||
return String(row?.change_type || row?.type || row?.log_type || '')
|
||
}
|
||
|
||
function getBalanceLogBusinessType(row: any): string {
|
||
return String(row?.business_type || row?.biz_type || '')
|
||
}
|
||
|
||
function getBalanceLogBusinessId(row: any): number | string | undefined {
|
||
const candidate = row?.business_id ?? row?.biz_id
|
||
if (candidate === null || candidate === undefined || candidate === '') return undefined
|
||
return candidate
|
||
}
|
||
|
||
function getQimenErpDisplay(config: any): string {
|
||
return String(config?.erp_name || config?.erpName || config?.qimen_app_key || '').trim()
|
||
}
|
||
|
||
function getEditingQimenCustomerId(): string {
|
||
return String(qimenDialog.editingConfig?.qimen_customer_id || '').trim()
|
||
}
|
||
|
||
function getBalanceLogDeltaClass(delta: number | undefined): string {
|
||
if (delta === undefined) return ''
|
||
if (delta > 0) return 'text-up'
|
||
if (delta < 0) return 'text-down'
|
||
return 'text-flat'
|
||
}
|
||
|
||
function formatBalanceLogDelta(delta: number | undefined): string {
|
||
if (delta === undefined) return '—'
|
||
if (delta > 0) return `+${delta}`
|
||
return String(delta)
|
||
}
|
||
|
||
async function loadBalanceLogs() {
|
||
if (!selectedRow.value) {
|
||
balanceLogList.value = []
|
||
balanceLogPagination.total = 0
|
||
return
|
||
}
|
||
|
||
const storeId = selectedStoreId.value
|
||
if (storeId === undefined || storeId === null || String(storeId).trim() === '') {
|
||
balanceLogList.value = []
|
||
balanceLogPagination.total = 0
|
||
ElMessage.warning('当前记录缺少 store_id,无法查询余额变动')
|
||
return
|
||
}
|
||
|
||
balanceLogLoading.value = true
|
||
try {
|
||
// 构建 where 筛选条件
|
||
const whereFilter: Record<string, any> = {}
|
||
if (balanceLogFilter.value === 'recharge') {
|
||
// 充值:change_quantity > 0
|
||
whereFilter.change_quantity = { operator: 'gt', value: 0 }
|
||
} else if (balanceLogFilter.value === 'consumption') {
|
||
// 消费:change_quantity < 0
|
||
whereFilter.change_quantity = { operator: 'lt', value: 0 }
|
||
}
|
||
// 时间范围筛选
|
||
if (balanceLogDateRange.value && balanceLogDateRange.value.length === 2) {
|
||
whereFilter.created_at = {
|
||
operator: 'between',
|
||
value: balanceLogDateRange.value
|
||
}
|
||
}
|
||
|
||
const requestData: {
|
||
store_id: number | string
|
||
pagination: { page: number; page_size: number }
|
||
where?: Record<string, any>
|
||
} = {
|
||
store_id: storeId,
|
||
pagination: {
|
||
page: balanceLogPagination.currentPage,
|
||
page_size: balanceLogPagination.pageSize
|
||
}
|
||
}
|
||
if (Object.keys(whereFilter).length > 0) {
|
||
requestData.where = whereFilter
|
||
}
|
||
|
||
const res = (await storeWarehouseQueryPrintQuantityLogs(requestData)) as any
|
||
|
||
const payload = res?.data || {}
|
||
const nested = payload?.data && typeof payload.data === 'object' ? payload.data : null
|
||
const rowsRaw = payload?.list || payload?.records || payload?.logs || nested?.list || nested?.records || nested || []
|
||
const rows = Array.isArray(rowsRaw) ? rowsRaw : []
|
||
balanceLogList.value = rows
|
||
|
||
const paginationRaw = payload?.pagination || nested?.pagination || {}
|
||
const total = toFiniteNumber(paginationRaw?.total) ?? toFiniteNumber(payload?.total) ?? toFiniteNumber(nested?.total) ?? 0
|
||
const current = toFiniteNumber(paginationRaw?.page) ?? balanceLogPagination.currentPage
|
||
const pageSize =
|
||
toFiniteNumber(paginationRaw?.page_size) ??
|
||
toFiniteNumber(paginationRaw?.pageSize) ??
|
||
balanceLogPagination.pageSize
|
||
|
||
balanceLogPagination.total = total
|
||
balanceLogPagination.currentPage = current
|
||
balanceLogPagination.pageSize = pageSize
|
||
} catch {
|
||
balanceLogList.value = []
|
||
balanceLogPagination.total = 0
|
||
ElMessage.error('获取余额变动列表失败')
|
||
} finally {
|
||
balanceLogLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleBalanceLogPageChange(page: number) {
|
||
balanceLogPagination.currentPage = page
|
||
resetBalanceLogScroll()
|
||
void loadBalanceLogs()
|
||
}
|
||
|
||
function handleBalanceLogSizeChange(size: number) {
|
||
balanceLogPagination.pageSize = size
|
||
balanceLogPagination.currentPage = 1
|
||
resetBalanceLogScroll()
|
||
void loadBalanceLogs()
|
||
}
|
||
|
||
// ─── 状态辅助 ────────────────────────────────────────────────────────────────
|
||
function getAuthStatusType(status: number) {
|
||
const map: Record<number, string> = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info', 5: 'danger' }
|
||
return (map[status] || 'info') as any
|
||
}
|
||
|
||
function getAuthStatusLabel(status: number) {
|
||
const map: Record<number, string> = { 1: '待审核', 2: '已通过', 3: '已拒绝', 4: '已解除', 5: '已过期' }
|
||
return map[status] || '未知'
|
||
}
|
||
|
||
function formatDate(dateStr: string | null | undefined) {
|
||
if (!dateStr) return ''
|
||
return new Date(dateStr).toLocaleString('zh-CN', { hour12: false }).replace(/\//g, '-')
|
||
}
|
||
|
||
// ─── 确认签约 ────────────────────────────────────────────────────────────────
|
||
async function handleConfirmSign(row: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确认与「${row.store_name || row.remask || row.counterparty_name}」的签约关系?`,
|
||
'确认签约',
|
||
{ type: 'warning', buttonSize: 'small' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
const res = await storeWarehouseConfirmSign({ id: row.id })
|
||
if (res?.flag === 'success' || res?.code === 200 || res?.data?.mode === 'confirm') {
|
||
ElMessage.success('签约已确认')
|
||
loadList()
|
||
if (selectedRow.value && selectedRow.value.id === row.id && res.data?.contract) {
|
||
Object.assign(selectedRow.value, res.data.contract)
|
||
}
|
||
} 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.store_name || row.remask || row.counterparty_name}」的签约关系吗?`,
|
||
`${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('操作失败')
|
||
}
|
||
}
|
||
|
||
// ==================== 修改备注(弹窗表单,对齐「手工录入运单号」) ====================
|
||
|
||
const renameDialogVisible = ref(false)
|
||
const renameLoading = ref(false)
|
||
const renameRow = ref<any>(null)
|
||
const renameFormRef = ref<FormInstance>()
|
||
const renameForm = reactive({ remask: '' })
|
||
const renameRules: FormRules = {
|
||
/* 允许留空(= 清除备注,列表回退展示货主默认名称),仅限制长度 */
|
||
remask: [{ max: 50, message: '备注名称不能超过 50 个字符', trigger: 'blur' }]
|
||
}
|
||
|
||
async function handleRename(row: any) {
|
||
renameRow.value = row
|
||
renameForm.remask = String(row?.remask ?? '')
|
||
renameDialogVisible.value = true
|
||
nextTick(() => renameFormRef.value?.clearValidate?.())
|
||
}
|
||
|
||
async function handleRenameSubmit() {
|
||
const row = renameRow.value
|
||
if (!row?.id) {
|
||
ElMessage.warning('缺少签约关系 ID,无法修改备注')
|
||
return
|
||
}
|
||
const valid = await renameFormRef.value?.validate().catch(() => false)
|
||
if (!valid) 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
|
||
}
|
||
}
|
||
|
||
// ─── 签约策略配置 ────────────────────────────────────────────────────────────
|
||
const policyDialog = reactive({
|
||
visible: false,
|
||
loading: false,
|
||
saving: false,
|
||
contractRow: null as any,
|
||
fields: [] as any[],
|
||
formData: {} as Record<string, any>,
|
||
jsonText: '',
|
||
jsonError: ''
|
||
})
|
||
const policyExpressOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const policyPlatformOptions = ref<Array<{ label: string; value: string }>>([])
|
||
|
||
function normalizePolicyConfig(source: Record<string, any>, fields: any[] = []) {
|
||
const normalized: Record<string, any> = {}
|
||
const allowAllKeys = fields.length === 0
|
||
const fieldMap = new Map<string, any>(fields.map((f: any) => [f.key, f]))
|
||
Object.keys(source || {}).forEach((key) => {
|
||
if (!allowAllKeys && !fieldMap.has(key)) return
|
||
const field = fieldMap.get(key)
|
||
const value = source[key]
|
||
if (value === undefined || value === null || value === '') return
|
||
if (
|
||
field?.type === 'flag' ||
|
||
[
|
||
'auto_allocate_bin',
|
||
'allow_mix_batch',
|
||
'allow_temp_storage',
|
||
'storage_separation'
|
||
].includes(key)
|
||
) {
|
||
normalized[key] = Number(value) ? 1 : 0
|
||
return
|
||
}
|
||
if (field?.type === 'integer' || key === 'max_daily_inbound') {
|
||
const n = Number(value)
|
||
if (!Number.isNaN(n)) normalized[key] = Math.max(0, Math.trunc(n))
|
||
return
|
||
}
|
||
if ((field?.type === 'number' && field?.precision === 2) || key === 'print_recharge_price') {
|
||
const n = Number(value)
|
||
if (!Number.isNaN(n)) normalized[key] = Number(n.toFixed(2))
|
||
return
|
||
}
|
||
normalized[key] = value
|
||
})
|
||
return normalized
|
||
}
|
||
|
||
function resetPolicyDialog() {
|
||
policyDialog.contractRow = null
|
||
policyDialog.fields = []
|
||
policyDialog.formData = {}
|
||
policyDialog.jsonText = ''
|
||
policyDialog.jsonError = ''
|
||
}
|
||
|
||
function validatePolicyJson(): boolean {
|
||
const text = policyDialog.jsonText.trim()
|
||
if (!text) {
|
||
policyDialog.jsonError = ''
|
||
return true
|
||
}
|
||
try {
|
||
const parsed = JSON.parse(text)
|
||
if (typeof parsed !== 'object' || Array.isArray(parsed) || parsed === null) {
|
||
policyDialog.jsonError = '必须是 JSON 对象 {},不能是数组或 null'
|
||
return false
|
||
}
|
||
policyDialog.jsonError = ''
|
||
return true
|
||
} catch {
|
||
policyDialog.jsonError = 'JSON 格式有误,请检查后重新输入'
|
||
return false
|
||
}
|
||
}
|
||
|
||
function getEnumOptionValue(option: any) {
|
||
if (option && typeof option === 'object') {
|
||
return option.value ?? option.label ?? ''
|
||
}
|
||
return option
|
||
}
|
||
|
||
function getEnumOptionLabel(option: any) {
|
||
if (option && typeof option === 'object') {
|
||
return option.label ?? option.value ?? ''
|
||
}
|
||
return option
|
||
}
|
||
|
||
function normalizeOptionText(value: unknown) {
|
||
return String(value ?? '').trim()
|
||
}
|
||
|
||
/** 判断是否为“快递编码”类下拉字段(默认快递 / 出库单默认快递等),使用快递接口列表作为选项 */
|
||
function isExpressSelectField(field: any) {
|
||
if (!field) return false
|
||
const key = String(field.key || '').trim()
|
||
if (key === 'default_express_code') return true
|
||
const name = String(field.name || field.label || '').trim()
|
||
// 兼容后端动态字段:名称同时包含“出库单”与“快递”(如“出库单默认快递”),避免误伤 flag 类快递开关字段
|
||
return name.includes('出库单') && name.includes('快递')
|
||
}
|
||
|
||
function mapPolicyExpressOptions(rawList: any[]) {
|
||
const result: Array<{ label: string; value: string }> = []
|
||
const seen = new Set<string>()
|
||
for (const item of rawList || []) {
|
||
const code = normalizeOptionText(item?.express_code || item?.code || item?.express?.code)
|
||
if (!code || seen.has(code)) continue
|
||
const name = normalizeOptionText(item?.name || item?.express_name || item?.express?.name)
|
||
result.push({
|
||
value: code,
|
||
label: name ? `${code} - ${name}` : code
|
||
})
|
||
seen.add(code)
|
||
}
|
||
return result
|
||
}
|
||
|
||
function mapPolicyPlatformOptions(rawList: any[]) {
|
||
const result: Array<{ label: string; value: string }> = []
|
||
const seen = new Set<string>()
|
||
for (const item of rawList || []) {
|
||
const code = normalizeOptionText(item?.code || item?.platform_code)
|
||
if (!code || seen.has(code)) continue
|
||
const name = normalizeOptionText(item?.name || item?.platform_name)
|
||
result.push({
|
||
value: code,
|
||
label: name ? `${code} - ${name}` : code
|
||
})
|
||
seen.add(code)
|
||
}
|
||
return result
|
||
}
|
||
|
||
async function loadPolicySelectOptions() {
|
||
try {
|
||
const [expressRes, platformRes]: any = await Promise.all([
|
||
getExpressList({ systemOnly: 'true' }),
|
||
getPlatformList({ systemOnly: 'true' })
|
||
])
|
||
const expressRaw = expressRes?.data?.list || expressRes?.data || []
|
||
const platformRaw = platformRes?.data?.list || platformRes?.data || []
|
||
policyExpressOptions.value = mapPolicyExpressOptions(expressRaw)
|
||
policyPlatformOptions.value = mapPolicyPlatformOptions(platformRaw)
|
||
} catch {
|
||
policyExpressOptions.value = []
|
||
policyPlatformOptions.value = []
|
||
}
|
||
}
|
||
|
||
async function openPolicyDialog(row: any) {
|
||
policyDialog.contractRow = row
|
||
policyDialog.fields = []
|
||
policyDialog.formData = {}
|
||
policyDialog.jsonText = ''
|
||
policyDialog.jsonError = ''
|
||
policyDialog.visible = true
|
||
policyDialog.loading = true
|
||
try {
|
||
await loadPolicySelectOptions()
|
||
const [configRes, fieldsRes] = await Promise.all([
|
||
storeWarehouseGetPolicyConfig({ id: row.id }) as Promise<any>,
|
||
storeWarehouseGetPolicyConfigFields() as Promise<any>
|
||
])
|
||
// 加载字段元信息
|
||
const fieldList: any[] = Array.isArray(fieldsRes?.data) ? fieldsRes.data : []
|
||
policyDialog.fields = fieldList
|
||
// 用字段默认值初始化 formData
|
||
const defaults: Record<string, any> = {}
|
||
fieldList.forEach((f: any) => { defaults[f.key] = f.default ?? undefined })
|
||
// 用已保存的 policy_config 覆盖
|
||
const saved = configRes?.data?.policy_config
|
||
policyDialog.formData = { ...defaults, ...(saved && typeof saved === 'object' && !Array.isArray(saved) ? saved : {}) }
|
||
// 同步 JSON 文本(fallback)
|
||
if (saved && typeof saved === 'object') {
|
||
policyDialog.jsonText = JSON.stringify(saved, null, 2)
|
||
}
|
||
} catch {
|
||
ElMessage.error('加载策略配置失败')
|
||
} finally {
|
||
policyDialog.loading = false
|
||
}
|
||
}
|
||
|
||
async function submitPolicyConfig() {
|
||
policyDialog.saving = true
|
||
try {
|
||
let policy_config: Record<string, any> = {}
|
||
if (policyDialog.fields.length > 0) {
|
||
// 结构化表单模式:直接取 formData
|
||
const data: Record<string, any> = {}
|
||
policyDialog.fields.forEach((f: any) => {
|
||
const v = policyDialog.formData[f.key]
|
||
if (v !== undefined && v !== '') data[f.key] = v
|
||
})
|
||
policy_config = normalizePolicyConfig(data, policyDialog.fields)
|
||
} else {
|
||
// fallback JSON 模式
|
||
if (!validatePolicyJson()) { policyDialog.saving = false; return }
|
||
const text = policyDialog.jsonText.trim()
|
||
policy_config = text ? normalizePolicyConfig(JSON.parse(text), policyDialog.fields) : {}
|
||
}
|
||
const res = await storeWarehouseSavePolicyConfig({
|
||
id: policyDialog.contractRow?.id,
|
||
policy_config: policy_config as any
|
||
}) as any
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
ElMessage.success('策略配置保存成功')
|
||
policyDialog.visible = false
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '保存策略配置失败')
|
||
}
|
||
} catch {
|
||
ElMessage.error('保存策略配置失败')
|
||
} finally {
|
||
policyDialog.saving = false
|
||
}
|
||
}
|
||
|
||
// ─── 接口配置管理(奇门 / OPEN_API 等) ─────────────────────────────────────────
|
||
const qimenDialog = reactive({
|
||
visible: false,
|
||
loading: false,
|
||
contractRow: null as any,
|
||
list: [] as any[],
|
||
availableTypes: [] as any[], // 用于提交时解析 interface_type_id(来源:listInterfaceTypes)
|
||
selectableTypes: [] as any[], // 保留字段(兼容,实际下拉由 selectableLocalTypes 驱动)
|
||
total: 0,
|
||
contract: null as any,
|
||
formVisible: false,
|
||
formLoading: false,
|
||
editingConfig: null as any
|
||
})
|
||
const qimenAppOptions = ref<Array<{ label: string; value: string }>>([])
|
||
|
||
/** 新增时可选的接口类型 */
|
||
const selectableTypes = computed(() => qimenDialog.availableTypes)
|
||
|
||
const qimenForm = reactive<Record<string, any>>({ ...qimenFormDefault })
|
||
/** 接口类型联动:QM_WMS 专属字段是否展示(表单面板用) */
|
||
const isQmWmsFormType = computed(
|
||
() =>
|
||
qimenForm.interface_code === 'QM_WMS' ||
|
||
(!qimenForm.interface_code && qimenDialog.editingConfig?.interface_code === 'QM_WMS')
|
||
)
|
||
const visibleSecrets = reactive<Record<string | number, boolean>>({})
|
||
|
||
function toggleSecret(row: any) {
|
||
const key = row.id || row.interface_type_id
|
||
visibleSecrets[key] = !visibleSecrets[key]
|
||
}
|
||
|
||
// ─── 面单余额调整 ─────────────────────────────────────────────────────────
|
||
const adjustBalanceDialog = reactive({ ...adjustBalanceDialogDefault })
|
||
const adjustBalanceForm = reactive<Record<string, any>>({ ...adjustBalanceFormDefault })
|
||
const adjustBalanceFormRef = ref<FormInstance>()
|
||
/** 表单校验规则:沿用 store-config 的 adjustBalanceFormItems[].rules */
|
||
const adjustBalanceRules = Object.fromEntries(
|
||
(adjustBalanceFormItems as any[])
|
||
.filter((item) => item?.prop && Array.isArray(item.rules))
|
||
.map((item) => [String(item.prop), item.rules])
|
||
) as FormRules
|
||
|
||
/** 目标余额相对当前余额的增减提示 */
|
||
const adjustBalanceDeltaHint = computed(() => {
|
||
if (adjustBalanceDialog.fetchLoading) {
|
||
return { text: '', kind: 'neutral' as const }
|
||
}
|
||
const curN = parsePrintQuantity(adjustBalanceForm.current_print_quantity)
|
||
const tgtRaw = adjustBalanceForm.target_quantity
|
||
const tgtN = parsePrintQuantity(tgtRaw)
|
||
if (tgtRaw === undefined || tgtRaw === null || tgtRaw === '') {
|
||
return { text: '', kind: 'neutral' as const }
|
||
}
|
||
if (tgtN === undefined) {
|
||
return { text: '', kind: 'neutral' as const }
|
||
}
|
||
if (curN === undefined) {
|
||
return {
|
||
text: '提交后将把面单余额覆盖为上述目标值(当前余额未加载,无法计算增减)',
|
||
kind: 'neutral' as const
|
||
}
|
||
}
|
||
const delta = tgtN - curN
|
||
if (delta === 0) {
|
||
return { text: '与当前面单余额一致,无增减', kind: 'same' as const }
|
||
}
|
||
if (delta > 0) {
|
||
return { text: `相对当前余额将增加 ${delta}`, kind: 'up' as const }
|
||
}
|
||
return { text: `相对当前余额将减少 ${Math.abs(delta)}`, kind: 'down' as const }
|
||
})
|
||
|
||
function formatAdjustBalanceDisplayQty(value: unknown) {
|
||
if (value === null || value === undefined || value === '') {
|
||
return '—'
|
||
}
|
||
const n = Number(value)
|
||
return Number.isFinite(n) ? String(n) : '—'
|
||
}
|
||
|
||
function parsePrintQuantity(value: unknown): number | undefined {
|
||
if (value === null || value === undefined || value === '') {
|
||
return undefined
|
||
}
|
||
const n = Number(value)
|
||
return Number.isFinite(n) ? n : undefined
|
||
}
|
||
|
||
/** 调用 storeWarehouse.store.list,按签约 id 拉取最新一行(含 print_quantity) */
|
||
async function fetchLatestContractRowById(contractId: number): Promise<any | null> {
|
||
const filterAttempts: Record<string, unknown>[] = [
|
||
{ keyword: currentCondition.value?.keyword },
|
||
{}
|
||
]
|
||
|
||
const pageSize = 200
|
||
const maxPages = 40
|
||
|
||
for (const filters of filterAttempts) {
|
||
let page = 1
|
||
while (page <= maxPages) {
|
||
const res = (await storeWarehouseList({
|
||
page,
|
||
page_size: pageSize,
|
||
...filters
|
||
} as any)) as any
|
||
const payload = res?.data
|
||
const rows = Array.isArray(payload?.list) ? payload.list : []
|
||
|
||
const hit = rows.find((r: any) => Number(r?.id) === Number(contractId))
|
||
if (hit) {
|
||
return hit
|
||
}
|
||
|
||
if (rows.length === 0) {
|
||
break
|
||
}
|
||
|
||
const reportedTotal = Number(payload?.pagination?.total ?? payload?.total)
|
||
const noMore =
|
||
rows.length < pageSize ||
|
||
(Number.isFinite(reportedTotal) && page * pageSize >= reportedTotal)
|
||
if (noMore) {
|
||
break
|
||
}
|
||
|
||
page += 1
|
||
}
|
||
}
|
||
|
||
return null
|
||
}
|
||
|
||
async function openAdjustBalanceDialog(row: any) {
|
||
adjustBalanceDialog.contractRow = row
|
||
adjustBalanceDialog.visible = true
|
||
adjustBalanceDialog.fetchLoading = true
|
||
Object.assign(adjustBalanceForm, adjustBalanceFormDefault)
|
||
nextTick(() => adjustBalanceFormRef.value?.clearValidate?.())
|
||
|
||
try {
|
||
const fresh = await fetchLatestContractRowById(Number(row.id))
|
||
if (fresh) {
|
||
adjustBalanceDialog.contractRow = fresh
|
||
const pq = parsePrintQuantity(fresh.print_quantity)
|
||
adjustBalanceForm.current_print_quantity = pq
|
||
adjustBalanceForm.target_quantity = pq
|
||
} else {
|
||
ElMessage.warning('未能从列表接口获取该签约的最新数据,已使用表格当前行数据')
|
||
const pq = parsePrintQuantity(row.print_quantity)
|
||
adjustBalanceForm.current_print_quantity = pq
|
||
adjustBalanceForm.target_quantity = pq
|
||
}
|
||
} catch {
|
||
ElMessage.error('获取最新面单余额失败')
|
||
const pq = parsePrintQuantity(row.print_quantity)
|
||
adjustBalanceForm.current_print_quantity = pq
|
||
adjustBalanceForm.target_quantity = pq
|
||
} finally {
|
||
adjustBalanceDialog.fetchLoading = false
|
||
}
|
||
}
|
||
|
||
function resetAdjustBalanceDialog() {
|
||
adjustBalanceDialog.contractRow = null
|
||
adjustBalanceDialog.fetchLoading = false
|
||
Object.assign(adjustBalanceForm, adjustBalanceFormDefault)
|
||
}
|
||
|
||
async function submitAdjustBalance() {
|
||
const valid = await adjustBalanceFormRef.value?.validate().catch(() => false)
|
||
if (!valid) return
|
||
if (!adjustBalanceForm.reason?.trim()) {
|
||
ElMessage.warning('请输入调整原因')
|
||
return
|
||
}
|
||
|
||
adjustBalanceDialog.loading = true
|
||
try {
|
||
const res = await storeWarehouseAdjustPrintQuantity({
|
||
id: adjustBalanceDialog.contractRow.id,
|
||
target_quantity: adjustBalanceForm.target_quantity,
|
||
reason: adjustBalanceForm.reason.trim()
|
||
}) as any
|
||
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
ElMessage.success('面单余额设置成功')
|
||
adjustBalanceDialog.visible = false
|
||
loadList() // 刷新列表
|
||
} else {
|
||
ElMessage.error(res?.message || '调整失败')
|
||
}
|
||
} catch {
|
||
ElMessage.error('调整失败')
|
||
} finally {
|
||
adjustBalanceDialog.loading = false
|
||
}
|
||
}
|
||
|
||
// ─── 代开户 ────────────────────────────────────────────────────────────────────
|
||
const openAccountDialog = reactive({ ...openAccountDialogDefault })
|
||
const openAccountForm = reactive<Record<string, any>>({ ...openAccountFormDefault })
|
||
const openAccountFormRef = ref<any>(null)
|
||
|
||
const openAccountFormRules: Record<string, any> = {
|
||
username: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
|
||
company_name: [
|
||
{ required: true, message: '请输入公司全称', trigger: 'blur' },
|
||
{ max: 200, message: '公司全称不能超过200字符', trigger: 'blur' }
|
||
],
|
||
contact_person: [
|
||
{ required: true, message: '请输入联系人姓名', trigger: 'blur' },
|
||
{ max: 50, message: '联系人姓名不能超过50字符', trigger: 'blur' }
|
||
],
|
||
apply_reason: [{ max: 2000, message: '申请原因不能超过2000字符', trigger: 'blur' }],
|
||
store_remask: [{ max: 50, message: '货主备注名不能超过50字符', trigger: 'blur' }],
|
||
warehouse_remask: [{ max: 50, message: '仓库备注名不能超过50字符', trigger: 'blur' }]
|
||
}
|
||
|
||
function generateRandomUsername() {
|
||
const prefix = 'user'
|
||
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
|
||
let suffix = ''
|
||
for (let i = 0; i < 8; i++) {
|
||
suffix += chars.charAt(Math.floor(Math.random() * chars.length))
|
||
}
|
||
openAccountForm.username = `${prefix}${suffix}`
|
||
}
|
||
|
||
function openOpenAccountDialog() {
|
||
resetOpenAccountDialog()
|
||
// 默认授权开始日期为当天
|
||
const today = new Date()
|
||
openAccountForm.auth_start = today.toISOString().slice(0, 10)
|
||
openAccountDialog.visible = true
|
||
}
|
||
|
||
function resetOpenAccountDialog() {
|
||
Object.assign(openAccountDialog, openAccountDialogDefault)
|
||
Object.assign(openAccountForm, openAccountFormDefault)
|
||
openAccountFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function submitOpenAccount() {
|
||
if (!openAccountFormRef.value) return
|
||
try {
|
||
await openAccountFormRef.value.validate()
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
openAccountDialog.loading = true
|
||
try {
|
||
const payload: Record<string, any> = {
|
||
username: openAccountForm.username.trim(),
|
||
company_name: openAccountForm.company_name.trim(),
|
||
contact_person: openAccountForm.contact_person.trim()
|
||
}
|
||
// 仅提交非空值
|
||
const optionalFields = [
|
||
'password', 'real_name', 'business_license', 'contact_phone',
|
||
'legal_person', 'contact_email', 'address', 'industry',
|
||
'auth_start', 'auth_end', 'apply_reason', 'store_remask', 'warehouse_remask'
|
||
]
|
||
for (const field of optionalFields) {
|
||
const val = openAccountForm[field]
|
||
if (val !== undefined && val !== null && String(val).trim() !== '') {
|
||
payload[field] = typeof val === 'string' ? val.trim() : val
|
||
}
|
||
}
|
||
if (openAccountForm.print_quantity > 0) {
|
||
payload.print_quantity = openAccountForm.print_quantity
|
||
}
|
||
// 默认申请原因
|
||
if (!payload.apply_reason) {
|
||
payload.apply_reason = '仓库代开户'
|
||
}
|
||
|
||
const res = await storeWarehouseOpenAccount(payload as any) as any
|
||
if (res?.flag === 'success' || res?.code === 200 || res?.code === 1) {
|
||
ElMessage.success(res?.message || '开户成功')
|
||
openAccountDialog.visible = false
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '开户失败')
|
||
}
|
||
} catch (e: any) {
|
||
ElMessage.error(e?.message || '开户失败')
|
||
} finally {
|
||
openAccountDialog.loading = false
|
||
}
|
||
}
|
||
|
||
// ─── 创建用户(storeWarehouse.store.createUser) ──────────────────────────────
|
||
const createUserDialog = reactive({ ...createUserDialogDefault })
|
||
const createUserForm = reactive<Record<string, any>>({ ...createUserFormDefault })
|
||
const createUserFormRef = ref<any>(null)
|
||
|
||
const createUserFormRules: Record<string, any> = {
|
||
username: [
|
||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||
{
|
||
pattern: /^[a-zA-Z0-9_]{3,50}$/,
|
||
message: '用户名需为3-50位字母、数字或下划线',
|
||
trigger: 'blur'
|
||
}
|
||
]
|
||
}
|
||
|
||
function openCreateUserDialog(row: any) {
|
||
resetCreateUserDialog()
|
||
createUserForm.store_id = Number(row.store_id ?? row.counterparty_id)
|
||
createUserForm.store_label = String(row.counterparty_name ?? row.remask ?? '') || `货主 ${row.store_id}`
|
||
createUserDialog.visible = true
|
||
}
|
||
|
||
function resetCreateUserDialog() {
|
||
Object.assign(createUserDialog, createUserDialogDefault)
|
||
Object.assign(createUserForm, createUserFormDefault)
|
||
createUserFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function submitCreateUser() {
|
||
if (!createUserFormRef.value) return
|
||
try {
|
||
await createUserFormRef.value.validate()
|
||
} catch {
|
||
return
|
||
}
|
||
const storeId = Number(createUserForm.store_id)
|
||
if (!Number.isFinite(storeId) || storeId <= 0) {
|
||
ElMessage.warning('缺少货主信息,无法创建用户')
|
||
return
|
||
}
|
||
createUserDialog.loading = true
|
||
try {
|
||
const res: any = await storeWarehouseCreateUser({
|
||
username: String(createUserForm.username ?? '').trim(),
|
||
store_id: storeId
|
||
})
|
||
const data = res?.data ?? res
|
||
if (res?.flag === 'success' || res?.code === 200 || res?.code === 1) {
|
||
const created = Boolean(data?.created)
|
||
const password = data?.password
|
||
createUserDialog.visible = false
|
||
if (created && password) {
|
||
// 仅本次新建账号时返回初始明文密码
|
||
const username = String(data?.username ?? createUserForm.username ?? '').trim()
|
||
const copyText = `地址:https://wms.wms.gztbyc.com/\n账号:${username}\n密码:${password}`
|
||
ElMessageBox.alert(
|
||
copyText,
|
||
'创建成功',
|
||
{ confirmButtonText: '复制并关闭', type: 'success', buttonSize: 'small' }
|
||
).then(() => {
|
||
navigator.clipboard?.writeText(copyText).catch(() => {})
|
||
}).catch(() => {})
|
||
} else {
|
||
ElMessage.success(created ? '创建成功' : '账号已存在,已为货主授权')
|
||
}
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '创建用户失败')
|
||
}
|
||
} catch (e: any) {
|
||
ElMessage.error(e?.message || '创建用户失败')
|
||
} finally {
|
||
createUserDialog.loading = false
|
||
}
|
||
}
|
||
|
||
function openQimenDialog(row: any) {
|
||
qimenDialog.contractRow = row
|
||
qimenDialog.formVisible = false
|
||
qimenDialog.editingConfig = null
|
||
qimenDialog.list = []
|
||
qimenDialog.visible = true
|
||
void loadQimenAppOptions()
|
||
loadQimenConfigs()
|
||
}
|
||
|
||
function resetQimenDialog() {
|
||
qimenDialog.contractRow = null
|
||
qimenDialog.formVisible = false
|
||
qimenDialog.editingConfig = null
|
||
qimenDialog.list = []
|
||
qimenDialog.availableTypes = []
|
||
qimenDialog.selectableTypes = []
|
||
qimenAppOptions.value = []
|
||
}
|
||
|
||
function mapQimenAppOptions(rawList: any[]) {
|
||
const result: Array<{ label: string; value: string }> = []
|
||
const seen = new Set<string>()
|
||
for (const item of rawList || []) {
|
||
const appKey = String(item?.app_key ?? item?.qimen_app_key ?? item?.value ?? '').trim()
|
||
if (!appKey || seen.has(appKey)) continue
|
||
const appName = String(item?.app_name ?? item?.name ?? item?.label ?? '').trim()
|
||
result.push({
|
||
value: appKey,
|
||
label: appName ? `${appName}(${appKey})` : appKey
|
||
})
|
||
seen.add(appKey)
|
||
}
|
||
return result
|
||
}
|
||
|
||
async function loadQimenAppOptions() {
|
||
try {
|
||
const res: any = await getQimenAppList({})
|
||
const payload = res?.data
|
||
const listRaw =
|
||
res?.list ||
|
||
res?.records ||
|
||
(Array.isArray(res) ? res : null) ||
|
||
(Array.isArray(payload) ? payload : null) ||
|
||
payload?.list ||
|
||
payload?.records ||
|
||
payload?.data?.list ||
|
||
payload?.data?.records ||
|
||
payload?.data ||
|
||
[]
|
||
const rows = Array.isArray(listRaw) ? listRaw : []
|
||
qimenAppOptions.value = mapQimenAppOptions(rows)
|
||
} catch {
|
||
qimenAppOptions.value = []
|
||
}
|
||
}
|
||
|
||
async function loadQimenConfigs() {
|
||
if (!qimenDialog.contractRow) return
|
||
qimenDialog.loading = true
|
||
try {
|
||
// 并行获取已配置列表和全局接口类型列表
|
||
const [res, typesRes] = await Promise.all([
|
||
listApiConfig({ id: qimenDialog.contractRow.id }) as Promise<any>,
|
||
listInterfaceTypes() as Promise<any>
|
||
])
|
||
|
||
// listInterfaceTypes 接口返回 { list: [...], total, ... }
|
||
const serverTypes: any[] = Array.isArray(typesRes?.list) ? typesRes.list : []
|
||
|
||
// 以接口类型列表作为主数据源;对于历史数据中未出现在 serverTypes 的类型进行兜底补充
|
||
const typeMap = new Map<number, any>(serverTypes.map((t: any) => [t.id, t]))
|
||
|
||
if (res?.data) {
|
||
qimenDialog.list = (res.data.list || []).map((item: any) => ({
|
||
...item,
|
||
erp_display: getQimenErpDisplay(item)
|
||
}))
|
||
qimenDialog.total = res.data.total || 0
|
||
qimenDialog.contract = res.data.contract || null
|
||
|
||
// 将已配置列表中未被 listInterfaceTypes 收录的历史类型追加进去(兜底)
|
||
;(res.data.list || []).forEach((item: any) => {
|
||
const tid = item.interface_type_id
|
||
if (tid && !typeMap.has(tid)) {
|
||
typeMap.set(tid, {
|
||
id: tid,
|
||
interface_code: item.interface_code || item.interface_category || '',
|
||
interface_name: item.interface_name || item.interface_code || `类型 ${tid}`
|
||
})
|
||
}
|
||
})
|
||
}
|
||
|
||
qimenDialog.availableTypes = Array.from(typeMap.values())
|
||
} catch {
|
||
ElMessage.error('加载接口配置列表失败')
|
||
} finally {
|
||
qimenDialog.loading = false
|
||
}
|
||
}
|
||
|
||
function handleInterfaceTypeChange(_code: string) {
|
||
// interface_code 已由 v-model 绑定自动更新,此处只做联动清空
|
||
qimenForm.qimen_app_key = ''
|
||
qimenForm.qimen_customer_id = ''
|
||
qimenForm.qimen_warehouse_code = ''
|
||
}
|
||
|
||
function randomAlphaNum(length = 12): string {
|
||
const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'
|
||
let result = ''
|
||
for (let i = 0; i < length; i += 1) {
|
||
const idx = Math.floor(Math.random() * chars.length)
|
||
result += chars[idx]
|
||
}
|
||
return result
|
||
}
|
||
|
||
function generateQimenCustomerCode() {
|
||
qimenForm.qimen_customer_id = `ST_${randomAlphaNum(10)}`
|
||
}
|
||
|
||
function generateQimenWarehouseCode() {
|
||
qimenForm.qimen_warehouse_code = `WH_${randomAlphaNum(10)}`
|
||
}
|
||
|
||
async function copyText(text: string) {
|
||
try {
|
||
if (navigator?.clipboard?.writeText) {
|
||
await navigator.clipboard.writeText(text)
|
||
} else {
|
||
const input = document.createElement('textarea')
|
||
input.value = text
|
||
input.style.position = 'fixed'
|
||
input.style.opacity = '0'
|
||
document.body.appendChild(input)
|
||
input.focus()
|
||
input.select()
|
||
document.execCommand('copy')
|
||
document.body.removeChild(input)
|
||
}
|
||
ElMessage.success('已复制')
|
||
} catch {
|
||
ElMessage.error('复制失败')
|
||
}
|
||
}
|
||
|
||
async function copyEditingQimenCustomerId() {
|
||
const customerId = getEditingQimenCustomerId()
|
||
if (!customerId) {
|
||
ElMessage.warning('暂无可复制的货主编码')
|
||
return
|
||
}
|
||
|
||
try {
|
||
if (navigator?.clipboard?.writeText) {
|
||
await navigator.clipboard.writeText(customerId)
|
||
} else {
|
||
const input = document.createElement('textarea')
|
||
input.value = customerId
|
||
input.style.position = 'fixed'
|
||
input.style.opacity = '0'
|
||
document.body.appendChild(input)
|
||
input.focus()
|
||
input.select()
|
||
document.execCommand('copy')
|
||
document.body.removeChild(input)
|
||
}
|
||
ElMessage.success('货主编码已复制')
|
||
} catch {
|
||
ElMessage.error('复制货主编码失败')
|
||
}
|
||
}
|
||
|
||
function copyQmWmsConfig(row: any) {
|
||
const customerId = String(row.qimen_customer_id || '').trim()
|
||
const warehouseCode = String(row.qimen_warehouse_code || '').trim()
|
||
if (!customerId && !warehouseCode) {
|
||
ElMessage.warning('暂无可复制的奇门配置')
|
||
return
|
||
}
|
||
const lines: string[] = []
|
||
if (customerId) lines.push(`货主编码:${customerId}`)
|
||
if (warehouseCode) lines.push(`仓库编码:${warehouseCode}`)
|
||
copyText(lines.join('\n'))
|
||
}
|
||
|
||
function copyOpenApiConfig(row: any) {
|
||
const baseApi = String(import.meta.env.VITE_APP_BASE_API || '').replace(/\/+$/, '')
|
||
const lines: string[] = []
|
||
lines.push('【OPEN_API 接口配置信息】')
|
||
lines.push('')
|
||
if (row.app_name) lines.push(`应用名称:${row.app_name}`)
|
||
if (row.self_app_key) lines.push(`APPKEY:${row.self_app_key}`)
|
||
if (row.self_app_secret) lines.push(`APPSECRET:${row.self_app_secret}`)
|
||
lines.push(`接口地址:${baseApi}/openapi`)
|
||
lines.push('')
|
||
lines.push('开发文档:')
|
||
lines.push(` 接口文档 ${baseApi}/docs/api/openapi`)
|
||
lines.push(` 回调测试 ${baseApi}/docs/api/openapi/callback-test`)
|
||
lines.push('')
|
||
lines.push('请妥善保管以上信息,用于 API 对接。')
|
||
copyText(lines.join('\n'))
|
||
}
|
||
|
||
function openCallbackDoc() {
|
||
const baseApi = String(import.meta.env.VITE_APP_BASE_API || '').replace(/\/+$/, '')
|
||
window.open(`${baseApi}/docs/api/openapi/callback-test`, '_blank')
|
||
}
|
||
|
||
function openQimenForm(config: any) {
|
||
qimenDialog.editingConfig = config
|
||
if (config) {
|
||
Object.assign(qimenForm, qimenFormDefault, config)
|
||
// 从现有配置提取接口类型标识(用于表单条件渲染)
|
||
qimenForm.interface_code = config.interface_code || config.interface_category || ''
|
||
// is_enabled = 0 情况兼容
|
||
if (config.is_enabled !== undefined) qimenForm.is_enabled = config.is_enabled
|
||
} else {
|
||
Object.assign(qimenForm, qimenFormDefault)
|
||
// 若只有一个接口类型,自动选中
|
||
if (selectableTypes.value.length === 1) {
|
||
qimenForm.interface_code = selectableTypes.value[0]?.interface_code ?? ''
|
||
}
|
||
}
|
||
qimenDialog.formVisible = true
|
||
}
|
||
|
||
async function submitQimenForm() {
|
||
if (!qimenForm.interface_code) {
|
||
ElMessage.warning('请选择接口类型')
|
||
return
|
||
}
|
||
if (!qimenForm.app_name?.trim()) {
|
||
ElMessage.warning('请填写应用名称')
|
||
return
|
||
}
|
||
// QM_WMS 类型必填奇门字段
|
||
const isQmWms = qimenForm.interface_code === 'QM_WMS' ||
|
||
(!qimenForm.interface_code && qimenDialog.editingConfig?.interface_code === 'QM_WMS')
|
||
if (isQmWms) {
|
||
if (!qimenForm.qimen_app_key?.trim()) {
|
||
ElMessage.warning('奇门备山 QM_WMS 类型必须选择ERP')
|
||
return
|
||
}
|
||
if (!qimenForm.qimen_customer_id?.trim()) {
|
||
ElMessage.warning('奇门备山 QM_WMS 类型必须填写货主编码')
|
||
return
|
||
}
|
||
if (!qimenForm.qimen_warehouse_code?.trim()) {
|
||
ElMessage.warning('奇门备山 QM_WMS 类型必须填写仓库编码')
|
||
return
|
||
}
|
||
}
|
||
// 解析 interface_type_id:编辑时来自已有配置,新增时从 availableTypes 按 interface_code 反查
|
||
const resolvedTypeId: number | undefined =
|
||
qimenDialog.editingConfig?.interface_type_id ??
|
||
qimenDialog.availableTypes.find((t: any) => t.interface_code === qimenForm.interface_code)?.id
|
||
if (!resolvedTypeId) {
|
||
ElMessage.warning('无法解析接口类型ID,请稍后重试或刷新页面')
|
||
return
|
||
}
|
||
qimenDialog.formLoading = true
|
||
try {
|
||
// 仅提交 saveApiConfig 接口所要求的字段
|
||
const payload: Record<string, any> = {
|
||
id: qimenDialog.contractRow?.id as number,
|
||
interface_type_id: resolvedTypeId,
|
||
app_name: qimenForm.app_name.trim()
|
||
}
|
||
// QM_WMS 类型额外传奇门字段
|
||
if (isQmWms) {
|
||
payload.qimen_app_key = qimenForm.qimen_app_key.trim()
|
||
payload.qimen_customer_id = qimenForm.qimen_customer_id.trim()
|
||
payload.qimen_warehouse_code = qimenForm.qimen_warehouse_code.trim()
|
||
}
|
||
// 回调地址(所有类型)
|
||
if (qimenForm.callback_url?.trim()) {
|
||
payload.callback_url = qimenForm.callback_url.trim()
|
||
}
|
||
const res = await saveApiConfig(payload as any) as any
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
const action = res.data?.action === 'create' ? '新增' : '更新'
|
||
ElMessage.success(`奇门配置${action}成功`)
|
||
qimenDialog.formVisible = false
|
||
await loadQimenConfigs()
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '保存奇门配置失败')
|
||
}
|
||
} catch {
|
||
ElMessage.error('保存奇门配置失败')
|
||
} finally {
|
||
qimenDialog.formLoading = false
|
||
}
|
||
}
|
||
|
||
async function handleDeleteQimenConfig(config: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确认要删除奇门配置「${config.app_name}」吗?删除后签约关系将无奇门配置。`,
|
||
'删除奇门配置',
|
||
{ type: 'warning', confirmButtonText: '确认删除', cancelButtonText: '取消', buttonSize: 'small' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
const res = await storeWarehouseDeleteQimenConfig({
|
||
id: qimenDialog.contractRow?.id,
|
||
interface_type_id: config.interface_type_id
|
||
}) as any
|
||
if (res?.flag === 'success' || res?.code === 200) {
|
||
ElMessage.success('删除成功')
|
||
await loadQimenConfigs()
|
||
loadList()
|
||
} else {
|
||
ElMessage.error(res?.message || '删除失败')
|
||
}
|
||
} catch {
|
||
ElMessage.error('删除失败')
|
||
}
|
||
}
|
||
|
||
// ─── 生成加群授权码 ────────────────────────────────────────────────────────────
|
||
const bindCodeDialog = reactive({
|
||
visible: false,
|
||
loading: false,
|
||
storeName: '',
|
||
code: '',
|
||
contractRow: null as any
|
||
})
|
||
|
||
function resetBindCodeDialog() {
|
||
bindCodeDialog.contractRow = null
|
||
bindCodeDialog.storeName = ''
|
||
bindCodeDialog.code = ''
|
||
}
|
||
|
||
async function handleGenerateBindCode(row: any) {
|
||
bindCodeDialog.contractRow = row
|
||
bindCodeDialog.storeName = row.store_name || row.remask || row.counterparty_name || ''
|
||
bindCodeDialog.code = ''
|
||
bindCodeDialog.visible = true
|
||
bindCodeDialog.loading = true
|
||
try {
|
||
const storeId = row.store_id || row.id
|
||
const res = await inboxBindCode({ storeId }) as any
|
||
if (res?.data?.code) {
|
||
bindCodeDialog.code = res.data.code
|
||
ElMessage.success('授权码生成成功')
|
||
} else if (res?.code === 200 && res?.data) {
|
||
bindCodeDialog.code = res.data.code || res.data
|
||
} else {
|
||
ElMessage.error(res?.message || '生成授权码失败')
|
||
}
|
||
} catch {
|
||
ElMessage.error('生成授权码失败')
|
||
} finally {
|
||
bindCodeDialog.loading = false
|
||
}
|
||
}
|
||
|
||
function copyBindCode() {
|
||
if (!bindCodeDialog.code) {
|
||
ElMessage.warning('暂无可复制的授权码')
|
||
return
|
||
}
|
||
copyText(`授权:${bindCodeDialog.code}`)
|
||
}
|
||
|
||
// ─── 初始化 ───────────────────────────────────────────────────────────────────
|
||
|
||
async function loadStoreOptions() {
|
||
try {
|
||
const res = await loadStores() as any
|
||
if (res?.code === 200 || res?.code === 1 || res?.code === 20000 || res?.flag === 'success') {
|
||
const stores = res?.stores || res?.data?.stores || res?.data || []
|
||
const field = availableFields.find((f: any) => f.value === 'store_id')
|
||
if (field) {
|
||
field.options = stores.map((item: any) => {
|
||
const id = item?.store_id ?? item?.id ?? item?.value
|
||
const name = item?.store_name ?? item?.name ?? item?.label ?? String(id)
|
||
return { label: name, value: id }
|
||
})
|
||
}
|
||
}
|
||
} catch (e) {
|
||
console.error('加载货主列表失败', e)
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
loadList()
|
||
loadStoreOptions()
|
||
// 恢复被中断的货主列表导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
|
||
listExportResume()
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
@use "@/styles/list-page.scss";
|
||
@use "@/styles/status-text.scss";
|
||
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
/* 详情区外壳不留上/下间距(各详情面板自带 padding,对齐 stock/external_stock) */
|
||
padding: 0 10px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
|
||
:deep(.store-detail-pane) {
|
||
flex: 1;
|
||
min-height: 0;
|
||
min-width: 0;
|
||
width: 100%;
|
||
overflow: hidden;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
}
|
||
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
line-height: 1.5;
|
||
max-width: 360px;
|
||
color: #909399;
|
||
}
|
||
|
||
.real-name {
|
||
color: #999;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.wave-operation-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 4px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
// ─── 加群授权码弹窗样式 ────────────────────────────────────────────────────────
|
||
.bind-code-control {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.bind-code-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
}
|
||
|
||
.bind-code-value {
|
||
flex: 1;
|
||
min-width: 0;
|
||
font-size: 24px;
|
||
font-weight: 700;
|
||
font-family: 'Courier New', Courier, monospace;
|
||
letter-spacing: 4px;
|
||
color: #303133;
|
||
user-select: all;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.bind-code-placeholder {
|
||
font-size: 13px;
|
||
color: #909399;
|
||
}
|
||
|
||
.text-muted {
|
||
color: #c0c4cc;
|
||
}
|
||
|
||
.text-warning {
|
||
color: #e6a23c;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.text-up {
|
||
color: var(--el-color-success);
|
||
font-weight: 600;
|
||
}
|
||
|
||
.text-down {
|
||
color: var(--el-color-danger);
|
||
font-weight: 600;
|
||
}
|
||
|
||
.text-flat {
|
||
color: var(--el-text-color-secondary);
|
||
}
|
||
|
||
.balance-log-panel {
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 100%;
|
||
height: 100%;
|
||
min-height: 0;
|
||
padding: 6px 10px 8px;
|
||
background: #fff;
|
||
overflow: hidden;
|
||
box-sizing: border-box;
|
||
|
||
/* 按钮行(间距 6px 对齐 toolbar),样式对齐 stock/external_stock */
|
||
.header-actions {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 6px;
|
||
flex-shrink: 0;
|
||
gap: 4px;
|
||
flex-wrap: wrap;
|
||
|
||
/* 筛选控件固定宽度、不参与拉伸:Element Plus 的 .el-select 默认 width:100%,
|
||
.el-date-editor 自带 flex-grow:1,放在弹性行里会被水平拉长。
|
||
下拉 110px;时间范围 340px(实测:完整 YYYY-MM-DD HH:mm:ss 每侧输入框需 ~118px,
|
||
340px 仍有富余,320px 为刚好放下,低于 300px 秒数会被截断) */
|
||
:deep(.el-select) {
|
||
width: 110px;
|
||
flex: 0 1 auto;
|
||
}
|
||
|
||
:deep(.el-date-editor) {
|
||
width: 340px;
|
||
flex: 0 1 auto;
|
||
}
|
||
}
|
||
|
||
.left-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
flex-wrap: wrap;
|
||
|
||
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制间距 */
|
||
:deep(.el-button) {
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
}
|
||
}
|
||
|
||
.table-host {
|
||
flex: 1;
|
||
min-height: 120px;
|
||
min-width: 0;
|
||
overflow: hidden;
|
||
display: flex;
|
||
flex-direction: column;
|
||
|
||
/* 对齐「商品明细」:表格自带 border,不需要卡片阴影/圆角;
|
||
UpperTable 行内分页需要确定高度 */
|
||
:deep(.upper-table-container) {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
box-shadow: none;
|
||
border-radius: 0;
|
||
}
|
||
|
||
:deep(.table-container) {
|
||
flex: 1;
|
||
min-height: 0;
|
||
height: auto !important;
|
||
}
|
||
|
||
/* 分页区:左侧「已选 N 项」+ 右侧分页器,无分隔线 */
|
||
:deep(.pagination-container) {
|
||
flex-shrink: 0;
|
||
padding: 0;
|
||
border-top: none;
|
||
margin-top: 6px;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
:deep(.pagination-info) {
|
||
font-size: 12px;
|
||
color: #606266;
|
||
}
|
||
|
||
/* 表格内部空态(#empty 插槽):交给 el-table 自身居中 */
|
||
.empty-tip {
|
||
height: auto;
|
||
display: block;
|
||
line-height: 1.5;
|
||
}
|
||
}
|
||
|
||
.open-account-form-grid {
|
||
.el-row {
|
||
width: 100%;
|
||
}
|
||
.el-form-item {
|
||
margin-bottom: 18px;
|
||
}
|
||
.username-field-row {
|
||
display: flex;
|
||
width: 100%;
|
||
gap: 6px;
|
||
align-items: center;
|
||
}
|
||
}
|
||
|
||
.appkey-cell {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
.appkey-text {
|
||
font-family: monospace;
|
||
font-size: 12px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
flex: 1;
|
||
}
|
||
}
|
||
|
||
.callback-url-row {
|
||
display: flex;
|
||
width: 100%;
|
||
gap: 8px;
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.appsecret-cell {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
.appsecret-text {
|
||
font-family: monospace;
|
||
font-size: 12px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
flex: 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
.sign-preview {
|
||
.sign-tip {
|
||
margin-top: 12px;
|
||
}
|
||
}
|
||
|
||
.qimen-summary {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.qimen-info {
|
||
margin-top: 4px;
|
||
font-size: 12px;
|
||
color: #888;
|
||
}
|
||
|
||
.qimen-form {
|
||
.el-input-number {
|
||
width: 100%;
|
||
}
|
||
}
|
||
|
||
:deep(.is-error-textarea .el-textarea__inner) {
|
||
border-color: #f56c6c;
|
||
}
|
||
|
||
.adjust-balance-number-field {
|
||
width: 100%;
|
||
}
|
||
|
||
.adjust-balance-delta-hint {
|
||
margin-top: 8px;
|
||
font-size: 13px;
|
||
line-height: 1.45;
|
||
|
||
&.is-up {
|
||
color: var(--el-color-success);
|
||
}
|
||
|
||
&.is-down {
|
||
color: var(--el-color-danger);
|
||
}
|
||
|
||
&.is-same {
|
||
color: var(--el-text-color-secondary);
|
||
}
|
||
|
||
&.is-neutral {
|
||
color: var(--el-text-color-secondary);
|
||
}
|
||
}
|
||
|
||
/* 修改备注弹窗:面板结构 / 尺寸对齐「手工录入运单号」(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;
|
||
|
||
/* 字段较多时面板内滚动(对齐新建波次策略) */
|
||
&--scroll {
|
||
max-height: 64vh;
|
||
overflow-y: auto;
|
||
}
|
||
}
|
||
|
||
&__form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
|
||
/* 双列栅格:每格一个「标签 + 控件」行,窄屏自动降为单列 */
|
||
&__grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
column-gap: 16px;
|
||
row-gap: 8px;
|
||
|
||
@media (max-width: 720px) {
|
||
grid-template-columns: minmax(0, 1fr);
|
||
}
|
||
}
|
||
|
||
&__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;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 开关 / 数字输入等控件行:与输入行同构,行高对齐 32px */
|
||
&--control {
|
||
align-items: center;
|
||
min-height: 0;
|
||
padding: 4px 0 0 12px;
|
||
border: none;
|
||
border-radius: 0;
|
||
background: transparent;
|
||
|
||
.task-panel__field-label {
|
||
padding-top: 7px;
|
||
}
|
||
}
|
||
|
||
/* 多行文本行:标签与文本域首行对齐 */
|
||
&--textarea {
|
||
.task-panel__field-label {
|
||
padding-top: 7px;
|
||
}
|
||
}
|
||
|
||
/* 整行占满(登录账号 / 公司全称 / 公司地址 / 申请原因) */
|
||
&--full {
|
||
grid-column: 1 / -1;
|
||
}
|
||
}
|
||
|
||
/* 标签列固定宽度:输入框左边缘与上方静态信息行的标签列对齐 */
|
||
&__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;
|
||
|
||
/* 只作参考/未填写的弱化文本 */
|
||
&.is-muted {
|
||
font-weight: 400;
|
||
color: #c0c4cc;
|
||
}
|
||
}
|
||
|
||
/* 可编辑字段组:结构与「手工录入运单号」的 task-panel__field-form 一致 */
|
||
&__form-fields {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
min-width: 0;
|
||
|
||
:deep(.el-form-item) {
|
||
flex: 1;
|
||
min-width: 0;
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
:deep(.el-form-item__content) {
|
||
margin-left: 0 !important;
|
||
width: 100%;
|
||
}
|
||
|
||
:deep(.el-input),
|
||
:deep(.el-select),
|
||
:deep(.el-textarea) {
|
||
width: 100%;
|
||
}
|
||
|
||
/* 校验提示改为占位显示,避免绝对定位覆盖下一条字段 */
|
||
:deep(.el-form-item__error) {
|
||
position: static;
|
||
padding-top: 2px;
|
||
}
|
||
}
|
||
|
||
/* 输入控件容器(双列栅格内使用):占满标签列右侧剩余宽度 */
|
||
&__field-form {
|
||
flex: 1;
|
||
min-width: 0;
|
||
max-width: none;
|
||
|
||
:deep(.el-form-item) {
|
||
flex: 1;
|
||
min-width: 0;
|
||
width: 100%;
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
:deep(.el-form-item__content) {
|
||
margin-left: 0 !important;
|
||
width: 100%;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
:deep(.el-form-item__error) {
|
||
position: static;
|
||
padding-top: 4px;
|
||
}
|
||
|
||
:deep(.el-input),
|
||
:deep(.el-select),
|
||
:deep(.el-input-number),
|
||
:deep(.el-date-editor) {
|
||
width: 100%;
|
||
}
|
||
|
||
/* 控件行:数字输入左对齐,行高与输入框(32px)一致 */
|
||
&--row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
min-height: 32px;
|
||
}
|
||
}
|
||
|
||
/* 行内「输入框 + 按钮」组合(如登录账号 + 随机生成) */
|
||
&__inline {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
width: 100%;
|
||
min-width: 0;
|
||
|
||
:deep(.el-button) {
|
||
margin-left: 0;
|
||
flex: none;
|
||
}
|
||
}
|
||
|
||
&__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;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 策略配置:后端字段名普遍较长,标签列放宽并允许换行,避免文字溢出压住控件(不影响其它弹窗) */
|
||
.task-panel--policy {
|
||
.task-panel__field {
|
||
/* 标签与控件之间留出安全间距,长标签换行时不与控件重叠 */
|
||
gap: 12px;
|
||
}
|
||
|
||
.task-panel__field-label {
|
||
flex: 0 0 104px;
|
||
width: 104px;
|
||
/* 覆盖全局 nowrap:字段名过长时折行,避免溢出覆盖右侧控件 */
|
||
white-space: normal;
|
||
word-break: break-word;
|
||
overflow-wrap: anywhere;
|
||
line-height: 18px;
|
||
}
|
||
|
||
.task-panel__field--input .task-panel__field-label,
|
||
.task-panel__field--control .task-panel__field-label {
|
||
/* 折行后标签首行与控件首行对齐 */
|
||
padding-top: 6px;
|
||
}
|
||
|
||
.task-panel__field-help {
|
||
display: inline-block;
|
||
margin-left: 2px;
|
||
font-size: 12px;
|
||
color: #c0c4cc;
|
||
vertical-align: -2px;
|
||
cursor: help;
|
||
}
|
||
|
||
.task-panel__field-value {
|
||
/* 长货主名称在静态行内折行,不顶到标签 */
|
||
min-width: 0;
|
||
overflow-wrap: anywhere;
|
||
}
|
||
|
||
.task-panel__field-value.is-danger {
|
||
color: #f56c6c;
|
||
}
|
||
|
||
.task-panel__field-error {
|
||
margin-top: 4px;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #f56c6c;
|
||
}
|
||
}
|
||
/* 接口配置表:APPKEY / APPSECRET 单元格内容居中(含复制按钮) */
|
||
.appkey-cell,
|
||
.appsecret-cell {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 6px;
|
||
min-width: 0;
|
||
|
||
.appkey-text,
|
||
.appsecret-text {
|
||
font-family: monospace;
|
||
font-size: 12px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
}
|
||
|
||
/* 接口配置表单:回调地址 + 调试文档同一行 */
|
||
.callback-url-row {
|
||
display: flex;
|
||
width: 100%;
|
||
gap: 8px;
|
||
align-items: center;
|
||
}
|
||
</style>
|
||
|
||
<style lang="scss">
|
||
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
|
||
.el-dialog.rename-store-dialog,
|
||
.el-dialog.adjust-balance-dialog,
|
||
.el-dialog.open-account-dialog,
|
||
.el-dialog.create-user-dialog,
|
||
.el-dialog.policy-config-dialog,
|
||
.el-dialog.bind-code-dialog,
|
||
.el-dialog.qimen-config-dialog {
|
||
padding: 0;
|
||
overflow: hidden;
|
||
|
||
.el-dialog__header {
|
||
display: none;
|
||
}
|
||
|
||
.el-dialog__body {
|
||
padding: 0;
|
||
}
|
||
}
|
||
</style> |