From 5c124cdf26e4d749eae1e7fc9df366e9a5f4d259 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期二, 18 八月 2026 15:04:09 +0800
Subject: [PATCH] 选择采购订单修改列表宽度设置

---
 src/views/erp/sale/order/index.vue |  193 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 179 insertions(+), 14 deletions(-)

diff --git a/src/views/erp/sale/order/index.vue b/src/views/erp/sale/order/index.vue
index 8c663a6..7071c8e 100644
--- a/src/views/erp/sale/order/index.vue
+++ b/src/views/erp/sale/order/index.vue
@@ -2,30 +2,43 @@
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
 
-import { ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import { useRoute, useRouter } from 'vue-router';
 
-import { Page, useVbenModal } from '../../../../packages/effects/common-ui/src';
-import { downloadFileFromBlobPart, isEmpty } from '../../../../packages/utils/src';
+import { Page, useVbenModal } from '@vben/common-ui';
+import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
 
-import { message } from 'ant-design-vue';
+import { message, Tag, Tooltip } from 'ant-design-vue';
 
 import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
 import {
+  cancelSaleOrder,
   deleteSaleOrder,
+  enableSaleOrder,
   exportSaleOrder,
   getSaleOrderPage,
   updateSaleOrderStatus,
 } from '#/api/erp/sale/order';
+import { generateFromSaleOrder } from '#/api/mes/wm/salesnotice';
 import { $t } from '#/locales';
 
 import { useGridColumns, useGridFormSchema } from './data';
 import Form from './modules/form.vue';
+import SalesNoticeForm from '#/views/wls/salesnotice/modules/form.vue';
 
 /** ERP 閿�鍞鍗曞垪琛� */
 defineOptions({ name: 'ErpSaleOrder' });
 
+const router = useRouter();
+const route = useRoute();
+
 const [FormModal, formModalApi] = useVbenModal({
   connectedComponent: Form,
+  destroyOnClose: true,
+});
+
+const [SalesNoticeFormModal, salesNoticeFormModalApi] = useVbenModal({
+  connectedComponent: SalesNoticeForm,
   destroyOnClose: true,
 });
 
@@ -83,6 +96,36 @@
   }
 }
 
