index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { getSetting } from '@/services/api/system'
  2. import { useRequest } from 'umi'
  3. import { PageContainer } from '@ant-design/pro-layout'
  4. import { Card, Form, Input, Button, Upload } from 'antd'
  5. import { UploadOutlined } from '@ant-design/icons'
  6. import React, { useEffect, useState } from 'react'
  7. const Setting = () => {
  8. const [state, setState] = useState({
  9. contentValue: ''
  10. })
  11. const [form] = Form.useForm()
  12. const { run: tryGetSetting } = useRequest(
  13. () => {
  14. return getSetting()
  15. },
  16. {
  17. manual: true,
  18. onSuccess: (result: API.GetSettingParams) => {
  19. setState({ ...state, contentVlue: result })
  20. form.current?.setFieldsValue({ name: result.name, backstageName: result.backstageName })
  21. }
  22. }
  23. )
  24. useEffect(() => {
  25. tryGetSetting()
  26. form.current?.setFieldsValue(...state.contentValue)
  27. }, [])
  28. return (
  29. <PageContainer title={false}>
  30. <Card>
  31. <div className="text-2xl mb-7">系统设置</div>
  32. <Form
  33. labelCol={{ span: 2 }}
  34. wrapperCol={{ span: 8 }}
  35. layout="horizontal"
  36. form={form}
  37. // initialValues={{ name: 'admin' }}
  38. onFinish={async values => {
  39. console.log(values)
  40. }}>
  41. <Form.Item label="系统名称" name="name">
  42. <Input />
  43. </Form.Item>
  44. <Form.Item
  45. name="logo"
  46. label="系统LOGO"
  47. valuePropName="logo"
  48. // getValueFromEvent={normFile}
  49. // extra="大小"
  50. >
  51. <Upload name="logo" action="/upload.do" listType="picture">
  52. <Button icon={<UploadOutlined />}>上传</Button>
  53. </Upload>
  54. </Form.Item>
  55. <Form.Item label="后台名称" name="backstageName">
  56. <Input />
  57. </Form.Item>
  58. <Form.Item
  59. name="backstageLogo"
  60. label="后台LOGO"
  61. valuePropName="backstageLogo"
  62. // getValueFromEvent={normFile}
  63. // extra="大小"
  64. >
  65. <Upload name="logo" action="/upload.do" listType="picture">
  66. <Button icon={<UploadOutlined />}>上传</Button>
  67. </Upload>
  68. </Form.Item>
  69. <Form.Item wrapperCol={{ offset: 2, span: 8 }}>
  70. <Button type="primary" htmlType="submit">
  71. 确认
  72. </Button>
  73. </Form.Item>
  74. </Form>
  75. </Card>
  76. </PageContainer>
  77. )
  78. }
  79. export default Setting