feat: add unused records block
This commit is contained in:
parent
7813ace40c
commit
bc2544ed34
@ -1,6 +1,6 @@
|
|||||||
import { useRecord } from '@nocobase/client';
|
import { useRecord } from '@nocobase/client';
|
||||||
import React, { createContext, useContext, useState } from 'react';
|
import React, { createContext, useContext, useState } from 'react';
|
||||||
import { SettlementStyleContext } from '../schema-initializer/SettlementStyleSwitchActionInitializer';
|
import { SettlementStyleContext } from '../schema-initializer/actions/SettlementStyleSwitchActionInitializer';
|
||||||
|
|
||||||
export const PdfIsDoubleContext = createContext({
|
export const PdfIsDoubleContext = createContext({
|
||||||
isDouble: null,
|
isDouble: null,
|
||||||
|
@ -10,7 +10,7 @@ import { RecordFeeConvertedAmount } from './custom-components/RecordFeeConverted
|
|||||||
import { ReadFeeConvertedAmount } from './custom-components/RecordFeeConvertedRead';
|
import { ReadFeeConvertedAmount } from './custom-components/RecordFeeConvertedRead';
|
||||||
import { RecordDetails } from './custom-components/RecordDetails';
|
import { RecordDetails } from './custom-components/RecordDetails';
|
||||||
import { Locale, tval } from './locale';
|
import { Locale, tval } from './locale';
|
||||||
import { AddToChecklistActionInitializer } from './schema-initializer/AddToChecklistActionInitializer';
|
import { AddToChecklistActionInitializer } from './schema-initializer/actions/AddToChecklistActionInitializer';
|
||||||
import { useAddToChecklistActionProps } from './hooks/useAddToChecklistActionProps';
|
import { useAddToChecklistActionProps } from './hooks/useAddToChecklistActionProps';
|
||||||
import { DetailChecks } from './custom-components/DetailChecks';
|
import { DetailChecks } from './custom-components/DetailChecks';
|
||||||
import {
|
import {
|
||||||
@ -18,7 +18,7 @@ import {
|
|||||||
PrintCounterAction,
|
PrintCounterAction,
|
||||||
PrintCounterProvider,
|
PrintCounterProvider,
|
||||||
usePDFViewerCountablePrintActionProps,
|
usePDFViewerCountablePrintActionProps,
|
||||||
} from './schema-initializer/PDFViewerPrintActionInitializer';
|
} from './schema-initializer/actions/PDFViewerPrintActionInitializer';
|
||||||
import {
|
import {
|
||||||
PdfIsDoubleProvider,
|
PdfIsDoubleProvider,
|
||||||
useRecordPdfPath,
|
useRecordPdfPath,
|
||||||
@ -26,22 +26,23 @@ import {
|
|||||||
useWaybillPdfPath,
|
useWaybillPdfPath,
|
||||||
WaybillsProvider,
|
WaybillsProvider,
|
||||||
} from './hooks/usePdfPath';
|
} from './hooks/usePdfPath';
|
||||||
import { ColumnSwitchAction, ColumnSwitchActionInitializer } from './schema-initializer/ColumnSwitchActionInitializer';
|
import { ColumnSwitchAction, ColumnSwitchActionInitializer } from './schema-initializer/actions/ColumnSwitchActionInitializer';
|
||||||
import {
|
import {
|
||||||
SettlementExcelExportActionInitializer,
|
SettlementExcelExportActionInitializer,
|
||||||
useSettlementExcelExportActionProps,
|
useSettlementExcelExportActionProps,
|
||||||
} from './schema-initializer/SettlementExcelExportActionInitializer';
|
} from './schema-initializer/actions/SettlementExcelExportActionInitializer';
|
||||||
import {
|
import {
|
||||||
SettlementStyleProvider,
|
SettlementStyleProvider,
|
||||||
SettlementStyleSwitchAction,
|
SettlementStyleSwitchAction,
|
||||||
SettlementStyleSwitchActionInitializer,
|
SettlementStyleSwitchActionInitializer,
|
||||||
useSettlementStyleSwitchActionProps,
|
useSettlementStyleSwitchActionProps,
|
||||||
} from './schema-initializer/SettlementStyleSwitchActionInitializer';
|
} from './schema-initializer/actions/SettlementStyleSwitchActionInitializer';
|
||||||
import { RecordPrintSetupActionInitializer, PrintSetup } from './schema-initializer/RecordPrintSetupActionInitializer';
|
import { RecordPrintSetupActionInitializer, PrintSetup } from './schema-initializer/actions/RecordPrintSetupActionInitializer';
|
||||||
import {
|
import {
|
||||||
RecordPrintSetupMargingTopInitializer,
|
RecordPrintSetupMargingTopInitializer,
|
||||||
PrintSetupMargingTop,
|
PrintSetupMargingTop,
|
||||||
} from './schema-initializer/RecordPrintSetupMargingTopInitializer';
|
} from './schema-initializer/actions/RecordPrintSetupMargingTopInitializer';
|
||||||
|
import { UnusedRecordsBlockHelper } from './schema-initializer/blocks/UnusedRecordsBlockInitializer';
|
||||||
export class PluginRentalClient extends Plugin {
|
export class PluginRentalClient extends Plugin {
|
||||||
locale: Locale;
|
locale: Locale;
|
||||||
async afterAdd() {}
|
async afterAdd() {}
|
||||||
@ -188,6 +189,9 @@ export class PluginRentalClient extends Plugin {
|
|||||||
useSettlementExcelExportActionProps,
|
useSettlementExcelExportActionProps,
|
||||||
useSettlementStyleSwitchActionProps,
|
useSettlementStyleSwitchActionProps,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await new UnusedRecordsBlockHelper(this.app).load();
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
await this.app.apiClient.resource('link-manage').init({ name: 'DetailCheckPage' });
|
await this.app.apiClient.resource('link-manage').init({ name: 'DetailCheckPage' });
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ActionInitializer } from '@nocobase/client';
|
import { ActionInitializer } from '@nocobase/client';
|
||||||
import { tval } from '../locale';
|
import { tval } from '../../locale';
|
||||||
|
|
||||||
export const AddToChecklistActionInitializer = (props) => {
|
export const AddToChecklistActionInitializer = (props) => {
|
||||||
const schema = {
|
const schema = {
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import { ActionInitializer, useRequest } from '@nocobase/client';
|
import { ActionInitializer, useRequest } from '@nocobase/client';
|
||||||
import { Radio } from 'antd';
|
import { Radio } from 'antd';
|
||||||
import { PdfIsDoubleContext } from '../hooks/usePdfPath';
|
import { PdfIsDoubleContext } from '../../hooks/usePdfPath';
|
||||||
|
|
||||||
export const ColumnSwitchAction = (props) => {
|
export const ColumnSwitchAction = (props) => {
|
||||||
const [value, setValue] = useState('0');
|
const [value, setValue] = useState('0');
|
@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from 'react';
|
|||||||
import { ActionInitializer } from '@nocobase/client';
|
import { ActionInitializer } from '@nocobase/client';
|
||||||
import { Radio, RadioChangeEvent } from 'antd';
|
import { Radio, RadioChangeEvent } from 'antd';
|
||||||
import { useRequest } from '@nocobase/client';
|
import { useRequest } from '@nocobase/client';
|
||||||
import { PdfIsLoadContext } from '../hooks/usePdfPath';
|
import { PdfIsLoadContext } from '../../hooks/usePdfPath';
|
||||||
export const PrintSetup = (props) => {
|
export const PrintSetup = (props) => {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
const settingsData = useRequest<any>({
|
const settingsData = useRequest<any>({
|
@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from 'react';
|
|||||||
import { ActionInitializer, useAPIClient } from '@nocobase/client';
|
import { ActionInitializer, useAPIClient } from '@nocobase/client';
|
||||||
import { Input } from 'antd';
|
import { Input } from 'antd';
|
||||||
import { useRequest } from '@nocobase/client';
|
import { useRequest } from '@nocobase/client';
|
||||||
import { PdfMargingTopContext } from '../hooks/usePdfPath';
|
import { PdfMargingTopContext } from '../../hooks/usePdfPath';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { useCurrentUserContext } from '@nocobase/client';
|
import { useCurrentUserContext } from '@nocobase/client';
|
||||||
export const PrintSetupMargingTop = (props) => {
|
export const PrintSetupMargingTop = (props) => {
|
@ -1,9 +1,9 @@
|
|||||||
import ExcelJS from 'exceljs';
|
import ExcelJS from 'exceljs';
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import * as QRCode from 'qrcode';
|
import * as QRCode from 'qrcode';
|
||||||
import { RecordCategory, PromptText, Itemcategory, AddItemsCategory } from '../../utils/constants';
|
import { RecordCategory, PromptText, Itemcategory, AddItemsCategory } from '../../../utils/constants';
|
||||||
import { converDate } from '../../utils/daysUtils';
|
import { converDate } from '../../../utils/daysUtils';
|
||||||
import { formatPercent } from '../../utils/currencyUtils';
|
import { formatPercent } from '../../../utils/currencyUtils';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
|
|
||||||
export const excelDataHandle = (excelData) => {
|
export const excelDataHandle = (excelData) => {
|
@ -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';
|
Loading…
Reference in New Issue
Block a user