fangmingyue 2 年 前
コミット
da1f1bc59f

+ 4
- 3
src/components/Page/List.jsx ファイルの表示

@@ -22,10 +22,11 @@ export default React.forwardRef((props, ref) => {
22 22
       valueType: 'option',
23 23
       key: 'option',
24 24
       ellipsis: true,
25
+      fixed: 'right',
25 26
       render: (_, record) => [
26 27
         (
27
-          onEdit && 
28
-          <Button style={{ padding: 0 }} type="link" key={1} onClick={() => onEdit(record) }>
28
+          onEdit &&
29
+          <Button style={{ padding: 0 }} type="link" key={1} onClick={() => onEdit(record)}>
29 30
             编辑
30 31
           </Button>
31 32
         ),
@@ -71,7 +72,7 @@ export default React.forwardRef((props, ref) => {
71 72
         actionRef={actionRef}
72 73
         toolBarRender={() => [
73 74
           (
74
-            onAdd && 
75
+            onAdd &&
75 76
             <Button
76 77
               key="1"
77 78
               type="primary"

+ 2
- 2
src/layouts/AuthLayout/components/Header/Exit.jsx ファイルの表示

@@ -9,7 +9,7 @@ const { confirm } = Modal;
9 9
 
10 10
 export default (props) => {
11 11
   const navigate = useNavigate();
12
-  const { setUser } = useModel("user");
12
+  // const { setUser } = useModel("user");
13 13
 
14 14
   const onExit = () => {
15 15
     confirm({
@@ -17,7 +17,7 @@ export default (props) => {
17 17
       onOk: () => {
18 18
         logout(); // 调用接口
19 19
         localStorage.removeItem("token");
20
-        setUser();
20
+        // setUser();
21 21
         navigate("/login?back=true");
22 22
       },
23 23
     });

+ 1
- 1
src/pages/custom/index.jsx ファイルの表示

@@ -2,7 +2,7 @@ import React from "react";
2 2
 import { useNavigate } from "react-router-dom";
3 3
 import { Button, Popconfirm, message } from "antd";
4 4
 import { ProTable } from "@ant-design/pro-components";
5
-import { queryTable, queryDict } from "@/utils/request";
5
+import { queryTable } from "@/utils/request";
6 6
 import { getTaCustom, deleteTaCustom } from "@/services/taCustom";
7 7
 import Page from "@/components/Page";
8 8
 

+ 3
- 1
src/pages/login/index.jsx ファイルの表示

@@ -27,6 +27,7 @@ export default (props) => {
27 27
 
28 28
     // console.log('ticket', ticket);
29 29
     if (searchParams.get("redirect")) {
30
+      // console.log('爱', searchParams.get("redirect"));
30 31
       const redirect = decodeURIComponent(searchParams.get("redirect"));
31 32
       let href = "";
32 33
       if (redirect.indexOf("#") === -1) {
@@ -38,10 +39,11 @@ export default (props) => {
38 39
       }
39 40
       window.location.href = href;
40 41
     } else if (searchParams.get("back")) {
41
-      // console.log(navigate(-1), "---");
42
+      // console.log('else if', searchParams.get("back"));
42 43
       navigate(-1);
43 44
       // navigate("/");
44 45
     } else {
46
+      console.log('else');
45 47
       navigate("/");
46 48
     }
47 49
   };

+ 38
- 8
src/pages/project/Edit.jsx ファイルの表示

@@ -5,6 +5,7 @@ import { useSearchParams, useNavigate } from "react-router-dom";
5 5
 import Page from "@/components/Page";
6 6
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
7 7
 import { postTaProject, putTaProject, getTaProjectById } from "@/services/project";
8
+import { getTaCustom } from "@/services/taCustom";
8 9
 import moment from 'moment'
9 10
 const { Option } = Select;
10 11
 
@@ -12,12 +13,14 @@ export default (props) => {
12 13
 
13 14
   const [loading, startLoading, cancelLoading] = useBool();
14 15
   const [submiting, startSubmit, cancelSubmit] = useBool();
16
+  const [list, setList] = React.useState([]);
15 17
 
16 18
   const [searchParams] = useSearchParams();
17 19
   const [form] = Form.useForm();
18 20
   const navigate = useNavigate();
19 21
 
20 22
   const id = searchParams.get("id");
23
+  // const Format = format("YYYY-MM-DD HH:mm:ss") : undefined;
21 24
 
22 25
   React.useEffect(() => {
23 26
     if (id) {
@@ -26,19 +29,32 @@ export default (props) => {
26 29
         // const endTime = res.endTime ? { endTime: moment(res.endTime) } : undefined;
27 30
         // form.setFieldsValue({ ...res, startTime, endTime });
28 31
         // console.log('-------res', { ...res, startTime, endTime })
29
-        form.setFieldsValue({ ...res, startTime: res.startTime ? moment(res.startTime) : undefined, endTime: res.endTime ? moment(res.endTime) : undefined });
32
+        form.setFieldsValue({
33
+          ...res, startTime: res.startTime ? moment(res.startTime) : undefined, endTime: res.endTime ? moment(res.endTime) : undefined,
34
+          crm: res.crm ? moment(res.crm) : undefined
35
+        });
30 36
       })
31 37
     }
38
+    getTaCustom().then((res) => {
39
+      setList(res.records);
40
+    })
32 41
   }, [id])
33 42
 
43
+  const changeDate = (val) => {
44
+    return val.format("YYYY-MM-DD HH:mm:ss")
45
+  }
46
+
34 47
   const onFinish = (values) => {
35
-    const startTime = values.startTime ? moment(values.startTime).format("YYYY-MM-DD HH:mm:ss") : undefined;
36
-    const endTime = values.endTime ? moment(values.endTime).format("YYYY-MM-DD HH:mm:ss") : undefined;
48
+    const startTime = values.startTime ? changeDate(values.startTime) : undefined;
49
+    const endTime = values.endTime ? changeDate(values.endTime) : undefined;
50
+    const crm = values.crm ? changeDate(values.crm) : undefined;
51
+
52
+    // console.log('crm', crm)
37 53
     startSubmit();
38 54
     if (id) {
39 55
       // console.log('startTime,...values', { ...values, startTime, endTime })
40 56
       //更新
41
-      putTaProject(id, { ...values, startTime, endTime }).then((res) => {
57
+      putTaProject(id, { ...values, startTime, endTime, crm }).then((res) => {
42 58
         cancelSubmit();
43 59
         navigate(-1)
44 60
       }).catch(() => {
@@ -46,7 +62,8 @@ export default (props) => {
46 62
       })
47 63
     } else {
48 64
       //新增
49
-      postTaProject(values).then((res) => {
65
+      // console.log('新增', { ...values, startTime, endTime, crm })
66
+      postTaProject({ ...values, startTime, endTime, crm }).then((res) => {
50 67
         cancelSubmit();
51 68
         navigate(-1)
52 69
       }).catch(() => {
@@ -55,6 +72,8 @@ export default (props) => {
55 72
     }
56 73
   }
57 74
 
75
+  // console.log('first', list);
76
+
58 77
   return (
59 78
     <Page>
60 79
       <Card loading={loading}>
@@ -86,7 +105,21 @@ export default (props) => {
86 105
           <Form.Item name="endTime" label="结束日期">
87 106
             <DatePicker placeholder="请选择" style={{ width: '100%' }} locale />
88 107
           </Form.Item>
108
+          <Form.Item name="crm" label="运维服务期">
109
+            <DatePicker placeholder="请选择" style={{ width: '100%' }} locale />
110
+          </Form.Item>
89 111
 
112
+          <Form.Item name="customId" label="所属客户">
113
+            <Select placeholder="请选择">
114
+              {
115
+                list.map((res, index) => {
116
+                  return (
117
+                    <Option key={index} value={res.customId}>{res.customName}</Option>
118
+                  )
119
+                })
120
+              }
121
+            </Select>
122
+          </Form.Item>
90 123
           <Form.Item name="quotation" label="合同报价">
91 124
             <Input placeholder="请输入" />
92 125
           </Form.Item>
@@ -132,9 +165,6 @@ export default (props) => {
132 165
             <Input placeholder="请输入" />
133 166
           </Form.Item>
134 167
 
135
-          <Form.Item name="customId" label="客户ID">
136
-            <Input placeholder="请输入" />
137
-          </Form.Item>
138 168
 
139 169
           <Form.Item {...tailFormItemLayout}>
140 170
             <Button loading={submiting} type="primary" htmlType="submit">

+ 21
- 1
src/pages/project/index.jsx ファイルの表示

@@ -2,9 +2,11 @@ import React from "react";
2 2
 import { useNavigate } from "react-router-dom";
3 3
 import { Button, Popconfirm } from "antd";
4 4
 import List from "@/components/Page/List";
5
+import { queryDict } from "@/utils/request";
6
+import { getTaCustom } from "@/services/taCustom";
5 7
 import { getTaProject, deleteTaProject } from "@/services/project";
6 8
 
7
-
9
+const TaCustom = queryDict(getTaCustom, { labelKey: 'customName', valueKey: 'customId' })
8 10
 
9 11
 export default (props) => {
10 12
   const actionRef = React.useRef();
@@ -30,6 +32,18 @@ export default (props) => {
30 32
       dataIndex: "endTime",
31 33
       search: false,
32 34
     },
35
+    {
36
+      title: "运维服务期",
37
+      dataIndex: "crm",
38
+      search: false,
39
+    },
40
+    {
41
+      title: "所属客户",
42
+      dataIndex: "customId",
43
+      valueType: "select",
44
+      search: false,
45
+      request: TaCustom
46
+    },
33 47
     {
34 48
       title: "合同报价",
35 49
       dataIndex: "quotation",
@@ -128,6 +142,12 @@ export default (props) => {
128 142
       onDelete={onDelete}
129 143
       onEdit={onEdit}
130 144
       request={getTaProject}
145
+      columnOptionRender={(_, res) => [
146
+        // console.log('res', res.webUrl),
147
+        <Button key={1} style={{ padding: 0 }} type="link" href={res.webUrl}>
148
+          跳转
149
+        </Button>
150
+      ]}
131 151
     />
132 152
   );
133 153
 };

+ 30
- 1
src/pages/user/Edit.jsx ファイルの表示

@@ -4,6 +4,7 @@ import useBool from "@/utils/hooks/useBool";
4 4
 import { useSearchParams, useNavigate } from "react-router-dom";
5 5
 import Page from "@/components/Page";
6 6
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
7
+import { postSysUser, putSysUser, getSysUserById } from "@/services/sysuser";
7 8
 const { Option } = Select;
8 9
 
9 10
 export default (props) => {
@@ -17,8 +18,36 @@ export default (props) => {
17 18
 
18 19
   const id = searchParams.get("id");
19 20
 
20
-  const onFinish = () => {
21
+  React.useEffect(() => {
22
+    if (id) {
23
+      console.log('---id--->', id)
24
+      getSysUserById(id).then((res) => {
25
+        console.log('res', res)
26
+        form.setFieldsValue(res);
27
+      })
28
+    }
29
+  }, [id])
21 30
 
31
+  const onFinish = (values) => {
32
+    startSubmit();
33
+    if (id) {
34
+      // console.log('---id--->', id)
35
+      //修改
36
+      putSysUser(id, values).then((res) => {
37
+        cancelSubmit();
38
+        navigate(-1);
39
+      }).catch(() => {
40
+        cancelSubmit();
41
+      })
42
+    } else {
43
+      //新增
44
+      postSysUser(values).then((res) => {
45
+        cancelSubmit();
46
+        navigate(-1)
47
+      }).catch(() => {
48
+        cancelSubmit();
49
+      })
50
+    }
22 51
   }
23 52
 
24 53
   return (

+ 11
- 9
src/pages/user/index.jsx ファイルの表示

@@ -2,17 +2,20 @@ import React from "react";
2 2
 import { useNavigate } from "react-router-dom";
3 3
 import { Button, Popconfirm, message } from "antd";
4 4
 import { ProTable } from "@ant-design/pro-components";
5
-import { queryTable, queryDict } from "@/utils/request";
5
+import { queryTable } from "@/utils/request";
6
+import { getSysUser, deleteSysUser } from "@/services/sysuser";
6 7
 import Page from "@/components/Page";
7 8
 
8
-
9
+const sysUserList = queryTable(getSysUser)
9 10
 
10 11
 export default (props) => {
11 12
   const actionRef = React.useRef();
12 13
   const navigate = useNavigate();
13 14
 
14
-  const handleDelete = () => {
15
-
15
+  const handleDelete = (id) => {
16
+    deleteSysUser(id).then((res) => {
17
+      actionRef.current.reload();
18
+    })
16 19
   }
17 20
 
18 21
   const columns = [
@@ -34,9 +37,8 @@ export default (props) => {
34 37
           key={3}
35 38
           style={{ padding: 0 }}
36 39
           type="link"
37
-          disabled
38 40
           onClick={() => {
39
-            navigate(`/user/edit?id=${record}`);
41
+            navigate(`/user/edit?id=${record.userId}`);
40 42
           }}
41 43
         >
42 44
           编辑
@@ -44,7 +46,7 @@ export default (props) => {
44 46
         <Popconfirm
45 47
           key={4}
46 48
           title="您是否确认删除 ?"
47
-          onConfirm={() => handleDelete(record)}
49
+          onConfirm={() => handleDelete(record.userId)}
48 50
           okText="确定"
49 51
           cancelText="取消"
50 52
         >
@@ -60,7 +62,7 @@ export default (props) => {
60 62
     <Page>
61 63
       <ProTable
62 64
         actionRef={actionRef}
63
-        rowKey=""
65
+        rowKey="userId"
64 66
         toolBarRender={() => [
65 67
           <Button
66 68
             key="1"
@@ -72,7 +74,7 @@ export default (props) => {
72 74
             新增
73 75
           </Button>,
74 76
         ]}
75
-        // request={{}}
77
+        request={sysUserList}
76 78
         columns={columns}
77 79
       />
78 80
     </Page>

+ 2
- 1
src/routes/routes.jsx ファイルの表示

@@ -99,7 +99,8 @@ export const defaultRoutes = [
99 99
   {
100 100
     path: "*",
101 101
     element: <Page404 />,
102
-  }
102
+  },
103
+
103 104
 ];
104 105
 
105 106
 export function mergeAuthRoutes (r1, r2) {

+ 26
- 0
src/services/sysUser.js ファイルの表示

@@ -0,0 +1,26 @@
1
+import request from "@/utils/request";
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getSysUser = (params) => request(`/api/sysUser/paginQuery`, { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postSysUser = (data) => request('/api/sysUser/addList', { data, method: 'post' });
12
+
13
+/*
14
+ * 更新数据
15
+ */
16
+export const putSysUser = (id, data) => request(`/api/sysUser/edit/${id}`, { data, method: 'put' });
17
+
18
+/*
19
+ * 通过主键删除数据
20
+ */
21
+export const deleteSysUser = (id) => request(`/api/sysUser/deleteById/${id}`, { method: 'delete' });
22
+
23
+/*
24
+ * 通过ID查询单条数据
25
+ */
26
+export const getSysUserById = (id) => request(`/api/sysUser/queryById/${id}`);

+ 20
- 18
src/store/models/user.js ファイルの表示

@@ -5,34 +5,36 @@ import { getMenuItems } from "@/routes/menus";
5 5
 import { isLogin } from "@/services/login";
6 6
 
7 7
 export default function useUser () {
8
-  const [user, setUser] = useState();
8
+  // const [user, setUser] = useState();
9 9
   const menusRef = useRef();
10 10
   const routesRef = useRef();
11 11
 
12
-  const getCurrentUser = (params) =>
12
+  const getCurrentUser = () =>
13 13
     new Promise((resolve, reject) => {
14
-      isLogin(params)
15
-        .then((res) => {
16
-          const { user } = res;
17
-          // const permissions = res;
14
+      // isLogin()
15
+      //   .then((res) => {
16
+      // const { user } = res;
17
+      // const permissions = res;
18 18
 
19
-          // authRoutes 是所有待验证授权的路由
20
-          // authedRoutes 是已经被授权的路由
21
-          // const authedRoutes = authRoutes;
19
+      // authRoutes 是所有待验证授权的路由
20
+      // authedRoutes 是已经被授权的路由
21
+      // const authedRoutes = authRoutes;
22 22
 
23
-          menusRef.current = getMenuItems(defaultRoutes);
24
-          routesRef.current = mergeAuthRoutes(defaultRoutes);
25
-          // console.log('menusRef.current', menusRef.current)
23
+      menusRef.current = getMenuItems(authRoutes);
24
+      routesRef.current = mergeAuthRoutes(defaultRoutes);
25
+      // console.log('menusRef.current', menusRef.current)
26 26
 
27
-          setUser(user);
28
-          resolve(user);
29
-        })
30
-        .catch(reject);
27
+      // setUser(user);
28
+      resolve();
29
+      // })
30
+
31
+    }).catch((e) => {
32
+      console.log(e)
31 33
     });
32 34
 
33 35
   return {
34
-    user,
35
-    setUser,
36
+    // user,
37
+    // setUser,
36 38
     getCurrentUser,
37 39
     menus: menusRef.current || [],
38 40
     routes: routesRef.current || [],

+ 3
- 1
src/utils/request.js ファイルの表示

@@ -21,6 +21,8 @@ instance.interceptors.request.use(
21 21
       params = {},
22 22
     } = config;
23 23
     let token = localStorage.getItem("token") || "";
24
+    const tokenB = (`Bearer ${token}`);
25
+    console.log('----tokenB---->', tokenB);
24 26
 
25 27
     let noTip = silent;
26 28
     if (noTip === undefined) {
@@ -43,7 +45,7 @@ instance.interceptors.request.use(
43 45
       silent: noTip,
44 46
       headers: {
45 47
         ...headers,
46
-        Authorization: token,
48
+        Authorization: tokenB,
47 49
       },
48 50
       responseType: download ? "blob" : responseType,
49 51
     };