From 34b5d13e7322da990565e88b15bdfdd4c7abe903 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 04 十一月 2026 17:32:51 +0800
Subject: [PATCH] feat(erp): 采购台账与采购退货界面改造

---
 src/views/erp/purchase/order/data.ts |  225 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 223 insertions(+), 2 deletions(-)

diff --git a/src/views/erp/purchase/order/data.ts b/src/views/erp/purchase/order/data.ts
index de357d6..9edd2fb 100644
--- a/src/views/erp/purchase/order/data.ts
+++ b/src/views/erp/purchase/order/data.ts
@@ -11,14 +11,34 @@
 import { getAccountSimpleList } from '#/api/erp/finance/account';
 import { getSupplierSimpleList } from '#/api/srm/supplier';
 import { getSimpleUserList } from '#/api/system/user';
+import { getRangePickerDefaultProps, getOverdueTip, withoutFixedColumns } from '#/utils';
 import { MdmItemSelect } from '#/views/basicData/mdm/components';
-import { getRangePickerDefaultProps, withoutFixedColumns } from '#/utils';
+import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components';
+import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
 
 /** 琛ㄥ崟绫诲瀷 */
 export type FormType = 'create' | 'detail' | 'edit';
 
+/** 閲囪喘鏉ユ簮绫诲瀷锛�0 鏃犳潵婧愩��1 鐢熶骇宸ュ崟銆�3 閿�鍞鍗曪紙涓庡悗绔� ErpPurchaseOrderSourceTypeEnum 瀵归綈锛� */
+export const PurchaseSourceTypeEnum = {
+  NONE: 0,
+  WORK_ORDER: 1,
+  SALE_ORDER: 3,
+} as const;
+
+/** 琛ㄥ崟鏉ユ簮鑱斿姩鍥炶皟 */
+export interface FormSchemaHandlers {
+  /** 鏉ユ簮绫诲瀷鍙樻洿锛堢敤浜庢竻绌哄凡閫夋潵婧愬崟鎹級 */
+  onSourceTypeChange?: (sourceType: number | undefined) => void;
+  /** 鏉ユ簮鍗曟嵁閫変腑锛堢敤浜庡甫鍏ラ噰璐槑缁嗭級 */
+  onSourceOrderChange?: (sourceType: number, item: any) => void;
+}
+
 /** 琛ㄥ崟鐨勯厤缃」 */
