Commit f9388903 authored by wuting's avatar wuting

feat: 会员领取

parent 22052e31
......@@ -970,6 +970,7 @@ export default {
'member.management.assigned.query.sourceName': '申请来源',
'member.management.assigned.query.receive': '领取',
'member.management.assigned.query.batchReceive': '批量领取',
'member.management.assigned.query.bind.suc': '会员领取成功!',
}
......@@ -15,8 +15,11 @@ import NiceForm from '@/components/NiceForm';
import LevelBrand from '@/components/LevelBrand';
import StatusTag from '@/components/StatusTag';
import {
getMemberAbilityAssignedPage,
getMemberAbilityAssignedPageitems,
getMemberAbilityMaintenancePage,
getMemberAbilityMaintenancePageitems,
postMemberAbilityAssignedBind,
postMemberDepositVerifyBatch,
} from '@/services/MemberV2Api';
import useSpliceArray from '@/hooks/useSpliceArray';
......@@ -30,26 +33,30 @@ import styles from './index.less';
const formActions = createFormActions();
const fetchData = async (params: any) => {
const { startDate = null, endDate = null } = params;
const payload = { ...params };
if (startDate) {
payload.startDate = moment(+startDate).format('YYYY-MM-DD');
}
if (endDate) {
payload.endDate = moment(+endDate).format('YYYY-MM-DD');
}
const res = await getMemberAbilityMaintenancePage(payload);
if (res.code === 1000) {
return res.data;
}
return { data: [], totalCount: 0 };
};
const MemberMaintain: React.FC<[]> = () => {
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
const [data,setData] = useState<any>([])
const fetchData = async (params: any) => {
const { startDate = null, endDate = null } = params;
const payload = { ...params };
if (startDate) {
payload.startDate = moment(+startDate).format('YYYY-MM-DD');
}
if (endDate) {
payload.endDate = moment(+endDate).format('YYYY-MM-DD');
}
const res = await getMemberAbilityAssignedPage(payload);
if (res.code === 1000) {
setData(res.data.data)
return res.data;
}
return { data: [], totalCount: 0 };
};
const ref = useRef<any>({});
const intl = useIntl();
......@@ -63,6 +70,7 @@ const MemberMaintain: React.FC<[]> = () => {
id: 'member.management.maintain.query.memberName',
})}`,
dataIndex: 'memberId',
width:150,
render: (text, record) => (
<>
<div>{text}</div>
......@@ -170,7 +178,7 @@ const MemberMaintain: React.FC<[]> = () => {
title: intl.formatMessage({ id: 'common.table.action' }),
dataIndex: 'option',
render: (_, record) => (
<Button type="link" onClick={() => handleReceive(record.memberId)}>
<Button type="link" onClick={() => handleReceive(record.memberId,record.roleId)}>
{intl.formatMessage({
id: 'member.management.assigned.query.receive',
})}
......@@ -185,7 +193,7 @@ const MemberMaintain: React.FC<[]> = () => {
// 初始化高级筛选选项
const fetchSelectOptions = async () => {
const res = await getMemberAbilityMaintenancePageitems();
const res = await getMemberAbilityAssignedPageitems();
if (res.code === 1000) {
const { data = {} }: any = res;
......@@ -269,10 +277,28 @@ const MemberMaintain: React.FC<[]> = () => {
selectedRowKeys: selectedRowKeys,
};
const handleReceive = id => {
console.log('lingqu', id);
const handleReceive = (memberId,roleId) => {
let selectDataParam = [{subMemberId:memberId,subRoleId:roleId}]
postMemberAbilityAssignedBind(selectDataParam,{ctlType:'none'})
.then(res => {
if (res.code === 1000) {
message.success(intl.formatMessage({
id: 'member.management.assigned.query.bind.suc',
}) )
setTimeout(() => {
ref.current.reload();
setSelectedRowKeys([]);
}, 200);
}
})
.catch((err) => {
message.error(err.message)
});
};
const handleBatch = () => {
if (!selectedRowKeys.length) {
message.warning(
......@@ -280,6 +306,18 @@ const MemberMaintain: React.FC<[]> = () => {
);
return;
}
let selectDataParam = []
data?.length && data.map((item)=>{
selectedRowKeys.map((i)=>{
if(item.validateId === i){
selectDataParam.push({subMemberId:item.memberId,subRoleId:item.roleId})
}
})
})
console.log('选中data:',selectDataParam)
confirm({
title: intl.formatMessage({ id: 'member.actions.verify-tip' }),
icon: <QuestionCircleOutlined />,
......@@ -288,21 +326,23 @@ const MemberMaintain: React.FC<[]> = () => {
}),
onOk() {
return new Promise<void>((resolve, reject) => {
console.log('提交的会员idlist:', selectedRowKeys);
// postMemberDepositVerifyBatch({
// validateIds: selectedRowKeys,
// })
// .then(res => {
// if (res.code === 1000) {
// ref.current.reload();
// setSelectedRowKeys([]);
// resolve();
// }
// reject();
// })
// .catch(() => {
// reject();
// });
postMemberAbilityAssignedBind(selectDataParam,{ctlType:'none'})
.then(res => {
if (res.code === 1000) {
resolve();
message.success(intl.formatMessage({
id: 'member.management.assigned.query.bind.suc',
}) )
setTimeout(() => {
ref.current.reload();
setSelectedRowKeys([]);
}, 200);
}
reject();
})
.catch(() => {
reject();
});
});
},
});
......
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