张涛 1 年之前
父節點
當前提交
8e62ec850b
共有 6 個檔案被更改,包括 329 行新增76 行删除
  1. 24
    6
      src/pages/custom/Edit.jsx
  2. 28
    7
      src/pages/custom/index.jsx
  3. 78
    31
      src/pages/project/Edit.jsx
  4. 84
    30
      src/pages/project/index.jsx
  5. 113
    0
      src/pages/project/zh-cn.js
  6. 2
    2
      src/utils/form.js

+ 24
- 6
src/pages/custom/Edit.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import React, { useRef } from 'react'
2
-import { Button, Card, Form, Input, Select } from 'antd'
2
+import { Button, Card, Form, Input, Select, Row, Col } from 'antd'
3 3
 import {
4 4
   ProForm,
5 5
   ProFormDateTimeRangePicker,
@@ -28,7 +28,7 @@ export default (props) => {
28 28
   React.useEffect(() => {
29 29
     if (id) {
30 30
       getTaCustomId(id).then((res) => {
31
-        formRef.current.setFieldsValue(res)
31
+        formRef.current?.setFieldsValue(res)
32 32
       })
33 33
     }
34 34
   })
@@ -37,7 +37,8 @@ export default (props) => {
37 37
     startSubmit()
38 38
     if (id) {
39 39
       //修改
40
-      putTaCustom(id, values)
40
+      const customId = id
41
+      putTaCustom(id, { customId, ...values })
41 42
         .then((res) => {
42 43
           cancelSubmit()
43 44
           navigate(-1)
@@ -65,14 +66,23 @@ export default (props) => {
65 66
           formRef={formRef}
66 67
           onFinish={onFinish}
67 68
           layout="horizontal"
69
+          {...formItemLayout}
68 70
           submitter={{
69 71
             render: (_, doms) => [
70
-              doms.find((dom) => dom.props?.children === '提交'),
71
-              <Button onClick={() => navigate(-1)}>返回</Button>,
72
+              <Row>
73
+                <Col offset={6}>
74
+                  <Button type="primary" htmlType="submit">
75
+                    提交
76
+                  </Button>
77
+                </Col>
78
+                <Col offset={1}>
79
+                  <Button onClick={() => navigate(-1)}>返回</Button>
80
+                </Col>
81
+              </Row>,
72 82
             ],
73 83
           }}
74 84
         >
75
-          <ProFormText name="customName" label="客户公司" />
85
+          <ProFormText name="customName" label="客户" />
76 86
           <ProFormText name="dutyParagraph" label="客户税号" />
77 87
           <ProFormText name="openingBank" label="开户行" />
78 88
           <ProFormText name="account" label="客户账号" />
@@ -80,6 +90,14 @@ export default (props) => {
80 90
           <ProFormText name="contactsTitle" label="联系人头衔" />
81 91
           <ProFormText name="contactsPhone" label="联系人手机" />
82 92
           <ProFormText name="contactsEmail" label="联系人邮箱" />
93
+          <ProFormSelect
94
+            name="isOrg"
95
+            label="是否企业"
96
+            options={[
97
+              { label: '否', value: 0 },
98
+              { label: '是', value: 1 },
99
+            ]}
100
+          />
83 101
         </ProForm>
84 102
       </Card>
85 103
     </Page>

+ 28
- 7
src/pages/custom/index.jsx 查看文件

@@ -23,8 +23,8 @@ export default (props) => {
23 23
 
24 24
   const columns = [
25 25
     {
26
-      title: "公司",
27
-      dataIndex: "customName",
26
+      title: '客户名',
27
+      dataIndex: 'customName',
28 28
       ellipsis: true,
29 29
     },
30 30
     {
@@ -49,11 +49,16 @@ export default (props) => {
49 49
       ellipsis: true,
50 50
     },
51 51
     {
52
-      title: "联系人头衔",
53
-      dataIndex: "contactsTitle",
54
-      search: false,
52
+      title: '联系人头衔',
53
+      dataIndex: 'contactsTitle',
55 54
       ellipsis: true,
55
+      search: false,
56 56
     },
57
+    // {
58
+    //   title: '状态',
59
+    //   dataIndex: 'status',
60
+    //   ellipsis: true,
61
+    // },
57 62
     {
58 63
       title: "联系人手机",
59 64
       dataIndex: "contactsPhone",
@@ -65,10 +70,26 @@ export default (props) => {
65 70
       search: false,
66 71
       ellipsis: true,
67 72
     },
73
+    {
74
+      title: '是否企业',
75
+      dataIndex: 'isOrg',
76
+      ellipsis: true,
77
+      valueType: 'select',
78
+      valueEnum: {
79
+        0: '否',
80
+        1: '是',
81
+      },
82
+    },
83
+    // {
84
+    //   title: '租户号',
85
+    //   dataIndex: 'tenantId',
86
+    //   ellipsis: true,
87
+    // },
68 88
     // {
69
-    //   title: '联系人地址',
70
-    //   dataIndex: 'address',
89
+    //   title: '创建人',
90
+    //   dataIndex: 'createdBy',
71 91
     //   ellipsis: true,
92
+    //   search: false,
72 93
     // },
73 94
     {
74 95
       title: "操作",

+ 78
- 31
src/pages/project/Edit.jsx 查看文件

@@ -1,55 +1,72 @@
1
-import React, { useEffect, useRef } from "react";
1
+import React, { useEffect, useRef, useState } from 'react'
2 2
 import {
3 3
   postTaProject,
4 4
   putTaProject,
5 5
   getTaProjectId,
6
-} from "@/services/taProject";
7
-import Page from "@/components/Page";
8
-import { Button, Card } from "antd";
6
+} from '@/services/taProject'
7
+import { getTaCustom } from '@/services/taCustom'
8
+import Page from '@/components/Page'
9
+import { Button, Card, Row, Col } from 'antd'
9 10
 import {
10 11
   ProForm,
11 12
   ProFormDateTimeRangePicker,
12 13
   ProFormMoney,
13 14
   ProFormSelect,
14 15
   ProFormText,
15
-} from "@ant-design/pro-components";
16
-import { useNavigate, useSearchParams } from "react-router-dom";
17
-import moment from "moment";
16
+  ProFormTextArea,
17
+} from '@ant-design/pro-components'
18
+import { formItemLayout, tailFormItemLayout } from '@/utils/form'
19
+import { useNavigate, useSearchParams } from 'react-router-dom'
20
+import moment from 'moment'
21
+
18 22
 export default (props) => {
19
-  const formRef = useRef();
20
-  const navigate = useNavigate();
23
+  const formRef = useRef()
24
+  const navigate = useNavigate()
21 25
 
22
-  const [params] = useSearchParams();
23
-  const id = params.get("id");
26
+  const [params] = useSearchParams()
27
+  const id = params.get('id')
28
+  const [customSelect, setCustomSelect] = useState()
24 29
 
25 30
   useEffect(() => {
26 31
     if (id) {
27 32
       getTaProjectId(id).then((res) => {
28
-
29 33
         formRef.current?.setFieldsValue({
30
-            ...res,
31
-            time:[moment(res.startTime),moment(res.endTime)] 
32
-        });
33
-      });
34
+          ...res,
35
+          time: [moment(res.startTime), moment(res.endTime)],
36
+        })
37
+      })
34 38
     }
35
-  }, []);
39
+
40
+    //所属客户下拉
41
+    getTaCustom().then((res) => {
42
+      setCustomSelect(
43
+        res.records?.map(
44
+          (x) =>
45
+            ({
46
+              label: x.customName,
47
+              value: x.customId,
48
+            } || [])
49
+        )
50
+      )
51
+    })
52
+  }, [])
36 53
   const onFinish = (values) => {
37 54
     const data = {
38 55
       ...values,
39 56
       startTime: values.time[0],
40 57
       endTime: values.time[1],
41
-    };
42
-    console.log(data);
58
+    }
59
+    console.log(data)
43 60
     if (!id) {
44 61
       postTaProject(data).then((res) => {
45
-        navigate(-1);
46
-      });
62
+        navigate(-1)
63
+      })
47 64
     } else if (id) {
48 65
       putTaProject(id, data).then((res) => {
49
-        navigate(-1);
50
-      });
66
+        navigate(-1)
67
+      })
51 68
     }
52
-  };
69
+  }
53 70
   return (
54 71
     <Page>
55 72
       <Card>
@@ -57,10 +74,20 @@ export default (props) => {
57 74
           formRef={formRef}
58 75
           onFinish={onFinish}
59 76
           layout="horizontal"
77
+          {...formItemLayout}
60 78
           submitter={{
61 79
             render: (_, doms) => [
62
-              doms.find((dom) => dom.props?.children === "提交"),
63
-              <Button onClick={() => navigate(-1)}>返回</Button>,
80
+              // doms.find((dom) => dom.props?.children === '提交'),
81
+              <Row>
82
+                <Col offset={6}>
83
+                  <Button type="primary" htmlType="submit">
84
+                    提交
85
+                  </Button>
86
+                </Col>
87
+                <Col offset={1}>
88
+                  <Button onClick={() => navigate(-1)}>返回</Button>
89
+                </Col>
90
+              </Row>,
64 91
             ],
65 92
           }}
66 93
         >
@@ -69,15 +96,35 @@ export default (props) => {
69 96
           <ProFormText name="partyB" label="乙方联系人" />
70 97
           <ProFormText name="partyBName" label="乙方名称" />
71 98
           <ProFormText name="projectName" label="项目名称" />
72
-          <ProFormText name="introduction" label="项目简介" />
99
+          <ProFormTextArea name="introduction" label="项目简介" />
73 100
           <ProFormDateTimeRangePicker name="time" label="工作周期" />
74 101
           <ProFormMoney name="quotation" label="合同报价" />
75 102
           <ProFormMoney name="receivedMoney" label="已收款" />
76 103
           <ProFormMoney name="invoicedMoney" label="已开票额" />
77
-          <ProFormText name="stageName" label="阶段名称" />
78
-          <ProFormSelect name="status" label="状态" />
104
+          <ProFormSelect
105
+            name="stageName"
106
+            label="阶段名称"
107
+            options={[
108
+              { label: '未开始', value: '0' },
109
+              { label: '处理中', value: '1' },
110
+              { label: '已完成', value: '2' },
111
+            ]}
112
+          />
113
+          <ProFormSelect
114
+            name="status"
115
+            label="项目状态"
116
+            options={[
117
+              { label: '禁用', value: 0 },
118
+              { label: '正常', value: 1 },
119
+            ]}
120
+          />
121
+          <ProFormSelect
122
+            options={customSelect}
123
+            name="customId"
124
+            label="所属客户"
125
+          />
79 126
         </ProForm>
80 127
       </Card>
81 128
     </Page>
82
-  );
83
-};
129
+  )
130
+}

