Explorar el Código

Merge branch 'v2' of http://git.ycjcjy.com/yunzhi/crm_pc into v2

张涛 hace 1 año
padre
commit
24b0a48a6a

+ 34
- 41
src/layouts/AuthLayout/components/Header/User.jsx Ver fichero

@@ -1,19 +1,14 @@
1
-import React, {
2
-  useState,
3
-  forwardRef,
4
-  useRef,
5
-  useImperativeHandle,
6
-} from "react";
7
-import { Avatar, Dropdown } from "antd";
1
+import React, { useState, forwardRef, useRef, useImperativeHandle } from 'react'
2
+import { Avatar, Dropdown } from 'antd'
8 3
 import {
9 4
   ModalForm,
10 5
   ProFormText,
11 6
   ProFormDependency,
12
-} from "@ant-design/pro-components";
13
-import md5 from "md5";
14
-import { changePassword } from "@/services/login";
7
+} from '@ant-design/pro-components'
8
+import md5 from 'md5'
9
+import { changePassword } from '@/services/login'
15 10
 
16
-const DefaultAvatar = ({ color = "#1296db" }) => (
11
+const DefaultAvatar = ({ color = '#1296db' }) => (
17 12
   <svg
18 13
     viewBox="0 0 1024 1024"
19 14
     version="1.1"
@@ -26,26 +21,25 @@ const DefaultAvatar = ({ color = "#1296db" }) => (
26 21
       fill={color}
27 22
     ></path>
28 23
   </svg>
29
-);
24
+)
30 25
 
31 26
 const ChangePassword = forwardRef((props, ref) => {
32
-
33
-  const [visible, setVisible] = useState(false);
27
+  const [visible, setVisible] = useState(false)
34 28
 
35 29
   const onFinish = async (values) => {
36 30
     const data = {
37 31
       password: values.newPassword,
38
-    };
39
-    await changePassword(data);
32
+    }
33
+    await changePassword(data)
40 34
 
41
-    return true;
42
-  };
35
+    return true
36
+  }
43 37
 
44 38
   useImperativeHandle(ref, () => {
45 39
     return {
46 40
       show: () => setVisible(true),
47
-    };
48
-  });
41
+    }
42
+  })
49 43
 
50 44
   return (
51 45
     <ModalForm
@@ -58,28 +52,28 @@ const ChangePassword = forwardRef((props, ref) => {
58 52
       <ProFormText.Password
59 53
         label="原始密码"
60 54
         name="password"
61
-        rules={[{ required: true, message: "请输入原始密码!" }]}
55
+        rules={[{ required: true, message: '请输入原始密码!' }]}
62 56
       />
63 57
       <ProFormText.Password
64 58
         label="新密码"
65 59
         name="newPassword"
66
-        rules={[{ required: true, message: "请输入新密码!" }]}
60
+        rules={[{ required: true, message: '请输入新密码!' }]}
67 61
       />
68 62
 
69
-      <ProFormDependency name={["newPassword"]}>
63
+      <ProFormDependency name={['newPassword']}>
70 64
         {({ newPassword }) => (
71 65
           <ProFormText.Password
72 66
             label="确认新密码"
73 67
             name="newPassword2"
74 68
             rules={[
75
-              { required: true, message: "请输入新密码!" },
69
+              { required: true, message: '请输入新密码!' },
76 70
               () => ({
77
-                validator (_, value) {
71
+                validator(_, value) {
78 72
                   if (!value || value == newPassword) {
79
-                    return Promise.resolve();
73
+                    return Promise.resolve()
80 74
                   }
81 75
 
82
-                  return Promise.reject("两次输入密码不一致");
76
+                  return Promise.reject('两次输入密码不一致')
83 77
                 },
84 78
               }),
85 79
             ]}
@@ -87,32 +81,31 @@ const ChangePassword = forwardRef((props, ref) => {
87 81
         )}
88 82
       </ProFormDependency>
89 83
     </ModalForm>
90
-  );
91
-});
84
+  )
85
+})
92 86
 
93 87
 export default (props) => {
94 88
   const items = [
95 89
     {
96
-      key: "changePassword",
97
-      label: "修改密码",
90
+      key: 'changePassword',
91
+      label: '修改密码',
98 92
     },
99
-  ];
100
-
101
-  const passRef = useRef();
102
-  const { user = {} } = props;
93
+  ]
103 94
 
