feat: add unused records block

This commit is contained in:
sealday 2024-03-20 18:23:30 +08:00
parent 7813ace40c
commit bc2544ed34
11 changed files with 99 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { useRecord } from '@nocobase/client';
import React, { createContext, useContext, useState } from 'react';
import { SettlementStyleContext } from '../schema-initializer/SettlementStyleSwitchActionInitializer';
import { SettlementStyleContext } from '../schema-initializer/actions/SettlementStyleSwitchActionInitializer';
export const PdfIsDoubleContext = createContext({
isDouble: null,

View File

@ -10,7 +10,7 @@ import { RecordFeeConvertedAmount } from './custom-components/RecordFeeConverted
import { ReadFeeConvertedAmount } from './custom-components/RecordFeeConvertedRead';
import { RecordDetails } from './custom-components/RecordDetails';
import { Locale, tval } from './locale';
import { AddToChecklistActionInitializer } from './schema-initializer/AddToChecklistActionInitializer';
import { AddToChecklistActionInitializer } from './schema-initializer/actions/AddToChecklistActionInitializer';
import { useAddToChecklistActionProps } from './hooks/useAddToChecklistActionProps';
import { DetailChecks } from './custom-components/DetailChecks';
import {
@ -18,7 +18,7 @@ import {
PrintCounterAction,
PrintCounterProvider,
usePDFViewerCountablePrintActionProps,
} from './schema-initializer/PDFViewerPrintActionInitializer';
} from './schema-initializer/actions/PDFViewerPrintActionInitializer';
import {
PdfIsDoubleProvider,
useRecordPdfPath,
@ -26,22 +26,23 @@ import {
useWaybillPdfPath,
WaybillsProvider,
} from './hooks/usePdfPath';
import { ColumnSwitchAction, ColumnSwitchActionInitializer } from './schema-initializer/ColumnSwitchActionInitializer';
import { ColumnSwitchAction, ColumnSwitchActionInitializer } from './schema-initializer/actions/ColumnSwitchActionInitializer';
import {
SettlementExcelExportActionInitializer,
useSettlementExcelExportActionProps,
} from './schema-initializer/SettlementExcelExportActionInitializer';
} from './schema-initializer/actions/SettlementExcelExportActionInitializer';
import {
SettlementStyleProvider,
SettlementStyleSwitchAction,
SettlementStyleSwitchActionInitializer,
useSettlementStyleSwitchActionProps,
} from './schema-initializer/SettlementStyleSwitchActionInitializer';
import { RecordPrintSetupActionInitializer, PrintSetup } from './schema-initializer/RecordPrintSetupActionInitializer';
} from './schema-initializer/actions/SettlementStyleSwitchActionInitializer';
import { RecordPrintSetupActionInitializer, PrintSetup } from './schema-initializer/actions/RecordPrintSetupActionInitializer';
import {
RecordPrintSetupMargingTopInitializer,
PrintSetupMargingTop,
} from './schema-initializer/RecordPrintSetupMargingTopInitializer';
} from './schema-initializer/actions/RecordPrintSetupMargingTopInitializer';
import { UnusedRecordsBlockHelper } from './schema-initializer/blocks/UnusedRecordsBlockInitializer';
export class PluginRentalClient extends Plugin {
locale: Locale;
async afterAdd() {}
@ -188,6 +189,9 @@ export class PluginRentalClient extends Plugin {
useSettlementExcelExportActionProps,
useSettlementStyleSwitchActionProps,
});
await new UnusedRecordsBlockHelper(this.app).load();
// FIXME
await this.app.apiClient.resource('link-manage').init({ name: 'DetailCheckPage' });
}

View File

