张涛 1 rok temu
rodzic
commit
5ad356f030
3 zmienionych plików z 104 dodań i 90 usunięć
  1. 38
    33
      src/pages/custom/Edit.jsx
  2. 32
    57
      src/pages/custom/index.jsx
  3. 34
    0
      src/pages/member/index.jsx

+ 38
- 33
src/pages/custom/Edit.jsx Wyświetl plik

@@ -1,5 +1,5 @@
1
-import React, { useRef } from 'react'
2
-import { Button, Card, Form, Input, Select, Row, Col } from 'antd'
1
+import React, { useRef } from "react";
2
+import { Button, Card, Form, Input, Select, Row, Col } from "antd";
3 3
 import {
4 4
   ProForm,
5 5
   ProFormDateTimeRangePicker,
@@ -7,56 +7,56 @@ import {
7 7
   ProFormSelect,
8 8
   ProFormText,
9 9
   ProFormRadio,
10
-} from '@ant-design/pro-components'
11
-import useBool from '@/utils/hooks/useBool'
12
-import { useSearchParams, useNavigate } from 'react-router-dom'
13
-import Page from '@/components/Page'
14
-import { formItemLayout, tailFormItemLayout } from '@/utils/form'
15
-import { postTaCustom, putTaCustom, getTaCustomId } from '@/services/taCustom'
16
-const { Option } = Select
10
+} from "@ant-design/pro-components";
11
+import useBool from "@/utils/hooks/useBool";
12
+import { useSearchParams, useNavigate } from "react-router-dom";
13
+import Page from "@/components/Page";
14
+import { formItemLayout, tailFormItemLayout } from "@/utils/form";
15
+import { postTaCustom, putTaCustom, getTaCustomId } from "@/services/taCustom";
16
+const { Option } = Select;
17 17
 
18 18
 export default (props) => {
19
-  const formRef = useRef()
20
-  const [submiting, startSubmit, cancelSubmit] = useBool()
19
+  const formRef = useRef();
20
+  const [submiting, startSubmit, cancelSubmit] = useBool();
21 21
 
22
-  const [searchParams] = useSearchParams()
23
-  const navigate = useNavigate()
22
+  const [searchParams] = useSearchParams();
23
+  const navigate = useNavigate();
24 24
 
25
-  const id = searchParams.get('id')
25
+  const id = searchParams.get("id");
26 26
 
27 27
   React.useEffect(() => {
28 28
     if (id) {
29 29
       getTaCustomId(id).then((res) => {
30
-        formRef.current?.setFieldsValue(res)
31
-      })
30
+        formRef.current?.setFieldsValue(res);
31
+      });
32 32
     }
33
-  })
33
+  });
34 34
 
35 35
   const onFinish = (values) => {
36
-    startSubmit()
36
+    startSubmit();
37 37
     if (id) {
38 38
       //修改
39
-      const customId = id
39
+      const customId = id;
40 40
       putTaCustom(id, { customId, ...values })
41 41
         .then((res) => {
42
-          cancelSubmit()
43
-          navigate(-1)
42
+          cancelSubmit();
43
+          navigate(-1);
44 44
         })
45 45
         .catch(() => {
46
-          cancelSubmit()
47
-        })
46
+          cancelSubmit();
47
+        });
48 48
     } else {
49 49
       //新增
50 50
       postTaCustom(values)
51 51
         .then((res) => {
52
-          cancelSubmit()
53
-          navigate(-1)
52
+          cancelSubmit();
53
+          navigate(-1);
54 54
         })
55 55
         .catch(() => {
56
-          cancelSubmit()
57
-        })
56
+          cancelSubmit();
57
+        });
58 58
     }
59
-  }
59
+  };
60 60
 
61 61
   return (
62 62
     <Page>
@@ -87,18 +87,23 @@ export default (props) => {
87 87
           <ProFormText name="account" label="客户账号" />
88 88
           <ProFormText name="contactsName" label="联系人姓名" />
89 89
           <ProFormText name="contactsTitle" label="联系人头衔" />
90
-          <ProFormText name="contactsPhone" label="联系人手机" />
90
+          <ProFormText
91
+            name="contactsPhone"
92
+            label="联系人手机"
93
+            maxlength={11}
94
+            type="number"
95
+          />
91 96
           <ProFormText name="contactsEmail" label="联系人邮箱" />
92 97
           <ProFormRadio.Group
93 98
             name="isOrg"
94 99
             label="是否企业"
95 100
             options={[
96
-              { label: '否', value: 0 },
97
-              { label: '是', value: 1 },
101
+              { label: "否", value: 0 },
102
+              { label: "是", value: 1 },
98 103
             ]}
99 104
           />
100 105
         </ProForm>
101 106
       </Card>
102 107
     </Page>
103
-  )
104
-}
108
+  );
109
+};

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

@@ -5,8 +5,11 @@ import { ProTable } from "@ant-design/pro-components";
5 5
 import { queryTable } from "@/utils/request";
6 6
 import { getTaCustom, deleteTaCustom } from "@/services/taCustom";
7 7
 import Page from "@/components/Page";
8
-
9
-const customList = queryTable(getTaCustom);
8
+import List from "@/components/Page/List";
9
+import {
10
+  postTaMemberCardIdActive,
11
+  putTaMemberCardIdWrite,
12
+} from "@/services/taMemberCard";
10 13
 
11 14
 export default (props) => {
12 15
   const actionRef = React.useRef();
@@ -20,11 +23,10 @@ export default (props) => {
20 23
     }
21 24
   };
