Browse Source

提交

storemanagementweb
gwbvipvip 10 months ago
parent
commit
3f91fad899
11 changed files with 1738 additions and 6 deletions
  1. +19
    -0
      config/routes.js
  2. +196
    -0
      src/pages/shopmanage/member/memberInfo/components/CreateForm.jsx
  3. +81
    -0
      src/pages/shopmanage/member/memberInfo/components/IntegralRecord.jsx
  4. +622
    -0
      src/pages/shopmanage/member/memberInfo/index.jsx
  5. +62
    -0
      src/pages/shopmanage/member/memberInfo/service.js
  6. +93
    -0
      src/pages/shopmanage/member/membertag/components/CreateForm.jsx
  7. +51
    -0
      src/pages/shopmanage/member/membertag/components/CreateMemberInfoForm.jsx
  8. +191
    -0
      src/pages/shopmanage/member/membertag/components/memberInfoList.jsx
  9. +369
    -0
      src/pages/shopmanage/member/membertag/index.jsx
  10. +48
    -0
      src/pages/shopmanage/member/membertag/services.js
  11. +6
    -6
      src/pages/shopmanage/storeGoodsInfo/components/CreateFoodMeun.jsx

+ 19
- 0
config/routes.js View File

@@ -308,6 +308,25 @@ export default [
},
],
},
{
name: '门店会员管理',
icon: 'BankFilled',
path: '/shopmanage/member',
routes: [
{
name: '会员信息',
icon: 'smile',
path: '/shopmanage/member/memberInfo',
component: './shopmanage/member/memberInfo',
},
{
name: '会员标签',
icon: 'smile',
path: '/shopmanage/member/membertag',
component: './shopmanage/member/membertag',
},
]
},
{
name: '门店管理',
icon: 'BankFilled',


+ 196
- 0
src/pages/shopmanage/member/memberInfo/components/CreateForm.jsx View File

@@ -0,0 +1,196 @@
import React, { useState, useEffect } from 'react';
import { Radio, Modal, Form, Input, Button, Select, InputNumber, DatePicker, Alert } from 'antd';
import { GetCouponStatusOrType } from '../service';
const CreateForm = (props) => {
const { Option, OptGroup } = Select;

const [options, setoptions] = useState();

const couponType = async () => { };

//初始化数据
useEffect(() => {
const initcouponType = async (value) => { };
initcouponType();
}, []);

const formItemLayout = {
labelCol: {
sm: { span: 4 },
},
wrapperCol: {},
};
const tailFormItemLayout = {
wrapperCol: {
sm: {
offset: 1,
},
},
};
const onTimeTypeChange = (value) => { };

return (
<Modal
title={props.isLook ? "会员信息详情" : (props.values.id ? '编辑会员信息' : '新建会员信息')}
width={700}
maskClosable={false}
visible={props.createModalVisible}
// bodyStyle={{ padding: '32px 40px 48px' }}
footer={null} //底部内容
//取消
onCancel={() => {
props.onCancel();
}}
//关闭时销毁 Modal 里的子元素
destroyOnClose
>
<Form
{...formItemLayout}
layout="Horizontal"
preserve={false}
initialValues={props.values}
onFinish={props.onFinish}
>
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item name="platformType" hidden={true}>
<Input />
</Form.Item>
<Form.Item name="memberInfo_Id" hidden={true}>
<Input />
</Form.Item>

<Form.Item name="nickName" label="会员昵称" rules={[{ required: true, max: 200 }]}>
<Input placeholder="请输入会员昵称" />
</Form.Item>
<Form.Item
name="phone"
label="电话号码"
rules={[{ required: true, pattern: '^1[0-9]{10}$', message: '请输入正确的电话号码' }]}
>
<Input placeholder="" disabled={props.platformType == 0 ? true : false} />
</Form.Item>

<Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) =>
prevValues.platformType !== currentValues.platformType
}
>
{({ getFieldValue }) =>
!getFieldValue('id') ? (
<Form.Item
name="platformType"
disabled={true}
label="平台"
rules={[{ required: true, message: '请选择平台' }]}
>
<Select style={{ width: 120 }}>
<Option value="1" disabled>
微信
</Option>
<Option value="2" disabled>
支付宝
</Option>
<Option value="3">POS</Option>
<Option value="4">储值卡</Option>
</Select>
</Form.Item>
) : null
}
</Form.Item>

<Form.Item name="headImgUrl" label="头像" rules={[{ max: 500 }]}>
<Input placeholder="请输入头像" />
</Form.Item>

<Form.Item style={{ height: 32 }}>
<Form.Item
rules={[{ required: true, message: '请选择出生日期' }]}
name="birthday"
label="出生日期"
style={{ float: 'left', marginLeft: 40 }}
>
<DatePicker />
</Form.Item>
<Form.Item name="sex" label="性别" style={{ float: 'left', marginLeft: 110 }}>
<Radio.Group>
<Radio value={0}>未知</Radio>
<Radio value={1}>男</Radio>
<Radio value={2}>女</Radio>
</Radio.Group>
</Form.Item>
</Form.Item>

<Form.Item label="实名认证" style={{ height: 32 }}>
<Form.Item name="realName" style={{ float: 'left', width: '145px' }}>
<Input placeholder="请输入真实姓名" />
</Form.Item>
<Form.Item name="cardNum"
rules={[{ pattern: '^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$', message: '请请输入正确的身份证号码' }]}
style={{ float: 'left', marginLeft: 10, width: '300px' }}>
<Input placeholder="请输入身份证号码" />
</Form.Item>
</Form.Item>

<Form.Item name="country" label="国家">
<Input placeholder="请输入国家" />
</Form.Item>
<Form.Item label="地区" style={{ height: 32 }}>
<Form.Item name="province" style={{ float: 'left' }}>
<Input style={{ width: '150px' }} placeholder="请输入省" />
</Form.Item>
<Form.Item name="city" style={{ float: 'left', marginLeft: 10 }}>
<Input style={{ width: '150px' }} placeholder="请输入市" />
</Form.Item>

<Form.Item name="county" style={{ float: 'left', marginLeft: 10 }}>
<Input style={{ width: '150px' }} placeholder="请输入县(区)" />
</Form.Item>
</Form.Item>

<Form.Item name="address" label="详细地址">
<Input placeholder="" />
</Form.Item>

<Form.Item name="level_Id" label="等级">
<Input placeholder="" />
</Form.Item>
{/* <Form.Item name="status" label="状态" rules={[{ required: true }]}>
<Select placeholder="状态">
<Option value={0}>正常</Option>
<Option value={1}>停用</Option>
</Select>
</Form.Item> */}



<Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) =>
prevValues.platformType !== currentValues.platformType
}
>
{({ getFieldValue }) =>
(!props.isLook) ? (
<Form.Item>
<Button
disabled={props.isLook}
type="primary"
htmlType="submit"
style={{ float: 'right' }}
>
保存
</Button>
</Form.Item>
) : null
}
</Form.Item>