@ -1,6 +1,6 @@
import React from 'react';
import { ActionInitializer } from '@nocobase/client';
import { tval } from '../locale';
import { tval } from '../../locale';
export const AddToChecklistActionInitializer = (props) => {
const schema = {

View File

@ -1,7 +1,7 @@
import React, { useContext, useEffect, useState } from 'react';
import { ActionInitializer, useRequest } from '@nocobase/client';
import { Radio } from 'antd';
import { PdfIsDoubleContext } from '../hooks/usePdfPath';
import { PdfIsDoubleContext } from '../../hooks/usePdfPath';
export const ColumnSwitchAction = (props) => {
const [value, setValue] = useState('0');

View File

@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from 'react';
import { ActionInitializer } from '@nocobase/client';
import { Radio, RadioChangeEvent } from 'antd';
import { useRequest } from '@nocobase/client';
import { PdfIsLoadContext } from '../hooks/usePdfPath';
import { PdfIsLoadContext } from '../../hooks/usePdfPath';
export const PrintSetup = (props) => {
const [value, setValue] = useState('');
const settingsData = useRequest<any>({

View File

@ -2,7 +2,7 @@ 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 { PdfMargingTopContext } from '../../hooks/usePdfPath';
import { debounce } from 'lodash';
import { useCurrentUserContext } from '@nocobase/client';
export const PrintSetupMargingTop = (props) => {

View File

@ -1,9 +1,9 @@
import ExcelJS from 'exceljs';
import { saveAs } from 'file-saver';
import * as QRCode from 'qrcode';
import { RecordCategory, PromptText, Itemcategory, AddItemsCategory } from '../../utils/constants';
import { converDate } from '../../utils/daysUtils';
import { formatPercent } from '../../utils/currencyUtils';
import { RecordCategory, PromptText, Itemcategory, AddItemsCategory } from '../../../utils/constants';
import { converDate } from '../../../utils/daysUtils';
import { formatPercent } from '../../../utils/currencyUtils';
import { message } from 'antd';
export const excelDataHandle = (excelData) => {

View File

@ -0,0 +1,80 @@
import React from 'react';
import {
Application,
SchemaInitializerItem,
SchemaSettings,
SchemaToolbar,
useSchemaInitializer,
useSchemaInitializerItem,
} from '@nocobase/client';
import { useFieldSchema } from '@formily/react';
import { ToolOutlined } from '@ant-design/icons';
export class UnusedRecordsBlockHelper {
constructor(private app: Application) {}
async load() {
this.app.schemaSettingsManager.add(unusedRecordsBlockSettings);
this.app.schemaInitializerManager.get('page:addBlock').add('otherBlocks.unusedRecords', {
name: 'unusedRecords',
title: 'unusedRecords',
Component: UnusedRecordsBlockInitializer.displayName,
});
this.app.addComponents({
UnusedRecordsBlock,
UnusedRecordsBlockInitializer,
UnusedRecordsBlockToolbar,
});
}
}
export const UnusedRecordsBlock: React.FC = () => {
return <div>使</div>;
};
UnusedRecordsBlock.displayName = 'UnusedRecordsBlock';
export const UnusedRecordsBlockInitializer: React.FC = () => {
const { insert } = useSchemaInitializer();
const itemConfig = useSchemaInitializerItem();
return (
<SchemaInitializerItem
{...itemConfig}
icon={<ToolOutlined />}
onClick={() => {
insert({
type: 'void',
'x-toolbar': 'UnusedRecordsBlockToolbar',
'x-settings': 'unusedRecordsBlockSettings',
'x-component': 'CardItem',
properties: {
viewer: {
type: 'void',
'x-component': 'UnusedRecordsBlock',
},
},
});
}}
/>
);
};
UnusedRecordsBlockInitializer.displayName = 'UnusedRecordsBlockInitializer';
export const unusedRecordsBlockSettings = new SchemaSettings({
name: 'unusedRecordsBlockSettings',
items: [
{
name: 'remove',
type: 'remove',
componentProps: {
removeParentsIfNoChildren: true,
},
},
],
});
export const UnusedRecordsBlockToolbar: React.FC = (props) => {
const fieldSchema = useFieldSchema();
return <SchemaToolbar title={fieldSchema.title} settings={fieldSchema['x-settings']} {...props} />;
};
UnusedRecordsBlockToolbar.displayName = 'UnusedRecordsBlockToolbar';