Commit 2c0ea4bc authored by Bill's avatar Bill
parents bea1dac7 9f50820b
import { useIntl } from 'umi';
import React, { Fragment, useCallback, useMemo, useState } from 'react';
import { Badge, Button, Tag, Typography, Image } from 'antd';
import { Badge, Button, Tag, Typography, Image, Space } from 'antd';
import { history } from 'umi';
import { Context } from '@/pages/transaction/components/detailLayout/components/context';
import PeripheralLayout from '@/pages/transaction/components/detailLayout';
......@@ -29,6 +29,12 @@ import { postManageWebShopWebAll } from '@/services/ManageV2Api';
import { GlobalConfig } from '@/global/config';
const { onFormMount$ } = FormEffectHooks;
/** 订单 */
const ORDER_TYPE = 1;
/** 退货订单 */
const REFUND_TYPE = 2;
const DetialLayout = () => {
const intl = useIntl();
const { query: { id } } = history.location;
......@@ -45,6 +51,7 @@ const DetialLayout = () => {
const [collocation, setCollocation] = useState<any[]>([]);
const [listModalVisible, setListModalVisible] = useState<boolean>(false);
const [tableModalVisible, setTableModalVisible] = useState<boolean>(false);
const [idata, setIdata] = useState<any[]>([]);
const [param, setParam] = useState<any>({});
......@@ -236,6 +243,21 @@ const DetialLayout = () => {
return taxText
}
const hasQuantity = (DATA: any[], name?: string) => {
let buy_no = 0;
let refund_no = 0;
if (!isEmpty(DATA)) {
DATA.forEach(item => {
if (item.recordType === ORDER_TYPE) {
buy_no += item[name]
} else if (item.recordType === REFUND_TYPE) {
refund_no += item[name]
}
})
}
return buy_no - refund_no
}
const tableModalColumns: ColumnType<any>[] = [
{
title: '单据号',
......@@ -261,7 +283,7 @@ const DetialLayout = () => {
{
title: '客户名称',
key: 'memberName',
dataIndex: 'memberName'
dataIndex: 'memberName',
},
{
title: '单据时间',
......@@ -281,24 +303,36 @@ const DetialLayout = () => {
render: (text, record) => `${isHasTax(text)} / ${record.taxRate}%`
},
{
title: '购买数量',
title: <Space direction='vertical' size={0}>
<Typography.Text>购买数量</Typography.Text>
<Typography.Text type='secondary'>{hasQuantity(idata, 'quantity')}</Typography.Text>
</Space>,
key: 'quantity',
dataIndex: 'quantity'
},
{
title: '应付金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>应付金额</Typography.Text>
<Typography.Text type='secondary'>{Number(hasQuantity(idata, 'skuPrice')).toFixed(2)}</Typography.Text>
</Space>,
key: 'skuPrice',
dataIndex: 'skuPrice',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '实付金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>实付金额</Typography.Text>
<Typography.Text type='secondary'>{Number(hasQuantity(idata, 'amount')).toFixed(2)}</Typography.Text>
</Space>,
key: 'amount',
dataIndex: 'amount',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '优惠金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>优惠金额</Typography.Text>
<Typography.Text type='secondary'>{(Number(hasQuantity(idata, 'skuPrice')) - Number(hasQuantity(idata, 'amount'))).toFixed(2)}</Typography.Text>
</Space>,
key: 'discountPrice',
dataIndex: 'discountPrice',
render: (_text, record) => `¥${(record.skuPrice - record.amount).toFixed(2)}`
......@@ -310,6 +344,7 @@ const DetialLayout = () => {
if (!Array.isArray(fetch)) {
getMarketingAbilityActivityExecutePlatformDetailGoodsExecuteDetailPage({ ...params, ...param }).then(res => {
resolve(res.data)
setIdata(res.data.data)
}).catch(error => {
console.warn(error)
})
......
import { useIntl } from 'umi';
import React, { Fragment, useCallback, useMemo, useState } from 'react';
import { Badge, Button, Typography, Image } from 'antd';
import { Badge, Button, Typography, Image, Space } from 'antd';
import { history } from 'umi';
import { Context } from '@/pages/transaction/components/detailLayout/components/context';
import PeripheralLayout from '@/pages/transaction/components/detailLayout';
......@@ -29,6 +29,12 @@ import { postManageWebShopWebAll } from '@/services/ManageV2Api';
import { GlobalConfig } from '@/global/config';
const { onFormMount$ } = FormEffectHooks;
/** 订单 */
const ORDER_TYPE = 1;
/** 退货订单 */
const REFUND_TYPE = 2;
const DetialLayout = () => {
const intl = useIntl();
const { query: { id } } = history.location;
......@@ -45,6 +51,7 @@ const DetialLayout = () => {
const [collocation, setCollocation] = useState<any[]>([]);
const [listModalVisible, setListModalVisible] = useState<boolean>(false);
const [tableModalVisible, setTableModalVisible] = useState<boolean>(false);
const [idata, setIdata] = useState<any[]>([]);
const [param, setParam] = useState<any>({});
......@@ -234,6 +241,22 @@ const DetialLayout = () => {
return taxText
}
const hasQuantity = (DATA: any[], name?: string) => {
let buy_no = 0;
let refund_no = 0;
if (!isEmpty(DATA)) {
DATA.forEach(item => {
if (item.recordType === ORDER_TYPE) {
buy_no += item[name]
} else if (item.recordType === REFUND_TYPE) {
refund_no += item[name]
}
})
}
return buy_no - refund_no
}
const tableModalColumns: ColumnType<any>[] = [
{
title: '单据号',
......@@ -279,24 +302,36 @@ const DetialLayout = () => {
render: (text, record) => `${isHasTax(text)} / ${record.taxRate}%`
},
{
title: '购买数量',
title: <Space direction='vertical' size={0}>
<Typography.Text>购买数量</Typography.Text>
<Typography.Text type='secondary'>{hasQuantity(idata, 'quantity')}</Typography.Text>
</Space>,
key: 'quantity',
dataIndex: 'quantity'
},
{
title: '应付金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>应付金额</Typography.Text>
<Typography.Text type='secondary'>{Number(hasQuantity(idata, 'skuPrice')).toFixed(2)}</Typography.Text>
</Space>,
key: 'skuPrice',
dataIndex: 'skuPrice',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '实付金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>实付金额</Typography.Text>
<Typography.Text type='secondary'>{Number(hasQuantity(idata, 'amount')).toFixed(2)}</Typography.Text>
</Space>,
key: 'amount',
dataIndex: 'amount',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '优惠金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>优惠金额</Typography.Text>
<Typography.Text type='secondary'>{(Number(hasQuantity(idata, 'skuPrice')) - Number(hasQuantity(idata, 'amount'))).toFixed(2)}</Typography.Text>
</Space>,
key: 'discountPrice',
dataIndex: 'discountPrice',
render: (_text, record) => `¥${(record.skuPrice - record.amount).toFixed(2)}`
......@@ -308,6 +343,7 @@ const DetialLayout = () => {
if (!Array.isArray(fetch)) {
getMarketingAbilityActivityExecuteMerchantDetailGoodsExecuteDetailPage({ ...params, ...param }).then(res => {
resolve(res.data)
setIdata(res.data.data)
}).catch(error => {
console.warn(error)
})
......
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