</Form>
</Modal>
);
};

export default CreateForm;

+ 81
- 0
src/pages/shopmanage/member/memberInfo/components/IntegralRecord.jsx View File

@@ -0,0 +1,81 @@
import React, { useRef, useState, useEffect } from 'react';
import { Radio, Modal, Form, Input, Button, Select, InputNumber, DatePicker, Drawer } from 'antd';
import { GetIntegralRecord } from '../service';
import ProTable from '@ant-design/pro-table';
const IntegralRecord = (props) => {

const actionRef = useRef();

const columns = [
{
title: '主键',
dataIndex: 'id',
tip: '规则名称是唯一的key',
hideInSearch: true,
hideInTable: true,
},
{
title: '变更前',
dataIndex: 'beforeChange',
valueType: 'textarea',
search: false,
}, {
title: '变更类型',
dataIndex: 'type',
valueEnum: {
1: { text: '增加',status:'Success'},
2: { text: '减少',status: 'Error'},
},
}, {
title: '变更积分',
dataIndex: 'integral',
valueType: 'textarea',
search: false,
}, {
title: '变更后',
dataIndex: 'afterChange',
valueType: 'textarea',
search: false,
}, {
title: '变更时间',
dataIndex: 'createAt',
valueType: 'dateTime',
}];

return (
<Drawer title="积分记录"
//取消
onClose={() => {
props.onClose();
}}
width={720}
visible={props.integralRecordVisible}
placement="right"
//关闭时销毁 Modal 里的子元素
destroyOnClose>

<ProTable
actionRef={actionRef}
rowKey="id"
request={async (params) => {
var queryData = [];
var total = 0;
params.memberId = props.memberId;
await GetIntegralRecord(JSON.stringify(params)).then((re) => {
queryData = re.data.data;
total = re.data.total;
});
return {
data: queryData,
success: true,
total: total,
};
}}
columns={columns}
pagination={{ defaultPageSize: 10 }}
/>
</Drawer>);
};

export default IntegralRecord;

+ 622
- 0
src/pages/shopmanage/member/memberInfo/index.jsx View File

@@ -0,0 +1,622 @@
import { PlusOutlined } from '@ant-design/icons';
import { Checkbox, Modal, Space, Tag, Button, message, Popconfirm, Drawer } from 'antd';
import React, { useState, useRef } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import CreateForm from './components/CreateForm';
import IntegralRecord from './components/IntegralRecord';
import moment from 'moment';
import {
GetMemberPageQuery,
UpdateMemberStatus,
UpdateMemberInfo,
GetMemberTagAndInfo,
UpdateMemberTag,
SyncMember,
GetPlatformMemberList,
post,
CreateMemberInfo,
} from './service';
import { get, set } from 'lodash-es';
import { encode, decode } from 'js-base64';

