Bladeren bron

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

张涛 1 jaar geleden
bovenliggende
commit
29cd612997
4 gewijzigde bestanden met toevoegingen van 279 en 53 verwijderingen
  1. 86
    5
      src/pages/custom/Edit.jsx
  2. 121
    4
      src/pages/custom/index.jsx
  3. 46
    44
      src/pages/project/index.jsx
  4. 26
    0
      src/services/taCustom.js

+ 86
- 5
src/pages/custom/Edit.jsx Bestand weergeven

@@ -1,6 +1,87 @@
1
-import React from 'react'
1
+import React, { useRef } from 'react'
2
+import { Button, Card, Form, Input, Select } from 'antd'
3
+import {
4
+  ProForm,
5
+  ProFormDateTimeRangePicker,
6
+  ProFormMoney,
7
+  ProFormSelect,
8
+  ProFormText,
9
+} from '@ant-design/pro-components'
10
+import useBool from '@/utils/hooks/useBool'
11
+import { useSearchParams, useNavigate } from 'react-router-dom'
12
+import Page from '@/components/Page'
13
+import { formItemLayout, tailFormItemLayout } from '@/utils/form'
14
+import { postTaCustom, putTaCustom, getTaCustomId } from '@/services/taCustom'
15
+const { Option } = Select
16
+
2 17
 export default (props) => {
3
-return (
4
-<div></div>
5
-)
6
-}
18
+  const formRef = useRef()
19
+  const [loading, startLoading, cancelLoading] = useBool()
20
+  const [submiting, startSubmit, cancelSubmit] = useBool()
21
+
22
+  const [searchParams] = useSearchParams()
23
+  // const [form] = Form.useForm()
24
+  const navigate = useNavigate()
25
+
26
+  const id = searchParams.get('id')
27
+
28
+  React.useEffect(() => {
29
+    if (id) {
30
+      getTaCustomId(id).then((res) => {
31
+        formRef.current.setFieldsValue(res)
32
+      })
33
+    }
34
+  })
35
+
36
+  const onFinish = (values) => {
37
+    startSubmit()
38
+    if (id) {
39
+      //修改
40
+      putTaCustom(id, values)
41
+        .then((res) => {
42
+          cancelSubmit()
43
+          navigate(-1)
44
+        })
45
+        .catch(() => {
46
+          cancelSubmit()
47
+        })
48
+    } else {
49
+      //新增
50
+      postTaCustom(values)
51
+        .then((res) => {
52
+          cancelSubmit()
53
+          navigate(-1)
54
+        })
55
+        .catch(() => {
56
+          cancelSubmit()
57
+        })
58
+    }
59
+  }
60
+
61
+  return (
62
+    <Page>
63
+      <Card loading={loading}>
64
+        <ProForm
65
+          formRef={formRef}
66
+          onFinish={onFinish}
67
+          layout="horizontal"
68
+          submitter={{
69
+            render: (_, doms) => [
70
+              doms.find((dom) => dom.props?.children === '提交'),
71
+              <Button onClick={() => navigate(-1)}>返回</Button>,
72
+            ],
73
+          }}
74
+        >
75
+          <ProFormText name="customName" label="客户公司" />
76
+          <ProFormText name="dutyParagraph" label="客户税号" />
77
+          <ProFormText name="openingBank" label="开户行" />
78
+          <ProFormText name="account" label="客户账号" />
79
+          <ProFormText name="contactsName" label="联系人姓名" />
80
+          <ProFormText name="contactsTitle" label="联系人头衔" />
81
+          <ProFormText name="contactsPhone" label="联系人手机" />
82
+          <ProFormText name="contactsEmail" label="联系人邮箱" />
83
+        </ProForm>
84
+      </Card>
85
+    </Page>
86
+  )
87
+}

+ 121
- 4
src/pages/custom/index.jsx Bestand weergeven

@@ -1,6 +1,123 @@
1 1
 import React from 'react'
