张涛 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
-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
 import {
3
 import {
4
   ProForm,
4
   ProForm,
5
   ProFormDateTimeRangePicker,
5
   ProFormDateTimeRangePicker,
7
   ProFormSelect,
7
   ProFormSelect,
8
   ProFormText,
8
   ProFormText,
9
   ProFormRadio,
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
 export default (props) => {
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
   React.useEffect(() => {
27
   React.useEffect(() => {
28
     if (id) {
28
     if (id) {
29
       getTaCustomId(id).then((res) => {
29
       getTaCustomId(id).then((res) => {
30
-        formRef.current?.setFieldsValue(res)
31
-      })
30
+        formRef.current?.setFieldsValue(res);
31
+      });
32
     }
32
     }
33
-  })
33
+  });
34
 
34
 
35
   const onFinish = (values) => {
35
   const onFinish = (values) => {
36
-    startSubmit()
36
+    startSubmit();
37
     if (id) {
37
     if (id) {
38
       //修改
38
       //修改
39
-      const customId = id
39
+      const customId = id;
40
       putTaCustom(id, { customId, ...values })
40
       putTaCustom(id, { customId, ...values })
41
         .then((res) => {
41
         .then((res) => {
42
-          cancelSubmit()
43
-          navigate(-1)
42
+          cancelSubmit();
43
+          navigate(-1);
44
         })
44
         })
45
         .catch(() => {
45
         .catch(() => {
46
-          cancelSubmit()
47
-        })
46
+          cancelSubmit();
47
+        });
48
     } else {
48
     } else {
49
       //新增
49
       //新增
50
       postTaCustom(values)
50
       postTaCustom(values)
51
         .then((res) => {
51
         .then((res) => {
52
-          cancelSubmit()
53
-          navigate(-1)
52
+          cancelSubmit();
53
+          navigate(-1);
54
         })
54
         })
55
         .catch(() => {
55
         .catch(() => {
56
-          cancelSubmit()
57
-        })
56
+          cancelSubmit();
57
+        });
58
     }
58
     }
59
-  }
59
+  };
60
 
60
 
61
   return (
61
   return (
62
     <Page>
62
     <Page>
87
           <ProFormText name="account" label="客户账号" />
87
           <ProFormText name="account" label="客户账号" />
88
           <ProFormText name="contactsName" label="联系人姓名" />
88
           <ProFormText name="contactsName" label="联系人姓名" />
89
           <ProFormText name="contactsTitle" label="联系人头衔" />
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
           <ProFormText name="contactsEmail" label="联系人邮箱" />
96
           <ProFormText name="contactsEmail" label="联系人邮箱" />
92
           <ProFormRadio.Group
97
           <ProFormRadio.Group
93
             name="isOrg"
98
             name="isOrg"
94
             label="是否企业"
99
             label="是否企业"
95
             options={[
100
             options={[
96
-              { label: '否', value: 0 },
97
-              { label: '是', value: 1 },
101
+              { label: "否", value: 0 },
102
+              { label: "是", value: 1 },
98
             ]}
103
             ]}
99
           />
104
           />
100
         </ProForm>
105
         </ProForm>
101
       </Card>
106
       </Card>
102
     </Page>
107
     </Page>
103
-  )
104
-}
108
+  );
109
+};

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

5
 import { queryTable } from "@/utils/request";
5
 import { queryTable } from "@/utils/request";
6
 import { getTaCustom, deleteTaCustom } from "@/services/taCustom";
6
 import { getTaCustom, deleteTaCustom } from "@/services/taCustom";
7
 import Page from "@/components/Page";
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
 export default (props) => {
14
 export default (props) => {
12
   const actionRef = React.useRef();
15
   const actionRef = React.useRef();
20
     }
23
     }
21
   };
24
   };
22
 
25
 
23
-
24
   const columns = [
26
   const columns = [
25
     {
27
     {
26
-      title: '客户名',
27
-      dataIndex: 'customName',
28
+      title: "客户名",
29
+      dataIndex: "customName",
28
       ellipsis: true,
30
       ellipsis: true,
29
     },
31
     },
30
     {
32
     {
49
       ellipsis: true,
51
       ellipsis: true,
50
     },
52
     },
51
     {
53
     {
52
-      title: '联系人头衔',
53
-      dataIndex: 'contactsTitle',
54
+      title: "联系人头衔",
55
+      dataIndex: "contactsTitle",
54
       ellipsis: true,
56
       ellipsis: true,
55
       search: false,
57
       search: false,
56
     },
58
     },
71
       ellipsis: true,
73
       ellipsis: true,
72
     },
74
     },
73
     {
75
     {
74
-      title: '是否企业',
75
-      dataIndex: 'isOrg',
76
+      title: "是否企业",
77
+      dataIndex: "isOrg",
76
       ellipsis: true,
78
       ellipsis: true,
77
-      valueType: 'select',
79
+      valueType: "select",
78
       valueEnum: {
80
       valueEnum: {
79
-        0: '否',
80
-        1: '是',
81
+        0: "否",
82
+        1: "是",
81
       },
83
       },
82
     },
84
     },
83
     // {
85
     // {
91
     //   ellipsis: true,
93
     //   ellipsis: true,
92
     //   search: false,
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
         <Button
106
         <Button
100
-          key={3}
101
-          style={{ padding: 0 }}
102
-          type="link"
107
+          key="1"
108
+          type="primary"
103
           onClick={() => {
109
           onClick={() => {
104
-            navigate(`/custom/edit?id=${record.customId}`);
110
+            navigate("/custom/edit");
105
           }}
111
           }}
106
         >
112
         >
107
-          编辑
113
+          新增
108
         </Button>,
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
 import List from "@/components/Page/List";
3
 import List from "@/components/Page/List";
4
 import moment from "moment";
4
 import moment from "moment";
5
 import { useNavigate } from "react-router-dom";
5
 import { useNavigate } from "react-router-dom";
6
+import { Button, Popconfirm } from "antd";
6
 export default (props) => {
7
 export default (props) => {
7
   const navigate = useNavigate();
8
   const navigate = useNavigate();
8
 
9
 
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
   return (
93
   return (
62
     <List
94
     <List
63
       // actionRef={actionRef}
95
       // actionRef={actionRef}
64
       rowKey="memberId"
96
       rowKey="memberId"
65
       onEdit={(record) => navigate(`/member/edit?id=${record.memberId}`)}
97
       onEdit={(record) => navigate(`/member/edit?id=${record.memberId}`)}
98
+      columnOptionRender={ColumnOptionRender}
99
+
66
       // onDelete={(record) => handleDelete(record.memberId)}
100
       // onDelete={(record) => handleDelete(record.memberId)}
67
       // toolBarRender={() => [
101
       // toolBarRender={() => [
68
       //   <Button
102
       //   <Button