import React, { useState } from 'react'; import { Button, Modal, Alert, Descriptions, Tabs } from 'antd'; import { PlusCircleOutlined } from '@ant-design/icons'; import Styles from './web.pc.module.less'; import Upsert from '../upsert'; import WpProductConfig from '../../wpProduct/config'; import { OakAttrNotNullException, OakException } from 'oak-domain/lib/types'; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; import { ToYuan } from 'oak-domain/lib/utils/money'; export function WpAccount(props) { const { data: account, t, onUpdate, onRemove, systemId } = props; const { refundGapDays, mchId, enabled, price, taxLossRatio, refundCompensateRatio, allowWithdrawTransfer, withdrawTransferLossRatio, needReceiving } = account; const [activeKey, setActiveKey] = useState("1"); const D = ( {mchId} {ToYuan(price)}{t('common::pay.scale')} {taxLossRatio}% {refundCompensateRatio}% {refundGapDays} {t(`common::${!!allowWithdrawTransfer}`)} {withdrawTransferLossRatio}% {t(`common::${enabled}`)} ); if (onUpdate) { return ( { setActiveKey(activeKey); }} tabBarExtraContent={activeKey === "1" && <> {onUpdate && } {onRemove && } } style={{ width: 380, height: 520 }} items={[ { key: '1', label: t('common::action.detail'), children: D, }, { key: '2', label: t('wpProduct:name'), children: () } ]}/>); } return D; } export default function render(props) { const { accounts, oakFullpath, oakExecutable, canCreate, systemId } = props.data; const { t, addItem, execute, clean } = props.methods; const getNotNullMessage = (entity, attr) => { return t('notnull', { value: t(`${entity}:attr.${attr}`) }); }; const errMsg = oakExecutable instanceof OakException && (oakExecutable instanceof OakAttrNotNullException ? getNotNullMessage(oakExecutable.getEntity(), oakExecutable.getAttributes()[0]) : t(oakExecutable.message)); const [upsertId, setUpsertId] = useState(''); const U = ( { clean(); setUpsertId(''); }} closeIcon={null} onOk={async () => { await execute(); setUpsertId(''); }} okButtonProps={{ disabled: oakExecutable !== true, }} okText={t('common::confirm')} cancelText={(t('common::action.cancel'))}>
{errMsg && }
); if (accounts && accounts?.length) { return (
{U}
{accounts.filter(ele => ele.$$createAt$$ > 1).map((ele, idx) =>
{ Modal.confirm({ title: t('confirmDelete'), content: t('areYouSure'), onOk: async () => execute(undefined, undefined, undefined, [ { entity: 'wpAccount', operation: { id: await generateNewIdAsync(), action: 'remove', data: {}, filter: { id: ele.id, }, } } ]), }); } : undefined} onUpdate={ele['#oakLegalActions']?.includes('update') ? () => setUpsertId(ele.id) : undefined}/>
)}
{canCreate && }
); } return (
{U}
{canCreate ? { const id = addItem({ systemId }); setUpsertId(id); }}/> : t('noData')}
); }