Преглед на файлове

feta 增加宗门福利设置

Young преди 4 месеца
родител
ревизия
6007a06dc9
променени са 3 файла, в които са добавени 118 реда и са изтрити 0 реда
  1. 5 0
      config/routes.ts
  2. 1 0
      src/locales/zh-CN/menu.ts
  3. 112 0
      src/pages/Settings/PeakWeal.tsx

+ 5 - 0
config/routes.ts

@@ -99,6 +99,11 @@ export default [
         component: './Settings/Vest',
       },
       {
+        path: '/settings/platform/peak_weal',
+        name: 'peakWeal',
+        component: './Settings/PeakWeal',
+      },
+      {
         path: '/settings/platform/visit',
         name: 'visit',
         component: './Settings/Visit',

+ 1 - 0
src/locales/zh-CN/menu.ts

@@ -15,6 +15,7 @@ export default {
   'menu.settings.platform': '平台设置',
   'menu.settings.platform.sign': '签到设置',
   'menu.settings.platform.vest': '掉马甲设置',
+  'menu.settings.platform.peakWeal': '紫晶发放设置',
   'menu.settings.platform.visit': '拜访设置',
 
   'menu.peak': '峰管理',

+ 112 - 0
src/pages/Settings/PeakWeal.tsx

@@ -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>
+  );
+};