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/contract/components/command-list.vue |  188 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 188 insertions(+), 0 deletions(-)

diff --git a/src/views/crm/contract/components/command-list.vue b/src/views/crm/contract/components/command-list.vue
new file mode 100644
index 0000000..bea274d
--- /dev/null
+++ b/src/views/crm/contract/components/command-list.vue
@@ -0,0 +1,188 @@
+<!-- 鍚堝悓鎸囦护涓嬪彂鍒楄〃锛氱敤浜庛�愬悎鍚屻�戣鎯� Tab锛屽睍绀哄苟涓嬪彂/鎵ц/鍙栨秷鍚堝悓鎸囦护 -->
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { CrmContractCommandApi } from '#/api/crm/contract-command';
+
+import { useVbenModal } from '@vben/common-ui';
+
+import { message } from 'ant-design-vue';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import {
+  cancelContractCommand,
+  deleteContractCommand,
+  executeContractCommand,
+  getContractCommandPage,
+} from '#/api/crm/contract-command';
+import { $t } from '#/locales';
+
+import CommandForm from './command-form.vue';
+import { useDetailListColumns } from './command-list-data';
+
+const props = defineProps<{
+  contractId?: number; // 鍚堝悓缂栧彿
+  contractNo?: string; // 鍚堝悓鍗曞彿
+}>();
+
+const [FormModal, formModalApi] = useVbenModal({
+  connectedComponent: CommandForm,
+  destroyOnClose: true,
+});
+
+/** 鍒锋柊琛ㄦ牸 */
+function handleRefresh() {
+  gridApi.query();
+}
+
+/** 鍒涘缓鎸囦护 */
+function handleCreate() {
+  formModalApi
+    .setData({ contractNo: props.contractNo })
+    .open();
+}
+
+/** 缂栬緫鎸囦护 */
+function handleEdit(row: CrmContractCommandApi.ContractCommand) {
+  formModalApi.setData({ command: row }).open();
+}
+
+/** 鎵ц鎸囦护 */
+async function handleExecute(row: CrmContractCommandApi.ContractCommand) {
+  const hideLoading = message.loading({ content: '鎸囦护鎵ц涓�...', duration: 0 });
+  try {
+    await executeContractCommand(row.id!);
+    message.success('鎸囦护鎵ц瀹屾垚');
+    handleRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+
+/** 鍙栨秷鎸囦护 */
+async function handleCancel(row: CrmContractCommandApi.ContractCommand) {
+  const hideLoading = message.loading({ content: '鎸囦护鍙栨秷涓�...', duration: 0 });
+  try {
+    await cancelContractCommand(row.id!);
+    message.success('鎸囦护宸插彇娑�');
+    handleRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+
+/** 鍒犻櫎鎸囦护 */
+async function handleDelete(row: CrmContractCommandApi.ContractCommand) {
+  const hideLoading = message.loading({
+    content: $t('ui.actionMessage.deleting', [row.bizNo ?? '']),
+    duration: 0,
+  });
+  try {
+    await deleteContractCommand(row.id!);
+    message.success($t('ui.actionMessage.deleteSuccess', [row.bizNo ?? '']));
+    handleRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+  gridOptions: {
+    columns: useDetailListColumns(),
+    height: 400,
+    keepSource: true,
+    proxyConfig: {
+      ajax: {
+        query: async ({ page }) => {
+          if (!props.contractId) {
+            return { list: [], total: 0 };
+          }
+          return await getContractCommandPage({
+            pageNo: page.currentPage,
+            pageSize: page.pageSize,
+            contractId: props.contractId,
+          });
+        },
+      },
+    },
+    rowConfig: {
+      keyField: 'id',
+      isHover: true,
+    },
+    toolbarConfig: {
+      refresh: true,
+      search: false,
+    },
+  } as VxeTableGridOptions<CrmContractCommandApi.ContractCommand>,
+});
+</script>
+
+<template>
+  <div>
+    <FormModal @success="handleRefresh" />
+    <Grid>
+      <template #toolbar-tools>
+        <TableAction
+          :actions="[
+            {
+              label: '涓嬪彂鎸囦护',
+              type: 'primary',
+              icon: ACTION_ICON.ADD,
+              auth: ['crm:contract-command:create'],
+              onClick: handleCreate,
+            },
+          ]"
+        />
+      </template>
+      <template #actions="{ row }">
+        <TableAction
+          :actions="[
+            {
+              label: '鎵ц',
+              type: 'link',
+              icon: ACTION_ICON.AUDIT,
+              auth: ['crm:contract-command:update'],
+              ifShow: row.status === 0 || row.status === 10,
+              popConfirm: {
+                title: '纭鎵ц璇ユ寚浠わ紵',
+                confirm: handleExecute.bind(null, row),
+              },
+            },
+            {
+              label: '鍙栨秷',
+              type: 'link',
+              danger: true,
+              icon: ACTION_ICON.CLOSE,
+              auth: ['crm:contract-command:update'],
+              ifShow: row.status === 0 || row.status === 10,
+              popConfirm: {
+                title: '纭鍙栨秷璇ユ寚浠わ紵',
+                confirm: handleCancel.bind(null, row),
+              },
+            },
+            {
+              label: $t('common.edit'),
+              type: 'link',
+              icon: ACTION_ICON.EDIT,
+              auth: ['crm:contract-command:update'],
+              ifShow: row.status === 0,
+              onClick: handleEdit.bind(null, row),
+            },
+            {
+              label: $t('common.delete'),
+              type: 'link',
+              danger: true,
+              icon: ACTION_ICON.DELETE,
+              auth: ['crm:contract-command:delete'],
+              popConfirm: {
+                title: $t('ui.actionMessage.deleteConfirm', [
+                  row.bizNo ?? '',
+                ]),
+                confirm: handleDelete.bind(null, row),
+              },
+            },
+          ]"
+        />
+      </template>
+    </Grid>
+  </div>
+</template>

--
Gitblit v1.9.3