Commit 77795136 authored by Bill's avatar Bill
parents 4c8c25d0 a83947f5
......@@ -34,7 +34,6 @@ interface Iprops {
const RangeTime: React.FC<Iprops> = (props: Iprops) => {
const { containerStyle, rangeTime, onChange, placeholader, shouldGtCurrent, disabled, showTime } = props;
const currentDay = moment();
const endOfUnit = showTime ? 'second' : 'day';
const [innerRangeTime, setInnerRangeTime] = useState<{ [key: string]: Moment | null }>({
startTime: null,
......@@ -50,11 +49,24 @@ const RangeTime: React.FC<Iprops> = (props: Iprops) => {
}, [props.rangeTime]);
const handleChange = (date: Moment | null, dateString: string, mode: "startTime" | "endTime") => {
const reverseMode = mode === 'startTime' ? 'endTime' : 'startTime';
const newObject = {
...innerRangeTime,
[mode]: date,
};
// 对调位置,可以省去很多复杂且不必要的判断
if (date && newObject[reverseMode]) {
if (mode === 'startTime' && date > newObject[reverseMode]!) {
newObject[mode] = newObject[reverseMode];
newObject[reverseMode] = date;
}
if (mode === 'endTime' && date < newObject[reverseMode]!) {
newObject[mode] = newObject[reverseMode];
newObject[reverseMode] = date;
}
}
if (onChange) {
onChange?.([newObject.startTime as unknown as Moment, newObject.endTime as unknown as Moment]);
} else {
......@@ -64,37 +76,39 @@ const RangeTime: React.FC<Iprops> = (props: Iprops) => {
const getDisableDate = useCallback((current: Moment, mode: "startTime" | "endTime") => {
const reverseMode = mode === 'startTime' ? 'endTime' : 'startTime';
const modeTime: Moment | null = innerRangeTime[reverseMode];
const modeTime: Moment | null = moment(innerRangeTime[reverseMode]);
// current 为当前日历上的日期, 如果返回值为true,那么表示当前日期为禁用状态
if(!modeTime) {
if(shouldGtCurrent) {
return current < currentDay.endOf(endOfUnit);
if (!modeTime) {
if (shouldGtCurrent) {
return current < currentDay;
}
return false;
}
if (mode === 'startTime') {
return shouldGtCurrent ? (current < currentDay.endOf(endOfUnit) || current > (modeTime as Moment).endOf(endOfUnit)) : current > (modeTime as Moment).endOf(endOfUnit);
return shouldGtCurrent ? (current < currentDay || current > modeTime.endOf('day')) : current > modeTime.endOf('day');
} else {
//现在的时间要大于开始的时间, true 为禁用
return shouldGtCurrent ? (current < currentDay.endOf(endOfUnit) || current < (modeTime as Moment).endOf(endOfUnit)) : current < (modeTime as Moment).endOf(endOfUnit);
return shouldGtCurrent ? (current < currentDay || current < modeTime) : current < modeTime.endOf('day');
}
}, [innerRangeTime]);
const disabledDateTime = (current: Moment, partial: 'start' | 'end') => {
const { startTime } = innerRangeTime;
const hours = range(0, 24);
const minutes = range(0, 60);
if (partial === 'start') {
return {
disabledHours: () => range(0, 24).splice(0, moment().get('hour')),
disabledMinutes: () => range(0, 60).splice(0, moment().get('minute')),
disabledSeconds: () => range(0, 60).splice(0, moment().get('second')),
disabledHours: () => hours.splice(0, current && current.isSame(currentDay, 'day') ? moment().get('hour') : 0),
disabledMinutes: () => minutes.splice(0, current && current.isSame(currentDay, 'day') ? moment().get('minute') : 0),
disabledSeconds: () => minutes.splice(0, current && current.isSame(currentDay, 'day') ? moment().get('second') : 0),
};
}
if (partial === 'end') {
return {
disabledHours: () => range(0, 24).splice(0, startTime?.get('hour')),
disabledMinutes: () => range(0, 60).splice(0, current && current.isSame(startTime, 'hour') ? startTime?.get('minute') : 0),
disabledSeconds: () => range(0, 60).splice(0, current && current.isSame(startTime, 'hour') && current.isSame(startTime, 'minute') ? (startTime?.get('second') || 0) + 1 : 0),
disabledHours: () => hours.splice(0, startTime?.get('hour')),
disabledMinutes: () => minutes.splice(0, current && current.isSame(startTime, 'hour') ? startTime?.get('minute') : 0),
disabledSeconds: () => minutes.splice(0, current && current.isSame(startTime, 'hour') && current.isSame(startTime, 'minute') ? startTime?.get('second')! + 1 : 0),
};
}
return {};
......
......@@ -53,11 +53,13 @@ interface Iprops {
/** customKey */
customKey?: string,
/** 宽度 */
width?: number
width?: number,
/** 是否可选 */
ctl?: boolean
}
const TableModal: React.FC<Iprops> = (props: Iprops) => {
const { title, visible, schema, columns, effects, tableProps, mode, expressionScope, fetchData, onClose, onOk, value, format, customizeRadio, modalType, footer, customKey, width } = props;
const { title, visible, schema, columns, effects, tableProps, mode, expressionScope, fetchData, onClose, onOk, value, format, customizeRadio, modalType, footer, customKey, width, ctl } = props;
const ref = useRef<any>({});
const [rowSelection, RowCtl] = useRowSelectionTable({ type: customizeRadio && mode === 'radio' ? 'checkbox' : mode, customKey: customKey });
const isFirstLoad = useRef<boolean>(true);
......@@ -112,7 +114,7 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => {
)
}
const otherProps = modalType === 'Drawer' ? { footer: renderFooter() } : { onOk: handleOk }
const otherProps = (modalType === 'Drawer' && ctl) && { footer: renderFooter() }
return (
......@@ -135,7 +137,7 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => {
tableType="small"
fetchTableData={fetchData}
currentRef={ref}
rowSelection={{
rowSelection={ctl && {
...rowSelection,
hideSelectAll: customizeRadio,
}}
......@@ -171,7 +173,8 @@ TableModal.defaultProps = {
customizeRadio: false,
modalType: "Modal",
footer: null,
width: 900
width: 900,
ctl: true,
}
export default TableModal;
......@@ -49,6 +49,7 @@ const DateModalLayout: React.FC<DateModalProps> = (props: any) => {
visible={visible}
onCancel={onCancel}
confirmLoading={loading}
destroyOnClose
onOk={handleSubmit}
>
<Form layout='vertical' form={form}>
......
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 '@/components/DetailLayout/components/context';
import PeripheralLayout from '@/components/DetailLayout';
......@@ -28,6 +28,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 { query: { id } } = history.location;
const format = (text, fmt?: string) => {
......@@ -43,6 +49,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>({});
......@@ -134,7 +141,8 @@ const DetialLayout = () => {
{
title: '实购金额',
key: 'amount',
dataIndex: 'amount'
dataIndex: 'amount',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '操作',
......@@ -193,6 +201,22 @@ const DetialLayout = () => {
dataIndex: 'restrictTotalNum',
},
{
title: '参与客户数',
key: 'customerCount',
dataIndex: 'customerCount'
},
{
title: '实购数量',
key: 'salesNum',
dataIndex: 'salesNum'
},
{
title: '实购金额',
key: 'amount',
dataIndex: 'amount',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
......@@ -215,6 +239,27 @@ const DetialLayout = () => {
}
}, [value])
const isHasTax = (tax: number) => {
const taxText = tax === 1 ? '是' : '否';
return taxText
}
const hasQuantity = (DATA: any[], name?: string, name1?: string) => {
let buy_no = 0;
let refund_no = 0;
if (!isEmpty(DATA)) {
DATA.forEach(item => {
if ((item.recordType === ORDER_TYPE) && name) {
buy_no += Number(item[name])
} else if ((item.recordType === REFUND_TYPE) && name1) {
refund_no += Number(item[name1].toString().split('-')[1])
console.log(typeof item[name1], item[name1])
}
})
}
return buy_no - refund_no
}
const tableModalColumns: ColumnType<any>[] = [
{
title: '单据号',
......@@ -222,7 +267,7 @@ const DetialLayout = () => {
dataIndex: 'orderId',
render: (_text, _r) => (
<>
{_r.recordType === 1 && <Button type='link' target='_blank' onClick={() => history.push(`/orderSystem/list/detail?id=${_r.skuId}`)}>{_r.skuId}</Button>}
{_r.recordType === 1 && <Button type='link' target='_blank' onClick={() => history.push(`/orderSystem/list/detail?id=${_r.skuId}`)}>{_r.orderNo}</Button>}
{_r.recordType === 2 && <Button type='link' target='_blank' onClick={() => history.push(`/afterService/returnManage/query/detail?id=${_text}`)}>{_r.orderNo}</Button>}
</>
)
......@@ -240,12 +285,13 @@ const DetialLayout = () => {
{
title: '客户名称',
key: 'memberName',
dataIndex: 'memberName'
dataIndex: 'memberName',
},
{
title: '单据时间',
key: 'orderTime',
dataIndex: 'orderTime'
dataIndex: 'orderTime',
render: (text) => format(text)
},
{
title: '单据状态',
......@@ -255,27 +301,43 @@ const DetialLayout = () => {
{
title: '含税/税率',
key: 'isHasTax',
dataIndex: 'isHasTax'
dataIndex: 'isHasTax',
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', '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'
dataIndex: 'skuPrice',
render: (text, record) => record.recordType === ORDER_TYPE ? `¥${Number(text).toFixed(2)}` : '-'
},
{
title: '实付金额',
title: <Space direction='vertical' size={0}>
<Typography.Text>实付金额</Typography.Text>
<Typography.Text type='secondary'>{Number(hasQuantity(idata, 'amount', 'amount')).toFixed(2)}</Typography.Text>
</Space>,
key: 'amount',
dataIndex: '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'
dataIndex: 'discountPrice',
render: (_text, record) => record.recordType === ORDER_TYPE ? `¥${(record.skuPrice - record.amount).toFixed(2)}` : '-'
},
]
......@@ -284,6 +346,7 @@ const DetialLayout = () => {
if (!Array.isArray(fetch)) {
getMarketingPlatformActivityExecuteDetailGoodsExecuteDetailPage({ ...params, ...param }).then(res => {
resolve(res.data)
setIdata(res.data.data)
}).catch(error => {
console.warn(error)
})
......@@ -378,8 +441,9 @@ const DetialLayout = () => {
width={1200}
visible={tableModalVisible}
columns={tableModalColumns}
ctl={false}
tableProps={{
rowKey: 'orderId',
rowKey: (record) => `${record.orderNo}`,
}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, "orderNo", FORM_FILTER_PATH)
......
......@@ -171,6 +171,7 @@ const MarketingSearch = () => {
const handleOnSubmit = () => {
setDateVisible(false);
setDateInfo({} as dateInfoProps)
ref.current.reload();
}
......
......@@ -27,7 +27,7 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import NiceForm from '@/components/NiceForm';
import { getMarketingCouponPlatformTypeList, getMarketingCouponPlatformWaitAuditPage, GetMarketingCouponWaitAuditPageResponseDetail, postMarketingCouponPlatformWaitAuditDelete, postMarketingCouponPlatformWaitAuditSubmitBatch } from '@/services/MarketingV2Api';
import { getMarketingCouponPlatformTypeList, getMarketingCouponPlatformWaitAuditPage, GetMarketingCouponPlatformWaitAuditPageResponseDetail, postMarketingCouponPlatformWaitAuditDelete, postMarketingCouponPlatformWaitAuditSubmitBatch } from '@/services/MarketingV2Api';
import useSpliceArray from '@/hooks/useSpliceArray';
import { querySchema } from './schema';
import commonColumn from '../common/columns/coupon';
......@@ -96,7 +96,7 @@ const PlatformCouponUnsubmitted: React.FC = () => {
});
};
const defaultColumns: ColumnType<GetMarketingCouponWaitAuditPageResponseDetail>[] = commonColumn().concat([
const defaultColumns: ColumnType<GetMarketingCouponPlatformWaitAuditPageResponseDetail>[] = commonColumn().concat([
{
title: '操作',
dataIndex: 'option',
......@@ -138,6 +138,9 @@ const PlatformCouponUnsubmitted: React.FC = () => {
setSelectedRowKeys(keys);
},
selectedRowKeys: selectedRowKeys,
getCheckboxProps: (record: GetMarketingCouponPlatformWaitAuditPageResponseDetail) => ({
disabled: record.status !== 1, // 状态不等于待提交审核的禁用
}),
};
// 初始化高级筛选选项
......
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