|
@@ -0,0 +1,109 @@
|
|
1
|
+import { history } from 'umi';
|
|
2
|
+import { useRef,useState } from 'react';
|
|
3
|
+import { Button, Modal, message, Image,Form,Input, InputNumber } from 'antd';
|
|
4
|
+import { PlusOutlined } from '@ant-design/icons';
|
|
5
|
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
|
6
|
+import PageTable from '@/components/PageTable';
|
|
7
|
+import { getCardNoList,addCarNoBatch } from '@/services/card';
|
|
8
|
+import moment from 'moment';
|
|
9
|
+
|
|
10
|
+const formatterTime = (val) => {
|
|
11
|
+ return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
|
|
12
|
+};
|
|
13
|
+const FormItem = Form.Item;
|
|
14
|
+export default (props) => {
|
|
15
|
+ const actionRef = useRef();
|
|
16
|
+
|
|
17
|
+ const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
|
|
18
|
+ const [form] = Form.useForm();
|
|
19
|
+ const [visible, setVisible] = useState(false);
|
|
20
|
+ const [loading, setLoading] = useState(false);
|
|
21
|
+
|
|
22
|
+ const Submit=(val)=>{
|
|
23
|
+ setLoading(true)
|
|
24
|
+ addCarNoBatch(val).then(()=>{
|
|
25
|
+ message.success('制卡成功,制卡时长较长请10分钟后刷新页面查看卡号')
|
|
26
|
+ onCancel()
|
|
27
|
+ setLoading(false)
|
|
28
|
+ }).catch(err=>{
|
|
29
|
+ console.log(err)
|
|
30
|
+ setLoading(false)
|
|
31
|
+ })
|
|
32
|
+ }
|
|
33
|
+ const onCancel=()=>{
|
|
34
|
+ form.resetFields()
|
|
35
|
+ setVisible(false)
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ const actions = () => [
|
|
39
|
+ <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => setVisible(true)}>
|
|
40
|
+ 批量制卡
|
|
41
|
+ </Button>,
|
|
42
|
+ ];
|
|
43
|
+ const columns = [
|
|
44
|
+ {
|
|
45
|
+ title: '卡号',
|
|
46
|
+ key: 'cardNo',
|
|
47
|
+ dataIndex: 'cardNo',
|
|
48
|
+ },
|
|
49
|
+ {
|
|
50
|
+ title: '二维码',
|
|
51
|
+ key: 'qrcode',
|
|
52
|
+ dataIndex: 'qrcode',
|
|
53
|
+ render: (t) => <Image width={110} src={t} alt="" />,
|
|
54
|
+ search:false
|
|
55
|
+ },
|
|
56
|
+ {
|
|
57
|
+ title: '创建时间',
|
|
58
|
+ key: 'createDate',
|
|
59
|
+ dataIndex: 'createDate',
|
|
60
|
+ render: formatterTime,
|
|
61
|
+ },
|
|
62
|
+ ];
|
|
63
|
+
|
|
64
|
+ return (
|
|
65
|
+ <PageHeaderWrapper>
|
|
66
|
+ <PageTable
|
|
67
|
+ columns={columns}
|
|
68
|
+ request={getCardNoList}
|
|
69
|
+ rowKey="bannerId"
|
|
70
|
+ options={false}
|
|
71
|
+ toolBarRender={actions}
|
|
72
|
+ actionRef={actionRef}
|
|
73
|
+ />
|
|
74
|
+ <Modal
|
|
75
|
+ forceRender
|
|
76
|
+ title='犬证制卡'
|
|
77
|
+ visible={visible}
|
|
78
|
+ onCancel={onCancel}
|
|
79
|
+ keyboard={false}
|
|
80
|
+ maskClosable={false}
|
|
81
|
+ destroyOnClose={true}
|
|
82
|
+ footer={null}
|
|
83
|
+ >
|
|
84
|
+ <Form {...formItemLayout} onFinish={Submit} form={form}>
|
|
85
|
+ <FormItem label="卡号前缀" name="prefix" rules={[{ required: true, message: '请输入' }]}>
|
|
86
|
+ <Input placeholder="请输入" />
|
|
87
|
+ </FormItem>
|
|
88
|
+ <FormItem label="生成数量" name="num" tooltip='生成数建议至多1000' rules={[{ required: true, message: '请输入正整数' }]}>
|
|
89
|
+ <InputNumber style={{width:'100%'}} min={1} placeholder="请输入" />
|
|
90
|
+ </FormItem>
|
|
91
|
+ <FormItem label=" " colon={false}>
|
|
92
|
+ <Button type="default" onClick={onCancel}>
|
|
93
|
+ 取消
|
|
94
|
+ </Button>
|
|
95
|
+ <Button
|
|
96
|
+ type="primary"
|
|
97
|
+ loading={loading}
|
|
98
|
+ htmlType="Submit"
|
|
99
|
+ style={{ marginLeft: '4em' }}
|
|
100
|
+ >
|
|
101
|
+ 确认
|
|
102
|
+ </Button>
|
|
103
|
+ </FormItem>
|
|
104
|
+ </Form>
|
|
105
|
+ </Modal>
|
|
106
|
+
|
|
107
|
+ </PageHeaderWrapper>
|
|
108
|
+ );
|
|
109
|
+};
|