Bladeren bron

底部信息管理

master
suomingxiang 4 maanden geleden
bovenliggende
commit
4d33388703
2 gewijzigde bestanden met toevoegingen van 71 en 75 verwijderingen
  1. 13
    38
      src/pages/Other/footer/edit.tsx
  2. 58
    37
      src/pages/Other/footer/index.tsx

+ 13
- 38
src/pages/Other/footer/edit.tsx Bestand weergeven

@@ -3,67 +3,41 @@ import {
3 3
   ProForm,
4 4
   ProFormText,
5 5
   ProFormDigit,
6
-  ProFormRadio
7 6
 } from '@ant-design/pro-components';
8
-import { Form, Modal, Drawer, message, Upload, Space, Button, Switch,Input,Tooltip } from 'antd';
9
-import {InfoCircleOutlined} from '@ant-design/icons';
10
-import { useIntl, FormattedMessage } from '@umijs/max';
11
-import { DictValueEnumObj } from '@/components/DictTag';
12
-import Editor from '@/components/ueditor';
13
-import Quill from "quill";
7
+import { Form, Drawer, Space, Button } from 'antd';
8
+import { useIntl } from '@umijs/max';
14 9
 import "quill/dist/quill.snow.css";
15
-import moment from 'moment';
16
-import { trim } from 'lodash';
17
-let editor: any;
18 10
 
19 11
 export type VideoProps = {
20 12
   onCancel: (flag?: boolean, formVals?: any) => void;
21 13
   onSubmit: (values: any) => Promise<void>;
22 14
   open: boolean;
23 15
   currentRow: any;
24
-  sort: number;
25
-  name: string;
26
-  jumpUrl: string;
27 16
 };
28 17
 
