oakExecutable适配,使用this.tryExecute()判断

This commit is contained in:
lxy 2024-12-20 15:38:38 +08:00
parent 4decb22949
commit 711a104c3f
58 changed files with 78 additions and 25 deletions

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { EntityDict } from "../../../oak-app-domain";
export default function Render(props: {
accountOpers: EntityDict['accountOper']['OpSchema'][];

View File

@ -42,6 +42,7 @@ export default OakComponent({
};
}),
canCreate: legalActions?.includes('create'),
oakExecutable: this.tryExecute(),
};
},
actions: ['create', 'update', 'remove'],

View File

@ -1,6 +1,7 @@
import React from 'react';
import { EntityDict } from "../../../oak-app-domain";
import { RowWithActions, WebComponentProps } from "oak-frontend-base";
import { OakException } from 'oak-domain/lib/types';
export declare function OfflineAccount(props: {
data: RowWithActions<EntityDict, 'offlineAccount'> & {
color: string;
@ -16,4 +17,5 @@ export default function render(props: WebComponentProps<EntityDict, 'offlineAcco
})[];
systemId: string;
canCreate?: boolean;
oakExecutable: boolean | OakException<EntityDict>;
}>): React.JSX.Element;

View File

@ -90,7 +90,7 @@ export default function render(props) {
</div>)}
</div>
<div className={Styles.btnBar}>
{canCreate && <Button type="primary" onClick={() => {
{canCreate && <Button type="primary" onClick={() => {
const id = addItem({ systemId });
setUpsertId(id);
}}>

View File

@ -1,2 +1,3 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "offlineAccount", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -1,2 +1,3 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "order", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -2,6 +2,6 @@ import { EntityDict } from "../../../oak-app-domain";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "order", false, {
accountId: string;
accountAvailMax: number;
onSetPays: (pays: Partial<EntityDict["pay"]["CreateSingle"]["data"]>[]) => void;
onSetPays: (pays: Partial<EntityDict['pay']['CreateSingle']['data']>[]) => void;
}>) => React.ReactElement;
export default _default;

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
export default function Info(props: {
price: number;
t: (k: string) => string;

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { PayChannelOption } from "../../../types/Pay";
export default function Render(props: {
data: {

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { PayChannelOption } from "../../../types/Pay";
export default function Render(props: {
data: {

View File

@ -156,6 +156,7 @@ export default OakComponent({
offlines,
notSameApp: data && data.applicationId !== application.id && data.entity !== 'offlineAccount',
priceStr: data?.price && CentToString(data.price, 2),
oakExecutable: this.tryExecute(),
};
},
features: [{

View File

@ -22,6 +22,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
type: string;
offlines?: ColoredOffline[];
offline?: ColoredOffline;
oakExecutable: boolean;
}, {
goBack: () => void;
startPay: () => Promise<void>;

View File

@ -22,6 +22,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
type: string;
offlines?: ColoredOffline[];
offline?: ColoredOffline;
oakExecutable: boolean;
}, {
goBack: () => void;
startPay: () => Promise<void>;

View File

@ -25,7 +25,7 @@ export function RenderOffline(props) {
</Tag>
</Form.Item>,
<Form.Item key="externalId" label={<span className={Styles.bold}>{t('externalId.label')}</span>}>
<Input value={externalId || ''} onChange={({ currentTarget }) => {
<Input value={externalId || ''} onChange={({ currentTarget }) => {
const { value } = currentTarget;
updateExternalId(value);
}} placeholder={t('externalId.help')} disabled={iState !== 'paying'}/>

View File

@ -1,2 +1,3 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "pay", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -10,5 +10,6 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
creatorMobile?: string;
})[];
offlines?: ColoredOffline[];
oakExecutable: boolean;
}>): React.JSX.Element | null;
export {};

View File

@ -1,2 +1,3 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "system", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -23,6 +23,7 @@ export default OakComponent({
operation: operation && operation[0].operation,
system: data,
canUpdate: !!data?.['#oakLegalActions']?.includes('update'),
oakExecutable: this.tryExecute(),
};
},
actions: ['update'],

View File

@ -11,4 +11,5 @@ export default function render(props: WebComponentProps<EntityDict, 'system', fa
operation?: EntityDict['system']['Update'];
serverUrl?: string;
canUpdate?: boolean;
oakExecutable: boolean;
}>): React.JSX.Element | null;

View File

@ -1,2 +1,3 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "refund", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -71,6 +71,7 @@ export default OakComponent({
};
}),
amIRoot: features.token.isRoot(),
oakExecutable: this.tryExecute(),
};
}
});

View File

@ -9,4 +9,5 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
payChannel: string;
})[];
amIRoot?: boolean;
oakExecutable: boolean;
}>): React.JSX.Element | null;

View File

@ -1,2 +1,3 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "withdrawTransfer", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -3,7 +3,7 @@ import { Result, Alert } from 'antd';
import ListPro from 'oak-frontend-base/es/components/listPro';
import { ThousandCont, ToYuan } from 'oak-domain/lib/utils/money';
export default function Render(props) {
const { transfers, oakFullpath, oakExecutable } = props.data;
const { transfers, oakFullpath } = props.data;
const { t } = props.methods;
if (transfers?.length) {
return (<ListPro entity="withdrawTransfer" data={transfers} title={<Alert type="info" message={t('tips')}/>} attributes={[

View File

@ -1,7 +1,7 @@
import { EntityDict } from "../../../oak-app-domain";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, keyof EntityDict, boolean, {
accountId: string;
withdrawAccountFilter: EntityDict["withdrawAccount"]["Selection"]["filter"];
withdrawAccountFilter: import("../../../oak-app-domain/WithdrawAccount/Schema").Filter | undefined;
onNewWithdrawAccount: () => void;
onCreateWithdraw: (id: string) => void;
onGoToHistory: () => void;

View File

@ -1,3 +1,4 @@
/// <reference types="wechat-miniprogram" />
import { EntityDict } from "../../../oak-app-domain";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "withdraw", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -1,6 +1,6 @@
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, keyof EntityDict, boolean, {
withdraw: EntityDict["withdraw"]["Schema"];
withdraw: import("../../../oak-app-domain/Withdraw/Schema").Schema;
create: boolean;
}>) => React.ReactElement;
export default _default;

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { EntityDict } from '../../../oak-app-domain';
export default function render(props: {
data: {

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { EntityDict } from '../../../oak-app-domain';
export default function render(props: {
data: {

View File

@ -49,6 +49,7 @@ export default OakComponent({
}),
asPicker: !!this.props.onPick,
allowCreate: legalActions?.includes('create'),
oakExecutable: this.tryExecute(),
};
},
data: {

View File

@ -16,6 +16,7 @@ export default function render(props: WebComponentProps<EntityDict, 'withdrawAcc
allowCreate?: boolean;
selectedId?: string;
onCancel?: () => void;
oakExecutable: boolean;
}, {
setUpsertId: (id: string) => void;
doUpdate: () => Promise<void>;

View File

@ -16,6 +16,7 @@ export default function render(props: WebComponentProps<EntityDict, 'withdrawAcc
allowCreate?: boolean;
selectedId?: string;
onCancel?: () => void;
oakExecutable: boolean;
}, {
setUpsertId: (id: string) => void;
doUpdate: () => Promise<void>;

View File

@ -1,3 +1,4 @@
/// <reference types="wechat-miniprogram" />
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "withdrawTransfer", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -64,6 +64,7 @@ export default OakComponent({
channel,
};
}),
oakExecutable: this.tryExecute(),
};
},
data: {

View File

@ -11,6 +11,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
})[];
updateId: string;
sysAccountAmount: number;
oakExecutable: boolean;
}, {
setUpdateId: (id: string, action: string) => void;
}>): React.JSX.Element | null;

View File

@ -29,6 +29,7 @@ export default OakComponent({
return {
accounts: data,
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
oakExecutable: this.tryExecute(),
};
},
actions: ['create', 'update', 'remove'],

View File

@ -1,6 +1,7 @@
import React from 'react';
import { EntityDict } from "../../../oak-app-domain";
import { RowWithActions, WebComponentProps } from "oak-frontend-base";
import { OakException } from 'oak-domain/lib/types';
export declare function WpAccount(props: {
data: RowWithActions<EntityDict, 'wpAccount'>;
systemId: string;
@ -12,4 +13,5 @@ export default function render(props: WebComponentProps<EntityDict, 'wpAccount',
accounts?: (RowWithActions<EntityDict, 'wpAccount'> & {})[];
systemId: string;
canCreate?: boolean;
oakExecutable: boolean | OakException<EntityDict>;
}>): React.JSX.Element;

View File

@ -1,9 +1,11 @@
import React from 'react';
import { EntityDict } from "../../../oak-app-domain";
import { RowWithActions, WebComponentProps } from "oak-frontend-base";
import { OakException } from 'oak-domain/lib/types';
export default function render(props: WebComponentProps<EntityDict, 'wpProduct', true, {
wpProducts?: (RowWithActions<EntityDict, 'wpProduct'> & {})[];
systemId: string;
canCreate?: boolean;
wpAccountId: string;
oakExecutable: boolean | OakException<EntityDict>;
}>): React.JSX.Element;

View File

@ -82,7 +82,7 @@ export default function render(props) {
}
]);
}}/>
</List.Item>)}/>
</List.Item>)}/>
</div>);
}
return (<div className={Styles.container2}>

View File

@ -44,6 +44,7 @@ export default OakComponent({
}
),
canCreate: legalActions?.includes('create'),
oakExecutable: this.tryExecute(),
};
},
actions: ['create', 'update', 'remove'],