95
+  const passRef = useRef()
96
+  const { user = {} } = props
104 97
   const onClick = ({ key }) => {
105
-    if (key === "changePassword") {
106
-      passRef.current.show();
98
+    if (key === 'changePassword') {
99
+      passRef.current.show()
107 100
     }
108
-  };
101
+  }
109 102
   return (
110 103
     <Dropdown menu={{ items, onClick }}>
111 104
       <div className="user-info">
112 105
         <Avatar size={24} src={<DefaultAvatar />} />
113
-        <span className="font">{user?.userName}</span>
106
+        <span className="font">{user?.user?.userName}</span>
114 107
         <ChangePassword user={user} ref={passRef} />
115 108
       </div>
116 109
     </Dropdown>
117
-  );
118
-};
110
+  )
111
+}

+ 107
- 0
src/pages/projectContact/Edit.jsx Ver fichero

@@ -0,0 +1,107 @@
1
+import React, { useEffect, useRef, useState, forwardRef } from 'react'
2
+import {
3
+  postTaProjectContact,
4
+  putTaProjectContact,
5
+  getTaProjectContactId,
6
+} from '@/services/taProjectContact'
7
+import { Button, Card, Row, Col, Form, Input } from 'antd'
8
+import {
9
+  ProForm,
10
+  ProFormDateTimeRangePicker,
11
+  ProFormDatePicker,
12
+  ProFormMoney,
13
+  ProFormSelect,
14
+  ProFormText,
15
+  ProFormTextArea,
16
+  ProFormRadio,
17
+} from '@ant-design/pro-components'
18
+import Page from '@/components/Page'
19
+import { formItemLayout, tailFormItemLayout } from '@/utils/form'
20
+import { useNavigate, useSearchParams } from 'react-router-dom'
21
+import moment from 'moment'
22
+
23
+export default (props) => {
24
+  const formRef = useRef()
25
+  const navigate = useNavigate()
26
+
27
+  const [params] = useSearchParams()
28
+  const id = params.get('id')
29
+
30
+  useEffect(() => {
31
+    if (id) {
32
+      getTaProjectContactId(id).then((res) => {
33
+        formRef.current?.setFieldsValue(res)
34
+      })
35
+    }
36
+  }, [])
37
+
38
+  const onFinish = (values) => {
39
+    if (!id) {
40
+      postTaProjectContact(values).then((res) => {
41
+        navigate(-1)
42
+      })
43
+    } else if (id) {
44
+      let personId = id
45
+      putTaProjectContact(id, { personId, ...values }).then((res) => {
46
+        navigate(-1)
47
+      })
48
+    }
49
+  }
50
+
51
+  let formatter = new Intl.NumberFormat('zh-CN', {
52
+    minimumFractionDigits: 4,
53
+    maximumFractionDigits: 4,
54
+  })
55
+
56
+  return (
57
+    <Page>
58
+      <Card>
59
+        <ProForm
60
+          formRef={formRef}
61
+          onFinish={onFinish}
62
+          layout="horizontal"
63
+          initialValues={{ isDefault: 0 }}
64
+          {...formItemLayout}
65
+          submitter={{
66
+            render: (_, doms) => [
67
+              <Row>
68
+                <Col offset={8}>
69
+                  <Button type="primary" htmlType="submit">
70
+                    提交
71
+                  </Button>
72
+                </Col>
73
+                <Col offset={1}>
74
+                  <Button onClick={() => navigate(-1)}>返回</Button>
75
+                </Col>
76
+              </Row>,
77
+            ],
78
+          }}
79
+        >
80
+          <ProFormText name="personName" label="名称" />
81
+          <ProFormSelect
82
+            name="sex"
83
+            label="性别"
84
+            options={[
85
+              { label: '男', value: 1 },
86
+              { label: '女', value: 2 },
87
+              { label: '未知', value: 9 },
88
+            ]}
89
+          />
90
+          <ProFormText name="age" label="年龄" />
91
+          <ProFormText name="phone" label="手机号" />
92
+          <ProFormText name="email" label="邮箱" />
93
+          <ProFormText name="position" label="职位" />
94
+          <ProFormDatePicker name="birthDay" label="生日" />
95
+          <ProFormRadio.Group
96
+            name="isDefault"
97
+            label="是否默认联系人"
98
+            options={[
99
+              { label: '是', value: 1 },
100
+              { label: '否', value: 0 },
101
+            ]}
102
+          />
103
+        </ProForm>
104
+      </Card>
105
+    </Page>
106
+  )
107
+}

+ 10
- 4
src/pages/projectContact/index.jsx Ver fichero

