Sfoglia il codice sorgente

底部信息管理

master
suomingxiang 4 mesi fa
parent
commit
4d33388703
2 ha cambiato i file con 71 aggiunte e 75 eliminazioni
  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 Vedi File

3
   ProForm,
3
   ProForm,
4
   ProFormText,
4
   ProFormText,
5
   ProFormDigit,
5
   ProFormDigit,
6
-  ProFormRadio
7
 } from '@ant-design/pro-components';
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
 import "quill/dist/quill.snow.css";
9
 import "quill/dist/quill.snow.css";
15
-import moment from 'moment';
16
-import { trim } from 'lodash';
17
-let editor: any;
18
 
10
 
19
 export type VideoProps = {
11
 export type VideoProps = {
20
   onCancel: (flag?: boolean, formVals?: any) => void;
12
   onCancel: (flag?: boolean, formVals?: any) => void;
21
   onSubmit: (values: any) => Promise<void>;
13
   onSubmit: (values: any) => Promise<void>;
22
   open: boolean;
14
   open: boolean;
23
   currentRow: any;
15
   currentRow: any;
24
-  sort: number;
25
-  name: string;
26
-  jumpUrl: string;
27
 };
16
 };
28
 
17
 
29
 const VideoForm: React.FC<VideoProps> = (props) => {
18
 const VideoForm: React.FC<VideoProps> = (props) => {
30
   const [form] = Form.useForm();
19
   const [form] = Form.useForm();
31
   const intl = useIntl();
20
   const intl = useIntl();
32
-  let editorRef = useRef<HTMLDivElement>(null)
21
+  const [fileList, setFileList] = useState<any>([]);
33
 
22
 
34
   useEffect(() => {
23
   useEffect(() => {
35
-    console.log(props)
36
     form.resetFields();
24
     form.resetFields();
37
     if(!props.open) return;
25
     if(!props.open) return;
38
     if(!props.currentRow) return;
26
     if(!props.currentRow) return;
39
-    const {sort,title,digest,pcImg,pcImgUrl,mImg,mImgUrl} = props.currentRow;
27
+    const {sort,name,jumpUrl} = props.currentRow;
40
     if (props.currentRow) {
28
     if (props.currentRow) {
41
       form.setFieldsValue({
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
   }, [props.open]);
33
   }, [props.open]);
50
 
34
 
51
   
35
   
52
-  const [fileList, setFileList] = useState<any>([]);
36
+
53
  
37
  
54
   const handleOk = async () => {
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
   const handleCancel = () => {
42
   const handleCancel = () => {
69
     form.setFieldsValue({
43
     form.setFieldsValue({
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
   return (
56
   return (
85
     <Drawer
57
     <Drawer
101
         grid={true}
73
         grid={true}
102
         submitter={false}
74
         submitter={false}
103
         layout="horizontal"
75
         layout="horizontal"
76
+        onFinish={onFinishForm}
104
       >
77
       >
105
         <ProFormText
78
         <ProFormText
106
           name="name"
79
           name="name"
107
           label='企业名称'
80
           label='企业名称'
81
+          placeholder="请输入企业名称"
108
           labelCol={{
82
           labelCol={{
109
             style: { width: 95 }
83
             style: { width: 95 }
110
           }}
84
           }}
113
         <ProFormText
87
         <ProFormText
114
         name="jumpUrl"
88
         name="jumpUrl"
115
         label='跳转地址'
89
         label='跳转地址'
90
+        placeholder="请输入跳转地址"
116
         labelCol={{
91
         labelCol={{
117
           style: { width: 95 }
92
           style: { width: 95 }
118
         }}
93
         }}

+ 58
- 37
src/pages/Other/footer/index.tsx Vedi File

1
 
1
 
2
 import React, { useState, useRef, useEffect } from 'react';
2
 import React, { useState, useRef, useEffect } from 'react';
3
-import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
3
+import { useIntl, FormattedMessage } from '@umijs/max';
4
 import type { FormInstance } from 'antd';
4
 import type { FormInstance } from 'antd';
5
 import { Button, message, Modal, Image, Upload, Drawer } from 'antd';
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
 import EnterpriseForm from './edit';
9
 import EnterpriseForm from './edit';
11
-import moment from 'moment';
12
 import { KeepAlive } from 'react-activation';
10
 import { KeepAlive } from 'react-activation';
13
 import './index.less'
11
 import './index.less'
14
-import DictTag from '../../../components/DictTag';
15
-import { getDataEnumList } from '../../../services/system/Enum';
16
 import { RcFile } from 'antd/es/upload';
12
 import { RcFile } from 'antd/es/upload';
17
 
13
 
18
 
14
 
39
         }
35
         }
40
         return false;
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
     const columns: ProColumns<API.System.Notice>[] = [
39
     const columns: ProColumns<API.System.Notice>[] = [
63
         {
40
         {
87
             dataIndex: 'sort',
64
             dataIndex: 'sort',
88
             valueType: 'text',
65
             valueType: 'text',
89
             hideInSearch: true,
66
             hideInSearch: true,
67
+            width: 80,
68
+            align:'center'
90
         },
69
         },
91
         {
70
         {
92
             title: '操作',
71
             title: '操作',
93
             dataIndex: 'option',
72
             dataIndex: 'option',
94
             width: '120px',
73
             width: '120px',
95
             valueType: 'option',
74
             valueType: 'option',
75
+            align:'center',
96
             render: (_, record: any) => [
76
             render: (_, record: any) => [
97
                 <Button
77
                 <Button
98
                     type="link"
78
                     type="link"
120
                             okText: intl.formatMessage({ id: 'public.confirm' }),
100
                             okText: intl.formatMessage({ id: 'public.confirm' }),
121
                             cancelText: intl.formatMessage({ id: 'public.cancel' }),
101
                             cancelText: intl.formatMessage({ id: 'public.cancel' }),
122
                             onOk: async () => {
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
                                     if (actionRef.current) {
105
                                     if (actionRef.current) {
126
                                         actionRef.current.reload();
106
                                         actionRef.current.reload();
127
                                     }
107
                                     }
108
+                                    message.success('删除成功')
109
+                                }else{
110
+                                    message.error(success.msg || '操作失败,请重试')
128
                                 }
111
                                 }
129
                             },
112
                             },
130
                         });
113
                         });
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
     return (
158
     return (
140
-        <KeepAlive name='底部信息管理' path="/Enterprise/EnterpriseList">
159
+        <KeepAlive name='底部信息管理' path="/Other/footer">
141
             <PageContainer>
160
             <PageContainer>
142
                 <div style={{ width: '100%', float: 'right' }}>
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
                     <ProForm
166
                     <ProForm
145
                         formRef={form}
167
                         formRef={form}
146
                         grid={true}
168
                         grid={true}
147
                         submitter={false}
169
                         submitter={false}
148
                         layout="horizontal"
170
                         layout="horizontal"
171
+                        onFinish={onFinishForm}
149
                     >
172
                     >
150
                         <ProFormText
173
                         <ProFormText
151
                             name="phone"
174
                             name="phone"
207
                     <ProTable<API.System.Notice>
230
                     <ProTable<API.System.Notice>
208
                         actionRef={actionRef}
231
                         actionRef={actionRef}
209
                         formRef={formTableRef}
232
                         formRef={formTableRef}
233
+                        headerTitle="旗下企业"
210
                         rowKey="uuid"
234
                         rowKey="uuid"
211
-                        key="EnterpriseList"
212
-                        search={{
213
-                            labelWidth: 120,
214
-                        }}
235
+                        search={false}
215
                         toolBarRender={() => [
236
                         toolBarRender={() => [
216
                             <Button
237
                             <Button
217
                                 type="primary"
238
                                 type="primary"
246
                 <EnterpriseForm
267
                 <EnterpriseForm
247
                     onSubmit={async (values) => {
268
                     onSubmit={async (values) => {
248
                         let success = false;
269
                         let success = false;
249
-                        if (currentRow) {
270
+                        if (currentRow?.uuid) {
250
                             values.uuid = currentRow.uuid;
271
                             values.uuid = currentRow.uuid;
251
                         }
272
                         }
252
 
273
 

Loading…
Annulla
Salva