feat(afterSale): 售后模块V2 - 工单入口、发起售后、订单快速搜索
- 新增售后API层(afterSale.workList/detail/create/update/transfer/handleWorkOrder/registerClaim/export/workCount/quickSearch) - 消息中心改为工单入口(/workorder),支持ScanBox+UpperTable筛选列表 - Navbar工单角标(每60s轮询afterSale.workCount) - 新增发起售后单弹窗(关联单据按类型动态切换、货主下拉、订单快速搜索) - 订单搜索使用order.deliveryOrder.quickSearch跨表联合搜索 - DocSearchPicker通用单据搜索组件 - 售后明细页增加附件上传(handleWorkOrder/registerClaim) - 移除已废弃的workOrder页面、下载入口、LangSelect图标 - 修复where字段camelCase/snake_case不一致问题
This commit is contained in:
parent
ac42f708fe
commit
abe6d3f668
@ -1,8 +1,12 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
"path": ".",
|
||||
"name": "WEB (WMS前端)"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
"settings": {
|
||||
"git.autoRepositoryDetection": "subFolders",
|
||||
"git.repositoryScanMaxDepth": 1
|
||||
}
|
||||
}
|
||||
334
src/api/afterSale/index.ts
Normal file
334
src/api/afterSale/index.ts
Normal file
@ -0,0 +1,334 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const v = '1.0'
|
||||
|
||||
// ============================================================
|
||||
// 售后模块 V2 API
|
||||
// ============================================================
|
||||
|
||||
// ==================== 类型定义 ====================
|
||||
|
||||
/** 售后类型 */
|
||||
export type AfterSaleType = 'order' | 'receiving' | 'entry' | 'stockout'
|
||||
|
||||
/** 售后状态 */
|
||||
export type AfterSaleStatus = 'pending' | 'processing' | 'completed' | 'closed' | 'cancelled'
|
||||
|
||||
/** 角色组 */
|
||||
export type AfterSaleRoleGroup = 'customer_service' | 'warehouse' | 'finance'
|
||||
|
||||
/** 理赔状态 */
|
||||
export type ClaimStatus = 'pending' | 'reviewing' | 'approved' | 'paid' | 'monthly' | 'rejected'
|
||||
|
||||
/** 步骤状态: 0=待开始 1=进行中 2=已完成 3=已跳过 */
|
||||
export type StepStatus = 0 | 1 | 2 | 3
|
||||
|
||||
/** 售后单对象 */
|
||||
export interface AfterSale {
|
||||
id: number
|
||||
warehouse_id: number
|
||||
store_id: number | null
|
||||
after_sale_no: string
|
||||
type: AfterSaleType
|
||||
sub_type: string
|
||||
status: AfterSaleStatus
|
||||
priority: number
|
||||
title: string
|
||||
description: string | null
|
||||
creator_id: number
|
||||
inbox_message_id: number | null
|
||||
role_group: AfterSaleRoleGroup | null
|
||||
resolution: string | null
|
||||
resolved_at: string | null
|
||||
|
||||
// 仓库理赔
|
||||
claim_needed: 0 | 1
|
||||
claim_amount: number | null
|
||||
claim_status: ClaimStatus | null
|
||||
|
||||
// 运方理赔
|
||||
carrier_claim_needed: 0 | 1
|
||||
carrier_claim_amount: number | null
|
||||
carrier_claim_status: ClaimStatus | null
|
||||
|
||||
// 关联单据
|
||||
waybill_id: number | null
|
||||
waybill_no: string | null
|
||||
order_delivery_id: number | null
|
||||
order_delivery_no: string | null
|
||||
entry_order_id: number | null
|
||||
entry_order_no: string | null
|
||||
order_stockout_id: number | null
|
||||
order_stockout_no: string | null
|
||||
receiving_id: number | null
|
||||
receiving_no: string | null
|
||||
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 售后步骤对象 */
|
||||
export interface AfterSaleStep {
|
||||
id: number
|
||||
after_sale_id: number
|
||||
step_status: StepStatus
|
||||
operator_id: number | null
|
||||
operator_snapshot: string | null
|
||||
action: string | null
|
||||
remark: string | null
|
||||
started_at: string | null
|
||||
completed_at: string | null
|
||||
created_at: string
|
||||
attachments: FileReference[]
|
||||
}
|
||||
|
||||
/** 文件引用 */
|
||||
export interface FileReference {
|
||||
file_id: number
|
||||
file_name?: string
|
||||
file_url?: string
|
||||
}
|
||||
|
||||
// ==================== 请求参数类型 ====================
|
||||
|
||||
/** 列表查询参数 */
|
||||
export interface AfterSaleListParams {
|
||||
pagination?: { page?: number; pageSize?: number }
|
||||
where?: Record<string, any>
|
||||
sort?: { sortField?: string; sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC' }
|
||||
}
|
||||
|
||||
/** 创建售后单参数 */
|
||||
export interface AfterSaleCreateParams {
|
||||
type: AfterSaleType
|
||||
sub_type: string
|
||||
title: string
|
||||
description?: string
|
||||
priority?: number
|
||||
store_id?: number
|
||||
waybill_id?: number
|
||||
order_id?: number
|
||||
order_delivery_no?: string
|
||||
entry_order_id?: number
|
||||
entry_order_no?: string
|
||||
order_stockout_id?: number
|
||||
order_stockout_no?: string
|
||||
receiving_id?: number
|
||||
receiving_no?: string
|
||||
}
|
||||
|
||||
/** 更新售后单参数 */
|
||||
export interface AfterSaleUpdateParams extends Partial<AfterSaleCreateParams> {
|
||||
id: number
|
||||
}
|
||||
|
||||
/** 转单参数 */
|
||||
export interface AfterSaleTransferParams {
|
||||
id: number
|
||||
role_group: AfterSaleRoleGroup
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 处理工单参数 */
|
||||
export interface AfterSaleHandleWorkOrderParams {
|
||||
id: number
|
||||
action: string
|
||||
status?: AfterSaleStatus
|
||||
remark?: string
|
||||
attachment_ids?: number[]
|
||||
}
|
||||
|
||||
/** 登记理赔参数 */
|
||||
export interface AfterSaleRegisterClaimParams {
|
||||
id: number
|
||||
// 仓库理赔
|
||||
claim_needed?: 0 | 1
|
||||
claim_amount?: number
|
||||
claim_status?: ClaimStatus
|
||||
// 运方理赔
|
||||
carrier_claim_needed?: 0 | 1
|
||||
carrier_claim_amount?: number
|
||||
carrier_claim_status?: ClaimStatus
|
||||
// 步骤
|
||||
action: string
|
||||
remark?: string
|
||||
attachment_ids?: number[]
|
||||
}
|
||||
|
||||
/** 导出参数 */
|
||||
export interface AfterSaleExportParams {
|
||||
where?: Record<string, any>
|
||||
sort?: { sortField?: string; sortOrder?: 'asc' | 'desc' }
|
||||
}
|
||||
|
||||
/** 导出进度查询参数 */
|
||||
export interface AfterSaleExportTaskProgressParams {
|
||||
task_id: string
|
||||
}
|
||||
|
||||
// ==================== API 方法 ====================
|
||||
|
||||
/** 2.1 工作列表 afterSale.workList */
|
||||
export function afterSaleWorkList(data: AfterSaleListParams = {}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.workList',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.2 审计列表 afterSale.auditList */
|
||||
export function afterSaleAuditList(data: AfterSaleListParams = {}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.auditList',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.3 售后明细 afterSale.detail */
|
||||
export function afterSaleDetail(id: number) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.detail',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: { id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.4 创建售后单 afterSale.create */
|
||||
export function afterSaleCreate(data: AfterSaleCreateParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.create',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.5 更新售后单 afterSale.update */
|
||||
export function afterSaleUpdate(data: AfterSaleUpdateParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.update',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.6 转单 afterSale.transfer */
|
||||
export function afterSaleTransfer(data: AfterSaleTransferParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.transfer',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.7 处理工单 afterSale.handleWorkOrder */
|
||||
export function afterSaleHandleWorkOrder(data: AfterSaleHandleWorkOrderParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.handleWorkOrder',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.8 登记理赔 afterSale.registerClaim */
|
||||
export function afterSaleRegisterClaim(data: AfterSaleRegisterClaimParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.registerClaim',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.9 导出 afterSale.export */
|
||||
export function afterSaleExport(data: AfterSaleExportParams = {}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.export',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.10 导出进度 afterSale.exportTaskProgress */
|
||||
export function afterSaleExportTaskProgress(data: AfterSaleExportTaskProgressParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.exportTaskProgress',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 2.11 角标快速查询 afterSale.workCount */
|
||||
export function afterSaleWorkCount(): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'afterSale.workCount',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
@ -233,7 +233,22 @@ export function orderDeliveryOrderDetail(data: DeliveryOrderDetailParams): Promi
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function orderDeliveryOrderQuickSearch(keyword: string): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'order.deliveryOrder.quickSearch',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: { keyword },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export const orderDeliveryOrder = {
|
||||
list: orderDeliveryOrderList,
|
||||
detail: orderDeliveryOrderDetail
|
||||
detail: orderDeliveryOrderDetail,
|
||||
quickSearch: orderDeliveryOrderQuickSearch,
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<el-dropdown trigger="click" @command="handleSetLanguage" class="lang-select">
|
||||
<div class="lang-wrapper">
|
||||
<svg-icon icon-class="language" class="lang-icon" />
|
||||
<span class="lang-text">{{ $t("common.language") }}</span>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
@ -49,10 +48,6 @@ const handleSetLanguage = (lang: string) => {
|
||||
align-items: center;
|
||||
padding: 0 8px;
|
||||
}
|
||||
.lang-icon {
|
||||
font-size: 18px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.lang-text {
|
||||
font-size: 14px;
|
||||
color: aliceblue;
|
||||
|
||||
@ -30,20 +30,14 @@
|
||||
<svg-icon :icon-class="isFullscreen ? 'exit-fullscreen' : 'fullscreen'" />
|
||||
</div>
|
||||
|
||||
<!-- Message -->
|
||||
<router-link to="/message" class="right-menu-item">
|
||||
<div class="menu-item-content">
|
||||
<svg-icon icon-class="message" />
|
||||
<span class="menu-text">{{ $t('menu.Message') }}</span>
|
||||
</div>
|
||||
</router-link>
|
||||
|
||||
<!-- Download -->
|
||||
<router-link to="/download" class="right-menu-item">
|
||||
<div class="menu-item-content">
|
||||
<svg-icon icon-class="download" />
|
||||
<span class="menu-text">{{ $t('menu.Download') }}</span>
|
||||
</div>
|
||||
<!-- WorkOrder -->
|
||||
<router-link to="/workorder" class="right-menu-item workorder-item">
|
||||
<el-badge :value="workOrderBadgeCount" :max="99" :hidden="!workOrderBadgeCount">
|
||||
<div class="menu-item-content">
|
||||
<svg-icon icon-class="message" />
|
||||
<span class="menu-text">工单</span>
|
||||
</div>
|
||||
</el-badge>
|
||||
</router-link>
|
||||
|
||||
<!-- Language Select -->
|
||||
@ -96,7 +90,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useAppStore } from '@/stores/modules/app'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
@ -107,6 +101,7 @@ import LangSelect from '@/components/LangSelect/index.vue'
|
||||
import TopMenu from './TopMenu.vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { useFullscreen } from '@vueuse/core'
|
||||
import { afterSaleWorkCount } from '@/api/afterSale/index'
|
||||
|
||||
const { isFullscreen, toggle } = useFullscreen()
|
||||
|
||||
@ -126,6 +121,22 @@ const layoutMode = computed(() => settingsStore.layoutMode)
|
||||
const remainingDays = ref(0)
|
||||
const isExpired = ref(false)
|
||||
|
||||
// ==================== 工单角标 ====================
|
||||
const workOrderBadgeCount = ref(0)
|
||||
let badgeTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
async function fetchWorkOrderBadge() {
|
||||
try {
|
||||
const res: any = await afterSaleWorkCount()
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||
const data = res.data ?? res
|
||||
workOrderBadgeCount.value = data.pending ?? data.total ?? 0
|
||||
}
|
||||
} catch {
|
||||
// 静默失败,角标保持旧值
|
||||
}
|
||||
}
|
||||
|
||||
const activeWarehouse = computed(() => {
|
||||
const employees = user.value.employees
|
||||
if (!employees || !Array.isArray(employees)) return null
|
||||
@ -199,13 +210,22 @@ const logout = async () => {
|
||||
|
||||
onMounted(() => {
|
||||
calculateDays()
|
||||
fetchWorkOrderBadge()
|
||||
// 每 60 秒刷新一次工单角标
|
||||
badgeTimer = setInterval(fetchWorkOrderBadge, 60000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (badgeTimer) {
|
||||
clearInterval(badgeTimer)
|
||||
badgeTimer = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.navbar {
|
||||
height: 45px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background-color: #0C90FF;
|
||||
//box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
|
||||
@ -315,6 +335,14 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.workorder-item {
|
||||
overflow: visible;
|
||||
:deep(.el-badge__content) {
|
||||
top: 6px;
|
||||
right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
.avatar-wrapper {
|
||||
display: flex;
|
||||
|
||||
@ -112,16 +112,16 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/message',
|
||||
path: '/workorder',
|
||||
component: Layout,
|
||||
meta: { hidden: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'Message',
|
||||
name: 'WorkOrder',
|
||||
component: () => import('@/views/message/index.vue'),
|
||||
meta: {
|
||||
title: '消息中心',
|
||||
title: '我的工单',
|
||||
icon: 'example',
|
||||
affix: false
|
||||
}
|
||||
|
||||
842
src/views/afterSale/detail/index.vue
Normal file
842
src/views/afterSale/detail/index.vue
Normal file
@ -0,0 +1,842 @@
|
||||
<template>
|
||||
<div class="after-sale-detail-container">
|
||||
<!-- 顶部标题栏 -->
|
||||
<div class="detail-header-bar">
|
||||
<el-button size="small" @click="goBack">
|
||||
<el-icon><ArrowLeft /></el-icon>
|
||||
返回列表
|
||||
</el-button>
|
||||
<span class="detail-title">售后明细 - {{ detail?.after_sale_no || '加载中...' }}</span>
|
||||
<div class="header-actions">
|
||||
<el-button
|
||||
v-if="detail && (detail.status === 'pending' || detail.status === 'processing')"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="showTransferDialog"
|
||||
>
|
||||
转单
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="detail && detail.status !== 'completed' && detail.status !== 'cancelled' && detail.status !== 'closed'"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="showHandleDialog"
|
||||
>
|
||||
处理工单
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="detail"
|
||||
size="small"
|
||||
type="success"
|
||||
@click="showClaimDialog"
|
||||
>
|
||||
登记理赔
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-loading="loading" class="detail-body">
|
||||
<template v-if="detail">
|
||||
<!-- 基本信息卡片 -->
|
||||
<el-card class="info-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
<el-tag :type="statusTagType(detail.status)" size="small">
|
||||
{{ statusLabel(detail.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<el-descriptions :column="3" border size="small">
|
||||
<el-descriptions-item label="售后单号">{{ detail.after_sale_no }}</el-descriptions-item>
|
||||
<el-descriptions-item label="售后类型">
|
||||
<el-tag size="small" :type="typeTagType(detail.type)">{{ typeLabel(detail.type) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="子类型">{{ subTypeLabel(detail.sub_type) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="标题" :span="2">{{ detail.title }}</el-descriptions-item>
|
||||
<el-descriptions-item label="优先级">{{ detail.priority }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.description" label="详细描述" :span="3">
|
||||
{{ detail.description }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="角色组">
|
||||
<el-tag v-if="detail.role_group" size="small" :type="roleGroupTagType(detail.role_group)">
|
||||
{{ roleGroupLabel(detail.role_group) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="处理结果">
|
||||
{{ detail.resolution || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="完结时间">
|
||||
{{ detail.resolved_at || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ detail.created_at }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ detail.updated_at }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<!-- 关联单据 -->
|
||||
<el-card v-if="hasRelatedDocs" class="info-card" shadow="never">
|
||||
<template #header><span class="card-title">关联单据</span></template>
|
||||
<el-descriptions :column="3" border size="small">
|
||||
<el-descriptions-item v-if="detail.waybill_no" label="运单号">
|
||||
{{ detail.waybill_no }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.order_delivery_no" label="发货订单号">
|
||||
{{ detail.order_delivery_no }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.entry_order_no" label="入库单号">
|
||||
{{ detail.entry_order_no }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.order_stockout_no" label="出库单号">
|
||||
{{ detail.order_stockout_no }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.receiving_no" label="收货单号">
|
||||
{{ detail.receiving_no }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<!-- 理赔信息 -->
|
||||
<el-card v-if="detail.claim_needed || detail.carrier_claim_needed" class="info-card" shadow="never">
|
||||
<template #header><span class="card-title">理赔信息</span></template>
|
||||
<el-row :gutter="20">
|
||||
<!-- 仓库理赔 -->
|
||||
<el-col v-if="detail.claim_needed" :span="12">
|
||||
<div class="claim-section">
|
||||
<h4>🏭 仓库理赔</h4>
|
||||
<el-descriptions :column="1" border size="small">
|
||||
<el-descriptions-item label="金额">¥{{ detail.claim_amount ?? '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<el-tag size="small" :type="claimStatusTagType(detail.claim_status!)">
|
||||
{{ claimStatusLabel(detail.claim_status!) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-col>
|
||||
<!-- 运方理赔 -->
|
||||
<el-col v-if="detail.carrier_claim_needed" :span="12">
|
||||
<div class="claim-section">
|
||||
<h4>🚚 运方理赔</h4>
|
||||
<el-descriptions :column="1" border size="small">
|
||||
<el-descriptions-item label="金额">¥{{ detail.carrier_claim_amount ?? '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<el-tag size="small" :type="claimStatusTagType(detail.carrier_claim_status!)">
|
||||
{{ claimStatusLabel(detail.carrier_claim_status!) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
<!-- 处理步骤 / 时间线 -->
|
||||
<el-card v-if="steps && steps.length > 0" class="info-card" shadow="never">
|
||||
<template #header><span class="card-title">处理记录</span></template>
|
||||
<el-timeline>
|
||||
<el-timeline-item
|
||||
v-for="step in steps"
|
||||
:key="step.id"
|
||||
:timestamp="step.completed_at || step.started_at || step.created_at"
|
||||
placement="top"
|
||||
:type="stepTimelineType(step.step_status)"
|
||||
>
|
||||
<div class="step-item">
|
||||
<div class="step-header">
|
||||
<el-tag size="small" :type="stepStatusTagType(step.step_status)">
|
||||
{{ stepStatusLabel(step.step_status) }}
|
||||
</el-tag>
|
||||
<span class="step-action">{{ step.action || '未指定操作' }}</span>
|
||||
</div>
|
||||
<div v-if="step.remark" class="step-remark">{{ step.remark }}</div>
|
||||
<div v-if="step.operator_snapshot" class="step-operator">
|
||||
操作人: {{ parseOperatorName(step.operator_snapshot) }}
|
||||
</div>
|
||||
<div v-if="step.attachments && step.attachments.length > 0" class="step-attachments">
|
||||
<span class="att-label">附件:</span>
|
||||
<span v-for="(att, idx) in step.attachments" :key="idx" class="att-item">
|
||||
{{ att.file_name || `文件${att.file_id}` }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</el-card>
|
||||
|
||||
<!-- 暂无步骤 -->
|
||||
<el-empty v-if="!steps || steps.length === 0" description="暂无处理记录" />
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- ========== 弹窗 ========== -->
|
||||
|
||||
<!-- 处理工单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="handleDialogVisible"
|
||||
title="处理工单"
|
||||
width="550px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form ref="handleFormRef" :model="handleForm" :rules="handleRules" label-width="110px" size="small">
|
||||
<el-form-item label="售后单号">
|
||||
<el-input :model-value="detail?.after_sale_no" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="操作动作" prop="action">
|
||||
<el-input v-model="handleForm.action" placeholder="如:仓库验货、退款打款" />
|
||||
</el-form-item>
|
||||
<el-form-item label="更新状态" prop="status">
|
||||
<el-select v-model="handleForm.status" placeholder="请选择状态" style="width: 100%">
|
||||
<el-option label="待处理" value="pending" />
|
||||
<el-option label="处理中" value="processing" />
|
||||
<el-option label="已完成" value="completed" />
|
||||
<el-option label="已关闭" value="closed" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="处理备注">
|
||||
<el-input v-model="handleForm.remark" type="textarea" :rows="3" placeholder="请输入处理备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="附件">
|
||||
<el-upload
|
||||
ref="handleUploadRef"
|
||||
action="#"
|
||||
:auto-upload="false"
|
||||
:file-list="handleFileList"
|
||||
:limit="10"
|
||||
:on-change="(file: any) => onHandleFileChange(file)"
|
||||
:on-remove="(file: any) => onHandleFileRemove(file)"
|
||||
:before-upload="() => false"
|
||||
accept="image/*"
|
||||
list-type="text"
|
||||
>
|
||||
<el-button size="small" type="primary" plain>选择文件</el-button>
|
||||
<template #tip>
|
||||
<span class="upload-tip">支持图片格式,单张不超过10MB,选完后点击"确认处理"时自动上传</span>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="handleLoading" @click="handleSubmitHandle">
|
||||
确认处理
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 转单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="transferDialogVisible_"
|
||||
title="转单"
|
||||
width="500px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form ref="transferFormRef" :model="transferForm" :rules="transferRules" label-width="110px" size="small">
|
||||
<el-form-item label="售后单号">
|
||||
<el-input :model-value="detail?.after_sale_no" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="目标角色组" prop="role_group">
|
||||
<el-select v-model="transferForm.role_group" placeholder="请选择目标角色组" style="width: 100%">
|
||||
<el-option label="客服组" value="customer_service" />
|
||||
<el-option label="仓库组" value="warehouse" />
|
||||
<el-option label="财务组" value="finance" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转单备注">
|
||||
<el-input v-model="transferForm.remark" type="textarea" :rows="2" placeholder="请输入转单备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="transferDialogVisible_ = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="transferLoading" @click="handleSubmitTransfer">
|
||||
确认转单
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 登记理赔弹窗 -->
|
||||
<el-dialog
|
||||
v-model="claimDialogVisible"
|
||||
title="登记理赔"
|
||||
width="600px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form ref="claimFormRef" :model="claimForm" :rules="claimRules" label-width="120px" size="small">
|
||||
<el-form-item label="售后单号">
|
||||
<el-input :model-value="detail?.after_sale_no" disabled />
|
||||
</el-form-item>
|
||||
<el-divider content-position="left">🏭 仓库理赔</el-divider>
|
||||
<el-form-item label="是否需要理赔">
|
||||
<el-switch v-model="claimForm.claim_needed" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<template v-if="claimForm.claim_needed">
|
||||
<el-form-item label="理赔金额" prop="claim_amount">
|
||||
<el-input-number v-model="claimForm.claim_amount" :min="0" :precision="2" style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="理赔状态" prop="claim_status">
|
||||
<el-select v-model="claimForm.claim_status" placeholder="请选择" style="width: 180px">
|
||||
<el-option v-for="(label, value) in claimStatusOptions" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-divider content-position="left">🚚 运方理赔</el-divider>
|
||||
<el-form-item label="是否需要理赔">
|
||||
<el-switch v-model="claimForm.carrier_claim_needed" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<template v-if="claimForm.carrier_claim_needed">
|
||||
<el-form-item label="理赔金额" prop="carrier_claim_amount">
|
||||
<el-input-number v-model="claimForm.carrier_claim_amount" :min="0" :precision="2" style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="理赔状态" prop="carrier_claim_status">
|
||||
<el-select v-model="claimForm.carrier_claim_status" placeholder="请选择" style="width: 180px">
|
||||
<el-option v-for="(label, value) in claimStatusOptions" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-divider content-position="left">📝 操作信息</el-divider>
|
||||
<el-form-item label="操作动作" prop="claim_action">
|
||||
<el-input v-model="claimForm.claim_action" placeholder="如:登记仓库理赔" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="claimForm.claim_remark" type="textarea" :rows="2" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="附件">
|
||||
<el-upload
|
||||
ref="claimUploadRef"
|
||||
action="#"
|
||||
:auto-upload="false"
|
||||
:file-list="claimFileList"
|
||||
:limit="10"
|
||||
:on-change="(file: any) => onClaimFileChange(file)"
|
||||
:on-remove="(file: any) => onClaimFileRemove(file)"
|
||||
:before-upload="() => false"
|
||||
accept="image/*"
|
||||
list-type="text"
|
||||
>
|
||||
<el-button size="small" type="primary" plain>选择文件</el-button>
|
||||
<template #tip>
|
||||
<span class="upload-tip">支持图片格式,单张不超过10MB,选完后点击"确认登记"时自动上传</span>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="claimDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="claimLoading" @click="handleSubmitClaim">
|
||||
确认登记
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import {
|
||||
afterSaleDetail,
|
||||
afterSaleHandleWorkOrder,
|
||||
afterSaleTransfer,
|
||||
afterSaleRegisterClaim,
|
||||
type AfterSale,
|
||||
type AfterSaleStep,
|
||||
type AfterSaleHandleWorkOrderParams,
|
||||
type AfterSaleTransferParams,
|
||||
type AfterSaleRegisterClaimParams,
|
||||
} from '@/api/afterSale/index'
|
||||
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
|
||||
import {
|
||||
AFTER_SALE_TYPE_MAP,
|
||||
AFTER_SALE_TYPE_TAG_MAP,
|
||||
AFTER_SALE_SUB_TYPE_MAP,
|
||||
AFTER_SALE_STATUS_MAP,
|
||||
AFTER_SALE_STATUS_TAG_MAP,
|
||||
AFTER_SALE_ROLE_GROUP_MAP,
|
||||
AFTER_SALE_ROLE_GROUP_TAG_MAP,
|
||||
CLAIM_STATUS_MAP,
|
||||
CLAIM_STATUS_TAG_MAP,
|
||||
STEP_STATUS_MAP,
|
||||
STEP_STATUS_TAG_MAP,
|
||||
} from '@/views/afterSale/list/afterSale-config'
|
||||
|
||||
// ==================== 工具函数 ====================
|
||||
|
||||
function typeLabel(t: string) { return AFTER_SALE_TYPE_MAP[t] ?? t ?? '-' }
|
||||
function typeTagType(t: string) { return AFTER_SALE_TYPE_TAG_MAP[t] ?? 'info' }
|
||||
function subTypeLabel(s: string) { return AFTER_SALE_SUB_TYPE_MAP[s] ?? s ?? '-' }
|
||||
function statusLabel(s: string) { return AFTER_SALE_STATUS_MAP[s] ?? s ?? '-' }
|
||||
function statusTagType(s: string) { return AFTER_SALE_STATUS_TAG_MAP[s] ?? 'info' }
|
||||
function roleGroupLabel(r: string) { return AFTER_SALE_ROLE_GROUP_MAP[r] ?? r ?? '-' }
|
||||
function roleGroupTagType(r: string) { return AFTER_SALE_ROLE_GROUP_TAG_MAP[r] ?? 'info' }
|
||||
function claimStatusLabel(c: string) { return CLAIM_STATUS_MAP[c] ?? c ?? '-' }
|
||||
function claimStatusTagType(c: string) { return CLAIM_STATUS_TAG_MAP[c] ?? 'info' }
|
||||
function stepStatusLabel(s: number) { return STEP_STATUS_MAP[s] ?? String(s) }
|
||||
function stepStatusTagType(s: number) { return STEP_STATUS_TAG_MAP[s] ?? 'info' }
|
||||
function stepTimelineType(s: number): 'primary' | 'success' | 'warning' | 'danger' | 'info' {
|
||||
const map: Record<number, 'primary' | 'success' | 'warning' | 'danger' | 'info'> = {
|
||||
0: 'info', 1: 'primary', 2: 'success', 3: 'warning',
|
||||
}
|
||||
return map[s] ?? 'info'
|
||||
}
|
||||
|
||||
function parseOperatorName(snapshot: string): string {
|
||||
try {
|
||||
const obj = JSON.parse(snapshot)
|
||||
return obj.name || obj.id || '-'
|
||||
} catch {
|
||||
return snapshot || '-'
|
||||
}
|
||||
}
|
||||
|
||||
const claimStatusOptions = CLAIM_STATUS_MAP
|
||||
|
||||
// ==================== 路由 ====================
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
function goBack() {
|
||||
router.push({ name: 'afterSale.list' })
|
||||
}
|
||||
|
||||
// ==================== 数据 ====================
|
||||
|
||||
const loading = ref(false)
|
||||
const detail = ref<AfterSale | null>(null)
|
||||
const steps = ref<AfterSaleStep[]>([])
|
||||
|
||||
const hasRelatedDocs = computed(() => {
|
||||
if (!detail.value) return false
|
||||
return !!(detail.value.waybill_no || detail.value.order_delivery_no ||
|
||||
detail.value.entry_order_no || detail.value.order_stockout_no || detail.value.receiving_no)
|
||||
})
|
||||
|
||||
// ==================== 附件上传 ====================
|
||||
|
||||
/** 处理工单附件 */
|
||||
const handleFileList = ref<any[]>([])
|
||||
const handleUploadedIds = ref<number[]>([])
|
||||
const handleUploadRef = ref<any>()
|
||||
|
||||
/** 登记理赔附件 */
|
||||
const claimFileList = ref<any[]>([])
|
||||
const claimUploadedIds = ref<number[]>([])
|
||||
const claimUploadRef = ref<any>()
|
||||
|
||||
/** 上传单个文件到COS并注册 */
|
||||
async function uploadSingleFile(rawFile: File): Promise<number | null> {
|
||||
try {
|
||||
// 1. 获取COS上传配置
|
||||
const configRes: any = await getCOSUploadConfig({
|
||||
fileName: rawFile.name,
|
||||
fileType: rawFile.type,
|
||||
fileSize: rawFile.size,
|
||||
})
|
||||
const cosConfig = configRes?.data ?? configRes
|
||||
if (cosConfig?.isNew === false) {
|
||||
// 文件已存在,直接返回已有 file_id
|
||||
return cosConfig?.fileId ?? cosConfig?.file_id ?? null
|
||||
}
|
||||
if (cosConfig?.error) {
|
||||
console.error('获取上传配置失败:', cosConfig.msg)
|
||||
return null
|
||||
}
|
||||
|
||||
// 2. 上传到COS
|
||||
const formData = new FormData()
|
||||
if (cosConfig.data) {
|
||||
Object.keys(cosConfig.data).forEach((key) => {
|
||||
formData.append(key, cosConfig.data[key])
|
||||
})
|
||||
}
|
||||
formData.append('file', rawFile)
|
||||
const uploadUrl = cosConfig.uploadUrl || cosConfig.upload_url
|
||||
const uploadHeaders = cosConfig.headers || {}
|
||||
const uploadRes = await fetch(uploadUrl, {
|
||||
method: 'POST',
|
||||
headers: uploadHeaders,
|
||||
body: formData,
|
||||
})
|
||||
if (!uploadRes.ok) {
|
||||
throw new Error(`上传失败: ${uploadRes.status}`)
|
||||
}
|
||||
|
||||
// 3. 通知上传成功,获取 file_id
|
||||
const notifyRes: any = await uploadSuccessNotify(cosConfig.fileInfo || cosConfig)
|
||||
const fileId = notifyRes?.data?.file_id ?? notifyRes?.file_id ?? notifyRes?.data?.fileId
|
||||
return fileId ?? null
|
||||
} catch (error) {
|
||||
console.error('文件上传失败:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量上传文件,返回成功上传的 file_id 列表 */
|
||||
async function uploadFilesBatch(fileList: any[]): Promise<number[]> {
|
||||
const ids: number[] = []
|
||||
for (const file of fileList) {
|
||||
const rawFile = file.raw || file
|
||||
if (rawFile instanceof File) {
|
||||
const fileId = await uploadSingleFile(rawFile)
|
||||
if (fileId != null) {
|
||||
ids.push(fileId)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// 处理工单附件 - 选择文件
|
||||
function onHandleFileChange(_file: any) {
|
||||
// el-upload v-model 自动同步 fileList
|
||||
}
|
||||
|
||||
// 处理工单附件 - 移除文件
|
||||
function onHandleFileRemove(_file: any) {
|
||||
// el-upload v-model 自动同步 fileList
|
||||
}
|
||||
|
||||
// 登记理赔附件 - 选择文件
|
||||
function onClaimFileChange(_file: any) {
|
||||
// el-upload v-model 自动同步 fileList
|
||||
}
|
||||
|
||||
// 登记理赔附件 - 移除文件
|
||||
function onClaimFileRemove(_file: any) {
|
||||
// el-upload v-model 自动同步 fileList
|
||||
}
|
||||
|
||||
/** 清空处理工单附件 */
|
||||
function resetHandleAttachments() {
|
||||
handleFileList.value = []
|
||||
handleUploadedIds.value = []
|
||||
}
|
||||
|
||||
/** 清空登记理赔附件 */
|
||||
function resetClaimAttachments() {
|
||||
claimFileList.value = []
|
||||
claimUploadedIds.value = []
|
||||
}
|
||||
|
||||
async function fetchDetail() {
|
||||
const id = Number(route.query.id)
|
||||
if (!id) {
|
||||
ElMessage.error('缺少售后单ID')
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await afterSaleDetail(id)
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
const data = res.data ?? res
|
||||
detail.value = data.after_sale ?? null
|
||||
steps.value = data.steps ?? []
|
||||
} else {
|
||||
ElMessage.error(res?.message || '获取售后明细失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取售后明细失败:', error)
|
||||
ElMessage.error('获取售后明细失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 处理工单 ====================
|
||||
|
||||
const handleDialogVisible = ref(false)
|
||||
const handleLoading = ref(false)
|
||||
const handleFormRef = ref<FormInstance>()
|
||||
|
||||
const handleForm = reactive({
|
||||
action: '' as string,
|
||||
status: '' as string,
|
||||
remark: '' as string,
|
||||
})
|
||||
|
||||
const handleRules: FormRules = {
|
||||
action: [{ required: true, message: '请输入操作动作', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择更新状态', trigger: 'change' }],
|
||||
}
|
||||
|
||||
function showHandleDialog() {
|
||||
handleForm.action = ''
|
||||
handleForm.status = detail.value?.status || 'processing'
|
||||
handleForm.remark = ''
|
||||
resetHandleAttachments()
|
||||
handleDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmitHandle() {
|
||||
const valid = await handleFormRef.value?.validate().catch(() => false)
|
||||
if (!valid || !detail.value) return
|
||||
|
||||
handleLoading.value = true
|
||||
try {
|
||||
// 先上传附件
|
||||
const attachmentIds = await uploadFilesBatch(handleFileList.value)
|
||||
|
||||
const params: AfterSaleHandleWorkOrderParams = {
|
||||
id: detail.value.id,
|
||||
action: handleForm.action,
|
||||
status: handleForm.status as any,
|
||||
remark: handleForm.remark || undefined,
|
||||
attachment_ids: attachmentIds.length > 0 ? attachmentIds : undefined,
|
||||
}
|
||||
const res: any = await afterSaleHandleWorkOrder(params)
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success(res.message || '处理成功')
|
||||
handleDialogVisible.value = false
|
||||
resetHandleAttachments()
|
||||
fetchDetail()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '处理失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理工单失败:', error)
|
||||
ElMessage.error('处理失败')
|
||||
} finally {
|
||||
handleLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 转单 ====================
|
||||
|
||||
const transferDialogVisible_ = ref(false)
|
||||
const transferLoading = ref(false)
|
||||
const transferFormRef = ref<FormInstance>()
|
||||
|
||||
const transferForm = reactive({
|
||||
role_group: '' as string,
|
||||
remark: '' as string,
|
||||
})
|
||||
|
||||
const transferRules: FormRules = {
|
||||
role_group: [{ required: true, message: '请选择目标角色组', trigger: 'change' }],
|
||||
}
|
||||
|
||||
function showTransferDialog() {
|
||||
transferForm.role_group = ''
|
||||
transferForm.remark = ''
|
||||
transferDialogVisible_.value = true
|
||||
}
|
||||
|
||||
async function handleSubmitTransfer() {
|
||||
const valid = await transferFormRef.value?.validate().catch(() => false)
|
||||
if (!valid || !detail.value) return
|
||||
|
||||
transferLoading.value = true
|
||||
try {
|
||||
const params: AfterSaleTransferParams = {
|
||||
id: detail.value.id,
|
||||
role_group: transferForm.role_group as any,
|
||||
remark: transferForm.remark || undefined,
|
||||
}
|
||||
const res: any = await afterSaleTransfer(params)
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success(res.message || '转单成功')
|
||||
transferDialogVisible_.value = false
|
||||
fetchDetail()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '转单失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('转单失败:', error)
|
||||
ElMessage.error('转单失败')
|
||||
} finally {
|
||||
transferLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 登记理赔 ====================
|
||||
|
||||
const claimDialogVisible = ref(false)
|
||||
const claimLoading = ref(false)
|
||||
const claimFormRef = ref<FormInstance>()
|
||||
|
||||
const claimForm = reactive({
|
||||
claim_needed: 0 as 0 | 1,
|
||||
claim_amount: undefined as number | undefined,
|
||||
claim_status: '' as string,
|
||||
carrier_claim_needed: 0 as 0 | 1,
|
||||
carrier_claim_amount: undefined as number | undefined,
|
||||
carrier_claim_status: '' as string,
|
||||
claim_action: '' as string,
|
||||
claim_remark: '' as string,
|
||||
})
|
||||
|
||||
const claimRules: FormRules = {
|
||||
claim_action: [{ required: true, message: '请输入操作动作', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
function showClaimDialog() {
|
||||
claimForm.claim_needed = detail.value?.claim_needed ?? 0
|
||||
claimForm.claim_amount = detail.value?.claim_amount ?? undefined
|
||||
claimForm.claim_status = detail.value?.claim_status ?? ''
|
||||
claimForm.carrier_claim_needed = detail.value?.carrier_claim_needed ?? 0
|
||||
claimForm.carrier_claim_amount = detail.value?.carrier_claim_amount ?? undefined
|
||||
claimForm.carrier_claim_status = detail.value?.carrier_claim_status ?? ''
|
||||
claimForm.claim_action = ''
|
||||
claimForm.claim_remark = ''
|
||||
resetClaimAttachments()
|
||||
claimDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmitClaim() {
|
||||
const valid = await claimFormRef.value?.validate().catch(() => false)
|
||||
if (!valid || !detail.value) return
|
||||
|
||||
claimLoading.value = true
|
||||
try {
|
||||
// 先上传附件
|
||||
const attachmentIds = await uploadFilesBatch(claimFileList.value)
|
||||
|
||||
const params: AfterSaleRegisterClaimParams = {
|
||||
id: detail.value.id,
|
||||
claim_needed: claimForm.claim_needed,
|
||||
claim_amount: claimForm.claim_needed ? claimForm.claim_amount : undefined,
|
||||
claim_status: claimForm.claim_needed ? (claimForm.claim_status as any) : undefined,
|
||||
carrier_claim_needed: claimForm.carrier_claim_needed,
|
||||
carrier_claim_amount: claimForm.carrier_claim_needed ? claimForm.carrier_claim_amount : undefined,
|
||||
carrier_claim_status: claimForm.carrier_claim_needed ? (claimForm.carrier_claim_status as any) : undefined,
|
||||
action: claimForm.claim_action,
|
||||
remark: claimForm.claim_remark || undefined,
|
||||
attachment_ids: attachmentIds.length > 0 ? attachmentIds : undefined,
|
||||
}
|
||||
const res: any = await afterSaleRegisterClaim(params)
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success('理赔登记成功')
|
||||
claimDialogVisible.value = false
|
||||
resetClaimAttachments()
|
||||
fetchDetail()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '理赔登记失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('登记理赔失败:', error)
|
||||
ElMessage.error('理赔登记失败')
|
||||
} finally {
|
||||
claimLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 生命周期 ====================
|
||||
|
||||
onMounted(() => {
|
||||
fetchDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.after-sale-detail-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 8px 16px;
|
||||
}
|
||||
|
||||
.detail-header-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
margin-bottom: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.detail-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.claim-section h4 {
|
||||
margin: 0 0 12px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.step-item {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.step-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.step-action {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.step-remark {
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.step-operator {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.step-attachments {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.att-label {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.att-item {
|
||||
display: inline-block;
|
||||
background: #f0f2f5;
|
||||
padding: 1px 6px;
|
||||
border-radius: 3px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
</style>
|
||||
264
src/views/afterSale/list/afterSale-config.ts
Normal file
264
src/views/afterSale/list/afterSale-config.ts
Normal file
@ -0,0 +1,264 @@
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
|
||||
// ============================================================
|
||||
// 售后模块 - 枚举常量与标签映射
|
||||
// ============================================================
|
||||
|
||||
// -------------------- 售后类型 --------------------
|
||||
export const AFTER_SALE_TYPE_MAP: Record<string, string> = {
|
||||
order: '订单',
|
||||
receiving: '收货单',
|
||||
entry: '入库单',
|
||||
stockout: '出库单',
|
||||
}
|
||||
|
||||
export const AFTER_SALE_TYPE_TAG_MAP: Record<string, string> = {
|
||||
order: 'primary',
|
||||
receiving: 'warning',
|
||||
entry: 'success',
|
||||
stockout: 'danger',
|
||||
}
|
||||
|
||||
// -------------------- 售后子类型 --------------------
|
||||
export const AFTER_SALE_SUB_TYPE_MAP: Record<string, string> = {
|
||||
// 订单子类型
|
||||
damage: '破损',
|
||||
missing_item: '少发',
|
||||
mis_shipment: '错发',
|
||||
wrong_sku: '错品',
|
||||
quality_issue: '质量问题',
|
||||
delivery_delay: '发货延迟',
|
||||
logistics_issue: '物流异常',
|
||||
rejected: '客户拒收',
|
||||
intercept: '拦截',
|
||||
verify_delivery: '核实签收',
|
||||
urge: '催件',
|
||||
extra_item: '多发',
|
||||
change_address: '改地址',
|
||||
change_carrier: '换快递',
|
||||
weight_issue: '重量异常',
|
||||
freight_issue: '运费争议',
|
||||
other: '其他',
|
||||
// 收货/入库子类型
|
||||
shortage: '少货',
|
||||
// 出库子类型
|
||||
return_issue: '退货异常',
|
||||
wrong_outbound: '错发',
|
||||
}
|
||||
|
||||
// -------------------- 售后状态 --------------------
|
||||
export const AFTER_SALE_STATUS_MAP: Record<string, string> = {
|
||||
pending: '待处理',
|
||||
processing: '处理中',
|
||||
completed: '已完成',
|
||||
closed: '已关闭',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
|
||||
export const AFTER_SALE_STATUS_TAG_MAP: Record<string, string> = {
|
||||
pending: 'warning',
|
||||
processing: 'primary',
|
||||
completed: 'success',
|
||||
closed: 'info',
|
||||
cancelled: 'danger',
|
||||
}
|
||||
|
||||
// -------------------- 角色组 --------------------
|
||||
export const AFTER_SALE_ROLE_GROUP_MAP: Record<string, string> = {
|
||||
customer_service: '客服组',
|
||||
warehouse: '仓库组',
|
||||
finance: '财务组',
|
||||
}
|
||||
|
||||
export const AFTER_SALE_ROLE_GROUP_TAG_MAP: Record<string, string> = {
|
||||
customer_service: 'primary',
|
||||
warehouse: 'warning',
|
||||
finance: 'success',
|
||||
}
|
||||
|
||||
// -------------------- 理赔状态 --------------------
|
||||
export const CLAIM_STATUS_MAP: Record<string, string> = {
|
||||
pending: '待理赔',
|
||||
reviewing: '审核中',
|
||||
approved: '已通过',
|
||||
paid: '已打款',
|
||||
monthly: '月结',
|
||||
rejected: '已拒绝',
|
||||
}
|
||||
|
||||
export const CLAIM_STATUS_TAG_MAP: Record<string, string> = {
|
||||
pending: 'warning',
|
||||
reviewing: 'primary',
|
||||
approved: 'success',
|
||||
paid: 'success',
|
||||
monthly: 'info',
|
||||
rejected: 'danger',
|
||||
}
|
||||
|
||||
// -------------------- 步骤状态 --------------------
|
||||
export const STEP_STATUS_MAP: Record<number, string> = {
|
||||
0: '待开始',
|
||||
1: '进行中',
|
||||
2: '已完成',
|
||||
3: '已跳过',
|
||||
}
|
||||
|
||||
export const STEP_STATUS_TAG_MAP: Record<number, string> = {
|
||||
0: 'info',
|
||||
1: 'primary',
|
||||
2: 'success',
|
||||
3: 'warning',
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 售后列表页 - 配置
|
||||
// ============================================================
|
||||
|
||||
// -------------------- ScanBox 筛选字段 --------------------
|
||||
export const afterSaleAvailableFields = [
|
||||
{
|
||||
value: 'after_sale_no',
|
||||
label: '售后单号',
|
||||
type: 'text',
|
||||
placeholder: '输入售后单号',
|
||||
operators: ['eq', 'contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'type',
|
||||
label: '售后类型',
|
||||
type: 'select',
|
||||
placeholder: '请选择售后类型',
|
||||
operators: ['eq'],
|
||||
defaultOperator: 'eq',
|
||||
options: [
|
||||
{ label: '订单', value: 'order' },
|
||||
{ label: '收货单', value: 'receiving' },
|
||||
{ label: '入库单', value: 'entry' },
|
||||
{ label: '出库单', value: 'stockout' },
|
||||
],
|
||||
},
|
||||
{
|
||||
value: 'sub_type',
|
||||
label: '子类型',
|
||||
type: 'select',
|
||||
placeholder: '请选择子类型',
|
||||
operators: ['eq'],
|
||||
defaultOperator: 'eq',
|
||||
options: Object.entries(AFTER_SALE_SUB_TYPE_MAP).map(([k, v]) => ({ label: v, value: k })),
|
||||
},
|
||||
{
|
||||
value: 'status',
|
||||
label: '售后状态',
|
||||
type: 'select',
|
||||
placeholder: '请选择状态',
|
||||
operators: ['eq'],
|
||||
defaultOperator: 'eq',
|
||||
options: [
|
||||
{ label: '待处理', value: 'pending' },
|
||||
{ label: '处理中', value: 'processing' },
|
||||
{ label: '已完成', value: 'completed' },
|
||||
{ label: '已关闭', value: 'closed' },
|
||||
{ label: '已取消', value: 'cancelled' },
|
||||
],
|
||||
},
|
||||
{
|
||||
value: 'priority',
|
||||
label: '优先级',
|
||||
type: 'number',
|
||||
placeholder: '0-10',
|
||||
operators: ['eq', 'gte', 'lte'],
|
||||
defaultOperator: 'eq',
|
||||
},
|
||||
{
|
||||
value: 'role_group',
|
||||
label: '角色组',
|
||||
type: 'select',
|
||||
placeholder: '请选择角色组',
|
||||
operators: ['eq'],
|
||||
defaultOperator: 'eq',
|
||||
options: [
|
||||
{ label: '客服组', value: 'customer_service' },
|
||||
{ label: '仓库组', value: 'warehouse' },
|
||||
{ label: '财务组', value: 'finance' },
|
||||
],
|
||||
},
|
||||
{
|
||||
value: 'waybill_no',
|
||||
label: '运单号',
|
||||
type: 'text',
|
||||
placeholder: '输入运单号',
|
||||
operators: ['eq', 'contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'order_delivery_no',
|
||||
label: '发货订单号',
|
||||
type: 'text',
|
||||
placeholder: '输入发货订单号',
|
||||
operators: ['eq', 'contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'entry_order_no',
|
||||
label: '入库单号',
|
||||
type: 'text',
|
||||
placeholder: '输入入库单号',
|
||||
operators: ['eq', 'contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'order_stockout_no',
|
||||
label: '出库单号',
|
||||
type: 'text',
|
||||
placeholder: '输入出库单号',
|
||||
operators: ['eq', 'contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'receiving_no',
|
||||
label: '收货单号',
|
||||
type: 'text',
|
||||
placeholder: '输入收货单号',
|
||||
operators: ['eq', 'contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'created_at',
|
||||
label: '创建时间',
|
||||
type: 'daterange',
|
||||
placeholder: '选择日期范围',
|
||||
operators: ['between'],
|
||||
defaultOperator: 'between',
|
||||
},
|
||||
]
|
||||
|
||||
// -------------------- UpperTable 列配置 --------------------
|
||||
export const afterSaleColumns = [
|
||||
{ prop: 'after_sale_no', label: '售后单号', minWidth: '180', showOverflowTooltip: true },
|
||||
{ prop: 'type', label: '售后类型', width: '100' },
|
||||
{ prop: 'sub_type', label: '子类型', width: '110' },
|
||||
{ prop: 'title', label: '标题', minWidth: '180', showOverflowTooltip: true },
|
||||
{ prop: 'status', label: '状态', width: '90' },
|
||||
{ prop: 'priority', label: '优先级', width: '80', align: 'center' },
|
||||
{ prop: 'role_group', label: '角色组', width: '100' },
|
||||
{ prop: 'claim_status', label: '仓库理赔', width: '100' },
|
||||
{ prop: 'carrier_claim_status', label: '运方理赔', width: '100' },
|
||||
{ prop: 'waybill_no', label: '运单号', width: '150', showOverflowTooltip: true },
|
||||
{ prop: 'order_delivery_no', label: '发货订单号', width: '150', showOverflowTooltip: true },
|
||||
{ prop: 'entry_order_no', label: '入库单号', width: '150', showOverflowTooltip: true },
|
||||
{ prop: 'order_stockout_no', label: '出库单号', width: '150', showOverflowTooltip: true },
|
||||
{ prop: 'receiving_no', label: '收货单号', width: '150', showOverflowTooltip: true },
|
||||
{ prop: 'resolved_at', label: '完结时间', width: '170' },
|
||||
{ prop: 'created_at', label: '创建时间', width: '170' },
|
||||
{ prop: 'actions', label: '操作', width: '180', fixed: 'right' },
|
||||
]
|
||||
|
||||
// -------------------- 工具栏按钮 --------------------
|
||||
export const afterSaleToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'refresh' },
|
||||
{ key: 'create', label: '创建售后单', category: 'action', size: 'small', type: 'primary', action: 'showCreateDialog' },
|
||||
{ key: 'export', label: '导出', category: 'action', size: 'small', type: 'success', loadingKey: 'exportLoading', action: 'handleExport' },
|
||||
]
|
||||
|
||||
|
||||
716
src/views/afterSale/list/index.vue
Normal file
716
src/views/afterSale/list/index.vue
Normal file
@ -0,0 +1,716 @@
|
||||
<template>
|
||||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
cache-key="afterSale-list"
|
||||
width="250px"
|
||||
:tree-props="{ children: 'children', label: 'label' }"
|
||||
:auto-submit="false"
|
||||
:available-fields="availableFields"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
/>
|
||||
|
||||
<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">
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
title="售后列表"
|
||||
default-align="center"
|
||||
table-id="afterSale-list"
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
:table-size="tableSize"
|
||||
:pagination="upperPagination"
|
||||
:show-index="true"
|
||||
:show-actions="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
row-key="id"
|
||||
@current-change="handleRowClick"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@sort-change="handleSortChange"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<!-- 售后类型 -->
|
||||
<template #column-type="{ row }">
|
||||
<el-tag size="small" :type="typeTagType(row.type)">
|
||||
{{ typeLabel(row.type) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<!-- 子类型 -->
|
||||
<template #column-sub_type="{ row }">
|
||||
{{ subTypeLabel(row.sub_type) }}
|
||||
</template>
|
||||
|
||||
<!-- 状态 -->
|
||||
<template #column-status="{ row }">
|
||||
<el-tag size="small" :type="statusTagType(row.status)">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<!-- 角色组 -->
|
||||
<template #column-role_group="{ row }">
|
||||
<el-tag v-if="row.role_group" size="small" :type="roleGroupTagType(row.role_group)">
|
||||
{{ roleGroupLabel(row.role_group) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<!-- 仓库理赔 -->
|
||||
<template #column-claim_status="{ row }">
|
||||
<el-tag v-if="row.claim_status" size="small" :type="claimStatusTagType(row.claim_status)">
|
||||
{{ claimStatusLabel(row.claim_status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<!-- 运方理赔 -->
|
||||
<template #column-carrier_claim_status="{ row }">
|
||||
<el-tag v-if="row.carrier_claim_status" size="small" :type="claimStatusTagType(row.carrier_claim_status)">
|
||||
{{ claimStatusLabel(row.carrier_claim_status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #column-actions="{ row }">
|
||||
<div class="wave-operation-actions">
|
||||
<el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">详情</el-button>
|
||||
<el-button size="small" type="primary" link @click.stop="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-if="row.status === 'pending' || row.status === 'processing'" size="small" type="warning" link @click.stop="handleTransfer(row)">转单</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无售后单</div>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========== 弹窗 ========== -->
|
||||
|
||||
<!-- 创建/编辑售后单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="formDialogVisible"
|
||||
:title="isEditMode ? '编辑售后单' : '创建售后单'"
|
||||
width="650px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="110px" size="small">
|
||||
<el-form-item label="售后类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择售后类型" style="width: 100%" @change="onTypeChange">
|
||||
<el-option v-for="(label, value) in typeOptions" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="子类型" prop="sub_type">
|
||||
<el-select v-model="formData.sub_type" placeholder="请选择子类型" style="width: 100%">
|
||||
<el-option v-for="(label, value) in currentSubTypeOptions" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="formData.title" placeholder="请输入售后标题" maxlength="200" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="详细描述">
|
||||
<el-input v-model="formData.description" type="textarea" :rows="3" placeholder="请输入详细描述" maxlength="1000" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="优先级">
|
||||
<el-input-number v-model="formData.priority" :min="0" :max="10" placeholder="0-10,默认0" style="width: 120px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联运单号">
|
||||
<el-input v-model="formData.waybill_no" placeholder="输入运单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联发货订单号">
|
||||
<el-input v-model="formData.order_delivery_no" placeholder="输入发货订单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联入库单号">
|
||||
<el-input v-model="formData.entry_order_no" placeholder="输入入库单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联出库单号">
|
||||
<el-input v-model="formData.order_stockout_no" placeholder="输入出库单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联收货单号">
|
||||
<el-input v-model="formData.receiving_no" placeholder="输入收货单号" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="formDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="formLoading" @click="handleSubmitForm">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 转单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="transferDialogVisible"
|
||||
title="转单"
|
||||
width="500px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form ref="transferFormRef" :model="transferForm" :rules="transferRules" label-width="110px" size="small">
|
||||
<el-form-item label="售后单号">
|
||||
<el-input :model-value="transferForm.after_sale_no" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="目标角色组" prop="role_group">
|
||||
<el-select v-model="transferForm.role_group" placeholder="请选择目标角色组" style="width: 100%">
|
||||
<el-option label="客服组" value="customer_service" />
|
||||
<el-option label="仓库组" value="warehouse" />
|
||||
<el-option label="财务组" value="finance" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转单备注">
|
||||
<el-input v-model="transferForm.remark" type="textarea" :rows="2" placeholder="请输入转单备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="transferDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="transferLoading" @click="handleSubmitTransfer">确认转单</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导出进度弹窗 -->
|
||||
<AsyncExportProgressDialog
|
||||
v-model:visible="exportDialogVisible"
|
||||
:task-progress="exportTaskProgress"
|
||||
:progress-percent="exportProgressPercent"
|
||||
:progress-status="exportProgressStatus"
|
||||
:status-label="exportStatusLabel"
|
||||
@cancel="handleCancelExport"
|
||||
/>
|
||||
|
||||
<!-- 跳转路由(用于查看详情) -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, reactive, ref, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
afterSaleWorkList,
|
||||
afterSaleCreate,
|
||||
afterSaleUpdate,
|
||||
afterSaleTransfer,
|
||||
afterSaleExport,
|
||||
afterSaleExportTaskProgress,
|
||||
type AfterSaleListParams,
|
||||
type AfterSaleCreateParams,
|
||||
type AfterSaleUpdateParams,
|
||||
type AfterSaleTransferParams,
|
||||
} from '@/api/afterSale/index'
|
||||
import {
|
||||
afterSaleAvailableFields,
|
||||
afterSaleColumns,
|
||||
afterSaleToolbarButtons,
|
||||
AFTER_SALE_TYPE_MAP,
|
||||
AFTER_SALE_TYPE_TAG_MAP,
|
||||
AFTER_SALE_SUB_TYPE_MAP,
|
||||
AFTER_SALE_STATUS_MAP,
|
||||
AFTER_SALE_STATUS_TAG_MAP,
|
||||
AFTER_SALE_ROLE_GROUP_MAP,
|
||||
AFTER_SALE_ROLE_GROUP_TAG_MAP,
|
||||
CLAIM_STATUS_MAP,
|
||||
CLAIM_STATUS_TAG_MAP,
|
||||
} from './afterSale-config'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
|
||||
// ==================== 工具函数 ====================
|
||||
|
||||
function typeLabel(t: string) { return AFTER_SALE_TYPE_MAP[t] ?? t ?? '-' }
|
||||
function typeTagType(t: string) { return AFTER_SALE_TYPE_TAG_MAP[t] ?? 'info' }
|
||||
function subTypeLabel(s: string) { return AFTER_SALE_SUB_TYPE_MAP[s] ?? s ?? '-' }
|
||||
function statusLabel(s: string) { return AFTER_SALE_STATUS_MAP[s] ?? s ?? '-' }
|
||||
function statusTagType(s: string) { return AFTER_SALE_STATUS_TAG_MAP[s] ?? 'info' }
|
||||
function roleGroupLabel(r: string) { return AFTER_SALE_ROLE_GROUP_MAP[r] ?? r ?? '-' }
|
||||
function roleGroupTagType(r: string) { return AFTER_SALE_ROLE_GROUP_TAG_MAP[r] ?? 'info' }
|
||||
function claimStatusLabel(c: string) { return CLAIM_STATUS_MAP[c] ?? c ?? '-' }
|
||||
function claimStatusTagType(c: string) { return CLAIM_STATUS_TAG_MAP[c] ?? 'info' }
|
||||
|
||||
// ==================== 子类型映射(按 type 分组) ====================
|
||||
const subTypeOptionsByType: Record<string, Record<string, string>> = {
|
||||
order: {
|
||||
damage: '破损', missing_item: '少发', mis_shipment: '错发', wrong_sku: '错品',
|
||||
quality_issue: '质量问题', delivery_delay: '发货延迟', logistics_issue: '物流异常',
|
||||
rejected: '客户拒收', intercept: '拦截', verify_delivery: '核实签收', urge: '催件',
|
||||
extra_item: '多发', change_address: '改地址', change_carrier: '换快递',
|
||||
weight_issue: '重量异常', freight_issue: '运费争议', other: '其他',
|
||||
},
|
||||
receiving: {
|
||||
shortage: '少货', damage: '破损', wrong_sku: '错品', quality_issue: '质量问题', other: '其他',
|
||||
},
|
||||
entry: {
|
||||
shortage: '少货', damage: '破损', wrong_sku: '错品', quality_issue: '质量问题', other: '其他',
|
||||
},
|
||||
stockout: {
|
||||
return_issue: '退货异常', wrong_outbound: '错发', shortage: '少发', other: '其他',
|
||||
},
|
||||
}
|
||||
|
||||
const typeOptions = AFTER_SALE_TYPE_MAP
|
||||
|
||||
// ==================== 布局 ====================
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// ==================== 配置 ====================
|
||||
|
||||
const availableFields = afterSaleAvailableFields
|
||||
const columns = afterSaleColumns
|
||||
const tableSize = 'small'
|
||||
const toolbarButtons = afterSaleToolbarButtons
|
||||
|
||||
// ==================== 按钮状态 ====================
|
||||
|
||||
const buttonLoadingMap = computed(() => ({
|
||||
loading: loading.value,
|
||||
exportLoading: exportLoading.value,
|
||||
}))
|
||||
|
||||
const buttonDisabledMap = computed(() => ({}))
|
||||
|
||||
const buttonLabelMap = computed(() => ({}))
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
refresh: () => handleRefresh(),
|
||||
showCreateDialog: () => showCreateDialog(),
|
||||
handleExport: () => handleExport(),
|
||||
}
|
||||
|
||||
function handleToolbarButtonClick(action: string) {
|
||||
const handler = toolbarActionMap[action]
|
||||
if (!handler) return
|
||||
safeInvoke(() => handler())
|
||||
}
|
||||
|
||||
// ==================== 数据状态 ====================
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
const tableData = ref<any[]>([])
|
||||
const currentConditions = ref<Record<string, any>>({})
|
||||
const selectedRow = ref<any>(null)
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
// ==================== 导出 ====================
|
||||
|
||||
const {
|
||||
exportLoading,
|
||||
exportDialogVisible,
|
||||
exportTaskProgress,
|
||||
exportProgressPercent,
|
||||
exportProgressStatus,
|
||||
exportStatusLabel,
|
||||
submitExportTask,
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'afterSale:list:exportTaskId',
|
||||
submitExport: (payload) => afterSaleExport(payload as any),
|
||||
queryProgress: (params) => afterSaleExportTaskProgress(params as any),
|
||||
})
|
||||
|
||||
function handleExport() {
|
||||
const where = buildWhereFromConditions(currentConditions.value)
|
||||
submitExportTask({ where, sort: {} })
|
||||
}
|
||||
|
||||
function handleCancelExport() {
|
||||
exportDialogVisible.value = false
|
||||
}
|
||||
|
||||
// ==================== ScanBox 事件 ====================
|
||||
|
||||
function handleConditionChange(conditions: Record<string, any>) {
|
||||
currentConditions.value = conditions ?? {}
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleConditionReset() {
|
||||
currentConditions.value = {}
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleConditionClear() {
|
||||
currentConditions.value = {}
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleRowClick(row: any) {
|
||||
selectedRow.value = row
|
||||
}
|
||||
|
||||
// ==================== 数据查询 ====================
|
||||
|
||||
function buildWhereFromConditions(conditions: Record<string, any>): Record<string, any> {
|
||||
const where: Record<string, any> = {}
|
||||
for (const [key, cond] of Object.entries(conditions)) {
|
||||
if (cond === undefined || cond === null || cond === '') continue
|
||||
if (typeof cond === 'object' && cond.value !== undefined) {
|
||||
const val = cond.value
|
||||
const op = cond.operator || 'eq'
|
||||
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
|
||||
where[key] = { operator: op, value: val }
|
||||
} else {
|
||||
where[key] = { operator: 'eq', value: cond }
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
const start = Date.now()
|
||||
try {
|
||||
const where = buildWhereFromConditions(currentConditions.value)
|
||||
const params: AfterSaleListParams = {
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
}
|
||||
const res: any = await afterSaleWorkList(params)
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||
const data = res.data ?? res
|
||||
tableData.value = data.list ?? []
|
||||
const total = data.total ?? (data.pagination?.total ?? 0)
|
||||
pagination.total = total
|
||||
upperPagination.total = total
|
||||
} else {
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
upperPagination.total = 0
|
||||
ElMessage.error(res?.message || '获取售后列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取售后列表失败:', error)
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
upperPagination.total = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
queryTime.value = Date.now() - start
|
||||
}
|
||||
}
|
||||
|
||||
function handleRefresh() {
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSortChange(_sort: { prop: string; order: string }) {
|
||||
// 预留排序事件处理
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
pagination.currentPage = page
|
||||
upperPagination.currentPage = page
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageSizeChange(size: number) {
|
||||
pagination.pageSize = size
|
||||
upperPagination.pageSize = size
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// ==================== 创建 / 编辑 ====================
|
||||
|
||||
const formDialogVisible = ref(false)
|
||||
const isEditMode = ref(false)
|
||||
const formLoading = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const defaultFormData = () => ({
|
||||
id: null as number | null,
|
||||
type: 'order' as string,
|
||||
sub_type: '' as string,
|
||||
title: '' as string,
|
||||
description: '' as string,
|
||||
priority: 0 as number,
|
||||
waybill_no: '' as string,
|
||||
order_delivery_no: '' as string,
|
||||
entry_order_no: '' as string,
|
||||
order_stockout_no: '' as string,
|
||||
receiving_no: '' as string,
|
||||
})
|
||||
|
||||
const formData = reactive(defaultFormData())
|
||||
|
||||
const formRules: FormRules = {
|
||||
type: [{ required: true, message: '请选择售后类型', trigger: 'change' }],
|
||||
sub_type: [{ required: true, message: '请选择子类型', trigger: 'change' }],
|
||||
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
const currentSubTypeOptions = computed(() => {
|
||||
return subTypeOptionsByType[formData.type] || {}
|
||||
})
|
||||
|
||||
function onTypeChange() {
|
||||
formData.sub_type = ''
|
||||
}
|
||||
|
||||
function showCreateDialog() {
|
||||
isEditMode.value = false
|
||||
Object.assign(formData, defaultFormData())
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleEdit(row: any) {
|
||||
isEditMode.value = true
|
||||
formData.id = row.id
|
||||
formData.type = row.type
|
||||
formData.sub_type = row.sub_type
|
||||
formData.title = row.title
|
||||
formData.description = row.description ?? ''
|
||||
formData.priority = row.priority ?? 0
|
||||
formData.waybill_no = row.waybill_no ?? ''
|
||||
formData.order_delivery_no = row.order_delivery_no ?? ''
|
||||
formData.entry_order_no = row.entry_order_no ?? ''
|
||||
formData.order_stockout_no = row.order_stockout_no ?? ''
|
||||
formData.receiving_no = row.receiving_no ?? ''
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
async function handleSubmitForm() {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
let res: any
|
||||
if (isEditMode.value && formData.id) {
|
||||
const updateParams: AfterSaleUpdateParams = {
|
||||
id: formData.id,
|
||||
type: formData.type as any,
|
||||
sub_type: formData.sub_type,
|
||||
title: formData.title,
|
||||
description: formData.description || undefined,
|
||||
priority: formData.priority,
|
||||
waybill_no: formData.waybill_no || undefined,
|
||||
order_delivery_no: formData.order_delivery_no || undefined,
|
||||
entry_order_no: formData.entry_order_no || undefined,
|
||||
order_stockout_no: formData.order_stockout_no || undefined,
|
||||
receiving_no: formData.receiving_no || undefined,
|
||||
}
|
||||
res = await afterSaleUpdate(updateParams)
|
||||
} else {
|
||||
const createParams: AfterSaleCreateParams = {
|
||||
type: formData.type as any,
|
||||
sub_type: formData.sub_type,
|
||||
title: formData.title,
|
||||
description: formData.description || undefined,
|
||||
priority: formData.priority,
|
||||
waybill_no: formData.waybill_no || undefined,
|
||||
order_delivery_no: formData.order_delivery_no || undefined,
|
||||
entry_order_no: formData.entry_order_no || undefined,
|
||||
order_stockout_no: formData.order_stockout_no || undefined,
|
||||
receiving_no: formData.receiving_no || undefined,
|
||||
}
|
||||
res = await afterSaleCreate(createParams)
|
||||
}
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success(isEditMode.value ? '更新成功' : '创建成功')
|
||||
formDialogVisible.value = false
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '操作失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交售后单失败:', error)
|
||||
ElMessage.error('操作失败')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 转单 ====================
|
||||
|
||||
const transferDialogVisible = ref(false)
|
||||
const transferLoading = ref(false)
|
||||
const transferFormRef = ref<FormInstance>()
|
||||
|
||||
const transferForm = reactive({
|
||||
id: null as number | null,
|
||||
after_sale_no: '' as string,
|
||||
role_group: '' as string,
|
||||
remark: '' as string,
|
||||
})
|
||||
|
||||
const transferRules: FormRules = {
|
||||
role_group: [{ required: true, message: '请选择目标角色组', trigger: 'change' }],
|
||||
}
|
||||
|
||||
function handleTransfer(row: any) {
|
||||
transferForm.id = row.id
|
||||
transferForm.after_sale_no = row.after_sale_no
|
||||
transferForm.role_group = ''
|
||||
transferForm.remark = ''
|
||||
transferDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmitTransfer() {
|
||||
const valid = await transferFormRef.value?.validate().catch(() => false)
|
||||
if (!valid || !transferForm.id) return
|
||||
|
||||
transferLoading.value = true
|
||||
try {
|
||||
const params: AfterSaleTransferParams = {
|
||||
id: transferForm.id,
|
||||
role_group: transferForm.role_group as any,
|
||||
remark: transferForm.remark || undefined,
|
||||
}
|
||||
const res: any = await afterSaleTransfer(params)
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success(res.message || '转单成功')
|
||||
transferDialogVisible.value = false
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '转单失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('转单失败:', error)
|
||||
ElMessage.error('转单失败')
|
||||
} finally {
|
||||
transferLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 查看详情 ====================
|
||||
|
||||
function handleViewDetail(row: any) {
|
||||
router.push({ name: 'afterSale.detail', query: { id: row.id } })
|
||||
}
|
||||
|
||||
// ==================== 生命周期 ====================
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
// 清理导出定时器
|
||||
onUnmounted(() => {
|
||||
// useAsyncExportTask 内部会自动清理
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.order-sub-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.toolbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.split-stack {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.upper-wrapper {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wave-operation-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
padding: 40px 0;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
391
src/views/message/components/CreateAfterSaleDialog.vue
Normal file
391
src/views/message/components/CreateAfterSaleDialog.vue
Normal file
@ -0,0 +1,391 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="发起售后单"
|
||||
width="780px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
@update:model-value="$emit('update:visible', $event)"
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="110px" size="small">
|
||||
<el-form-item label="售后类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择售后类型" style="width: 100%" @change="onTypeChange">
|
||||
<el-option v-for="(label, value) in typeOptions" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="问题子类型" prop="sub_type">
|
||||
<el-select v-model="formData.sub_type" placeholder="请选择问题子类型" style="width: 100%">
|
||||
<el-option v-for="(label, value) in currentSubTypeOptions" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="formData.title" placeholder="简要描述售后原因" maxlength="200" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="详细描述">
|
||||
<el-input v-model="formData.description" type="textarea" :rows="3" placeholder="详细描述(选填)" maxlength="1000" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="优先级">
|
||||
<el-input-number v-model="formData.priority" :min="0" :max="10" style="width: 120px" />
|
||||
<span class="form-tip">0-10,默认0(普通),数值越大越紧急</span>
|
||||
</el-form-item>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关联货主">
|
||||
<el-select v-model="formData.store_id" placeholder="选择货主" clearable filterable style="width: 100%">
|
||||
<el-option v-for="s in storeOptions" :key="s.value" :label="s.label" :value="s.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-divider content-position="left">关联单据(选填)</el-divider>
|
||||
|
||||
<!-- order 订单 → 关联订单(按运单号/外部订单号搜索) -->
|
||||
<template v-if="formData.type === 'order'">
|
||||
<el-form-item label="关联订单">
|
||||
<DocSearchPicker
|
||||
v-model="formData.order_delivery_no"
|
||||
title="选择订单"
|
||||
placeholder="输入运单号或外部订单号搜索"
|
||||
search-field-label="运单号/订单号"
|
||||
search-field="keyword"
|
||||
value-field="waybill_code"
|
||||
:columns="[
|
||||
{ prop: 'delivery_order_code', label: '外部订单号', minWidth: '150' },
|
||||
{ prop: 'waybill_code', label: '运单号', minWidth: '130' },
|
||||
{ prop: 'source_order_codes', label: '平台订单号', minWidth: '150' },
|
||||
{ prop: 'store_remask', label: '货主', width: '80' },
|
||||
{ prop: 'logistics_name', label: '物流', width: '70' },
|
||||
{ prop: 'logistics_interface_name', label: '物流接口', minWidth: '110' },
|
||||
{ prop: 'is_back', label: '退回', width: '60', align: 'center', formatter: (_r: any, _c: any, v: any) => v === 'Y' ? '<span style=background:#fef0f0;color:#f56c6c;padding:0 6px;border-radius:3px;font-size:12px>退回</span>' : '<span style=color:#c0c4cc>否</span>' },
|
||||
{ prop: 'is_intercept', label: '拦截', width: '60', align: 'center', formatter: (_r: any, _c: any, v: any) => v === 'Y' ? '<span style=background:#fdf6ec;color:#e6a23c;padding:0 6px;border-radius:3px;font-size:12px>拦截</span>' : '<span style=color:#c0c4cc>否</span>' },
|
||||
{ prop: 'is_galaxy_receive', label: '揽收', width: '60', align: 'center', formatter: (_r: any, _c: any, v: any) => v === 'Y' ? '<span style=background:#f0f9eb;color:#67c23a;padding:0 6px;border-radius:3px;font-size:12px>揽收</span>' : '<span style=color:#c0c4cc>否</span>' },
|
||||
]"
|
||||
:fetch-fn="orderSearchFetchFn"
|
||||
:extract-list="(res: any) => res?.data?.list ?? res?.list ?? []"
|
||||
:extract-total="(res: any) => (res?.data?.list ?? res?.list ?? []).length"
|
||||
@select="onOrderSelected"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<!-- receiving 收货单 → 收货单号 -->
|
||||
<template v-if="formData.type === 'receiving'">
|
||||
<el-form-item label="收货单号">
|
||||
<DocSearchPicker
|
||||
v-model="formData.receiving_no"
|
||||
title="选择收货单"
|
||||
placeholder="搜索收货单号"
|
||||
search-field-label="收货单号"
|
||||
search-field="keyword"
|
||||
value-field="receiving_code"
|
||||
:columns="[
|
||||
{ prop: 'receiving_code', label: '收货单号', minWidth: '180' },
|
||||
{ prop: 'store_remark_name', label: '货主', width: '120' },
|
||||
{ prop: 'status_text', label: '状态', width: '80' },
|
||||
{ prop: 'created_at', label: '创建时间', width: '150' },
|
||||
]"
|
||||
:fetch-fn="receivingFetchFn"
|
||||
:extract-list="(res: any) => res?.list ?? res?.data?.list ?? []"
|
||||
:extract-total="(res: any) => res?.pagination?.total ?? res?.data?.total ?? 0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<!-- entry 入库单 → 入库单号 -->
|
||||
<template v-if="formData.type === 'entry'">
|
||||
<el-form-item label="入库单号">
|
||||
<DocSearchPicker
|
||||
v-model="formData.entry_order_no"
|
||||
title="选择入库单"
|
||||
placeholder="搜索入库单号"
|
||||
search-field-label="入库单号"
|
||||
search-field="keyword"
|
||||
value-field="entry_order_code"
|
||||
:columns="[
|
||||
{ prop: 'entry_order_code', label: '入库单号', minWidth: '180' },
|
||||
{ prop: 'store_remark_name', label: '货主', width: '120' },
|
||||
{ prop: 'status_text', label: '状态', width: '80' },
|
||||
{ prop: 'created_at', label: '创建时间', width: '150' },
|
||||
]"
|
||||
:fetch-fn="entryFetchFn"
|
||||
:extract-list="(res: any) => res?.list ?? res?.data?.list ?? []"
|
||||
:extract-total="(res: any) => res?.pagination?.total ?? res?.data?.total ?? 0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<!-- stockout 出库单 → 出库单号 -->
|
||||
<template v-if="formData.type === 'stockout'">
|
||||
<el-form-item label="出库单号">
|
||||
<DocSearchPicker
|
||||
v-model="formData.order_stockout_no"
|
||||
title="选择出库单"
|
||||
placeholder="搜索出库单号"
|
||||
search-field-label="出库单号"
|
||||
search-field="keyword"
|
||||
value-field="stockout_order_code"
|
||||
:columns="[
|
||||
{ prop: 'stockout_order_code', label: '出库单号', minWidth: '180' },
|
||||
{ prop: 'store_remark_name', label: '货主', width: '120' },
|
||||
{ prop: 'status_text', label: '状态', width: '80' },
|
||||
{ prop: 'created_at', label: '创建时间', width: '150' },
|
||||
]"
|
||||
:fetch-fn="stockoutFetchFn"
|
||||
:extract-list="(res: any) => res?.list ?? res?.data?.list ?? []"
|
||||
:extract-total="(res: any) => res?.pagination?.total ?? res?.data?.total ?? 0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="loading" @click="handleSubmit">
|
||||
确认创建
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { afterSaleCreate, type AfterSaleCreateParams } from '@/api/afterSale/index'
|
||||
import { AFTER_SALE_TYPE_MAP } from '@/views/afterSale/list/afterSale-config'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, mapStoreListToSelectOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { orderDeliveryOrderQuickSearch } from '@/api/order.deliveryOrder/orderdeliveryOrder'
|
||||
import { getEntryList } from '@/api/storage.entry/entry'
|
||||
import { stockoutList } from '@/api/storage.stockout/stockout'
|
||||
import { getReceivingList } from '@/api/storage_receiving/receiving'
|
||||
import DocSearchPicker from './DocSearchPicker.vue'
|
||||
|
||||
// ==================== 子类型选项(按 type 分组) ====================
|
||||
const subTypeOptionsByType: Record<string, Record<string, string>> = {
|
||||
order: {
|
||||
damage: '破损', missing_item: '少发', mis_shipment: '错发', wrong_sku: '错品',
|
||||
quality_issue: '质量问题', delivery_delay: '发货延迟', logistics_issue: '物流异常',
|
||||
rejected: '客户拒收', intercept: '拦截', verify_delivery: '核实签收', urge: '催件',
|
||||
extra_item: '多发', change_address: '改地址', change_carrier: '换快递',
|
||||
weight_issue: '重量异常', freight_issue: '运费争议', other: '其他',
|
||||
},
|
||||
receiving: {
|
||||
shortage: '少货', damage: '破损', wrong_sku: '错品', quality_issue: '质量问题', other: '其他',
|
||||
},
|
||||
entry: {
|
||||
shortage: '少货', damage: '破损', wrong_sku: '错品', quality_issue: '质量问题', other: '其他',
|
||||
},
|
||||
stockout: {
|
||||
return_issue: '退货异常', wrong_outbound: '错发', shortage: '少发', other: '其他',
|
||||
},
|
||||
}
|
||||
|
||||
// ==================== Props / Emits ====================
|
||||
const props = defineProps<{ visible: boolean }>()
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
success: []
|
||||
}>()
|
||||
|
||||
// ==================== 选项 ====================
|
||||
const typeOptions = AFTER_SALE_TYPE_MAP
|
||||
|
||||
const currentSubTypeOptions = computed(() => {
|
||||
return subTypeOptionsByType[formData.type] || {}
|
||||
})
|
||||
|
||||
function onTypeChange() {
|
||||
formData.sub_type = ''
|
||||
formData.waybill_id = undefined
|
||||
formData.order_delivery_no = ''
|
||||
formData.order_delivery_id = undefined
|
||||
formData.entry_order_no = ''
|
||||
formData.entry_order_id = undefined
|
||||
formData.order_stockout_no = ''
|
||||
formData.order_stockout_id = undefined
|
||||
formData.receiving_no = ''
|
||||
formData.receiving_id = undefined
|
||||
}
|
||||
|
||||
// ==================== 表单 ====================
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
|
||||
const defaultFormData = () => ({
|
||||
type: 'order' as string,
|
||||
sub_type: '' as string,
|
||||
title: '' as string,
|
||||
description: '' as string,
|
||||
priority: 0 as number,
|
||||
store_id: undefined as number | undefined,
|
||||
waybill_id: undefined as number | undefined,
|
||||
order_delivery_no: '' as string,
|
||||
order_delivery_id: undefined as number | undefined,
|
||||
entry_order_no: '' as string,
|
||||
entry_order_id: undefined as number | undefined,
|
||||
order_stockout_no: '' as string,
|
||||
order_stockout_id: undefined as number | undefined,
|
||||
receiving_no: '' as string,
|
||||
receiving_id: undefined as number | undefined,
|
||||
})
|
||||
|
||||
const formData = reactive(defaultFormData())
|
||||
|
||||
const formRules: FormRules = {
|
||||
type: [{ required: true, message: '请选择售后类型', trigger: 'change' }],
|
||||
sub_type: [{ required: true, message: '请选择问题子类型', trigger: 'change' }],
|
||||
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
// ==================== 货主下拉 ====================
|
||||
const storeOptions = ref<Array<{ label: string; value: number | string }>>([])
|
||||
|
||||
async function fetchStoreOptions() {
|
||||
try {
|
||||
const res: any = await loadStores()
|
||||
const rawStores = extractStoreListFromResponse(res)
|
||||
storeOptions.value = mapStoreListToSelectOptions(rawStores)
|
||||
} catch {
|
||||
storeOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 组件挂载时即加载货主列表,确保后续选择单据时下拉数据已就绪
|
||||
onMounted(() => {
|
||||
fetchStoreOptions()
|
||||
})
|
||||
|
||||
// ==================== 单据搜索 fetch 函数 ====================
|
||||
|
||||
/**
|
||||
* 构建 where 条件。
|
||||
* 注意:不同模块 where 字段命名规范不一致——
|
||||
* waybill.warehouse.list → camelCase (storeId)
|
||||
* order.deliveryOrder.list 等 → snake_case (store_id),base.js 直接透传数据库列名
|
||||
*/
|
||||
function buildDocWhere(keyword: string, field: string, storeField: string): Record<string, any> {
|
||||
const where: Record<string, any> = {}
|
||||
if (formData.store_id) {
|
||||
where[storeField] = { operator: 'eq', value: formData.store_id }
|
||||
}
|
||||
if (keyword) {
|
||||
where[field] = { operator: 'contains', value: keyword }
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单快速搜索:跨表联合搜索运单号/发货单号/外部订单号/平台交易单号
|
||||
*/
|
||||
async function orderSearchFetchFn(params: { page: number; pageSize: number; keyword: string }) {
|
||||
if (!params.keyword) return { list: [], pagination: { page: 1, pageSize: 20, total: 0 } }
|
||||
const res: any = await orderDeliveryOrderQuickSearch(params.keyword)
|
||||
const list = res?.list ?? res?.data?.list ?? []
|
||||
return {
|
||||
list,
|
||||
pagination: { page: 1, pageSize: 20, total: list.length },
|
||||
}
|
||||
}
|
||||
|
||||
async function entryFetchFn(params: { page: number; pageSize: number; keyword: string }) {
|
||||
const res: any = await getEntryList({
|
||||
pagination: { page: params.page, pageSize: params.pageSize },
|
||||
where: buildDocWhere(params.keyword, 'entry_order_code', 'store_id'),
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
async function stockoutFetchFn(params: { page: number; pageSize: number; keyword: string }) {
|
||||
const res: any = await stockoutList({
|
||||
pagination: { page: params.page, pageSize: params.pageSize },
|
||||
where: buildDocWhere(params.keyword, 'stockout_order_code', 'store_id'),
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
async function receivingFetchFn(params: { page: number; pageSize: number; keyword: string }) {
|
||||
const res: any = await getReceivingList({
|
||||
pagination: { page: params.page, pageSize: params.pageSize },
|
||||
where: buildDocWhere(params.keyword, 'receiving_code', 'store_id'),
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
// ==================== 选中单据后自动回填 ====================
|
||||
|
||||
function onOrderSelected(row: any) {
|
||||
// 选中订单后,自动回填所有关联信息(字段名匹配 quickSearch 响应)
|
||||
if (row.store_id && !formData.store_id) {
|
||||
formData.store_id = row.store_id
|
||||
}
|
||||
if (row.order_id && !formData.order_delivery_id) {
|
||||
formData.order_delivery_id = row.order_id
|
||||
}
|
||||
if (row.waybill_id && !formData.waybill_id) {
|
||||
formData.waybill_id = row.waybill_id
|
||||
}
|
||||
if (row.delivery_order_code && !formData.order_delivery_no) {
|
||||
formData.order_delivery_no = row.delivery_order_code
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 提交 ====================
|
||||
async function handleSubmit() {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const params: AfterSaleCreateParams = {
|
||||
type: formData.type as any,
|
||||
sub_type: formData.sub_type,
|
||||
title: formData.title,
|
||||
description: formData.description || undefined,
|
||||
priority: formData.priority,
|
||||
store_id: formData.store_id || undefined,
|
||||
waybill_id: formData.waybill_id || undefined,
|
||||
order_id: formData.order_delivery_id || undefined,
|
||||
order_delivery_no: formData.order_delivery_no || undefined,
|
||||
entry_order_id: formData.entry_order_id || undefined,
|
||||
entry_order_no: formData.entry_order_no || undefined,
|
||||
order_stockout_id: formData.order_stockout_id || undefined,
|
||||
order_stockout_no: formData.order_stockout_no || undefined,
|
||||
receiving_id: formData.receiving_id || undefined,
|
||||
receiving_no: formData.receiving_no || undefined,
|
||||
}
|
||||
const res: any = await afterSaleCreate(params)
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
const afterSaleNo = res.after_sale_no ?? res.data?.after_sale_no ?? ''
|
||||
ElMessage.success(`售后单 ${afterSaleNo} 创建成功`)
|
||||
emit('update:visible', false)
|
||||
emit('success')
|
||||
} else {
|
||||
ElMessage.error(res?.message || '创建失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('创建售后单失败:', error)
|
||||
ElMessage.error('创建失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formRef.value?.resetFields()
|
||||
Object.assign(formData, defaultFormData())
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-tip {
|
||||
margin-left: 10px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
197
src/views/message/components/DocSearchPicker.vue
Normal file
197
src/views/message/components/DocSearchPicker.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<div class="doc-search-picker">
|
||||
<el-input
|
||||
:model-value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
clearable
|
||||
readonly
|
||||
@clear="handleClear"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="openPicker">选择</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="title"
|
||||
width="1100px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div class="picker-body">
|
||||
<div class="picker-toolbar">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
:placeholder="`输入${searchFieldLabel}搜索`"
|
||||
clearable
|
||||
style="width: 320px"
|
||||
@keyup.enter="loadData(1)"
|
||||
>
|
||||
<template #append>
|
||||
<el-button :loading="loading" @click="loadData(1)">查询</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
|
||||
<div class="picker-table-wrap">
|
||||
<UpperTable
|
||||
ref="tableRef"
|
||||
:data="list"
|
||||
:loading="loading"
|
||||
show-selection
|
||||
:pagination="{ currentPage: pagination.page, pageSize: pagination.pageSize, total: pagination.total }"
|
||||
:columns="columns"
|
||||
:row-key="(row: any) => row.id ?? row[valueField] ?? ''"
|
||||
@selection-change="handleSelectionChange"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :disabled="!selectedItem" @click="applySelection">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
|
||||
export interface DocSearchPickerColumn {
|
||||
prop: string
|
||||
label: string
|
||||
width?: string
|
||||
minWidth?: string
|
||||
formatter?: (row: any, value: any) => string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue?: string
|
||||
/** 弹窗标题 */
|
||||
title?: string
|
||||
/** 输入框占位 */
|
||||
placeholder?: string
|
||||
/** 搜索字段标签 */
|
||||
searchFieldLabel?: string
|
||||
/** 搜索时传给 API 的字段名 */
|
||||
searchField?: string
|
||||
/** 选中后返回的字段名 */
|
||||
valueField?: string
|
||||
/** 表格列定义 */
|
||||
columns?: DocSearchPickerColumn[]
|
||||
/** 列表查询 API 函数,接受 { page, pageSize, keyword } */
|
||||
fetchFn?: (params: { page: number; pageSize: number; keyword: string }) => Promise<any>
|
||||
/** 从 API 响应中提取列表数据 */
|
||||
extractList?: (res: any) => any[]
|
||||
/** 从 API 响应中提取总数 */
|
||||
extractTotal?: (res: any) => number
|
||||
}>(), {
|
||||
modelValue: '',
|
||||
title: '选择单据',
|
||||
placeholder: '请选择',
|
||||
searchFieldLabel: '单号',
|
||||
searchField: 'keyword',
|
||||
valueField: 'id',
|
||||
columns: () => [],
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: string): void
|
||||
(e: 'select', row: any): void
|
||||
}>()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
const list = ref<any[]>([])
|
||||
const selectedItem = ref<any>(null)
|
||||
const tableRef = ref()
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
function openPicker() {
|
||||
dialogVisible.value = true
|
||||
keyword.value = ''
|
||||
list.value = []
|
||||
pagination.total = 0
|
||||
selectedItem.value = null
|
||||
}
|
||||
|
||||
function handleClear() {
|
||||
emit('update:modelValue', '')
|
||||
}
|
||||
|
||||
async function loadData(page = 1) {
|
||||
if (!props.fetchFn) return
|
||||
loading.value = true
|
||||
pagination.page = page
|
||||
try {
|
||||
const res = await props.fetchFn({
|
||||
page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: String(keyword.value || '').trim(),
|
||||
})
|
||||
const rawList = props.extractList ? props.extractList(res) : (res?.data?.list ?? res?.list ?? [])
|
||||
list.value = Array.isArray(rawList) ? rawList : []
|
||||
pagination.total = props.extractTotal
|
||||
? props.extractTotal(res)
|
||||
: (res?.data?.total ?? res?.total ?? list.value.length)
|
||||
} catch {
|
||||
list.value = []
|
||||
pagination.total = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSelectionChange(selection: any[]) {
|
||||
selectedItem.value = selection?.[0] ?? null
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
loadData(page)
|
||||
}
|
||||
|
||||
function handlePageSizeChange(size: number) {
|
||||
pagination.pageSize = size
|
||||
pagination.page = 1
|
||||
loadData(1)
|
||||
}
|
||||
|
||||
function applySelection() {
|
||||
if (!selectedItem.value) return
|
||||
const value = String(selectedItem.value[props.valueField] ?? '')
|
||||
emit('update:modelValue', value)
|
||||
emit('select', selectedItem.value)
|
||||
dialogVisible.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.doc-search-picker {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.picker-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.picker-toolbar {
|
||||
margin-bottom: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.picker-table-wrap {
|
||||
flex: 1;
|
||||
min-height: 200px;
|
||||
max-height: 50vh;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@ -1,6 +1,376 @@
|
||||
<template>
|
||||
<div class="message-container">
|
||||
<h1>消息中心</h1>
|
||||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
cache-key="workOrder-list"
|
||||
width="250px"
|
||||
:tree-props="{ children: 'children', label: 'label' }"
|
||||
:auto-submit="false"
|
||||
:available-fields="availableFields"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
/>
|
||||
|
||||
<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">
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
title="我的工单"
|
||||
default-align="center"
|
||||
table-id="workOrder-list"
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
:table-size="tableSize"
|
||||
:pagination="upperPagination"
|
||||
:show-index="true"
|
||||
:show-actions="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
row-key="id"
|
||||
@current-change="handleRowClick"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@sort-change="handleSortChange"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<!-- 售后类型 -->
|
||||
<template #column-type="{ row }">
|
||||
<el-tag size="small" :type="typeTagType(row.type)">
|
||||
{{ typeLabel(row.type) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<!-- 子类型 -->
|
||||
<template #column-sub_type="{ row }">
|
||||
{{ subTypeLabel(row.sub_type) }}
|
||||
</template>
|
||||
|
||||
<!-- 状态 -->
|
||||
<template #column-status="{ row }">
|
||||
<el-tag size="small" :type="statusTagType(row.status)">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<!-- 角色组 -->
|
||||
<template #column-role_group="{ row }">
|
||||
<el-tag v-if="row.role_group" size="small" :type="roleGroupTagType(row.role_group)">
|
||||
{{ roleGroupLabel(row.role_group) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<!-- 仓库理赔 -->
|
||||
<template #column-claim_status="{ row }">
|
||||
<el-tag v-if="row.claim_status" size="small" :type="claimStatusTagType(row.claim_status)">
|
||||
{{ claimStatusLabel(row.claim_status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<!-- 运方理赔 -->
|
||||
<template #column-carrier_claim_status="{ row }">
|
||||
<el-tag v-if="row.carrier_claim_status" size="small" :type="claimStatusTagType(row.carrier_claim_status)">
|
||||
{{ claimStatusLabel(row.carrier_claim_status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #column-actions="{ row }">
|
||||
<div class="wave-operation-actions">
|
||||
<el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">
|
||||
查看详情
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无待处理工单 🎉</div>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 发起售后单弹窗 -->
|
||||
<CreateAfterSaleDialog v-model:visible="createDialogVisible" @success="onCreateSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { afterSaleWorkList, type AfterSaleListParams } from '@/api/afterSale/index'
|
||||
import {
|
||||
afterSaleAvailableFields,
|
||||
afterSaleColumns,
|
||||
AFTER_SALE_TYPE_MAP,
|
||||
AFTER_SALE_TYPE_TAG_MAP,
|
||||
AFTER_SALE_SUB_TYPE_MAP,
|
||||
AFTER_SALE_STATUS_MAP,
|
||||
AFTER_SALE_STATUS_TAG_MAP,
|
||||
AFTER_SALE_ROLE_GROUP_MAP,
|
||||
AFTER_SALE_ROLE_GROUP_TAG_MAP,
|
||||
CLAIM_STATUS_MAP,
|
||||
CLAIM_STATUS_TAG_MAP,
|
||||
} from '@/views/afterSale/list/afterSale-config'
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||
import CreateAfterSaleDialog from './components/CreateAfterSaleDialog.vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
|
||||
// ==================== 工具函数 ====================
|
||||
function typeLabel(t: string) { return AFTER_SALE_TYPE_MAP[t] ?? t ?? '-' }
|
||||
function typeTagType(t: string) { return AFTER_SALE_TYPE_TAG_MAP[t] ?? 'info' }
|
||||
function subTypeLabel(s: string) { return AFTER_SALE_SUB_TYPE_MAP[s] ?? s ?? '-' }
|
||||
function statusLabel(s: string) { return AFTER_SALE_STATUS_MAP[s] ?? s ?? '-' }
|
||||
function statusTagType(s: string) { return AFTER_SALE_STATUS_TAG_MAP[s] ?? 'info' }
|
||||
function roleGroupLabel(r: string) { return AFTER_SALE_ROLE_GROUP_MAP[r] ?? r ?? '-' }
|
||||
function roleGroupTagType(r: string) { return AFTER_SALE_ROLE_GROUP_TAG_MAP[r] ?? 'info' }
|
||||
function claimStatusLabel(c: string) { return CLAIM_STATUS_MAP[c] ?? c ?? '-' }
|
||||
function claimStatusTagType(c: string) { return CLAIM_STATUS_TAG_MAP[c] ?? 'info' }
|
||||
|
||||
// ==================== 布局 ====================
|
||||
const settingsStore = useSettingsStore()
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// ==================== 配置 ====================
|
||||
const availableFields = afterSaleAvailableFields
|
||||
const columns = afterSaleColumns
|
||||
const tableSize = 'small'
|
||||
|
||||
const toolbarButtons: ToolbarButtonConfig[] = [
|
||||
{ key: 'create', label: '发起售后单', category: 'action', size: 'small', type: 'primary', action: 'showCreateDialog' },
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'refresh' },
|
||||
]
|
||||
|
||||
// ==================== 按钮状态 ====================
|
||||
const buttonLoadingMap = computed(() => ({ loading: loading.value }))
|
||||
const buttonDisabledMap = computed(() => ({}))
|
||||
const buttonLabelMap = computed(() => ({}))
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
refresh: () => handleRefresh(),
|
||||
showCreateDialog: () => { createDialogVisible.value = true },
|
||||
}
|
||||
|
||||
function handleToolbarButtonClick(action: string) {
|
||||
const handler = toolbarActionMap[action]
|
||||
if (!handler) return
|
||||
safeInvoke(() => handler())
|
||||
}
|
||||
|
||||
// ==================== 数据状态 ====================
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
const tableData = ref<any[]>([])
|
||||
const currentConditions = ref<Record<string, any>>({})
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
// ==================== ScanBox 事件 ====================
|
||||
function handleConditionChange(conditions: Record<string, any>) {
|
||||
currentConditions.value = conditions ?? {}
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleConditionReset() {
|
||||
currentConditions.value = {}
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleConditionClear() {
|
||||
currentConditions.value = {}
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleRowClick(_row: any) {
|
||||
// row click handled via column-actions
|
||||
}
|
||||
|
||||
// ==================== 数据查询 ====================
|
||||
function buildWhereFromConditions(conditions: Record<string, any>): Record<string, any> {
|
||||
const where: Record<string, any> = {}
|
||||
for (const [key, cond] of Object.entries(conditions)) {
|
||||
if (cond === undefined || cond === null || cond === '') continue
|
||||
if (typeof cond === 'object' && cond.value !== undefined) {
|
||||
const val = cond.value
|
||||
const op = cond.operator || 'eq'
|
||||
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
|
||||
where[key] = { operator: op, value: val }
|
||||
} else {
|
||||
where[key] = { operator: 'eq', value: cond }
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
const start = Date.now()
|
||||
try {
|
||||
const where = buildWhereFromConditions(currentConditions.value)
|
||||
const params: AfterSaleListParams = {
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
}
|
||||
const res: any = await afterSaleWorkList(params)
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||
const data = res.data ?? res
|
||||
tableData.value = data.list ?? []
|
||||
const total = data.total ?? (data.pagination?.total ?? 0)
|
||||
pagination.total = total
|
||||
upperPagination.total = total
|
||||
} else {
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
upperPagination.total = 0
|
||||
ElMessage.error(res?.message || '获取工单列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取工单列表失败:', error)
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
upperPagination.total = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
queryTime.value = Date.now() - start
|
||||
}
|
||||
}
|
||||
|
||||
function handleRefresh() {
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleSortChange(_sort: { prop: string; order: string }) {}
|
||||
function handlePageChange(page: number) {
|
||||
pagination.currentPage = page
|
||||
upperPagination.currentPage = page
|
||||
fetchData()
|
||||
}
|
||||
function handlePageSizeChange(size: number) {
|
||||
pagination.pageSize = size
|
||||
upperPagination.pageSize = size
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// ==================== 发起售后单 ====================
|
||||
const createDialogVisible = ref(false)
|
||||
|
||||
function onCreateSuccess() {
|
||||
handleRefresh()
|
||||
}
|
||||
|
||||
// ==================== 查看详情 ====================
|
||||
function handleViewDetail(row: any) {
|
||||
router.push({ name: 'afterSale.detail', query: { id: row.id } })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.order-sub-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.toolbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.split-stack {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.upper-wrapper {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wave-operation-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user