2
+import { useNavigate } from 'react-router-dom'
3
+import { Button, Popconfirm, message } from 'antd'
4
+import { ProTable } from '@ant-design/pro-components'
5
+import { queryTable } from '@/utils/request'
6
+import { getTaCustom, deleteTaCustom } from '@/services/taCustom'
7
+import Page from '@/components/Page'
8
+
9
+const customList = queryTable(getTaCustom)
10
+
2 11
 export default (props) => {
3
-return (
4
-<div></div>
5
-)
6
-}
12
+  const actionRef = React.useRef()
13
+  const navigate = useNavigate()
14
+
15
+  const handleDelete = (id) => {
16
+    if (id) {
17
+      deleteTaCustom(id).then((res) => {
18
+        actionRef.current.reload()
19
+      })
20
+    }
21
+  }
22
+
23
+  const columns = [
24
+    {
25
+      title: '公司',
26
+      dataIndex: 'customName',
27
+      ellipsis: true,
28
+    },
29
+    {
30
+      title: '税号',
31
+      dataIndex: 'dutyParagraph',
32
+      ellipsis: true,
33
+      search: false,
34
+    },
35
+    {
36
+      title: '开户行',
37
+      dataIndex: 'openingBank',
38
+      ellipsis: true,
39
+    },
40
+    {
41
+      title: '账号',
42
+      dataIndex: 'account',
43
+      ellipsis: true,
44
+    },
45
+    {
46
+      title: '联系人姓名',
47
+      dataIndex: 'contactsName',
48
+      ellipsis: true,
49
+    },
50
+    {
51
+      title: '联系人头衔',
52
+      dataIndex: 'contactsTitle',
53
+      search: false,
54
+      ellipsis: true,
55
+    },
56
+    {
57
+      title: '联系人手机',
58
+      dataIndex: 'contactsPhone',
59
+      ellipsis: true,
60
+    },
61
+    {
62
+      title: '联系人邮箱',
63
+      dataIndex: 'contactsEmail',
64
+      search: false,
65
+      ellipsis: true,
66
+    },
67
+    // {
68
+    //   title: '联系人地址',
69
+    //   dataIndex: 'address',
70
+    //   ellipsis: true,
71
+    // },
72
+    {
73
+      title: '操作',
74
+      valueType: 'option',
75
+      width: 200,
76
+      render: (_, record) => [
77
+        <Button
78
+          key={3}
79
+          style={{ padding: 0 }}
80
+          type="link"
81
+          onClick={() => {
82
+            navigate(`/custom/edit?id=${record.customId}`)
83
+          }}
84
+        >
85
+          编辑
86
+        </Button>,
87
+        <Popconfirm
88
+          key={4}
89
+          title="您是否确认删除 ?"
90
+          onConfirm={() => handleDelete(record.customId)}
91
+          okText="确定"
92
+          cancelText="取消"
93
+        >
94
+          <Button style={{ padding: 0 }} type="link">
95
+            删除
96
+          </Button>
97
+        </Popconfirm>,
98
+      ],
99
+    },
100
+  ]
101
+
102
+  return (
103
+    <Page>
104
+      <ProTable
105
+        actionRef={actionRef}
106
+        rowKey="customId"
107
+        toolBarRender={() => [
108
+          <Button
109
+            key="1"
110
+            type="primary"
111
+            onClick={() => {
112
+              navigate('/custom/edit')
113
+            }}
114
+          >
115
+            新增
116
+          </Button>,
117
+        ]}
118
+        request={customList}
119
+        columns={columns}
120
+      />
121
+    </Page>
122
+  )
123
+}

+ 46
- 44
src/pages/project/index.jsx Bestand weergeven

