RedPacket.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {ProForm, ProFormInstance, ProFormText} from '@ant-design/pro-components';
  2. import {message} from 'antd';
  3. import React, {useRef} from 'react';
  4. import {getConfigGetApi, postConfigSaveApi} from "@/services/swagger/configAdmin";
  5. type RedPacketSend = {
  6. minLimit: number
  7. };
  8. export default () => {
  9. const formRef = useRef<ProFormInstance>();
  10. return (
  11. <ProForm
  12. layout="horizontal"
  13. title="签到设置"
  14. formRef={formRef}
  15. submitter={{}}
  16. request={async () => {
  17. const res = await getConfigGetApi({"code": "platform.redPacket.send"})
  18. if (res.success && res.data.content) {
  19. const result: RedPacketSend = JSON.parse(res.data.content)
  20. return result;
  21. }
  22. return {
  23. minLimit: 0,
  24. }
  25. }}
  26. onFinish={async (values) => {
  27. const result: RedPacketSend = {
  28. minLimit: parseInt(values.minLimit),
  29. };
  30. console.log("value " + values);
  31. const res = await postConfigSaveApi({
  32. "type": "json",
  33. "code": "platform.redPacket.send",
  34. "remark": "红包发送设置",
  35. "content": JSON.stringify(result)
  36. })
  37. if (res.success) {
  38. message.success('提交成功');
  39. } else {
  40. message.error(res.errorMessage)
  41. }
  42. return res.success;
  43. }}
  44. >
  45. <ProFormText name="minLimit" width="md" label={`每次发送红包至少`} addonAfter={"个"}/>
  46. </ProForm>
  47. );
  48. };