From 2ee69f2c07b7cdc5b1f209d3b4d9606374b94c25 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 02 十一月 2026 16:52:04 +0800
Subject: [PATCH] feat(erp): 采购/销售明细按含税单价口径联算,采购申请与申请采购单合并入口

---
 src/views/erp/purchase/demand/index.vue |  265 ----------------------------------------------------
 1 files changed, 4 insertions(+), 261 deletions(-)

diff --git a/src/views/erp/purchase/demand/index.vue b/src/views/erp/purchase/demand/index.vue
index 3b0ffd3..a76b000 100644
--- a/src/views/erp/purchase/demand/index.vue
+++ b/src/views/erp/purchase/demand/index.vue
@@ -1,270 +1,13 @@
 <script lang="ts" setup>
-import type { VxeTableGridOptions } from '#/adapter/vxe-table';
-import type { ErpPurchaseDemandApi } from '#/api/erp/purchase/demand';
+import { Page } from '@vben/common-ui';
 
-import { ref } from 'vue';
-import { useRouter } from 'vue-router';
+import DemandPanel from './modules/demand-panel.vue';
 
-import { confirm, Page, useVbenModal } from '@vben/common-ui';
-import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
-
-import { message } from 'ant-design-vue';
-
-import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
-import {
-  createPurchaseOrderByDemand,
-  deleteDemand,
-  exportDemand,
-  getDemandPage,
-} from '#/api/erp/purchase/demand';
-import { $t } from '#/locales';
-
-import { DEMAND_STATUS, useGridColumns, useGridFormSchema } from './data';
-import Form from './modules/form.vue';
-import Print from './modules/print.vue';
-
-/** 鐢宠閲囪喘鍗曪紙闇�姹傚崟锛夛細鎵嬪伐/鐢熶骇璁″垝闇�姹� 鈫� 鎵归噺閲囪喘涓嬪崟鐢熸垚閲囪喘璁㈠崟 */
+/** 鐢宠閲囪喘鍗曪紙4.4锛夛細宸插苟鍏ャ�岄噰璐敵璇峰崟銆嶉〉绛撅紝姝ら〉闈繚鐣欑敤浜庢棫璺敱鐩磋揪 */
 defineOptions({ name: 'ErpPurchaseDemand' });