const CheckboxGroup = Checkbox.Group;

const plainOptions = ['Apple', 'Pear', 'Orange'];
const defaultCheckedList = ['Apple', 'Orange'];

const key = 'message';

/**
* 判断会员名称是否被小程序加密
* @param {*} str
* @returns
*/
const isBase64 = (str) => {
const result = decode(str);
if (result.includes('BPA_BASE64')) {
return true;
} else {
false;
}
};

/**
* 对小程序加密的昵称进行解密
* @param {*} str
* @returns
*/
const decodeBPABase64 = (str) => {
return decode(str).replace('BPA_BASE64', '');
};

const MemberManage = () => {
const actionRef = useRef();
const actionRef2 = useRef();
/** 新建/更新窗口的弹窗 */
const [createModalVisible, SetCreateModalVisible] = useState(false);
const [integralRecordVisible, SetIntegralRecordVisible] = useState(false);
const [dataRow, setdataRow] = useState([]);
const [dataRowKey, setDataRowKey] = useState([]);
const [currentRow, setCurrentRow] = useState();
//会员标签弹窗
const [isTagModalVisible, setIsTagModalVisible] = useState(false);
//会员标签和绑定详情
const [memberTagAndInfo, SetMemberTagAndInfo] = useState([]);
//选中的标签
const [checkedTagList, setCheckedTagList] = React.useState();
const [isLook, setIsLook] = useState(false);

const PlatformMemberList = async (memberId) => {
await GetPlatformMemberList(memberId).then((r) => {
setdataRow(r.data);
});
};

//添加会员信息
const AddMemberInfo = async (fields) => {
message.loading('正在添加...', key);
try {
fields.status = 0;
await CreateMemberInfo(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.data) {
message.success('添加成功');
} else {
message.error('添加失败');
}
});
//刷新数据
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.destroy(key);
message.error('添加失败请重试!');
return false;
}
};

//修改会员信息
const updateMemberInfo = async (fields) => {
message.loading('正在修改...', key);
try {
await UpdateMemberInfo(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.data) {
message.success('修改成功');
} else {
message.error('修改失败' + r.errors == null ? '' : r.errors);
}
});
//刷新数据
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.destroy(key);
message.error('修改失败请重试!');
return false;
}
};

//修改会员状态
const updateMemberStatus = async (fields) => {
message.loading('正在修改...', key);
try {
await UpdateMemberStatus(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.data) {
PlatformMemberList(fields.Id);
message.success('修改成功');
} else {
message.error('修改失败' + r.errors == null ? '' : r.errors);
}
});
//刷新数据
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.destroy(key);
message.error('修改失败请重试!');
return false;
}
};
//修改会员标签
const updateMemberTag = async (platformType, memberInfo_Id) => {
message.loading('正在修改...', key);
try {
await UpdateMemberTag(
JSON.stringify({
platformType: platformType,
memberInfo_Id: memberInfo_Id,
tags: checkedTagList,
}),
).then((r) => {
message.destroy(key);
if (r.data) {
message.success('修改成功');
} else {
message.error('修改失败' + r.errors == null ? '' : r.errors);
}
});
//刷新数据
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.destroy(key);
message.error('修改失败请重试!');
return false;
}
};

//获取会员标签和会员的绑定标签
const getMemberTagAndInfo = async (memberinfoid, platformtype) => {
await GetMemberTagAndInfo(memberinfoid, platformtype).then((r) => {
if (r.data) {
var list = [];
var list2 = [];
r.data.forEach((element) => {
if (element.memberTagInfoId != null) {
list2.push(element.id);
}
list.push({ label: element.name, value: element.id });
});
SetMemberTagAndInfo(list);
setCheckedTagList(list2);
}
});
};

