import React, { useState } from 'react';
import { Input, Form, Tag, Modal, Divider } from 'antd';
import Styles from './web.pc.module.less';
import ListPro from 'oak-frontend-base/es/components/listPro';
import { FilterPanel } from '../../../components/AbstractComponents';
import { ToYuan, ThousandCont } from 'oak-domain/lib/utils/money';
import assert from 'assert';
export default function Render(props) {
const { refunds, oakFullpath, oakExecutable, amIRoot } = props.data;
const { t, updateItem, execute, clean, setMessage } = props.methods;
const [upsertId, setUpsertId] = useState('');
const [updateAction, setUpdateAction] = useState('');
if (refunds) {
const upsertRow = upsertId && refunds.find(ele => ele.id === upsertId);
return (
{
return `${t('common::pay.symbol')} ${ThousandCont(ToYuan(row.price), 2)}`;
}
},
{
path: 'loss',
label: t('refund:attr.loss'),
width: 100,
render: (row) => {
return `${t('common::pay.symbol')} ${ThousandCont(ToYuan(row.loss), 2)}`;
}
},
{
path: 'iState',
width: 80,
label: t('refund:attr.iState'),
},
{
path: '$$createAt$$',
label: t('common::$$createAt$$'),
width: 120,
},
{
path: 'creatorName',
label: t('label.cn'),
width: 140,
render: (row) => {
const { creatorName, creatorMobile } = row;
return (
{creatorName}
{creatorMobile}
);
}
},
{
path: 'channel',
width: 100,
label: t('pay:attr.entity'),
render: (row) => {
const { entity, offlineAccount, wpProduct } = row.pay;
const colorDict = {
'account': 'blue',
'offlineAccount': 'red',
'wpProduct': 'green',
};
return (
{t(`payChannel::${entity}`)}
{row.payChannel}
);
}
},
{
path: 'isWithdraw',
label: t('label.isWithdraw'),
type: 'boolean',
width: 90,
render: (row) => {
const { isWithdraw } = row;
return isWithdraw ? t('common::true') : t('common::false');
}
},
{
path: 'externalId',
label: t('refund:attr.externalId'),
width: 120,
},
{
path: 'reason',
label: t('refund:attr.reason'),
width: 200,
}
]} onAction={(row, action) => {
const { entity } = row.pay;
assert(entity !== 'account');
if (entity !== 'offlineAccount' && !amIRoot) {
setMessage({
type: 'error',
title: t('cantOperateOnline'),
content: t('chargePlz'),
});
}
else {
if (action === 'succeed') {
updateItem({}, row.id, 'succeed');
}
else if (action === 'fail') {
updateItem({}, row.id, 'fail');
}
updateItem({}, row.id);
setUpsertId(row.id);
setUpdateAction(action);
}
}} oakPath={oakFullpath}/>
{upsertRow && {
clean();
setUpsertId('');
setUpdateAction('');
}} onOk={async () => {
await execute();
clean();
setUpsertId('');
setUpdateAction('');
}} destroyOnClose closeIcon={null} okText={t('common::confirm')} cancelText={t('common::action.cancel')} okButtonProps={{
disabled: oakExecutable !== true,
}}>
{t('pay:name') + t('info')}
{upsertRow.pay.offlineAccount?.channel && (
)}
{upsertRow.pay.offlineAccount?.name && (
)}
{t('refund:name') + t('info')}
{updateAction === 'succeed' && (
{
const { value } = currentTarget;
updateItem({
externalId: value,
}, upsertId);
}}/>
)}
{updateAction === 'fail' && (
{
const { value } = currentTarget;
updateItem({
reason: value,
}, upsertId);
}}/>
)}
}
);
}
return null;
}