Kaynağa Gözat

增加成员名录

master
suomingxiang 2 ay önce
ebeveyn
işleme
34ecbed80a

+ 12
- 0
config/routes.ts Dosyayı Görüntüle

@@ -74,6 +74,18 @@ export default [
74 74
       },
75 75
     ],
76 76
   },
77
+  {
78
+    name: 'Product',
79
+    path: '/Product',
80
+    icon: 'smile',
81
+    routes: [
82
+      {
83
+        name: 'member',
84
+        path: '/Product/member',
85
+        component: './Product/member',
86
+      },
87
+    ],
88
+  },
77 89
   {
78 90
     name: 'GoinZZ',
79 91
     path: '/GoinZZ',

+ 3
- 0
src/global.less Dosyayı Görüntüle

@@ -309,6 +309,9 @@ ol {
309 309
 .ant-pro-layout .ant-pro-sider .ant-menu .ant-menu-item:hover {
310 310
   color: #00d3a1;
311 311
 }
312
+.ant-pro-layout .ant-pro-sider .ant-menu .ant-menu-item:not(.ant-menu-item-selected):hover{
313
+  color: #00d3a1;
314
+}
312 315
 
313 316
 //自定义滚动条;
314 317
 .custom-scrollbar {

+ 188
- 0
src/pages/Product/member/edit.tsx Dosyayı Görüntüle

@@ -0,0 +1,188 @@
1
+import React, { useEffect, useState, useRef } from 'react';
2
+import {
3
+  ProForm,
4
+  ProFormText,
5
+  ProFormDigit,
6
+} from '@ant-design/pro-components';
7
+import { Form, Drawer, Upload, Space, Button } from 'antd';
8
+import { useIntl } from '@umijs/max';
9
+import { upload } from '@/services/product/member'
10
+import "quill/dist/quill.snow.css";
11
+import { RcFile } from 'antd/es/upload';
12
+
13
+export type Props = {
14
+  onCancel: (flag?: boolean, formVals?: any) => void;
15
+  onSubmit: (values: any) => Promise<void>;
16
+  open: boolean;
17
+  currentRow: any;
18
+};
19
+
20
+const VideoForm: React.FC<Props> = (props) => {
21
+  const [form] = Form.useForm();
22
+  const intl = useIntl();
23
+
24
+  useEffect(() => {
25
+    form.resetFields();
26
+    if (!props.open) return;
27
+    if (!props.currentRow) return;
28
+    const { sort, title, digest, pcImg, pcImgUrl,url } = props.currentRow;
29
+    if (props.currentRow) {
30
+      form.setFieldsValue({
31
+        sort, title, digest, pcImg, pcImgUrl,url
32
+      })
33
+    }
34
+
35
+    setpcImg(pcImg)
36
+
37
+    if (pcImgUrl && pcImg) {
38
+      setFileList([
39
+        {
40
+          uid: pcImg,
41
+          thumbUrl: pcImgUrl
42
+        }
43
+      ])
44
+    }
45
+
46
+    setmImg(mImg)
47
+
48
+  }, [props.open]);
49
+
50
+
51
+  const [fileList, setFileList] = useState<any>([]);
52
+  const [fileList2, setFileList2] = useState<any>([]);
53
+  const [pcImg, setpcImg] = useState<any>('');
54
+  const [mImg, setmImg] = useState<any>('');
55
+  const handleOk = async () => {
56
+    let data = form.getFieldsValue()
57
+
58
+    let val = await form.validateFields()
59
+    let formData = {
60
+      ...data,
61
+      pcImg,
62
+      mImg
63
+    }
64
+    form.setFieldsValue({
65
+      title: '',
66
+      digest: ""
67
+    })
68
+    setFileList([]);
69
+    setFileList2([]);
70
+    props.onSubmit(formData);
71
+  };
72
+  const handleCancel = () => {
73
+    form.setFieldsValue({
74
+      title: '',
75
+      digest: "",
76
+    })
77
+    setFileList([]);
78
+    props.onCancel();
79
+
80
+  };
81
+
82
+  const handleChange = async (res) => {
83
+    const { fileList } = res;
84
+    setFileList(fileList);
85
+  };
86
+
87
+  const handlePCBeforeUpload = async (file: RcFile) => {
88
+    const formData = new FormData();
89
+    formData.append('file', file, file.name);
90
+    const res = await upload(formData);
91
+    if (res?.data?.uuid) {
92
+      setpcImg(res.data.uuid)
93
+    }
94
+    return false;
95
+  };
96
+
97
+
98
+  return (
99
+    <Drawer
100
+      width={'80%'}
101
+      title={props.currentRow ? '编辑' : '新建'}
102
+      forceRender
103
+      open={props.open}
104
+      destroyOnClose
105
+      onClose={handleCancel}
106
+      extra={
107
+        <Space>
108
+          <Button onClick={handleCancel}>取消</Button>
109
+          <Button type="primary" onClick={handleOk}>确认</Button>
110
+        </Space>
111
+      }
112
+    >
113
+      <ProForm
114
+        form={form}
115
+        grid={true}
116
+        submitter={false}
117
+        layout="horizontal"
118
+      >
119
+        <ProForm.Item
120
+          label={'logo图'}
121
+          extra={'图片尺寸620*114'}
122
+          labelCol={{
123
+            style: { width: 95 }
124
+          }}
125
+          rules={[
126
+            {
127
+              required: true,
128
+              message: "请上传图片!",
129
+            }
130
+          ]
131
+          }
132
+        >
133
+          <Upload
134
+            listType="picture-card" // 设置为图片卡片模式
135
+            fileList={fileList}
136
+            maxCount={1}
137
+            onChange={handleChange}
138
+            beforeUpload={handlePCBeforeUpload}
139
+          >
140
+            {fileList?.length < 1 && '+' + intl.formatMessage({ id: 'public.uploadImg' })}
141
+          </Upload>
142
+        </ProForm.Item>
143
+
144
+        <ProFormText
145
+          name="title"
146
+          label='标题'
147
+          labelCol={{
148
+            style: { width: 95 }
149
+          }}
150
+        />
151
+
152
+        <ProFormText
153
+          name="digest"
154
+          label='简述'
155
+          labelCol={{
156
+            style: { width: 95 }
157
+          }}
158
+        />
159
+
160
+        <ProFormText
161
+          name="url"
162
+          label='链接'
163
+          labelCol={{
164
+            style: { width: 95 }
165
+          }}
166
+        />
167
+
168
+        <ProFormDigit
169
+          name="sort"
170
+          label="排序"
171
+          labelCol={{
172
+            style: { width: 95 }
173
+          }}
174
+          placeholder="请输入排序"
175
+          rules={[
176
+            {
177
+              required: true,
178
+              message: "请输入排序!",
179
+            },
180
+          ]}
181
+        />
182
+
183
+      </ProForm>
184
+    </Drawer>
185
+  );
186
+};
187
+
188
+export default VideoForm;

+ 3
- 0
src/pages/Product/member/index.less Dosyayı Görüntüle

@@ -0,0 +1,3 @@
1
+.ant-pro-table-list-toolbar-title{
2
+    display:none;
3
+}

+ 253
- 0
src/pages/Product/member/index.tsx Dosyayı Görüntüle

@@ -0,0 +1,253 @@
1
+
2
+import React, { useState, useRef, useEffect } from 'react';
3
+import { useIntl, FormattedMessage } from '@umijs/max';
4
+import type { FormInstance } from 'antd';
5
+import { Button, message, Modal, Image } from 'antd';
6
+import { ActionType, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
7
+import { PlusOutlined } from '@ant-design/icons';
8
+import { getBannerList, saveBanner, deleteBanner,push } from '@/services/product/member';
9
+import BannerForm from './edit';
10
+import { KeepAlive } from 'react-activation';
11
+import './index.less'
12
+import { getDataEnumList } from '../../../services/system/Enum';
13
+
14
+
15
+const NoticeTableList: React.FC = () => {
16
+    const formTableRef = useRef<FormInstance>();
17
+
18
+    const [modalVisible, setModalVisible] = useState<boolean>(false);
19
+
20
+    const actionRef = useRef<ActionType>();
21
+    const intl = useIntl();
22
+    const [currentRow, setCurrentRow] = useState<any>();
23
+    const [enumList, setEnumList] = useState()
24
+
25
+    const handleRemoveOne = async (selectedRow: API.System.Notice) => {
26
+        const hide = message.loading(intl.formatMessage({ id: 'public.loadingDelete' }));
27
+        if (!selectedRow) return true;
28
+        try {
29
+            const params = [selectedRow.uuid];
30
+            const resp = await deleteBanner(params.join(','));
31
+            hide();
32
+            if (resp.code === 200) {
33
+                message.success(intl.formatMessage({ id: 'public.deleteSuccess' }));
34
+            } else {
35
+                message.error(resp.msg);
36
+            }
37
+            return true;
38
+        } catch (error) {
39
+            hide();
40
+            message.error(intl.formatMessage({ id: 'public.deleteError' }));
41
+            return false;
42
+        }
43
+    };
44
+
45
+    useEffect(() => {
46
+        getEnum()
47
+    }, [])
48
+
49
+    const getEnum = () => {
50
+        getDataEnumList({ enumUuid: '2024810214616101' }).then((res) => {
51
+            console.log(res.rows)
52
+
53
+            const enumOptions = res.rows.map((item: any) => ({
54
+                label: item.dataName,
55
+                value: item.uuid,
56
+            }));
57
+            setEnumList(enumOptions); // 设置 enumList
58
+        })
59
+    }
60
+    const columns: ProColumns<API.System.Notice>[] = [
61
+        {
62
+            title: '序号',
63
+            dataIndex: 'id',
64
+            valueType: 'text',
65
+            hideInSearch: true,
66
+            render: (_, record: any) => {
67
+                // console.log('record---',_,record)
68
+                return record.rowIndex;
69
+            },
70
+        },
71
+        {
72
+            title: 'logo图片',
73
+            dataIndex: 'pcImgUrl',
74
+            valueType: 'text',
75
+            hideInSearch: true,
76
+            render: (_, record: any) => {
77
+                // console.log('record---',_,record)
78
+                return <Image src={record.pcImgUrl} style={{ 'height': '40px' }}></Image>;
79
+            }
80
+        },
81
+        // {
82
+        //     title: '焦点图(移动端)',
83
+        //     dataIndex: 'mImgUrl',
84
+        //     valueType: 'text',
85
+        //     hideInSearch: true,
86
+        //     render: (_, record: any) => {
87
+        //         // console.log('record---',_,record)
88
+        //         return <Image src={record.mImgUrl} style={{ 'height': '40px' }}></Image>;
89
+        //     }
90
+        // },
91
+        {
92
+            title: '标题',
93
+            dataIndex: 'title',
94
+            valueType: 'text',
95
+            hideInSearch: true,
96
+        },
97
+        {
98
+            title: '简述',
99
+            dataIndex: 'digest',
100
+            valueType: 'text',
101
+            hideInSearch: true,
102
+        },
103
+        {
104
+            title: '链接',
105
+            dataIndex: 'url',
106
+            valueType: 'text',
107
+            hideInSearch: true,
108
+        },
109
+        {
110
+            title: '排序',
111
+            dataIndex: 'sort',
112
+            valueType: 'text',
113
+            hideInSearch: true,
114
+        },
115
+        {
116
+            title: '操作',
117
+            dataIndex: 'option',
118
+            width: '120px',
119
+            valueType: 'option',
120
+            render: (_, record: any) => [
121
+                <Button
122
+                    type="link"
123
+                    size="small"
124
+                    key="edit"
125
+
126
+                    onClick={() => {
127
+                        setModalVisible(true);
128
+                        setCurrentRow(record);
129
+                    }}
130
+                >
131
+                    编辑
132
+                </Button>,
133
+
134
+                <Button
135
+                    type="link"
136
+                    size="small"
137
+                    danger
138
+                    key="batchRemove"
139
+
140
+                    onClick={async () => {
141
+                        Modal.confirm({
142
+                            title: intl.formatMessage({ id: 'public.delete' }),
143
+                            content: intl.formatMessage({ id: 'public.confirmdeletemsg' }),
144
+                            okText: intl.formatMessage({ id: 'public.confirm' }),
145
+                            cancelText: intl.formatMessage({ id: 'public.cancel' }),
146
+                            onOk: async () => {
147
+                                const success = await handleRemoveOne(record);
148
+                                if (success) {
149
+                                    if (actionRef.current) {
150
+                                        actionRef.current.reload();
151
+                                    }
152
+                                }
153
+                            },
154
+                        });
155
+                    }}
156
+                >
157
+                    <FormattedMessage id="public.delete" defaultMessage="删除" />
158
+                </Button>,
159
+            ],
160
+        },
161
+    ];
162
+
163
+    /**
164
+     * 一键发布
165
+     */
166
+    const publishing = async () => {
167
+        try {
168
+            const resp = await push();
169
+            if (resp.code === 200) {
170
+                message.success('发布成功');
171
+            } else {
172
+                message.error(resp.msg);
173
+            }
174
+        } catch (error) { }
175
+    }
176
+
177
+    return (
178
+        <KeepAlive name='成员名录' path="/Product/member">
179
+            <PageContainer>
180
+                <div style={{ width: '100%', float: 'right' }}>
181
+                    <ProTable<API.System.Notice>
182
+                        actionRef={actionRef}
183
+                        formRef={formTableRef}
184
+                        rowKey="uuid"
185
+                        search={false}
186
+                        toolBarRender={() => [
187
+                            <Button
188
+                                type="primary"
189
+                                key="add"
190
+                                onClick={async () => {
191
+                                    setCurrentRow(undefined);
192
+                                    setModalVisible(true);
193
+                                }}
194
+                            >
195
+                                <PlusOutlined /> <FormattedMessage id="public.add" defaultMessage="新建" />
196
+                            </Button>,
197
+                            <Button
198
+                                type="primary"
199
+                                key="fabu"
200
+                                onClick={publishing}
201
+                            >
202
+                                一键发布
203
+                            </Button>
204
+                        ]}
205
+                        request={(params) => {
206
+                            return getBannerList({ ...params } as API.System.NoticeListParams).then((res) => {
207
+
208
+                                res.rows.forEach((item: any, index: any) => {
209
+                                    item.rowIndex = index + 1
210
+                                })
211
+                                const result = {
212
+                                    data: res.rows,
213
+                                    total: res.total,
214
+                                    success: true,
215
+
216
+                                };
217
+                                return result;
218
+                            })
219
+                        }
220
+                        }
221
+                        columns={columns}
222
+                    />
223
+                </div>
224
+                <BannerForm
225
+                    onSubmit={async (values) => {
226
+                        let success = false;
227
+                        if (currentRow) {
228
+                            values.uuid = currentRow.uuid;
229
+                        }
230
+
231
+                        success = await saveBanner({ ...values });
232
+                        if (success) {
233
+                            setModalVisible(false);
234
+                            setCurrentRow(undefined);
235
+                            if (actionRef.current) {
236
+                                actionRef.current.reload();
237
+                            }
238
+                        }
239
+                    }}
240
+                    onCancel={() => {
241
+                        setModalVisible(false);
242
+                        setCurrentRow(undefined);
243
+                    }}
244
+                    currentRow={currentRow}
245
+                    open={modalVisible}
246
+                />
247
+            </PageContainer>
248
+        </KeepAlive>
249
+
250
+    );
251
+};
252
+
253
+export default NoticeTableList;

+ 52
- 0
src/services/product/member.ts Dosyayı Görüntüle

@@ -0,0 +1,52 @@
1
+import { request } from '@umijs/max'; 
2
+
3
+// 查询
4
+export async function getBannerList(params: any) {
5
+    return request('/api/system/banner/select', {
6
+      method: 'GET',
7
+      headers: {
8
+        'Content-Type': 'application/json;charset=UTF-8',
9
+      },
10
+      params,
11
+    });
12
+  }
13
+
14
+// 保存
15
+export async function saveBanner(data: any) {
16
+  return request('/api/system/banner/save', {
17
+    method: 'post',
18
+    data: data, 
19
+  });
20
+}
21
+
22
+// 上传
23
+export async function upload(data: any) {
24
+  return request('/api/file/upload', {
25
+    method: 'post',
26
+    data: data,
27
+  });
28
+}
29
+
30
+//删除
31
+export async function deleteBanner(bannerUuid:any) {
32
+  return request(`/api/system/banner/remove`, {
33
+    method: 'DELETE',
34
+    headers: {
35
+      'Content-Type': 'application/json;charset=UTF-8',
36
+    },
37
+    params:{
38
+      bannerUuid:bannerUuid
39
+    },
40
+  });
41
+}
42
+
43
+//发布
44
+export async function push(params: any) {
45
+  return request('/api/staticize/static/index', {
46
+    method: 'GET',
47
+    headers: {
48
+      'Content-Type': 'application/json;charset=UTF-8',
49
+    },
50
+    params,
51
+  });
52
+}

Loading…
İptal
Kaydet