201 lines
5.7 KiB
Vue
201 lines
5.7 KiB
Vue
<template>
|
|
<div class="order-sub-container">
|
|
<div class="main-content">
|
|
<div class="toolbar">
|
|
<div class="toolbar-left">
|
|
<el-button size="small" type="primary" @click="loadData">刷新</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-status="{ row }">
|
|
<el-tag :type="row.status === 'pedding' ? 'info' : row.status === 'created' ? 'success' : 'warning'" size="small">
|
|
{{ translateOrderField('status', row.status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #column-sync_status="{ row }">
|
|
<el-tag :type="row.sync_status === 'fin' ? 'success' : row.sync_status === 'error' ? 'danger' : 'info'" size="small">
|
|
{{ translateOrderField('sync_status', row.sync_status) }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #empty>
|
|
<div class="empty-tip">暂无订单</div>
|
|
</template>
|
|
</upper-table>
|
|
</div>
|
|
|
|
<div class="lower-level" :class="tableSize">
|
|
<template v-if="selectedOrderId">
|
|
<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'">
|
|
<detail :data="selectedRow" :config="deliverydetail" :column="3" />
|
|
</div>
|
|
<div v-else-if="activeTab === 'items'">
|
|
<orderdetail :orderId="selectedOrderId" />
|
|
</div>
|
|
<div v-else>
|
|
<log :data="selectedRow" />
|
|
</div>
|
|
</KeepAlive>
|
|
</div>
|
|
</template>
|
|
|
|
<div class="no-selection" v-else>
|
|
<div class="empty-tip">
|
|
<p>请从上方列表中选择一项查看详情</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, reactive, onMounted, computed } from 'vue'
|
|
import UpperTable from '@/components/UpperTable/index.vue'
|
|
import { orderDeliveryOrder } from '@/api/order.deliveryOrder/orderdeliveryOrder'
|
|
|
|
import {
|
|
deliveryColumns,
|
|
deliverydetail,
|
|
translateOrderField
|
|
} from './config/order-common-config'
|
|
import detail from './component/detail.vue'
|
|
import log from './component/log.vue'
|
|
import orderdetail from './component/orderdetail.vue'
|
|
|
|
const upperTable = ref<any>(null)
|
|
const activeTab = ref('details')
|
|
const list = ref<any[]>([])
|
|
const loading = 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 hasSelection = ref(false)
|
|
const selectedOrderId = ref<number | string | null>(null)
|
|
const quickSearch = ref('')
|
|
|
|
const selectedRow = computed(() => {
|
|
return list.value.find((i: any) => i.id === selectedOrderId.value) || null
|
|
})
|
|
|
|
onMounted(() => {
|
|
loadData()
|
|
})
|
|
|
|
async function loadData() {
|
|
if (loading.value) return
|
|
loading.value = true
|
|
const start = Date.now()
|
|
try {
|
|
const params = {
|
|
pagination: {
|
|
page: pagination.currentPage,
|
|
pageSize: pagination.pageSize
|
|
},
|
|
where: quickSearch.value
|
|
? {
|
|
delivery_order_code: {
|
|
operator: 'like',
|
|
value: quickSearch.value,
|
|
type: 'text'
|
|
}
|
|
}
|
|
: {},
|
|
sort: {
|
|
sortField: 'updated_at',
|
|
sortOrder: 'DESC'
|
|
}
|
|
}
|
|
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) {
|
|
console.error('loadData error:', e)
|
|
list.value = []
|
|
pagination.total = 0
|
|
} finally {
|
|
loading.value = false
|
|
queryTime.value = Date.now() - start
|
|
}
|
|
}
|
|
|
|
function onSelectionChange(rows: any[]) {
|
|
selectionRows.value = rows || []
|
|
hasSelection.value = selectionRows.value.length > 0
|
|
}
|
|
|
|
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()
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
@use "./styles/order-sub.scss";
|
|
</style>
|
|
|