+/** 浣滃簾閿�鍞鍗� */
+async function handleCancel(row: ErpSaleOrderApi.SaleOrder) {
+  const hideLoading = message.loading({
+    content: '姝e湪浣滃簾璇ヨ鍗�...',
+    duration: 0,
+  });
+  try {
+    await cancelSaleOrder(row.id!);
+    message.success('浣滃簾鎴愬姛');
+    handleRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+
+/** 鍚敤閿�鍞鍗曪紙鎭㈠宸蹭綔搴熻鍗曪級 */
+async function handleEnable(row: ErpSaleOrderApi.SaleOrder) {
+  const hideLoading = message.loading({
+    content: '姝e湪鍚敤璇ヨ鍗�...',
+    duration: 0,
+  });
+  try {
+    await enableSaleOrder(row.id!);
+    message.success('鍚敤鎴愬姛');
+    handleRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+
 const checkedIds = ref<number[]>([]);
 function handleRowCheckboxChange({
   records,
@@ -97,6 +140,30 @@
   formModalApi.setData({ formType: 'detail', id: row.id }).open();
 }
 
+/** 鏌ョ湅鍏宠仈鍚堝悓 */
+function handleViewContract(row: ErpSaleOrderApi.SaleOrder) {
+  if (row.contractId) {
+    router.push({
+      path: `/crm/contract/detail/${row.contractId}`,
+    });
+  }
+}
+
+/** 鐢熸垚鍙戣揣閫氱煡鍗� */
+async function handleGenerateNotice(row: ErpSaleOrderApi.SaleOrder) {
+  try {
+    const noticeId = await generateFromSaleOrder(row.id!);
+    message.success('鐢熸垚鍙戣揣閫氱煡鍗曟垚鍔�');
+    handleRefresh();
+    // 鐩存帴鎵撳紑鍙戣揣閫氱煡鍗曡鎯呭脊妗�
+    salesNoticeFormModalApi
+      .setData({ formType: 'detail', id: noticeId })
+      .open();
+  } catch (e) {
+    console.error(e);
+  }
+}
+
 const [Grid, gridApi] = useVbenVxeGrid({
   formOptions: {
     schema: useGridFormSchema(),
@@ -108,10 +175,19 @@
     proxyConfig: {
       ajax: {
         query: async ({ page }, formValues) => {
+          // 鐢熶骇鐘舵�佹悳绱㈠弬鏁拌浆鎹細-1(鏃犻渶鐢熶骇) 鈫� needProduction=0
+          const { productionStatus, ...rest } = formValues;
+          const params: Record<string, any> = { ...rest };
+          if (productionStatus === -1) {
+            params.needProduction = 0;
+          } else if (productionStatus != null) {
+            params.productionStatus = productionStatus;
+            params.needProduction = 1;
+          }
           return await getSaleOrderPage({
             pageNo: page.currentPage,
             pageSize: page.pageSize,
-            ...formValues,
+            ...params,
           });
         },
       },
@@ -130,10 +206,20 @@
     checkboxChange: handleRowCheckboxChange,
   },
 });
+
+/** 澶勭悊浠庡悎鍚岃烦杞繃鏉ョ殑鏌ヨ鍙傛暟 */
+onMounted(() => {
+  const orderId = route.query.id;
+  if (orderId) {
+    formModalApi.setData({ formType: 'detail', id: Number(orderId) }).open();
+  }
+});
 </script>
 
 <template>
-  <Page auto-content-height><FormModal @success="handleRefresh" />
+  <Page auto-content-height>
+    <FormModal @success="handleRefresh" />
+    <SalesNoticeFormModal />
     <Grid table-title="閿�鍞鍗曞垪琛�">
       <template #toolbar-tools>
         <TableAction
@@ -167,6 +253,46 @@
           ]"
         />
       </template>
+      <template #no="{ row }">
+        <Tooltip v-if="row.status === 30" title="璇ヨ鍗曞凡浣滃簾锛岃鍗曞凡澶辨晥">
+          <span class="text-red-500 cursor-pointer" @click="handleDetail(row)">
+            {{ row.no }}
+          </span>
+        </Tooltip>
+        <a v-else class="text-primary cursor-pointer" @click="handleDetail(row)">
+          {{ row.no }}
+        </a>
+      </template>
+      <template #contractNo="{ row }">
+        <a v-if="row.contractId" class="text-primary cursor-pointer" @click="handleViewContract(row)">
+          {{ row.contractNo }}
+        </a>
+        <span v-else>-</span>
+      </template>
+      <template #status="{ row }">
+        <Tag v-if="row.status === 10" color="warning">鏈鏍�</Tag>
+        <Tag v-if="row.status === 20" color="success">宸插鏍�</Tag>
+        <Tag v-if="row.status === 30" color="error">宸蹭綔搴�</Tag>
+      </template>
+      <template #needProduction="{ row }">
+        <Tag v-if="row.needProduction === 1" color="success">鏄�</Tag>
+        <Tag v-else color="default">鍚�</Tag>
+      </template>
+      <template #outStatus="{ row }">
+        <Tag v-if="row.outStatus === 0" color="default">鏈嚭搴�</Tag>
+        <Tag v-else-if="row.outStatus === 1" color="processing">宸查鐣�</Tag>
+        <Tag v-else-if="row.outStatus === 2" color="warning">閮ㄥ垎鍑哄簱</Tag>
+        <Tag v-else-if="row.outStatus === 3" color="success">鍏ㄩ儴鍑哄簱</Tag>
+      </template>
+      <template #productionStatus="{ row }">
+        <template v-if="row.needProduction !== 1">
+          <Tag color="default">鏃犻渶鐢熶骇</Tag>
+        </template>
+        <template v-else>
+          <Tag v-if="row.productionStatus === 0" color="warning">鏈畬鎴�</Tag>
+          <Tag v-else-if="row.productionStatus === 1" color="success">宸插畬鎴�</Tag>
+        </template>
+      </template>
       <template #actions="{ row }">
         <TableAction
           :actions="[
@@ -182,22 +308,60 @@
               type: 'link',
               icon: ACTION_ICON.EDIT,
               auth: ['erp:sale-order:update'],
-              ifShow: () => row.status !== 20,
+              ifShow: () => row.status === 10,
               onClick: handleEdit.bind(null, row),
             },
             {
-              label: row.status === 10 ? '瀹℃壒' : '鍙嶅鎵�',
+              label: '瀹℃壒',
               type: 'link',
               icon: ACTION_ICON.AUDIT,
               auth: ['erp:sale-order:update-status'],
+              ifShow: () => row.status === 10,
               popConfirm: {
-                title: `纭${row.status === 10 ? '瀹℃壒' : '鍙嶅鎵�'}${row.no}鍚楋紵`,
-                confirm: handleUpdateStatus.bind(
-                  null,
-                  row,
-                  row.status === 10 ? 20 : 10,
-                ),
+                title: `纭瀹℃壒${row.no}鍚楋紵`,
+                confirm: handleUpdateStatus.bind(null, row, 20),
               },
+            },
+            {
+              label: '鍙嶅鎵�',
+              type: 'link',
+              icon: ACTION_ICON.AUDIT,
+              auth: ['erp:sale-order:update-status'],
+              ifShow: () => row.status === 20,
+              popConfirm: {
+                title: `纭鍙嶅鎵�${row.no}鍚楋紵`,
+                confirm: handleUpdateStatus.bind(null, row, 10),
+              },
+            },
+            {
+              label: '浣滃簾',
+              type: 'link',
+              icon: 'ant-design:stop-outlined',
+              auth: ['erp:sale-order:cancel'],
+              ifShow: () => row.status === 20,
+              popConfirm: {
+                title: `纭浣滃簾${row.no}鍚楋紵浣滃簾鍚庝笉鍙仮澶嶏紒`,
+                confirm: handleCancel.bind(null, row),
+              },
+            },
+            {
+              label: '鍚敤',
+              type: 'link',
+              icon: 'ant-design:check-circle-outlined',
+              auth: ['erp:sale-order:enable'],
+              ifShow: () => row.status === 30,
+              popConfirm: {
+                title: `纭鍚敤${row.no}鍚楋紵`,
+                confirm: handleEnable.bind(null, row),
+              },
+            },
+            {
+              label: '鐢熸垚鍙戣揣閫氱煡鍗�',
+              type: 'link',
+              icon: 'ant-design:file-protect-outlined',
+              auth: ['mes:wm-sales-notice:create'],
+              ifShow: () => row.status === 20 && row.canCreateSalesNotice,
+              onClick: handleGenerateNotice.bind(null, row),
             },
             {
               label: $t('common.delete'),
@@ -205,6 +369,7 @@
               danger: true,
               icon: ACTION_ICON.DELETE,
               auth: ['erp:sale-order:delete'],
+              ifShow: () => row.status === 10,
               popConfirm: {
                 title: $t('ui.actionMessage.deleteConfirm', [row.no]),
                 confirm: handleDelete.bind(null, [row.id!]),

--
Gitblit v1.9.3