/** 国际化配置 */
const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key',
},
{
title: '头像',
dataIndex: 'headImgUrl',
search: false,
hideInForm: true,
render: (_, record) => (
<img src={record.headImgUrl} style={{ width: '45px', height: '45px' }}></img>
),
},
{
title: '昵称',
dataIndex: 'nickName',
valueType: 'textarea',
ellipsis: {
showTitle: true,
},
hideInForm: true,
render: (_, record) => (
<a>{isBase64(record.nickName) ? decodeBPABase64(record.nickName) : record.nickName}</a>
),
},
{
title: '电话',
dataIndex: 'phone',
valueType: 'textarea',
hideInForm: true,
},
{
title: '性别',
dataIndex: 'sex',
search: false,
valueEnum: {
0: { text: '未知' },
1: { text: '男' },
2: { text: '女' },
},
},
{
title: '等级',
dataIndex: 'level',
search: false,
valueType: 'textarea',
},
{
title: '状态',
dataIndex: 'status',
valueEnum: {
0: { text: '正常', status: 'Success' },
1: { text: '禁用', status: 'error' },
},
},
{
title: '标签',
dataIndex: 'memberTag',
search: false,
width: 300,
render: (_, record) => (
<Space>
{record.memberTag.map(({ id, name }) => (
<Tag color="#87d068" key={id}>
{name}
</Tag>
))}
</Space>
),
},
{
title: '创建时间',
dataIndex: 'createAt',
search: false,
width: 150,
valueType: 'textarea',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 300,
render: (_, record) => {
let template = [
<a
key="primary"
type="primary"
onClick={() => {
SetCreateModalVisible(true);
setCurrentRow(() => {
record.birthday = moment(record.birthday);
setIsLook(true);
return record;
});
}}
>
详情
</a>,
<a
key="primary"
type="primary"
onClick={() => {
SetCreateModalVisible(true);
setCurrentRow(() => {
record.birthday = moment(record.birthday);
setIsLook(false);
return record;
});
}}
>
更新
</a>,
// <Popconfirm
// key="delete"
// title={`确定要${record.status == 0 ? '禁用' : '启用'}吗?`}
// onConfirm={async () => {
// var data = { Id: record.id, platformType: 0, status: record.status == 0 ? 1 : 0 };
// updateMemberStatus(data);
// }}
// okText="确定"
// cancelText="取消"
// >
// <a
// key="primary"
// type="primary"
// >
// {record.status == 0 ? '禁用 ' : '启用'}
// </a>
// </Popconfirm>,


<a
key="primary"
type="primary"
onClick={() => {
getMemberTagAndInfo(record.id, 0);
setIsTagModalVisible(true);
setCurrentRow(() => {
return record;
});
}}
>
标签管理
</a>,
// <a
// key="primary"
// type="primary"
// onClick={() => {
// setCurrentRow(record);
// SetIntegralRecordVisible(true);
// }}
// >
// 积分记录
// </a>,
];
return template;
},
},
];
const onExpand = (expanded, record) => {
if (expanded) {
setdataRow(record.platformMemberInfos);
setDataRowKey([record.id]);
} else {
setDataRowKey([]);
}
};
const expandedRowRender = (data) => {
return (
<ProTable
rowKey="id"
actionRef={actionRef2}

pagination={{
pageSize: 10
}}
scroll={{
x: 1300,
}}
columns={[
{
title: '平台',
dataIndex: 'platformType',
key: 'platformType',
valueEnum: {
1: { text: '微信' },
2: { text: '支付宝' },
3: { text: 'POS' },
4: { text: '储值卡' },
},
},
{
title: '头像',
dataIndex: 'headImgUrl',
valueType: 'textarea',
search: false,
hideInForm: true,
render: (_, record) => (
<img src={record.headImgUrl} style={{ width: '45px', height: '45px' }}></img>
),
},
{
title: '昵称',
dataIndex: 'nickName',
valueType: 'textarea',
hideInForm: true,
render: (_, record) => (
<a>
{isBase64(record.nickName) ? decodeBPABase64(record.nickName) : record.nickName}
</a>
),
},
{
title: '性别',
dataIndex: 'sex',
search: false,
valueEnum: {
0: { text: '未知' },
1: { text: '男' },
2: { text: '女' },
},
},
{
title: '状态',
dataIndex: 'status',
valueEnum: {
0: { text: '正常', status: 'Success' },
1: { text: '禁用', status: 'error' },
},
},
{
title: '标签',
dataIndex: 'memberTag',
key: 'memberTag',
width: 450,
render: (_, record) => (
<>
<Space>
{record.memberTag.map(({ id, name }) => (
<Tag color="#87d068" key={id}>
{name}
</Tag>
))}
</Space>
</>
),
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => {
let template = [
// <a
// key="primary"
// type="primary"
// onClick={() => {
// SetCreateModalVisible(true);
// setCurrentRow(() => {
// record.birthday = moment(record.birthday);
// return record;
// });
// }}
// >
// 更新
// </a>,
// <a
// key="primary"
// type="primary"
// onClick={() => {
// var data = {
// Id: record.memberInfo_Id,
// platformType: record.platformType,
// status: record.status == 0 ? 1 : 0,
// };
// updateMemberStatus(data);
// }}
// >
// {record.status == 0 ? '禁用 ' : '启用'}
// </a>,
<a
key="primary"
type="primary"
onClick={() => {
getMemberTagAndInfo(record.memberInfo_Id, record.platformType);
setIsTagModalVisible(true);
setCurrentRow(() => {
return record;
});
PlatformMemberList(record.memberInfo_Id);
}}
>
标签管理
</a>,
];
return template;
},
},
]}
headerTitle={false}
search={false}
options={false}
dataSource={dataRow}
/>
);
};
return (
<PageContainer
header={{
title: '',
breadcrumb: {},
}}
>
<ProTable
headerTitle="会员信息"
pagination={{
pageSize: 10,
}}
scroll={{
x: 1300,
}}
actionRef={actionRef}
onExpand={onExpand}
expandedRowKeys={dataRowKey}
rowKey="id"
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
// SyncMember(1).then((r) => {
// message.success('启动同步,稍后请刷新页面');
// });
setIsLook(false);
setCurrentRow({});
SetCreateModalVisible(true);
}}
>
<PlusOutlined /> 添加会员
</Button>,
]}
expandable={{ expandedRowRender }}
request={async (params) => {
var data = [];
var total = 0;
await GetMemberPageQuery(params).then((r) => {
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
/>

{/* 修改会员 */}
<CreateForm
isLook={isLook}
onFinish={async (value) => {
// value.birthday = value.birthday._i;
var success = false;
value.MemberInfo_Id = value.id;
if (value.id) {
success = updateMemberInfo(value);
} else {
success = AddMemberInfo(value);
}
if (success) {
SetCreateModalVisible(false);
if (actionRef.current) {
actionRef.current.reloadAndRest();
}
}
}}
onCancel={() => {
setCurrentRow(undefined);
SetCreateModalVisible(false);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
/>

{/* 会员标签 */}
<Modal
title="会员标签"
visible={isTagModalVisible}
onOk={() => {
if (
updateMemberTag(
currentRow.platformType,
currentRow.platformType == 0 ? currentRow.id : currentRow.memberInfo_Id,
)
) {
setIsTagModalVisible(false);
setDataRowKey([]);
}
}}
onCancel={() => {
setCurrentRow([]);
setIsTagModalVisible(false);
}}
>
<>
<CheckboxGroup
options={memberTagAndInfo}
value={checkedTagList}
onChange={(list) => {
setCheckedTagList(list);
}}
/>
</>
</Modal>
{/* 积分记录 */}
{/* <IntegralRecord
onClose={() => {
SetIntegralRecordVisible(false);
}}
memberId={currentRow?.id}
integralRecordVisible={integralRecordVisible}
/> */}
</PageContainer>
);
};

export default MemberManage;

+ 62
- 0
src/pages/shopmanage/member/memberInfo/service.js View File

@@ -0,0 +1,62 @@
import { request } from 'umi';
import { getDataBaseUrl,getStoremanagement } from '@/global_data';



//获取会员信息
export function GetMemberPageQuery(data) {
return request(getStoremanagement()+`​/api/MemberInfoService/GetMemberPageQuery`, {
method: 'post',
data: data,
});
}

//添加会员
export function CreateMemberInfo(data) {
return request(getStoremanagement()+`/api/MemberInfoService/AddMember`, {
method: 'post',
data: data,
});
}

//修改会员信息
export function UpdateMemberInfo(data) {
return request(getStoremanagement()+`/api/MemberInfoService/UpdateMemberInfo`, {
method: 'post',
data: data,
});
}

//修改会员状态
export function UpdateMemberStatus(data) {
return request(getStoremanagement()+`/api/MemberInfoService/UpdateMemberStatus`, {
method: 'post',
data: data,
});
}

//获取会员
export function GetPlatformMemberList(data) {
return request(getStoremanagement()+`/api/MemberInfoService/GetPlatformMemberList?memberId=${data}`, {
method: 'get',
});
}

//获取会员标签 和绑定详情
export function GetMemberTagAndInfo(memberinfoid, platformtype) {
return request(
getStoremanagement()+`/api/MemberInfoService/GetMemberTagAndInfo?memberInfoId=${memberinfoid}&PlatformType=${platformtype}`,
{
method: 'get',
},
);
}

//修改会员标签
export function UpdateMemberTag(data) {
return request(getStoremanagement()+`/api/MemberInfoService/UpdateMemberTag`, {
method: 'post',
data: data,
});
}


+ 93
- 0
src/pages/shopmanage/member/membertag/components/CreateForm.jsx View File

@@ -0,0 +1,93 @@
import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, InputNumber } from 'antd';
const CreateForm = (props) => {
const { Option, OptGroup } = Select;
return (
<Modal
title={props.values.id ? '编辑' : '新建'}
width={640}
visible={props.createModalVisible}
bodyStyle={{ padding: '32px 40px 48px' }}
footer={null}
onCancel={() => {
props.onCancel();
}}
destroyOnClose
maskClosable={false}
>
<Form
layout="vertical"
preserve={false}
form={props.form}
initialValues={props.values}
onFinish={props.onFinish}
>
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item name="name" label="标签名称" rules={[{ required: true, max: 65,whitespace:true }]}>
<Input placeholder="请输入标签名称" />
</Form.Item>
<Form.Item
name="platformType"
label="平台"
defaultValue={props.values.status}
rules={[{ required: true, message: '请选择平台' }]}
>
<Select placeholder="请选择平台">
<OptGroup>
<Select.Option value="0">默认</Select.Option>
<Select.Option value="1">微信</Select.Option>
<Select.Option value="2">支付宝</Select.Option>
<Select.Option value="3">POS</Select.Option>
<Select.Option value="4">储值卡</Select.Option>
</OptGroup>
</Select>
</Form.Item>
{/* <Form.Item name="sort" label="排序">
<InputNumber min={1} placeholder="请选择排序" />
</Form.Item> */}


{/* <Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) =>
prevValues.mode !== currentValues.mode
} >
{({ getFieldValue }) =>
(props.values.id) ? (
<Form.Item
name="status"
label="状态"
defaultValue={props.values.status}
rules={[{ required: true, message: '请选择状态' }]}
>
<Select placeholder="请选择状态">
<OptGroup>
<Select.Option value="0">正常</Select.Option>
<Select.Option value="1">停用</Select.Option>
</OptGroup>
</Select>
</Form.Item>
) : null
}
</Form.Item> */}


<Form.Item>
{/* <Button type="primary" htmlType="submit">
保存
</Button> */}
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} >
确认
</Button>
<Button htmlType="button" style={{ float: 'right' }} onClick={props.onCancel} >
取消
</Button>
</Form.Item>
</Form>
</Modal>
);
};

export default CreateForm;

+ 51
- 0
src/pages/shopmanage/member/membertag/components/CreateMemberInfoForm.jsx View File

@@ -0,0 +1,51 @@
import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, InputNumber } from 'antd';
const CreateForm = (props) => {
const { Option, OptGroup } = Select;
return (
<Modal
title="分配会员平台"
width={640}
visible={props.createModalVisible}
bodyStyle={{ padding: '32px 40px 48px' }}
footer={null}
onCancel={() => {
props.onCancel();
}}
centered={true}
destroyOnClose
>
<Form
layout="vertical"
preserve={false}
initialValues={props.values}
onFinish={props.onFinish}
>
<Form.Item
name="platformType"
label="平台"
defaultValue={props.values.status}
rules={[{ required: true, message: '请选择平台', width: 50 }]}
>
<Select placeholder="请选择平台">
<OptGroup>
<Select.Option value="-1">全部</Select.Option>
<Select.Option value={0}>默认</Select.Option>
<Select.Option value={1}>微信</Select.Option>
<Select.Option value={2}>支付宝</Select.Option>
<Select.Option value={3}>POS</Select.Option>
<Select.Option value={4}>储值卡</Select.Option>
</OptGroup>
</Select>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
保存
</Button>
</Form.Item>
</Form>
</Modal>
);
};

export default CreateForm;

+ 191
- 0
src/pages/shopmanage/member/membertag/components/memberInfoList.jsx View File

@@ -0,0 +1,191 @@
import { PlusOutlined } from '@ant-design/icons';
import { Popconfirm, Modal, Button, message, Input, Drawer } from 'antd';
import React, { useEffect, useState, useRef } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import ProDescriptions from '@ant-design/pro-descriptions';
// import CreateForm from './CreateMemberInfoForm';
import api from '../services';

const key = 'message';

const memberInfoListManage = (props) => {
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);

//分配会员

function pushMemberTagInfo(value) {
try {
api
.AddOrUpdateMemberTagInfo({
ids: selectedRowsState.map((item, index) => item.id),
memberTag_Id: props.values.id,
platformType: value.platformType,
})
.then((r) => {
if (r.data) {
message.success('分配会员成功!!!!');
} else {
message.error('分配会员失败,请重试');
}
});
//刷新数据
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.error('分配会员失败,请重试');
}
}
const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key',
},
{
title: '头像',
dataIndex: 'headImgUrl',
search: false,
hideInForm: true,
render: (_, record) => (
<img src={record.headImgUrl} style={{ width: '45px', height: '45px' }}></img>
),
},
{
title: '会员昵称',
dataIndex: 'nickName',
valueType: 'textarea',
},
{
title: '真实姓名',
dataIndex: 'realName',
valueType: 'textarea',
},
{
title: '性别',
dataIndex: 'sex',
search: false,
valueEnum: {
0: { text: '未知', status: 'Processing' },
1: { text: '男', status: 'Processing' },
2: { text: '女', status: 'Success' },
},
},
{
title: '电话',
dataIndex: 'phone',
valueType: 'textarea',
},
{
title: '状态',
dataIndex: 'status',
valueEnum: {
0: {
text: '正常',
status: 'Processing',
},
1: {
text: '停用',
status: 'Success',
},
},
},
];

