fangmingyue 1 ano atrás
pai
commit
0bd6f2affe

+ 100
- 0
src/pages/finance/Edit.jsx Ver arquivo

@@ -0,0 +1,100 @@
1
+import React, { useEffect, useRef, useState, forwardRef } from 'react'
2
+import {
3
+  postTfFinance,
4
+  putTfFinance,
5
+  getTfFinanceId,
6
+} from '@/services/tfFinance'
7
+import { Button, Card, Row, Col, Form, Input } from 'antd'
8
+import {
9
+  ProForm,
10
+  ProFormDateTimeRangePicker,
11
+  ProFormMoney,
12
+  ProFormSelect,
13
+  ProFormText,
14
+  ProFormTextArea,
15
+  ProFormRadio,
16
+} from '@ant-design/pro-components'
17
+import Page from '@/components/Page'
18
+import { formItemLayout, tailFormItemLayout } from '@/utils/form'
19
+import { useNavigate, useSearchParams } from 'react-router-dom'
20
+import moment from 'moment'
21
+
22
+export default (props) => {
23
+  const formRef = useRef()
24
+  const navigate = useNavigate()
25
+
26
+  const [params] = useSearchParams()
27
+  const id = params.get('id')
28
+
29
+  useEffect(() => {
30
+    if (id) {
31
+      getTfFinanceId(id).then((res) => {
32
+        formRef.current?.setFieldsValue(res)
33
+      })
34
+    }
35
+  }, [])
36
+
37
+  const onFinish = (values) => {
38
+    if (!id) {
39
+      postTfFinance(values).then((res) => {
40
+        navigate(-1)
41
+      })
42
+    } else if (id) {
43
+      let financeId = id
44
+      putTfFinance(id, { financeId, ...values }).then((res) => {
45
+        navigate(-1)
46
+      })
47
+    }
48
+  }
49
+
50
+  let formatter = new Intl.NumberFormat('zh-CN', {
51
+    minimumFractionDigits: 4,
52
+    maximumFractionDigits: 4,
53
+  })
54
+
55
+  return (
56
+    <Page>
57
+      <Card>
58
+        <ProForm
59
+          formRef={formRef}
60
+          onFinish={onFinish}
61
+          layout="horizontal"
62
+          initialValues={{ bizStatus: '1' }}
63
+          {...formItemLayout}
64
+          // grid={true}
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="financeName" label="记录名称" />
81
+          <ProFormMoney name="totalCharges" label="总费用" />
82
+          <ProFormMoney name="grossProfits" label="毛利润" />
83
+          <ProFormMoney name="totalCost" label="总成本" />
84
+          <ProFormMoney name="expense" label="已支出" />
85
+          <ProFormMoney name="received" label="已收款" />
86
+          <ProFormMoney name="balancePayment" label="尾款" />
87
+          <ProFormMoney name="invoice" label="发票" />
88
+          <ProFormRadio.Group
89
+            name="bizStatus"
90
+            label="项目状态"
91
+            options={[
92
+              { label: '正常', value: '1' },
93
+              { label: '禁用', value: '0' },
94
+            ]}
95
+          />
96
+        </ProForm>
97
+      </Card>
98
+    </Page>
99
+  )
100
+}

+ 94
- 5
src/pages/finance/index.jsx Ver arquivo

@@ -1,6 +1,95 @@
1
-import React from 'react'
1
+import List from '@/components/Page/List'
2
+import React, { useRef } from 'react'
3
+import { getTfFinance, deleteTfFinance } from '@/services/tfFinance'
4
+import { queryDict } from '@/utils/request'
5
+import { Button, ConfigProvider } from 'antd'
6
+import { ProFormDateTimeRangePicker } from '@ant-design/pro-components'
7
+import { useNavigate } from 'react-router-dom'
8
+
2 9
 export default (props) => {
3
-return (
4
-<div></div>
5
-)
6
-}
10
+  const navigate = useNavigate()
11
+
12
+  const columns = [
13
+    {
14
+      title: '记录名称',
15
+      dataIndex: 'financeName',
16
+      ellipsis: true,
17
+    },
18
+    {
19
+      title: '项目状态',
20
+      dataIndex: 'bizStatus',
21
+      valueEnum: {
22
+        1: '正常',
23
+        0: '禁用',
24
+      },
25
+      search: false,
26
+      ellipsis: true,
27
+    },
28
+    {
29
+      title: '总费用',
30
+      dataIndex: 'totalCharges',
31
+      search: false,
32
+      ellipsis: true,
33
+    },
34
+    {
35
+      title: '毛利润',
36
+      dataIndex: 'grossProfits',
37
+      search: false,
38
+      ellipsis: true,
39
+    },
40
+    {
41
+      title: '总成本',
42
+      dataIndex: 'totalCost',
43
+      search: false,
44
+      ellipsis: true,
45
+    },
46
+    {
47
+      title: '已支出',
48
+      dataIndex: 'expense',
49
+      search: false,
50
+      ellipsis: true,
51
+    },
52
+    {
53
+      title: '已收款',
54
+      dataIndex: 'received',
55
+      search: false,
56
+      ellipsis: true,
57
+    },
58
+    {
59
+      title: '尾款',
60
+      dataIndex: 'balancePayment',
61
+      search: false,
62
+      ellipsis: true,
63
+    },
64
+    {
65
+      title: '发票',
66
+      dataIndex: 'invoice',
67
+      search: false,
68
+      ellipsis: true,
69
+    },
70
+  ]
71
+
72
+  const actionRef = useRef()
73
+  const onAdd = () => {
74
+    navigate('/finance/edit')
75
+  }
76
+  return (
77
+    <List
78
+      actionRef={actionRef}
79
+      rowKey="financeId"
80
+      onEdit={(record) => navigate(`/finance/edit?id=${record?.financeId}`)}
81
+      onDelete={(record) =>
82
+        deleteTfFinance(record?.financeId).then(() =>
83
+          actionRef.current.reload()
84
+        )
85
+      }
86
+      toolBarRender={() => [
87
+        <Button key="1" type="primary" onClick={onAdd}>
88
+          新增
89
+        </Button>,
90
+      ]}
91
+      request={getTfFinance}
92
+      columns={columns}
93
+    />
94
+  )
95
+}

