From 3f91fad89940c40ae98cbda30bf18456239e56aa Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Tue, 20 Feb 2024 16:12:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.js | 19 + .../memberInfo/components/CreateForm.jsx | 196 ++++++ .../memberInfo/components/IntegralRecord.jsx | 81 +++ .../shopmanage/member/memberInfo/index.jsx | 622 ++++++++++++++++++ .../shopmanage/member/memberInfo/service.js | 62 ++ .../membertag/components/CreateForm.jsx | 93 +++ .../components/CreateMemberInfoForm.jsx | 51 ++ .../membertag/components/memberInfoList.jsx | 191 ++++++ .../shopmanage/member/membertag/index.jsx | 369 +++++++++++ .../shopmanage/member/membertag/services.js | 48 ++ .../components/CreateFoodMeun.jsx | 12 +- 11 files changed, 1738 insertions(+), 6 deletions(-) create mode 100644 src/pages/shopmanage/member/memberInfo/components/CreateForm.jsx create mode 100644 src/pages/shopmanage/member/memberInfo/components/IntegralRecord.jsx create mode 100644 src/pages/shopmanage/member/memberInfo/index.jsx create mode 100644 src/pages/shopmanage/member/memberInfo/service.js create mode 100644 src/pages/shopmanage/member/membertag/components/CreateForm.jsx create mode 100644 src/pages/shopmanage/member/membertag/components/CreateMemberInfoForm.jsx create mode 100644 src/pages/shopmanage/member/membertag/components/memberInfoList.jsx create mode 100644 src/pages/shopmanage/member/membertag/index.jsx create mode 100644 src/pages/shopmanage/member/membertag/services.js diff --git a/config/routes.js b/config/routes.js index 42d5e29..dc3bf43 100644 --- a/config/routes.js +++ b/config/routes.js @@ -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', diff --git a/src/pages/shopmanage/member/memberInfo/components/CreateForm.jsx b/src/pages/shopmanage/member/memberInfo/components/CreateForm.jsx new file mode 100644 index 0000000..78235fe --- /dev/null +++ b/src/pages/shopmanage/member/memberInfo/components/CreateForm.jsx @@ -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 ( + { + props.onCancel(); + }} + //关闭时销毁 Modal 里的子元素 + destroyOnClose + > +
+ + + + + + + + + + + + + prevValues.platformType !== currentValues.platformType + } + > + {({ getFieldValue }) => + !getFieldValue('id') ? ( + + + + ) : null + } + + + + + + + + + + + + + 未知 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/* + + */} + + + + + prevValues.platformType !== currentValues.platformType + } + > + {({ getFieldValue }) => + (!props.isLook) ? ( + + + + ) : null + } + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/shopmanage/member/memberInfo/components/IntegralRecord.jsx b/src/pages/shopmanage/member/memberInfo/components/IntegralRecord.jsx new file mode 100644 index 0000000..30c2263 --- /dev/null +++ b/src/pages/shopmanage/member/memberInfo/components/IntegralRecord.jsx @@ -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 ( + { + props.onClose(); + }} + width={720} + visible={props.integralRecordVisible} + placement="right" + //关闭时销毁 Modal 里的子元素 + destroyOnClose> + + { + 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 }} + /> + ); +}; + +export default IntegralRecord; diff --git a/src/pages/shopmanage/member/memberInfo/index.jsx b/src/pages/shopmanage/member/memberInfo/index.jsx new file mode 100644 index 0000000..a993dfb --- /dev/null +++ b/src/pages/shopmanage/member/memberInfo/index.jsx @@ -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) => ( + + ), + }, + { + title: '昵称', + dataIndex: 'nickName', + valueType: 'textarea', + ellipsis: { + showTitle: true, + }, + hideInForm: true, + render: (_, record) => ( + {isBase64(record.nickName) ? decodeBPABase64(record.nickName) : record.nickName} + ), + }, + { + 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) => ( + + {record.memberTag.map(({ id, name }) => ( + + {name} + + ))} + + ), + }, + { + title: '创建时间', + dataIndex: 'createAt', + search: false, + width: 150, + valueType: 'textarea', + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + width: 300, + render: (_, record) => { + let template = [ + { + SetCreateModalVisible(true); + setCurrentRow(() => { + record.birthday = moment(record.birthday); + setIsLook(true); + return record; + }); + }} + > + 详情 + , + { + SetCreateModalVisible(true); + setCurrentRow(() => { + record.birthday = moment(record.birthday); + setIsLook(false); + return record; + }); + }} + > + 更新 + , + // { + // var data = { Id: record.id, platformType: 0, status: record.status == 0 ? 1 : 0 }; + // updateMemberStatus(data); + // }} + // okText="确定" + // cancelText="取消" + // > + // + // {record.status == 0 ? '禁用 ' : '启用'} + // + // , + + + { + getMemberTagAndInfo(record.id, 0); + setIsTagModalVisible(true); + setCurrentRow(() => { + return record; + }); + }} + > + 标签管理 + , + // { + // setCurrentRow(record); + // SetIntegralRecordVisible(true); + // }} + // > + // 积分记录 + // , + ]; + return template; + }, + }, + ]; + const onExpand = (expanded, record) => { + if (expanded) { + setdataRow(record.platformMemberInfos); + setDataRowKey([record.id]); + } else { + setDataRowKey([]); + } + }; + const expandedRowRender = (data) => { + return ( + ( + + ), + }, + { + title: '昵称', + dataIndex: 'nickName', + valueType: 'textarea', + hideInForm: true, + render: (_, record) => ( + + {isBase64(record.nickName) ? decodeBPABase64(record.nickName) : record.nickName} + + ), + }, + { + 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) => ( + <> + + {record.memberTag.map(({ id, name }) => ( + + {name} + + ))} + + + ), + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (_, record) => { + let template = [ + // { + // SetCreateModalVisible(true); + // setCurrentRow(() => { + // record.birthday = moment(record.birthday); + // return record; + // }); + // }} + // > + // 更新 + // , + // { + // var data = { + // Id: record.memberInfo_Id, + // platformType: record.platformType, + // status: record.status == 0 ? 1 : 0, + // }; + // updateMemberStatus(data); + // }} + // > + // {record.status == 0 ? '禁用 ' : '启用'} + // , + { + getMemberTagAndInfo(record.memberInfo_Id, record.platformType); + setIsTagModalVisible(true); + setCurrentRow(() => { + return record; + }); + PlatformMemberList(record.memberInfo_Id); + }} + > + 标签管理 + , + ]; + return template; + }, + }, + ]} + headerTitle={false} + search={false} + options={false} + dataSource={dataRow} + /> + ); + }; + return ( + + [ + , + ]} + 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} + /> + + {/* 修改会员 */} + { + // 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 || {}} + /> + + {/* 会员标签 */} + { + if ( + updateMemberTag( + currentRow.platformType, + currentRow.platformType == 0 ? currentRow.id : currentRow.memberInfo_Id, + ) + ) { + setIsTagModalVisible(false); + setDataRowKey([]); + } + }} + onCancel={() => { + setCurrentRow([]); + setIsTagModalVisible(false); + }} + > + <> + { + setCheckedTagList(list); + }} + /> + + + {/* 积分记录 */} + {/* { + SetIntegralRecordVisible(false); + }} + memberId={currentRow?.id} + integralRecordVisible={integralRecordVisible} + /> */} + + ); +}; + +export default MemberManage; diff --git a/src/pages/shopmanage/member/memberInfo/service.js b/src/pages/shopmanage/member/memberInfo/service.js new file mode 100644 index 0000000..4b012d0 --- /dev/null +++ b/src/pages/shopmanage/member/memberInfo/service.js @@ -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, + }); +} + diff --git a/src/pages/shopmanage/member/membertag/components/CreateForm.jsx b/src/pages/shopmanage/member/membertag/components/CreateForm.jsx new file mode 100644 index 0000000..dbd4b78 --- /dev/null +++ b/src/pages/shopmanage/member/membertag/components/CreateForm.jsx @@ -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 ( + { + props.onCancel(); + }} + destroyOnClose + maskClosable={false} + > +
+ + + + + + + + {/* + + */} + + + {/* + prevValues.mode !== currentValues.mode + } > + {({ getFieldValue }) => + (props.values.id) ? ( + + + + ) : null + } + */} + + + + {/* */} + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/shopmanage/member/membertag/components/CreateMemberInfoForm.jsx b/src/pages/shopmanage/member/membertag/components/CreateMemberInfoForm.jsx new file mode 100644 index 0000000..774fbe6 --- /dev/null +++ b/src/pages/shopmanage/member/membertag/components/CreateMemberInfoForm.jsx @@ -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 ( + { + props.onCancel(); + }} + centered={true} + destroyOnClose + > +
+ + + + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/shopmanage/member/membertag/components/memberInfoList.jsx b/src/pages/shopmanage/member/membertag/components/memberInfoList.jsx new file mode 100644 index 0000000..d7299a0 --- /dev/null +++ b/src/pages/shopmanage/member/membertag/components/memberInfoList.jsx @@ -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) => ( + + ), + }, + { + 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 ( + props.onCancel()} + maskClosable={false} + centered={true} + > + + [ + , + ]} + 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); + }, + }} + /> + {/* { + var success = false; + var success = pushMemberTagInfo(value); + if (success) { + handleModalVisible(false); + } + }} + onCancel={() => { + //分配数据 + handleModalVisible(false); + setCurrentRow(undefined); + }} + createModalVisible={createModalVisible} + values={currentRow || {}} + /> */} + + + ); +}; + +export default memberInfoListManage; diff --git a/src/pages/shopmanage/member/membertag/index.jsx b/src/pages/shopmanage/member/membertag/index.jsx new file mode 100644 index 0000000..f939667 --- /dev/null +++ b/src/pages/shopmanage/member/membertag/index.jsx @@ -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 ( + { + setCurrentRow(entity); + setShowDetail(true); + }} + > + {dom} + + ); + }, + }, + { + 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) => [ + { + handleModalVisible(true); + setCurrentRow(record); + }} + > + 更新 + , + { + //handleRemoveSingle(record.id); + api.removeMemberTag([record.id]).then((r) => { + if (r.data) { + message.success('删除成功,即将刷新'); + actionRef.current.reloadAndRest(); + } else { + message.error('删除失败,请重试'); + } + }); + }} + onCancel={() => {}} + > + 删除 + , + // { + // setCurrentRow(record); + // setMemberInfoModalVisible(true); + // }} + // > + // {' '} + // 分配会员平台 + // , + ], + }, + ]; + + return ( + + [ + , + ]} + //数据绑定 + 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); + // }, + // }} + > + {selectedRowsState?.length > 0 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + + } + > + + + )} + {/* 会员标签管理(新增,修改) */} + { + 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 || {}} + /> + { + setCurrentRow(undefined); + setShowDetail(false); + }} + closable={false} + > + {currentRow?.name && ( + ({ + data: currentRow || {}, + })} + params={{ + id: currentRow?.name, + }} + columns={columns} + /> + )} + + {/* 分配会员 */} + { + setMemberInfoModalVisible(false); + setCurrentRow({}); + }} + memberInfoModalVisible={memberInfoModalVisible} + values={currentRow} + /> + + ); +}; + +export default MemberTagManage; diff --git a/src/pages/shopmanage/member/membertag/services.js b/src/pages/shopmanage/member/membertag/services.js new file mode 100644 index 0000000..3da1eba --- /dev/null +++ b/src/pages/shopmanage/member/membertag/services.js @@ -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 || {}), + }); + }, + +}; diff --git a/src/pages/shopmanage/storeGoodsInfo/components/CreateFoodMeun.jsx b/src/pages/shopmanage/storeGoodsInfo/components/CreateFoodMeun.jsx index f3e9dff..2f0458c 100644 --- a/src/pages/shopmanage/storeGoodsInfo/components/CreateFoodMeun.jsx +++ b/src/pages/shopmanage/storeGoodsInfo/components/CreateFoodMeun.jsx @@ -35,12 +35,12 @@ const CreateForm = (props) => { - - + +