return (
<Modal
width={1200}
bodyStyle={{ padding: '32px 40px 48px' }}
destroyOnClose
title={(props.values == undefined ? '' : props.values.name) + '分配会员'}
search={false}
visible={props.memberInfoModalVisible}
footer={false}
onCancel={() => props.onCancel()}
maskClosable={false}
centered={true}
>
<PageContainer
header={{
title: '',
breadcrumb: {},
}}
>
<ProTable
headerTitle="会员信息"
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {

if (selectedRowsState.length == 0) {
message.error('请选择需要分配平台的会员的数据!!');
} else {
//handleModalVisible(false);
var success = false;
var success = pushMemberTagInfo(props.values);
if (success) {
setSelectedRows([]);
handleModalVisible(false);
props.onCancel();
}
}
}}
>
分配
</Button>,
]}
request={async (params) => {
var data = [];
var total = 0;
await api.GetMemberInfoPageAsync(params).then((r) => {
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
/>
{/* <CreateForm
onFinish={async (value) => {
var success = false;
var success = pushMemberTagInfo(value);
if (success) {
handleModalVisible(false);
}
}}
onCancel={() => {
//分配数据
handleModalVisible(false);
setCurrentRow(undefined);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
/> */}
</PageContainer>
</Modal>
);
};

export default memberInfoListManage;

+ 369
- 0
src/pages/shopmanage/member/membertag/index.jsx View File

@@ -0,0 +1,369 @@
import { DropboxOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, message, Input, Drawer, Popconfirm } from 'antd';
import React, { useState, useRef, useEffect } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import ProDescriptions from '@ant-design/pro-descriptions';
import CreateForm from './components/CreateForm';
import MemberInfoTable from './components/memberInfoList';
import api from './services';

//页面 相当于 class
const MemberTagManage = () => {
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
/** 分布更新窗口的弹窗 */

const [showDetail, setShowDetail] = useState(false);
//绑定
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
//选中的行
const [selectedRowsState, setSelectedRows] = useState([]);

//分配会员
const [memberInfoModalVisible, setMemberInfoModalVisible] = useState(false);
/**
* 添加节点
*
* @param fields
*/
function handleAdd(fields) {
try {
fields.status=0;
api.addMemberTag(JSON.stringify(fields)).then((r) => {
if (r.data) {
message.success('添加成功');
//刷新数据
actionRef.current.reloadAndRest();
} else {
message.success('添加失败请重试!');
}
});
return true;
} catch (error) {
message.error('添加失败请重试!');
return false;
}
}

/**
* 更新节点
*
* @param fields
*/

function handleUpdate(fields) {
try {
api.updateMemberTag(fields).then((r) => {
if (r.data) {
message.success('更新成功');
actionRef.current.reloadAndRest();
} else {
message.error('更新失败请重试!');
}
});
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.error('更新失败请重试!');
return false;
}
}

/**
* 删除节点
*
* @param selectedRows
*/
function handleRemove() {
try {
api.removeMemberTag(selectedRowsState.map((item, index) => item.id)).then((r) => {
if (r.data) {
message.success('删除成功,即将刷新');
} else {
message.error('删除失败,请重试');
}
});
//刷新数据
actionRef.current.reloadAndRest();
return true;
} catch (error) {
message.error('删除失败,请重试');
}
}

/** 国际化配置 */

const columns = [
{
title: '主键',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
render: (dom, entity) => {
return (
<a
onClick={() => {
setCurrentRow(entity);
setShowDetail(true);
}}
>
{dom}
</a>
);
},
},
{
title: '名称',
dataIndex: 'name',
valueType: 'textarea',
ellipsis: true,
},
{
title: '平台',
dataIndex: 'platformType',
hideInForm: true,
valueEnum: {
0: {
text: '默认平台',
defaultPlatformType: 'Processing',
},
1: {
text: '微信',
defaultPlatformType: 'Success',
},
2: {
text: '支付宝',
defaultPlatformType: 'Default',
},
3: {
text: 'POS',
defaultPlatformType: 'Default',
},
4: {
text: '储值卡',
defaultPlatformType: 'Default',
},
},
},
{
title: '状态',
dataIndex: 'status',
hideInForm: true,
hideInSearch: true,
valueEnum: {
0: {
text: '正常',
status: 'Processing',
},
1: {
text: '停用',
status: 'Success',
},
},
},
{
title: '创建时间',
dataIndex: 'createAt',
valueType: 'date',
hideInSearch: true,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 150,
render: (_, record) => [
<a
key="config"
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
}}
>
更新
</a>,
<Popconfirm
key="primary"
type="primary"
title="确认删除吗"
okText="是"
cancelText="否"
onConfirm={() => {
//handleRemoveSingle(record.id);
api.removeMemberTag([record.id]).then((r) => {
if (r.data) {
message.success('删除成功,即将刷新');
actionRef.current.reloadAndRest();
} else {
message.error('删除失败,请重试');
}
});
}}
onCancel={() => {}}
>
<a href="#">删除</a>
</Popconfirm>,
// <a
// key="primary"
// onClick={() => {
// setCurrentRow(record);
// setMemberInfoModalVisible(true);
// }}
// >
// {' '}
// 分配会员平台
// </a>,
],
},
];

return (
<PageContainer header={{
title: '',
breadcrumb: {},
}}>
<ProTable
pagination={{
pageSize: 10
}}
scroll={{
x: 1300,
}}
headerTitle="会员标签管理"
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
columns={columns}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleModalVisible(true);
}}
>
<PlusOutlined /> 新建
</Button>,
]}
//数据绑定
request={async (params) => {
var memberTagData = [];
var total = 0;
await api.memberTagList(params).then((r) => {
memberTagData = r.data.data;
memberTagData.forEach((x) => {
x.status = x.status.toString();
x.platformType = x.platformType.toString();
});
total = r.data.total;
});
return {
data: memberTagData,
success: true,
total: total,
};
}}
// 每行选择点击事件
// rowSelection={{
// onChange: (_, selectedRows) => {
// setSelectedRows(selectedRows);
// },
// }}
></ProTable>
{selectedRowsState?.length > 0 && (
<FooterToolbar
extra={
<div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowsState.length}
</a>{' '}
项 &nbsp;&nbsp;
</div>
}
>
<Button
onClick={() => {
handleRemove(selectedRowsState);
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}
type="primary"
key="primary"
>
批量删除
</Button>
</FooterToolbar>
)}
{/* 会员标签管理(新增,修改) */}
<CreateForm
isAdd="true"
onFinish={async (value) => {
var success = false;
if (value.id) {
success = await handleUpdate(value);
setCurrentRow(undefined);
} else {
success = await handleAdd(value);
}
if (success) {
handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reloadAndRest();
}
}
}}
onCancel={() => {
setCurrentRow(undefined);
handleModalVisible(false);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
/>
<Drawer
width={600}
visible={showDetail}
onClose={() => {
setCurrentRow(undefined);
setShowDetail(false);
}}
closable={false}
>
{currentRow?.name && (
<ProDescriptions
column={2}
title={currentRow?.name}
request={async () => ({
data: currentRow || {},
})}
params={{
id: currentRow?.name,
}}
columns={columns}
/>
)}
</Drawer>
{/* 分配会员 */}
<MemberInfoTable
onCancel={() => {
setMemberInfoModalVisible(false);
setCurrentRow({});
}}
memberInfoModalVisible={memberInfoModalVisible}
values={currentRow}
/>
</PageContainer>
);
};

