Commit b2093cd1 authored by XieZhiXiong's avatar XieZhiXiong

对接中

parent b33b882a
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { import {
Row, Row,
Col, Col,
...@@ -16,7 +16,7 @@ import { Pie } from '@/components/Charts'; ...@@ -16,7 +16,7 @@ import { Pie } from '@/components/Charts';
import StatusTag from '@/components/StatusTag'; import StatusTag from '@/components/StatusTag';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { repaymentModalSchema, uploadVoucherModalSchema } from './schema'; import { repaymentModalSchema, uploadVoucherModalSchema } from './schema';
import TradeRecord, { TradeRecordProps } from '../TradeRecord'; import TradeRecord, { RecordParams, RecordRes } from '../TradeRecord';
import styles from './index.less'; import styles from './index.less';
const repaymentFormActions = createFormActions(); const repaymentFormActions = createFormActions();
...@@ -24,11 +24,11 @@ const uploadVoucherFormActions = createFormActions(); ...@@ -24,11 +24,11 @@ const uploadVoucherFormActions = createFormActions();
const { Option } = Select; const { Option } = Select;
export interface DetailParams { export interface BillDetailParams {
id: string; id: string;
}; };
export interface DetailData { export interface BillDetailData {
/** /**
* 账单名称(格式:yyyyMMdd~yyyyMMdd) * 账单名称(格式:yyyyMMdd~yyyyMMdd)
*/ */
...@@ -63,7 +63,12 @@ export interface DetailData { ...@@ -63,7 +63,12 @@ export interface DetailData {
lastRepayDate: string lastRepayDate: string
}; };
interface IntroduceRowProps extends TradeRecordProps { export interface BillRecordParams extends RecordParams {
creditId: string;
billId: string;
};
interface IntroduceRowProps {
quotaData: { quotaData: {
x: string, x: string,
y: number, y: number,
...@@ -72,20 +77,53 @@ interface IntroduceRowProps extends TradeRecordProps { ...@@ -72,20 +77,53 @@ interface IntroduceRowProps extends TradeRecordProps {
// 时间段下拉框选项 // 时间段下拉框选项
options: { options: {
title: string, title: string,
value: string, value: number,
}[]; }[];
// 剩余的数据
extraData: {
canUseQuota: number, // 可用额度
useQuota: number, // 已用额度
quota: number, // 现有额度
};
// 获取账单账单记录详情 // 获取账单账单记录详情
fetchCreditDetail: (params: DetailParams) => Promise<DetailData>; fetchBillDetail: (params: BillDetailParams) => Promise<BillDetailData>;
// 获取账单记录列表
fetchBillRecordList: (params: BillRecordParams) => Promise<RecordRes>;
}; };
const IntroduceRow: React.FC<IntroduceRowProps> = ({ const IntroduceRow: React.FC<IntroduceRowProps> = ({
quotaData = [], quotaData = [],
fetchRecordList, options,
extraData = {},
fetchBillDetail,
fetchBillRecordList,
}) => { }) => {
const [billId, setBillId] = useState(0);
const [billInfo, setBillInfo] = useState(null);
const [visibleRecord, setVisibleRecord] = useState(false); const [visibleRecord, setVisibleRecord] = useState(false);
const [visibleRepayment, setVisibleRepayment] = useState(false); const [visibleRepayment, setVisibleRepayment] = useState(false);
const [visibleUploadVoucher, setVisibleUploadVoucher] = useState(false); const [visibleUploadVoucher, setVisibleUploadVoucher] = useState(false);
const getBillDetail = id => {
if (fetchBillDetail && id) {
fetchBillDetail({
id: `${id}`,
}).then(res => {
setBillInfo(res);
});
}
};
useEffect(() => {
if (options && options.length) {
const first = options[0];
setBillId(first.value);
getBillDetail(first.value);
}
}, [options]);
const handleRecordCheckboxChange = e => { const handleRecordCheckboxChange = e => {
setVisibleRecord(e.target.checked); setVisibleRecord(e.target.checked);
...@@ -112,6 +150,20 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({ ...@@ -112,6 +150,20 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({
return Promise.reject(); return Promise.reject();
} }
}; };
const getRecordList = params => {
if (fetchBillRecordList && billId) {
return fetchBillRecordList({
billId,
...params,
});
}
};
const handleBillChange = val => {
setBillId(val);
getBillDetail(val);
};
return ( return (
<> <>
...@@ -141,7 +193,7 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({ ...@@ -141,7 +193,7 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({
<div className={styles['statistic-title']}> <div className={styles['statistic-title']}>
<Badge color="#41CC9E" text="剩余可用额度(元):" /> <Badge color="#41CC9E" text="剩余可用额度(元):" />
</div> </div>
<div className={styles['statistic-amount']}>100,000</div> <div className={styles['statistic-amount']}>{extraData?.canUseQuota}</div>
</div> </div>
</Col> </Col>
</Row> </Row>
...@@ -150,20 +202,21 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({ ...@@ -150,20 +202,21 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({
<Row> <Row>
<Col span={12}> <Col span={12}>
<div className={styles.badgeWrap}> <div className={styles.badgeWrap}>
<Badge color="#EF6260" text={(<span className={styles['badgeWrap-title']}>剩余可用额度(元)</span>)} /> <Badge color="#EF6260" text={(<span className={styles['badgeWrap-title']}>已用额度(元):</span>)} />
<span className={styles['badgeWrap-content']}>100,000</span> <span className={styles['badgeWrap-content']}>{extraData?.useQuota}</span>
</div> </div>
</Col> </Col>
<Col span={12}> <Col span={12}>
<div className={styles.badgeWrap}> <div className={styles.badgeWrap}>
<Badge color="#DFE1E6" text={(<span className={styles['badgeWrap-title']}>总额度(元):</span>)} /> <Badge color="#DFE1E6" text={(<span className={styles['badgeWrap-title']}>总额度(元):</span>)} />
<span className={styles['badgeWrap-content']}>200,000</span> <span className={styles['badgeWrap-content']}>{extraData?.quota}</span>
</div> </div>
</Col> </Col>
</Row> </Row>
</div> </div>
</MellowCard> </MellowCard>
</Col> </Col>
<Col span={14}> <Col span={14}>
<MellowCard <MellowCard
title="账单记录" title="账单记录"
...@@ -171,9 +224,14 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({ ...@@ -171,9 +224,14 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({
<div className={styles.recordExtra}> <div className={styles.recordExtra}>
<Space> <Space>
<Checkbox onChange={handleRecordCheckboxChange}>查看交易记录</Checkbox> <Checkbox onChange={handleRecordCheckboxChange}>查看交易记录</Checkbox>
<Select value="1" style={{ width: 256 }}> <Select
<Option value="1">2020/06/11 ~ 2020/07/11</Option> value={billId}
<Option value="2">2020/08/11 ~ 2020/09/11</Option> style={{ width: 256 }}
onChange={handleBillChange}
>
{options.map(item => (
<Option key={item.value} value={item.value}>{item.title}</Option>
))}
</Select> </Select>
</Space> </Space>
</div> </div>
...@@ -194,13 +252,13 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({ ...@@ -194,13 +252,13 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({
<div className={styles['repayment-left']}> <div className={styles['repayment-left']}>
<div className={styles.statistic}> <div className={styles.statistic}>
<div className={styles['statistic-title']}>剩余应还(元):</div> <div className={styles['statistic-title']}>剩余应还(元):</div>
<div className={styles['statistic-amount']}>100,000</div> <div className={styles['statistic-amount']}>{billInfo?.residueRepayQuota}</div>
</div> </div>
<div className={styles['repayment-end']}> <div className={styles['repayment-end']}>
<span className={styles['repayment-time']}> <span className={styles['repayment-time']}>
2020-08-32到期 {billInfo?.expireTime} 到期
</span> </span>
<StatusTag type="danger" title="逾期 3 天" /> <StatusTag type="danger" title={billInfo?.expireDay} />
</div> </div>
</div> </div>
<div className={styles['repayment-right']}> <div className={styles['repayment-right']}>
...@@ -211,29 +269,35 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({ ...@@ -211,29 +269,35 @@ const IntroduceRow: React.FC<IntroduceRowProps> = ({
<Col span={10}> <Col span={10}>
<div className={styles.statistic}> <div className={styles.statistic}>
<div className={styles['statistic-title']}>本期账单(元):</div> <div className={styles['statistic-title']}>本期账单(元):</div>
<div className={styles['statistic-amount']}>100,000</div> <div className={styles['statistic-amount']}>{billInfo?.billQuota}</div>
</div> </div>
</Col> </Col>
</Row> </Row>
<div className={styles.foot}> <div className={styles.foot}>
<Row> <Row>
<Col span={12}> <Col span={8}>
<div className={styles.badgeWrap}>
<Badge color="#EF6260" text={(<span className={styles['badgeWrap-title']}>最后还款日期:</span>)} />
<span className={styles['badgeWrap-content']}>{billInfo?.lastRepayDate}</span>
</div>
</Col>
<Col span={8}>
<div className={styles.badgeWrap}> <div className={styles.badgeWrap}>
<Badge color="#EF6260" text={(<span className={styles['badgeWrap-title']}>剩余可用额度(元)</span>)} /> <Badge color="#DFE1E6" text={(<span className={styles['badgeWrap-title']}>还款周期</span>)} />
<span className={styles['badgeWrap-content']}>100,000</span> <span className={styles['badgeWrap-content']}>{billInfo?.repayPeriod}</span>
</div> </div>
</Col> </Col>
<Col span={12}> <Col span={8}>
<div className={styles.badgeWrap}> <div className={styles.badgeWrap}>
<Badge color="#DFE1E6" text={(<span className={styles['badgeWrap-title']}>总额度(元)</span>)} /> <Badge color="#DFE1E6" text={(<span className={styles['badgeWrap-title']}>账单日期</span>)} />
<span className={styles['badgeWrap-content']}>200,000</span> <span className={styles['badgeWrap-content']}>{billInfo?.billDay}</span>
</div> </div>
</Col> </Col>
</Row> </Row>
</div> </div>
</> </>
) : ( ) : (
<TradeRecord fetchRecordList={fetchRecordList} /> <TradeRecord fetchRecordList={getRecordList} />
)} )}
</MellowCard> </MellowCard>
</Col> </Col>
......
...@@ -70,9 +70,14 @@ export interface RecordItem { ...@@ -70,9 +70,14 @@ export interface RecordItem {
}[] }[]
}; };
export interface RecordRes {
data: RecordItem[];
totalCount: number;
};
export interface TradeRecordProps { export interface TradeRecordProps {
// 获取账单账单记录详情 // 获取账单账单记录详情
fetchRecordList: (params: RecordParams) => Promise<{ data: RecordItem[] , totalCount: number }>; fetchRecordList: (params: RecordParams) => Promise<RecordRes>;
}; };
const TradeRecord: React.FC<TradeRecordProps> = ({ const TradeRecord: React.FC<TradeRecordProps> = ({
......
import React, { Suspense, useEffect, useState } from 'react'; import React, { Suspense, useEffect, useState, useMemo, useCallback } from 'react';
import { import {
PageHeader, PageHeader,
Descriptions, Descriptions,
...@@ -21,6 +21,7 @@ import { ...@@ -21,6 +21,7 @@ import {
MEMBER_STATUS_BADGE_MAP, MEMBER_STATUS_BADGE_MAP,
CREDIT_REPAYMENT_STATUS_TAG_MAP, CREDIT_REPAYMENT_STATUS_TAG_MAP,
} from '../../../constant'; } from '../../../constant';
import { BillDetailParams, BillDetailData, BillRecordParams } from './components/IntroduceRow';
import styles from './index.less'; import styles from './index.less';
const IntroduceRow = React.lazy(() => import('./components/IntroduceRow')); const IntroduceRow = React.lazy(() => import('./components/IntroduceRow'));
...@@ -58,9 +59,24 @@ const QuotaMenageDetail: React.FC = () => { ...@@ -58,9 +59,24 @@ const QuotaMenageDetail: React.FC = () => {
x: '已用额度(元)', x: '已用额度(元)',
y: creditInfo && creditInfo.useQuota ? creditInfo.useQuota : 0, y: creditInfo && creditInfo.useQuota ? creditInfo.useQuota : 0,
}, },
]; ];
const fetchRecordList = (params) => { const fetchBillDetail = (params: BillDetailParams): Promise<BillDetailData> => {
return new Promise((resolve, reject) => {
PublicApi.getPayCreditApplyGetCreditBillDetail(params)
.then(res => {
if (res.code === 1000) {
resolve(res.data);
}
reject();
})
.catch(() => {
reject();
});
});
};
const fetchBillRecordList = (params: BillRecordParams): Promise<any> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
PublicApi.getPayCreditApplyPageCreditTradeRecord({ PublicApi.getPayCreditApplyPageCreditTradeRecord({
creditId: id, creditId: id,
...@@ -76,6 +92,16 @@ const QuotaMenageDetail: React.FC = () => { ...@@ -76,6 +92,16 @@ const QuotaMenageDetail: React.FC = () => {
}); });
}; };
const normalizeOptions = arr => {
if (!arr || !Array.isArray(arr)) {
return [];
}
return arr.map(item => ({
title: item.name,
value: item.id,
}));
};
return ( return (
<Spin spinning={infoLoading}> <Spin spinning={infoLoading}>
<PageHeaderWrapper <PageHeaderWrapper
...@@ -127,7 +153,14 @@ const QuotaMenageDetail: React.FC = () => { ...@@ -127,7 +153,14 @@ const QuotaMenageDetail: React.FC = () => {
<Suspense fallback={null}> <Suspense fallback={null}>
<IntroduceRow <IntroduceRow
quotaData={quotaData} quotaData={quotaData}
fetchRecordList={fetchRecordList} extraData={{
canUseQuota: creditInfo?.canUseQuota,
useQuota: creditInfo?.useQuota,
quota: creditInfo?.quota,
}}
options={normalizeOptions(creditInfo?.billSelectList)}
fetchBillDetail={fetchBillDetail}
fetchBillRecordList={fetchBillRecordList}
/> />
</Suspense> </Suspense>
......
...@@ -42,7 +42,7 @@ const QuotaMenage: React.FC = () => { ...@@ -42,7 +42,7 @@ const QuotaMenage: React.FC = () => {
render: (text, record) => ( render: (text, record) => (
<> <>
{/* 未申请过,并且授信状态为未申请 或者 申请中 */} {/* 未申请过,并且授信状态为未申请 或者 申请中 */}
{!(!record.isHasApply && (record.status === CREDIT_STATUS_NOT_APPLIED || record.status === CREDIT_STATUS_APPLYING)) ? ( {(!record.isHasApply && (record.status === CREDIT_STATUS_NOT_APPLIED || record.status === CREDIT_STATUS_APPLYING)) ? (
text text
) : ( ) : (
<EyePreview <EyePreview
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment