Commit a33add65 authored by XieZhiXiong's avatar XieZhiXiong

feat: 待提交审核商家优惠劵

parent 5e8725eb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-06-22 11:08:16 * @Date: 2021-06-22 11:08:16
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-28 10:27:45 * @LastEditTime: 2021-07-02 15:19:32
* @Description: 待提交审核商家优惠劵 * @Description: 待提交审核商家优惠劵
*/ */
import React, { useState, useRef } from 'react'; import React, { useState, useRef } from 'react';
...@@ -11,123 +11,127 @@ import { ...@@ -11,123 +11,127 @@ import {
Card, Card,
Space, Space,
Button, Button,
message,
Modal,
} from 'antd'; } from 'antd';
import { import {
PlusOutlined, PlusOutlined,
QuestionCircleOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { StandardTable } from 'god'; import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
import { createFormActions } from '@formily/antd'; import { createFormActions } from '@formily/antd';
import { DatePicker } from '@formily/antd-components'; import { DatePicker } from '@formily/antd-components';
import moment from 'moment';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'; import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect'; import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { GetMarketingCouponWaitAuditPageResponseDetail } from '@/services/MarketingApi';
import useSpliceArray from '@/hooks/useSpliceArray'; import useSpliceArray from '@/hooks/useSpliceArray';
import { querySchema } from './schema'; import { querySchema } from './schema';
import commonColumn from '../common/columns/coupon';
const { confirm } = Modal;
const formActions = createFormActions(); const formActions = createFormActions();
type fetchParams = {
name: string,
id: number,
effectiveTimeStart: string | number,
effectiveTimeEnd: string | number,
type: number,
}
const MerchantCouponUnsubmitted: React.FC = () => { const MerchantCouponUnsubmitted: React.FC = () => {
const ref = useRef<any>({}); const ref = useRef<any>({});
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]); const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
const fetchData = async (params: any) => { const fetchData = async (params: fetchParams) => {
let res = await PublicApi.getMemberAbilityMaintenancePage(params); const { effectiveTimeStart = null, effectiveTimeEnd = null } = params;
const newParams: fetchParams = { ...params };
if (effectiveTimeStart) {
newParams.effectiveTimeStart = moment(effectiveTimeStart).valueOf();
}
if (effectiveTimeEnd) {
newParams.effectiveTimeEnd = moment(effectiveTimeEnd).valueOf();
}
let res = await PublicApi.getMarketingCouponWaitAuditPage(newParams as any);
return res.data; return res.data;
}; };
const defaultColumns: ColumnType<any>[] = [ const handleCommit = (ids: number[]) => {
{ const mesInstance = message.loading({
title: 'ID', content: '正在提交',
dataIndex: 'id', duration: 0,
align: 'center', });
}, PublicApi.postMarketingCouponWaitAuditSubmitBatch({
{ ids,
title: '优惠劵名称', }).then(res => {
dataIndex: 'name', if (res.code !== 1000) {
align: 'center', return;
render: (text, record) => ( }
<EyePreview ref.current.reload();
url={`/memberCenter/marketingAbility/merchantCoupon/unsubmitted/detail?id=${record.validateId}`} }).finally(() => {
> mesInstance();
{text} });
</EyePreview> };
),
}, const handleDelete = (ids: number[]) => {
{ const mesInstance = message.loading({
title: '优惠劵类型', content: '正在删除',
dataIndex: 'memberTypeName', duration: 0,
align: 'center', });
}, PublicApi.postMarketingCouponWaitAuditDelete({
{ ids,
title: '领(发)劵起始时间', }).then(res => {
dataIndex: 'registerTime', if (res.code !== 1000) {
align: 'center', return;
}, }
{ ref.current.reload();
title: '领(发)劵截止时间', }).finally(() => {
dataIndex: 'registerTime', mesInstance();
align: 'center', });
}, };
{
title: '劵有效期起始时间', const defaultColumns: ColumnType<GetMarketingCouponWaitAuditPageResponseDetail>[] = commonColumn().concat([
dataIndex: 'registerTime',
align: 'center',
},
{
title: '劵有效期截止时间',
dataIndex: 'registerTime',
align: 'center',
},
{
title: '领劵方式',
dataIndex: 'depositTime',
align: 'center',
},
{
title: '劵面额',
dataIndex: 'statusName',
},
{
title: '发劵数量',
dataIndex: 'statusName',
},
{
title: '内部状态',
dataIndex: 'statusName',
},
{ {
title: '操作', title: '操作',
dataIndex: 'option', dataIndex: 'option',
align: 'center', align: 'center',
render: (_, record) => ( render: (_, record) => (
<> <>
{record.submit && (
<Button <Button
type="link" type="link"
onClick={() => {}} onClick={() => handleCommit([record.id])}
> >
提交 提交
</Button> </Button>
)}
{record.update && (
<Button <Button
type="link" type="link"
onClick={() => history.push(`/memberCenter/marketingAbility/merchantCoupon/unsubmitted/edit`)} onClick={() => history.push(`/memberCenter/marketingAbility/merchantCoupon/unsubmitted/edit?id=${record.id}`)}
> >
修改 修改
</Button> </Button>
)}
{record.delete && (
<Button <Button
type="link" type="link"
onClick={() => {}} onClick={() => handleDelete([record.id])}
> >
删除 删除
</Button> </Button>
)}
</> </>
), ),
}, },
]; ]);
const [columns, columnsHandle] = useSpliceArray<ColumnType<any>>(defaultColumns); const [columns, columnsHandle] = useSpliceArray<ColumnType<any>>(defaultColumns);
const rowSelection = { const rowSelection = {
...@@ -138,31 +142,79 @@ const MerchantCouponUnsubmitted: React.FC = () => { ...@@ -138,31 +142,79 @@ const MerchantCouponUnsubmitted: React.FC = () => {
}; };
// 初始化高级筛选选项 // 初始化高级筛选选项
const fetchSelectOptions = async () => { const fetchTypeEnums = async () => {
const res = await PublicApi.getMemberAbilityInfoPageitems(); const res = await PublicApi.getMarketingCouponTypeList();
if (res.code === 1000) { if (res.code === 1000) {
const { data = {} }: any = res; const { data = [] } = res;
const {
outerStatus = [],
} = data;
const outerIndex = columns.findIndex((item) => item.dataIndex === 'memberTypeName');
if (outerIndex) {
columnsHandle.replace(outerIndex, {
...columns[outerIndex],
filters: outerStatus.map(item => ({ text: item.text, value: item.id })).filter(item => item.value !== 0),
});
}
return { return {
innerStatus: outerStatus.map(item => ({ label: item.text, value: item.id })), type: data.map(item => ({ label: item.name, value: item.value })),
}; };
} }
return {}; return {};
}; };
const handleBatchCommit = () => {
if (!selectedRowKeys.length) {
message.warning('未选择任何优惠券');
return;
}
confirm({
title: '提示',
icon: <QuestionCircleOutlined />,
content: '确定要提交选中的优惠券吗?',
onOk() {
return new Promise<void>((resolve, reject) => {
PublicApi.postMarketingCouponWaitAuditSubmitBatch({
ids: selectedRowKeys,
})
.then(res => {
if (res.code === 1000) {
ref.current.reload();
setSelectedRowKeys([]);
resolve();
}
reject();
})
.catch(() => {
reject();
});
});
},
});
};
const handleBatchDelete = () => {
if (!selectedRowKeys.length) {
message.warning('未选择任何优惠券');
return;
}
confirm({
title: '提示',
icon: <QuestionCircleOutlined />,
content: '确定要删除选中的优惠券吗?',
onOk() {
return new Promise<void>((resolve, reject) => {
PublicApi.postMarketingCouponWaitAuditDelete({
ids: selectedRowKeys,
})
.then(res => {
if (res.code === 1000) {
ref.current.reload();
setSelectedRowKeys([]);
resolve();
}
reject();
})
.catch(() => {
reject();
});
});
},
});
};
const ControllerBtns = () => ( const ControllerBtns = () => (
<Space size={16}> <Space size={16}>
<Button <Button
...@@ -173,12 +225,12 @@ const MerchantCouponUnsubmitted: React.FC = () => { ...@@ -173,12 +225,12 @@ const MerchantCouponUnsubmitted: React.FC = () => {
新增优惠券 新增优惠券
</Button> </Button>
<Button <Button
onClick={() => {}} onClick={handleBatchCommit}
> >
批量提交 批量提交
</Button> </Button>
<Button <Button
onClick={() => {}} onClick={handleBatchDelete}
> >
批量删除 批量删除
</Button> </Button>
...@@ -189,7 +241,7 @@ const MerchantCouponUnsubmitted: React.FC = () => { ...@@ -189,7 +241,7 @@ const MerchantCouponUnsubmitted: React.FC = () => {
<Card> <Card>
<StandardTable <StandardTable
tableProps={{ tableProps={{
rowKey: 'validateId', rowKey: 'id',
}} }}
columns={columns} columns={columns}
currentRef={ref} currentRef={ref}
...@@ -211,8 +263,8 @@ const MerchantCouponUnsubmitted: React.FC = () => { ...@@ -211,8 +263,8 @@ const MerchantCouponUnsubmitted: React.FC = () => {
FORM_FILTER_PATH, FORM_FILTER_PATH,
); );
useAsyncInitSelect( useAsyncInitSelect(
['outerStatus'], ['type'],
fetchSelectOptions, fetchTypeEnums,
); );
}} }}
schema={querySchema} schema={querySchema}
......
...@@ -50,12 +50,9 @@ export const querySchema: ISchema = { ...@@ -50,12 +50,9 @@ export const querySchema: ISchema = {
'x-component-props': { 'x-component-props': {
placeholder: '优惠劵ID', placeholder: '优惠劵ID',
allowClear: true, allowClear: true,
style: {
width: 160,
}, },
}, },
}, '[effectiveTimeStart, effectiveTimeEnd]': {
'[startTime2, endTime2]': {
type: 'object', type: 'object',
'x-component': 'RangePicker', 'x-component': 'RangePicker',
'x-component-props': { 'x-component-props': {
......
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