kts-component-invoice-operate 3.2.257 → 3.2.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Invoice/Invoice-digtal/_test/passenger/index.d.ts +4 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/PassengerListState/IColumnsReplenish/index.d.ts +6 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/PassengerListState/IGood/index.d.ts +24 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/PassengerListState/index.d.ts +44 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/index.d.ts +5 -0
- package/dist/Invoice/InvoiceController/fns/addPassenger.d.ts +6 -0
- package/dist/Invoice/InvoiceController/fns/delPassenger.d.ts +6 -0
- package/dist/Invoice/InvoiceController/fns/saveEditPassenger.d.ts +6 -0
- package/dist/Invoice/InvoiceController/fns/setEditPassenger.d.ts +6 -0
- package/dist/Invoice/InvoiceController/index.d.ts +12 -0
- package/dist/Invoice/index.d.ts +2 -0
- package/dist/Invoice/ui/components/CustomCascader/index.d.ts +20 -0
- package/dist/Invoice/ui/default/ImportPassengerDrawer/index.d.ts +3 -0
- package/dist/Invoice/ui/digtal/PassengerList/hook/useColumns/index.d.ts +3 -0
- package/dist/Invoice/ui/digtal/PassengerList/hook/useColumns/ui/TitleText/index.d.ts +8 -0
- package/dist/Invoice/ui/digtal/PassengerList/hook/useOnRow/index.d.ts +8 -0
- package/dist/Invoice/ui/digtal/PassengerList/hook/useRowSelection/index.d.ts +8 -0
- package/dist/Invoice/ui/digtal/PassengerList/hook/useWindowClick/index.d.ts +8 -0
- package/dist/Invoice/ui/digtal/PassengerList/index.d.ts +18 -0
- package/dist/Invoice/ui/digtal/PassengerList/ui/AddRowButton/index.d.ts +3 -0
- package/dist/Invoice/ui/digtal/PassengerList/ui/BatchImportButton/index.d.ts +3 -0
- package/dist/Invoice/ui/digtal/PassengerList/ui/BulkMenu/hooks/useDelRowButton/index.d.ts +6 -0
- package/dist/Invoice/ui/digtal/PassengerList/ui/BulkMenu/hooks/useEmptyRefill/index.d.ts +6 -0
- package/dist/Invoice/ui/digtal/PassengerList/ui/TableRow/index.d.ts +3 -0
- package/dist/Invoice/ui/digtal/PassengerList/ui/TableVirtual/index.d.ts +4 -0
- package/dist/Invoice/ui/digtal/Stakeholder/index.d.ts +2 -0
- package/dist/index.esm.js +3501 -45
- package/dist/index.js +3491 -35
- package/package.json +1 -1
- package/src/Invoice/Invoice-digtal/_test/freight/index.tsx +12 -0
- package/src/Invoice/Invoice-digtal/_test/passenger/index.tsx +14602 -0
- package/src/Invoice/Invoice-digtal/index.md +3 -0
- package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +11 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/PassengerListState/IColumnsReplenish/index.ts +10 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/PassengerListState/IGood/index.ts +34 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/PassengerListState/index.ts +179 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +8 -2
- package/src/Invoice/InvoiceController/fns/addPassenger.ts +11 -0
- package/src/Invoice/InvoiceController/fns/delPassenger.ts +38 -0
- package/src/Invoice/InvoiceController/fns/saveEditPassenger.ts +24 -0
- package/src/Invoice/InvoiceController/fns/setEditPassenger.ts +16 -0
- package/src/Invoice/InvoiceController/index.ts +23 -1
- package/src/Invoice/index.tsx +5 -0
- package/src/Invoice/ui/components/CustomCascader/index.tsx +356 -0
- package/src/Invoice/ui/default/ImportPassengerDrawer/index.tsx +214 -0
- package/src/Invoice/ui/digtal/PassengerList/hook/useColumns/index.tsx +428 -0
- package/src/Invoice/ui/digtal/PassengerList/hook/useColumns/ui/TitleText/index.tsx +20 -0
- package/src/Invoice/ui/digtal/PassengerList/hook/useOnRow/index.tsx +37 -0
- package/src/Invoice/ui/digtal/PassengerList/hook/useRowSelection/index.tsx +120 -0
- package/src/Invoice/ui/digtal/PassengerList/hook/useWindowClick/index.tsx +23 -0
- package/src/Invoice/ui/digtal/PassengerList/index.less +73 -0
- package/src/Invoice/ui/digtal/PassengerList/index.tsx +152 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/AddRowButton/index.tsx +75 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/BatchImportButton/index.tsx +74 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +37 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/TableRow/index.less +29 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/TableRow/index.tsx +21 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/TableVirtual/index.less +39 -0
- package/src/Invoice/ui/digtal/PassengerList/ui/TableVirtual/index.tsx +109 -0
- package/src/Invoice/ui/digtal/Stakeholder/index.tsx +22 -17
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Form } from 'kts-components-antd-x3';
|
|
4
|
+
import { Select, Input, Spin, InputProps, Cascader, DatePicker } from 'kts-xui';
|
|
5
|
+
import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
|
|
6
|
+
import { IGoodPassenger } from '../../../../../InvoiceController';
|
|
7
|
+
import Invoice from '../../../../..';
|
|
8
|
+
import TitleText from './ui/TitleText';
|
|
9
|
+
import moment from 'moment';
|
|
10
|
+
import CustomCascader from '@/Invoice/ui/components/CustomCascader';
|
|
11
|
+
|
|
12
|
+
export default (form: WrappedFormUtils, isRequired?: boolean) => {
|
|
13
|
+
const { getFieldDecorator } = form;
|
|
14
|
+
|
|
15
|
+
const controller = Invoice.useInvoiceController();
|
|
16
|
+
|
|
17
|
+
const rootElement = controller.useMemo(s => s.rootElement, []);
|
|
18
|
+
|
|
19
|
+
/** 组件模式 */
|
|
20
|
+
const model = controller.useMemo(e => e.model, []);
|
|
21
|
+
|
|
22
|
+
/** 正在编辑的货物 */
|
|
23
|
+
const editGood = controller.useMemo((e) => e.passengerListState.editGood, []);
|
|
24
|
+
|
|
25
|
+
/** 禁用字段 */
|
|
26
|
+
const disableds = controller.useMemo((e) => e.stakeholder.disableds || [], []);
|
|
27
|
+
|
|
28
|
+
/** 运输工具种类列表 */
|
|
29
|
+
const vehicleTypeList = controller.useMemo((e) => e.passengerListState.vehicleTypeList, []);
|
|
30
|
+
|
|
31
|
+
/** 证件类型列表 */
|
|
32
|
+
const certificateTypeList = controller.useMemo((e) => e.passengerListState.certificateTypeList, []);
|
|
33
|
+
|
|
34
|
+
const area = controller.useMemo((e) => e.passengerListState.area, []);
|
|
35
|
+
const addressFieldNames = controller.useMemo((e) => e.passengerListState.addressFieldNames, []);
|
|
36
|
+
|
|
37
|
+
const getVehicle = React.useCallback((value?: string) => {
|
|
38
|
+
if (vehicleTypeList && vehicleTypeList.length > 0) {
|
|
39
|
+
return vehicleTypeList.find(e => e.value === value)?.label || '';
|
|
40
|
+
}
|
|
41
|
+
}, [vehicleTypeList])
|
|
42
|
+
|
|
43
|
+
const getCertificateType = React.useCallback((value?: string) => {
|
|
44
|
+
if (certificateTypeList && certificateTypeList.length > 0) {
|
|
45
|
+
return certificateTypeList.find(e => e.value === value)?.label || '';
|
|
46
|
+
}
|
|
47
|
+
}, [certificateTypeList])
|
|
48
|
+
|
|
49
|
+
// 等级选项配置
|
|
50
|
+
const levelOptionsMap = React.useMemo(() => {
|
|
51
|
+
return {
|
|
52
|
+
'AIRCRAFT': { // 飞机
|
|
53
|
+
options: [
|
|
54
|
+
{ value: '公务舱', label: '公务舱' },
|
|
55
|
+
{ value: '头等舱', label: '头等舱' },
|
|
56
|
+
{ value: '经济舱', label: '经济舱' },
|
|
57
|
+
],
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
'TRAIN': { // 火车
|
|
61
|
+
options: [
|
|
62
|
+
{ value: '一等座', label: '一等座' },
|
|
63
|
+
{ value: '二等座', label: '二等座' },
|
|
64
|
+
{ value: '软席(软座、软卧)', label: '软席(软座、软卧)' },
|
|
65
|
+
{ value: '硬席(硬座、硬卧)', label: '硬席(硬座、硬卧)' },
|
|
66
|
+
],
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
'SHIP': { // 船舶
|
|
70
|
+
options: [
|
|
71
|
+
{ value: '一等舱', label: '一等舱' },
|
|
72
|
+
{ value: '二等舱', label: '二等舱' },
|
|
73
|
+
{ value: '三等舱', label: '三等舱' },
|
|
74
|
+
],
|
|
75
|
+
required: true,
|
|
76
|
+
},
|
|
77
|
+
// 其他类型不配置,则等级为非必填的文本输入
|
|
78
|
+
} as any;
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const splitArea = React.useCallback((value?: string) => {
|
|
82
|
+
if (value) {
|
|
83
|
+
const _array = value.split(',');
|
|
84
|
+
return _array;
|
|
85
|
+
} else {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
/** 表头 */
|
|
91
|
+
const columns = React.useMemo(() => {
|
|
92
|
+
return [
|
|
93
|
+
// {
|
|
94
|
+
// title: '序号',
|
|
95
|
+
// key: 'cxrxh',
|
|
96
|
+
// dataIndex: 'cxrxh',
|
|
97
|
+
// width: 50,
|
|
98
|
+
// render: (e: number) => <span style={{ padding: '0 10px' }}>{e}</span>,
|
|
99
|
+
// },
|
|
100
|
+
{
|
|
101
|
+
title: <TitleText required>出行人</TitleText>,
|
|
102
|
+
dataIndex: 'cxr',
|
|
103
|
+
key: 'cxr',
|
|
104
|
+
width: 100,
|
|
105
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
106
|
+
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
107
|
+
return (
|
|
108
|
+
<Form.Item>
|
|
109
|
+
{getFieldDecorator('cxr', {
|
|
110
|
+
initialValue: editGood.cxr,
|
|
111
|
+
rules: [
|
|
112
|
+
{ required: true, message: '请输入出行人' },
|
|
113
|
+
],
|
|
114
|
+
})(
|
|
115
|
+
<MyInput
|
|
116
|
+
maxLength={20}
|
|
117
|
+
onChange={async () => {
|
|
118
|
+
await controller.wait()
|
|
119
|
+
await controller.setEditPassenger({ cxr: form.getFieldsValue().cxr });
|
|
120
|
+
}}
|
|
121
|
+
/>,
|
|
122
|
+
)}
|
|
123
|
+
</Form.Item>
|
|
124
|
+
);
|
|
125
|
+
} else {
|
|
126
|
+
return <span style={{ padding: '0 10px' }}>{record.cxr}</span>;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
title: <TitleText required={isRequired}>出行日期</TitleText>,
|
|
132
|
+
dataIndex: 'chuxrq',
|
|
133
|
+
key: 'chuxrq',
|
|
134
|
+
width: 130,
|
|
135
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
136
|
+
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
137
|
+
return (
|
|
138
|
+
<Form.Item>
|
|
139
|
+
{getFieldDecorator('chuxrq', {
|
|
140
|
+
initialValue: editGood.chuxrq ? moment(editGood.chuxrq) : undefined,
|
|
141
|
+
rules: [
|
|
142
|
+
{ required: isRequired, message: '请选择出行日期' },
|
|
143
|
+
],
|
|
144
|
+
})(
|
|
145
|
+
<DatePicker
|
|
146
|
+
format="YYYY-MM-DD"
|
|
147
|
+
placeholder='请选择'
|
|
148
|
+
onChange={async (v) => {
|
|
149
|
+
await controller.wait()
|
|
150
|
+
await controller.setEditPassenger({ chuxrq: moment(v).format('YYYY-MM-DD') });
|
|
151
|
+
}}
|
|
152
|
+
/>,
|
|
153
|
+
)}
|
|
154
|
+
</Form.Item>
|
|
155
|
+
);
|
|
156
|
+
} else {
|
|
157
|
+
return <span style={{ padding: '0 10px' }}>{record.chuxrq}</span>;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
title: <TitleText required={isRequired} >出行人证件类型</TitleText>,
|
|
163
|
+
key: 'cxrzjlxDm',
|
|
164
|
+
dataIndex: 'cxrzjlxDm',
|
|
165
|
+
width: 160,
|
|
166
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
167
|
+
if (editGood?.$index === record.$index && !(model === 'prefab')) {
|
|
168
|
+
return (
|
|
169
|
+
<Form.Item>
|
|
170
|
+
{getFieldDecorator('cxrzjlxDm', {
|
|
171
|
+
initialValue: editGood.cxrzjlxDm,
|
|
172
|
+
rules: [
|
|
173
|
+
{ required: isRequired, message: '请选择出行人证件类型' },
|
|
174
|
+
],
|
|
175
|
+
})(
|
|
176
|
+
<Select
|
|
177
|
+
className="kts-invoice-operate-goods-list-table-tax-rate"
|
|
178
|
+
showArrow={true}
|
|
179
|
+
allowClear={true}
|
|
180
|
+
style={{ width: '100%' }}
|
|
181
|
+
getPopupContainer={() => rootElement || document.body}
|
|
182
|
+
onChange={async (value) => {
|
|
183
|
+
await controller.wait()
|
|
184
|
+
controller.setEditPassenger({ cxrzjlxDm: value });
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
{(certificateTypeList).map((e, i) => {
|
|
188
|
+
return (
|
|
189
|
+
<Select.Option key={i} value={e.value}>
|
|
190
|
+
{e.label}
|
|
191
|
+
</Select.Option>
|
|
192
|
+
);
|
|
193
|
+
})}
|
|
194
|
+
</Select>,
|
|
195
|
+
)}
|
|
196
|
+
</Form.Item>
|
|
197
|
+
);
|
|
198
|
+
} else {
|
|
199
|
+
return <span style={{ padding: '0 10px' }}>{getCertificateType(record.cxrzjlxDm)}</span>;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
title: <TitleText required={isRequired}>出行人证件号码</TitleText>,
|
|
205
|
+
dataIndex: 'sfzjhm',
|
|
206
|
+
key: 'sfzjhm',
|
|
207
|
+
width: 150,
|
|
208
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
209
|
+
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
210
|
+
return (
|
|
211
|
+
<Form.Item>
|
|
212
|
+
{getFieldDecorator('sfzjhm', {
|
|
213
|
+
initialValue: editGood.sfzjhm,
|
|
214
|
+
rules: [
|
|
215
|
+
{ required: isRequired, message: '请输入证件号码' },
|
|
216
|
+
],
|
|
217
|
+
})(
|
|
218
|
+
<MyInput
|
|
219
|
+
maxLength={20}
|
|
220
|
+
onChange={async () => {
|
|
221
|
+
await controller.wait()
|
|
222
|
+
await controller.setEditPassenger({ sfzjhm: form.getFieldsValue().sfzjhm });
|
|
223
|
+
}}
|
|
224
|
+
/>,
|
|
225
|
+
)}
|
|
226
|
+
</Form.Item>
|
|
227
|
+
);
|
|
228
|
+
} else {
|
|
229
|
+
return <span style={{ padding: '0 10px' }}>{record.sfzjhm}</span>;
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
{
|
|
235
|
+
title: <TitleText required={isRequired}>出发点</TitleText>,
|
|
236
|
+
key: 'cfd',
|
|
237
|
+
dataIndex: 'cfd',
|
|
238
|
+
width: 180,
|
|
239
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
240
|
+
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
241
|
+
return (
|
|
242
|
+
<Form.Item>
|
|
243
|
+
{getFieldDecorator('cfd', {
|
|
244
|
+
initialValue: editGood.cfd,
|
|
245
|
+
rules: [
|
|
246
|
+
{ required: isRequired, message: '请输入出发点' },
|
|
247
|
+
],
|
|
248
|
+
})(<CustomCascader
|
|
249
|
+
style={{ width: '100%' }}
|
|
250
|
+
options={area}
|
|
251
|
+
fieldNames={addressFieldNames}
|
|
252
|
+
onChange={async (value: any) => {
|
|
253
|
+
await controller.setEditPassenger({ cfd: value });
|
|
254
|
+
}}
|
|
255
|
+
/>)}
|
|
256
|
+
</Form.Item>
|
|
257
|
+
);
|
|
258
|
+
} else {
|
|
259
|
+
return <span style={{ padding: '0 10px' }}>{record.cfd}</span>;
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
title: <TitleText required={isRequired}>到达地</TitleText>,
|
|
265
|
+
dataIndex: 'ddd',
|
|
266
|
+
key: 'ddd',
|
|
267
|
+
width: 180,
|
|
268
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
269
|
+
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
270
|
+
return (
|
|
271
|
+
<Form.Item>
|
|
272
|
+
{getFieldDecorator('ddd', {
|
|
273
|
+
initialValue: editGood.ddd,
|
|
274
|
+
rules: [
|
|
275
|
+
{ required: isRequired, message: '请输入到达地' },
|
|
276
|
+
],
|
|
277
|
+
})(
|
|
278
|
+
<CustomCascader
|
|
279
|
+
options={area}
|
|
280
|
+
fieldNames={addressFieldNames}
|
|
281
|
+
style={{ width: '100%' }}
|
|
282
|
+
onChange={async (value) => {
|
|
283
|
+
await controller.setEditPassenger({ ddd: value });
|
|
284
|
+
}}
|
|
285
|
+
/>
|
|
286
|
+
)}
|
|
287
|
+
</Form.Item>
|
|
288
|
+
);
|
|
289
|
+
} else {
|
|
290
|
+
return <span style={{ padding: '0 10px' }}>{record.ddd}</span>;
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
title: <TitleText required={isRequired} >交通工具类型</TitleText>,
|
|
296
|
+
key: 'jtgjlxDm',
|
|
297
|
+
dataIndex: 'jtgjlxDm',
|
|
298
|
+
width: 130,
|
|
299
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
300
|
+
if (editGood?.$index === record.$index && !(model === 'prefab')) {
|
|
301
|
+
return (
|
|
302
|
+
<Form.Item>
|
|
303
|
+
{getFieldDecorator('jtgjlxDm', {
|
|
304
|
+
initialValue: editGood.jtgjlxDm,
|
|
305
|
+
rules: [
|
|
306
|
+
{ required: isRequired, message: '请选择交通工具类型' },
|
|
307
|
+
],
|
|
308
|
+
})(
|
|
309
|
+
<Select
|
|
310
|
+
className="kts-invoice-operate-goods-list-table-tax-rate"
|
|
311
|
+
showArrow={true}
|
|
312
|
+
allowClear={true}
|
|
313
|
+
style={{ width: '100%' }}
|
|
314
|
+
getPopupContainer={() => rootElement || document.body}
|
|
315
|
+
onChange={async (value) => {
|
|
316
|
+
await controller.wait()
|
|
317
|
+
controller.setEditPassenger({ jtgjlxDm: value });
|
|
318
|
+
}}
|
|
319
|
+
>
|
|
320
|
+
{(vehicleTypeList).map((e, i) => {
|
|
321
|
+
return (
|
|
322
|
+
<Select.Option key={i} value={e.value} disabled={e.disabled}>
|
|
323
|
+
{e.label}{e.disabled ? '(暂不支持)' : ''}
|
|
324
|
+
</Select.Option>
|
|
325
|
+
);
|
|
326
|
+
})}
|
|
327
|
+
</Select>,
|
|
328
|
+
)}
|
|
329
|
+
</Form.Item>
|
|
330
|
+
);
|
|
331
|
+
} else {
|
|
332
|
+
return <span style={{ padding: '0 10px' }}>{getVehicle(record.jtgjlxDm)}</span>;
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
title: <TitleText required={false}>等级</TitleText>,
|
|
338
|
+
dataIndex: 'zwdj',
|
|
339
|
+
key: 'zwdj',
|
|
340
|
+
width: 110,
|
|
341
|
+
render: (_: string, record: IGoodPassenger) => {
|
|
342
|
+
if (editGood?.$index === record.$index && model !== 'prefab') {
|
|
343
|
+
// 获取当前等级配置
|
|
344
|
+
const levelConfig: any = editGood.jtgjlxDm ? levelOptionsMap[editGood.jtgjlxDm as any] : undefined;
|
|
345
|
+
const isLevelSelect = !!levelConfig;
|
|
346
|
+
const isLevelRequired = levelConfig?.required || false;
|
|
347
|
+
const levelOptions = levelConfig?.options || [];
|
|
348
|
+
return (
|
|
349
|
+
<Form.Item>
|
|
350
|
+
{getFieldDecorator('zwdj', {
|
|
351
|
+
initialValue: editGood.zwdj,
|
|
352
|
+
rules: [
|
|
353
|
+
{ required: isLevelRequired, message: '请选择等级' },
|
|
354
|
+
],
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
(isLevelSelect ?
|
|
358
|
+
<Select
|
|
359
|
+
className="kts-invoice-operate-goods-list-table-tax-rate"
|
|
360
|
+
showArrow={true}
|
|
361
|
+
allowClear={true}
|
|
362
|
+
style={{ width: '100%' }
|
|
363
|
+
}
|
|
364
|
+
getPopupContainer={() => rootElement || document.body}
|
|
365
|
+
onChange={async (value) => {
|
|
366
|
+
await controller.wait()
|
|
367
|
+
controller.setEditPassenger({ zwdj: value });
|
|
368
|
+
}}
|
|
369
|
+
>
|
|
370
|
+
{(levelOptions).map((e:any, i:any) => {
|
|
371
|
+
return (
|
|
372
|
+
<Select.Option key={i} value={e.value}>
|
|
373
|
+
{e.label}
|
|
374
|
+
</Select.Option>
|
|
375
|
+
);
|
|
376
|
+
})}
|
|
377
|
+
</Select>
|
|
378
|
+
:
|
|
379
|
+
<MyInput
|
|
380
|
+
maxLength={20}
|
|
381
|
+
onChange={async () => {
|
|
382
|
+
await controller.wait()
|
|
383
|
+
await controller.setEditPassenger({ zwdj: form.getFieldsValue().zwdj });
|
|
384
|
+
}}
|
|
385
|
+
/>
|
|
386
|
+
)}
|
|
387
|
+
</Form.Item >
|
|
388
|
+
);
|
|
389
|
+
} else {
|
|
390
|
+
return <span style={{ padding: '0 10px' }}>{record.zwdj}</span>;
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
]
|
|
395
|
+
|
|
396
|
+
// 只读
|
|
397
|
+
.filter(e => {
|
|
398
|
+
if (model === 'readOnly') {
|
|
399
|
+
return e.key !== 'operating';
|
|
400
|
+
} else {
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
.map((e) => {
|
|
405
|
+
return {
|
|
406
|
+
...e,
|
|
407
|
+
ellipsis: true,
|
|
408
|
+
};
|
|
409
|
+
}) as any[];
|
|
410
|
+
}, [editGood, controller, model, getVehicle]);
|
|
411
|
+
|
|
412
|
+
return columns;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
class MyInput extends React.Component<InputProps & { loading?: boolean }> {
|
|
417
|
+
render() {
|
|
418
|
+
if (this.props.loading) {
|
|
419
|
+
return (
|
|
420
|
+
<Spin size="small">
|
|
421
|
+
<Input {...this.props} autoComplete="off" />
|
|
422
|
+
</Spin>
|
|
423
|
+
)
|
|
424
|
+
} else {
|
|
425
|
+
return <Input {...this.props} autoComplete="off" />
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Typography } from 'kts-components-antd-x3';
|
|
4
|
+
import { ValidationRule } from 'kts-components-antd-x3/lib/form';
|
|
5
|
+
|
|
6
|
+
const { Text } = Typography;
|
|
7
|
+
|
|
8
|
+
export default (props: { children?: React.ReactNode, required?: boolean, rules?: ValidationRule[] }) => {
|
|
9
|
+
|
|
10
|
+
const { rules, children } = props;
|
|
11
|
+
|
|
12
|
+
const required = React.useMemo(() => rules?.some(e => !!e.required) || props.required, [rules, props.required]);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
{required ? <Text type="danger">*</Text> : <></>}
|
|
17
|
+
{children}
|
|
18
|
+
</>
|
|
19
|
+
)
|
|
20
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格行事件
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import Invoice from '../../../../..';
|
|
7
|
+
import IGood from '../../../../../InvoiceController/InvoiceControllerState/PassengerListState/IGood';
|
|
8
|
+
|
|
9
|
+
export default () => {
|
|
10
|
+
/** 控制器 */
|
|
11
|
+
const controller = Invoice.useInvoiceController();
|
|
12
|
+
|
|
13
|
+
const model = controller.useMemo(s => s.model, []);
|
|
14
|
+
|
|
15
|
+
const onClick = React.useCallback(
|
|
16
|
+
async (record: IGood) => {
|
|
17
|
+
// if (model === 'prefab') return;
|
|
18
|
+
if (model === 'readOnly') return;
|
|
19
|
+
|
|
20
|
+
const editGood = controller.state.passengerListState.editGood;
|
|
21
|
+
|
|
22
|
+
if (editGood) {
|
|
23
|
+
if (editGood.$index === record.$index) return;
|
|
24
|
+
await controller.saveEditPassenger();
|
|
25
|
+
await controller.wait();
|
|
26
|
+
await controller.pipeline(async s => { s.passengerListState.editGood || (await controller.setEditPassenger(record)) })();
|
|
27
|
+
} else {
|
|
28
|
+
await controller.setEditPassenger(record);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[controller, model],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
onClick,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Checkbox } from 'kts-components-antd-x3';
|
|
4
|
+
import Invoice from '../../../../..';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
|
|
8
|
+
/** 控制器 */
|
|
9
|
+
const controller = Invoice.useInvoiceController();
|
|
10
|
+
|
|
11
|
+
/** 列表选中的货物索引列表 */
|
|
12
|
+
const selectedRowKeys = controller.useMemo(s => s.passengerListState.selectedGoodIndex, []);
|
|
13
|
+
|
|
14
|
+
/** 货物列表 */
|
|
15
|
+
const goodsList = controller.useMemo(s => s.passengerListState.goodsList, []);
|
|
16
|
+
|
|
17
|
+
/** 组件模式 */
|
|
18
|
+
const model = controller.useMemo(s => s.model, []);
|
|
19
|
+
|
|
20
|
+
/** 搜索条件 */
|
|
21
|
+
// const searchValue = controller.useMemo(s => s.goodsListState.searchValue, []);
|
|
22
|
+
|
|
23
|
+
/** 是否显示选择框 */
|
|
24
|
+
const isShow = React.useMemo(() => {
|
|
25
|
+
if (model === 'readOnly' || model === 'prefab') return false
|
|
26
|
+
return true;
|
|
27
|
+
}, [model])
|
|
28
|
+
|
|
29
|
+
/** 是否全选 */
|
|
30
|
+
// const isAll = controller.useMemo(s => s.goodsListState.goodsList.length > 0 && s.goodsListState.selectedGoodIndex.length === s.goodsListState.goodsList.length, [])
|
|
31
|
+
const isAll = controller.useMemo(s => {
|
|
32
|
+
if (s.passengerListState.selectedGoodIndex.length <= 0) return false;
|
|
33
|
+
const seeGoodsIndex = s.passengerListState.goodsList.map(e => e.$index);
|
|
34
|
+
const selectedGoodIndex = s.passengerListState.selectedGoodIndex.filter(e => seeGoodsIndex.some(t => e === t));
|
|
35
|
+
return selectedGoodIndex.length === seeGoodsIndex.length
|
|
36
|
+
}, [])
|
|
37
|
+
|
|
38
|
+
const indeterminate = controller.useMemo(s => {
|
|
39
|
+
const seeGoodsIndex = s.passengerListState.goodsList.map(e => e.$index);
|
|
40
|
+
const selectedGoodIndex = s.passengerListState.selectedGoodIndex.filter(e => seeGoodsIndex.some(t => e === t));
|
|
41
|
+
if (selectedGoodIndex.length === 0) return false;
|
|
42
|
+
return selectedGoodIndex.length < seeGoodsIndex.length
|
|
43
|
+
}, [])
|
|
44
|
+
/** 点击了全选 */
|
|
45
|
+
const onClickSelectAll = React.useCallback(async () => {
|
|
46
|
+
if (isAll) {
|
|
47
|
+
await controller.pipeline(async s => {
|
|
48
|
+
const seeGoodsIndex = s.passengerListState.goodsList.map(e => e.$index)
|
|
49
|
+
|
|
50
|
+
s.passengerListState.selectedGoodIndex = s.passengerListState.selectedGoodIndex.filter(e => !seeGoodsIndex.some(t => e === t));
|
|
51
|
+
})()
|
|
52
|
+
} else {
|
|
53
|
+
await controller.pipeline(async s => {
|
|
54
|
+
const seeGoodsIndex = s.passengerListState.goodsList.map(e => e.$index)
|
|
55
|
+
|
|
56
|
+
s.passengerListState.selectedGoodIndex = [...s.passengerListState.selectedGoodIndex, ...seeGoodsIndex];
|
|
57
|
+
s.passengerListState.selectedGoodIndex = Array.from(new Set(s.passengerListState.selectedGoodIndex));
|
|
58
|
+
})()
|
|
59
|
+
}
|
|
60
|
+
// await sortOut(true);
|
|
61
|
+
}, [controller, isAll])
|
|
62
|
+
|
|
63
|
+
const onSelect = React.useCallback(async (record, selected) => {
|
|
64
|
+
if (selected) {
|
|
65
|
+
await controller.pipeline(async s => {
|
|
66
|
+
s.passengerListState.selectedGoodIndex = [...s.passengerListState.selectedGoodIndex, record.$index];
|
|
67
|
+
s.passengerListState = { ...s.passengerListState };
|
|
68
|
+
})()
|
|
69
|
+
} else {
|
|
70
|
+
await controller.pipeline(async s => {
|
|
71
|
+
s.passengerListState.selectedGoodIndex = s.passengerListState.selectedGoodIndex.filter(e => e !== record.$index);
|
|
72
|
+
s.passengerListState = { ...s.passengerListState };
|
|
73
|
+
})()
|
|
74
|
+
}
|
|
75
|
+
// await sortOut(selected);
|
|
76
|
+
}, [controller])
|
|
77
|
+
|
|
78
|
+
const columnTitle = React.useMemo(() => {
|
|
79
|
+
return (
|
|
80
|
+
<Checkbox
|
|
81
|
+
onChange={onClickSelectAll}
|
|
82
|
+
indeterminate={indeterminate}
|
|
83
|
+
checked={isAll}
|
|
84
|
+
></Checkbox>
|
|
85
|
+
)
|
|
86
|
+
}, [goodsList, selectedRowKeys, onClickSelectAll, isAll, indeterminate])
|
|
87
|
+
|
|
88
|
+
/** 选择了商品后 调整 折扣行 和 被折扣行 */
|
|
89
|
+
const sortOut = React.useCallback(async (selected: boolean) => {
|
|
90
|
+
await controller.wait();
|
|
91
|
+
await controller.pipeline(async s => {
|
|
92
|
+
s.passengerListState.selectedGoodIndex.forEach($index => {
|
|
93
|
+
const goods = s.passengerListState.goodsMap.get($index);
|
|
94
|
+
if (!goods) return;
|
|
95
|
+
|
|
96
|
+
// 数组位置
|
|
97
|
+
let t = s.passengerListState.goodsList.indexOf(goods);
|
|
98
|
+
// goods.lineAttribute === LineAttributeType.折扣行 ? t : t++;
|
|
99
|
+
const i = s.goodsListState.goodsList[t].$index;
|
|
100
|
+
if (selected) {
|
|
101
|
+
if (s.passengerListState.selectedGoodIndex.indexOf(i) < 0) s.passengerListState.selectedGoodIndex = [...s.passengerListState.selectedGoodIndex, i];
|
|
102
|
+
} else {
|
|
103
|
+
if (s.passengerListState.selectedGoodIndex.indexOf(i) < 0) s.passengerListState.selectedGoodIndex = s.passengerListState.selectedGoodIndex.filter(e => e !== $index);
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
})()
|
|
107
|
+
}, [controller])
|
|
108
|
+
|
|
109
|
+
// React.useEffect(() => {
|
|
110
|
+
// sortOut(true);
|
|
111
|
+
// }, [sortOut, goodsList])
|
|
112
|
+
|
|
113
|
+
if (isShow === false) return undefined;
|
|
114
|
+
return {
|
|
115
|
+
columnWidth: 45,
|
|
116
|
+
columnTitle,
|
|
117
|
+
onSelect,
|
|
118
|
+
selectedRowKeys,
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 点击组件外部 保存正在编辑的行
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { InvoiceController } from "../../../../../..";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 点击组件外部 保存正在编辑的货物
|
|
11
|
+
*/
|
|
12
|
+
export default function useWindowClick(controller: InvoiceController) {
|
|
13
|
+
|
|
14
|
+
/** 点击组件外部 保存正在编辑的货物 */
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
const click = () => { setTimeout(controller.saveEditPassenger) };
|
|
17
|
+
|
|
18
|
+
window.addEventListener('click', click);
|
|
19
|
+
return () => {
|
|
20
|
+
window.removeEventListener('click', click);
|
|
21
|
+
};
|
|
22
|
+
}, [controller]);
|
|
23
|
+
}
|