<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { AftersalesProblemApi } from '#/api/aftersales/problem';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
import { Button, message, Tag } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import {
|
deleteProblem,
|
disableProblem,
|
getProblemPage,
|
publishProblem,
|
} from '#/api/aftersales/problem';
|
|
import {
|
PROBLEM_STATUS_OPTIONS,
|
ROOT_CAUSE_CATEGORY_OPTIONS,
|
useProblemGridColumns,
|
useProblemSearchFormSchema,
|
} from './data';
|
import ProblemForm from './modules/form.vue';
|
|
const statusLabelMap = Object.fromEntries(
|
PROBLEM_STATUS_OPTIONS.map((o) => [o.value, o.label]),
|
);
|
const rootCauseLabelMap = Object.fromEntries(
|
ROOT_CAUSE_CATEGORY_OPTIONS.map((o) => [o.value, o.label]),
|
);
|
|
const [FormModal, formModalApi] = useVbenModal({
|
connectedComponent: ProblemForm,
|
destroyOnClose: true,
|
});
|
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
function handleCreate() {
|
formModalApi.setData({ formType: 'create' }).open();
|
}
|
|
function handleDetail(row: AftersalesProblemApi.Problem) {
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
}
|
|
function handleEdit(row: AftersalesProblemApi.Problem) {
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
}
|
|
async function handleDelete(row: AftersalesProblemApi.Problem) {
|
await deleteProblem(row.id!);
|
message.success('删除成功');
|
handleRefresh();
|
}
|
|
async function handlePublish(row: AftersalesProblemApi.Problem) {
|
await publishProblem(row.id!);
|
message.success('发布成功');
|
handleRefresh();
|
}
|
|
async function handleDisable(row: AftersalesProblemApi.Problem) {
|
await disableProblem(row.id!);
|
message.success('停用成功');
|
handleRefresh();
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useProblemSearchFormSchema(),
|
},
|
gridOptions: {
|
columns: useProblemGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) => {
|
return await getProblemPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
});
|
},
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
},
|
} as VxeTableGridOptions<AftersalesProblemApi.Problem>,
|
});
|
</script>
|
|
<template>
|
<Page auto-content-height>
|
<FormModal @success="handleRefresh" />
|
|
<Grid table-title="售后问题库列表">
|
<template #toolbar-tools>
|
<TableAction
|
:actions="[
|
{
|
label: '新增问题',
|
type: 'primary',
|
icon: ACTION_ICON.ADD,
|
auth: ['aftersales:problem:create'],
|
onClick: handleCreate,
|
},
|
]"
|
/>
|
</template>
|
|
<template #no="{ row }">
|
<Button type="link" @click="handleDetail(row)">
|
{{ row.no }}
|
</Button>
|
</template>
|
|
<template #issueType="{ row }">
|
<Tag v-if="row.issueType === 1" color="blue">一般问题</Tag>
|
<Tag v-else-if="row.issueType === 2" color="orange">维修问题</Tag>
|
<Tag v-else-if="row.issueType === 3" color="red">退货问题</Tag>
|
<span v-else>-</span>
|
</template>
|
|
<template #severityLevel="{ row }">
|
<Tag v-if="row.severityLevel === 0" color="green">轻微</Tag>
|
<Tag v-else-if="row.severityLevel === 1" color="blue">一般</Tag>
|
<Tag v-else-if="row.severityLevel === 2" color="orange">严重</Tag>
|
<Tag v-else-if="row.severityLevel === 3" color="red">致命</Tag>
|
<span v-else>-</span>
|
</template>
|
|
<template #rootCauseCategory="{ row }">
|
<span>{{ rootCauseLabelMap[row.rootCauseCategory!] || '-' }}</span>
|
</template>
|
|
<template #status="{ row }">
|
<Tag
|
:color="
|
row.status === 1
|
? 'green'
|
: row.status === 0
|
? 'default'
|
: 'orange'
|
"
|
>
|
{{ statusLabelMap[row.status!] || '-' }}
|
</Tag>
|
</template>
|
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: '查看',
|
type: 'link',
|
icon: ACTION_ICON.VIEW,
|
onClick: handleDetail.bind(null, row),
|
},
|
{
|
label: '编辑',
|
type: 'link',
|
icon: ACTION_ICON.EDIT,
|
auth: ['aftersales:problem:update'],
|
ifShow: row.status === 0,
|
onClick: handleEdit.bind(null, row),
|
},
|
{
|
label: '发布',
|
type: 'link',
|
auth: ['aftersales:problem:publish'],
|
ifShow: row.status === 0 || row.status === 2,
|
popConfirm: {
|
title: '确认发布该问题?',
|
confirm: handlePublish.bind(null, row),
|
},
|
},
|
{
|
label: '停用',
|
type: 'link',
|
auth: ['aftersales:problem:disable'],
|
ifShow: row.status === 1,
|
popConfirm: {
|
title: '确认停用该问题?',
|
confirm: handleDisable.bind(null, row),
|
},
|
},
|
{
|
label: '删除',
|
type: 'link',
|
danger: true,
|
icon: ACTION_ICON.DELETE,
|
auth: ['aftersales:problem:delete'],
|
ifShow: row.status === 0,
|
popConfirm: {
|
title: `确认删除问题【${row.no}】?`,
|
confirm: handleDelete.bind(null, row),
|
},
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|