@@ -1,95 +1,97 @@
1
-import List from "@/components/Page/List";
2
-import React, { useRef } from "react";
3
-import { getTaProject, deleteTaProject } from "@/services/taProject";
4
-import { Button } from "antd";
5
-import { useNavigate } from "react-router-dom";
6
-import moment from "moment";
1
+import List from '@/components/Page/List'
2
+import React, { useRef } from 'react'
3
+import { getTaProject, deleteTaProject } from '@/services/taProject'
4
+import { Button } from 'antd'
5
+import { ProFormDateTimeRangePicker } from '@ant-design/pro-components'
6
+import { useNavigate } from 'react-router-dom'
7
+import moment from 'moment'
7 8
 export default (props) => {
8
-  const navigate = useNavigate();
9
+  const navigate = useNavigate()
9 10
 
10 11
   const columns = [
11 12
     {
12
-      title: "项目日期",
13
-      dataIndex: "startTime1",
13
+      title: '项目日期',
14
+      dataIndex: 'startTime1',
14 15
       search: {
15 16
         transform: (value) => {
16 17
           return {
17 18
             startTime: value[0],
18 19
             endTime: value[1],
19
-          };
20
+          }
20 21
         },
21 22
       },
22
-
23
+      valueType: 'dateRange',
24
+      // render: () => [<ProFormDateTimeRangePicker />],
23 25
       hideInTable: true,
24 26
     },
25 27
 
26 28
     {
27
-      title: "甲方",
28
-      dataIndex: "partyA",
29
+      title: '甲方',
30
+      dataIndex: 'partyA',
29 31
       search: false,
30 32
     },
31 33
     {
32
-      title: "甲方名称",
33
-      dataIndex: "partyAName",
34
+      title: '甲方名称',
35
+      dataIndex: 'partyAName',
34 36
     },
35 37
     {
36
-      title: "已方",
37
-      dataIndex: "partyB",
38
+      title: '已方',
39
+      dataIndex: 'partyB',
38 40
       search: false,
39 41
     },
40 42
     {
41
-      title: "已方名称",
42
-      dataIndex: "partyBName",
43
+      title: '已方名称',
44
+      dataIndex: 'partyBName',
43 45
     },
44 46
 
45 47
     {
46
-      title: "项目名称",
47
-      dataIndex: "projectName",
48
+      title: '项目名称',
49
+      dataIndex: 'projectName',
48 50
     },
49 51
     {
50
-      title: "项目简介",
51
-      dataIndex: "introduction",
52
+      title: '项目简介',
53
+      dataIndex: 'introduction',
52 54
       search: false,
53 55
     },
54 56
 
55 57
     {
56
-      title: "开始日期",
57
-      dataIndex: "startTime",
58
-      render: (t) => moment(t).format("YYYY-MM-DD"),
58
+      title: '开始日期',
59
+      dataIndex: 'startTime',
60
+      render: (t) => moment(t).format('YYYY-MM-DD'),
59 61
       search: false,
60 62
     },
61 63
     {
62
-      title: "结束日期",
63
-      dataIndex: "endTime",
64
-      render: (t) => moment(t).format("YYYY-MM-DD"),
64
+      title: '结束日期',
65
+      dataIndex: 'endTime',
66
+      render: (t) => moment(t).format('YYYY-MM-DD'),
65 67
       search: false,
66 68
     },
67 69
     {
68
-      title: "合同报价",
69
-      dataIndex: "quotation",
70
+      title: '合同报价',
71
+      dataIndex: 'quotation',
70 72
       search: false,
71 73
     },
72 74
     {
73
-      title: "已收款",
74
-      dataIndex: "receivedMoney",
75
+      title: '已收款',
76
+      dataIndex: 'receivedMoney',
75 77
       search: false,
76 78
     },
77 79
     {
78
-      title: "已开票额",
79
-      dataIndex: "invoicedMoney",
80
+      title: '已开票额',
81
+      dataIndex: 'invoicedMoney',
80 82
       search: false,
81 83
     },
82 84
     {
83
-      title: "阶段名称",
84
-      dataIndex: "stageName",
85
+      title: '阶段名称',
86
+      dataIndex: 'stageName',
85 87
       search: false,
86 88
     },
87 89
     {
88
-      title: "状态",
89
-      dataIndex: "status",
90
+      title: '状态',
91
+      dataIndex: 'status',
90 92
     },
91
-  ];
92
-  const actionRef = useRef();
93
+  ]
94
+  const actionRef = useRef()
93 95
   return (
94 96
     <List
95 97
       actionRef={actionRef}
@@ -103,7 +105,7 @@ export default (props) => {
103 105
           key="1"
104 106
           type="primary"
105 107
           onClick={() => {
106
-            navigate("/project/edit");
108
+            navigate('/project/edit')
107 109
           }}
108 110
         >
109 111
           新增
@@ -112,5 +114,5 @@ export default (props) => {
112 114
       request={getTaProject}
113 115
       columns={columns}
114 116
     />
115
-  );
116
-};
117
+  )
118
+}

+ 26
- 0
src/services/taCustom.js Bestand weergeven

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