29 18
 const VideoForm: React.FC<VideoProps> = (props) => {
30 19
   const [form] = Form.useForm();
31 20
   const intl = useIntl();
32
-  let editorRef = useRef<HTMLDivElement>(null)
21
+  const [fileList, setFileList] = useState<any>([]);
33 22
 
34 23
   useEffect(() => {
35
-    console.log(props)
36 24
     form.resetFields();
37 25
     if(!props.open) return;
38 26
     if(!props.currentRow) return;
39
-    const {sort,title,digest,pcImg,pcImgUrl,mImg,mImgUrl} = props.currentRow;
27
+    const {sort,name,jumpUrl} = props.currentRow;
40 28
     if (props.currentRow) {
41 29
       form.setFieldsValue({
42
-        sort,title,digest,pcImg,pcImgUrl,mImg,mImgUrl
30
+        sort,name,jumpUrl
43 31
       })
44 32
     }
45
-    if (editorRef && editorRef.current && editorRef.current.children[0]) {
46
-      editorRef.current.children[0].innerHTML = content
47
-    }
48
-
49 33
   }, [props.open]);
50 34
 
51 35
   
52
-  const [fileList, setFileList] = useState<any>([]);
36
+
53 37
  
54 38
   const handleOk = async () => {
55
-    let data = form.getFieldsValue()
39
+    form.submit()
56 40
     
57
-    let val = await form.validateFields()
58
-    let formData = {
59
-      ...data,
60
-    }
61
-    form.setFieldsValue({
62
-      title: '',
63
-      digest: ""
64
-    })
65
-    setFileList([]);
66
-    props.onSubmit(formData);
67 41
   };
68 42
   const handleCancel = () => {
69 43
     form.setFieldsValue({
@@ -75,11 +49,9 @@ const VideoForm: React.FC<VideoProps> = (props) => {
75 49
 
76 50
   };
77 51
 
78
-  const handleChange = async (res) => {
79
-    const { fileList } = res;
80
-    setFileList(fileList);
81
-  };
82
-
52
+  const onFinishForm = (values)=>{
53
+    props.onSubmit(values);
54
+  }
83 55
 
84 56
   return (
85 57
     <Drawer
@@ -101,10 +73,12 @@ const VideoForm: React.FC<VideoProps> = (props) => {
101 73
         grid={true}
102 74
         submitter={false}
103 75
         layout="horizontal"
76
+        onFinish={onFinishForm}
104 77
       >
105 78
         <ProFormText
106 79
           name="name"
107 80
           label='企业名称'
81
+          placeholder="请输入企业名称"
108 82
           labelCol={{
109 83
             style: { width: 95 }
110 84
           }}
@@ -113,6 +87,7 @@ const VideoForm: React.FC<VideoProps> = (props) => {
113 87
         <ProFormText
114 88
         name="jumpUrl"
115 89
         label='跳转地址'
90
+        placeholder="请输入跳转地址"
116 91
         labelCol={{
117 92
           style: { width: 95 }
118 93
         }}

+ 58
- 37
src/pages/Other/footer/index.tsx Bestand weergeven

@@ -1,18 +1,14 @@
1 1
 
2 2
 import React, { useState, useRef, useEffect } from 'react';
3
-import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
3
+import { useIntl, FormattedMessage } from '@umijs/max';
4 4
 import type { FormInstance } from 'antd';
5 5
 import { Button, message, Modal, Image, Upload, Drawer } from 'antd';
6
-import { ActionType, FooterToolbar, PageContainer, ProColumns, ProForm, ProFormDigit, ProFormText, ProTable } from '@ant-design/pro-components';
7
-import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, RedoOutlined } from '@ant-design/icons';
8
-// import { getNoticeList, removeNotice, addNotice, updateNotice, exportNotice } from '@/services/system/notice';
9
-import { getEnterpriseList, saveEnterprise, deleteEnterprise, upload } from '@/services/other/footer';
6
+import { ActionType, PageContainer, ProColumns, ProForm, ProFormDigit, ProFormText, ProTable } from '@ant-design/pro-components';
7
+import { PlusOutlined } from '@ant-design/icons';
8
+import { getEnterpriseList, saveEnterprise, deleteEnterprise, upload,saveFooter,getFooterList } from '@/services/other/footer';
10 9
 import EnterpriseForm from './edit';
11
-import moment from 'moment';
12 10
 import { KeepAlive } from 'react-activation';
13 11
 import './index.less'
14
-import DictTag from '../../../components/DictTag';
15
-import { getDataEnumList } from '../../../services/system/Enum';
16 12
 import { RcFile } from 'antd/es/upload';
17 13
 
18 14
 
@@ -39,25 +35,6 @@ const NoticeTableList: React.FC = () => {
39 35
         }
40 36
         return false;
41 37
     };
42
-    const handleRemoveOne = async (selectedRow: API.System.Notice) => {
43
-        const hide = message.loading(intl.formatMessage({ id: 'public.loadingDelete' }));
44
-        if (!selectedRow) return true;
45
-        try {
46
-            const params = [selectedRow.uuid];
47
-            const resp = await deleteEnterprise(params.join(','));
48
-            hide();
49
-            if (resp.code === 200) {
50
-                message.success(intl.formatMessage({ id: 'public.deleteSuccess' }));
51
-            } else {
52
-                message.error(resp.msg);
53
-            }
54
-            return true;
55
-        } catch (error) {
56
-            hide();
57
-            message.error(intl.formatMessage({ id: 'public.deleteError' }));
58
-            return false;
59
-        }
60
-    };
61 38
 
62 39
     const columns: ProColumns<API.System.Notice>[] = [
63 40
         {
@@ -87,12 +64,15 @@ const NoticeTableList: React.FC = () => {
87 64
             dataIndex: 'sort',
88 65
             valueType: 'text',
89 66
             hideInSearch: true,
67
+            width: 80,
68
+            align:'center'
90 69
         },
91 70
         {
92 71
             title: '操作',
93 72
             dataIndex: 'option',
94 73
             width: '120px',
95 74
             valueType: 'option',
75
+            align:'center',
96 76
             render: (_, record: any) => [
97 77
                 <Button
98 78
                     type="link"
@@ -120,11 +100,14 @@ const NoticeTableList: React.FC = () => {
120 100
                             okText: intl.formatMessage({ id: 'public.confirm' }),
121 101
                             cancelText: intl.formatMessage({ id: 'public.cancel' }),
122 102
                             onOk: async () => {
123
-                                const success = await handleRemoveOne(record);
124
-                                if (success) {
103
+                                const success = await deleteEnterprise(record.uuid);
104
+                                if (success.code == 200) {
125 105
                                     if (actionRef.current) {
126 106
                                         actionRef.current.reload();
127 107
                                     }
108
+                                    message.success('删除成功')
109
+                                }else{
110
+                                    message.error(success.msg || '操作失败,请重试')
128 111
                                 }
129 112
                             },
130 113
                         });
@@ -135,17 +118,57 @@ const NoticeTableList: React.FC = () => {
135 118
             ],
136 119
         },
137 120
     ];
138
-
121
+    useEffect(()=>{
122
+        getDetail()
123
+    },[])
124
+    const getDetail = async ()=>{
125
+        try {
126
+            const res = await getFooterList()
127
+            if(res.code === 200){
128
+                if(res.data){
129
+                    form?.current?.setFieldsValue(res.data)
130
+                    if(res.data.wxImgUrl){
131
+                        setFileList([{
132
+                            id:res.data.wxImg,
133
+                            url:res.data.wxImgUrl
134
+                        }])
135
+                    }
136
+                }
137
+            }else{
138
+                message.error(res.msg || '操作失败,请重试')
139
+            }
140
+        } catch (error) {
141
+            
142
+        }
143
+        
144
+    }
145
+    const onFinishForm = async (values)=>{
146
+        try {
147
+            if(img) values.img = img;
148
+            const res = await saveFooter(values)
149
+            if(res.code === 200){
150
+                message.success('保存成功')
151
+            }else{
152
+                message.error(res.msg || '操作失败,请重试')
153
+            }
154
+        } catch (error) {
155
+            
156
+        }
157
+    }
139 158
     return (
140
-        <KeepAlive name='底部信息管理' path="/Enterprise/EnterpriseList">
159
+        <KeepAlive name='底部信息管理' path="/Other/footer">
141 160
             <PageContainer>
142 161
                 <div style={{ width: '100%', float: 'right' }}>
143
-
162
+                    <div style={{ width:'100%',padding:'30px',display:'flex',alignItems:'center',justifyContent:'space-between' }}>
163
+                        <div></div>
164
+                        <Button type='primary' onClick={() => form?.current?.submit()}>保存</Button>
165
+                    </div>
144 166
                     <ProForm
145 167
                         formRef={form}
146 168
                         grid={true}
147 169
                         submitter={false}
148 170
                         layout="horizontal"
171
+                        onFinish={onFinishForm}
149 172
                     >
150 173
                         <ProFormText
151 174
                             name="phone"
@@ -207,11 +230,9 @@ const NoticeTableList: React.FC = () => {
207 230
                     <ProTable<API.System.Notice>
208 231
                         actionRef={actionRef}
209 232
                         formRef={formTableRef}
233
+                        headerTitle="旗下企业"
210 234
                         rowKey="uuid"
211
-                        key="EnterpriseList"
212
-                        search={{
213
-                            labelWidth: 120,
214
-                        }}
235
+                        search={false}
215 236
                         toolBarRender={() => [
216 237
                             <Button
217 238
                                 type="primary"
@@ -246,7 +267,7 @@ const NoticeTableList: React.FC = () => {
246 267
                 <EnterpriseForm
247 268
                     onSubmit={async (values) => {
248 269
                         let success = false;
249
-                        if (currentRow) {
270
+                        if (currentRow?.uuid) {
250 271
                             values.uuid = currentRow.uuid;
251 272
                         }
252 273
 

Laden…
Annuleren
Opslaan