|
@@ -0,0 +1,112 @@
|
|
|
|
+import {ProForm, ProFormInstance, ProFormSelect, ProFormText} from '@ant-design/pro-components';
|
|
|
|
+import {message} from 'antd';
|
|
|
|
+import React, {useEffect, useRef, useState} from 'react';
|
|
|
|
+import {getConfigGetApi, postConfigSaveApi} from "@/services/swagger/configAdmin";
|
|
|
|
+import {getPeakLevelListTreeApi} from "@/services/swagger/peakLevelAdmin";
|
|
|
|
+
|
|
|
|
+type PeakLevelVO = {
|
|
|
|
+ /** 创建时间 */
|
|
|
|
+ createTime?: string;
|
|
|
|
+ /** 更新时间 */
|
|
|
|
+ updateTime?: string;
|
|
|
|
+ /** 自增 ID */
|
|
|
|
+ id?: number;
|
|
|
|
+ /** 父节点 */
|
|
|
|
+ parentId?: number;
|
|
|
|
+ /** 名称 */
|
|
|
|
+ name?: string;
|
|
|
|
+ /** 等级 */
|
|
|
|
+ level?: number;
|
|
|
|
+ /** 经验值 */
|
|
|
|
+ exp?: number;
|
|
|
|
+ /** 子节点 */
|
|
|
|
+ children?: PeakLevelVO[];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const options = [
|
|
|
|
+ {
|
|
|
|
+ value: 1,
|
|
|
|
+ label: '紫币',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: 2,
|
|
|
|
+ label: '紫晶',
|
|
|
|
+ },
|
|
|
|
+]
|
|
|
|
+
|
|
|
|
+type WealSetting = {
|
|
|
|
+ level?: number;
|
|
|
|
+ wealCnt: number;
|
|
|
|
+ wealType: number;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export default () => {
|
|
|
|
+ const formRef = useRef<ProFormInstance>();
|
|
|
|
+
|
|
|
|
+ const [peakLevelList, setPeakLevelList] = useState<PeakLevelVO[]>([]);
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ const fetchLevels = async () => {
|
|
|
|
+ const res = await getPeakLevelListTreeApi();
|
|
|
|
+ if (res.success) {
|
|
|
|
+ setPeakLevelList(res.data);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ fetchLevels();
|
|
|
|
+ }, []);
|
|
|
|
+
|
|
|
|
+ return (
|
|
|
|
+ <ProForm
|
|
|
|
+ layout="horizontal"
|
|
|
|
+ title="签到设置"
|
|
|
|
+ formRef={formRef}
|
|
|
|
+ submitter={{}}
|
|
|
|
+ request={async () => {
|
|
|
|
+ const res = await getConfigGetApi({"code": "platform.peak.weal"})
|
|
|
|
+ if (res.success && res.data.content) {
|
|
|
|
+ const result: WealSetting[] = JSON.parse(res.data.content)
|
|
|
|
+ return result.reduce((acc: any, item: WealSetting) => {
|
|
|
|
+ acc[`${item.level}WealCnt`] = item.wealCnt;
|
|
|
|
+ acc[`${item.level}WealType`] = item.wealType;
|
|
|
|
+ return acc;
|
|
|
|
+ }, {});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Promise.resolve({});
|
|
|
|
+ }}
|
|
|
|
+ onFinish={async (values) => {
|
|
|
|
+ const result: WealSetting[] = peakLevelList.map(peakLevel => ({
|
|
|
|
+ level: peakLevel.level,
|
|
|
|
+ wealCnt: parseInt(values[`${peakLevel.level}WealCnt`]),
|
|
|
|
+ wealType: parseInt(values[`${peakLevel.level}WealType`]),
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ console.log("value " + values);
|
|
|
|
+ console.log("result " + result);
|
|
|
|
+
|
|
|
|
+ const res = await postConfigSaveApi({
|
|
|
|
+ "type": "json",
|
|
|
|
+ "code": "platform.peak.weal",
|
|
|
|
+ "remark": "宗门奖励发放设置",
|
|
|
|
+ "content": JSON.stringify(result)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if (res.success) {
|
|
|
|
+ message.success('提交成功');
|
|
|
|
+ } else {
|
|
|
|
+ message.error(res.errorMessage)
|
|
|
|
+ }
|
|
|
|
+ return res.success;
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+
|
|
|
|
+ {peakLevelList.map(level => (
|
|
|
|
+ <ProForm.Group key={level.name}>
|
|
|
|
+ <ProFormText name={`${level.level}WealCnt`} width="md" label={`${level.name}`}/>
|
|
|
|
+ <ProFormSelect name={`${level.level}WealType`} options={options} initialValue="1" width="xs"/>
|
|
|
|
+ </ProForm.Group>
|
|
|
|
+ ))}
|
|
|
|
+ </ProForm>
|
|
|
|
+ );
|
|
|
|
+};
|