960 lines
42 KiB
TypeScript
960 lines
42 KiB
TypeScript
// 成长值规则配置 成长规则配置
|
|
import React, { useRef, useState, Suspense } from 'react';
|
|
import moment from 'moment'; // 时间相关引用,没有使用可以删除
|
|
import numeral from "numeral"; // 数字相关引用,没有使用可以删除
|
|
import { connect } from 'umi';
|
|
|
|
import useRequest from '@ahooksjs/use-request'; // 请求数据的引用
|
|
import Draggable from 'react-draggable';
|
|
import SubMenu from "antd/lib/menu/SubMenu";
|
|
import ProTable from '@ant-design/pro-table';
|
|
import ProDescriptions from '@ant-design/pro-descriptions';
|
|
import ProForm, { ProFormDatePicker, ProFormDateTimePicker, ProFormMoney, ProFormSelect, ProFormText, ProFormTextArea, ProFormUploadButton } from '@ant-design/pro-form';
|
|
import { MenuFoldOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
import { Button, Col, Drawer, message, Row, Popconfirm, Space, Image, Modal, Form, Switch, Upload, Tooltip, Descriptions, TreeSelect } from 'antd';
|
|
|
|
import type { CurrentUser } from "umi";
|
|
import type { ConnectState } from '@/models/connect';
|
|
import type { ActionType, ProColumns } from '@ant-design/pro-table';
|
|
import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
|
|
import type { FormInstance } from 'antd';
|
|
|
|
import { getFieldEnumTree, getFieldEnumName } from "@/services/options"; // 枚举的引用,没有使用可以删除
|
|
import { handleDeleteGROWTHSETTING, handleGetGROWTHSETTINGList, handleSynchroGROWTHSETTING } from '../service';
|
|
import session from '@/utils/session';
|
|
import PageTitleBox from '@/components/PageTitleBox';
|
|
import ModalFooter from '../scenicSpotConfig/component/modalFooter';
|
|
import GrowthConfig from './components/growthConfig';
|
|
import { handleSetlogSave } from '@/utils/format';
|
|
import MembershipTypeConfig from './components/MEMBERSHIPTYPEConfig';
|
|
|
|
const { confirm } = Modal;
|
|
|
|
|
|
const GrowthValueRuleConfig: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => {
|
|
const { currentUser } = props
|
|
const actionRef = useRef<ActionType>();
|
|
const formRef = useRef<FormInstance>();
|
|
const [currentRow, setCurrentRow] = useState<any>();
|
|
const [showDetail, setShowDetail] = useState<boolean>();
|
|
const [modalVisible, handleModalVisible] = useState<boolean>();
|
|
const [showConfig, setShowConfig] = useState<boolean>();
|
|
const [showTypeConfig, setShowTypeConfig] = useState<boolean>();
|
|
const [confirmLoading, handleConfirmLoading] = useState<boolean>(false) // 弹出框的内容表单是否在提交
|
|
const [searchParams, setSearchParams] = useState<any>();
|
|
|
|
// 会员成长值枚举
|
|
let GROWTHTYPEList = session.get('GROWTHTYPEList')
|
|
let GROWTHTYPEObj = session.get('GROWTHTYPEObj')
|
|
let MEMBERSHIPTYPEYNObj = session.get('MEMBERSHIPTYPEYNObj')
|
|
let MEMBERSHIPTYPEYNList = session.get('MEMBERSHIPTYPEYNList')
|
|
let MEMBERSHIPLEVELYNObj = session.get('MEMBERSHIPLEVELYNObj')
|
|
let MEMBERSHIPLEVELYNList = session.get('MEMBERSHIPLEVELYNList')
|
|
|
|
|
|
// 弹出框拖动效果
|
|
const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置
|
|
const [disabled, setDraggleDisabled] = useState<boolean>() // 是否拖动
|
|
const draggleRef = React.createRef<any>()
|
|
// 初始会员等级列表
|
|
const [defaultMemberLevel, setDefaultMemberLevel] = useState<any>(MEMBERSHIPLEVELYNList)
|
|
// 晋升后会员等级列表
|
|
const [promotionMemberLevel, setPromotionMemberLevel] = useState<any>(MEMBERSHIPLEVELYNList)
|
|
// 先存表格数据
|
|
const [tableData, setTableData] = useState<any>([]);
|
|
// 判断是不是第一次进入页面
|
|
const [isFirst, setIsFirst] = useState<boolean>(true)
|
|
|
|
const onDraggaleStart = (event, uiData) => {
|
|
const { clientWidth, clientHeight } = window.document.documentElement;
|
|
const targetRect = draggleRef.current?.getBoundingClientRect();
|
|
if (!targetRect) {
|
|
return;
|
|
}
|
|
setBounds({
|
|
left: -targetRect.left + uiData.x,
|
|
right: clientWidth - (targetRect.right - uiData.x),
|
|
top: -targetRect.top + uiData.y,
|
|
bottom: clientHeight - (targetRect.bottom - uiData.y),
|
|
});
|
|
};
|
|
// 拖动结束
|
|
// 定义列表字段内容
|
|
const columns: any = [
|
|
{
|
|
dataIndex: 'GROWTHSETTING_TYPE',
|
|
title: '规则类型',
|
|
width: 120,
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
valueType: 'select',
|
|
// valueEnum: GROWTHTYPEObj
|
|
request: () => {
|
|
let GROWTHTYPEList = session.get('GROWTHTYPEList')
|
|
return GROWTHTYPEList
|
|
},
|
|
render: (_, record) => {
|
|
return record?.GROWTHSETTING_TYPE && GROWTHTYPEObj && GROWTHTYPEObj[record?.GROWTHSETTING_TYPE] ? <a onClick={() => {
|
|
console.log('recordrecordrecord', record);
|
|
|
|
handleSetlogSave(`查看【${record?.GROWTHSETTING_NAME}】规则详情`)
|
|
setCurrentRow({ ...record });
|
|
handleModalVisible(true);
|
|
}}>
|
|
{GROWTHTYPEObj[record?.GROWTHSETTING_TYPE]}
|
|
</a> : '-'
|
|
}
|
|
},
|
|
// {
|
|
// dataIndex: 'GROWTHSETTING_NAME',
|
|
// title: '规则名称',
|
|
// align: 'center',
|
|
// width: 120,
|
|
// hideInSearch: true,
|
|
// hideInDescriptions: true,
|
|
// render: (_, record) => {
|
|
// return record?.GROWTHSETTING_NAME ? <a onClick={() => {
|
|
// handleSetlogSave(`查看【${record?.GROWTHSETTING_NAME}】规则详情`)
|
|
// setCurrentRow({ ...record });
|
|
// handleModalVisible(true);
|
|
// }}>{record?.GROWTHSETTING_NAME}</a> : '-'
|
|
// }
|
|
// },
|
|
{
|
|
dataIndex: 'MEMBERSHIP_TYPE',
|
|
title: '会员类型',
|
|
align: 'center',
|
|
width: 120,
|
|
// hideInSearch: true,
|
|
valueType: 'select',
|
|
// valueEnum: MEMBERSHIPTYPEYNObj
|
|
request: async () => {
|
|
return MEMBERSHIPTYPEYNList
|
|
}
|
|
},
|
|
{
|
|
dataIndex: 'MEMBERSHIP_LEVEL',
|
|
title: '会员等级',
|
|
align: 'center',
|
|
width: 120,
|
|
hideInSearch: true,
|
|
valueType: 'select',
|
|
valueEnum: MEMBERSHIPLEVELYNObj
|
|
},
|
|
{
|
|
dataIndex: 'PROMOTION_LEVEL',
|
|
title: '晋升等级',
|
|
width: 120,
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
valueEnum: MEMBERSHIPLEVELYNObj
|
|
},
|
|
{
|
|
dataIndex: 'GROWTH_VALUE',
|
|
title: '所需成长值',
|
|
width: 120,
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
// {
|
|
// dataIndex: 'GROWTHDAILY_CAP',
|
|
// title: '每日上限',
|
|
// width: 120,
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
{
|
|
dataIndex: 'GROWTHTOTAL_CAP',
|
|
title: '晋升后成长值',
|
|
width: 120,
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
// {
|
|
// dataIndex: 'PROVINCE_CODE',
|
|
// title: '省份编码',
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
// {
|
|
// dataIndex: 'OWNERUNIT_NAME',
|
|
// title: '业主单位名称',
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
{
|
|
dataIndex: 'GROWTHSETTING_STATE',
|
|
title: '有效状态',
|
|
width: 120,
|
|
align: 'center',
|
|
valueType: 'select',
|
|
valueEnum: {
|
|
"0": "无效",
|
|
"1": "有效",
|
|
},
|
|
initialValue: "1"
|
|
},
|
|
// {
|
|
// dataIndex: 'STAFF_NAME',
|
|
// title: '操作人员',
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
// {
|
|
// dataIndex: 'OPERATE_DATE',
|
|
// title: '操作时间',
|
|
// valueType: 'fromNow',
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
{
|
|
dataIndex: 'GROWTHSETTING_DESC',
|
|
title: '备注说明',
|
|
width: 250,
|
|
ellipsis: true,
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
// {
|
|
// dataIndex: 'option',
|
|
// title: '操作',
|
|
// width: 120,
|
|
// align: 'center',
|
|
// valueType: 'option',
|
|
// hideInSearch: true,
|
|
// render: (_, record) => {
|
|
// return (
|
|
// <Space>
|
|
// <a
|
|
// onClick={() => {
|
|
// setCurrentRow({ ...record });
|
|
// handleModalVisible(true);
|
|
// }}
|
|
// >
|
|
// 编辑
|
|
// </a>
|
|
// <Popconfirm
|
|
// title="确认删除该会员成长值配置列表信息吗?"
|
|
// onConfirm={async () => {
|
|
// await handelDelete(record.GROWTHSETTING_ID);
|
|
// }}
|
|
// >
|
|
// <a>删除</a>
|
|
// </Popconfirm>
|
|
// </Space>
|
|
// );
|
|
// },
|
|
// },
|
|
];
|
|
|
|
const handelDelete = async (id: number) => {
|
|
const result = await handleDeleteGROWTHSETTING({
|
|
GROWTHSETTINGId: id
|
|
});
|
|
if (result.Result_Code !== 100) {
|
|
message.error(`${result.Result_Desc}` || `${result.Result_Code}:删除失败`);
|
|
} else {
|
|
message.success('删除成功!');
|
|
handleSetlogSave(`删除【${currentRow?.GROWTHSETTING_NAME}】成功`)
|
|
actionRef.current?.reload()
|
|
handleConfirmLoading(false)
|
|
handleModalVisible(false)
|
|
}
|
|
};
|
|
|
|
const handleAddUpdate = async (res: any) => {
|
|
let req: any = {}
|
|
|
|
if (res?.GROWTHSETTING_ID) {
|
|
req = {
|
|
...currentRow,
|
|
...res
|
|
}
|
|
} else {
|
|
req = {
|
|
...res,
|
|
ADDTIME: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
STAFF_ID: currentUser?.ID,
|
|
STAFF_NAME: currentUser?.Name,
|
|
OWNERUNIT_ID: currentUser?.OwnerUnitId,
|
|
OWNERUNIT_NAME: currentUser?.OwnerUnitName,
|
|
PROVINCE_CODE: currentUser?.ProvinceCode
|
|
}
|
|
}
|
|
const data = await handleSynchroGROWTHSETTING(req);
|
|
if (data.Result_Code === 100) {
|
|
handleSetlogSave(`${currentRow?.GROWTHSETTING_ID ? '更新' : '新增'}【${data.Result_Data.GROWTHSETTING_NAME}】成功`)
|
|
message.success(data.Result_Desc)
|
|
formRef?.current?.resetFields()
|
|
setCurrentRow(undefined)
|
|
handleModalVisible(false)
|
|
actionRef.current?.reload()
|
|
} else {
|
|
message.error(data.Result_Desc)
|
|
}
|
|
};
|
|
|
|
|
|
// 支持会员类型单个选择或者多个选择的
|
|
const handleNewAddUpdate = (newValue: any, newList: any) => {
|
|
// newValue 表单数据 会员类型的数组 选择单个或所有类型
|
|
|
|
// 入参列表
|
|
let reqList: any = []
|
|
// 入参列表的提示信息 更新的
|
|
let reqListUpdateMsg: any = []
|
|
// 入参列表的提示信息 新增的
|
|
let reqListAddMsg: any = []
|
|
|
|
// for 循环 遍历去调用 批量新增
|
|
for (let i = 0; i < newList.length; i++) {
|
|
let nowItem = newList[i];
|
|
|
|
// 找到当前项的会员类型 会员等级 规则类型 外面表格数据是否已经存在了
|
|
console.log('nowItemnowItemnowItemnowItem', nowItem);
|
|
console.log('table', tableData);
|
|
|
|
let req: any = {}
|
|
if (tableData && tableData.length > 0) {
|
|
tableData.forEach((item: any) => {
|
|
// 判断 会员类型、会员等级、规则类型 是否一致
|
|
if (Number(item.MEMBERSHIP_TYPE) === Number(nowItem.value) && Number(newValue?.MEMBERSHIP_LEVEL) === Number(item.MEMBERSHIP_LEVEL) && Number(newValue?.GROWTHSETTING_TYPE) === Number(item.GROWTHSETTING_TYPE) && item.GROWTHSETTING_STATE === 1) {
|
|
console.log('itemitemitemitem', item);
|
|
|
|
req = {
|
|
...item
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
// 如果req 里面 有 GROWTHSETTING_ID 说明是更新的
|
|
console.log('reqreqreqreqreq', req);
|
|
if (req?.GROWTHSETTING_ID) {
|
|
reqList.push({
|
|
...req,
|
|
...newValue,
|
|
MEMBERSHIP_TYPE: nowItem.value
|
|
})
|
|
reqListUpdateMsg.push(`${nowItem.label}【${GROWTHTYPEObj[newValue.GROWTHSETTING_TYPE]}】${MEMBERSHIPLEVELYNObj[newValue.PROMOTION_LEVEL]}`)
|
|
} else {
|
|
req = {
|
|
...newValue,
|
|
MEMBERSHIP_TYPE: nowItem.value
|
|
}
|
|
reqList.push(req)
|
|
reqListAddMsg.push(`${nowItem.label}【${GROWTHTYPEObj[newValue.GROWTHSETTING_TYPE]}】${MEMBERSHIPLEVELYNObj[newValue.PROMOTION_LEVEL]}`)
|
|
}
|
|
}
|
|
|
|
console.log('reqListreqListreqListreqList', reqList);
|
|
console.log('reqListUpdateMsgreqListUpdateMsgreqListUpdateMsg', reqListUpdateMsg);
|
|
console.log('reqListAddMsgreqListAddMsgreqListAddMsgreqListAddMsg', reqListAddMsg);
|
|
|
|
confirm({
|
|
title: '提示',
|
|
content: `本次操作将 ${reqListUpdateMsg && reqListUpdateMsg.length > 0 ? '更新:' + reqListUpdateMsg.toString() : ""}${reqListAddMsg && reqListAddMsg.length > 0 ? ',新增:' + reqListAddMsg.toString() : ""},是否确认此次操作?`,
|
|
width: 600,
|
|
icon: <ExclamationCircleOutlined />,
|
|
async onOk() {
|
|
let isOK: boolean = await handleBatchUpdate(reqList)
|
|
if (isOK) {
|
|
formRef?.current?.resetFields()
|
|
setCurrentRow(undefined)
|
|
handleModalVisible(false)
|
|
actionRef.current?.reload()
|
|
}
|
|
},
|
|
onCancel() {
|
|
|
|
|
|
},
|
|
});
|
|
}
|
|
|
|
// 批量更新的方法
|
|
const handleBatchUpdate = async (reqList: any) => {
|
|
// reqList 入参列表
|
|
for (let i = 0; i < reqList.length; i++) {
|
|
let res: any = reqList[i]
|
|
let req: any = {}
|
|
if (res?.GROWTHSETTING_ID) {
|
|
req = {
|
|
...res
|
|
}
|
|
} else {
|
|
req = {
|
|
...res,
|
|
ADDTIME: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
STAFF_ID: currentUser?.ID,
|
|
STAFF_NAME: currentUser?.Name,
|
|
OWNERUNIT_ID: currentUser?.OwnerUnitId,
|
|
OWNERUNIT_NAME: currentUser?.OwnerUnitName,
|
|
PROVINCE_CODE: currentUser?.ProvinceCode
|
|
}
|
|
}
|
|
const data = await handleSynchroGROWTHSETTING(req);
|
|
console.log('datadatadatadata', data);
|
|
handleSetlogSave(`${currentRow?.GROWTHSETTING_ID ? '更新' : '新增'}【${data.Result_Data.GROWTHSETTING_NAME}】成功`)
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// 拿到最全的规则的数据
|
|
const handleGetAllRuleData = async () => {
|
|
const req: any = {
|
|
searchParameter: {
|
|
PROVINCE_CODE: currentUser?.ProvinceCode || "",
|
|
OWNERUNIT_ID: 911,
|
|
GROWTHSETTING_STATE: "",
|
|
MEMBERSHIP_TYPES: ""
|
|
},
|
|
SortStr: "MEMBERSHIP_TYPE,MEMBERSHIP_LEVEL,PROMOTION_LEVEL desc",
|
|
PageIndex: 1,
|
|
PageSize: 999999
|
|
}
|
|
const data = await handleGetGROWTHSETTINGList(req);
|
|
setTableData(data.List)
|
|
}
|
|
|
|
return (
|
|
<PageContainer header={{
|
|
title: '',
|
|
breadcrumb: {}
|
|
}}>
|
|
<ProTable
|
|
style={{ height: 'calc(100vh - 135px)', background: '#fff' }}
|
|
scroll={{ y: 'calc(100vh - 430px)' }}
|
|
rowKey={(record) => {
|
|
return `${record?.GROWTHSETTING_ID}`
|
|
}}
|
|
formRef={formRef}
|
|
headerTitle={<PageTitleBox props={props} />}
|
|
actionRef={actionRef}
|
|
bordered
|
|
search={{ span: 6, labelWidth: 'auto' }}
|
|
// 请求数据
|
|
request={async (params, sorter) => {
|
|
const req: any = {
|
|
searchParameter: {
|
|
PROVINCE_CODE: currentUser?.ProvinceCode || "",
|
|
OWNERUNIT_ID: 911,
|
|
GROWTHSETTING_STATE: params?.GROWTHSETTING_STATE,
|
|
MEMBERSHIP_TYPES: params?.MEMBERSHIP_TYPE
|
|
},
|
|
SortStr: "MEMBERSHIP_TYPE,MEMBERSHIP_LEVEL,PROMOTION_LEVEL desc",
|
|
PageIndex: 1,
|
|
PageSize: 20
|
|
}
|
|
const data = await handleGetGROWTHSETTINGList(req);
|
|
if (data.List && data.List.length > 0) {
|
|
handleSetlogSave(`查看了成长规则配置列表`)
|
|
// if (isFirst) {
|
|
// setTableData(data.List);
|
|
// setIsFirst(false)
|
|
// }
|
|
handleGetAllRuleData()
|
|
return { data: data.List, success: true, total: data.TotalCount }
|
|
}
|
|
return { data: [], success: true }
|
|
}}
|
|
columns={columns}
|
|
toolbar={{
|
|
actions: [
|
|
// 新增按钮
|
|
<Button
|
|
key="new"
|
|
icon={<PlusOutlined rev={undefined} />}
|
|
type="primary"
|
|
onClick={() => {
|
|
handleModalVisible(true);
|
|
}}
|
|
>
|
|
会员成长值配置
|
|
</Button>,
|
|
// 配置成长值规则枚举
|
|
<Button
|
|
key="new"
|
|
type="primary"
|
|
onClick={() => {
|
|
setShowConfig(true);
|
|
}}
|
|
>
|
|
成长值枚举配置
|
|
</Button>,
|
|
// 配置会员类型枚举
|
|
<Button
|
|
key="new"
|
|
type="primary"
|
|
onClick={() => {
|
|
setShowTypeConfig(true);
|
|
}}
|
|
>
|
|
会员类型枚举配置
|
|
</Button>
|
|
],
|
|
}}
|
|
pagination={{ defaultPageSize: 10 }}
|
|
/>
|
|
<Drawer
|
|
width={600}
|
|
visible={showDetail}
|
|
onClose={() => {
|
|
setCurrentRow(undefined);
|
|
setShowDetail(false);
|
|
}}
|
|
closable={false}
|
|
>
|
|
{currentRow?.GROWTHSETTING_ID && (
|
|
<ProDescriptions
|
|
column={2}
|
|
title={currentRow?.GROWTHSETTING_NAME}
|
|
request={async () => ({
|
|
data: currentRow || {},
|
|
})}
|
|
params={{
|
|
id: currentRow?.GROWTHSETTING_ID,
|
|
}}
|
|
columns={columns}
|
|
/>
|
|
)}
|
|
</Drawer>
|
|
|
|
<Modal
|
|
title={
|
|
<div
|
|
className='GrowthValueModal'
|
|
style={{
|
|
width: '100%',
|
|
cursor: 'move',
|
|
}}
|
|
onMouseOver={() => {
|
|
if (disabled) {
|
|
setDraggleDisabled(false)
|
|
}
|
|
}}
|
|
onMouseOut={() => {
|
|
setDraggleDisabled(true)
|
|
}}
|
|
|
|
onFocus={() => { }}
|
|
onBlur={() => { }}
|
|
>
|
|
{currentRow ? '更新会员成长值配置' : '新建会员成长值配置'}
|
|
</div>
|
|
}
|
|
destroyOnClose={true}
|
|
width={900}
|
|
bodyStyle={{
|
|
height: '700px', // 你可以根据需要调整高度
|
|
overflowY: 'auto',
|
|
}}
|
|
footer={<ModalFooter
|
|
hideDelete={!currentRow?.GROWTHSETTING_ID}
|
|
handleDelete={async () => {
|
|
await handelDelete(currentRow?.GROWTHSETTING_ID)
|
|
}}
|
|
handleCancel={() => {
|
|
handleConfirmLoading(false)
|
|
handleModalVisible(false)
|
|
}}
|
|
handleOK={() => {
|
|
formRef?.current?.validateFields().then(() => {
|
|
handleConfirmLoading(true)
|
|
formRef?.current?.submit()
|
|
})
|
|
}}
|
|
|
|
/>}
|
|
|
|
visible={modalVisible}
|
|
confirmLoading={confirmLoading}
|
|
afterClose={() => {
|
|
formRef.current?.resetFields();
|
|
setCurrentRow(undefined);
|
|
}}
|
|
onCancel={() => {
|
|
handleConfirmLoading(false)
|
|
handleModalVisible(false)
|
|
}}
|
|
|
|
onOk={async () => { // 提交框内的数据
|
|
formRef?.current?.validateFields().then(() => {
|
|
handleConfirmLoading(true)
|
|
formRef?.current?.submit()
|
|
})
|
|
}}
|
|
modalRender={(modal) => {
|
|
return <Draggable
|
|
disabled={disabled}
|
|
bounds={bounds}
|
|
onStart={(event, uiData) => onDraggaleStart(event, uiData)}
|
|
handle='.GrowthValueModal'
|
|
>
|
|
<div ref={draggleRef}>{modal}</div>
|
|
</Draggable>
|
|
}}
|
|
>
|
|
<ProForm
|
|
layout={'horizontal'}
|
|
formRef={formRef}
|
|
autoFocusFirstInput
|
|
submitter={false}
|
|
preserve={false}
|
|
labelCol={{ style: { width: 120 } }}
|
|
initialValues={currentRow?.GROWTHSETTING_ID ? {
|
|
...currentRow,
|
|
SCORESETTING_STATE: (currentRow?.GROWTHSETTING_STATE || currentRow?.GROWTHSETTING_STATE === 0) ? currentRow?.GROWTHSETTING_STATE : 1,
|
|
GROWTHSETTING_TYPE: currentRow?.GROWTHSETTING_TYPE ? currentRow?.GROWTHSETTING_TYPE.toString() : "",
|
|
// MEMBERSHIP_LEVEL: currentRow?.MEMBERSHIP_LEVEL ? currentRow?.MEMBERSHIP_LEVEL.toString() : "",
|
|
PROMOTION_LEVEL: currentRow?.PROMOTION_LEVEL ? currentRow?.PROMOTION_LEVEL.toString() : "",
|
|
// MEMBERSHIP_TYPE: currentRow?.MEMBERSHIP_TYPE ? currentRow?.MEMBERSHIP_TYPE.toString() : "",
|
|
} : {
|
|
MEMBERSHIP_TYPE: 1,
|
|
MEMBERSHIP_LEVEL: 1000,
|
|
PROMOTION_LEVEL: '2000',
|
|
GROWTH_VALUE: 1,
|
|
// GROWTHTOTAL_CAP: 1,
|
|
GROWTHSETTING_TYPE: '90'
|
|
}}
|
|
onFinish={async (values) => {
|
|
let newValue: any = { ...values };
|
|
if (currentRow) {
|
|
// 编辑数据
|
|
newValue = { ...currentRow, ...values, GROWTHSETTING_ID: currentRow.GROWTHSETTING_ID };
|
|
}
|
|
|
|
console.log('newValuenewValuenewValue', newValue);
|
|
|
|
let newList: any = []
|
|
if (newValue?.MEMBERSHIP_TYPE === 1) {
|
|
let list: any = JSON.parse(JSON.stringify(MEMBERSHIPTYPEYNList))
|
|
if (list && list.length > 0) {
|
|
list.forEach((item: any) => {
|
|
if (item.value < 9000 && Number(item.value) !== 1) {
|
|
newList.push({
|
|
label: item.label,
|
|
value: Number(item.value)
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
console.log('newListnewListnewListnewList', newList);
|
|
} else {
|
|
newList = [{ label: MEMBERSHIPTYPEYNObj[newValue.MEMBERSHIP_TYPE], value: newValue.MEMBERSHIP_TYPE }]
|
|
}
|
|
|
|
// 判断会员类型 是不是选了所有类型 所有类型的话 需要遍历操作下 不然就走正常的
|
|
handleNewAddUpdate(newValue, newList)
|
|
handleConfirmLoading(false)
|
|
|
|
// return
|
|
// if (newValue?.MEMBERSHIP_TYPE === 1) {
|
|
// let list: any = JSON.parse(JSON.stringify(MEMBERSHIPTYPEYNList))
|
|
// let newList: any = []
|
|
// if (list && list.length > 0) {
|
|
// list.forEach((item: any) => {
|
|
// if (item.value < 9000 && Number(item.value) !== 1) {
|
|
// newList.push({
|
|
// label: item.label,
|
|
// value: Number(item.value)
|
|
// })
|
|
// }
|
|
// })
|
|
// }
|
|
|
|
// console.log('newListnewListnewListnewList', newList);
|
|
|
|
// // 入参列表
|
|
// let reqList: any = []
|
|
// // 入参列表的提示信息 更新的
|
|
// let reqListUpdateMsg: any = []
|
|
// // 入参列表的提示信息 新增的
|
|
// let reqListAddMsg: any = []
|
|
|
|
// // for 循环 遍历去调用 批量新增
|
|
// for (let i = 0; i < newList.length; i++) {
|
|
// let nowItem = newList[i];
|
|
|
|
// // 找到当前项的会员类型 会员等级 规则类型 外面表格数据是否已经存在了
|
|
// console.log('nowItemnowItemnowItemnowItem', nowItem);
|
|
// console.log('table', tableData);
|
|
|
|
// let req: any = {}
|
|
// if (tableData && tableData.length > 0) {
|
|
// tableData.forEach((item: any) => {
|
|
// // 判断 会员类型、会员等级、规则类型 是否一致
|
|
// if (Number(item.MEMBERSHIP_TYPE) === Number(nowItem.value) && Number(newValue?.MEMBERSHIP_LEVEL) === Number(item.MEMBERSHIP_LEVEL) && Number(newValue?.GROWTHSETTING_TYPE) === Number(item.GROWTHSETTING_TYPE)) {
|
|
// req = {
|
|
// ...item
|
|
// }
|
|
// }
|
|
// })
|
|
// }
|
|
|
|
// // 如果req 里面 有 GROWTHSETTING_ID 说明是更新的
|
|
// console.log('reqreqreqreqreq', req);
|
|
// if (req?.GROWTHSETTING_ID) {
|
|
// reqList.push({
|
|
// ...req,
|
|
// ...newValue,
|
|
// MEMBERSHIP_TYPE: nowItem.value
|
|
// })
|
|
// reqListUpdateMsg.push(`${nowItem.label}【${GROWTHTYPEObj[newValue.GROWTHSETTING_TYPE]}】${MEMBERSHIPLEVELYNObj[newValue.PROMOTION_LEVEL]}`)
|
|
// } else {
|
|
// req = {
|
|
// ...newValue,
|
|
// MEMBERSHIP_TYPE: nowItem.value
|
|
// }
|
|
// reqList.push(req)
|
|
// reqListAddMsg.push(`${nowItem.label}【${GROWTHTYPEObj[newValue.GROWTHSETTING_TYPE]}】${MEMBERSHIPLEVELYNObj[newValue.PROMOTION_LEVEL]}`)
|
|
// }
|
|
// }
|
|
|
|
// console.log('reqListreqListreqListreqList', reqList);
|
|
// console.log('reqListUpdateMsgreqListUpdateMsgreqListUpdateMsg', reqListUpdateMsg);
|
|
// console.log('reqListAddMsgreqListAddMsgreqListAddMsgreqListAddMsg', reqListAddMsg);
|
|
|
|
|
|
|
|
// confirm({
|
|
// title: '提示',
|
|
// content: `本次操作将 ${reqListUpdateMsg && reqListUpdateMsg.length > 0 ? '更新:' + reqListUpdateMsg.toString() : ""}${reqListAddMsg && reqListAddMsg.length > 0 ? ',新增:' + reqListAddMsg.toString() : ""},是否确认此次操作?`,
|
|
// width: 600,
|
|
// icon: <ExclamationCircleOutlined />,
|
|
// async onOk() {
|
|
// let isOK: boolean = await handleBatchUpdate(reqList)
|
|
// if (isOK) {
|
|
// formRef?.current?.resetFields()
|
|
// setCurrentRow(undefined)
|
|
// handleModalVisible(false)
|
|
// actionRef.current?.reload()
|
|
// }
|
|
// },
|
|
// onCancel() {
|
|
|
|
|
|
// },
|
|
// });
|
|
|
|
// } else {
|
|
// await handleAddUpdate(newValue);
|
|
// }
|
|
}}
|
|
>
|
|
<Row gutter={8}>
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="GROWTHSETTING_TYPE"
|
|
label="规则类型"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: '请选择规则类型'
|
|
}
|
|
]}
|
|
request={() => {
|
|
let GROWTHTYPEList = session.get('GROWTHTYPEList')
|
|
let newList: any = []
|
|
if (GROWTHTYPEList && GROWTHTYPEList.length > 0) {
|
|
GROWTHTYPEList.forEach((item: any) => {
|
|
if (item.value === '90') {
|
|
newList.push(item)
|
|
}
|
|
})
|
|
}
|
|
return newList
|
|
}}
|
|
// options={GROWTHTYPEList}
|
|
/>
|
|
</Col>
|
|
{/* <Col span={12}>
|
|
<ProFormText
|
|
name="GROWTHSETTING_NAME"
|
|
label="规则名称"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: '请输入规则名称'
|
|
}
|
|
]}
|
|
/>
|
|
</Col> */}
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="MEMBERSHIP_TYPE"
|
|
label="会员类型"
|
|
// options={MEMBERSHIPTYPEYNList}
|
|
request={async () => {
|
|
let list: any = JSON.parse(JSON.stringify(MEMBERSHIPTYPEYNList))
|
|
let newList: any = []
|
|
if (list && list.length > 0) {
|
|
list.forEach((item: any) => {
|
|
if (item.value < 9000) {
|
|
newList.push({
|
|
label: item.label,
|
|
value: Number(item.value)
|
|
})
|
|
}
|
|
})
|
|
}
|
|
return newList
|
|
}}
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="MEMBERSHIP_LEVEL"
|
|
label="会员等级"
|
|
// options={}
|
|
request={async () => {
|
|
let list: any = JSON.parse(JSON.stringify(defaultMemberLevel))
|
|
let newList: any = []
|
|
if (list && list.length > 0) {
|
|
list.forEach((item: any) => {
|
|
if (Number(item.value) !== 1 && Number(item.value) < 9000) {
|
|
newList.push({
|
|
label: item.label,
|
|
value: Number(item.value),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
return newList
|
|
}}
|
|
fieldProps={{
|
|
onChange: (e: any) => {
|
|
console.log('e', e);
|
|
let newList: any = []
|
|
if (defaultMemberLevel && defaultMemberLevel.length > 0) {
|
|
defaultMemberLevel.forEach((item: any) => {
|
|
if (Number(item.value) !== 1 && Number(item.value) < 9000 && Number(e) < Number(item.value)) {
|
|
newList.push({
|
|
label: item.label,
|
|
value: item.value.toString(),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
formRef.current?.setFieldsValue({ PROMOTION_LEVEL: newList && newList.length > 0 ? newList[0].value : "" })
|
|
|
|
// console.log('promotionMemberLevel', promotionMemberLevel);
|
|
// if (promotionMemberLevel && promotionMemberLevel.length > 0) {
|
|
// let list: any = JSON.parse(JSON.stringify(promotionMemberLevel))
|
|
// list.forEach((item: any) => {
|
|
// item.disabled = false
|
|
// })
|
|
// list.forEach((item: any) => {
|
|
// if (Number(item.value) <= Number(e)) {
|
|
// item.disabled = true
|
|
// }
|
|
// })
|
|
// setPromotionMemberLevel(list)
|
|
// }
|
|
}
|
|
}}
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="PROMOTION_LEVEL"
|
|
label="晋升等级"
|
|
options={promotionMemberLevel}
|
|
disabled
|
|
tooltip="用户晋升后的目标等级,必须选择当前会员等级的下一级"
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormText
|
|
name="GROWTH_VALUE"
|
|
label="所需成长值"
|
|
tooltip="用户从当前等级晋升到下一等级需要累积的成长值"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: '请输入所需成长值'
|
|
}
|
|
]}
|
|
/>
|
|
</Col>
|
|
{/* <Col span={12}>
|
|
<ProFormText
|
|
name="GROWTHDAILY_CAP"
|
|
label="每日上限"
|
|
/>
|
|
</Col> */}
|
|
<Col span={12}>
|
|
<ProFormText
|
|
name="GROWTHTOTAL_CAP"
|
|
label="晋升后成长值"
|
|
tooltip="用户晋升到新等级后,系统自动设置的初始成长值"
|
|
/>
|
|
</Col>
|
|
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="GROWTHSETTING_STATE"
|
|
label="有效状态"
|
|
options={[
|
|
{ label: '有效', value: 1 },
|
|
{ label: '无效', value: 0 },
|
|
]}
|
|
initialValue={1}
|
|
/>
|
|
</Col>
|
|
|
|
<Col span={24}>
|
|
<ProFormTextArea
|
|
name="GROWTHSETTING_DESC"
|
|
label="备注说明"
|
|
/>
|
|
</Col>
|
|
</Row>
|
|
</ProForm>
|
|
</Modal>
|
|
|
|
<Modal
|
|
title={"成长值枚举配置"}
|
|
destroyOnClose={true}
|
|
width={1200}
|
|
bodyStyle={{
|
|
height: '700px', // 你可以根据需要调整高度
|
|
overflowY: 'auto',
|
|
}}
|
|
visible={showConfig}
|
|
footer={false}
|
|
onCancel={() => {
|
|
setShowConfig(false)
|
|
}}
|
|
>
|
|
<GrowthConfig />
|
|
</Modal>
|
|
|
|
|
|
<Modal
|
|
title={"会员类型枚举配置"}
|
|
destroyOnClose={true}
|
|
width={1200}
|
|
bodyStyle={{
|
|
height: '700px', // 你可以根据需要调整高度
|
|
overflowY: 'auto',
|
|
}}
|
|
visible={showTypeConfig}
|
|
footer={false}
|
|
onCancel={() => {
|
|
setShowTypeConfig(false)
|
|
}}
|
|
>
|
|
<MembershipTypeConfig />
|
|
</Modal>
|
|
</PageContainer>
|
|
);
|
|
};
|
|
export default connect(({ user }: ConnectState) => ({
|
|
currentUser: user.currentUser
|
|
}))(GrowthValueRuleConfig);
|