From c77086ad2d7949ab36dd0c4e0b59907e672dd64f Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 18 九月 2026 15:04:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev_pro2.0' into dev_宁夏_九泓化工

---
 src/views/erp/purchase/invoice/data.ts |  250 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 250 insertions(+), 0 deletions(-)

diff --git a/src/views/erp/purchase/invoice/data.ts b/src/views/erp/purchase/invoice/data.ts
new file mode 100644
index 0000000..73ff3e0
--- /dev/null
+++ b/src/views/erp/purchase/invoice/data.ts
@@ -0,0 +1,250 @@
+import type { Ref } from 'vue';
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+
+import { getSupplierSimpleList } from '#/api/srm/supplier';
+
+import { z } from '#/adapter/form';
+
+import { markRaw } from 'vue';
+
+import PurchaseOrderSelect from './modules/purchase-order-select.vue';
+
+/** 琛ㄥ崟绫诲瀷 */
+export type FormType = 'create' | 'detail' | 'edit';
+
+/** 鏂板/淇敼鐨勮〃鍗� */
+export function useFormSchema(
+  orderRemainInvoicePrice?: Ref<number | undefined>,
+): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'id',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'no',
+      label: '鏉ョエ缂栧彿',
+      component: 'Input',
+      componentProps: {
+        placeholder: '淇濆瓨鏃惰嚜鍔ㄧ敓鎴�',
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'purchaseOrderId',
+      label: '閲囪喘璁㈠崟',
+      component: markRaw(PurchaseOrderSelect),
+      rules: 'required',
+      dependencies: {
+        triggerFields: ['id'],
+        disabled: (values) => !!values.id,
+      },
+      componentProps: (_values, form) => ({
+        placeholder: '璇烽�夋嫨閲囪喘璁㈠崟',
+        onChange: (
+          order:
+            | { supplierName?: string; remainInvoicePrice?: number }
+            | undefined,
+        ) => {
+          form.setFieldValue('supplierName', order?.supplierName);
+          if (orderRemainInvoicePrice) {
+            orderRemainInvoicePrice.value = order?.remainInvoicePrice;
+          }
+        },
+      }),
+    },
+    {
+      fieldName: 'supplierName',
+      label: '渚涘簲鍟�',
+      component: 'Input',
+      componentProps: {
+        placeholder: '閫夋嫨閲囪喘璁㈠崟鍚庤嚜鍔ㄥ甫鍑�',
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'invoiceNo',
+      label: '鍙戠エ鍙风爜',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ彂绁ㄥ彿鐮�',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'invoiceTitle',
+      label: '鍙戠エ鎶ご',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ彂绁ㄦ姮澶�',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'price',
+      label: '鏉ョエ閲戦锛堝厓锛�',
+      component: 'InputNumber',
+      rules: 'required',
+      description: () =>
+        orderRemainInvoicePrice?.value != null
+          ? `閲囪喘璁㈠崟鏈紑绁ㄩ噾棰濓細${Number(orderRemainInvoicePrice.value).toFixed(2)} 鍏僠
+          : '',
+      componentProps: {
+        class: '!w-full',
+        placeholder: '璇疯緭鍏ユ潵绁ㄩ噾棰�',
+        min: 0,
+        precision: 2,
+      },
+      dependencies: {
+        triggerFields: ['purchaseOrderId'],
+        componentProps: () => ({
+          class: '!w-full',
+          placeholder: '璇疯緭鍏ユ潵绁ㄩ噾棰�',
+          min: 0,
+          max: orderRemainInvoicePrice?.value ?? undefined,
+          precision: 2,
+        }),
+        rules: () => {
+          const max = orderRemainInvoicePrice?.value;
+          if (max != null) {
+            return z
+              .number({ message: '璇疯緭鍏ユ潵绁ㄩ噾棰�' })
+              .min(0, '鏉ョエ閲戦涓嶈兘灏忎簬 0')
+              .max(max, `鏉ョエ閲戦涓嶈兘澶т簬鏈紑绁ㄩ噾棰� ${Number(max).toFixed(2)}`);
+          }
+          return z
+            .number({ message: '璇疯緭鍏ユ潵绁ㄩ噾棰�' })
+            .min(0, '鏉ョエ閲戦涓嶈兘灏忎簬 0');
+        },
+      },
+    },
+    {
+      fieldName: 'invoiceTime',
+      label: '鏉ョエ鏃ユ湡',
+      component: 'DatePicker',
+      rules: 'required',
+      componentProps: {
+        placeholder: '璇烽�夋嫨鏉ョエ鏃ユ湡',
+        showTime: false,
+        valueFormat: 'YYYY-MM-DD',
+        format: 'YYYY-MM-DD',
+      },
+    },
+    {
+      fieldName: 'blobIds',
+      label: '鍙戠エ闄勪欢',
+      component: 'FileUpload',
+      componentProps: {
+        valueKey: 'id',
+        maxNumber: 10,
+        multiple: true,
+        accept: ['jpg', 'jpeg', 'png', 'pdf'],
+        helpText: '鏀寔jpg銆乯peg銆乸ng銆乸df鏍煎紡锛屽崟涓枃浠朵笉瓒呰繃50MB',
+      },
+      formItemClass: 'md:col-span-2',
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ娉�',
+        rows: 4,
+      },
+      formItemClass: 'md:col-span-2',
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'no',
+      label: '鏉ョエ缂栧彿',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ユ潵绁ㄧ紪鍙�',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'supplierId',
+      label: '渚涘簲鍟�',
+      component: 'ApiSelect',
+      componentProps: {
+        placeholder: '璇烽�夋嫨渚涘簲鍟�',
+        allowClear: true,
+        showSearch: true,
+        api: getSupplierSimpleList,
+        labelField: 'name',
+        valueField: 'id',
+      },
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions['columns'] {
+  return [
+    {
+      title: '鏉ョエ缂栧彿',
+      field: 'no',
+      minWidth: 160,
+      fixed: 'left',
+      slots: { default: 'no' },
+    },
+    {
+      title: '渚涘簲鍟�',
+      field: 'supplierName',
+      minWidth: 150,
+    },
+    {
+      title: '閲囪喘璁㈠崟缂栧彿',
+      field: 'order',
+      minWidth: 160,
+      slots: { default: 'orderNo' },
+    },
+    {
+      title: '鍙戠エ鍙风爜',
+      field: 'invoiceNo',
+      minWidth: 150,
+    },
+    {
+      title: '鏉ョエ閲戦锛堝厓锛�',
+      field: 'price',
+      minWidth: 150,
+      formatter: 'formatAmount2',
+    },
+    {
+      title: '鏉ョエ鏃ユ湡',
+      field: 'invoiceTime',
+      minWidth: 150,
+      formatter: 'formatDateTime',
+    },
+    {
+      title: '澶囨敞',
+      field: 'remark',
+      minWidth: 150,
+    },
+    {
+      title: '闄勪欢',
+      field: 'attachmentList',
+      minWidth: 100,
+      fixed: 'right',
+      slots: { default: 'attachment' },
+    },
+    {
+      title: '鎿嶄綔',
+      field: 'actions',
+      minWidth: 200,
+      fixed: 'right',
+      slots: { default: 'actions' },
+    },
+  ];
+}

--
Gitblit v1.9.3