Browse Source

feat: 系统设置

outaozhen 3 năm trước cách đây
mục cha
commit
2cecd628fc
2 tập tin đã thay đổi với 75 bổ sung6 xóa
  1. 3 3
      src/pages/System/AdminUpdate/index.tsx
  2. 72 3
      src/pages/System/Setting/index.tsx

+ 3 - 3
src/pages/System/AdminUpdate/index.tsx

@@ -25,13 +25,13 @@ const AdminUpdate = () => {
             <Input disabled />
           </Form.Item>
           <Form.Item label="旧密码" name="password">
-            <Input.Password />
+            <Input.Password placeholder="请输入" />
           </Form.Item>
           <Form.Item label="新密码" name="newPassword">
-            <Input.Password />
+            <Input.Password placeholder="请输入" />
           </Form.Item>
           <Form.Item label="确认新密码" name="confirmPassword">
-            <Input.Password />
+            <Input.Password placeholder="请输入" />
           </Form.Item>
           <Form.Item wrapperCol={{ offset: 2, span: 8 }}>
             <Button type="primary" htmlType="submit">

+ 72 - 3
src/pages/System/Setting/index.tsx

@@ -1,12 +1,81 @@
+import { getSetting } from '@/services/api/system'
+import { useRequest } from 'umi'
 import { PageContainer } from '@ant-design/pro-layout'
-import { Card } from 'antd'
-import React from 'react'
+import { Card, Form, Input, Button, Upload } from 'antd'
+import { UploadOutlined } from '@ant-design/icons'
+import React, { useEffect, useState } from 'react'
 
 const Setting = () => {
+  const [state, setState] = useState({
+    contentValue: ''
+  })
+  const [form] = Form.useForm()
+
+  const { run: tryGetSetting } = useRequest(
+    () => {
+      return getSetting()
+    },
+    {
+      manual: true,
+      onSuccess: (result: API.GetSettingParams) => {
+        setState({ ...state, contentVlue: result })
+        form.current?.setFieldsValue({ name: result.name, backstageName: result.backstageName })
+      }
+    }
+  )
+
+  useEffect(() => {
+    tryGetSetting()
+    form.current?.setFieldsValue(...state.contentValue)
+  }, [])
+
   return (
     <PageContainer title={false}>
       <Card>
-        <h1>系统</h1>
+        <div className="text-2xl mb-7">系统设置</div>
+        <Form
+          labelCol={{ span: 2 }}
+          wrapperCol={{ span: 8 }}
+          layout="horizontal"
+          form={form}
+          // initialValues={{ name: 'admin' }}
+          onFinish={async values => {
+            console.log(values)
+          }}>
+          <Form.Item label="系统名称" name="name">
+            <Input />
+          </Form.Item>
+          <Form.Item
+            name="logo"
+            label="系统LOGO"
+            valuePropName="logo"
+            // getValueFromEvent={normFile}
+            // extra="大小"
+          >
+            <Upload name="logo" action="/upload.do" listType="picture">
+              <Button icon={<UploadOutlined />}>上传</Button>
+            </Upload>
+          </Form.Item>
+          <Form.Item label="后台名称" name="backstageName">
+            <Input />
+          </Form.Item>
+          <Form.Item
+            name="backstageLogo"
+            label="后台LOGO"
+            valuePropName="backstageLogo"
+            // getValueFromEvent={normFile}
+            // extra="大小"
+          >
+            <Upload name="logo" action="/upload.do" listType="picture">
+              <Button icon={<UploadOutlined />}>上传</Button>
+            </Upload>
+          </Form.Item>
+          <Form.Item wrapperCol={{ offset: 2, span: 8 }}>
+            <Button type="primary" htmlType="submit">
+              确认
+            </Button>
+          </Form.Item>
+        </Form>
       </Card>
     </PageContainer>
   )