1117 lines
40 KiB
Vue
1117 lines
40 KiB
Vue
<template>
|
||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||
<scan-box
|
||
ref="scanBox"
|
||
cache-key="warehouses-list"
|
||
width="220px"
|
||
title="仓库筛选"
|
||
:auto-submit="false"
|
||
:preset-tree="presetTree"
|
||
:available-fields="availableFields"
|
||
:initial-conditions="{ store_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="warehouses-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.warehouse_name || row.remask || row.counterparty_name }}</span>
|
||
<span
|
||
v-if="(row.warehouse_name || row.remask) && row.counterparty_name && (row.warehouse_name || row.remask) !== row.counterparty_name"
|
||
class="real-name"
|
||
>({{ row.counterparty_name }})</span>
|
||
</template>
|
||
<template #column-auth_status="{ row }">
|
||
<el-tag size="small" :type="getAuthStatusType(row.auth_status)" effect="light">
|
||
{{ row.auth_status_label || getAuthStatusLabel(row.auth_status) }}
|
||
</el-tag>
|
||
</template>
|
||
<template #column-needs_my_confirm="{ row }">
|
||
<el-tag v-if="row.needs_my_confirm" size="small" type="warning" effect="dark">待我确认</el-tag>
|
||
<span v-else class="text-muted">—</span>
|
||
</template>
|
||
<template #column-store_use_status="{ row }">
|
||
<el-tag size="small" :type="row.store_use_status === 1 ? 'success' : 'info'" effect="light">
|
||
{{ row.store_use_status === 1 ? '启用' : '禁用' }}
|
||
</el-tag>
|
||
</template>
|
||
<template #column-auth_end="{ row }">
|
||
<span :class="{ 'text-danger': isExpired(row.auth_end) }">{{ row.auth_end || '—' }}</span>
|
||
</template>
|
||
<template #column-print_quantity="{ row }">
|
||
{{ row.print_quantity ?? '—' }}
|
||
</template>
|
||
<template #column-has_qimen_config="{ row }">
|
||
<el-tag
|
||
size="small"
|
||
:type="row.has_qimen_config ? 'success' : 'info'"
|
||
effect="plain"
|
||
@click.stop="openQimenDialog(row)"
|
||
style="cursor:pointer"
|
||
>
|
||
{{ row.has_qimen_config ? '已配置' : '未配置' }}
|
||
</el-tag>
|
||
</template>
|
||
<template #column-actions="{ row }">
|
||
<div class="wave-operation-actions">
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
link
|
||
@click.stop="handleRename(row)"
|
||
>修改备注</el-button>
|
||
<el-button
|
||
v-if="row.needs_my_confirm"
|
||
size="small"
|
||
type="warning"
|
||
link
|
||
@click.stop="handleConfirmSign(row)"
|
||
>确认签约</el-button>
|
||
<el-button
|
||
v-if="row.store_use_status === 1 && row.auth_status !== 1"
|
||
size="small"
|
||
type="danger"
|
||
link
|
||
@click.stop="handleUnbind(row, 0)"
|
||
>禁用</el-button>
|
||
<el-button
|
||
v-else-if="row.store_use_status === 0 && row.auth_status !== 1"
|
||
size="small"
|
||
type="success"
|
||
link
|
||
@click.stop="handleUnbind(row, 1)"
|
||
>启用</el-button>
|
||
<span v-else class="text-muted">—</span>
|
||
</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="logs" />
|
||
</el-tabs>
|
||
</div>
|
||
|
||
<div class="detail-container">
|
||
<el-descriptions v-if="activeTab === 'details'" :column="2" border size="small">
|
||
<el-descriptions-item label="签约ID">{{ selectedRow.id }}</el-descriptions-item>
|
||
<el-descriptions-item label="签约状态">
|
||
<el-tag size="small" :type="getAuthStatusType(selectedRow.auth_status)" effect="light">
|
||
{{ selectedRow.auth_status_label || getAuthStatusLabel(selectedRow.auth_status) }}
|
||
</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="签约仓库">{{ selectedRow.warehouse_name || selectedRow.remask || selectedRow.counterparty_name || '—' }}</el-descriptions-item>
|
||
<el-descriptions-item v-if="currentSubject.company_name" label="当前货主">
|
||
{{ currentSubject.company_name }}
|
||
<el-tag size="small" type="warning" effect="plain" style="margin-left:6px">货主方</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="仓库ID">{{ selectedRow.warehouse_id }}</el-descriptions-item>
|
||
<el-descriptions-item label="使用状态">
|
||
<el-tag size="small" :type="selectedRow.store_use_status === 1 ? 'success' : 'info'" effect="light">
|
||
{{ selectedRow.store_use_status === 1 ? '启用' : '禁用' }}
|
||
</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="授权截止">
|
||
<span :class="{ 'text-danger': isExpired(selectedRow.auth_end) }">{{ selectedRow.auth_end || '—' }}</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="面单余额">{{ selectedRow.print_quantity ?? '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="奇门配置">
|
||
<el-tag size="small" :type="selectedRow.has_qimen_config ? 'success' : 'info'" effect="plain">
|
||
{{ selectedRow.has_qimen_config ? '已配置' : '未配置' }}
|
||
</el-tag>
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
<div v-else class="log-placeholder">
|
||
<div class="log-toolbar">
|
||
<el-pagination
|
||
v-if="logPagination.total > 0"
|
||
v-model:current-page="logPagination.currentPage"
|
||
v-model:page-size="logPagination.pageSize"
|
||
:total="logPagination.total"
|
||
:page-sizes="[10, 20, 50]"
|
||
layout="total, sizes, prev, pager, next"
|
||
size="small"
|
||
@current-change="loadLogs"
|
||
@size-change="handleLogSizeChange"
|
||
/>
|
||
</div>
|
||
<el-table :data="logList" v-loading="logLoading" size="small" border max-height="220">
|
||
<el-table-column prop="id" label="ID" width="70" />
|
||
<el-table-column prop="business_type" label="业务类型" min-width="100">
|
||
<template #default="{ row }">{{ row.business_type || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="change_quantity" label="变更数量" width="100" />
|
||
<el-table-column prop="before_quantity" label="变更前面单余额" width="130" />
|
||
<el-table-column prop="after_quantity" label="变更后面单余额" width="130" />
|
||
<el-table-column prop="reason" label="变更原因" min-width="140">
|
||
<template #default="{ row }">{{ row.reason || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="operator_name" label="操作人" width="100">
|
||
<template #default="{ row }">{{ row.operator_name || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="created_at" label="操作时间" width="170">
|
||
<template #default="{ row }">{{ row.created_at || '—' }}</template>
|
||
</el-table-column>
|
||
<template #empty>
|
||
<el-empty description="暂无操作日志" :image-size="40" />
|
||
</template>
|
||
</el-table>
|
||
<el-pagination
|
||
v-if="logPagination.total > 0"
|
||
v-model:current-page="logPagination.currentPage"
|
||
v-model:page-size="logPagination.pageSize"
|
||
:total="logPagination.total"
|
||
:page-sizes="[10, 20, 50]"
|
||
layout="total, sizes, prev, pager, next"
|
||
size="small"
|
||
style="margin-top:8px;justify-content:flex-end"
|
||
@current-change="loadLogs"
|
||
@size-change="handleLogSizeChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="no-selection" v-else :style="lowerPaneStyle">
|
||
<div class="empty-tip">
|
||
<p>请从上方列表中选择一项查看详情</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 发起签约弹窗 -->
|
||
<el-dialog
|
||
v-model="signDialog.visible"
|
||
:title="signDialog.title"
|
||
width="480px"
|
||
align-center
|
||
:close-on-click-modal="false"
|
||
@close="resetSignDialog"
|
||
>
|
||
<template v-if="signDialog.step === 1">
|
||
<el-form :model="signForm" label-width="100px" size="small">
|
||
<el-form-item label="对方主体ID" required>
|
||
<el-input-number v-model.number="signForm.counterparty_id" placeholder="请输入对方主体ID" style="width: 100%" :controls="false" />
|
||
</el-form-item>
|
||
</el-form>
|
||
</template>
|
||
|
||
<!-- 预览结果 / 提交结果 -->
|
||
<template v-else-if="signDialog.step === 2">
|
||
<div class="sign-preview">
|
||
<!-- 预览模式:展示双方主体信息 -->
|
||
<template v-if="signDialog.signMode === 'preview'">
|
||
<el-descriptions :column="1" border size="small">
|
||
<el-descriptions-item label="己方(货主)">
|
||
{{ signDialog.currentSubject?.company_name || '—' }}
|
||
<el-tag size="small" type="warning" effect="plain" style="margin-left:6px">货主方</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="对方(仓库)">
|
||
{{ signDialog.counterparty?.company_name || '—' }}
|
||
<el-tag size="small" type="primary" effect="plain" style="margin-left:6px">仓库方</el-tag>
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
<div class="sign-tip">
|
||
<el-alert type="info" :closable="false" show-icon>
|
||
<template #default>请确认签约信息,确认无误后点击「确认提交」。</template>
|
||
</el-alert>
|
||
</div>
|
||
</template>
|
||
<!-- 提交后:展示合同信息 -->
|
||
<template v-else>
|
||
<el-descriptions :column="2" border size="small">
|
||
<el-descriptions-item label="签约ID">{{ signDialog.contract?.id || '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="签约状态">
|
||
<el-tag size="small" :type="getAuthStatusType(signDialog.contract?.auth_status)">
|
||
{{ signDialog.contract?.auth_status_label || '—' }}
|
||
</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="仓库">{{ signDialog.contract?.warehouse_name || signDialog.contract?.counterparty_name || '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="货主">{{ signDialog.contract?.store_name || '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="备注">{{ signDialog.contract?.remask || '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="面单余额">{{ signDialog.contract?.print_quantity ?? '—' }}</el-descriptions-item>
|
||
</el-descriptions>
|
||
<div class="sign-tip">
|
||
<el-alert
|
||
v-if="signDialog.signMode === 'initiate'"
|
||
type="info" :closable="false" show-icon
|
||
>
|
||
<template #default>已提交申请,等待对方确认。</template>
|
||
</el-alert>
|
||
<el-alert
|
||
v-else-if="signDialog.signMode === 'already_exists'"
|
||
type="warning" :closable="false" show-icon
|
||
>
|
||
<template #default>对方已发起签约申请,等待处理。</template>
|
||
</el-alert>
|
||
<el-alert
|
||
v-else-if="signDialog.signMode === 'already_confirmed'"
|
||
type="success" :closable="false" show-icon
|
||
>
|
||
<template #default>该签约已完成,无需重复提交。</template>
|
||
</el-alert>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</template>
|
||
|
||
<template #footer>
|
||
<div class="dialog-footer">
|
||
<!-- Step 1: 填写信息 -->
|
||
<template v-if="signDialog.step === 1">
|
||
<el-button size="small" @click="signDialog.visible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="signDialog.loading" @click="doPreviewSign">
|
||
预览
|
||
</el-button>
|
||
</template>
|
||
<!-- Step 2: 预览结果 -->
|
||
<template v-else-if="signDialog.step === 2">
|
||
<el-button size="small" @click="goBackToStep1">返回</el-button>
|
||
<el-button
|
||
v-if="signDialog.signMode === 'preview'"
|
||
size="small"
|
||
type="primary"
|
||
:loading="signDialog.loading"
|
||
@click="doSubmitSign"
|
||
>确认提交</el-button>
|
||
<el-button v-else size="small" @click="signDialog.visible = false">关闭</el-button>
|
||
</template>
|
||
</div>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 奇门接口配置查看弹窗 -->
|
||
<el-dialog
|
||
v-model="qimenDialog.visible"
|
||
:title="`接口配置查看 — ${qimenDialog.contractRow?.warehouse_name || qimenDialog.contractRow?.remask || qimenDialog.contractRow?.counterparty_name || ''}`"
|
||
width="90%"
|
||
align-center
|
||
:close-on-click-modal="false"
|
||
@close="resetQimenDialog"
|
||
>
|
||
<div style="display:flex;justify-content:flex-end;margin-bottom:10px">
|
||
<el-button size="small" @click="loadQimenConfigs">
|
||
<el-icon><Refresh /></el-icon> 刷新
|
||
</el-button>
|
||
</div>
|
||
<el-table :data="qimenDialog.list" v-loading="qimenDialog.loading" size="small" border>
|
||
<el-table-column prop="app_name" label="应用名称" min-width="120" />
|
||
<el-table-column prop="interface_name" label="接口类型" width="130" />
|
||
<el-table-column label="ERP" min-width="110">
|
||
<template #default="{ row }">{{ row.erp_display || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="货主编码" min-width="150">
|
||
<template #default="{ row }">
|
||
<div class="copy-cell">
|
||
<span class="copy-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 label="仓库编码" min-width="130">
|
||
<template #default="{ row }">
|
||
<div class="copy-cell">
|
||
<span class="copy-text">{{ row.qimen_warehouse_code || '—' }}</span>
|
||
<el-button v-if="row.qimen_warehouse_code" size="small" type="primary" link @click="copyText(row.qimen_warehouse_code)">复制</el-button>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="APPKEY" min-width="200">
|
||
<template #default="{ row }">
|
||
<div class="copy-cell">
|
||
<span class="copy-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="150">
|
||
<template #default="{ row }">
|
||
<div class="copy-cell">
|
||
<template v-if="visibleSecrets[row.id || row.interface_type_id]">
|
||
<span class="copy-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 }">
|
||
<el-tag size="small" :type="row.is_enabled ? 'success' : 'info'">{{ row.is_enabled ? '启用' : '停用' }}</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<template #empty>
|
||
<el-empty description="暂无奇门配置" :image-size="50" />
|
||
</template>
|
||
</el-table>
|
||
<template #footer>
|
||
<el-button size="small" @click="qimenDialog.visible = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<AsyncExportProgressDialog
|
||
v-model:visible="exportDialogVisible"
|
||
title="面单日志导出进度"
|
||
:loading="exportLoading"
|
||
:progress-percent="exportProgressPercent"
|
||
:progress-status="exportProgressStatus"
|
||
:status-label="exportStatusLabel"
|
||
:task-id="exportTaskProgress.taskId"
|
||
:message="exportTaskProgress.message"
|
||
:error="exportTaskProgress.error"
|
||
:update-time="exportTaskProgress.updateTime"
|
||
/>
|
||
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, reactive, onMounted, computed, watch } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import {
|
||
warehouseList,
|
||
storeWarehouseSign,
|
||
storeWarehouseConfirmSign,
|
||
storeWarehouseUnbind,
|
||
storeWarehouseRename,
|
||
listApiConfig,
|
||
storeWarehouseExportStorePrintQuantityLogs,
|
||
storeWarehouseExportStorePrintQuantityLogsTaskProgress,
|
||
storeWarehouseQueryStorePrintQuantityLogs
|
||
} from '@/api/storewarehouse.store/storeWarehouse'
|
||
import { listInterfaceTypes, getQimenAppList } from '@/api/index/index'
|
||
import ScanBox from '@/components/ScanBox/index.vue'
|
||
import UpperTable from '@/components/UpperTable/index.vue'
|
||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||
import { useSettingsStore } from '@/stores/modules/settings'
|
||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
|
||
const settingsStore = useSettingsStore()
|
||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||
|
||
const {
|
||
splitStackRef,
|
||
beginSplitDrag,
|
||
lowerPaneStyle,
|
||
upperPaneStyle,
|
||
} = useVerticalSplitPane({ defaultLowerPercent: 35 })
|
||
|
||
const upperPaneFullStyle = computed(() => ({
|
||
flex: '1 1 auto',
|
||
minHeight: '0',
|
||
overflow: 'hidden',
|
||
}))
|
||
|
||
const detailVisible = ref(true)
|
||
|
||
const toolbarButtons: ToolbarButtonConfig[] = [
|
||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadList' },
|
||
{
|
||
key: 'toggleDetail',
|
||
label: '显示详情',
|
||
dynamicLabelKey: 'detailToggleLabel',
|
||
category: 'setting',
|
||
size: 'small',
|
||
action: 'toggleDetailVisible'
|
||
},
|
||
{ key: 'openSign', label: '发起签约', category: 'action', size: 'small', action: 'openSignDialog' },
|
||
{ key: 'exportLogs', label: '导出日志', category: 'action', size: 'small', loadingKey: 'exportLoading', action: 'handleExportLogs' },
|
||
]
|
||
|
||
// ─── 工具栏状态管理 ──────────────────────────────────────────────────────────
|
||
const buttonLoadingMap = computed(() => ({
|
||
loading: loading.value,
|
||
exportLoading: exportLoading.value
|
||
}))
|
||
|
||
const buttonDisabledMap = computed(() => ({}))
|
||
|
||
const buttonLabelMap = computed(() => ({
|
||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||
}))
|
||
|
||
const toolbarLayoutKey = computed(() =>
|
||
JSON.stringify({
|
||
loading: buttonLoadingMap.value,
|
||
disabled: buttonDisabledMap.value,
|
||
labels: buttonLabelMap.value
|
||
})
|
||
)
|
||
|
||
function resolveButtonLoading(loadingKey?: string) {
|
||
if (!loadingKey) return false
|
||
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
|
||
}
|
||
|
||
function resolveButtonDisabled(disabledKey?: string) {
|
||
if (!disabledKey) return false
|
||
return Boolean((buttonDisabledMap.value as Record<string, boolean>)[disabledKey])
|
||
}
|
||
|
||
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||
if (!dynamicLabelKey) return defaultLabel
|
||
return (buttonLabelMap.value as Record<string, string>)[dynamicLabelKey] || defaultLabel
|
||
}
|
||
|
||
function toggleDetailVisible() {
|
||
detailVisible.value = !detailVisible.value
|
||
}
|
||
|
||
const toolbarActionMap: Record<string, () => void> = {
|
||
loadList: () => { void loadList() },
|
||
openSignDialog: () => openSignDialog(),
|
||
handleExportLogs: () => { void handleExportLogs() },
|
||
toggleDetailVisible: () => toggleDetailVisible()
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
|
||
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
|
||
const columns = [
|
||
{ prop: 'counterparty_name', label: '签约仓库', minWidth: 140 },
|
||
{ prop: 'auth_status', label: '签约状态', width: 100 },
|
||
{ prop: 'needs_my_confirm', label: '待确认', width: 90 },
|
||
{ prop: 'store_use_status', label: '使用状态', width: 90 },
|
||
{ prop: 'print_quantity', label: '面单余额', width: 100 },
|
||
{ prop: 'has_qimen_config', label: '奇门配置', width: 100 },
|
||
{ prop: 'auth_end', label: '授权截止', width: 120 },
|
||
{ prop: 'actions', label: '操作', width: 280, fixed: 'right' }
|
||
]
|
||
|
||
// ─── 筛选字段配置 ─────────────────────────────────────────────────────────
|
||
const availableFields = [
|
||
{
|
||
label: '关键词',
|
||
value: 'keyword',
|
||
type: 'text',
|
||
group: '基础信息',
|
||
placeholder: '搜索仓库名或备注'
|
||
},
|
||
{
|
||
label: '签约状态',
|
||
value: 'auth_status',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '待审核', value: 1 },
|
||
{ label: '已通过', value: 2 },
|
||
{ label: '已拒绝', value: 3 },
|
||
{ label: '已解除', value: 4 },
|
||
{ label: '已过期', value: 5 }
|
||
]
|
||
},
|
||
{
|
||
label: '使用状态',
|
||
value: 'store_use_status',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '全部', value: undefined },
|
||
{ label: '启用', value: 1 },
|
||
{ label: '禁用', value: 0 }
|
||
]
|
||
}
|
||
]
|
||
|
||
const presetTree: any[] = []
|
||
|
||
// ─── 当前主体信息(从列表接口返回) ────────────────────────────────────────
|
||
const currentSubject = ref<{ store_id?: number; company_name?: string; role?: string }>({})
|
||
|
||
// ─── 列表状态 ──────────────────────────────────────────────────────────────
|
||
const loading = ref(false)
|
||
const queryTime = ref(0)
|
||
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
||
const list = ref<any[]>([])
|
||
const selectionRows = ref<any[]>([])
|
||
const selectedRow = ref<any>(null)
|
||
const tableRef = ref<any>(null)
|
||
const scanBox = ref<any>(null)
|
||
const activeTab = ref('details')
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const currentCondition = ref<any>({ store_use_status: 1 })
|
||
|
||
// ─── 操作日志状态 ──────────────────────────────────────────────────────────
|
||
const logLoading = ref(false)
|
||
const logList = ref<any[]>([])
|
||
const logPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
|
||
// ─── 导出日志(异步任务) ──────────────────────────────────────────────────
|
||
const {
|
||
exportLoading,
|
||
exportDialogVisible,
|
||
exportTaskProgress,
|
||
exportProgressPercent,
|
||
exportProgressStatus,
|
||
exportStatusLabel,
|
||
submitExportTask
|
||
} = useAsyncExportTask({
|
||
storageKey: 'warehouses:exportLogsTaskId',
|
||
submitExport: (payload) => storeWarehouseExportStorePrintQuantityLogs(payload as any),
|
||
queryProgress: (params) => storeWarehouseExportStorePrintQuantityLogsTaskProgress(params)
|
||
})
|
||
|
||
// ─── 加载列表 ──────────────────────────────────────────────────────────────
|
||
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 warehouseList(params) as any
|
||
if (res?.data) {
|
||
const payload = res.data
|
||
list.value = payload.list || []
|
||
pagination.total = payload.pagination?.total || payload.total || 0
|
||
pagination.currentPage = payload.pagination?.page || payload.page || pagination.currentPage
|
||
pagination.pageSize = payload.pagination?.pageSize || payload.page_size || pagination.pageSize
|
||
if (payload.current_subject) {
|
||
currentSubject.value = payload.current_subject
|
||
}
|
||
}
|
||
} catch (e) {
|
||
ElMessage.error('获取列表失败')
|
||
} finally {
|
||
queryTime.value = Date.now() - startTime
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function isExpired(dateStr: string): boolean {
|
||
if (!dateStr) return false
|
||
const d = new Date(dateStr)
|
||
if (isNaN(d.getTime())) return false
|
||
return d < new Date()
|
||
}
|
||
|
||
function handleConditionChange(condition: any) {
|
||
const where: any = {}
|
||
if (condition) {
|
||
Object.keys(condition).forEach(k => {
|
||
const c = condition[k]
|
||
if (c && typeof c === 'object' && !Array.isArray(c) && c.value !== undefined) {
|
||
if (c.value !== '' && c.value !== null && c.value !== undefined) {
|
||
where[k] = c.value
|
||
}
|
||
} else if (c !== '' && c !== null && c !== undefined) {
|
||
where[k] = c
|
||
}
|
||
})
|
||
}
|
||
currentCondition.value = where
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleSubmit() {
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleConditionClear() {
|
||
currentCondition.value = {}
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleReset() {
|
||
currentCondition.value = {}
|
||
pagination.currentPage = 1
|
||
if (scanBox.value?.reset) {
|
||
scanBox.value.reset()
|
||
} else if (scanBox.value?.clear) {
|
||
scanBox.value.clear()
|
||
}
|
||
loadList()
|
||
}
|
||
|
||
function handlePageChange(page: number) {
|
||
pagination.currentPage = page
|
||
loadList()
|
||
}
|
||
|
||
function handleSizeChange(size: number) {
|
||
pagination.pageSize = size
|
||
pagination.currentPage = 1
|
||
loadList()
|
||
}
|
||
|
||
function handleRowClick(row: any) {
|
||
selectedRow.value = row
|
||
}
|
||
|
||
function handleSortChange(_sort: { prop: string; order: string }) {
|
||
// 预留排序事件处理
|
||
}
|
||
|
||
function handleSelectionChange(rows: any[]) {
|
||
selectionRows.value = rows || []
|
||
}
|
||
|
||
// ─── 工具函数 ──────────────────────────────────────────────────────────────
|
||
function getAuthStatusType(status: number): string {
|
||
const map: Record<number, string> = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info', 5: 'danger' }
|
||
return map[status] || 'info'
|
||
}
|
||
|
||
function getAuthStatusLabel(status: number): string {
|
||
const map: Record<number, string> = { 1: '待审核', 2: '已通过', 3: '已拒绝', 4: '已解除', 5: '已过期' }
|
||
return map[status] || '未知'
|
||
}
|
||
|
||
// ─── 启用/禁用 ─────────────────────────────────────────────────────────────
|
||
async function handleUnbind(row: any, targetStatus: number) {
|
||
const action = targetStatus === 1 ? '启用' : '禁用'
|
||
try {
|
||
await ElMessageBox.confirm(`确认${action}该签约关系?`, '提示', { type: 'warning' })
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
await storeWarehouseUnbind({ id: row.id, store_use_status: targetStatus })
|
||
ElMessage.success(`${action}成功`)
|
||
loadList()
|
||
} catch (e) {
|
||
ElMessage.error(`${action}失败`)
|
||
}
|
||
}
|
||
|
||
// ─── 修改备注 ──────────────────────────────────────────────────────────────
|
||
async function handleRename(row: any) {
|
||
try {
|
||
const { value } = await ElMessageBox.prompt('请输入新的备注名', '修改备注', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
inputValue: row.remask || ''
|
||
})
|
||
if (value != null) {
|
||
await storeWarehouseRename({ id: row.id, remask: value })
|
||
ElMessage.success('备注修改成功')
|
||
loadList()
|
||
}
|
||
} catch {
|
||
// 用户取消
|
||
}
|
||
}
|
||
|
||
// ─── 发起签约 ──────────────────────────────────────────────────────────────
|
||
const signDialog = reactive({
|
||
visible: false,
|
||
title: '发起签约',
|
||
step: 1,
|
||
loading: false,
|
||
signMode: '' as string,
|
||
temp_code: '' as string,
|
||
contract: null as any,
|
||
currentSubject: null as any,
|
||
counterparty: null as any
|
||
})
|
||
|
||
const signForm = reactive({
|
||
counterparty_id: undefined as number | undefined
|
||
})
|
||
|
||
function openSignDialog() {
|
||
signDialog.visible = true
|
||
signDialog.step = 1
|
||
signDialog.title = '发起签约'
|
||
signDialog.signMode = ''
|
||
signDialog.temp_code = ''
|
||
signDialog.contract = null
|
||
signDialog.currentSubject = null
|
||
signDialog.counterparty = null
|
||
signForm.counterparty_id = undefined
|
||
}
|
||
|
||
function resetSignDialog() {
|
||
signForm.counterparty_id = undefined
|
||
signDialog.step = 1
|
||
signDialog.loading = false
|
||
signDialog.temp_code = ''
|
||
}
|
||
|
||
async function doPreviewSign() {
|
||
if (!signForm.counterparty_id) {
|
||
ElMessage.warning('请输入对方主体ID')
|
||
return
|
||
}
|
||
signDialog.loading = true
|
||
try {
|
||
const res = await storeWarehouseSign({
|
||
counterparty_id: signForm.counterparty_id
|
||
}) as any
|
||
if (res?.data) {
|
||
const d = res.data
|
||
signDialog.signMode = d.mode || ''
|
||
signDialog.temp_code = d.temp_code || ''
|
||
signDialog.contract = d.contract || null
|
||
signDialog.currentSubject = d.current_subject || null
|
||
signDialog.counterparty = d.counterparty || null
|
||
signDialog.step = 2
|
||
signDialog.title = '签约预览'
|
||
}
|
||
} catch (e) {
|
||
ElMessage.error('获取预览失败')
|
||
} finally {
|
||
signDialog.loading = false
|
||
}
|
||
}
|
||
|
||
async function doSubmitSign() {
|
||
if (!signForm.counterparty_id) {
|
||
ElMessage.warning('缺少对方主体ID')
|
||
return
|
||
}
|
||
signDialog.loading = true
|
||
try {
|
||
const payload: { counterparty_id: number; temp_code?: string } = {
|
||
counterparty_id: signForm.counterparty_id
|
||
}
|
||
if (signDialog.temp_code) {
|
||
payload.temp_code = signDialog.temp_code
|
||
}
|
||
await storeWarehouseSign(payload)
|
||
ElMessage.success('签约申请已提交')
|
||
signDialog.visible = false
|
||
loadList()
|
||
} catch (e) {
|
||
ElMessage.error('提交签约失败')
|
||
} finally {
|
||
signDialog.loading = false
|
||
}
|
||
}
|
||
|
||
function goBackToStep1() {
|
||
signDialog.step = 1
|
||
signDialog.signMode = ''
|
||
signDialog.temp_code = ''
|
||
signDialog.contract = null
|
||
signDialog.currentSubject = null
|
||
signDialog.counterparty = null
|
||
}
|
||
|
||
async function handleConfirmSign(row: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确认与「${row.warehouse_name || row.remask || row.counterparty_name}」的签约关系?`,
|
||
'确认签约',
|
||
{ type: 'warning' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
await storeWarehouseConfirmSign({ id: row.id })
|
||
ElMessage.success('签约已确认')
|
||
loadList()
|
||
} catch (e) {
|
||
ElMessage.error('确认签约失败')
|
||
}
|
||
}
|
||
|
||
// ─── 奇门接口配置查看 ──────────────────────────────────────────────────────
|
||
const qimenDialog = reactive({
|
||
visible: false,
|
||
loading: false,
|
||
contractRow: null as any,
|
||
list: [] as any[],
|
||
availableTypes: [] as any[]
|
||
})
|
||
const qimenAppOptions = ref<Array<{ label: string; value: string }>>([])
|
||
const visibleSecrets = reactive<Record<string | number, boolean>>({})
|
||
|
||
function toggleSecret(row: any) {
|
||
const key = row.id || row.interface_type_id
|
||
visibleSecrets[key] = !visibleSecrets[key]
|
||
}
|
||
|
||
function openQimenDialog(row: any) {
|
||
qimenDialog.contractRow = row
|
||
qimenDialog.list = []
|
||
qimenDialog.visible = true
|
||
void loadQimenAppOptions()
|
||
loadQimenConfigs()
|
||
}
|
||
|
||
function resetQimenDialog() {
|
||
qimenDialog.contractRow = null
|
||
qimenDialog.list = []
|
||
qimenDialog.availableTypes = []
|
||
qimenAppOptions.value = []
|
||
}
|
||
|
||
function getQimenErpDisplay(config: any): string {
|
||
return String(config?.erp_name || config?.erpName || config?.qimen_app_key || '').trim()
|
||
}
|
||
|
||
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>
|
||
])
|
||
const serverTypes: any[] = Array.isArray(typesRes?.list) ? typesRes.list : []
|
||
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)
|
||
}))
|
||
;(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
|
||
}
|
||
}
|
||
|
||
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 loadLogs() {
|
||
if (!selectedRow.value?.id) return
|
||
logLoading.value = true
|
||
try {
|
||
const res = await storeWarehouseQueryStorePrintQuantityLogs({
|
||
where: { id: selectedRow.value.id },
|
||
pagination: {
|
||
page: logPagination.currentPage,
|
||
page_size: logPagination.pageSize
|
||
}
|
||
}) as any
|
||
if (res?.data) {
|
||
const payload = res.data
|
||
logList.value = payload.list || []
|
||
logPagination.total = payload.pagination?.total || payload.total || 0
|
||
}
|
||
} catch {
|
||
ElMessage.error('获取操作日志失败')
|
||
} finally {
|
||
logLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleLogSizeChange() {
|
||
logPagination.currentPage = 1
|
||
loadLogs()
|
||
}
|
||
|
||
// 监听 tab 切换,切换到操作日志时自动加载
|
||
watch(activeTab, (val) => {
|
||
if (val === 'logs' && selectedRow.value) {
|
||
logPagination.currentPage = 1
|
||
loadLogs()
|
||
}
|
||
})
|
||
|
||
watch(selectedRow, (row) => {
|
||
if (row && activeTab.value === 'logs') {
|
||
logPagination.currentPage = 1
|
||
loadLogs()
|
||
}
|
||
})
|
||
|
||
// ─── 导出操作日志 ──────────────────────────────────────────────────────────
|
||
async function handleExportLogs() {
|
||
if (!selectedRow.value?.id) {
|
||
ElMessage.warning('请先选择一条签约记录')
|
||
return
|
||
}
|
||
await submitExportTask({
|
||
where: { id: selectedRow.value.id }
|
||
})
|
||
}
|
||
|
||
// ─── 初始化 ────────────────────────────────────────────────────────────────
|
||
onMounted(() => {
|
||
loadList()
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use "../order/orderManagement/styles/order-sub.scss";
|
||
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
padding: 6px 10px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
overflow: auto;
|
||
flex: 1;
|
||
min-height: 0;
|
||
}
|
||
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
color: #909399;
|
||
padding: 16px;
|
||
}
|
||
|
||
.real-name {
|
||
color: #999;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.wave-operation-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 4px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.text-muted {
|
||
color: #c0c4cc;
|
||
}
|
||
|
||
.text-danger {
|
||
color: #f56c6c;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.sign-preview {
|
||
.sign-tip {
|
||
margin-top: 16px;
|
||
}
|
||
}
|
||
|
||
.copy-cell {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
.copy-text {
|
||
font-family: monospace;
|
||
font-size: 12px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
flex: 1;
|
||
}
|
||
}
|
||
</style>
|