From 27c8277d717b34b55f3ea967027b53b067f77df3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 16:58:49 +0800
Subject: [PATCH] feat 功能变更
---
src/views/crm/cancellation/index.vue | 189 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 189 insertions(+), 0 deletions(-)
diff --git a/src/views/crm/cancellation/index.vue b/src/views/crm/cancellation/index.vue
new file mode 100644
index 0000000..731d4e1
--- /dev/null
+++ b/src/views/crm/cancellation/index.vue
@@ -0,0 +1,189 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { CrmCancellationApi } from '#/api/crm/cancellation';
+
+import { Page, useVbenModal } from '@vben/common-ui';
+import { downloadFileFromBlobPart } from '@vben/utils';
+
+import { message } from 'ant-design-vue';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import {
+ auditCancellation,
+ deleteCancellation,
+ exportCancellation,
+ getCancellationPage,
+} from '#/api/crm/cancellation';
+import { $t } from '#/locales';
+
+import { useGridColumns, useGridFormSchema } from './data';
+import Form from './modules/form.vue';
+
+const [FormModal, formModalApi] = useVbenModal({
+ connectedComponent: Form,
+ destroyOnClose: true,
+});
+
+/** 鍒锋柊琛ㄦ牸 */
+function handleRefresh() {
+ gridApi.query();
+}
+
+/** 瀵煎嚭琛ㄦ牸 */
+async function handleExport() {
+ const formValues = await gridApi.formApi.getValues();
+ const data = await exportCancellation(formValues);
+ downloadFileFromBlobPart({ fileName: '閿�鎴风敵璇�.xls', source: data });
+}
+
+/** 鏂板 */
+function handleCreate() {
+ formModalApi.setData(null).open();
+}
+
+/** 缂栬緫 */
+function handleEdit(row: CrmCancellationApi.Cancellation) {
+ formModalApi.setData({ cancellation: row }).open();
+}
+
+/** 鍒犻櫎 */
+async function handleDelete(row: CrmCancellationApi.Cancellation) {
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deleting', [row.cancellationNo ?? '']),
+ duration: 0,
+ });
+ try {
+ await deleteCancellation(row.id!);
+ message.success(
+ $t('ui.actionMessage.deleteSuccess', [row.cancellationNo ?? '']),
+ );
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 瀹℃壒锛堥�氳繃/椹冲洖锛� */
+async function handleAudit(
+ row: CrmCancellationApi.Cancellation,
+ pass: boolean,
+) {
+ const hideLoading = message.loading({
+ content: pass ? '瀹℃壒閫氳繃涓�...' : '瀹℃壒椹冲洖涓�...',
+ duration: 0,
+ });
+ try {
+ await auditCancellation({ id: row.id!, auditStatus: pass ? 20 : 30 });
+ message.success(pass ? '瀹℃壒閫氳繃' : '瀹℃壒椹冲洖');
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: useGridFormSchema(),
+ },
+ gridOptions: {
+ columns: useGridColumns(),
+ height: 'auto',
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) =>
+ await getCancellationPage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ ...formValues,
+ }),
+ },
+ },
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: true,
+ search: true,
+ },
+ } as VxeTableGridOptions<CrmCancellationApi.Cancellation>,
+});
+</script>
+
+<template>
+ <Page auto-content-height>
+ <FormModal @success="handleRefresh" />
+ <Grid table-title="閿�鎴风敵璇峰垪琛�">
+ <template #toolbar-tools>
+ <TableAction
+ :actions="[
+ {
+ label: $t('ui.actionTitle.create', ['閿�鎴风敵璇�']),
+ type: 'primary',
+ icon: ACTION_ICON.ADD,
+ auth: ['crm:cancellation:create'],
+ onClick: handleCreate,
+ },
+ {
+ label: $t('ui.actionTitle.export'),
+ type: 'primary',
+ icon: ACTION_ICON.DOWNLOAD,
+ auth: ['crm:cancellation:export'],
+ onClick: handleExport,
+ },
+ ]"
+ />
+ </template>
+ <template #actions="{ row }">
+ <TableAction
+ :actions="[
+ {
+ label: '閫氳繃',
+ type: 'link',
+ icon: ACTION_ICON.AUDIT,
+ auth: ['crm:cancellation:update'],
+ ifShow: row.auditStatus === 0 || row.auditStatus === 10,
+ popConfirm: {
+ title: '纭瀹℃壒閫氳繃璇ラ攢鎴风敵璇凤紵',
+ confirm: handleAudit.bind(null, row, true),
+ },
+ },
+ {
+ label: '椹冲洖',
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.AUDIT,
+ auth: ['crm:cancellation:update'],
+ ifShow: row.auditStatus === 0 || row.auditStatus === 10,
+ popConfirm: {
+ title: '纭椹冲洖璇ラ攢鎴风敵璇凤紵',
+ confirm: handleAudit.bind(null, row, false),
+ },
+ },
+ {
+ label: $t('common.edit'),
+ type: 'link',
+ icon: ACTION_ICON.EDIT,
+ auth: ['crm:cancellation:update'],
+ onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: $t('common.delete'),
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ auth: ['crm:cancellation:delete'],
+ popConfirm: {
+ title: $t('ui.actionMessage.deleteConfirm', [
+ row.cancellationNo ?? '',
+ ]),
+ confirm: handleDelete.bind(null, row),
+ },
+ },
+ ]"
+ />
+ </template>
+ </Grid>
+ </Page>
+</template>
--
Gitblit v1.9.3