Explorar el Código

feta 增加签到奖励设置

Young hace 4 meses
padre
commit
e4a497617d
Se han modificado 1 ficheros con 15 adiciones y 8 borrados
  1. 15 8
      src/pages/Settings/Sign.tsx

+ 15 - 8
src/pages/Settings/Sign.tsx

@@ -1,12 +1,7 @@
-import {ProFormInstance, ProFormSelect} from '@ant-design/pro-components';
-import {
-  ProForm,
-  ProFormText,
-} from '@ant-design/pro-components';
+import {ProForm, ProFormInstance, ProFormSelect, ProFormText} from '@ant-design/pro-components';
 import {message} from 'antd';
 import React, {useRef} from 'react';
-import {postConfigSaveApi} from "@/services/swagger/configAdmin";
-import {Button, Card, Modal} from 'antd';
+import {getConfigGetApi, postConfigSaveApi} from "@/services/swagger/configAdmin";
 
 const options = [
   {
@@ -28,7 +23,6 @@ type SignSetting = {
 export default () => {
   const formRef = useRef<ProFormInstance>();
   const days = Array.from({length: 7}, (_, i) => i + 1);
-  const [form] = ProForm.useForm();
 
   return (
     <ProForm
@@ -36,6 +30,19 @@ export default () => {
       title="签到设置"
       formRef={formRef}
       submitter={{}}
+      request={async () => {
+        const res = await getConfigGetApi({"code": "platform.sign.award"})
+        if (res.success && res.data.content) {
+          const result: SignSetting[] = JSON.parse(res.data.content)
+          return result.reduce((acc: any, item: SignSetting) => {
+            acc[`day${item.dayCnt}AwardCnt`] = item.awardCnt;
+            acc[`day${item.dayCnt}AwardType`] = item.awardType.toString();
+            return acc;
+          }, {});
+        }
+
+        return Promise.resolve({});
+      }}
       onFinish={async (values) => {
         const result: SignSetting[] = days.map(day => ({
           dayCnt: day,