-export function useFormSchema(formType: FormType): VbenFormSchema[] {
+export function useFormSchema(
+  formType: FormType,
+  handlers?: FormSchemaHandlers,
+): VbenFormSchema[] {
   return [
     {
       fieldName: 'id',
@@ -62,6 +82,127 @@
         valueField: 'id',
       },
       rules: 'required',
+    },
+    {
+      fieldName: 'purchaseType',
+      label: '閲囪喘绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        placeholder: '璇烽�夋嫨閲囪喘绫诲瀷',
+        allowClear: true,
+        options: getDictOptions(DICT_TYPE.ERP_PURCHASE_TYPE, 'number'),
+      },
+    },
+    {
+      fieldName: 'contractNo',
+      label: '鍚堝悓鍙�',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ悎鍚屽彿锛堟墜宸ヨ緭鍏ワ紝绯荤粺涓嶈嚜鍔ㄧ敓鎴愶級',
+        maxlength: 64,
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'projectName',
+      label: '椤圭洰鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ラ」鐩悕绉帮紙闈炲繀濉級',
+        maxlength: 255,
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'paymentDate',
+      label: '浠樻鏃ユ湡',
+      component: 'DatePicker',
+      componentProps: {
+        placeholder: '璇烽�夋嫨浠樻鏃ユ湡',
+        showTime: false,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD HH:mm:ss',
+      },
+      rules: 'required',
+      help: (values: {
+        orderTime?: Date | string;
+        paymentDate?: Date | string;
+      }) => {
+        const tip = getOverdueTip(values.orderTime, values.paymentDate);
+        return tip ? `鈿� ${tip}锛岃纭浠樻璁″垝` : '';
+      },
+    },
+    {
+      fieldName: 'paymentMethod',
+      label: '浠樻鏂瑰紡',
+      component: 'Select',
+      componentProps: {
+        placeholder: '璇烽�夋嫨浠樻鏂瑰紡',
+        allowClear: true,
+        options: getDictOptions(DICT_TYPE.ERP_PAYMENT_METHOD, 'number'),
+      },
+    },
+    {
+      fieldName: 'sourceId',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'sourceNo',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'sourceType',
+      label: '鏉ユ簮绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        placeholder: '璇烽�夋嫨鏉ユ簮绫诲瀷',
+        allowClear: true,
+        options: [
+          { label: '鏃犳潵婧�', value: PurchaseSourceTypeEnum.NONE },
+          { label: '鐢熶骇宸ュ崟', value: PurchaseSourceTypeEnum.WORK_ORDER },
+          { label: '閿�鍞鍗�', value: PurchaseSourceTypeEnum.SALE_ORDER },
+        ],
+        onChange: (value: number | undefined) =>
+          handlers?.onSourceTypeChange?.(value),
+      },
+    },
+    {
+      fieldName: 'sourceWorkOrderId',
+      label: '鐢熶骇宸ュ崟',
+      component: markRaw(ProWorkOrderSelect),
+      componentProps: {
+        placeholder: '璇烽�夋嫨鐢熶骇宸ュ崟',
+        onChange: (item: any) =>
+          handlers?.onSourceOrderChange?.(PurchaseSourceTypeEnum.WORK_ORDER, item),
+      },
+      dependencies: {
+        triggerFields: ['sourceType'],
+        show: (values) =>
+          values.sourceType === PurchaseSourceTypeEnum.WORK_ORDER,
+      },
+    },
+    {
+      fieldName: 'sourceSaleOrderId',
+      label: '閿�鍞鍗�',
+      component: markRaw(ErpSaleOrderSelect),
+      componentProps: {
+        placeholder: '璇烽�夋嫨閿�鍞鍗�',
+        onChange: (item: any) =>
+          handlers?.onSourceOrderChange?.(PurchaseSourceTypeEnum.SALE_ORDER, item),
+      },
+      dependencies: {
+        triggerFields: ['sourceType'],
+        show: (values) =>
+          values.sourceType === PurchaseSourceTypeEnum.SALE_ORDER,
+      },
     },
     {
       component: 'InputNumber',
@@ -184,6 +325,12 @@
       slots: { default: 'productId' },
     },
     {
+      field: 'productCode',
+      title: '浜у搧缂栧彿',
+      minWidth: 140,
+      showOverflow: 'tooltip',
+    },
+    {
       field: 'productUnitName',
       title: '鍗曚綅',
       minWidth: 80,
@@ -291,6 +438,44 @@
       },
     },
     {
+      fieldName: 'purchaseType',
+      label: '閲囪喘绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ERP_PURCHASE_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨閲囪喘绫诲瀷',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'contractNo',
+      label: '鍚堝悓鍙�',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ悎鍚屽彿',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'paymentMethod',
+      label: '浠樻鏂瑰紡',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ERP_PAYMENT_METHOD, 'number'),
+        placeholder: '璇烽�夋嫨浠樻鏂瑰紡',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'paymentDate',
+      label: '浠樻鏃ユ湡',
+      component: 'RangePicker',
+      componentProps: {
+        ...getRangePickerDefaultProps(),
+        allowClear: true,
+      },
+    },
+    {
       fieldName: 'creator',
       label: '鍒涘缓浜�',
       component: 'ApiSelect',
@@ -362,6 +547,12 @@
       minWidth: 120,
     },
     {
+      field: 'productCodes',
+      title: '浜у搧缂栧彿',
+      showOverflow: 'tooltip',
+      minWidth: 140,
+    },
+    {
       field: 'supplierName',
       title: '渚涘簲鍟�',
       minWidth: 120,
@@ -373,6 +564,36 @@
       formatter: 'formatDate',
     },
     {
+      field: 'purchaseType',
+      title: '閲囪喘绫诲瀷',
+      minWidth: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ERP_PURCHASE_TYPE },
+      },
+    },
+    {
+      field: 'contractNo',
+      title: '鍚堝悓鍙�',
+      minWidth: 140,
+      showOverflow: 'tooltip',
+    },
+    {
+      field: 'paymentDate',
+      title: '浠樻鏃ユ湡',
+      width: 140,
+      slots: { default: 'paymentDate' },
+    },
+    {
+      field: 'paymentMethod',
+      title: '浠樻鏂瑰紡',
+      minWidth: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ERP_PAYMENT_METHOD },
+      },
+    },
+    {
       field: 'creatorName',
       title: '鍒涘缓浜�',
       minWidth: 120,

--
Gitblit v1.9.3