+ 84
- 30
src/pages/project/index.jsx 查看文件

@@ -1,12 +1,21 @@
1 1
 import List from '@/components/Page/List'
2 2
 import React, { useRef } from 'react'
3 3
 import { getTaProject, deleteTaProject } from '@/services/taProject'
4
-import { Button } from 'antd'
4
+import { getTaCustom } from '@/services/taCustom'
5
+import { queryDict } from '@/utils/request'
6
+import { Button, ConfigProvider } from 'antd'
7
+import zhCN from 'antd/es/locale/zh_CN'
5 8
 import { ProFormDateTimeRangePicker } from '@ant-design/pro-components'
6 9
 import { useNavigate } from 'react-router-dom'
7 10
 import moment from 'moment'
11
+import './zh-cn.js'
12
+
8 13
 export default (props) => {
9 14
   const navigate = useNavigate()
15
+  const queryCustom = queryDict(getTaCustom, {
16
+    labelKey: 'customName',
17
+    valueKey: 'customId',
18
+  })
10 19
 
11 20
   const columns = [
12 21
     {
@@ -21,10 +30,8 @@ export default (props) => {
21 30
         },
22 31
       },
23 32
       valueType: 'dateRange',
24
-      // render: () => [<ProFormDateTimeRangePicker />],
25 33
       hideInTable: true,
26 34
     },
27
-
28 35
     {
29 36
       title: '甲方',
30 37
       dataIndex: 'partyA',
@@ -35,15 +42,14 @@ export default (props) => {
35 42
       dataIndex: 'partyAName',
36 43
     },
37 44
     {
38
-      title: '方',
45
+      title: '方',
39 46
       dataIndex: 'partyB',
40 47
       search: false,
41 48
     },
42 49
     {
43
-      title: '方名称',
50
+      title: '方名称',
44 51
       dataIndex: 'partyBName',
45 52
     },
46
-
47 53
     {
48 54
       title: '项目名称',
49 55
       dataIndex: 'projectName',
@@ -53,15 +59,14 @@ export default (props) => {
53 59
       dataIndex: 'introduction',
54 60
       search: false,
55 61
     },
56
-
57 62
     {
58
-      title: '开始日期',
63
+      title: '项目开始日期',
59 64
       dataIndex: 'startTime',
60 65
       render: (t) => moment(t).format('YYYY-MM-DD'),
61 66
       search: false,
62 67
     },
63 68
     {
64
-      title: '结束日期',
69
+      title: '项目结束日期',
65 70
       dataIndex: 'endTime',
66 71
       render: (t) => moment(t).format('YYYY-MM-DD'),
67 72
       search: false,
@@ -85,34 +90,83 @@ export default (props) => {
85 90
       title: '阶段名称',
86 91
       dataIndex: 'stageName',
87 92
       search: false,
93
+      valueEnum: {
94
+        0: '未开始',
95
+        1: '处理中',
96
+        2: '已完成',
97
+      },
88 98
     },
89 99
     {
90 100
       title: '状态',
91 101
       dataIndex: 'status',
102
+      valueEnum: {
103
+        0: '禁用',
104
+        1: '正常',
105
+      },
106
+      search: false,
107
+    },
108
+
109
+    // {
110
+    //   title: '创建时间',
111
+    //   dataIndex: 'createdAt',
112
+    // },
113
+    // {
114
+    //   title: '创建人',
115
+    //   dataIndex: 'createdBy',
116
+    //   search: false,
117
+    // },
118
+    {
119
+      title: '所属客户',
120
+      dataIndex: 'customId',
121
+      valueType: 'select',
122
+      request: queryCustom,
123
+      search: false,
92 124
     },
125
+    // {
126
+    //   title: '删除标志',
127
+    //   dataIndex: 'deleted',
128
+    // },
129
+    // {
130
+    //   title: '阶段ID',
131
+    //   dataIndex: 'stageId',
132
+    // },
133
+    // {
134
+    //   title: '租户号',
135
+    //   dataIndex: 'tenantId',
136
+    // },
137
+    // {
138
+    //   title: '更新时间',
139
+    //   dataIndex: 'updatedAt',
140
+    // }
93 141
   ]
142
+
94 143
   const actionRef = useRef()
95 144
   return (
96
-    <List
97
-      actionRef={actionRef}
98
-      rowKey="projectId"
99
-      onEdit={(record) => navigate(`/project/edit?id=${record.projectId}`)}
100
-      onDelete={(record) =>
101
-        deleteTaProject(record.projectId).then(() => actionRef.current.reload())
102
-      }
103
-      toolBarRender={() => [
104
-        <Button
105
-          key="1"
106
-          type="primary"
107
-          onClick={() => {
108
-            navigate('/project/edit')
109
-          }}
110
-        >
111
-          新增
112
-        </Button>,
113
-      ]}
114
-      request={getTaProject}
115
-      columns={columns}
116
-    />
145
+    <ConfigProvider locale={zhCN}>
146
+      <List
147
+        scroll={{ x: 1800 }}
148
+        actionRef={actionRef}
149
+        rowKey="projectId"
150
+        onEdit={(record) => navigate(`/project/edit?id=${record.projectId}`)}
151
+        onDelete={(record) =>
152
+          deleteTaProject(record.projectId).then(() =>
153
+            actionRef.current.reload()
154
+          )
155
+        }
156
+        toolBarRender={() => [
157
+          <Button
158
+            key="1"
159
+            type="primary"
160
+            onClick={() => {
161
+              navigate('/project/edit')
162
+            }}
163
+          >
164
+            新增
165
+          </Button>,
166
+        ]}
167
+        request={getTaProject}
168
+        columns={columns}
169
+      />
170
+    </ConfigProvider>
117 171
   )
118 172
 }

+ 113
- 0
src/pages/project/zh-cn.js 查看文件

@@ -0,0 +1,113 @@
1
+import moment from 'moment'
2
+moment.defineLocale('zh-cn', {
3
+  months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
4
+  monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
5
+  weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
6
+  weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
7
+  weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
8
+  longDateFormat: {
9
+    LT: 'Ah点mm分',
10
+    LTS: 'Ah点m分s秒',
11
+    L: 'YYYY-MM-DD',
12
+    LL: 'YYYY年MMMD日',
13
+    LLL: 'YYYY年MMMD日Ah点mm分',
14
+    LLLL: 'YYYY年MMMD日ddddAh点mm分',
15
+    l: 'YYYY-MM-DD',
16
+    ll: 'YYYY年MMMD日',
17
+    lll: 'YYYY年MMMD日Ah点mm分',
18
+    llll: 'YYYY年MMMD日ddddAh点mm分'
19
+  },
20
+  meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
21
+  meridiemHour: function (hour, meridiem) {
22
+    if (hour === 12) {
23
+      hour = 0;
24
+    }
25
+    if (meridiem === '凌晨' || meridiem === '早上' ||
26
+      meridiem === '上午') {
27
+      return hour;
28
+    } else if (meridiem === '下午' || meridiem === '晚上') {
29
+      return hour + 12;
30
+    } else {
31
+      // '中午'
32
+      return hour >= 11 ? hour : hour + 12;
33
+    }
34
+  },
35
+  meridiem: function (hour, minute, isLower) {
36
+    var hm = hour * 100 + minute;
37
+    if (hm < 600) {
38
+      return '凌晨';
39
+    } else if (hm < 900) {
40
+      return '早上';
41
+    } else if (hm < 1130) {
42
+      return '上午';
43
+    } else if (hm < 1230) {
44
+      return '中午';
45
+    } else if (hm < 1800) {
46
+      return '下午';
47
+    } else {
48
+      return '晚上';
49
+    }
50
+  },
51
+  calendar: {
52
+    sameDay: function () {
53
+      return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
54
+    },
55
+    nextDay: function () {
56
+      return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
57
+    },
58
+    lastDay: function () {
59
+      return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
60
+    },
61
+    nextWeek: function () {
62
+      var startOfWeek, prefix;
63
+      startOfWeek = moment().startOf('week');
64
+      prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
65
+      return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
66
+    },
67
+    lastWeek: function () {
68
+      var startOfWeek, prefix;
69
+      startOfWeek = moment().startOf('week');
70
+      prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
71
+      return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
72
+    },
73
+    sameElse: 'LL'
74
+  },
75
+  ordinalParse: /\d{1,2}(日|月|周)/,
76
+  ordinal: function (number, period) {
77
+    switch (period) {
78
+      case 'd':
79
+      case 'D':
80
+      case 'DDD':
81
+        return number + '日';
82
+      case 'M':
83
+        return number + '月';
84
+      case 'w':
85
+      case 'W':
86
+        return number + '周';
87
+      default:
88
+        return number;
89
+    }
90
+  },
91
+  relativeTime: {
92
+    future: '%s内',
93
+    past: '%s前',
94
+    s: '几秒',
95
+    m: '1 分钟',
96
+    mm: '%d 分钟',
97
+    h: '1 小时',
98
+    hh: '%d 小时',
99
+    d: '1 天',
100
+    dd: '%d 天',
101
+    M: '1 个月',
102
+    MM: '%d 个月',
103
+    y: '1 年',
104
+    yy: '%d 年'
105
+  },
106
+  week: {
107
+    // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
108
+    dow: 1, // Monday is the first day of the week.
109
+    doy: 4  // The week that contains Jan 4th is the first week of the year.
110
+  }
111
+
112
+}
113
+);

+ 2
- 2
src/utils/form.js 查看文件

@@ -2,11 +2,11 @@
2 2
 export const formItemLayout = {
3 3
   labelCol: {
4 4
     xs: { span: 24 },
5
-    sm: { span: 8 },
5
+    sm: { span: 4 },
6 6
   },
7 7
   wrapperCol: {
8 8
     xs: { span: 24 },
9
-    sm: { span: 16 },
9
+    sm: { span: 12 },
10 10
   },
11 11
 };
12 12
 export const tailFormItemLayout = {