1
This commit is contained in:
parent
3b35ce2d8b
commit
03051fb0d4
@ -84,9 +84,13 @@ export interface AfterSaleStep {
|
||||
|
||||
/** 文件引用 */
|
||||
export interface FileReference {
|
||||
file_id: number
|
||||
id?: number
|
||||
file_id?: number
|
||||
file_name?: string
|
||||
file_url?: string
|
||||
file_key?: string
|
||||
file_size?: number
|
||||
mime_type?: string
|
||||
}
|
||||
|
||||
// ==================== 请求参数类型 ====================
|
||||
@ -132,7 +136,6 @@ export interface AfterSaleTransferParams {
|
||||
/** 处理工单参数 */
|
||||
export interface AfterSaleHandleWorkOrderParams {
|
||||
id: number
|
||||
action: string
|
||||
status?: AfterSaleStatus
|
||||
remark?: string
|
||||
attachment_ids?: number[]
|
||||
|
||||
@ -54,6 +54,7 @@ export default {
|
||||
"Data": "Data",
|
||||
"Video": "Video",
|
||||
"Message": "Message",
|
||||
"WorkOrder": "Work Order",
|
||||
"Profile": "Profile",
|
||||
"printTemplate": "Print Template",
|
||||
'Permission': 'Permission',
|
||||
|
||||
@ -55,6 +55,7 @@ export default {
|
||||
"Data": "数据",
|
||||
"Video": "录像",
|
||||
"Message": "消息",
|
||||
"WorkOrder": "工单",
|
||||
"Profile": "个人中心",
|
||||
"printTemplate": "打印模板",
|
||||
'Permission': '权限管理',
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
<el-badge :value="workOrderBadgeCount" :max="99" :hidden="!workOrderBadgeCount">
|
||||
<div class="menu-item-content">
|
||||
<svg-icon icon-class="message" />
|
||||
<span class="menu-text">工单</span>
|
||||
<span class="menu-text">{{ $t('menu.WorkOrder') === 'menu.WorkOrder' ? '工单' : $t('menu.WorkOrder') }}</span>
|
||||
</div>
|
||||
</el-badge>
|
||||
</router-link>
|
||||
@ -101,7 +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'
|
||||
import { afterSaleWorkCount, afterSaleWorkList } from '@/api/afterSale/index'
|
||||
|
||||
const { isFullscreen, toggle } = useFullscreen()
|
||||
|
||||
@ -129,12 +129,21 @@ 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
|
||||
workOrderBadgeCount.value = res.count ?? res.data?.count ?? 0
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// 静默失败,角标保持旧值
|
||||
}
|
||||
} catch { /* 接口未就绪,降级使用列表接口 */ }
|
||||
// 降级:用 workList pageSize=1 获取总数
|
||||
try {
|
||||
const res: any = await afterSaleWorkList({
|
||||
pagination: { page: 1, pageSize: 1 },
|
||||
where: { status: { operator: 'in', value: ['pending', 'processing'] } },
|
||||
})
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||
const data = res.data ?? res
|
||||
workOrderBadgeCount.value = data.total ?? (data.pagination?.total ?? 0)
|
||||
}
|
||||
} catch { /* 静默失败 */ }
|
||||
}
|
||||
|
||||
const activeWarehouse = computed(() => {
|
||||
@ -211,8 +220,8 @@ const logout = async () => {
|
||||
onMounted(() => {
|
||||
calculateDays()
|
||||
fetchWorkOrderBadge()
|
||||
// 每 60 秒刷新一次工单角标
|
||||
badgeTimer = setInterval(fetchWorkOrderBadge, 60000)
|
||||
// 每 30 秒刷新一次工单角标
|
||||
badgeTimer = setInterval(fetchWorkOrderBadge, 30000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
380
src/views/afterSale/detail/AfterSaleDetailDialog.vue
Normal file
380
src/views/afterSale/detail/AfterSaleDetailDialog.vue
Normal file
@ -0,0 +1,380 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
:title="detail ? `售后明细 - ${detail.after_sale_no}` : '售后明细'"
|
||||
width="1100px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@update:model-value="$emit('update:visible', $event)"
|
||||
@closed="resetState"
|
||||
>
|
||||
<div v-loading="loading" class="detail-dialog-body">
|
||||
<template v-if="detail">
|
||||
<!-- 操作按钮 -->
|
||||
<div class="detail-actions-bar">
|
||||
<el-button size="small" @click="fetchDetail" :loading="loading"><el-icon><Refresh /></el-icon></el-button>
|
||||
<el-button v-if="detail.status === 'pending' || detail.status === 'processing'" size="small" type="warning" @click="showTransferDialog">转单</el-button>
|
||||
<el-button v-if="detail" size="small" type="success" @click="showClaimDialog">登记理赔</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 左右分栏 -->
|
||||
<div class="detail-split">
|
||||
<!-- 左侧:处理记录 -->
|
||||
<div class="detail-left">
|
||||
<!-- 标题固定 -->
|
||||
<div class="section-title">处理记录</div>
|
||||
<!-- 记录列表可滚动 -->
|
||||
<div class="detail-left-scroll">
|
||||
<template v-if="steps.length > 0">
|
||||
<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="statusTimelineType(step.step_status)">
|
||||
<div class="step-item">
|
||||
<div class="step-header">
|
||||
<el-tag size="small" :type="statusTagType(step.step_status as any)">{{ statusLabel(step.step_status as any) }}</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?.length" class="step-attachments">
|
||||
<span v-for="(att, idx) in step.attachments" :key="idx" class="att-item">
|
||||
<el-image
|
||||
v-if="att.mime_type?.startsWith('image/')"
|
||||
:src="att.file_url"
|
||||
:preview-src-list="[att.file_url]"
|
||||
fit="cover"
|
||||
style="width:60px;height:60px;border-radius:4px;cursor:pointer"
|
||||
:title="att.file_name"
|
||||
/>
|
||||
<a v-else :href="att.file_url" target="_blank">{{ att.file_name || `文件${(att as any).id || att.file_id}` }}</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</template>
|
||||
<el-empty v-else description="暂无处理记录" />
|
||||
</div>
|
||||
|
||||
<!-- 处理工单表单(固定底部) -->
|
||||
<div v-if="detail && detail.status !== 'completed' && detail.status !== 'cancelled' && detail.status !== 'closed'" class="detail-handle-bar">
|
||||
<div class="handle-row">
|
||||
<el-select v-model="handleStatus" size="small" style="width:110px" placeholder="状态">
|
||||
<el-option label="处理中" value="processing" />
|
||||
<el-option label="已完成" value="completed" />
|
||||
<el-option label="已关闭" value="closed" />
|
||||
</el-select>
|
||||
<el-input v-model="handleRemark" size="small" placeholder="输入处理备注..." class="remark-input" @keyup.enter="submitHandle" />
|
||||
<el-button size="small" @click="triggerFileInput"><el-icon><Plus /></el-icon></el-button>
|
||||
<el-button type="primary" size="small" :loading="handleLoading" @click="submitHandle">提交</el-button>
|
||||
</div>
|
||||
<div v-if="handleFiles.length > 0" class="handle-files-row">
|
||||
<span v-for="(f, i) in handleFiles" :key="i" class="file-thumb" @click="removeFile(i)">
|
||||
<img :src="f.url" /><span class="file-close">×</span>
|
||||
</span>
|
||||
</div>
|
||||
<input ref="fileInputRef" type="file" accept="image/*" multiple hidden @change="onFilePicked" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:基本信息 + 关联单据 + 理赔 -->
|
||||
<div class="detail-right">
|
||||
<!-- 基本信息 -->
|
||||
<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="2" border size="small">
|
||||
<el-descriptions-item label="售后单号" :span="2">{{ 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 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 v-if="detail.description" label="详细描述" :span="2">{{ detail.description }}</el-descriptions-item>
|
||||
<el-descriptions-item label="处理结果" :span="2">{{ 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="更新时间" :span="2">{{ 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="1" 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">
|
||||
<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>
|
||||
</el-col>
|
||||
<el-col v-if="detail.carrier_claim_needed" :span="12">
|
||||
<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>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<TransferDialog ref="transferDlgRef" :after-sale-id="detail?.id ?? 0" @success="onSubActionSuccess" />
|
||||
<ClaimDialog
|
||||
ref="claimDlgRef"
|
||||
:after-sale-id="detail?.id ?? 0"
|
||||
:claim-needed="detail?.claim_needed"
|
||||
:claim-amount="detail?.claim_amount ?? undefined"
|
||||
:claim-status="detail?.claim_status ?? undefined"
|
||||
:carrier-claim-needed="detail?.carrier_claim_needed"
|
||||
:carrier-claim-amount="detail?.carrier_claim_amount ?? undefined"
|
||||
:carrier-claim-status="detail?.carrier_claim_status ?? undefined"
|
||||
@success="onSubActionSuccess"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Plus, Refresh } from '@element-plus/icons-vue'
|
||||
import {
|
||||
afterSaleDetail,
|
||||
afterSaleHandleWorkOrder,
|
||||
type AfterSale,
|
||||
type AfterSaleStep,
|
||||
} 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'
|
||||
import TransferDialog from './TransferDialog.vue'
|
||||
import ClaimDialog from './ClaimDialog.vue'
|
||||
|
||||
const props = defineProps<{ visible: boolean; afterSaleId: number | null }>()
|
||||
const emit = defineEmits<{ 'update:visible': [v: boolean]; success: [] }>()
|
||||
|
||||
// 工具
|
||||
const typeLabel = (t: string) => AFTER_SALE_TYPE_MAP[t] ?? t ?? '-'
|
||||
const typeTagType = (t: string) => AFTER_SALE_TYPE_TAG_MAP[t] ?? 'info'
|
||||
const subTypeLabel = (s: string) => AFTER_SALE_SUB_TYPE_MAP[s] ?? s ?? '-'
|
||||
const statusLabel = (s: any) => AFTER_SALE_STATUS_MAP[s] ?? s ?? '-'
|
||||
const statusTagType = (s: any) => AFTER_SALE_STATUS_TAG_MAP[s] ?? 'info'
|
||||
const roleGroupLabel = (r: string) => AFTER_SALE_ROLE_GROUP_MAP[r] ?? r ?? '-'
|
||||
const roleGroupTagType = (r: string) => AFTER_SALE_ROLE_GROUP_TAG_MAP[r] ?? 'info'
|
||||
const claimStatusLabel = (c: string) => CLAIM_STATUS_MAP[c] ?? c ?? '-'
|
||||
const claimStatusTagType = (c: string) => CLAIM_STATUS_TAG_MAP[c] ?? 'info'
|
||||
const parseOperatorName = (s: string) => { try { const o = JSON.parse(s); return o.name || o.id || '-' } catch { return s || '-' } }
|
||||
const statusTimelineType = (s: any) => ({ pending: 'warning', processing: 'primary', completed: 'success', closed: 'info' } as any)[s] ?? 'info'
|
||||
|
||||
// 数据
|
||||
const loading = ref(false)
|
||||
const detail = ref<AfterSale | null>(null)
|
||||
const steps = ref<AfterSaleStep[]>([])
|
||||
const hasRelatedDocs = computed(() => !!(detail.value?.waybill_no || detail.value?.order_delivery_no || detail.value?.entry_order_no || detail.value?.order_stockout_no || detail.value?.receiving_no))
|
||||
|
||||
async function fetchDetail() {
|
||||
if (!props.afterSaleId) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await afterSaleDetail(props.afterSaleId)
|
||||
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 { ElMessage.error('获取失败') }
|
||||
finally { loading.value = false }
|
||||
}
|
||||
|
||||
watch(() => props.afterSaleId, (id) => { if (id) fetchDetail() }, { immediate: true })
|
||||
|
||||
// 明细加载后同步状态默认值(处理下拉框无 pending 选项,统一默认为 processing)
|
||||
const HANDLE_STATUS_OPTIONS = ['processing', 'completed', 'closed']
|
||||
watch(detail, (d) => {
|
||||
if (d) {
|
||||
handleStatus.value = HANDLE_STATUS_OPTIONS.includes(d.status) ? d.status : 'processing'
|
||||
}
|
||||
})
|
||||
|
||||
function resetState() {
|
||||
detail.value = null; steps.value = []
|
||||
}
|
||||
|
||||
// 子操作弹窗 refs
|
||||
const transferDlgRef = ref<InstanceType<typeof TransferDialog>>()
|
||||
const claimDlgRef = ref<InstanceType<typeof ClaimDialog>>()
|
||||
|
||||
function onSubActionSuccess() {
|
||||
fetchDetail()
|
||||
emit('success')
|
||||
}
|
||||
|
||||
function showTransferDialog() { transferDlgRef.value?.open() }
|
||||
function showClaimDialog() { claimDlgRef.value?.open() }
|
||||
|
||||
// ==================== 处理工单(内联) ====================
|
||||
const handleStatus = ref('processing')
|
||||
const handleRemark = ref('')
|
||||
const handleLoading = ref(false)
|
||||
const handleFiles = ref<Array<{ raw: File; url: string; fileId?: number }>>([])
|
||||
const uploadedIds = ref<number[]>([])
|
||||
const fileInputRef = ref<HTMLInputElement>()
|
||||
|
||||
function triggerFileInput() { fileInputRef.value?.click() }
|
||||
|
||||
async function onFilePicked(e: Event) {
|
||||
const files = (e.target as HTMLInputElement).files
|
||||
if (!files) return
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const f = files[i]
|
||||
if (!f) continue
|
||||
const item = { raw: f, url: URL.createObjectURL(f), fileId: undefined as number | undefined }
|
||||
handleFiles.value.push(item)
|
||||
// 立即上传
|
||||
try {
|
||||
const configRes: any = await getCOSUploadConfig({ fileName: f.name, fileType: f.type, fileSize: f.size })
|
||||
const cos = configRes?.data ?? configRes
|
||||
if (cos?.isNew === false) { item.fileId = cos.fileId ?? cos.file_id; if (item.fileId != null) uploadedIds.value.push(item.fileId); continue }
|
||||
if (cos?.error || !cos?.uploadUrl) { ElMessage.warning(`文件 ${f.name} 上传配置获取失败`); continue }
|
||||
const fd = new FormData()
|
||||
if (cos.data) Object.keys(cos.data).forEach(k => fd.append(k, cos.data[k]))
|
||||
fd.append('file', f)
|
||||
const uploadRes = await fetch(cos.uploadUrl, { method: 'POST', headers: cos.headers || {}, body: fd })
|
||||
if (!uploadRes.ok) { ElMessage.warning(`文件 ${f.name} 上传失败`); continue }
|
||||
const notifyRes: any = await uploadSuccessNotify(cos.fileInfo || cos)
|
||||
const resultData = notifyRes?.data ?? notifyRes
|
||||
const fid = resultData?.file_id ?? resultData?.fileId ?? notifyRes?.file_id
|
||||
if (fid != null) { item.fileId = Number(fid); uploadedIds.value.push(Number(fid)) }
|
||||
} catch { ElMessage.warning(`文件 ${f.name} 上传失败`) }
|
||||
}
|
||||
;(e.target as HTMLInputElement).value = ''
|
||||
}
|
||||
|
||||
function removeFile(i: number) {
|
||||
const f = handleFiles.value[i]
|
||||
if (!f) return
|
||||
if (f.url) URL.revokeObjectURL(f.url)
|
||||
if (f.fileId != null) {
|
||||
uploadedIds.value = uploadedIds.value.filter(id => id !== f.fileId)
|
||||
}
|
||||
handleFiles.value.splice(i, 1)
|
||||
}
|
||||
|
||||
async function submitHandle() {
|
||||
if (!detail.value) return
|
||||
handleLoading.value = true
|
||||
try {
|
||||
const res: any = await afterSaleHandleWorkOrder({
|
||||
id: detail.value.id, status: handleStatus.value as any,
|
||||
remark: handleRemark.value || undefined,
|
||||
attachment_ids: uploadedIds.value.length > 0 ? uploadedIds.value : undefined,
|
||||
})
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success('处理成功')
|
||||
const submittedStatus = handleStatus.value
|
||||
handleRemark.value = ''
|
||||
handleFiles.value.forEach(f => { if (f.url) URL.revokeObjectURL(f.url) })
|
||||
handleFiles.value = []
|
||||
uploadedIds.value = []
|
||||
handleStatus.value = HANDLE_STATUS_OPTIONS.includes(detail.value?.status) ? detail.value!.status : 'processing'
|
||||
emit('success')
|
||||
// 状态为已完成或已关闭时,关闭详情弹窗
|
||||
if (submittedStatus === 'completed' || submittedStatus === 'closed') {
|
||||
emit('update:visible', false)
|
||||
return
|
||||
}
|
||||
fetchDetail()
|
||||
} else ElMessage.error(res?.message || '失败')
|
||||
} catch { ElMessage.error('失败') } finally { handleLoading.value = false }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.detail-dialog-body { display: flex; flex-direction: column; min-height: 40vh; max-height: 70vh; }
|
||||
.detail-actions-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-shrink: 0; }
|
||||
|
||||
.detail-split {
|
||||
display: flex; gap: 12px; flex: 1; min-height: 0;
|
||||
}
|
||||
.detail-left {
|
||||
flex: 0 0 360px; min-width: 0; display: flex; flex-direction: column;
|
||||
}
|
||||
.detail-left-scroll {
|
||||
flex: 1; overflow-y: auto; min-height: 0;
|
||||
border: 1px solid #ebeef5; border-top: none; border-radius: 0 0 4px 4px;
|
||||
padding: 8px 12px; background: #fff;
|
||||
}
|
||||
.detail-right {
|
||||
flex: 1; min-width: 0; overflow-y: auto; max-height: 65vh;
|
||||
}
|
||||
|
||||
.info-card { margin-bottom: 10px; }
|
||||
.info-card:last-child { margin-bottom: 0; }
|
||||
.info-card :deep(.el-card__header) { padding: 8px 16px; }
|
||||
.card-title { font-size: 14px; font-weight: 600; }
|
||||
.section-title {
|
||||
font-size: 14px; font-weight: 600; padding: 8px 16px; background: #fafafa;
|
||||
border: 1px solid #ebeef5; border-radius: 4px 4px 0 0; flex-shrink: 0;
|
||||
}
|
||||
.step-item { padding: 2px 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: 2px; }
|
||||
.step-operator { color: #909399; font-size: 12px; margin-top: 2px; }
|
||||
.step-attachments { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
|
||||
.att-item { display: inline-flex; align-items: center; }
|
||||
|
||||
/* 紧凑时间线 */
|
||||
.detail-left-scroll :deep(.el-timeline) { padding-left: 4px; }
|
||||
h4 { margin: 0 0 10px; font-size: 14px; }
|
||||
|
||||
.detail-handle-bar {
|
||||
border-top: 1px solid #ebeef5; padding: 10px 0 0; margin-top: 10px; flex-shrink: 0;
|
||||
}
|
||||
.handle-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
||||
.remark-input { flex: 1; min-width: 80px; }
|
||||
.handle-files-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
|
||||
.file-thumb {
|
||||
position: relative; width: 48px; height: 48px; border-radius: 4px; overflow: hidden; cursor: pointer;
|
||||
border: 1px solid #dcdfe6;
|
||||
}
|
||||
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.file-close {
|
||||
position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; background: #f56c6c; color: #fff;
|
||||
border-radius: 50%; font-size: 12px; line-height: 16px; text-align: center;
|
||||
}
|
||||
</style>
|
||||
94
src/views/afterSale/detail/ClaimDialog.vue
Normal file
94
src/views/afterSale/detail/ClaimDialog.vue
Normal file
@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="登记理赔" width="550px" align-center append-to-body destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px" size="small">
|
||||
<el-divider content-position="left">仓库理赔</el-divider>
|
||||
<el-form-item label="是否需要"><el-switch v-model="form.claim_needed" :active-value="1" :inactive-value="0" /></el-form-item>
|
||||
<template v-if="form.claim_needed">
|
||||
<el-form-item label="金额"><el-input-number v-model="form.claim_amount" :min="0" :precision="2" style="width:180px" /></el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="form.claim_status" style="width:180px">
|
||||
<el-option v-for="(l,v) in claimStatusOptions" :key="v" :label="l" :value="v" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-divider content-position="left">运方理赔</el-divider>
|
||||
<el-form-item label="是否需要"><el-switch v-model="form.carrier_claim_needed" :active-value="1" :inactive-value="0" /></el-form-item>
|
||||
<template v-if="form.carrier_claim_needed">
|
||||
<el-form-item label="金额"><el-input-number v-model="form.carrier_claim_amount" :min="0" :precision="2" style="width:180px" /></el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="form.carrier_claim_status" style="width:180px">
|
||||
<el-option v-for="(l,v) in claimStatusOptions" :key="v" :label="l" :value="v" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-divider content-position="left">操作信息</el-divider>
|
||||
<el-form-item label="操作动作" prop="claim_action"><el-input v-model="form.claim_action" /></el-form-item>
|
||||
<el-form-item label="备注"><el-input v-model="form.claim_remark" type="textarea" :rows="2" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="loading" @click="submit">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { afterSaleRegisterClaim } from '@/api/afterSale/index'
|
||||
import { CLAIM_STATUS_MAP } from '@/views/afterSale/list/afterSale-config'
|
||||
|
||||
const props = defineProps<{ afterSaleId: number; claimNeeded?: 0|1; claimAmount?: number|null; claimStatus?: string|null; carrierClaimNeeded?: 0|1; carrierClaimAmount?: number|null; carrierClaimStatus?: string|null }>()
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const claimStatusOptions = CLAIM_STATUS_MAP
|
||||
|
||||
const form = reactive({
|
||||
claim_needed: 0 as 0|1, claim_amount: undefined as number|undefined, claim_status: '',
|
||||
carrier_claim_needed: 0 as 0|1, carrier_claim_amount: undefined as number|undefined, carrier_claim_status: '',
|
||||
claim_action: '', claim_remark: '',
|
||||
})
|
||||
const rules: FormRules = { claim_action: [{ required: true, message: '请输入', trigger: 'blur' }] }
|
||||
|
||||
function open() {
|
||||
form.claim_needed = props.claimNeeded ?? 0
|
||||
form.claim_amount = props.claimAmount
|
||||
form.claim_status = props.claimStatus ?? ''
|
||||
form.carrier_claim_needed = props.carrierClaimNeeded ?? 0
|
||||
form.carrier_claim_amount = props.carrierClaimAmount
|
||||
form.carrier_claim_status = props.carrierClaimStatus ?? ''
|
||||
form.claim_action = ''
|
||||
form.claim_remark = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!await formRef.value?.validate().catch(() => false)) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await afterSaleRegisterClaim({
|
||||
id: props.afterSaleId,
|
||||
claim_needed: form.claim_needed, claim_amount: form.claim_needed ? form.claim_amount : undefined,
|
||||
claim_status: form.claim_needed ? form.claim_status as any : undefined,
|
||||
carrier_claim_needed: form.carrier_claim_needed,
|
||||
carrier_claim_amount: form.carrier_claim_needed ? form.carrier_claim_amount : undefined,
|
||||
carrier_claim_status: form.carrier_claim_needed ? form.carrier_claim_status as any : undefined,
|
||||
action: form.claim_action, remark: form.claim_remark || undefined,
|
||||
})
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success('登记成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} else ElMessage.error(res?.message || '失败')
|
||||
} catch { ElMessage.error('失败') } finally { loading.value = false }
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
120
src/views/afterSale/detail/HandleDialog.vue
Normal file
120
src/views/afterSale/detail/HandleDialog.vue
Normal file
@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="处理工单" width="500px" align-center append-to-body destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" size="small">
|
||||
<el-form-item label="更新状态" prop="status">
|
||||
<el-select v-model="form.status" 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="form.remark" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-form-item label="附件">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
action="#"
|
||||
:auto-upload="false"
|
||||
v-model:file-list="fileList"
|
||||
list-type="picture-card"
|
||||
:multiple="true"
|
||||
:limit="10"
|
||||
:on-change="handleFileChange"
|
||||
:on-remove="handleFileRemove"
|
||||
:before-upload="() => false"
|
||||
accept="image/*"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="loading" @click="submit">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { afterSaleHandleWorkOrder } from '@/api/afterSale/index'
|
||||
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
|
||||
|
||||
const props = defineProps<{ afterSaleId: number; currentStatus?: string }>()
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const fileList = ref<any[]>([])
|
||||
|
||||
const form = reactive({ status: '', remark: '' })
|
||||
const rules: FormRules = { status: [{ required: true, message: '请选择', trigger: 'change' }] }
|
||||
|
||||
function open() {
|
||||
form.status = props.currentStatus || 'processing'
|
||||
form.remark = ''
|
||||
fileList.value = []
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formRef.value?.resetFields()
|
||||
fileList.value.forEach(f => { if (f.url?.startsWith('blob:')) URL.revokeObjectURL(f.url) })
|
||||
fileList.value = []
|
||||
}
|
||||
|
||||
function handleFileChange(uploadFile: any) {
|
||||
if (uploadFile.raw && !uploadFile.url) {
|
||||
uploadFile.url = URL.createObjectURL(uploadFile.raw)
|
||||
}
|
||||
}
|
||||
|
||||
function handleFileRemove(_file: any) {
|
||||
// v-model 自动同步
|
||||
}
|
||||
|
||||
async function uploadFiles(): Promise<number[]> {
|
||||
const ids: number[] = []
|
||||
for (const file of fileList.value) {
|
||||
const raw = file.raw || file
|
||||
if (!(raw instanceof File)) continue
|
||||
try {
|
||||
const configRes: any = await getCOSUploadConfig({ fileName: raw.name, fileType: raw.type, fileSize: raw.size })
|
||||
const cos = configRes?.data ?? configRes
|
||||
if (cos?.isNew === false) { ids.push(cos.fileId ?? cos.file_id); continue }
|
||||
if (cos?.error) continue
|
||||
const fd = new FormData()
|
||||
if (cos.data) Object.keys(cos.data).forEach(k => fd.append(k, cos.data[k]))
|
||||
fd.append('file', raw)
|
||||
const uploadRes = await fetch(cos.uploadUrl || cos.upload_url, { method: 'POST', headers: cos.headers || {}, body: fd })
|
||||
if (!uploadRes.ok) continue
|
||||
const notifyRes: any = await uploadSuccessNotify(cos.fileInfo || cos)
|
||||
const fid = notifyRes?.data?.file_id ?? notifyRes?.file_id ?? notifyRes?.data?.fileId
|
||||
if (fid != null) ids.push(fid)
|
||||
} catch { /* skip failed files */ }
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!await formRef.value?.validate().catch(() => false)) return
|
||||
loading.value = true
|
||||
try {
|
||||
const attachmentIds = await uploadFiles()
|
||||
const res: any = await afterSaleHandleWorkOrder({
|
||||
id: props.afterSaleId, status: form.status as any, remark: form.remark || undefined,
|
||||
attachment_ids: attachmentIds.length > 0 ? attachmentIds : undefined,
|
||||
})
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success('处理成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} else ElMessage.error(res?.message || '失败')
|
||||
} catch { ElMessage.error('失败') } finally { loading.value = false }
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
59
src/views/afterSale/detail/TransferDialog.vue
Normal file
59
src/views/afterSale/detail/TransferDialog.vue
Normal file
@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="转单" width="450px" align-center append-to-body destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" size="small">
|
||||
<el-form-item label="目标角色组" prop="role_group">
|
||||
<el-select v-model="form.role_group" 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="form.remark" type="textarea" :rows="2" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" size="small" :loading="loading" @click="submit">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { afterSaleTransfer } from '@/api/afterSale/index'
|
||||
|
||||
const props = defineProps<{ afterSaleId: number }>()
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const form = reactive({ role_group: '', remark: '' })
|
||||
const rules: FormRules = { role_group: [{ required: true, message: '请选择', trigger: 'change' }] }
|
||||
|
||||
function open() {
|
||||
form.role_group = ''
|
||||
form.remark = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!await formRef.value?.validate().catch(() => false)) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await afterSaleTransfer({ id: props.afterSaleId, role_group: form.role_group as any, remark: form.remark || undefined })
|
||||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
ElMessage.success('转单成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} else ElMessage.error(res?.message || '失败')
|
||||
} catch { ElMessage.error('失败') } finally { loading.value = false }
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@ -155,9 +155,16 @@
|
||||
操作人: {{ 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}` }}
|
||||
<el-image
|
||||
v-if="att.mime_type?.startsWith('image/')"
|
||||
:src="att.file_url"
|
||||
:preview-src-list="[att.file_url]"
|
||||
fit="cover"
|
||||
style="width:60px;height:60px;border-radius:4px;cursor:pointer"
|
||||
:title="att.file_name"
|
||||
/>
|
||||
<a v-else :href="att.file_url" target="_blank">{{ att.file_name || `文件${(att as any).id || att.file_id}` }}</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -184,9 +191,6 @@
|
||||
<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" />
|
||||
@ -557,18 +561,15 @@ 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()
|
||||
@ -586,7 +587,6 @@ async function handleSubmitHandle() {
|
||||
|
||||
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,
|
||||
|
||||
@ -48,7 +48,7 @@ export const AFTER_SALE_SUB_TYPE_MAP: Record<string, string> = {
|
||||
|
||||
// -------------------- 售后状态 --------------------
|
||||
export const AFTER_SALE_STATUS_MAP: Record<string, string> = {
|
||||
pending: '待处理',
|
||||
pending: '未开始处理',
|
||||
processing: '处理中',
|
||||
completed: '已完成',
|
||||
closed: '已关闭',
|
||||
@ -251,13 +251,12 @@ export const afterSaleColumns = [
|
||||
{ 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' },
|
||||
{ prop: 'actions', label: '操作', width: '100', 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' },
|
||||
]
|
||||
|
||||
|
||||
@ -24,24 +24,13 @@
|
||||
@action="handleToolbarButtonClick"
|
||||
/>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<el-radio-group
|
||||
v-model="viewMode"
|
||||
class="view-mode-toggle"
|
||||
size="small"
|
||||
@change="onViewModeChange"
|
||||
>
|
||||
<el-radio-button label="work">售后工作列表</el-radio-button>
|
||||
<el-radio-button label="audit">售后审计列表</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="split-stack">
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
:title="viewMode === 'work' ? '售后列表' : '售后审计列表'"
|
||||
:title="'售后审计列表'"
|
||||
default-align="center"
|
||||
table-id="afterSale-list"
|
||||
:data="tableData"
|
||||
@ -106,13 +95,11 @@
|
||||
<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">{{ viewMode === 'work' ? '暂无售后单' : '暂无售后审计记录' }}</div>
|
||||
<div class="empty-tip">暂无售后审计记录</div>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
@ -214,16 +201,22 @@
|
||||
:update-time="exportTaskProgress.updateTime"
|
||||
/>
|
||||
|
||||
<!-- 售后明细弹窗 -->
|
||||
<AfterSaleDetailDialog
|
||||
v-model:visible="detailDialogVisible"
|
||||
:after-sale-id="detailAfterSaleId"
|
||||
@success="fetchData"
|
||||
/>
|
||||
|
||||
<!-- 跳转路由(用于查看详情) -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, reactive, ref, computed } from 'vue'
|
||||
import { onMounted, onUnmounted, reactive, ref, computed, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
afterSaleWorkList,
|
||||
afterSaleAuditList,
|
||||
afterSaleCreate,
|
||||
afterSaleUpdate,
|
||||
@ -253,6 +246,7 @@ 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 AfterSaleDetailDialog from '@/views/afterSale/detail/AfterSaleDetailDialog.vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
@ -342,7 +336,6 @@ function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||||
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
refresh: () => handleRefresh(),
|
||||
showCreateDialog: () => showCreateDialog(),
|
||||
handleExport: () => handleExport(),
|
||||
}
|
||||
|
||||
@ -354,7 +347,6 @@ function handleToolbarButtonClick(action: string) {
|
||||
|
||||
// ==================== 数据状态 ====================
|
||||
|
||||
const viewMode = ref<'work' | 'audit'>('work')
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
@ -441,9 +433,7 @@ async function fetchData() {
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
}
|
||||
const res: any = viewMode.value === 'audit'
|
||||
? await afterSaleAuditList(params)
|
||||
: await afterSaleWorkList(params)
|
||||
const res: any = await afterSaleAuditList(params)
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||
const data = res.data ?? res
|
||||
tableData.value = data.list ?? []
|
||||
@ -472,13 +462,6 @@ function handleRefresh() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function onViewModeChange() {
|
||||
selectedRow.value = null
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSortChange(_sort: { prop: string; order: string }) {
|
||||
// 预留排序事件处理
|
||||
}
|
||||
@ -666,8 +649,17 @@ async function handleSubmitTransfer() {
|
||||
|
||||
// ==================== 查看详情 ====================
|
||||
|
||||
const detailDialogVisible = ref(false)
|
||||
const detailAfterSaleId = ref<number | null>(null)
|
||||
|
||||
// 关闭弹窗时重置 ID,确保再次打开同一记录也能触发加载
|
||||
watch(detailDialogVisible, (v) => {
|
||||
if (!v) detailAfterSaleId.value = null
|
||||
})
|
||||
|
||||
function handleViewDetail(row: any) {
|
||||
router.push({ name: 'afterSale.detail', query: { id: row.id } })
|
||||
detailAfterSaleId.value = row.id
|
||||
detailDialogVisible.value = true
|
||||
}
|
||||
|
||||
// ==================== 生命周期 ====================
|
||||
@ -698,8 +690,4 @@ onUnmounted(() => {
|
||||
color: #909399;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.view-mode-toggle {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -110,12 +110,18 @@
|
||||
|
||||
<!-- 发起售后单弹窗 -->
|
||||
<CreateAfterSaleDialog v-model:visible="createDialogVisible" @success="onCreateSuccess" />
|
||||
|
||||
<!-- 售后明细弹窗 -->
|
||||
<AfterSaleDetailDialog
|
||||
v-model:visible="detailDialogVisible"
|
||||
:after-sale-id="detailAfterSaleId"
|
||||
@success="handleRefresh"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { onMounted, reactive, ref, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { afterSaleWorkList, type AfterSaleListParams } from '@/api/afterSale/index'
|
||||
import {
|
||||
@ -136,6 +142,7 @@ 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 AfterSaleDetailDialog from '@/views/afterSale/detail/AfterSaleDetailDialog.vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
|
||||
@ -155,7 +162,14 @@ const settingsStore = useSettingsStore()
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||||
|
||||
const router = useRouter()
|
||||
// ==================== 售后明细弹窗 ====================
|
||||
const detailDialogVisible = ref(false)
|
||||
const detailAfterSaleId = ref<number | null>(null)
|
||||
|
||||
// 关闭弹窗时重置 ID,确保再次打开同一记录也能触发加载
|
||||
watch(detailDialogVisible, (v) => {
|
||||
if (!v) detailAfterSaleId.value = null
|
||||
})
|
||||
|
||||
// ==================== 配置 ====================
|
||||
const availableFields = afterSaleAvailableFields
|
||||
@ -163,8 +177,8 @@ 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' },
|
||||
{ key: 'create', label: '发起售后单', category: 'action', size: 'small', type: 'primary', action: 'showCreateDialog' },
|
||||
]
|
||||
|
||||
// ==================== 按钮状态 ====================
|
||||
@ -315,7 +329,8 @@ function onCreateSuccess() {
|
||||
|
||||
// ==================== 查看详情 ====================
|
||||
function handleViewDetail(row: any) {
|
||||
router.push({ name: 'afterSale.detail', query: { id: row.id } })
|
||||
detailAfterSaleId.value = row.id
|
||||
detailDialogVisible.value = true
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user