@@ -30,6 +30,7 @@ export default (props) => {
30 30
     {
31 31
       title: '联系人名称',
32 32
       dataIndex: 'personName',
33
+      ellipsis: true,
33 34
     },
34 35
     {
35 36
       title: '性别',
@@ -45,8 +46,8 @@ export default (props) => {
45 46
     {
46 47
       title: '生日',
47 48
       dataIndex: 'birthDay',
48
-      search: false,
49
-      render: (t) => moment(t).format('YYYY-MM-DD'),
49
+      // render: (t) => moment(t).format('YYYY-MM-DD'),
50
+      valueType: 'date',
50 51
     },
51 52
 
52 53
     {
@@ -56,6 +57,8 @@ export default (props) => {
56 57
     {
57 58
       title: '邮箱',
58 59
       dataIndex: 'email',
60
+      ellipsis: true,
61
+      search: false,
59 62
     },
60 63
     {
61 64
       title: '职位',
@@ -64,6 +67,7 @@ export default (props) => {
64 67
     {
65 68
       title: '是否默认联系人',
66 69
       dataIndex: 'isDefault',
70
+      search: false,
67 71
       render: (t) => (t == 1 ? '是' : '否'),
68 72
     },
69 73
   ]
@@ -71,9 +75,11 @@ export default (props) => {
71 75
     <List
72 76
       rowKey="personId"
73 77
       actionRef={actionRef}
74
-      //   onEdit={(record) => navigate(`/projectContact/edit?id=${record.personId}`)}
78
+      onEdit={(record) =>
79
+        navigate(`/projectContact/edit?id=${record?.personId}`)
80
+      }
75 81
       onDelete={(record) =>
76
-        deleteTaProjectContact(record.projectId).then(() =>
82
+        deleteTaProjectContact(record?.personId).then(() =>
77 83
           actionRef.current.reload()
78 84
         )
79 85
       }

+ 17
- 4
src/routes/routes.jsx Ver fichero

@@ -5,6 +5,10 @@ import {
5 5
   HeartOutlined,
6 6
   HourglassTwoTone,
7 7
   StopFilled,
8
+  UserAddOutlined,
9
+  UsergroupAddOutlined,
10
+  TransactionOutlined,
11
+  PayCircleOutlined,
8 12
 } from '@ant-design/icons'
9 13
 import { Outlet, Navigate } from 'react-router-dom'
10 14
 import AuthLayout from '@/layouts/AuthLayout'
@@ -15,6 +19,7 @@ import AdUserEdit from '@/pages/adUser/Edit'
15 19
 import Project from '@/pages/project'
16 20
 import ProjectEdit from '@/pages/project/Edit'
17 21
 import ProjectContact from '@/pages/projectContact'
22
+import ProjectContactEdit from '@/pages/projectContact/Edit'
18 23
 import ProjectDeploy from '@/pages/projectDeploy'
19 24
 import ProjectDeployEdit from '@/pages/project/components/ProjectDeployEdit'
20 25
 import ProjectNode from '@/pages/projectNode'
@@ -98,7 +103,15 @@ export const authRoutes = [
98 103
     element: <ProjectContact />,
99 104
     meta: {
100 105
       title: '项目联系人管理',
101
-      icon: <FileTextOutlined />,
106
+      icon: <UserAddOutlined />,
107
+    },
108
+  },
109
+  {
110
+    path: 'projectContact/edit',
111
+    element: <ProjectContactEdit />,
112
+    meta: {
113
+      title: '项目联系人维护',
114
+      hideInMenu: true,
102 115
     },
103 116
   },
104 117
   // {
@@ -154,7 +167,7 @@ export const authRoutes = [
154 167
     element: <Custom />,
155 168
     meta: {
156 169
       title: '客户管理',
157
-      icon: <StopFilled />,
170
+      icon: <UsergroupAddOutlined />,
158 171
     },
159 172
   },
160 173
   {
@@ -203,7 +216,7 @@ export const authRoutes = [
203 216
     element: <Finance />,
204 217
     meta: {
205 218
       title: '公司财务管理',
206
-      icon: <HourglassTwoTone />,
219
+      icon: <TransactionOutlined />,
207 220
     },
208 221
   },
209 222
   {
@@ -219,7 +232,7 @@ export const authRoutes = [
219 232
     element: <FinanceItem />,
220 233
     meta: {
221 234
       title: '收付款管理',
222
-      icon: <HourglassTwoTone />,
235
+      icon: <PayCircleOutlined />,
223 236
     },
224 237
   },
225 238
   {