fangmingyue 2 lat temu
rodzic
commit
da1f1bc59f

+ 4
- 3
src/components/Page/List.jsx Wyświetl plik

22
       valueType: 'option',
22
       valueType: 'option',
23
       key: 'option',
23
       key: 'option',
24
       ellipsis: true,
24
       ellipsis: true,
25
+      fixed: 'right',
25
       render: (_, record) => [
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
           </Button>
31
           </Button>
31
         ),
32
         ),
71
         actionRef={actionRef}
72
         actionRef={actionRef}
72
         toolBarRender={() => [
73
         toolBarRender={() => [
73
           (
74
           (
74
-            onAdd && 
75
+            onAdd &&
75
             <Button
76
             <Button
76
               key="1"
77
               key="1"
77
               type="primary"
78
               type="primary"

+ 2
- 2
src/layouts/AuthLayout/components/Header/Exit.jsx Wyświetl plik

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

+ 1
- 1
src/pages/custom/index.jsx Wyświetl plik

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

+ 3
- 1
src/pages/login/index.jsx Wyświetl plik

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

+ 38
- 8
src/pages/project/Edit.jsx Wyświetl plik

5
 import Page from "@/components/Page";
5
 import Page from "@/components/Page";
6
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
6
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
7
 import { postTaProject, putTaProject, getTaProjectById } from "@/services/project";
7
 import { postTaProject, putTaProject, getTaProjectById } from "@/services/project";
8
+import { getTaCustom } from "@/services/taCustom";
8
 import moment from 'moment'
9
 import moment from 'moment'
9
 const { Option } = Select;
10
 const { Option } = Select;
10
 
11
 
12
 
13
 
13
   const [loading, startLoading, cancelLoading] = useBool();
14
   const [loading, startLoading, cancelLoading] = useBool();
14
   const [submiting, startSubmit, cancelSubmit] = useBool();
15
   const [submiting, startSubmit, cancelSubmit] = useBool();
16
+  const [list, setList] = React.useState([]);
15
 
17
 
16
   const [searchParams] = useSearchParams();
18
   const [searchParams] = useSearchParams();
17
   const [form] = Form.useForm();
19
   const [form] = Form.useForm();
18
   const navigate = useNavigate();
20
   const navigate = useNavigate();
19
 
21
 
20
   const id = searchParams.get("id");
22
   const id = searchParams.get("id");
23
+  // const Format = format("YYYY-MM-DD HH:mm:ss") : undefined;
21
 
24
 
22
   React.useEffect(() => {
25
   React.useEffect(() => {
23
     if (id) {
26
     if (id) {
26
         // const endTime = res.endTime ? { endTime: moment(res.endTime) } : undefined;
29
         // const endTime = res.endTime ? { endTime: moment(res.endTime) } : undefined;
27
         // form.setFieldsValue({ ...res, startTime, endTime });
30
         // form.setFieldsValue({ ...res, startTime, endTime });
28
         // console.log('-------res', { ...res, startTime, endTime })
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
   }, [id])
41
   }, [id])
33
 
42
 
43
+  const changeDate = (val) => {
44
+    return val.format("YYYY-MM-DD HH:mm:ss")
45
+  }
46
+
34
   const onFinish = (values) => {
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
     startSubmit();
53
     startSubmit();
38
     if (id) {
54
     if (id) {
39
       // console.log('startTime,...values', { ...values, startTime, endTime })
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
         cancelSubmit();
58
         cancelSubmit();
43
         navigate(-1)
59
         navigate(-1)
44
       }).catch(() => {
60
       }).catch(() => {
46
       })
62
       })
47
     } else {
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
         cancelSubmit();
67
         cancelSubmit();
51
         navigate(-1)
68
         navigate(-1)
52
       }).catch(() => {
69
       }).catch(() => {
55
     }
72
     }
56
   }
73
   }
57
 
74
 
75
+  // console.log('first', list);
76
+
58
   return (
77
   return (
59
     <Page>
78
     <Page>
60
       <Card loading={loading}>
79
       <Card loading={loading}>
86
           <Form.Item name="endTime" label="结束日期">
105
           <Form.Item name="endTime" label="结束日期">
87
             <DatePicker placeholder="请选择" style={{ width: '100%' }} locale />
106
             <DatePicker placeholder="请选择" style={{ width: '100%' }} locale />
88
           </Form.Item>
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
           <Form.Item name="quotation" label="合同报价">
123
           <Form.Item name="quotation" label="合同报价">
91
             <Input placeholder="请输入" />
124
             <Input placeholder="请输入" />
92
           </Form.Item>
125
           </Form.Item>
132
             <Input placeholder="请输入" />
165
             <Input placeholder="请输入" />
133
           </Form.Item>
166
           </Form.Item>
134
 
167
 
135
-          <Form.Item name="customId" label="客户ID">
136
-            <Input placeholder="请输入" />
137
-          </Form.Item>
138
 
168
 
139
           <Form.Item {...tailFormItemLayout}>
169
           <Form.Item {...tailFormItemLayout}>
140
             <Button loading={submiting} type="primary" htmlType="submit">
170
             <Button loading={submiting} type="primary" htmlType="submit">

+ 21
- 1
src/pages/project/index.jsx Wyświetl plik

2
 import { useNavigate } from "react-router-dom";
2
 import { useNavigate } from "react-router-dom";
3
 import { Button, Popconfirm } from "antd";
3
 import { Button, Popconfirm } from "antd";
4
 import List from "@/components/Page/List";
4
 import List from "@/components/Page/List";
5
+import { queryDict } from "@/utils/request";
6
+import { getTaCustom } from "@/services/taCustom";
5
 import { getTaProject, deleteTaProject } from "@/services/project";
7
 import { getTaProject, deleteTaProject } from "@/services/project";
6
 
8
 
7
-
9
+const TaCustom = queryDict(getTaCustom, { labelKey: 'customName', valueKey: 'customId' })
8
 
10
 
9
 export default (props) => {
11
 export default (props) => {
10
   const actionRef = React.useRef();
12
   const actionRef = React.useRef();
30
       dataIndex: "endTime",
32
       dataIndex: "endTime",
31
       search: false,
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
       title: "合同报价",
48
       title: "合同报价",
35
       dataIndex: "quotation",
49
       dataIndex: "quotation",
128
       onDelete={onDelete}
142
       onDelete={onDelete}
129
       onEdit={onEdit}
143
       onEdit={onEdit}
130
       request={getTaProject}
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 Wyświetl plik

4
 import { useSearchParams, useNavigate } from "react-router-dom";
4
 import { useSearchParams, useNavigate } from "react-router-dom";
5
 import Page from "@/components/Page";
5
 import Page from "@/components/Page";
6
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
6
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
7
+import { postSysUser, putSysUser, getSysUserById } from "@/services/sysuser";
7
 const { Option } = Select;
8
 const { Option } = Select;
8
 
9
 
9
 export default (props) => {
10
 export default (props) => {
17
 
18
 
18
   const id = searchParams.get("id");
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
   return (
53
   return (

+ 11
- 9
src/pages/user/index.jsx Wyświetl plik

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

+ 2
- 1
src/routes/routes.jsx Wyświetl plik

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

+ 26
- 0
src/services/sysUser.js Wyświetl plik

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 Wyświetl plik

5
 import { isLogin } from "@/services/login";
5
 import { isLogin } from "@/services/login";
6
 
6
 
7
 export default function useUser () {
7
 export default function useUser () {
8
-  const [user, setUser] = useState();
8
+  // const [user, setUser] = useState();
9
   const menusRef = useRef();
9
   const menusRef = useRef();
10
   const routesRef = useRef();
10
   const routesRef = useRef();
11
 
11
 
12
-  const getCurrentUser = (params) =>
12
+  const getCurrentUser = () =>
13
     new Promise((resolve, reject) => {
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
   return {
35
   return {
34
-    user,
35
-    setUser,
36
+    // user,
37
+    // setUser,
36
     getCurrentUser,
38
     getCurrentUser,
37
     menus: menusRef.current || [],
39
     menus: menusRef.current || [],
38
     routes: routesRef.current || [],
40
     routes: routesRef.current || [],

+ 3
- 1
src/utils/request.js Wyświetl plik

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