347 lines
10 KiB
Vue
347 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"
|
|
@submit="handleConditionChange"
|
|
/>
|
|
|
|
<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>
|
|
<el-button size="small" type="success" :disabled="!hasSelection" :loading="reviewSubmitting" @click="handleBatchReview">批量审核通过</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-order_status="{ row }">
|
|
<el-tag :type="getTagType('order_status', row.order_status)" size="small">
|
|
{{ translateOrderField('order_status', row.order_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 #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="receiver" />
|
|
<el-tab-pane label="操作日志" name="logs" />
|
|
<el-tab-pane label="订单审核" name="review" />
|
|
</el-tabs>
|
|
</div>
|
|
|
|
<div class="detail-container">
|
|
<KeepAlive>
|
|
<div v-if="activeTab === 'details'">
|
|
<order-detail-panel :data="selectedRow" :config="reviewOrderDetail" :column="3" />
|
|
</div>
|
|
<div v-else-if="activeTab === 'receiver'">
|
|
<el-descriptions :column="2" border>
|
|
<el-descriptions-item label="收货人">{{ selectedRow?.name }}</el-descriptions-item>
|
|
<el-descriptions-item label="手机">{{ selectedRow?.mobile }}</el-descriptions-item>
|
|
</el-descriptions>
|
|
</div>
|
|
<div v-else-if="activeTab === 'review'" class="review-tab-panel">
|
|
<el-alert type="info" :closable="false" show-icon title="可对当前选中订单发起审核操作" />
|
|
<div class="review-tab-action">
|
|
<el-button size="small" type="primary" :loading="reviewSubmitting" @click="handleSingleReview">审核当前订单</el-button>
|
|
</div>
|
|
</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, ElMessageBox } from 'element-plus'
|
|
import ScanBox from '@/components/ScanBox/index.vue'
|
|
import UpperTable from '@/components/UpperTable/index.vue'
|
|
import { orderReviewOrder } from '@/api/order.reviewOrder/orderreviewOrder'
|
|
|
|
import {
|
|
reviewAvailableFields,
|
|
reviewColums,
|
|
reviewOrderDetail,
|
|
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(reviewAvailableFields)))
|
|
|
|
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(reviewColums)
|
|
|
|
|
|
const selectionRows = ref<any[]>([])
|
|
const hasSelection = ref(false)
|
|
const selectedOrderId = ref<number | string | null>(null)
|
|
const reviewSubmitting = ref(false)
|
|
|
|
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()
|
|
|
|
const where = buildWhereConditions(scanBox.value?.getConditions?.() || {})
|
|
if (quickSearch.value) {
|
|
where.delivery_order_code = {
|
|
operator: 'like',
|
|
value: quickSearch.value,
|
|
type: 'text'
|
|
}
|
|
}
|
|
|
|
const queryParams = {
|
|
pagination: {
|
|
page: pagination.currentPage,
|
|
pageSize: pagination.pageSize
|
|
},
|
|
where
|
|
}
|
|
|
|
try {
|
|
const res = await orderReviewOrder.list(queryParams)
|
|
if (res && (res.code === 1 || res.code === 200) && res.data) {
|
|
list.value = res.data.list || []
|
|
pagination.total = res.data.pagination?.total || res.data.total || 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()
|
|
}
|
|
|
|
const handleConditionClear = () => {
|
|
pagination.currentPage = 1
|
|
loadData()
|
|
}
|
|
|
|
function handleConditionReset() {
|
|
pagination.currentPage = 1
|
|
scanBox.value?.reset?.()
|
|
loadData()
|
|
}
|
|
|
|
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()
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
async function submitReview(ids: Array<number | string>) {
|
|
if (!ids.length) {
|
|
ElMessage.warning('请先选择需要审核的订单')
|
|
return
|
|
}
|
|
if (reviewSubmitting.value) return
|
|
reviewSubmitting.value = true
|
|
|
|
try {
|
|
const res = await orderReviewOrder.reviewOrder({ ids })
|
|
if (res && (res.code === 1 || res.code === 200)) {
|
|
ElMessage.success(`审核成功 ${res.data?.updated_count || ids.length} 条`)
|
|
upperTable.value?.clearSelection?.()
|
|
selectionRows.value = []
|
|
hasSelection.value = false
|
|
await loadData()
|
|
} else {
|
|
ElMessage.error(res?.message || '订单审核失败,请稍后重试')
|
|
}
|
|
} catch (error) {
|
|
ElMessage.error('订单审核失败,请稍后重试')
|
|
} finally {
|
|
reviewSubmitting.value = false
|
|
}
|
|
}
|
|
|
|
async function handleBatchReview() {
|
|
const ids = selectionRows.value.map((item: any) => item?.id).filter((id: any) => id !== undefined && id !== null)
|
|
if (!ids.length) {
|
|
ElMessage.warning('请先选择需要审核的订单')
|
|
return
|
|
}
|
|
try {
|
|
await ElMessageBox.confirm(`确定审核通过选中的 ${ids.length} 条订单吗?`, '确认', { type: 'warning' })
|
|
await submitReview(ids)
|
|
} catch (e) {}
|
|
}
|
|
|
|
async function handleSingleReview() {
|
|
if (!selectedRow.value?.id) {
|
|
ElMessage.warning('请先选择订单')
|
|
return
|
|
}
|
|
try {
|
|
await ElMessageBox.confirm('确定审核通过当前订单吗?', '确认', { type: 'warning' })
|
|
await submitReview([selectedRow.value.id])
|
|
} catch (e) {}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
@use "./styles/order-sub.scss";
|
|
</style>
|
|
|