Blame view

src/pages/Order/components/FinancialMergeDrawer.tsx 4.04 KB
1
import { RESPONSE_CODE } from '@/constants/enum';
zhongnanhuang authored
2
import { enumToSelect } from '@/utils';
3
4
5
import {
  DrawerForm,
  ProFormDatePicker,
zhongnanhuang authored
6
  ProFormDigit,
7
8
9
10
11
  ProFormSelect,
  ProFormText,
  ProFormTextArea,
} from '@ant-design/pro-components';
import { Form, message } from 'antd';
zhongnanhuang authored
12
import { PAYEE_OPTIONS } from '../constant';
13
14

export default ({ dataList, setVisible, onClose }) => {
zhongnanhuang authored
15
16
17
  // let subOrderIds = dataList?.map((item) => {
  //   return item.id;
  // });
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
  let firstMainOrder = dataList[0];
  let bank = firstMainOrder?.bank;
  let bankAccountNumber = firstMainOrder?.bankAccountNumber;
  let invoiceIdentificationNumber = firstMainOrder?.invoiceIdentificationNumber;

  const [form] = Form.useForm<{
    invoicingTime: string;
    financialReceiptIssuanceTime: string;
    invoicingNotes: string;
    afterInvoicingStatus: string;
    collectMoneyTime: string;
  }>();
  return (
    <DrawerForm
      open
      title="合并开票"
      resize={{
        onResize() {
          console.log('resize!');
        },
        maxWidth: window.innerWidth * 0.8,
        minWidth: 400,
      }}
      form={form}
      autoFocusFirstInput
      drawerProps={{
        destroyOnClose: true,
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
zhongnanhuang authored
48
49
50
51
52
53
54
55
56
57
58
        console.log(values);
        let res;
        let body = values;
        body.subIds = subIds;
        body.mainOrderId = mainOrder.id;
        body.mainorderOrSubOrderInvoicing = isMainOrder;
        if (isEdit) {
          res = await postServiceOrderEditOrder({ data: body });
        } else {
          res = await postServiceOrderInvoicing({ data: body });
        }
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
        if (res.result === RESPONSE_CODE.SUCCESS) {
          message.success(res.message);
          onClose();
        }
      }}
      onOpenChange={(val) => {
        return !val && setVisible();
      }}
    >
      <ProFormText
        width="lg"
        name="invoiceIdentificationNumber"
        label="开票信息"
        placeholder="请输入开票信息"
        initialValue={invoiceIdentificationNumber}
        disabled
      />
      <ProFormText
        width="lg"
        name="bank"
        label="开户银行"
        placeholder="请输入开户银行"
        initialValue={bank}
        disabled
      />
      <ProFormText
        width="lg"
        name="bankAccountNumber"
        label="开户银行账号"
        placeholder="请输入开户银行账号"
        initialValue={bankAccountNumber}
        disabled
      />

      <ProFormDatePicker
        key="invoicingTime"
        width="lg"
        name="invoicingTime"
        label="开票时间"
        rules={[{ required: true, message: '这是必填项' }]}
      />
      <ProFormDatePicker
        key="financialReceiptIssuanceTime"
        width="lg"
        name="financialReceiptIssuanceTime"
        label="开收据时间"
      />
      <ProFormDatePicker
        key="collectMoneyTime"
        width="lg"
        name="collectMoneyTime"
        label="收款时间"
      />
zhongnanhuang authored
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
      <ProFormText
        width="lg"
        key="invoiceNumber"
        name="invoiceNumber"
        label="发票号码"
        rules={[{ required: true, message: '发票号码必填' }]}
      />
      <ProFormSelect
        key="payee"
        placeholder="选择收款单位"
        name="payee"
        width="lg"
        label="收款单位"
        options={enumToSelect(PAYEE_OPTIONS)}
        rules={[{ required: true, message: '收款单位必填' }]}
      />
128
zhongnanhuang authored
129
130
131
132
133
134
135
      <ProFormDigit
        key="money"
        name="money"
        width="lg"
        label="金额"
        rules={[{ required: true, message: '金额必填' }]}
      />
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
      <ProFormSelect
        placeholder="是否完全开票"
        name="afterInvoicingStatus"
        width="lg"
        label="是否完全开票"
        options={[
          { label: '完全开票', value: 'COMPLETE_INVOICING' },
          { label: '部分开票', value: 'PARTIAL_INVOICING' },
        ]}
        initialValue={'COMPLETE_INVOICING'}
      />
      <ProFormTextArea width="lg" name="invoicingNotes" label="备注" />
    </DrawerForm>
  );
};