22 25
 
23
-
24 26
   const columns = [
25 27
     {
26
-      title: '客户名',
27
-      dataIndex: 'customName',
28
+      title: "客户名",
29
+      dataIndex: "customName",
28 30
       ellipsis: true,
29 31
     },
30 32
     {
@@ -49,8 +51,8 @@ export default (props) => {
49 51
       ellipsis: true,
50 52
     },
51 53
     {
52
-      title: '联系人头衔',
53
-      dataIndex: 'contactsTitle',
54
+      title: "联系人头衔",
55
+      dataIndex: "contactsTitle",
54 56
       ellipsis: true,
55 57
       search: false,
56 58
     },
@@ -71,13 +73,13 @@ export default (props) => {
71 73
       ellipsis: true,
72 74
     },
73 75
     {
74
-      title: '是否企业',
75
-      dataIndex: 'isOrg',
76
+      title: "是否企业",
77
+      dataIndex: "isOrg",
76 78
       ellipsis: true,
77
-      valueType: 'select',
79
+      valueType: "select",
78 80
       valueEnum: {
79
-        0: '否',
80
-        1: '是',
81
+        0: "否",
82
+        1: "是",
81 83
       },
82 84
     },
83 85
     // {
@@ -91,55 +93,28 @@ export default (props) => {
91 93
     //   ellipsis: true,
92 94
     //   search: false,
93 95
     // },
94
-    {
95
-      title: "操作",
96
-      valueType: "option",
97
-      width: 200,
98
-      render: (_, record) => [
96
+  ];
97
+
98
+
99
+  return (
100
+    <List
101
+      actionRef={actionRef}
102
+      rowKey="customId"
103
+      onDelete={(record) => handleDelete(record?.customId)}
104
+      onEdit={(record) => navigate(`/custom/edit?id=${record?.customId}`)}
105
+      toolBarRender={() => [
99 106
         <Button
100
-          key={3}
101
-          style={{ padding: 0 }}
102
-          type="link"
107
+          key="1"
108
+          type="primary"
103 109
           onClick={() => {
104
-            navigate(`/custom/edit?id=${record.customId}`);
110
+            navigate("/custom/edit");
105 111
           }}
106 112
         >
107
-          编辑
113
+          新增
108 114
         </Button>,
109
-        <Popconfirm
110
-          key={4}
111
-          title="您是否确认删除 ?"
112
-          onConfirm={() => handleDelete(record.customId)}
113
-          okText="确定"
114
-          cancelText="取消"
115
-        >
116
-          <Button style={{ padding: 0 }} type="link">
117
-            删除
118
-          </Button>
119
-        </Popconfirm>,
120
-      ],
121
-    },
122
-  ];
123
-
124
-  return (
125
-    <Page>
126
-      <ProTable
127
-        actionRef={actionRef}
128
-        rowKey="customId"
129
-        toolBarRender={() => [
130
-          <Button
131
-            key="1"
132
-            type="primary"
133
-            onClick={() => {
134
-              navigate("/custom/edit");
135
-            }}
136
-          >
137
-            新增
138
-          </Button>,
139
-        ]}
140
-        request={customList}
141
-        columns={columns}
142
-      />
143
-    </Page>
115
+      ]}
116
+      request={getTaCustom}
117
+      columns={columns}
118
+    />
144 119
   );
145 120
 };

+ 34
- 0
src/pages/member/index.jsx Wyświetl plik

@@ -3,6 +3,7 @@ import { getTaMember } from "@/services/taMember";
3 3
 import List from "@/components/Page/List";
4 4
 import moment from "moment";
5 5
 import { useNavigate } from "react-router-dom";
6
+import { Button, Popconfirm } from "antd";
6 7
 export default (props) => {
7 8
   const navigate = useNavigate();
8 9
 
@@ -58,11 +59,44 @@ export default (props) => {
58 59
 
59 60
     },
60 61
   ];
62
+  const onActive = (record) => {
63
+    // postTaMemberCardIdActive().then((res) => {});
64
+  };
65
+  const onWrite = (record) => {
66
+    // putTaMemberCardIdWrite().then((res) => {});
67
+  };
68
+
69
+  const ColumnOptionRender = (_, record) => [
70
+    <Popconfirm
71
+      key="A3"
72
+      title="您是否确认发卡?"
73
+      onConfirm={() => onActive(record.customId)}
74
+      okText="确定" 
75
+      cancelText="取消"
76
+    >
77
+      <Button style={{ padding: 0 }} type="link">
78
+        发卡
79
+      </Button>
80
+    </Popconfirm>,
81
+    <Popconfirm
82
+      key="A2"
83
+      title="您是否确认核销卡?"
84
+      onConfirm={() => onWrite(record.customId)}
85
+      okText="确定"
86
+      cancelText="取消"
87
+    >
88
+      <Button style={{ padding: 0 }} type="link">
89
+        核销卡
90
+      </Button>
91
+    </Popconfirm>,
92
+  ];
61 93
   return (
62 94
     <List
63 95
       // actionRef={actionRef}
64 96
       rowKey="memberId"
65 97
       onEdit={(record) => navigate(`/member/edit?id=${record.memberId}`)}
98
+      columnOptionRender={ColumnOptionRender}
99
+
66 100
       // onDelete={(record) => handleDelete(record.memberId)}
67 101
       // toolBarRender={() => [
68 102
       //   <Button