570 lines
22 KiB
TypeScript
570 lines
22 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';
|
|
|
|
|
|
|
|
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 [confirmLoading, handleConfirmLoading] = useState<boolean>(false) // 弹出框的内容表单是否在提交
|
|
const [searchParams, setSearchParams] = useState<any>();
|
|
|
|
// 会员成长值枚举
|
|
let GROWTHTYPEList = session.get('GROWTHTYPEList')
|
|
let GROWTHTYPEObj = session.get('GROWTHTYPEObj')
|
|
let MEMBERSHIP_TYPEList = session.get('MEMBERSHIP_TYPEList')
|
|
let MEMBERSHIP_TYPEObj = session.get('MEMBERSHIP_TYPEObj')
|
|
let MEMBERSHIPLEVELYNList = session.get('MEMBERSHIPLEVELYNList')
|
|
let MEMBERSHIPLEVELYNObj = session.get('MEMBERSHIPLEVELYNObj')
|
|
|
|
|
|
// 弹出框拖动效果
|
|
const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置
|
|
const [disabled, setDraggleDisabled] = useState<boolean>() // 是否拖动
|
|
const draggleRef = React.createRef<any>()
|
|
|
|
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
|
|
}
|
|
},
|
|
{
|
|
dataIndex: 'GROWTHSETTING_NAME',
|
|
title: '规则名称',
|
|
align: 'center',
|
|
width: 120,
|
|
hideInSearch: true,
|
|
hideInDescriptions: true,
|
|
render: (_, record) => {
|
|
return record?.GROWTHSETTING_NAME ? <a onClick={() => {
|
|
setCurrentRow({ ...record });
|
|
handleModalVisible(true);
|
|
}}>{record?.GROWTHSETTING_NAME}</a> : '-'
|
|
}
|
|
},
|
|
{
|
|
dataIndex: 'MEMBERSHIP_TYPE',
|
|
title: '会员类型',
|
|
align: 'center',
|
|
width: 120,
|
|
hideInSearch: true,
|
|
valueType: 'select',
|
|
valueEnum: MEMBERSHIP_TYPEObj
|
|
},
|
|
{
|
|
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: {
|
|
"1": "有效",
|
|
"0": "无效"
|
|
},
|
|
initialValue: "1"
|
|
},
|
|
// {
|
|
// dataIndex: 'STAFF_NAME',
|
|
// title: '操作人员',
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
// {
|
|
// dataIndex: 'OPERATE_DATE',
|
|
// title: '操作时间',
|
|
// valueType: 'fromNow',
|
|
// align: 'center',
|
|
// hideInSearch: true,
|
|
// },
|
|
// {
|
|
// dataIndex: 'GROWTHSETTING_DESC',
|
|
// title: '备注说明',
|
|
// 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('删除成功!');
|
|
actionRef.current?.reload()
|
|
handleConfirmLoading(false)
|
|
handleModalVisible(false)
|
|
}
|
|
};
|
|
|
|
const handleAddUpdate = async (res: any) => {
|
|
let req: any = {}
|
|
|
|
if (currentRow?.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) {
|
|
message.success(data.Result_Desc)
|
|
formRef?.current?.resetFields()
|
|
setCurrentRow(undefined)
|
|
handleModalVisible(false)
|
|
actionRef.current?.reload()
|
|
} else {
|
|
message.error(data.Result_Desc)
|
|
}
|
|
};
|
|
|
|
|
|
return (
|
|
<PageContainer header={{
|
|
title: '',
|
|
breadcrumb: {}
|
|
}}>
|
|
<ProTable
|
|
style={{ height: 'calc(100vh - 135px)', background: '#fff' }}
|
|
scroll={{ y: 'calc(100vh - 410px)' }}
|
|
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
|
|
},
|
|
SortStr: "PROMOTION_LEVEL desc",
|
|
PageIndex: 1,
|
|
PageSize: 20
|
|
}
|
|
const data = await handleGetGROWTHSETTINGList(req);
|
|
if (data.List && data.List.length > 0) {
|
|
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>
|
|
],
|
|
}}
|
|
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: 80 } }}
|
|
initialValues={{
|
|
...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() : "",
|
|
}}
|
|
onFinish={async (values) => {
|
|
let newValue: any = { ...values };
|
|
if (currentRow) {
|
|
// 编辑数据
|
|
newValue = { ...values, GROWTHSETTING_ID: currentRow.GROWTHSETTING_ID };
|
|
}
|
|
|
|
await handleAddUpdate(newValue);
|
|
|
|
handleConfirmLoading(false)
|
|
}}
|
|
>
|
|
<Row gutter={8}>
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="GROWTHSETTING_TYPE"
|
|
label="规则类型"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: '请选择规则类型'
|
|
}
|
|
]}
|
|
request={() => {
|
|
let GROWTHTYPEList = session.get('GROWTHTYPEList')
|
|
return GROWTHTYPEList
|
|
}}
|
|
// 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={MEMBERSHIP_TYPEList}
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="MEMBERSHIP_LEVEL"
|
|
label="会员等级"
|
|
options={MEMBERSHIPLEVELYNList}
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormSelect
|
|
name="PROMOTION_LEVEL"
|
|
label="晋升等级"
|
|
options={MEMBERSHIPLEVELYNList}
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormText
|
|
name="GROWTH_VALUE"
|
|
label="所需成长值"
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormText
|
|
name="GROWTHDAILY_CAP"
|
|
label="每日上限"
|
|
/>
|
|
</Col>
|
|
<Col span={12}>
|
|
<ProFormText
|
|
name="GROWTHTOTAL_CAP"
|
|
label="总上限值"
|
|
/>
|
|
</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>
|
|
</PageContainer>
|
|
);
|
|
};
|
|
export default connect(({ user }: ConnectState) => ({
|
|
currentUser: user.currentUser
|
|
}))(GrowthValueRuleConfig);
|