From 0b7e7c728760e241ea913d34310f78e26b0a95dd Mon Sep 17 00:00:00 2001 From: 79E <5980844@qq.com> Date: Sun, 21 May 2023 15:54:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=90=BA=E5=B8=A6?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E4=BF=A1=E6=81=AF=E6=95=B0=E9=87=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/admin/config/index.tsx | 147 ++++++++++++++++++++----------- 1 file changed, 98 insertions(+), 49 deletions(-) diff --git a/src/pages/admin/config/index.tsx b/src/pages/admin/config/index.tsx index b622085..24adcaf 100644 --- a/src/pages/admin/config/index.tsx +++ b/src/pages/admin/config/index.tsx @@ -2,7 +2,7 @@ import { ProFormDigit, QueryFilter, } from '@ant-design/pro-components'; -import { Form, message } from 'antd'; +import { Form, Space, message } from 'antd'; import { useEffect, useState } from 'react'; import styles from './index.module.less' import { getAdminConfig, putAdminConfig } from '@/request/adminApi'; @@ -16,24 +16,32 @@ function ConfigPage() { signin_reward: number | string, }>(); - function getConfigValue (key: string, data: Array){ + const [historyMessageForm] = Form.useForm<{ + history_message_count: number | string, + }>(); + + function getConfigValue(key: string, data: Array) { const value = data.filter(c => c.name === key)[0] return value } - function onRewardFormSet (data: Array){ + function onRewardFormSet(data: Array) { const registerRewardInfo = getConfigValue('register_reward', data) const signinRewardInfo = getConfigValue('signin_reward', data) + const historyMessageCountInfo = getConfigValue('history_message_count', data) rewardForm.setFieldsValue({ register_reward: registerRewardInfo.value, signin_reward: signinRewardInfo.value }) + historyMessageForm.setFieldsValue({ + history_message_count: Number(historyMessageCountInfo.value) + }) } - function onGetConfig (){ - getAdminConfig().then((res)=>{ - if(res.code){ + function onGetConfig() { + getAdminConfig().then((res) => { + if (res.code) { message.error('获取配置错误') return } @@ -42,53 +50,94 @@ function ConfigPage() { }) } - useEffect(()=>{ + useEffect(() => { onGetConfig() - },[]) + }, []) + + async function onSave(values: any){ + return putAdminConfig(values).then((res) => { + if (res.code) { + message.error('保存失败') + return + } + message.success('保存成功') + onGetConfig() + }) + } return (
-
-

奖励激励

- { - putAdminConfig(values).then((res)=>{ - if(res.code) { - message.error('保存失败') - return - } - message.success('保存成功') - onGetConfig() - }) - }} - onReset={()=>{ - onRewardFormSet(configs) - }} - size="large" - collapsed={false} - defaultCollapsed={false} - requiredMark={false} - defaultColsNumber={79} - searchText="保存" - resetText="恢复" - > - - - -
+ +
+

奖励激励

+ { + putAdminConfig(values).then((res) => { + if (res.code) { + message.error('保存失败') + return + } + message.success('保存成功') + onGetConfig() + }) + }} + onReset={() => { + onRewardFormSet(configs) + }} + size="large" + collapsed={false} + defaultCollapsed={false} + requiredMark={false} + defaultColsNumber={79} + searchText="保存" + resetText="恢复" + > + + + +
+
+

历史记录

+ { + onRewardFormSet(configs) + }} + size="large" + collapsed={false} + defaultCollapsed={false} + requiredMark={false} + defaultColsNumber={79} + searchText="保存" + resetText="恢复" + > + + +
+
) }