From 965a568c02c1450a65c8d19834a02a07e6f8ce4c Mon Sep 17 00:00:00 2001 From: "bai.jingfeng" Date: Sun, 7 Apr 2024 18:16:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=8D=E5=88=B6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/client/DuplicateAction.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-action-duplicate/src/client/DuplicateAction.tsx b/packages/plugins/@nocobase/plugin-action-duplicate/src/client/DuplicateAction.tsx index 020602f0d..238999007 100644 --- a/packages/plugins/@nocobase/plugin-action-duplicate/src/client/DuplicateAction.tsx +++ b/packages/plugins/@nocobase/plugin-action-duplicate/src/client/DuplicateAction.tsx @@ -4,9 +4,7 @@ import { ActionContextProvider, CollectionProvider_deprecated, RecordProvider, - CollectionProvider, FormBlockContext, - CollectionRecordProvider, fetchTemplateData, useAPIClient, useActionContext, @@ -17,7 +15,7 @@ import { useFormBlockContext, useCollectionParentRecordData, useRecord, - useCollectionRecord, + useCollection, } from '@nocobase/client'; import { App, Button } from 'antd'; import React, { useState } from 'react'; @@ -78,16 +76,21 @@ export const DuplicateAction = observer( const { duplicateFields, duplicateMode = 'quickDulicate', duplicateCollection } = fieldSchema['x-component-props']; const record = useRecord(); const parentRecordData = useCollectionParentRecordData(); - const { id, __collection } = record; + const { __collection } = record; const ctx = useActionContext(); const { name } = useCollection_deprecated(); const { getCollectionFields } = useCollectionManager_deprecated(); const { t } = useTranslation(); const collectionFields = getCollectionFields(__collection || name); const formctx = useFormBlockContext(); + + // 获取当前数据表的主键 + const collection = useCollection(); + const primaryKey = collection?.getPrimaryKey(); + const template = { key: 'duplicate', - dataId: id, + dataId: record[primaryKey], default: true, fields: duplicateFields?.filter((v) => {