380 lines
12 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="shipper-signing-container">
<scan-box
ref="scanBox"
width="220px"
title="货主筛选"
:preset-tree="presetTree"
:available-fields="availableFields"
:initial-conditions="{ use_status: 1 }"
@condition-change="handleConditionChange"
@reset="handleReset"
/>
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-tag v-if="currentSubject.company_name" size="small" type="primary" effect="plain">
当前仓库:{{ currentSubject.company_name }}
</el-tag>
<el-button size="small" @click="loadList">
<el-icon><Refresh /></el-icon> 刷新
</el-button>
</div>
<div class="toolbar-right">
<el-input
v-model="queryForm.keyword"
placeholder="搜索货主名或备注"
clearable
size="small"
style="width: 200px"
@keyup.enter="handleSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
</div>
</div>
<div class="upper-wrapper">
<upper-table
ref="tableRef"
default-align="center"
:data="list"
:columns="columns"
:loading="loading"
:pagination="pagination"
@current-change="handleRowClick"
@page-change="handlePageChange"
@page-size-change="handleSizeChange"
>
<template #column-counterparty_name="{ row }">
<span>{{ row.remask || row.counterparty_name }}</span>
<span v-if="row.remask && row.remask !== row.counterparty_name" class="real-name">({{ row.counterparty_name }})</span>
</template>
<template #column-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-use_status="{ row }">
<el-tag size="small" :type="row.use_status === 1 ? 'success' : 'info'" effect="light">
{{ row.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">
{{ row.has_qimen_config ? '已配置' : '未配置' }}
</el-tag>
</template>
</upper-table>
</div>
<div class="lower-level" v-if="selectedRow">
<div class="detail-header">
<el-tabs v-model="activeTab" class="detail-tab">
<el-tab-pane label="签约详情" name="details" />
</el-tabs>
</div>
<div class="detail-container">
<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.remask || selectedRow.counterparty_name || '—' }}
</el-descriptions-item>
<el-descriptions-item v-if="currentSubject.company_name" label="当前仓库">
{{ currentSubject.company_name }}
<el-tag size="small" type="primary" effect="plain" style="margin-left:6px">仓库方</el-tag>
</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ selectedRow.store_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="仓库ID">{{ selectedRow.warehouse_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="使用状态">
<el-tag size="small" :type="selectedRow.use_status === 1 ? 'success' : 'info'" effect="light">
{{ selectedRow.use_status === 1 ? '启用' : '禁用' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="待我确认">
<el-tag v-if="selectedRow.needs_my_confirm" size="small" type="warning" effect="dark">是</el-tag>
<span v-else>否</span>
</el-descriptions-item>
<el-descriptions-item label="授权截止">
<span :class="{ 'text-danger': isExpired(selectedRow.auth_end) }">{{ selectedRow.auth_end || '—' }}</span>
</el-descriptions-item>
<el-descriptions-item label="面单余额">{{ selectedRow.print_quantity ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="奇门配置">
<el-tag size="small" :type="selectedRow.has_qimen_config ? 'success' : 'info'" effect="plain">
{{ selectedRow.has_qimen_config ? '已配置' : '未配置' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item v-if="selectedRow.counterparty_name && selectedRow.remask" label="货主全称" :span="2">
{{ selectedRow.counterparty_name }}
</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div class="lower-level empty" v-else>
<el-empty description="请选择数据查看详情" :image-size="60" />
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { Search, Refresh } from '@element-plus/icons-vue'
import { storeWarehouseWarehouseList } from '@/api/storeWarehouse.warehouse/storeWarehouse'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
const columns = [
{ prop: 'counterparty_name', label: '签约货主', minWidth: 140 },
{ prop: 'auth_status', label: '签约状态', width: 100 },
{ prop: 'needs_my_confirm', label: '待确认', width: 90 },
{ prop: 'use_status', label: '使用状态', width: 90 },
{ prop: 'print_quantity', label: '面单余额', width: 100 },
{ prop: 'has_qimen_config', label: '奇门配置', width: 100 },
{ prop: 'auth_end', label: '授权截止', width: 120 }
]
const availableFields = [
{
label: '签约状态',
value: 'auth_status',
type: 'select',
options: [
{ label: '待审核', value: 1 },
{ label: '已通过', value: 2 },
{ label: '已拒绝', value: 3 },
{ label: '已解除', value: 4 }
]
},
{
label: '使用状态',
value: 'use_status',
type: 'select',
options: [
{ label: '全部', value: undefined },
{ label: '启用', value: 1 },
{ label: '禁用', value: 0 }
]
}
]
const presetTree: any[] = []
const currentSubject = ref<{ store_id?: number; company_name?: string; role?: string }>({})
const loading = ref(false)
const list = 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 queryForm = reactive({ keyword: '' })
const currentCondition = ref<any>({ use_status: 1 })
async function loadList() {
loading.value = true
try {
const params: any = {
page: pagination.currentPage,
page_size: pagination.pageSize,
...currentCondition.value
}
if (queryForm.keyword) params.keyword = queryForm.keyword
const res = await storeWarehouseWarehouseList(params) as any
if (res?.data) {
const payload = res.data
list.value = payload.list || []
pagination.total = payload.pagination?.total || payload.total || 0
pagination.currentPage = payload.pagination?.page || payload.page || pagination.currentPage
pagination.pageSize = payload.pagination?.pageSize || payload.page_size || pagination.pageSize
if (payload.current_subject) {
currentSubject.value = payload.current_subject
}
}
} catch {
ElMessage.error('获取货主签约列表失败')
} finally {
loading.value = false
}
}
function isExpired(dateStr: string | null): boolean {
if (!dateStr) return false
const d = new Date(dateStr)
if (isNaN(d.getTime())) return false
return d < new Date()
}
function handleConditionChange(condition: any) {
const where: any = {}
if (condition) {
Object.keys(condition).forEach(k => {
const c = condition[k]
if (c && typeof c === 'object' && c.value !== undefined) {
if (c.value !== '' && c.value !== null) {
where[k] = c.value
}
} else if (c !== '' && c !== null && c !== undefined) {
where[k] = c
}
})
}
currentCondition.value = where
pagination.currentPage = 1
loadList()
}
function handleSearch() {
pagination.currentPage = 1
loadList()
}
function handleReset() {
queryForm.keyword = ''
currentCondition.value = {}
if (scanBox.value?.reset) {
scanBox.value.reset()
} else {
pagination.currentPage = 1
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 getAuthStatusType(status: number): string {
const map: Record<number, string> = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info' }
return map[status] || 'info'
}
function getAuthStatusLabel(status: number): string {
const map: Record<number, string> = { 1: '待审核', 2: '已通过', 3: '已拒绝', 4: '已解除' }
return map[status] || '未知'
}
onMounted(() => {
loadList()
})
</script>
<style scoped lang="scss">
.shipper-signing-container {
display: flex;
height: 100%;
.main-content {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
padding: 12px;
overflow: hidden;
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
flex-shrink: 0;
gap: 12px;
&-left {
display: flex;
align-items: center;
gap: 6px;
}
&-right {
display: flex;
align-items: center;
}
}
.upper-wrapper {
flex: 1;
min-height: 0;
overflow: hidden;
}
.lower-level {
margin-top: 8px;
border: 1px solid #ebeef5;
border-radius: 4px;
flex-shrink: 0;
display: flex;
flex-direction: column;
&.empty {
border: none;
}
.detail-header {
padding: 0 12px;
border-bottom: 1px solid #ebeef5;
flex-shrink: 0;
}
.detail-container {
padding: 12px;
overflow: auto;
max-height: 260px;
}
}
.text-danger {
color: #f56c6c;
font-weight: 500;
}
.text-muted {
color: #c0c4cc;
}
.real-name {
font-size: 12px;
color: #c0c4cc;
}
:deep(.el-descriptions__label) {
width: 110px;
}
}
</style>