-
-const router = useRouter();
-
-const [FormModal, formModalApi] = useVbenModal({
-  connectedComponent: Form,
-  destroyOnClose: true,
-});
-
-const checkedRows = ref<ErpPurchaseDemandApi.Demand[]>([]);
-
-/** 鎵撳嵃缁勪欢锛�4.4鈶� 鎵撳嵃闇�姹傚崟锛� */
-const printRef = ref<InstanceType<typeof Print>>();
-
-/** 鎵撳嵃闇�姹傚崟 */
-function handlePrint(row: ErpPurchaseDemandApi.Demand) {
-  printRef.value?.print(row.id!);
-}
-
-/** 鍒锋柊琛ㄦ牸 */
-function handleRefresh() {
-  gridApi.query();
-}
-
-/** 瀵煎嚭琛ㄦ牸 */
-async function handleExport() {
-  const data = await exportDemand(await gridApi.formApi.getValues());
-  downloadFileFromBlobPart({ fileName: '鐢宠閲囪喘鍗�.xlsx', source: data });
-}
-
-/** 鏂板闇�姹傚崟 */
-function handleCreate() {
-  formModalApi.setData({ formType: 'create' }).open();
-}
-
-/** 缂栬緫闇�姹傚崟 */
-function handleEdit(row: ErpPurchaseDemandApi.Demand) {
-  formModalApi.setData({ formType: 'edit', id: row.id }).open();
-}
-
-/** 鏌ョ湅璇︽儏 */
-function handleDetail(row: ErpPurchaseDemandApi.Demand) {
-  formModalApi.setData({ formType: 'detail', id: row.id }).open();
-}
-
-/** 鍒犻櫎闇�姹傚崟 */
-async function handleDelete(row: ErpPurchaseDemandApi.Demand) {
-  const hideLoading = message.loading({
-    content: $t('ui.actionMessage.deleting'),
-    duration: 0,
-  });
-  try {
-    await deleteDemand(row.id!);
-    message.success($t('ui.actionMessage.deleteSuccess'));
-    handleRefresh();
-  } finally {
-    hideLoading();
-  }
-}
-
-/** 閲囪喘涓嬪崟锛堝崟鏉℃垨鎵归噺锛夛細鎵�閫夐渶姹傚崟蹇呴』灞炰簬鍚屼竴渚涜揣鍟� */
-async function handlePurchase(rows: ErpPurchaseDemandApi.Demand[]) {
-  const unpurchased = rows.filter(
-    (row) => row.status === DEMAND_STATUS.UNPURCHASED,
-  );
-  if (unpurchased.length === 0) {
-    message.warning('鎵�閫夐渶姹傚崟鍧囧凡閲囪喘锛屾棤闇�閲嶅涓嬪崟');
-    return;
-  }
-  if (unpurchased.length !== rows.length) {
-    message.warning(
-      `鎵�閫� ${rows.length} 鏉¢渶姹傚崟涓紝${rows.length - unpurchased.length} 鏉″凡閲囪喘锛屼粎瀵瑰墿浣欑殑 ${unpurchased.length} 鏉′笅鍗昤,
-    );
-  }
-  const noSupplier = unpurchased.find((row) => !row.supplierId);
-  if (noSupplier) {
-    message.error(
-      `闇�姹傚崟[${noSupplier.no}]鏈�夋嫨渚涜揣鍟嗭紝璇峰厛銆岀紪杈戙�嶈ˉ榻愪緵璐у晢鍚庡啀閲囪喘涓嬪崟`,
-    );
-    return;
-  }
-  const supplierNames = new Set(unpurchased.map((row) => row.supplierName));
-  if (supplierNames.size > 1) {
-    message.error(
-      `鎵�閫夐渶姹傚崟鍒嗗睘澶氫釜渚涜揣鍟嗭紙${[...supplierNames].join('銆�')}锛夛紝涓�娆″彧鑳藉鍚屼竴渚涜揣鍟嗙殑闇�姹傚崟鍚堝苟涓嬪崟锛岃鍒嗘壒鎿嶄綔`,
-    );
-    return;
-  }
-  await confirm(
-    `纭涓轰緵璐у晢[${[...supplierNames][0]}]鐨� ${unpurchased.length} 鏉¢渶姹傚崟鐢熸垚閲囪喘璁㈠崟鍚楋紵`,
-  );
-  const hideLoading = message.loading({
-    content: '姝e湪鐢熸垚閲囪喘璁㈠崟...',
-    duration: 0,
-  });
-  try {
-    const result = await createPurchaseOrderByDemand(
-      unpurchased.map((row) => row.id!),
-    );
-    message.success({
-      content: `宸茬敓鎴愰噰璐鍗昜${result.orderNo}]锛屽彲鍦ㄣ�屾煡鐪嬬浉鍏宠鍗曘�嶄腑杩芥函`,
-      duration: 5,
-    });
-    handleRefresh();
-  } finally {
-    hideLoading();
-  }
-}
-
-/** 鎵归噺閲囪喘涓嬪崟锛氬彇琛ㄦ牸鍕鹃�夎 */
-function handleBatchPurchase() {
-  handlePurchase(checkedRows.value);
-}
-
-/** 鏌ョ湅鐩稿叧閲囪喘璁㈠崟 */
-function handleViewOrder(row: ErpPurchaseDemandApi.Demand) {
-  router.push({
-    name: 'ErpPurchaseOrder',
-    query: { id: row.orderId },
-  });
-}
-
-function handleRowCheckboxChange({
-  records,
-}: {
-  records: ErpPurchaseDemandApi.Demand[];
-}) {
-  checkedRows.value = records;
-}
-
-const [Grid, gridApi] = useVbenVxeGrid({
-  formOptions: {
-    schema: useGridFormSchema(),
-  },
-  gridOptions: {
-    columns: useGridColumns(),
-    height: 'auto',
-    keepSource: true,
-    proxyConfig: {
-      ajax: {
-        query: async ({ page }, formValues) =>
-          await getDemandPage({
-            pageNo: page.currentPage,
-            pageSize: page.pageSize,
-            ...formValues,
-          }),
-      },
-    },
-    rowConfig: { keyField: 'id', isHover: true },
-    toolbarConfig: { refresh: true, search: true, custom: true },
-  } as VxeTableGridOptions<ErpPurchaseDemandApi.Demand>,
-  gridEvents: {
-    checkboxAll: handleRowCheckboxChange,
-    checkboxChange: handleRowCheckboxChange,
-  },
-});
 </script>
 <template>
   <Page auto-content-height>
-    <FormModal @success="handleRefresh" />
-    <Print ref="printRef" />
-    <Grid table-title="鐢宠閲囪喘鍗曞垪琛�">
-      <template #toolbar-tools>
-        <TableAction
-          :actions="[
-            {
-              label: $t('ui.actionTitle.create', ['鐢宠閲囪喘鍗�']),
-              type: 'primary',
-              icon: ACTION_ICON.ADD,
-              auth: ['erp:purchase-demand:create'],
-              onClick: handleCreate,
-            },
-            {
-              label: '鎵归噺閲囪喘涓嬪崟',
-              type: 'primary',
-              icon: ACTION_ICON.AUDIT,
-              disabled: isEmpty(checkedRows),
-              auth: ['erp:purchase-demand:purchase'],
-              onClick: handleBatchPurchase,
-            },
-            {
-              label: $t('ui.actionTitle.export'),
-              type: 'primary',
-              icon: ACTION_ICON.DOWNLOAD,
-              auth: ['erp:purchase-demand:export'],
-              onClick: handleExport,
-            },
-          ]"
-        />
-      </template>
-      <template #actions="{ row }">
-        <TableAction
-          :actions="[
-            {
-              label: $t('common.detail'),
-              type: 'link',
-              icon: ACTION_ICON.VIEW,
-              onClick: handleDetail.bind(null, row),
-            },
-            {
-              label: $t('common.edit'),
-              type: 'link',
-              icon: ACTION_ICON.EDIT,
-              auth: ['erp:purchase-demand:update'],
-              ifShow: () => row.status === DEMAND_STATUS.UNPURCHASED,
-              onClick: handleEdit.bind(null, row),
-            },
-            {
-              label: '閲囪喘涓嬪崟',
-              type: 'link',
-              auth: ['erp:purchase-demand:purchase'],
-              ifShow: () => row.status === DEMAND_STATUS.UNPURCHASED,
-              onClick: handlePurchase.bind(null, [row]),
-            },
-            {
-              label: '鎵撳嵃',
-              type: 'link',
-              icon: 'lucide:printer',
-              onClick: handlePrint.bind(null, row),
-            },
-            {
-              label: '鏌ョ湅鐩稿叧璁㈠崟',
-              type: 'link',
-              ifShow: () => !!row.orderId,
-              onClick: handleViewOrder.bind(null, row),
-            },
-            {
-              label: $t('common.delete'),
-              type: 'link',
-              danger: true,
-              icon: ACTION_ICON.DELETE,
-              auth: ['erp:purchase-demand:delete'],
-              ifShow: () => row.status === DEMAND_STATUS.UNPURCHASED,
-              popConfirm: {
-                title: $t('ui.actionMessage.deleteConfirm', [row.no]),
-                confirm: handleDelete.bind(null, row),
-              },
-            },
-          ]"
-        />
-      </template>
-    </Grid>
+    <DemandPanel />
   </Page>
 </template>

--
Gitblit v1.9.3