Blame view

src/pages/Order/components/InvoicingDrawerForm.tsx 4.37 KB
曾国涛 authored
1
2
3
4
5
6
7
// import { PlusOutlined } from '@ant-design/icons';
import {
  postServiceConstInvoiceType,
  postServiceConstInvoicingType,
  postServiceInvoiceApplyInvoice,
} from '@/services';
import { enumToSelect } from '@/utils';
曾国涛 authored
8
9
import {
  DrawerForm,
曾国涛 authored
10
  ProFormGroup,
曾国涛 authored
11
12
  ProFormList,
  ProFormMoney,
曾国涛 authored
13
14
  ProFormSelect,
  ProFormText,
曾国涛 authored
15
  ProFormTextArea,
曾国涛 authored
16
  ProFormUploadDragger,
曾国涛 authored
17
} from '@ant-design/pro-components';
曾国涛 authored
18
import { Form } from 'antd';
曾国涛 authored
19
import { useEffect } from 'react';
曾国涛 authored
20
import { PAYEE_OPTIONS } from '../constant';
曾国涛 authored
21
曾国涛 authored
22
export default ({ dataList, mainOrderList, setVisible, onClose }) => {
曾国涛 authored
23
24
25
26
  // let subOrderIds = dataList?.map((item) => {
  //   return item.id;
  // });
  const [form] = Form.useForm();
曾国涛 authored
27
  useEffect(() => {}, []);
曾国涛 authored
28
  return (
曾国涛 authored
29
30
31
    <DrawerForm
      open
      title="合并开票"
曾国涛 authored
32
33
34
35
36
      resize={{
        onResize() {
          console.log('resize!');
        },
        maxWidth: window.innerWidth * 0.8,
曾国涛 authored
37
        minWidth: 400,
曾国涛 authored
38
39
40
41
42
43
44
45
      }}
      form={form}
      autoFocusFirstInput
      drawerProps={{
        destroyOnClose: true,
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
曾国涛 authored
46
47
48
49
50
51
52
53
        postServiceInvoiceApplyInvoice({
          data: {
            ...values,
            subOrderIds: dataList.map((item) => {
              return item.id;
            }),
          },
        });
曾国涛 authored
54
        onClose();
曾国涛 authored
55
56
57
      }}
      onOpenChange={(val) => {
        return !val && setVisible();
曾国涛 authored
58
59
      }}
    >
曾国涛 authored
60
      <ProFormList
曾国涛 authored
61
        name="subOrderIdObjs"
曾国涛 authored
62
        readonly={true}
曾国涛 authored
63
        label="开票订单"
曾国涛 authored
64
65
66
67
68
        initialValue={dataList.map((item) => {
          return {
            value: item.id,
          };
        })}
曾国涛 authored
69
        deleteIconProps={false}
曾国涛 authored
70
      >
曾国涛 authored
71
        <ProFormGroup key="group">
曾国涛 authored
72
          <ProFormText readonly={true} name="value" label="" />
曾国涛 authored
73
        </ProFormGroup>
曾国涛 authored
74
      </ProFormList>
曾国涛 authored
75
      <ProFormText
曾国涛 authored
76
77
78
79
80
81
        rules={[
          {
            required: true,
          },
        ]}
        width="md"
曾国涛 authored
82
        name="partyAName"
曾国涛 authored
83
        label="购方名称"
曾国涛 authored
84
85
86
        initialValue={
          mainOrderList?.length === 1 ? mainOrderList[0].institution : ''
        }
曾国涛 authored
87
        placeholder="请输入名称"
曾国涛 authored
88
      />
曾国涛 authored
89
90
91
92
93
94
95
      <ProFormText
        rules={[
          {
            required: true,
          },
        ]}
        width="md"
曾国涛 authored
96
        name="partyATaxid"
曾国涛 authored
97
98
99
100
101
        label="购方税号"
        placeholder="请输入名称"
      />
      <ProFormText
        width="md"
曾国涛 authored
102
        name="partyAOpenBank"
曾国涛 authored
103
104
105
106
107
        label="开户银行"
        placeholder="请输入名称"
      />
      <ProFormText
        width="md"
曾国涛 authored
108
        name="partyABankAccount"
曾国涛 authored
109
110
111
112
113
        label="开户行账号"
        placeholder="请输入名称"
      />
      <ProFormMoney
        label="开票金额"
曾国涛 authored
114
        name="price"
曾国涛 authored
115
        locale="en-GB"
曾国涛 authored
116
117
118
        initialValue={dataList.reduce((accumulator, currentValue) => {
          return accumulator + currentValue.subOrderPayment;
        }, 0)}
曾国涛 authored
119
120
      />
      <ProFormSelect
曾国涛 authored
121
        name="invoicingType"
曾国涛 authored
122
        label="开具类型"
曾国涛 authored
123
124
125
126
127
        request={async () => {
          let invoicingTypeRet = await postServiceConstInvoicingType();
          let options = enumToSelect(invoicingTypeRet.data);
          return options;
        }}
曾国涛 authored
128
129
        placeholder="请选择开具类型"
        rules={[{ required: true, message: '请选择开具类型!' }]}
曾国涛 authored
130
131
      />
      <ProFormSelect
曾国涛 authored
132
        name="type"
曾国涛 authored
133
        label="开票类型"
曾国涛 authored
134
135
        placeholder="请选择开票类型"
        rules={[{ required: true, message: '请选择开票类型!' }]}
曾国涛 authored
136
137
138
139
140
        request={async () => {
          let invoiceTypeRet = await postServiceConstInvoiceType();
          let options = enumToSelect(invoiceTypeRet.data);
          return options;
        }}
曾国涛 authored
141
142
      />
      <ProFormSelect
曾国涛 authored
143
        name="partyBName"
曾国涛 authored
144
        label="开票收款单位"
曾国涛 authored
145
146
147
        options={enumToSelect(PAYEE_OPTIONS)}
        placeholder="请选择收款单位"
        rules={[{ required: true, message: '请选择收款单位!' }]}
曾国涛 authored
148
149
      />
      <ProFormSelect
曾国涛 authored
150
        name="isUrgent"
曾国涛 authored
151
152
        label="是否加急"
        valueEnum={{
曾国涛 authored
153
154
          true: '是',
          false: '否',
曾国涛 authored
155
        }}
曾国涛 authored
156
157
        placeholder="请选择是否加急"
        rules={[{ required: true, message: '请选择是否加急!' }]}
曾国涛 authored
158
159
      />
      <ProFormUploadDragger name="drag-pic" label="拖拽上传" />
曾国涛 authored
160
161
162
163
164
      <ProFormTextArea
        name="applyInvoicingNotes"
        label="备注"
        placeholder="请输入名称"
      />
曾国涛 authored
165
166
167
    </DrawerForm>
  );
};