diff --git a/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx b/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx
index 354ba5d7e..8e1d349a4 100644
--- a/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx
+++ b/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx
@@ -12,13 +12,21 @@ export const PdfIsLoadContext = createContext({
setSettingLoad: null,
});
+export const PdfMargingTopContext = createContext({
+ margingTop: 0,
+ setMargingTop: null,
+});
+
export const PdfIsDoubleProvider = (props) => {
const [isDouble, setIsDouble] = useState(false);
const [settingType, setSettingLoad] = useState(false);
+ const [margingTop, setMargingTop] = useState(0);
return (
-
- {props.children}
-
+
+
+ {props.children}
+
+
);
};
@@ -26,7 +34,8 @@ export const useRecordPdfPath = () => {
const record = useRecord();
const { isDouble } = useContext(PdfIsDoubleContext);
const { settingType } = useContext(PdfIsLoadContext);
- return `/records:pdf?recordId=${record.id}&isDouble=${isDouble}&settingType=${settingType}`;
+ const { margingTop } = useContext(PdfMargingTopContext);
+ return `/records:pdf?recordId=${record.id}&isDouble=${isDouble}&settingType=${settingType}&margingTop=${margingTop}`;
};
export const useWaybillPdfPath = () => {
diff --git a/packages/plugins/@hera/plugin-rental/src/client/index.tsx b/packages/plugins/@hera/plugin-rental/src/client/index.tsx
index 59dadf520..398535839 100644
--- a/packages/plugins/@hera/plugin-rental/src/client/index.tsx
+++ b/packages/plugins/@hera/plugin-rental/src/client/index.tsx
@@ -32,7 +32,10 @@ import {
useSettlementStyleSwitchActionProps,
} from './schema-initializer/SettlementStyleSwitchActionInitializer';
import { RecordPrintSetupActionInitializer, PrintSetup } from './schema-initializer/RecordPrintSetupActionInitializer';
-
+import {
+ RecordPrintSetupMargingTopInitializer,
+ PrintSetupMargingTop,
+} from './schema-initializer/RecordPrintSetupMargingTopInitializer';
export class PluginRentalClient extends Plugin {
locale: Locale;
async afterAdd() {}
@@ -69,6 +72,11 @@ export class PluginRentalClient extends Plugin {
title: '{{t("Record print setup")}}',
component: 'RecordPrintSetupActionInitializer',
});
+ this.app.schemaInitializerManager.addItem('PDFViewActionInitializer', 'enbaleActions.recordPrintMargingTop', {
+ type: 'item',
+ title: '{{t("Record print margingtop")}}',
+ component: 'RecordPrintSetupMargingTopInitializer',
+ });
this.app.schemaInitializerManager.addItem('PDFViewActionInitializer', 'enbaleActions.settlementExcelExport', {
type: 'item',
title: '{{t("Settlement excel export")}}',
@@ -134,7 +142,9 @@ export class PluginRentalClient extends Plugin {
SettlementStyleSwitchActionInitializer,
SettlementStyleSwitchAction,
RecordPrintSetupActionInitializer,
+ RecordPrintSetupMargingTopInitializer,
PrintSetup,
+ PrintSetupMargingTop,
});
this.app.addScopes({
useAddToChecklistActionProps,
diff --git a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/RecordPrintSetupMargingTopInitializer.tsx b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/RecordPrintSetupMargingTopInitializer.tsx
new file mode 100644
index 000000000..e303bffaa
--- /dev/null
+++ b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/RecordPrintSetupMargingTopInitializer.tsx
@@ -0,0 +1,65 @@
+import React, { useContext, useEffect, useState } from 'react';
+import { ActionInitializer, useAPIClient } from '@nocobase/client';
+import { Input } from 'antd';
+import { useRequest } from '@nocobase/client';
+import { PdfMargingTopContext } from '../hooks/usePdfPath';
+import { debounce } from 'lodash';
+import { useCurrentUserContext } from '@nocobase/client';
+export const PrintSetupMargingTop = (props) => {
+ const { data } = useCurrentUserContext();
+ const userId = data.data?.id;
+ const api = useAPIClient();
+ const [value, setValue] = useState('0');
+ const { setMargingTop } = useContext(PdfMargingTopContext);
+ const users = useRequest({
+ resource: 'users',
+ action: 'get',
+ params: {
+ filter: {
+ id: userId,
+ },
+ },
+ });
+ useEffect(() => {
+ if (!users.loading) {
+ setValue(users.data.data?.pdf_top_margin || 0);
+ }
+ }, [users.loading]);
+
+ const change = debounce(async (v) => {
+ await api.resource('users').update({
+ filterByTk: userId,
+ filter: {
+ id: userId,
+ },
+ values: {
+ pdf_top_margin: Number(v),
+ },
+ });
+ setMargingTop(v);
+ }, 2000);
+
+ return (
+ {
+ change(e.target.value);
+ setValue(e.target.value);
+ }}
+ />
+ );
+};
+
+export const RecordPrintSetupMargingTopInitializer = (props) => {
+ const schema = {
+ title: '{{ t("record print setup margingTop") }}',
+ 'x-action': 'printSetupMargingTop',
+ 'x-component': 'PrintSetupMargingTop',
+ 'x-designer': 'Action.Designer',
+ };
+ return ;
+};
diff --git a/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts b/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts
index a192a824c..6a33a371c 100644
--- a/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts
+++ b/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts
@@ -61,7 +61,7 @@ export class RecordPreviewController {
@Action('pdf')
async printPreview(ctx: Context) {
const {
- params: { recordId, isDouble, settingType },
+ params: { recordId, isDouble, settingType, margingTop },
} = ctx.action;
// 拉侧面文字说明
const pdfExplain = await ctx.db.getRepository('basic_configuration').find();
@@ -87,6 +87,14 @@ export class RecordPreviewController {
record.nickname = user?.nickname || '';
record.userPhone = user?.phone || '';
record.pdfExplain = pdfExplain[0]?.out_of_storage_explain;
+ if (Number(margingTop)) {
+ record.margingTop = Number(margingTop);
+ } else {
+ // 查询当前用户信息
+ const currentUser = await ctx.db.getRepository('users').findOne({ filter: { id: ctx.state.currentUser.id } });
+ record.margingTop = Number(currentUser?.pdf_top_margin) || 0;
+ }
+
// 费用数据
const feeData = await ctx.db.sequelize.query(this.sqlLoader.sqlFiles['pdf_record_fee'], {
replacements: {
diff --git a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx
index 5bf5111a4..581e0d4c0 100644
--- a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx
+++ b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx
@@ -304,7 +304,7 @@ const PreviewDocument = ({
}
return (
-
+
{recordsName}
{detail.category === RecordCategory.inventory ? '盘点' : outOfStorage}单