View File

@ -20,7 +20,7 @@ export function OfflineAccount(props: {
const { data: account, t, onUpdate, onRemove, onQrCodeClick } = props;
const { type, channel, name, qrCode, allowDeposit, allowPay, color, enabled, price,
taxLossRatio, refundCompensateRatio, refundGapDays, allowWithdrawTransfer, withdrawTransferLossRatio
} = account;
} = account;
return (
<Descriptions
@ -70,6 +70,7 @@ export default function render(props: WebComponentProps<EntityDict, 'offlineAcco
accounts?: (RowWithActions<EntityDict, 'offlineAccount'> & { color: string })[];
systemId: string;
canCreate?: boolean;
oakExecutable: boolean | OakException<EntityDict>;
}>) {
const { accounts, oakFullpath, oakExecutable, systemId, canCreate } = props.data;
const { t, addItem, execute, clean } = props.methods;
@ -165,7 +166,7 @@ export default function render(props: WebComponentProps<EntityDict, 'offlineAcco
}
</div>
<div className={Styles.btnBar}>
{canCreate && <Button
{canCreate && <Button
type="primary"
onClick={() => {
const id = addItem({ systemId });
@ -175,13 +176,13 @@ export default function render(props: WebComponentProps<EntityDict, 'offlineAcco
{t('common::action.add')}
</Button>}
</div>
{ showQrCodeRow && <Modal
{showQrCodeRow && <Modal
open={!!showQrCodeId}
closeIcon={null}
footer={null}
onCancel={() => setShowQrCodeId('')}
>
<QRCode value={showQrCodeRow!.qrCode!} size={480} color={showQrCodeRow!.color!}/>
<QRCode value={showQrCodeRow!.qrCode!} size={480} color={showQrCodeRow!.color!} />
</Modal>}
</div>
);
@ -192,7 +193,7 @@ export default function render(props: WebComponentProps<EntityDict, 'offlineAcco
<Alert type='info' message={t('tips')} />
{U}
<div className={Styles.body}>
{ canCreate ? <PlusCircleOutlined
{canCreate ? <PlusCircleOutlined
className={Styles.add}
shape="circle"
style={{ fontSize: 50 }}
@ -200,7 +201,7 @@ export default function render(props: WebComponentProps<EntityDict, 'offlineAcco
const id = addItem({ systemId });
setUpsertId(id);
}}
/> : t('noData') }
/> : t('noData')}
</div>
</div>
)

View File

@ -184,6 +184,7 @@ export default OakComponent({
offlines,
notSameApp: data && data.applicationId !== application!.id && data.entity !== 'offlineAccount',
priceStr: data?.price && CentToString(data!.price!, 2),
oakExecutable: this.tryExecute(),
};
},
features: [{

View File

@ -47,7 +47,7 @@ export function RenderOffline(props: {
key="externalId"
label={<span className={Styles.bold}>{t('externalId.label')}</span>}
>
<Input
<Input
value={externalId || ''}
onChange={({ currentTarget }) => {
const { value } = currentTarget;
@ -55,7 +55,7 @@ export function RenderOffline(props: {
}}
placeholder={t('externalId.help')}
disabled={iState !== 'paying'}
/>
/>
</Form.Item>
];
if (type === 'bank') {
@ -289,6 +289,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
type: string;
offlines?: ColoredOffline[];
offline?: ColoredOffline;
oakExecutable: boolean;
}, {
goBack: () => void;
startPay: () => Promise<void>;

View File

@ -281,6 +281,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
type: string;
offlines?: ColoredOffline[];
offline?: ColoredOffline;
oakExecutable: boolean;
}, {
goBack: () => void;
startPay: () => Promise<void>;

View File

@ -19,6 +19,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
creatorMobile?: string;
})[];
offlines?: ColoredOffline[];
oakExecutable: boolean;
}>) {
const { pays, offlines, oakExecutable, oakFullpath } = props.data;
const { t, execute, updateItem, setMessage, clean } = props.methods;

View File

@ -20,12 +20,13 @@ export default OakComponent({
},
},
formData({ data, features }) {
const operation = this.state.oakFullpath && this.features.runningTree.getOperations(this.state.oakFullpath);
const operation = this.state.oakFullpath && this.features.runningTree.getOperations(this.state.oakFullpath);
return {
operation: operation && operation[0].operation,
system: data,
canUpdate: !!data?.['#oakLegalActions']?.includes('update'),
oakExecutable: this.tryExecute(),
};
},
actions: ['update'],

View File

@ -243,6 +243,7 @@ export default function render(props: WebComponentProps<EntityDict, 'system', fa
operation?: EntityDict['system']['Update'];
serverUrl?: string;
canUpdate?: boolean;
oakExecutable: boolean;
}>) {
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable, canUpdate } = props.data;
const { t, update, clean, execute } = props.methods;
@ -262,7 +263,7 @@ export default function render(props: WebComponentProps<EntityDict, 'system', fa
),
key: 'system',
children: (
<Flex
<Flex
vertical
>
<PayConfig
@ -270,8 +271,8 @@ export default function render(props: WebComponentProps<EntityDict, 'system', fa
update={canUpdate ? (payConfig) => update({ payConfig }) : undefined}
t={t}
/>
<Flex
gap="middle"
<Flex
gap="middle"
justify='end'
>
<Button

View File

@ -70,13 +70,14 @@ export default OakComponent({
...rest,
isWithdraw: !!withdrawId,
payChannel,
pay,
pay,
creatorName: creator?.name || creator?.nickname || '-',
creatorMobile: creator?.mobile$user?.[0]?.mobile || '-',
};
}
),
amIRoot: features.token.isRoot(),
oakExecutable: this.tryExecute(),
};
}
})

View File

@ -18,6 +18,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
payChannel: string;
})[];
amIRoot?: boolean;
oakExecutable: boolean;
}>) {
const { refunds, oakFullpath, oakExecutable, amIRoot } = props.data;
const { t, updateItem, execute, clean, setMessage } = props.methods;

View File

@ -14,7 +14,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
channel: string;
})[];
}>) {
const { transfers, oakFullpath, oakExecutable } = props.data;
const { transfers, oakFullpath } = props.data;
const { t } = props.methods;
if (transfers?.length) {

View File

@ -56,6 +56,7 @@ export default OakComponent({
),
asPicker: !!this.props.onPick,
allowCreate: legalActions?.includes('create'),
oakExecutable: this.tryExecute(),
};
},
data: {

View File

@ -21,6 +21,7 @@ export default function render(props: WebComponentProps<EntityDict, 'withdrawAcc
allowCreate?: boolean;
selectedId?: string;
onCancel?: () => void;
oakExecutable: boolean;
}, {
setUpsertId: (id: string) => void;
doUpdate: () => Promise<void>;
@ -98,10 +99,10 @@ export default function render(props: WebComponentProps<EntityDict, 'withdrawAcc
}
}}
/>] : [
item.allowUpdate &&
<Switch
item.allowUpdate &&
<Switch
checkedChildren={t('default')}
value={item.isDefault}
value={item.isDefault}
onChange={(value) => switchDefault(item.id!)}
/>,
<Button

View File

@ -21,6 +21,7 @@ export default function render(props: WebComponentProps<EntityDict, 'withdrawAcc
allowCreate?: boolean;
selectedId?: string;
onCancel?: () => void;
oakExecutable: boolean;
}, {
setUpsertId: (id: string) => void;
doUpdate: () => Promise<void>;

View File

@ -69,6 +69,7 @@ export default OakComponent({
};
}
),
oakExecutable: this.tryExecute(),
};
},
data: {

View File

@ -20,6 +20,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
})[];
updateId: string;
sysAccountAmount: number;
oakExecutable: boolean;
}, {
setUpdateId: (id: string, action: string) => void;
}>) {

View File

@ -29,6 +29,7 @@ export default OakComponent({
return {
accounts: data,
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
oakExecutable: this.tryExecute(),
};
},
actions: ['create', 'update', 'remove'],

View File

@ -95,6 +95,7 @@ export default function render(props: WebComponentProps<EntityDict, 'wpAccount',
accounts?: (RowWithActions<EntityDict, 'wpAccount'> & {})[];
systemId: string;
canCreate?: boolean;
oakExecutable: boolean | OakException<EntityDict>;
}>) {
const { accounts, oakFullpath, oakExecutable, canCreate, systemId } = props.data;
const { t, addItem, execute, clean } = props.methods;

View File

@ -14,6 +14,7 @@ export default function render(props: WebComponentProps<EntityDict, 'wpProduct',
systemId: string;
canCreate?: boolean;
wpAccountId: string;
oakExecutable: boolean | OakException<EntityDict>;
}>) {
const { wpAccountId, wpProducts, oakFullpath, oakExecutable, canCreate, systemId } = props.data;
const { t, addItem, execute, clean } = props.methods;
@ -141,7 +142,7 @@ export default function render(props: WebComponentProps<EntityDict, 'wpProduct',
/>
</List.Item>
)}
/>
/>
</div>
);
}