WEB/src/views/afterSale/detail/ClaimDialog.vue
2026-10-27 19:10:53 +08:00

400 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
售后明细 - 登记理赔弹窗
面板结构 / 尺寸对齐「批量修改平台信息」(UpdateOrderMetaForm)
-->
<template>
<el-dialog
v-model="visible"
class="after-sale-claim-dialog"
width="min(560px, 92vw)"
align-center
append-to-body
destroy-on-close
:show-close="false"
:close-on-click-modal="false"
@closed="resetForm"
>
<div class="task-panel">
<header class="task-panel__head">
<div class="task-panel__titles">
<h2>登记理赔</h2>
<p>登记仓库理赔与运方理赔信息,并记录本次操作</p>
</div>
<button
class="task-panel__close"
type="button"
aria-label="关闭"
@click="visible = false"
>
<svg viewBox="0 0 12 12" fill="none">
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
</svg>
</button>
</header>
<div class="task-panel__body task-panel__body--scroll">
<el-form ref="formRef" :model="form" :rules="rules" class="task-panel__form">
<div class="task-panel__section-title">仓库理赔</div>
<div class="task-panel__field">
<span class="task-panel__field-label">是否需要</span>
<el-switch v-model="form.claim_needed" :active-value="1" :inactive-value="0" />
</div>
<template v-if="form.claim_needed">
<div class="task-panel__field task-panel__field--input">
<span class="task-panel__field-label">金额</span>
<div class="task-panel__field-control">
<el-input-number
v-model="form.claim_amount"
size="default"
:min="0"
:precision="2"
controls-position="right"
style="width: 180px"
/>
</div>
</div>
<div class="task-panel__field task-panel__field--input">
<span class="task-panel__field-label">状态</span>
<div class="task-panel__field-control">
<el-select v-model="form.claim_status" size="default" placeholder="请选择理赔状态" style="width: 180px">
<el-option v-for="(l, v) in claimStatusOptions" :key="v" :label="l" :value="v" />
</el-select>
</div>
</div>
</template>
<div class="task-panel__section-title is-spaced">运方理赔</div>
<div class="task-panel__field">
<span class="task-panel__field-label">是否需要</span>
<el-switch v-model="form.carrier_claim_needed" :active-value="1" :inactive-value="0" />
</div>
<template v-if="form.carrier_claim_needed">
<div class="task-panel__field task-panel__field--input">
<span class="task-panel__field-label">金额</span>
<div class="task-panel__field-control">
<el-input-number
v-model="form.carrier_claim_amount"
size="default"
:min="0"
:precision="2"
controls-position="right"
style="width: 180px"
/>
</div>
</div>
<div class="task-panel__field task-panel__field--input">
<span class="task-panel__field-label">状态</span>
<div class="task-panel__field-control">
<el-select v-model="form.carrier_claim_status" size="default" placeholder="请选择理赔状态" style="width: 180px">
<el-option v-for="(l, v) in claimStatusOptions" :key="v" :label="l" :value="v" />
</el-select>
</div>
</div>
</template>
<div class="task-panel__section-title is-spaced">操作信息</div>
<div class="task-panel__field task-panel__field--input">
<span class="task-panel__field-label is-required">操作动作</span>
<div class="task-panel__field-control">
<el-form-item prop="claim_action">
<el-input v-model="form.claim_action" size="default" placeholder="请输入本次操作动作" />
</el-form-item>
</div>
</div>
<div class="task-panel__field task-panel__field--input task-panel__field--textarea">
<span class="task-panel__field-label">备注</span>
<div class="task-panel__field-control">
<el-input
v-model="form.claim_remark"
type="textarea"
:rows="3"
resize="none"
size="default"
placeholder="请输入备注(可选)"
/>
<p class="task-panel__field-tip">操作动作与备注将记入售后单处理记录</p>
</div>
</div>
</el-form>
</div>
<footer class="task-panel__foot">
<span class="task-panel__hint">提交后理赔信息将更新到售后单</span>
<div class="task-panel__actions">
<el-button size="small" @click="visible = false">取消</el-button>
<el-button size="small" type="primary" :loading="loading" @click="submit">确认</el-button>
</div>
</footer>
</div>
</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 ?? undefined
form.claim_status = props.claimStatus ?? ''
form.carrier_claim_needed = props.carrierClaimNeeded ?? 0
form.carrier_claim_amount = props.carrierClaimAmount ?? undefined
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>
<style scoped lang="scss">
/* 面板结构 / 尺寸对齐「批量修改平台信息」(UpdateOrderMetaForm) */
.task-panel {
background: #fff;
color: #303133;
&__head {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 16px;
}
&__titles {
flex: 1;
min-width: 0;
h2 {
margin: 0;
font-size: 18px;
line-height: 24px;
font-weight: 400;
color: #303133;
}
p {
margin: 4px 0 0;
font-size: 12px;
line-height: 18px;
color: #909399;
}
}
&__close {
width: 24px;
height: 24px;
flex: none;
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
border-radius: 4px;
background: transparent;
color: #909399;
cursor: pointer;
transition: color 0.2s;
svg {
width: 12px;
height: 12px;
}
&:hover {
color: #409eff;
}
}
/* 分组较多:超出 64vh 时面板内滚动 */
&__body {
padding: 12px 16px 0;
&--scroll {
max-height: 64vh;
overflow-y: auto;
}
}
/* 分组标题(仓库理赔 / 运方理赔 / 操作信息) */
&__section-title {
font-size: 13px;
font-weight: 600;
line-height: 20px;
color: #303133;
&.is-spaced {
margin-top: 8px;
}
}
&__form {
display: flex;
flex-direction: column;
gap: 8px;
}
&__field {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
min-height: 40px;
padding: 8px 12px;
border: 1px solid #ebeef5;
border-radius: 4px;
background: #fafafa;
/* 输入行:去掉灰色容器,与静态信息行区分 */
&--input {
align-items: flex-start;
min-height: 0;
padding: 4px 0 0 12px;
border: none;
border-radius: 0;
background: transparent;
.task-panel__field-label {
padding-top: 7px;
}
}
/* 多行文本行:标签与文本域顶部对齐 */
&--textarea {
padding-top: 8px;
}
}
&__field-label {
font-size: 12px;
line-height: 20px;
color: #606266;
flex-shrink: 0;
&.is-required::before {
content: '*';
color: #f56c6c;
margin-right: 4px;
}
}
&__field-control {
flex: 1;
min-width: 0;
}
&__field-tip {
margin: 4px 0 0;
font-size: 12px;
line-height: 18px;
color: #909399;
}
&__foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 16px;
}
&__hint {
font-size: 12px;
color: #909399;
}
&__actions {
display: flex;
align-items: center;
gap: 8px;
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
}
/* 面板内嵌 el-form-item:去掉默认间距,错误提示改回文档流内展示 */
.task-panel__form {
:deep(.el-form-item) {
margin-bottom: 0;
}
:deep(.el-form-item__content) {
margin-left: 0;
line-height: 1.4;
}
:deep(.el-form-item__error) {
position: static;
padding-top: 4px;
}
}
</style>
<style lang="scss">
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
.el-dialog.after-sale-claim-dialog {
padding: 0;
overflow: hidden;
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 0;
}
}
</style>