+ 34
- 4
src/pages/project/components/ProjectEdit.jsx Ver arquivo

@@ -1,11 +1,11 @@
1
-import React, { useEffect, useRef, useState } from 'react'
1
+import React, { useEffect, useRef, useState, forwardRef } from 'react'
2 2
 import {
3 3
   postTaProject,
4 4
   putTaProject,
5 5
   getTaProjectId,
6 6
 } from '@/services/taProject'
7 7
 import { getTaCustom } from '@/services/taCustom'
8
-import { Button, Card, Row, Col } from 'antd'
8
+import { Button, Card, Row, Col, Form, Input } from 'antd'
9 9
 import {
10 10
   ProForm,
11 11
   ProFormDateTimeRangePicker,
@@ -21,6 +21,7 @@ import moment from 'moment'
21 21
 export default (props) => {
22 22
   const { setCustomId } = props
23 23
   const formRef = useRef()
24
+  const inputRef = useRef()
24 25
   const navigate = useNavigate()
25 26
 
26 27
   const [params] = useSearchParams()
@@ -28,7 +29,6 @@ export default (props) => {
28 29
   const [customSelect, setCustomSelect] = useState()
29 30
 
30 31
   useEffect(() => {
31
-    window.scrollTo(0, 0) // 将滚动位置设置为页面顶部
32 32
     if (id) {
33 33
       getTaProjectId(id).then((res) => {
34 34
         formRef.current?.setFieldsValue({
@@ -52,6 +52,7 @@ export default (props) => {
52 52
       )
53 53
     })
54 54
   }, [])
55
+
55 56
   const onFinish = (values) => {
56 57
     const data = {
57 58
       ...values,
@@ -65,10 +66,29 @@ export default (props) => {
65 66
       putTaProject(id, data).then((res) => {})
66 67
     }
67 68
   }
69
+
68 70
   let formatter = new Intl.NumberFormat('zh-CN', {
69 71
     minimumFractionDigits: 4,
70 72
     maximumFractionDigits: 4,
71 73
   })
74
+
75
+  const MyInput = forwardRef((props, ref) => {
76
+    return (
77
+      console.log('ref', ref),
78
+      (
79
+        // console.log('ref?.current', ref?.current),
80
+        <ProFormText
81
+          {...props}
82
+          fieldRef={ref?.current?.focus({ cursor: 'start' })}
83
+        />
84
+      )
85
+    )
86
+  })
87
+
88
+  // useEffect(() => {
89
+  //   inputRef?.current?.focus({ cursor: 'start' })
90
+  // }, [inputRef])
91
+
72 92
   return (
73 93
     <Card
74 94
       title={<div style={{ fontWeight: 'bold' }}>项目维护</div>}
@@ -99,12 +119,22 @@ export default (props) => {
99 119
           ],
100 120
         }}
101 121
       >
102
-        <ProFormText
122
+        <MyInput
103 123
           colProps={{ xl: 12 }}
104 124
           labelCol={{ sm: 4 }}
105 125
           name="partyA"
106 126
           label="甲方"
127
+          fieldProps={{ ref: inputRef }}
128
+          ref={inputRef}
107 129
         />
130
+        {/* <Form.Item
131
+          wrapperCol={{ xs: 16 }}
132
+          labelCol={{ span: 8 }}
133
+          name="partyA"
134
+          label="甲方"
135
+        >
136
+          <Input ref={inputRef?.current?.focus({ cursor: 'start' })} />
137
+        </Form.Item> */}
108 138
         <ProFormText colProps={{ xl: 12 }} name="partyAName" label="甲方名称" />
109 139
         <ProFormText
110 140
           colProps={{ xl: 12 }}

+ 0
- 1
src/pages/project/index.jsx Ver arquivo

@@ -143,7 +143,6 @@ export default (props) => {
143 143
   const actionRef = useRef()
144 144
   const onAdd = () => {
145 145
     navigate('/project/edit')
146
-    window.scrollTo(0, 0) // 在路由导航时滚动到页面顶部
147 146
   }
148 147
   return (
149 148
     <ConfigProvider locale={zhCN}>

+ 33
- 16
src/routes/routes.jsx Ver arquivo

@@ -16,6 +16,7 @@ import Project from '@/pages/project'
16 16
 import ProjectEdit from '@/pages/project/Edit'
17 17
 import ProjectContact from '@/pages/projectContact'
18 18
 import ProjectDeploy from '@/pages/projectDeploy'
19
+import ProjectDeployEdit from '@/pages/project/components/ProjectDeployEdit'
19 20
 import ProjectNode from '@/pages/projectNode'
20 21
 
21 22
 import Role from '@/pages/role'
@@ -27,6 +28,7 @@ import MemberEdit from '@/pages/member/Edit'
27 28
 import Custom from '@/pages/custom'
28 29
 import CustomEdit from '@/pages/custom/Edit'
29 30
 import Finance from '@/pages/finance'
31
+import FinanceEdit from '@/pages/finance/Edit'
30 32
 import Tenant from '@/pages/tenant'
31 33
 import TenantEdit from '@/pages/tenant/Edit'
32 34
 
@@ -82,29 +84,37 @@ export const authRoutes = [
82 84
     },
83 85
   },
84 86
   {
85
-    path: 'projectContact',
86
-    element: <ProjectContact />,
87
-    meta: {
88
-      title: '项目联系人管理',
89
-      icon: <FileTextOutlined />,
90
-    },
91
-  },
92
-  {
93
-    path: 'projectDeploy',
94
-    element: <ProjectDeploy />,
87
+    path: 'projectDeploy/edit',
88
+    element: <ProjectDeployEdit />,
95 89
     meta: {
96
-      title: '服务器管理',
97
-      icon: <FileTextOutlined />,
90
+      title: '部署维护',
91
+      hideInMenu: true,
98 92
     },
99 93
   },
100 94
   {
101
-    path: 'projectNode',
102
-    element: <ProjectNode />,
95
+    path: 'projectContact',
96
+    element: <ProjectContact />,
103 97
     meta: {
104
-      title: '流程节点管理',
98
+      title: '项目联系人管理',
105 99
       icon: <FileTextOutlined />,
106 100
     },
107 101
   },
102
+  // {
103
+  //   path: 'projectDeploy',
104
+  //   element: <ProjectDeploy />,
105
+  //   meta: {
106
+  //     title: '服务器管理',
107
+  //     icon: <FileTextOutlined />,
108
+  //   },
109
+  // },
110
+  // {
111
+  //   path: 'projectNode',
112
+  //   element: <ProjectNode />,
113
+  //   meta: {
114
+  //     title: '流程节点管理',
115
+  //     icon: <FileTextOutlined />,
116
+  //   },
117
+  // },
108 118
   {
109 119
     path: 'dept',
110 120
     element: <Dept />,
@@ -186,7 +196,6 @@ export const authRoutes = [
186 196
       hideInMenu: true,
187 197
     },
188 198
   },
189
-
190 199
   {
191 200
     path: 'finance',
192 201
     element: <Finance />,
@@ -195,6 +204,14 @@ export const authRoutes = [
195 204
       icon: <HourglassTwoTone />,
196 205
     },
197 206
   },
207
+  {
208
+    path: 'finance/edit',
209
+    element: <FinanceEdit />,
210
+    meta: {
211
+      title: '财务维护',
212
+      hideInMenu: true,
213
+    },
214
+  },
198 215
 ]
199 216
 
200 217
 export const defaultRoutes = [

+ 16
- 1
src/services/tfFinance.js Ver arquivo

@@ -9,4 +9,19 @@ export const getTfFinance = (params) => request(`/tfFinance`, { params });
9 9
 /*
10 10
  * 新增数据
11 11
  */
12
-export const postTfFinance = (data) => request('/tfFinance', { data, method: 'post' });
12
+export const postTfFinance = (data) => request('/tfFinance', { data, method: 'post' });
13
+
14
+/*
15
+ * 更新数据
16
+ */
17
+export const putTfFinance = (id, data) => request(`/tfFinance/${id}`, { data, method: 'put' });
18
+
19
+/*
20
+ * 通过主键删除数据
21
+ */
22
+export const deleteTfFinance = (id) => request(`/tfFinance/${id}`, { method: 'delete' });
23
+
24
+/*
25
+ * 通过ID查询单条数据
26
+ */
27
+export const getTfFinanceId = (id) => request(`/tfFinance/${id}`);

+ 1
- 1
vite.config.js Ver arquivo

@@ -11,7 +11,7 @@ export default defineConfig({
11 11
     host: "0.0.0.0",
12 12
     proxy: {
13 13
       '/api/admin': {
14
-        target: 'http://localhost:9101',
14
+        target: 'http://192.168.89.25:9101',
15 15
         changeOrigin: true,
16 16
       },
17 17
     },