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/mes/pro/alternativeplan/index.vue |  188 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 188 insertions(+), 0 deletions(-)

diff --git a/src/views/mes/pro/alternativeplan/index.vue b/src/views/mes/pro/alternativeplan/index.vue
new file mode 100644
index 0000000..3cb6506
--- /dev/null
+++ b/src/views/mes/pro/alternativeplan/index.vue
@@ -0,0 +1,188 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesProAlternativePlanApi } from '#/api/mes/pro/alternativeplan';
+
+import { ref } from 'vue';
+
+import { Page, useVbenModal } from '@vben/common-ui';
+import { isEmpty } from '@vben/utils';
+
+import { message, Tag } from 'ant-design-vue';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import { deletePlan, getPlanPage, publishPlan } from '#/api/mes/pro/alternativeplan';
+import { $t } from '#/locales';
+
+import { PLAN_STATUS, useGridColumns, useGridFormSchema } from './data';
+import Form from './modules/form.vue';
+
+/** MES 浣滀笟鏇夸唬鏂规鍒楄〃 */
+defineOptions({ name: 'MesProAlternativePlan' });
+
+const [FormModal, formModalApi] = useVbenModal({
+  connectedComponent: Form,
+  destroyOnClose: true,
+});
+
+function handleRefresh() {
+  gridApi.query();
+}
+
+function handleCreate() {
+  formModalApi.setData({ formType: 'create' }).open();
+}
+
+function handleEdit(row: MesProAlternativePlanApi.AlternativePlan) {
+  formModalApi.setData({ formType: 'edit', id: row.id }).open();
+}
+
+function handleDetail(row: MesProAlternativePlanApi.AlternativePlan) {
+  formModalApi.setData({ formType: 'detail', id: row.id }).open();
+}
+
+async function handleDelete(ids: number[]) {
+  const hideLoading = message.loading({
+    content: $t('ui.actionMessage.deleting'),
+    duration: 0,
+  });
+  try {
+    await deletePlan(ids);
+    message.success($t('ui.actionMessage.deleteSuccess'));
+    handleRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+
+async function handlePublish(row: MesProAlternativePlanApi.AlternativePlan) {
+  await publishPlan(row.id!);
+  message.success('宸插彂甯�');
+  handleRefresh();
+}
+
+const checkedIds = ref<number[]>([]);
+function handleRowCheckboxChange({
+  records,
+}: {
+  records: MesProAlternativePlanApi.AlternativePlan[];
+}) {
+  checkedIds.value = records.map((item) => item.id!);
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+  formOptions: {
+    schema: useGridFormSchema(),
+  },
+  gridOptions: {
+    columns: useGridColumns(),
+    height: 'auto',
+    keepSource: true,
+    proxyConfig: {
+      ajax: {
+        query: async ({ page }, formValues) => {
+          return await getPlanPage({
+            pageNo: page.currentPage,
+            pageSize: page.pageSize,
+            ...formValues,
+          });
+        },
+      },
+    },
+    rowConfig: {
+      keyField: 'id',
+      isHover: true,
+    },
+    toolbarConfig: {
+      refresh: true,
+      search: true,
+    },
+  } as VxeTableGridOptions<MesProAlternativePlanApi.AlternativePlan>,
+  gridEvents: {
+    checkboxAll: handleRowCheckboxChange,
+    checkboxChange: handleRowCheckboxChange,
+  },
+});
+</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: ['mes:pro-alternative-plan:create'],
+              onClick: handleCreate,
+            },
+            {
+              label: '鎵归噺鍒犻櫎',
+              type: 'primary',
+              danger: true,
+              disabled: isEmpty(checkedIds),
+              icon: ACTION_ICON.DELETE,
+              auth: ['mes:pro-alternative-plan:delete'],
+              popConfirm: {
+                title: `鏄惁鍒犻櫎鎵�閫変腑鏁版嵁锛焋,
+                confirm: handleDelete.bind(null, checkedIds),
+              },
+            },
+          ]"
+        />
+      </template>
+      <template #code="{ row }">
+        <a class="link" @click="handleDetail(row)">{{ row.code }}</a>
+      </template>
+      <template #status="{ row }">
+        <Tag v-if="row.status === PLAN_STATUS.DRAFT" color="default">鑽夌</Tag>
+        <Tag v-else-if="row.status === PLAN_STATUS.PUBLISHED" color="success">宸插彂甯�</Tag>
+      </template>
+      <template #actions="{ row }">
+        <TableAction
+          :actions="[
+            {
+              label: $t('common.detail'),
+              type: 'link',
+              icon: ACTION_ICON.VIEW,
+              auth: ['mes:pro-alternative-plan:query'],
+              onClick: handleDetail.bind(null, row),
+            },
+            {
+              label: $t('common.edit'),
+              type: 'link',
+              icon: ACTION_ICON.EDIT,
+              auth: ['mes:pro-alternative-plan:update'],
+              ifShow: row.status === PLAN_STATUS.DRAFT,
+              onClick: handleEdit.bind(null, row),
+            },
+            {
+              label: '鍙戝竷',
+              type: 'link',
+              auth: ['mes:pro-alternative-plan:update'],
+              ifShow: row.status === PLAN_STATUS.DRAFT,
+              popConfirm: {
+                title: '纭鍙戝竷璇ユ柟妗堬紵',
+                confirm: handlePublish.bind(null, row),
+              },
+            },
+            {
+              label: $t('common.delete'),
+              type: 'link',
+              danger: true,
+              icon: ACTION_ICON.DELETE,
+              auth: ['mes:pro-alternative-plan:delete'],
+              ifShow: row.status === PLAN_STATUS.DRAFT,
+              popConfirm: {
+                title: $t('ui.actionMessage.deleteConfirm', [row.code]),
+                confirm: handleDelete.bind(null, [row.id!]),
+              },
+            },
+          ]"
+        />
+      </template>
+    </Grid>
+  </Page>
+</template>

--
Gitblit v1.9.3