forked from gzzfw/frontEnd/gzDyh

xusd
2024-09-18 3ae864f005e8a874de01c15e14b83196a3f6f11b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * @Company: hugeInfo
 * @Author: lwh
 * @Date: 2022-03-11 17:01:10
 * @LastEditTime: 2022-04-11 08:46:13
 * @LastEditors: lwh
 * @Version: 1.0.0
 * @Description:客户管理-收款记录
 */
import React, { useState, useEffect } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import PageHead from '../../../components/PageHead';
import { Card, Descriptions, Input, message, Divider, Form, Select, DatePicker, Button, Spin } from 'antd';
import * as $$ from '../../../utils/utility';
import './index.less';
import moment from 'moment';
const { Option } = Select;
// 收款记录详情
function getByIdCustPay(id) {
    return $$.ax.request({ url: 'v1/custPay/getById', type: 'get', data: { id }, service: 'oper' });
}
// 保存修改版本和增强包
function saveCustPay(data) {
    return $$.ax.request({ url: 'v1/custPay/saveCustPay', type: 'POST', data, service: 'oper' });
}
 
const AddPayee = () => {
    const [form] = Form.useForm();
    const [formData, setFormData] = useState({});
    const [loading, setLoading] = useState(false);
    const navigate = useNavigate();
    const params = useParams();
 
    //初始化组件回显
    useEffect(() => {
        getOrganization();
    }, []);
 
    const getOrganization = async () => {
        const requestObj = await getByIdCustPay(params.id);
        setFormData(requestObj.data);
    };
 
    const save = async () => {
        setLoading(true);
        const row = await form.validateFields();
        const tableData = form.getFieldValue();
        const res = await saveCustPay({ ...tableData, custId: params.id });
        setLoading(false);
        if (res.type) {
            form.resetFields();
            message.success('提交成功!');
            navigate(-1);
        }
    };
 
    const reset = () => {
        form.resetFields();
    };
 
    const back = () => {
        navigate(-1);
    };
 
    return (
        <div className="add-Payee-main">
            <PageHead
                breadcrumbData={[{ title: '客户管理', url: '/operation/customer' }, { title: '新增收款记录' }]}
                title={params.title ? params.title : '新增收款记录'}
            />
            <Descriptions column={4} style={{ width: '100%', backgroundColor: '#ffffff', padding: '0 24px' }}>
                <Descriptions.Item label="累计应收">
                    <span style={{ fontWeight: '600' }}>¥{formData.planPrice}元</span>
                </Descriptions.Item>
                <Descriptions.Item label="累计实收">
                    <span style={{ fontWeight: '600' }}>¥{formData.payPrice}元</span>
                </Descriptions.Item>
                <Descriptions.Item label="剩余未收">
                    <span style={{ fontWeight: '600' }}>¥{formData.notPrice}元</span>
                </Descriptions.Item>
                <Descriptions.Item label="累计收款次数">{formData.priceCount}次</Descriptions.Item>
            </Descriptions>
            <div style={{ backgroundColor: '#fff', minHeight: '74vh', margin: '24px', display: 'flex' }}>
                <div style={{ width: '320px', padding: '24px 12px' }}>
                    {formData.custVerHis &&
                        formData.custVerHis.map((item, index) => (
                            <div style={{ padding: '12px' }}>
                                <span style={{ display: 'inline-block', width: '80px' }}>{item.verName}</span>
                                <span style={{ paddingLeft: '6px' }}>{item.openTime ? moment(item.openTime).format('YYYY-MM-DD') : ''}开通</span>
                            </div>
                        ))}
                    {formData.mealhis &&
                        formData.mealhis.map((item, index) => (
                            <div style={{ padding: '12px' }}>
                                <span style={{ display: 'inline-block', width: '80px' }}>{item.mealName}</span>
                                <span style={{ paddingLeft: '6px' }}>{item.createTime ? moment(item.createTime).format('YYYY-MM-DD') : ''}开通</span>
                            </div>
                        ))}
                </div>
                <Divider style={{ color: '#e8e8e8', minHeight: '70vh', margin: '24px 0' }} type="vertical" />
                {/* <div style={{ margin: '24px', width: '320px' }}>试用版</div> */}
                <Spin spinning={loading}>
                    <Card bordered={false} style={{ margin: '24px', width: '100%', paddingLeft: '23vh' }}>
                        <Form form={form} labelCol={{ style: { width: '100%', textAlign: 'left' } }} layout="vertical" component={false}>
                            <Form.Item label="收款金额" name="payPrice" rules={[{ required: false, message: `请输入收款金额` }]}>
                                <Input type={'number'} prefix={'¥'} suffix={'元'} placeholder={`请输入收款金额`} style={{ width: '320px' }} />
                            </Form.Item>
                            <Form.Item label="收款日期" name="payTime" rules={[{ required: false, message: `请选择收款日期` }]}>
                                <DatePicker
                                    format="YYYY-MM-DD"
                                    placeholder={`请选择收款日期`}
                                    disabledDate={(current) => current < moment().startOf('day')}
                                    style={{ width: '320px' }}
                                />
                            </Form.Item>
                            <Form.Item label="付款单位" name="payUnit" rules={[{ required: false, message: `请输入付款单位` }]}>
                                <Input placeholder={`请输入付款单位`} style={{ width: '320px' }} />
                            </Form.Item>
                            <Form.Item label="付款账号" name="payNum" rules={[{ required: false, message: `请输入付款账号` }]}>
                                <Input placeholder={`请输入付款账号`} style={{ width: '320px' }} />
                            </Form.Item>
                            <Form.Item label="税号" name="dutyNum" rules={[{ required: false, message: `请输入税号` }]}>
                                <Input placeholder={`请输入税号`} style={{ width: '320px' }} />
                            </Form.Item>
                            <Form.Item label="开票类型" name="billType" rules={[{ required: false, message: `请选择开票类型` }]}>
                                <Select fieldNames={{ label: 'name', key: 'id' }} placeholder="请选择开票类型" style={{ width: '320px' }} allowClear>
                                    {[
                                        { name: '增值税专用发票', id: '增值税专用发票' },
                                        { name: '普通发票', id: '普通发票' },
                                        { name: '机动车专用发票', id: '机动车专用发票' },
                                        { name: '机打发票', id: '机打发票' },
                                        { name: '定额发票', id: '定额发票' },
                                        { name: '剪口发票', id: '剪口发票' },
                                    ].map((item, index) => (
                                        <Option key={index} value={item.name}>
                                            {item.name}
                                        </Option>
                                    ))}
                                </Select>
                            </Form.Item>
                            <Form.Item label="备注" name="remake" rules={[{ required: false, message: `请输入备注` }]}>
                                <Input placeholder={`请输入备注`} style={{ width: '320px' }} />
                            </Form.Item>
                        </Form>
                        <div className="add-payee-foot-buttton">
                            <Button onClick={save} type="primary">
                                提交
                            </Button>
                            <Button onClick={reset}>重置</Button>
                            <Button onClick={back}>返回</Button>
                        </div>
                    </Card>
                </Spin>
            </div>
        </div>
    );
};
 
export default AddPayee;