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="恢复" + > + + +
+
) }