张延森 2 年之前
父節點
當前提交
6b723f4faf
共有 2 個文件被更改,包括 168 次插入30 次删除
  1. 18
    30
      config/routes.js
  2. 150
    0
      src/pages/monitor/index.jsx

+ 18
- 30
config/routes.js 查看文件

@@ -20,40 +20,28 @@
20 20
   //   component: './Welcome',
21 21
   // },
22 22
   {
23
-    path: '/rotationChart',
23
+    path: '/',
24
+    redirect: '/rotationChart/list',
25
+  },
26
+  {
27
+    path: '/rotationChart/list',
24 28
     name: '轮播图管理',
25 29
     icon: 'smile',
26
-    // access: 'canAdmin',
27
-    routes: [
28
-      {
29
-        path: '/rotationChart/list',
30
-        name: '轮播图管理',
31
-        icon: 'smile',
32
-        component: './rotationChart/list',
33
-      },
34
-      {
35
-        path: '/rotationChart/add',
36
-        name: '轮播图新增',
37
-        icon: 'smile',
38
-        hideInMenu: true,
39
-        component: './rotationChart/edit',
40
-      },
41
-      {
42
-        path: '/rotationChart/edit',
43
-        name: '轮播图编辑',
44
-        icon: 'smile',
45
-        hideInMenu: true,
46
-        component: './rotationChart/edit',
47
-      },
48
-      {
49
-        component: './404',
50
-      },
51
-    ],
30
+    component: './rotationChart/list',
52 31
   },
53
-
54 32
   {
55
-    path: '/',
56
-    redirect: '/rotationChart/list',
33
+    path: '/rotationChart/add',
34
+    name: '轮播图新增',
35
+    icon: 'smile',
36
+    hideInMenu: true,
37
+    component: './rotationChart/edit',
38
+  },
39
+  {
40
+    path: '/rotationChart/edit',
41
+    name: '轮播图编辑',
42
+    icon: 'smile',
43
+    hideInMenu: true,
44
+    component: './rotationChart/edit',
57 45
   },
58 46
   {
59 47
     component: './404',

+ 150
- 0
src/pages/monitor/index.jsx 查看文件

@@ -0,0 +1,150 @@
1
+import { deleteBanner, getBannerList, updataBanner } from '@/services/api/rotationChart';
2
+import { queryTable } from '@/utils/request';
3
+import { PageContainer, ProTable } from '@ant-design/pro-components';
4
+import { history } from '@umijs/max';
5
+import { Button, message, Popconfirm } from 'antd';
6
+import { useRef, useState } from 'react';
7
+
8
+const List = (props) => {
9
+  console.log(props, '===');
10
+  const [showDetail, setShowDetail] = useState(false);
11
+  const [activeKey, setActiveKey] = useState('');
12
+  const actionRef = useRef();
13
+
14
+  const updata = (row) => {
15
+    if (row.id) {
16
+      updataBanner(row.id, { state: row.state === '1' ? '2' : '1' }).then((res) => {
17
+        message.success('修改成功');
18
+        actionRef.current.reload();
19
+      });
20
+    }
21
+  };
22
+
23
+  const handleDelete = (id) => {
24
+    if (id) {
25
+      deleteBanner(id).then((res) => {
26
+        message.success('删除成功');
27
+        actionRef.current.reload();
28
+      });
29
+    }
30
+  };
31
+
32
+  const columns = [
33
+    {
34
+      title: 'id',
35
+      dataIndex: 'id',
36
+    },
37
+    {
38
+      title: '监控',
39
+      dataIndex: 'title',
40
+    },
41
+    {
42
+      title: '封面图',
43
+      dataIndex: 'image',
44
+      render: t => !t || '-' === t ? t : <img src={t}  style={{ width: '96px', borderRadius: '6px' }} />
45
+    },
46
+
47
+    {
48
+      title: '视频',
49
+      dataIndex: 'video',
50
+      render: () => '-',
51
+    },
52
+    {
53
+      title: '状态',
54
+      dataIndex: 'state',
55
+      valueEnum: {
56
+        1: {
57
+          text: '上架',
58
+          status: 'Processing',
59
+        },
60
+        2: {
61
+          text: '下架',
62
+          status: 'Error',
63
+        },
64
+      },
65
+    },
66
+    // {
67
+    //   title: '描述',
68
+    //   dataIndex: 'desc',
69
+    // },
70
+    {
71
+      title: '权重',
72
+      dataIndex: 'qz',
73
+    },
74
+    {
75
+      title: '操作',
76
+      valueType: 'option',
77
+      width: 200,
78
+      render: (_, record) => [
79
+        <Button
80
+          key={1}
81
+          style={{ padding: 0 }}
82
+          type="link"
83
+          onClick={() => {
84
+            updata(record);
85
+          }}
86
+        >
87
+          {record.state === '1' ? '下架' : '上架'}
88
+        </Button>,
89
+        <Button
90
+          key={2}
91
+          style={{ padding: 0 }}
92
+          type="link"
93
+          onClick={() => {
94
+            console.log(record, ']]');
95
+            history.push(`/rotationChart/add?id=${record.id}`);
96
+          }}
97
+        >
98
+          编辑
99
+        </Button>,
100
+
101
+        <Popconfirm
102
+          key={3}
103
+          title="您是否确认删除 ?"
104
+          onConfirm={() => handleDelete(record.id)}
105
+          okText="确定"
106
+          cancelText="取消"
107
+        >
108
+          {/* manualPush */}
109
+          <Button style={{ padding: 0 }} type="link">
110
+            删除
111
+          </Button>
112
+        </Popconfirm>,
113
+      ],
114
+    },
115
+  ];
116
+
117
+  return (
118
+    <PageContainer>
119
+      <ProTable
120
+        // headerTitle={'中高风险地区库'}
121
+        search={false}
122
+        actionRef={actionRef}
123
+        rowKey="id"
124
+        toolBarRender={() => [
125
+          <Button
126
+            key="2"
127
+            type="primary"
128
+            onClick={() => {
129
+              history.push('/rotationChart/add');
130
+            }}
131
+          >
132
+            新增
133
+          </Button>,
134
+          // <EditForm
135
+          //   key="2"
136
+          //   type="add"
137
+          //   butttomTitle="新增轮播图"
138
+          //   onSuccess={() => actionRef.current.reload()}
139
+          //   butttomProps={{}}
140
+          // />,
141
+        ]}
142
+        // search={false}
143
+        request={queryTable(getBannerList)}
144
+        columns={columns}
145
+      />
146
+    </PageContainer>
147
+  );
148
+};
149
+
150
+export default RotationChartList;