export default MemberTagManage;

+ 48
- 0
src/pages/shopmanage/member/membertag/services.js View File

@@ -0,0 +1,48 @@
// @ts-ignore

/* eslint-disable */
import { defaultActionRender } from '@ant-design/pro-utils/lib/useEditableArray';
import { request } from 'umi';
import { getDataBaseUrl,getStoremanagement } from '@/global_data';

export default {
/** 获取会员标签信息 sdsa GET /kitchen/api/rule */
memberTagList(data) {
return request(getStoremanagement()+`/api/MemberTagService/MemberTagQueryDto`, {
method: 'POST',
data: data,
// params: { ...params },
// ...(options || {}),
});
},
/** 新建会员标签信息 POST /kitchen/api/rule */
addMemberTag(data) {
// http://localhost:7002
return request(getStoremanagement()+`/api/MemberTagService/AddMemberTag`, {
method: 'POST',
// type:'json',
data: data,
// ...(options || {}),
});
},

/** 修改会员标签信息 POST /kitchen/api/rule */
updateMemberTag(data) {
// http://localhost:7002
return request(getStoremanagement()+`/api/MemberTagService/UpdateMemberTag`, {
method: 'post',
// type:'json',
data: data,
// ...(options || {}),
});
},

/** 删除会员标签信息 POST /kitchen/api/rule */
removeMemberTag(data) {
return request(getStoremanagement()+`/api/MemberTagService/DelMemberTag?Id=` + data, {
method: 'DELETE',
// ...(options || {}),
});
},

};

+ 6
- 6
src/pages/shopmanage/storeGoodsInfo/components/CreateFoodMeun.jsx View File

@@ -35,12 +35,12 @@ const CreateForm = (props) => {
</Form.Item>

<Form.Item>
<Button htmlType="button" style={{float:'right',left:10}} onClick={props.onCancel} >
取消
</Button>
<Button type="primary" htmlType="submit" style={{float:'right'}} >
保存
</Button>
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} >
确认
</Button>
<Button htmlType="button" style={{ float: 'right' }} onClick={props.onCancel} >
取消
</Button>
</Form.Item>
</Form>
</Modal>


Loading…
Cancel
Save