master
parent
91625ccb02
commit
64fa04e42f
@ -0,0 +1,75 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { DrawerForm, ProFormDigit, ProFormInstance, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
||||
import { queryAllRoleUsingPost } from '@/services/pop-b2b2c/pbcRoleController';
|
||||
import { Button, message } from 'antd';
|
||||
import { resetPasswordUsingGet } from '@/services/pop-b2b2c/pbcUsersController';
|
||||
export type FormValueType = {
|
||||
target?: string;
|
||||
template?: string;
|
||||
type?: string;
|
||||
time?: string;
|
||||
frequency?: string;
|
||||
} & Partial<API.PbcVipGrade>;
|
||||
export type UpdateFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
||||
onSubmit: (values: FormValueType) => Promise<void>;
|
||||
updateModalVisible: boolean;
|
||||
values: Partial<API.PbcVipGrade>;
|
||||
};
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
const formRef = useRef<ProFormInstance>();
|
||||
return (
|
||||
<DrawerForm
|
||||
width={640}
|
||||
title={props.values.pbcId ? '编辑' : '新增'}
|
||||
open={props.updateModalVisible}
|
||||
formRef={formRef}
|
||||
onFinish={(value: API.PbcVipGrade) => {
|
||||
return props.onSubmit({ ...value,pbcVipGradeDiscount: value.pbcVipGradeDiscount ? value.pbcVipGradeDiscount / 10 : 1, pbcId: props.values.pbcId })
|
||||
}}
|
||||
drawerProps={{
|
||||
destroyOnClose: true,
|
||||
}}
|
||||
initialValues={{
|
||||
pbcVipGradeName: props.values.pbcVipGradeName,
|
||||
pbcVipGradeDiscount: props.values.pbcVipGradeDiscount ? props.values.pbcVipGradeDiscount * 10 : 1
|
||||
}}
|
||||
onOpenChange={(visible) => {
|
||||
formRef.current?.resetFields();
|
||||
if (!visible) {
|
||||
props.onCancel();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ProFormText
|
||||
placeholder={'请输入会员等级名称'}
|
||||
label="会员等级名称"
|
||||
disabled
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '会员等级名称为必填项',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="pbcVipGradeName"
|
||||
/>
|
||||
<ProFormDigit
|
||||
placeholder={'请输入折扣权益'}
|
||||
label="折扣权益"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '折扣权益为必填项',
|
||||
},
|
||||
]}
|
||||
addonAfter={'折'}
|
||||
width="md"
|
||||
name="pbcVipGradeDiscount"
|
||||
/>
|
||||
</DrawerForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default UpdateForm;
|
||||
@ -0,0 +1,147 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { Button, message } from 'antd';
|
||||
import UpdateForm from './components/UpdateForm';
|
||||
import { Access, useAccess } from 'umi';
|
||||
import { PageContainer } from '@ant-design/pro-layout';
|
||||
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||
import { pbcVipGradePageUsingPost, saveOrUpdateGradeUsingPost } from '@/services/pop-b2b2c/pbcVipGradeController';
|
||||
import { handlePageQuery } from '@/utils/utils';
|
||||
|
||||
/**
|
||||
* 查询表格
|
||||
* @param param0
|
||||
*/
|
||||
const fetchData = async (params: API.PageVO) => {
|
||||
const msg = await pbcVipGradePageUsingPost(params);
|
||||
return {
|
||||
data: msg.data?.records,
|
||||
total: msg.data?.total,
|
||||
success: msg.retcode,
|
||||
} as any;
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新节点
|
||||
* @param fields
|
||||
*/
|
||||
const handleUpdate = async (fields: API.PbcVipGrade) => {
|
||||
const hide = message.loading('正在保存');
|
||||
|
||||
try {
|
||||
const msg = await saveOrUpdateGradeUsingPost({ ...fields });
|
||||
hide();
|
||||
if (msg.retcode) {
|
||||
message.success(!fields.pbcId ? '添加成功' : '保存成功');
|
||||
return true;
|
||||
}
|
||||
message.error(msg.retmsg);
|
||||
return false;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error(!fields.pbcId ? '添加失败请重试!' : '保存失败请重试!');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const TableList: React.FC<{}> = () => {
|
||||
const access: any = useAccess();
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [stepFormValues, setStepFormValues] = useState({});
|
||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||
|
||||
const columns: ProColumns<API.PbcVipGrade>[] = [
|
||||
{
|
||||
title: '会员等级名称',
|
||||
dataIndex: 'pbcVipGradeName',
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
title: '折扣权益',
|
||||
dataIndex: 'pbcVipGradeDiscount',
|
||||
search: false,
|
||||
render: (text, record) => record.pbcVipGradeDiscount ? record.pbcVipGradeDiscount * 10 + '折' : '-'
|
||||
},
|
||||
{
|
||||
title: '入会时长',
|
||||
dataIndex: 'pbcBusinessId',
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
title: '采购金额',
|
||||
dataIndex: 'pbcBusinessId',
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
valueType: 'option',
|
||||
render: (text, record) => (
|
||||
<span>
|
||||
<Access key="config" accessible={access.memberGradeSave}>
|
||||
<Button type="link" onClick={() => {
|
||||
handleUpdateModalVisible(true);
|
||||
setStepFormValues(record);
|
||||
}}>
|
||||
编辑
|
||||
</Button>
|
||||
</Access>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
return (
|
||||
<PageContainer
|
||||
header={{
|
||||
title: '',
|
||||
breadcrumb: {},
|
||||
}}
|
||||
>
|
||||
<ProTable<API.PbcVipGrade>
|
||||
columns={columns}
|
||||
actionRef={actionRef}
|
||||
request={(param: any) => {
|
||||
const queryParam = handlePageQuery(param);
|
||||
return fetchData(queryParam);
|
||||
}}
|
||||
rowKey="pbcId"
|
||||
size="small"
|
||||
bordered
|
||||
search={{
|
||||
labelWidth: 'auto',
|
||||
span: 6
|
||||
}}
|
||||
pagination={{
|
||||
pageSize: 20,
|
||||
showSizeChanger: true,
|
||||
}}
|
||||
scroll={{
|
||||
y: 'calc(100vh - 320px)',
|
||||
}}
|
||||
dateFormatter="string"
|
||||
options={false}
|
||||
toolBarRender={() => []}
|
||||
/>
|
||||
{stepFormValues && Object.keys(stepFormValues).length ? (
|
||||
<UpdateForm
|
||||
onSubmit={async (value: any) => {
|
||||
const success = await handleUpdate(value);
|
||||
|
||||
if (success) {
|
||||
handleUpdateModalVisible(false);
|
||||
setStepFormValues({});
|
||||
actionRef.current?.reload();
|
||||
}
|
||||
}}
|
||||
onCancel={() => {
|
||||
message.destroy();
|
||||
handleUpdateModalVisible(false);
|
||||
}}
|
||||
updateModalVisible={updateModalVisible}
|
||||
values={stepFormValues}
|
||||
/>
|
||||
) : null}
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@ -0,0 +1,151 @@
|
||||
import React, { useRef } from 'react';
|
||||
import { Switch, message } from 'antd';
|
||||
import { PageContainer } from '@ant-design/pro-layout';
|
||||
import Constants from '@/constants';
|
||||
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||
import { handlePageQuery } from '@/utils/utils';
|
||||
import { Access, useAccess } from '@umijs/max';
|
||||
import { pbcUsersPageUsingPost, updateMemberRecordStateUsingGet } from '@/services/pop-b2b2c/pbcUsersController';
|
||||
import { gradeListUsingPost } from '@/services/pop-b2b2c/pbcVipGradeController';
|
||||
|
||||
/**
|
||||
* 查询表格
|
||||
* @param param0
|
||||
*/
|
||||
const fetchData = async (params: API.PageVO) => {
|
||||
const msg = await pbcUsersPageUsingPost(params);
|
||||
return {
|
||||
data: msg.data?.records,
|
||||
total: msg.data?.total,
|
||||
success: msg.retcode,
|
||||
} as any;
|
||||
};
|
||||
|
||||
const handleUpdateState = async (id: string, state: number) => {
|
||||
const hide = message.loading('正在保存');
|
||||
if (!id) return false;
|
||||
try {
|
||||
const msg = await updateMemberRecordStateUsingGet({ pbcId: id, state: state });
|
||||
hide();
|
||||
if (msg.retcode) {
|
||||
message.success(!id ? '新增成功!' : '保存成功!');
|
||||
return true;
|
||||
}
|
||||
message.error(msg.retmsg);
|
||||
return false;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error(!id ? '新增失败,请重试!' : '保存失败,请重试!');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const TableList: React.FC<{}> = () => {
|
||||
const actionRef = useRef<ActionType>();
|
||||
const access: any = useAccess();
|
||||
|
||||
const columns: ProColumns<API.PbcUsers>[] = [
|
||||
{
|
||||
title: '会员昵称',
|
||||
dataIndex: 'pbcUserNickName',
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'pbcUserMobile',
|
||||
},
|
||||
{
|
||||
title: '入口',
|
||||
dataIndex: 'pbcUserSourceType',
|
||||
search: false
|
||||
},
|
||||
{
|
||||
title: '会员等级',
|
||||
dataIndex: 'pbcVipGradeName',
|
||||
valueType: 'select',
|
||||
request: async () => {
|
||||
const msg = await gradeListUsingPost();
|
||||
if (msg.retcode && msg.data) {
|
||||
return msg.data.map((e) => {
|
||||
return {
|
||||
label: e.pbcVipGradeName,
|
||||
value: e.pbcVipGradeName,
|
||||
};
|
||||
});
|
||||
}
|
||||
return [];
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '注册日期',
|
||||
dataIndex: 'pbcCreateAt',
|
||||
valueType: 'dateTimeRange',
|
||||
render: (text, record) => record.pbcCreateAt
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'pbcState',
|
||||
valueType: 'select',
|
||||
valueEnum: Constants.state,
|
||||
render: (_, record) => {
|
||||
return <Access key="switch" accessible={access.memberUpdateState}>
|
||||
<Switch
|
||||
checked={record.pbcState === 1}
|
||||
onChange={async (value) => {
|
||||
const success = await handleUpdateState(record.pbcId || '', value ? 1 : 2 );
|
||||
|
||||
if (success) {
|
||||
if (actionRef.current) {
|
||||
actionRef.current.reload();
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Access>
|
||||
}
|
||||
}
|
||||
];
|
||||
return (
|
||||
<PageContainer
|
||||
header={{
|
||||
title: '',
|
||||
breadcrumb: {},
|
||||
}}
|
||||
>
|
||||
<ProTable<API.PbcUsers>
|
||||
columns={columns}
|
||||
actionRef={actionRef}
|
||||
request={(param: any) => {
|
||||
const queryParam = handlePageQuery(param);
|
||||
if (queryParam.filters) {
|
||||
queryParam.filters.push({
|
||||
key: 'pbcUserType'.replace(/([A-Z])/g, '_$1').toLowerCase(),
|
||||
value: 0,
|
||||
action: '=',
|
||||
})
|
||||
}
|
||||
return fetchData(queryParam);
|
||||
}}
|
||||
rowKey="pbcId"
|
||||
size="small"
|
||||
bordered
|
||||
search={{
|
||||
labelWidth: 'auto',
|
||||
span: 6
|
||||
}}
|
||||
pagination={{
|
||||
pageSize: 20,
|
||||
showSizeChanger: true,
|
||||
}}
|
||||
scroll={{
|
||||
y: 'calc(100vh - 320px)',
|
||||
}}
|
||||
dateFormatter="string"
|
||||
options={false}
|
||||
toolBarRender={() => []}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@ -0,0 +1,21 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import request from '@/utils/request';
|
||||
|
||||
/** 利用三级类目id查询对应的颜色、规格参数 获取规格 GET /b2b2c/pbcCommonData/getRecordByL3CategoryId */
|
||||
export async function getRecordByL3CategoryIdUsingGet(
|
||||
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||
params: API.getRecordByL3CategoryIdUsingGETParams,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<API.AjaxResultPbcCategoryCommonDataVo_>(
|
||||
'/b2b2c/pbcCommonData/getRecordByL3CategoryId',
|
||||
{
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import request from '@/utils/request';
|
||||
|
||||
/** 验证邮箱验证码 邮箱 GET /b2b2c/pbcemail/checkemailverificationcode */
|
||||
export async function checkEmailVerificationCodeUsingGet(
|
||||
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||
params: API.checkEmailVerificationCodeUsingGETParams,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<boolean>('/b2b2c/pbcemail/checkemailverificationcode', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 获得邮箱验证码 邮箱 GET /b2b2c/pbcemail/getemailverificationcode */
|
||||
export async function getEmailVerificationCodeUsingGet(
|
||||
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||
params: API.getEmailVerificationCodeUsingGETParams,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<API.AjaxResult>('/b2b2c/pbcemail/getemailverificationcode', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue