344 lines
10 KiB
Vue
344 lines
10 KiB
Vue
<template>
|
|
<div class="order-sub-container">
|
|
<scan-box
|
|
ref="scanBox"
|
|
width="320px"
|
|
:tree-props="{ children: 'children', label: 'label' }"
|
|
:auto-submit="false"
|
|
:preset-tree="presetTree"
|
|
:available-fields="availableFieldsRef"
|
|
@condition-change="handleConditionChange"
|
|
@reset="handleConditionReset"
|
|
@condition-clear="handleConditionClear"
|
|
/>
|
|
|
|
<div class="main-content">
|
|
<div class="toolbar">
|
|
<div class="toolbar-left">
|
|
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
|
<el-button size="small" :loading="exportLoading" @click="handleExport">导出</el-button>
|
|
</div>
|
|
|
|
<div class="toolbar-right">
|
|
<el-input
|
|
size="small"
|
|
placeholder="搜索配送单号"
|
|
v-model="quickSearch"
|
|
style="width:220px"
|
|
@keyup.enter.native="onQuickSearch"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="upper-wrapper">
|
|
<upper-table
|
|
ref="upperTable"
|
|
title="配送订单列表"
|
|
:data="list"
|
|
:columns="columns"
|
|
:table-size="tableSize"
|
|
:pagination="pagination"
|
|
:show-index="true"
|
|
:show-actions="true"
|
|
:show-selection="true"
|
|
:loading="loading"
|
|
:queryTime="queryTime"
|
|
@current-change="handleRowClick"
|
|
@page-change="handlePageChange"
|
|
@page-size-change="handlePageSizeChange"
|
|
@refresh="loadData"
|
|
@selection-change="onSelectionChange"
|
|
>
|
|
<template #column-source_platform_code="{ row }">
|
|
{{ translateOrderField('source_platform_code', row.source_platform_code) }}
|
|
</template>
|
|
|
|
<template #column-status="{ row }">
|
|
<el-tag :type="getTagType('status', row.status)" size="small">
|
|
{{ translateOrderField('status', row.status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-is_urgency="{ row }">
|
|
<el-tag :type="getTagType('is_urgency', row.is_urgency)" size="small">
|
|
{{ translateOrderField('is_urgency', row.is_urgency) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-post_status="{ row }">
|
|
<el-tag :type="getTagType('post_status', row.post_status)" size="small">
|
|
{{ translateOrderField('post_status', row.post_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-storage_status="{ row }">
|
|
<el-tag :type="getTagType('storage_status', row.storage_status)" size="small">
|
|
{{ translateOrderField('storage_status', row.storage_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-print_status="{ row }">
|
|
<el-tag :type="getTagType('print_status', row.print_status)" size="small">
|
|
{{ translateOrderField('print_status', row.print_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-pick_status="{ row }">
|
|
<el-tag :type="getTagType('pick_status', row.pick_status)" size="small">
|
|
{{ translateOrderField('pick_status', row.pick_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-pack_status="{ row }">
|
|
<el-tag :type="getTagType('pack_status', row.pack_status)" size="small">
|
|
{{ translateOrderField('pack_status', row.pack_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-sync_status="{ row }">
|
|
<el-tag :type="getTagType('sync_status', row.sync_status)" size="small">
|
|
{{ translateOrderField('sync_status', row.sync_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-outbound_status="{ row }">
|
|
<el-tag :type="getTagType('outbound_status', row.outbound_status)" size="small">
|
|
{{ translateOrderField('outbound_status', row.outbound_status) || row.outbound_status || '-' }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #empty>
|
|
<div class="empty-tip">暂无配送订单</div>
|
|
</template>
|
|
</upper-table>
|
|
</div>
|
|
|
|
<div class="lower-level" v-if="selectedOrderId" :class="tableSize">
|
|
<div class="detail-header">
|
|
<el-tabs v-model="activeTab" class="detail-tab">
|
|
<el-tab-pane label="订单详情" name="details" />
|
|
<el-tab-pane label="商品明细" name="items" />
|
|
<el-tab-pane label="操作日志" name="logs" />
|
|
</el-tabs>
|
|
</div>
|
|
|
|
<div class="detail-container">
|
|
<KeepAlive>
|
|
<div v-if="activeTab === 'details'">
|
|
<order-detail-panel :data="selectedRow" :config="pendingOrderDetail" :column="3" />
|
|
</div>
|
|
<div v-else-if="activeTab === 'items'">
|
|
<el-table :data="detailItemRows" border stripe size="small" class="detail-items-table">
|
|
<el-table-column prop="index" label="#" width="56" align="center" />
|
|
<el-table-column prop="sku" label="商品SKU" min-width="180" show-overflow-tooltip />
|
|
<el-table-column prop="qty" label="数量" width="100" align="center" />
|
|
</el-table>
|
|
</div>
|
|
<div v-else>
|
|
<log :data="selectedRow" />
|
|
</div>
|
|
</KeepAlive>
|
|
</div>
|
|
</div>
|
|
<div class="no-selection" v-else>
|
|
<div class="empty-tip">
|
|
<p>请从上方列表中选择一项查看详情</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, reactive, onMounted, computed } from 'vue'
|
|
import { ElMessage } from 'element-plus'
|
|
import ScanBox from '@/components/ScanBox/index.vue'
|
|
import UpperTable from '@/components/UpperTable/index.vue'
|
|
import { orderDeliveryOrder } from '@/api/order.deliveryorder/orderdeliveryOrder'
|
|
|
|
import {
|
|
deliveryAvailableFields,
|
|
deliveryColumns,
|
|
pendingOrderDetail,
|
|
translateOrderField,
|
|
getTagType
|
|
} from './config/order-common-config'
|
|
import OrderDetailPanel from './component/OrderDetailPanel.vue'
|
|
import log from './component/log.vue'
|
|
import { exportUpperTableRows } from './utils/export'
|
|
|
|
const scanBox = ref<any>(null)
|
|
const upperTable = ref<any>(null)
|
|
const presetTree = ref<any[]>([])
|
|
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(deliveryAvailableFields)))
|
|
const activeTab = ref('details')
|
|
const list = ref<any[]>([])
|
|
const loading = ref(false)
|
|
const exportLoading = ref(false)
|
|
const queryTime = ref(0)
|
|
|
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
|
const tableSize = ref('small')
|
|
const columns = ref(deliveryColumns)
|
|
const selectionRows = ref<any[]>([])
|
|
const selectedOrderId = ref<number | string | null>(null)
|
|
const quickSearch = ref('')
|
|
|
|
const selectedRow = computed(() => {
|
|
return list.value.find((i: any) => i.id === selectedOrderId.value) || null
|
|
})
|
|
|
|
const detailItemRows = computed(() => {
|
|
const rawItems = selectedRow.value?.items
|
|
if (!rawItems) return []
|
|
const specs = String(rawItems)
|
|
.split(/[,\n;]/)
|
|
.map((item) => item.trim())
|
|
.filter((item) => !!item)
|
|
return specs.map((spec, index) => {
|
|
const [sku, qty] = spec.split('+')
|
|
return {
|
|
index: index + 1,
|
|
sku: sku || '-',
|
|
qty: qty || '-'
|
|
}
|
|
})
|
|
})
|
|
|
|
onMounted(() => {
|
|
loadData()
|
|
})
|
|
|
|
async function loadData() {
|
|
if (loading.value) return
|
|
loading.value = true
|
|
const start = Date.now()
|
|
try {
|
|
const where = buildWhereConditions(scanBox.value?.getConditions?.() || {})
|
|
if (quickSearch.value) {
|
|
where.delivery_order_code = {
|
|
operator: 'like',
|
|
value: quickSearch.value,
|
|
type: 'text'
|
|
}
|
|
}
|
|
const params = {
|
|
pagination: {
|
|
page: pagination.currentPage,
|
|
pageSize: pagination.pageSize
|
|
},
|
|
where,
|
|
sort: {
|
|
sortField: 'updated_at',
|
|
sortOrder: 'DESC' as const
|
|
}
|
|
}
|
|
const res: any = await orderDeliveryOrder.list(params)
|
|
if (res && (res.code === 200 || res.code === 1)) {
|
|
const responseData = res.data || {}
|
|
list.value = responseData.list || []
|
|
pagination.total = responseData.pagination?.total || responseData.total || (responseData.list ? responseData.list.length : 0)
|
|
} else {
|
|
list.value = []
|
|
pagination.total = 0
|
|
}
|
|
} catch (e) {
|
|
list.value = []
|
|
pagination.total = 0
|
|
ElMessage.error('获取配送订单列表失败')
|
|
} finally {
|
|
loading.value = false
|
|
queryTime.value = Date.now() - start
|
|
}
|
|
}
|
|
|
|
function buildWhereConditions(rawConditions: Record<string, any>) {
|
|
const where: Record<string, any> = {}
|
|
Object.keys(rawConditions || {}).forEach((key) => {
|
|
const condition = rawConditions[key]
|
|
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
|
where[key] = condition
|
|
return
|
|
}
|
|
if (condition !== undefined && condition !== null && condition !== '') {
|
|
where[key] = {
|
|
operator: 'eq',
|
|
value: condition,
|
|
type: Array.isArray(condition) ? 'array' : typeof condition
|
|
}
|
|
}
|
|
})
|
|
return where
|
|
}
|
|
|
|
function handleConditionChange() {
|
|
pagination.currentPage = 1
|
|
loadData()
|
|
}
|
|
|
|
function handleConditionClear() {
|
|
pagination.currentPage = 1
|
|
loadData()
|
|
}
|
|
|
|
function handleConditionReset() {
|
|
pagination.currentPage = 1
|
|
scanBox.value?.reset?.()
|
|
loadData()
|
|
}
|
|
|
|
function onSelectionChange(rows: any[]) {
|
|
selectionRows.value = rows || []
|
|
}
|
|
|
|
function handleRowClick(row: any) {
|
|
selectedOrderId.value = row?.id || null
|
|
}
|
|
|
|
function handlePageChange(page: number) {
|
|
pagination.currentPage = page
|
|
loadData()
|
|
}
|
|
|
|
function handlePageSizeChange(size: number) {
|
|
pagination.pageSize = size
|
|
pagination.currentPage = 1
|
|
loadData()
|
|
}
|
|
|
|
function onQuickSearch() {
|
|
pagination.currentPage = 1
|
|
loadData()
|
|
}
|
|
|
|
async function handleExport() {
|
|
if (!selectionRows.value.length) {
|
|
ElMessage.warning('请先勾选要导出的订单')
|
|
return
|
|
}
|
|
exportLoading.value = true
|
|
try {
|
|
exportUpperTableRows({
|
|
rows: selectionRows.value,
|
|
columns: columns.value,
|
|
fileName: `配送订单-${Date.now()}.xlsx`,
|
|
transformCell: (prop, value) => translateOrderField(prop, value)
|
|
})
|
|
ElMessage.success('导出完成')
|
|
} catch (error) {
|
|
ElMessage.error('导出失败')
|
|
} finally {
|
|
exportLoading.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
@use "./styles/order-sub.scss";
|
|
|
|
.detail-items-table {
|
|
padding: 8px 10px 10px;
|
|
}
|
|
</style>
|
|
|