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,73 @@
|
|
|
1
|
+
.kts-invoice-operate-freight{
|
|
2
|
+
// padding : 20px;
|
|
3
|
+
border-bottom: 2px solid #9F613E;
|
|
4
|
+
border-left: 2px solid #9F613E;
|
|
5
|
+
border-right: 2px solid #9F613E;
|
|
6
|
+
|
|
7
|
+
.real-estate-info-digtal-label {
|
|
8
|
+
padding: 20px 20px 0;
|
|
9
|
+
color: #9F613E;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ktsAnt3x-row.ktsAnt3x-form-item {
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.kts-invoice-operate-goods-list-digtal {
|
|
19
|
+
|
|
20
|
+
.goods-list-digtal-discount-tag {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
height: 20px;
|
|
23
|
+
line-height: 20px;
|
|
24
|
+
border: 1px solid;
|
|
25
|
+
padding: 0 5px;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.kts-invoice-operate-goods-list-table-tax-rate {
|
|
30
|
+
.ktsAnt3x-select-selection-selected-value {
|
|
31
|
+
float: right;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.kts-invoice-operate-freight-list-able {
|
|
36
|
+
display: flex;
|
|
37
|
+
padding: 10px;
|
|
38
|
+
border-bottom: 2px solid #9F613E;
|
|
39
|
+
gap: 10px;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ktsAntX-table {
|
|
44
|
+
|
|
45
|
+
.ktsAntX-table-row.kts-invoice-operate-goods-be-discount .ktsAntX-table-cell {
|
|
46
|
+
color: #f00;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// .ktsAntX-table-row.kts-invoice-operate-goods-discount .ktsAntX-table-cell {
|
|
50
|
+
// background: #f5f5f5;
|
|
51
|
+
// }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.kts-invoice-operate-goods-list-table-digtal {
|
|
56
|
+
|
|
57
|
+
.ktsAnt3x-form-item-control.has-error {
|
|
58
|
+
border: 1px solid #f00;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.kts-invoice-operate-goods-list-table.kts-invoice-operate-prefab {
|
|
62
|
+
.ktsAnt3x-table-row {
|
|
63
|
+
color: rgba(0, 0, 0, 0.25);
|
|
64
|
+
background: #f5f5f5;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.kts-invoice-operate-goods-list-table-search-protrude {
|
|
69
|
+
background: #ff0;
|
|
70
|
+
color: #000;
|
|
71
|
+
font-weight: bold;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { decorator } from 'grey-react-box';
|
|
5
|
+
import { Form } from 'kts-components-antd-x3';
|
|
6
|
+
import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
|
|
7
|
+
import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
|
|
8
|
+
import Invoice from '../../..';
|
|
9
|
+
|
|
10
|
+
import TableVirtual from './ui/TableVirtual';
|
|
11
|
+
import AddRowButton from './ui/AddRowButton';
|
|
12
|
+
import TableRow from './ui/TableRow';
|
|
13
|
+
|
|
14
|
+
import useColumns from './hook/useColumns';
|
|
15
|
+
import useOnRow from './hook/useOnRow';
|
|
16
|
+
import useWindowClick from './hook/useWindowClick';
|
|
17
|
+
import useRowSelection from './hook/useRowSelection';
|
|
18
|
+
|
|
19
|
+
import useDelRowButton from './ui/BulkMenu/hooks/useDelRowButton';
|
|
20
|
+
|
|
21
|
+
import './index.less';
|
|
22
|
+
import BatchImportButton from './ui/BatchImportButton';
|
|
23
|
+
|
|
24
|
+
export interface IGoodsListProps {
|
|
25
|
+
|
|
26
|
+
/** 产品最大数 */
|
|
27
|
+
goodMax?: number;
|
|
28
|
+
|
|
29
|
+
/** 必填校验 */
|
|
30
|
+
required?: boolean;
|
|
31
|
+
|
|
32
|
+
certificateTypeList?: any[];
|
|
33
|
+
|
|
34
|
+
vehicleTypeList?: any[];
|
|
35
|
+
|
|
36
|
+
addressOptions: any[];
|
|
37
|
+
/**
|
|
38
|
+
* 地址数据字段名
|
|
39
|
+
*/
|
|
40
|
+
fieldNames?: any;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default class PassengerList extends React.Component<IGoodsListProps> {
|
|
45
|
+
render() {
|
|
46
|
+
return <Main {...this.props} />
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Form.create())((props) => {
|
|
51
|
+
const { form } = props;
|
|
52
|
+
|
|
53
|
+
const [isRequired, setRequired] = React.useState(typeof props.required === 'boolean' ? props.required : true);
|
|
54
|
+
|
|
55
|
+
/** 控制器 */
|
|
56
|
+
const controller = Invoice.useInvoiceController();
|
|
57
|
+
|
|
58
|
+
const goodsList = controller.useMemo(s => s.passengerListState.goodsList, []);
|
|
59
|
+
|
|
60
|
+
/** 货物列表 */
|
|
61
|
+
const dataSource = controller.useMemo(s => s.passengerListState.goodsList, [])
|
|
62
|
+
|
|
63
|
+
/** 表格行事件 */
|
|
64
|
+
const onRow = useOnRow();
|
|
65
|
+
|
|
66
|
+
/** 批量删除 */
|
|
67
|
+
const delRowButton = useDelRowButton();
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
useWindowClick(controller); // 点击组件外部 保存正在编辑的货物
|
|
71
|
+
|
|
72
|
+
/** 注册 from 对象 */
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
controller.pipeline<WrappedFormUtils>(async (s, form) => { s.passengerListState = { ...s.passengerListState, form } })(props.form);
|
|
75
|
+
}, [controller, props.form]);
|
|
76
|
+
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
controller.run(async (s) => {
|
|
79
|
+
s.passengerListState.addressFieldNames = props.fieldNames
|
|
80
|
+
});
|
|
81
|
+
}, [props.fieldNames])
|
|
82
|
+
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
controller.run(async (s) => {
|
|
85
|
+
if (props.certificateTypeList) {
|
|
86
|
+
s.passengerListState.certificateTypeList = props.certificateTypeList
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (props.vehicleTypeList) {
|
|
90
|
+
s.passengerListState.vehicleTypeList = props.vehicleTypeList
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
});
|
|
94
|
+
}, [props.vehicleTypeList, props.certificateTypeList])
|
|
95
|
+
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
controller.run(async (s) => {
|
|
98
|
+
s.passengerListState.area = props.addressOptions
|
|
99
|
+
});
|
|
100
|
+
}, [props.addressOptions])
|
|
101
|
+
|
|
102
|
+
// 跟新 货物
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
controller.run(async (s) => {
|
|
105
|
+
s.passengerListState.goodsMap = new Map();
|
|
106
|
+
goodsList.forEach((e) => { s.passengerListState.goodsMap.set(e.$index, e); });
|
|
107
|
+
});
|
|
108
|
+
}, [controller, goodsList]);
|
|
109
|
+
|
|
110
|
+
/** props 产品最大数 更新 */
|
|
111
|
+
React.useEffect(() => {
|
|
112
|
+
controller.pipeline(async s => { s.passengerListState.goodMax = props.goodMax })()
|
|
113
|
+
}, [controller, props.goodMax])
|
|
114
|
+
// 注册 form
|
|
115
|
+
// controller.useForm('freightInfo', form);
|
|
116
|
+
return (
|
|
117
|
+
<div className="kts-invoice-operate-freight">
|
|
118
|
+
<div className='real-estate-info-digtal-label' >特定信息-旅客运输服务</div>
|
|
119
|
+
<div className="kts-invoice-operate-goods-list-digtal" onClick={(e) => { e.stopPropagation() }} >
|
|
120
|
+
<div className="kts-invoice-operate-freight-list-able">
|
|
121
|
+
{/* 添加行 */}
|
|
122
|
+
<AddRowButton />
|
|
123
|
+
|
|
124
|
+
{/* 批量删除 */}
|
|
125
|
+
{delRowButton.button}
|
|
126
|
+
|
|
127
|
+
<BatchImportButton />
|
|
128
|
+
|
|
129
|
+
<div style={{ flex: 1 }} />
|
|
130
|
+
|
|
131
|
+
</div>
|
|
132
|
+
<div className={classnames('kts-invoice-operate-goods-list-table-digtal')}>
|
|
133
|
+
<TableVirtual
|
|
134
|
+
size="small"
|
|
135
|
+
rowKey="$index"
|
|
136
|
+
pagination={false}
|
|
137
|
+
scroll={{ y: 280 }}
|
|
138
|
+
components={{ body: { row: TableRow } }}
|
|
139
|
+
dataSource={dataSource}
|
|
140
|
+
columns={useColumns(props.form, isRequired)}
|
|
141
|
+
rowSelection={useRowSelection()}
|
|
142
|
+
onRow={record => ({
|
|
143
|
+
onClick: () => {
|
|
144
|
+
onRow.onClick(record);
|
|
145
|
+
},
|
|
146
|
+
})}
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Invoice from '../../../../..';
|
|
3
|
+
import { Button, message } from 'kts-xui';
|
|
4
|
+
import InvoiceController, { LineAttributeType } from '../../../../../InvoiceController';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const controller = Invoice.useInvoiceController();
|
|
8
|
+
|
|
9
|
+
const model = controller.useMemo(s => s.model, []);
|
|
10
|
+
|
|
11
|
+
const rootElement = controller.useMemo(s => s.rootElement, []);
|
|
12
|
+
|
|
13
|
+
/** 产品数据量 */
|
|
14
|
+
const goodsNum = controller.useMemo(s => s.passengerListState.goodsList.length, []);
|
|
15
|
+
|
|
16
|
+
/** 搜索条件 */
|
|
17
|
+
const isAddRow = controller.useMemo(s => s.passengerListState.isAddRow, []);
|
|
18
|
+
|
|
19
|
+
/** 产品最大数 */
|
|
20
|
+
const goodMax = controller.useMemo(s => s.passengerListState.goodMax, []);
|
|
21
|
+
|
|
22
|
+
/** 按钮是否禁用 */
|
|
23
|
+
const disabled = React.useMemo(() => {
|
|
24
|
+
return typeof goodMax === 'number' ? goodsNum >= goodMax : false
|
|
25
|
+
}, [goodMax, goodsNum])
|
|
26
|
+
|
|
27
|
+
const onClick = React.useCallback(async () => {
|
|
28
|
+
await addGood(controller);
|
|
29
|
+
await rollBottom(controller, rootElement);
|
|
30
|
+
}, [controller, rootElement]);
|
|
31
|
+
|
|
32
|
+
if (isAddRow === false) return <></>;
|
|
33
|
+
if (model === 'prefab') return <></>;
|
|
34
|
+
if (model === 'readOnly') return <></>;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Button size='small' type='primary' onClick={onClick} disabled={disabled}>
|
|
38
|
+
增行
|
|
39
|
+
</Button>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** 添加一个空货物 */
|
|
44
|
+
async function addGood(controller: InvoiceController) {
|
|
45
|
+
await controller.saveEditPassenger();
|
|
46
|
+
await controller.wait();
|
|
47
|
+
await controller.run(async (s) => {
|
|
48
|
+
if (s.passengerListState.editGood) {
|
|
49
|
+
// message.error({
|
|
50
|
+
// content: '你正在编辑一个货物运输行',
|
|
51
|
+
// key: '你正在编辑一个货物运输行',
|
|
52
|
+
// });
|
|
53
|
+
// return;
|
|
54
|
+
await controller.state.passengerListState.form?.validateFields(async (err: any, values: any) => {
|
|
55
|
+
if (err) {
|
|
56
|
+
const firstError: any = Object.values(err)[0];
|
|
57
|
+
message.error({
|
|
58
|
+
content: firstError.errors[0].message,
|
|
59
|
+
key: '你正在编辑一条数据',
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
s.passengerListState.editGood = await controller.addPassenger({});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 货物列表,滚动到底部 */
|
|
70
|
+
async function rollBottom(controller: InvoiceController, rootElement: HTMLDivElement | null | undefined) {
|
|
71
|
+
await controller.wait();
|
|
72
|
+
const cont = rootElement?.querySelector('.ktsAntX-table-body');
|
|
73
|
+
if (!cont) return;
|
|
74
|
+
cont.scrollTop = cont.scrollHeight;
|
|
75
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Invoice from '../../../../..';
|
|
3
|
+
import { Button, message } from 'kts-xui';
|
|
4
|
+
import InvoiceController, { LineAttributeType } from '../../../../../InvoiceController';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const controller = Invoice.useInvoiceController();
|
|
8
|
+
|
|
9
|
+
const model = controller.useMemo(s => s.model, []);
|
|
10
|
+
|
|
11
|
+
const rootElement = controller.useMemo(s => s.rootElement, []);
|
|
12
|
+
|
|
13
|
+
/** 产品数据量 */
|
|
14
|
+
const goodsNum = controller.useMemo(s => s.passengerListState.goodsList.length, []);
|
|
15
|
+
|
|
16
|
+
const isBatchImport = controller.useMemo(s => s.passengerListState.isBatchImport, []);
|
|
17
|
+
|
|
18
|
+
/** 产品最大数 */
|
|
19
|
+
const goodMax = controller.useMemo(s => s.passengerListState.goodMax, []);
|
|
20
|
+
|
|
21
|
+
/** 按钮是否禁用 */
|
|
22
|
+
const disabled = React.useMemo(() => {
|
|
23
|
+
return typeof goodMax === 'number' ? goodsNum >= goodMax : false
|
|
24
|
+
}, [goodMax, goodsNum])
|
|
25
|
+
|
|
26
|
+
const onClick = React.useCallback(async () => {
|
|
27
|
+
await importGood(controller);
|
|
28
|
+
await rollBottom(controller, rootElement);
|
|
29
|
+
}, [controller, rootElement]);
|
|
30
|
+
|
|
31
|
+
if (isBatchImport === false) return <></>;
|
|
32
|
+
if (model === 'prefab') return <></>;
|
|
33
|
+
if (model === 'readOnly') return <></>;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Button size='small' onClick={onClick} disabled={disabled}>
|
|
37
|
+
批量导入
|
|
38
|
+
</Button>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** 导入 */
|
|
43
|
+
async function importGood(controller: InvoiceController) {
|
|
44
|
+
await controller.saveEditPassenger();
|
|
45
|
+
await controller.wait();
|
|
46
|
+
await controller.run(async (s) => {
|
|
47
|
+
if (s.passengerListState.editGood) {
|
|
48
|
+
// message.error({
|
|
49
|
+
// content: '你正在编辑一个货物运输行',
|
|
50
|
+
// key: '你正在编辑一个货物运输行',
|
|
51
|
+
// });
|
|
52
|
+
// return;
|
|
53
|
+
await controller.state.passengerListState.form?.validateFields(async (err: any, values: any) => {
|
|
54
|
+
if (err) {
|
|
55
|
+
const firstError: any = Object.values(err)[0];
|
|
56
|
+
message.error({
|
|
57
|
+
content: firstError.errors[0].message,
|
|
58
|
+
key: '你正在编辑一条数据',
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
s.passengerListState.isVisibleDrawer = true;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 货物列表,滚动到底部 */
|
|
69
|
+
async function rollBottom(controller: InvoiceController, rootElement: HTMLDivElement | null | undefined) {
|
|
70
|
+
await controller.wait();
|
|
71
|
+
const cont = rootElement?.querySelector('.ktsAntX-table-body');
|
|
72
|
+
if (!cont) return;
|
|
73
|
+
cont.scrollTop = cont.scrollHeight;
|
|
74
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Invoice from '../../../../../../..';
|
|
3
|
+
import { Button, Menu } from 'kts-xui';
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
|
|
7
|
+
const controller = Invoice.useInvoiceController();
|
|
8
|
+
|
|
9
|
+
const model = controller.useMemo(s => s.model, []);
|
|
10
|
+
|
|
11
|
+
const isRemRow = controller.useMemo(s => s.passengerListState.isRemRow, []);
|
|
12
|
+
|
|
13
|
+
/** 是否禁用 */
|
|
14
|
+
const disabled = controller.useMemo((s) => {
|
|
15
|
+
if (s.passengerListState.selectedGoodIndex.length <= 0) return true;
|
|
16
|
+
return false;
|
|
17
|
+
}, []);
|
|
18
|
+
|
|
19
|
+
/** 点击了删除 */
|
|
20
|
+
const onClick = React.useCallback(async () => {
|
|
21
|
+
const selectedGoodIndex = controller.state.passengerListState.selectedGoodIndex.slice();
|
|
22
|
+
for (let i = 0; i < selectedGoodIndex.length; i++) {
|
|
23
|
+
await controller.delPassenger(selectedGoodIndex[i]);
|
|
24
|
+
}
|
|
25
|
+
await controller.run(async s => { s.passengerListState.selectedGoodIndex = [] });
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
const menuItem = React.useMemo(() => {
|
|
29
|
+
|
|
30
|
+
if (model === 'prefab') return <></>;
|
|
31
|
+
if (model === 'readOnly') return <></>;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Menu.Item key="1" onClick={onClick} disabled={disabled}> 删除行 </Menu.Item>
|
|
35
|
+
)
|
|
36
|
+
}, [model, onClick, disabled])
|
|
37
|
+
|
|
38
|
+
const button = React.useMemo(() => {
|
|
39
|
+
|
|
40
|
+
if (isRemRow === false) return <></>;
|
|
41
|
+
if (model === 'prefab') return <></>;
|
|
42
|
+
if (model === 'readOnly') return <></>;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Button size='small' onClick={onClick} disabled={disabled} >删除</Button>
|
|
46
|
+
)
|
|
47
|
+
}, [model, onClick, disabled, isRemRow])
|
|
48
|
+
|
|
49
|
+
return { button, menuItem };
|
|
50
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import Invoice from '../../../../../../..';
|
|
3
|
+
import { Button, Popconfirm } from "kts-xui"
|
|
4
|
+
import React from "react"
|
|
5
|
+
|
|
6
|
+
/** 清空重填 */
|
|
7
|
+
export default () => {
|
|
8
|
+
|
|
9
|
+
const controller = Invoice.useInvoiceController();
|
|
10
|
+
|
|
11
|
+
const model = controller.useMemo(s => s.model, []);
|
|
12
|
+
|
|
13
|
+
const confirm = React.useCallback(() => {
|
|
14
|
+
controller.run(async s => {
|
|
15
|
+
s.passengerListState.goodsList = [];
|
|
16
|
+
s.passengerListState.goodsMap = new Map();
|
|
17
|
+
s.passengerListState.selectedGoodIndex = [];
|
|
18
|
+
})
|
|
19
|
+
}, [controller])
|
|
20
|
+
|
|
21
|
+
const button = React.useMemo(() => {
|
|
22
|
+
if (model === 'readOnly') return <></>;
|
|
23
|
+
if (model === 'prefab') return <></>;
|
|
24
|
+
return (
|
|
25
|
+
<Popconfirm
|
|
26
|
+
title="将要清空所有项目信息,是否继续"
|
|
27
|
+
onConfirm={confirm}
|
|
28
|
+
okText="确定"
|
|
29
|
+
cancelText="取消"
|
|
30
|
+
>
|
|
31
|
+
<Button size='small' >清空重填</Button>
|
|
32
|
+
</Popconfirm>
|
|
33
|
+
)
|
|
34
|
+
}, [model, confirm])
|
|
35
|
+
|
|
36
|
+
return { button }
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.kts-invoice-operate-goods-list-itemName-drag-container-u {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
&::after {
|
|
5
|
+
content : " ";
|
|
6
|
+
width : 100%;
|
|
7
|
+
height : 2px;
|
|
8
|
+
background: #0074ff;
|
|
9
|
+
position : absolute;
|
|
10
|
+
left : 0;
|
|
11
|
+
top : 0;
|
|
12
|
+
z-index : 9999;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.kts-invoice-operate-goods-list-itemName-drag-container-d {
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
&::after {
|
|
20
|
+
content : " ";
|
|
21
|
+
width : 100%;
|
|
22
|
+
height : 2px;
|
|
23
|
+
background: #0074ff;
|
|
24
|
+
position : absolute;
|
|
25
|
+
left : 0;
|
|
26
|
+
bottom : 0;
|
|
27
|
+
z-index : 9999;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Invoice from '../../../../..';
|
|
3
|
+
import { LineAttributeType } from '../../../../../InvoiceController'
|
|
4
|
+
import classnames from 'classnames'
|
|
5
|
+
import './index.less'
|
|
6
|
+
|
|
7
|
+
export default function TableRow(props: any) {
|
|
8
|
+
|
|
9
|
+
const rowKey = props['data-row-key']
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
return <tr
|
|
15
|
+
{...props}
|
|
16
|
+
className={classnames(
|
|
17
|
+
props.className,
|
|
18
|
+
)}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.kts-invoice-operate-goods-table-virtual {
|
|
2
|
+
|
|
3
|
+
.ktsAntX-table-body {
|
|
4
|
+
height: 280px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.ktsAntX-table.ktsAntX-table-bordered>.ktsAntX-table-container>.ktsAntX-table-header>table>thead>tr>th {
|
|
8
|
+
padding : 0 10px;
|
|
9
|
+
height : 32px;
|
|
10
|
+
background: #f4f4f4;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ktsAntX-table.ktsAntX-table-bordered>.ktsAntX-table-container>.ktsAntX-table-body>table>tbody>tr>td {
|
|
14
|
+
padding: 0;
|
|
15
|
+
height : 32px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ktsAntX-table .ktsAntX-table-body {
|
|
19
|
+
position: relative;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ktsAntX-table .ktsAntX-table-body>table {
|
|
23
|
+
position: absolute;
|
|
24
|
+
left : 0;
|
|
25
|
+
top : 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ktsAntX-table .ktsAntX-table-tbody {
|
|
29
|
+
position: relative;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ktsAntX-checkbox-wrapper .ktsAntX-checkbox-inner {
|
|
33
|
+
width : 16px;
|
|
34
|
+
height : 16px;
|
|
35
|
+
border : 1px solid #d9d9d9;
|
|
36
|
+
border-radius: 2px;
|
|
37
|
+
top : 1px;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TableManual, TableProps } from "kts-xui";
|
|
4
|
+
import { Table } from 'kts-components-antd-x4-v4';
|
|
5
|
+
import './index.less';
|
|
6
|
+
|
|
7
|
+
export default function <T extends object = any>(props: TableProps<T>) {
|
|
8
|
+
|
|
9
|
+
const [self, setSelf] = React.useState<HTMLSpanElement | null>(null);
|
|
10
|
+
|
|
11
|
+
const tableBody = React.useMemo(() => {
|
|
12
|
+
if (!self) return;
|
|
13
|
+
return self.querySelector('.ktsAntX-table-body') as HTMLDivElement;
|
|
14
|
+
}, [self]);
|
|
15
|
+
|
|
16
|
+
/** 显示指针 */
|
|
17
|
+
const [pointer, setPointer] = React.useState(0);
|
|
18
|
+
|
|
19
|
+
/** 行高 */
|
|
20
|
+
const rowHeight = React.useMemo(() => {
|
|
21
|
+
if (!self) return 50;
|
|
22
|
+
|
|
23
|
+
const td = self.querySelector('.ktsAntX-table-tbody .ktsAntX-table-row');
|
|
24
|
+
if (!td) return 50;
|
|
25
|
+
|
|
26
|
+
return td.clientHeight;
|
|
27
|
+
}, [self, props.dataSource]);
|
|
28
|
+
|
|
29
|
+
/** 间隔容器 */
|
|
30
|
+
const placeholder = React.useMemo(() => {
|
|
31
|
+
if (!self || !tableBody) return;
|
|
32
|
+
let placeholder = tableBody.querySelector('.table-virtual-placeholder') as HTMLDivElement;
|
|
33
|
+
if (!placeholder) {
|
|
34
|
+
placeholder = document.createElement('div');
|
|
35
|
+
placeholder.className = 'table-virtual-placeholder';
|
|
36
|
+
tableBody.appendChild(placeholder);
|
|
37
|
+
}
|
|
38
|
+
return placeholder;
|
|
39
|
+
}, [self, tableBody]);
|
|
40
|
+
|
|
41
|
+
// 设置占位dom的搞
|
|
42
|
+
const placeholderHeight = React.useMemo(() => {
|
|
43
|
+
if (!self || !rowHeight || !props.dataSource || !placeholder) return;
|
|
44
|
+
const placeholderHeight = rowHeight * props.dataSource.length;
|
|
45
|
+
placeholder.style.height = `${placeholderHeight}px`;
|
|
46
|
+
return placeholderHeight;
|
|
47
|
+
}, [self, rowHeight, props.dataSource, placeholder]);
|
|
48
|
+
|
|
49
|
+
/** 可以容纳的行数 */
|
|
50
|
+
const rowSize = React.useMemo(() => {
|
|
51
|
+
if (!tableBody! || !rowHeight) return 0;
|
|
52
|
+
return Math.ceil(tableBody.clientHeight / rowHeight);
|
|
53
|
+
}, [tableBody, rowHeight, placeholderHeight]);
|
|
54
|
+
|
|
55
|
+
// 计算渲染的行
|
|
56
|
+
const dataSource = React.useMemo(() => {
|
|
57
|
+
if (!props.dataSource) return [];
|
|
58
|
+
if (props.dataSource.length < 10) return props.dataSource;
|
|
59
|
+
|
|
60
|
+
if (!rowSize) return [props.dataSource[0]];
|
|
61
|
+
return props.dataSource?.slice(pointer, pointer + 2 * rowSize);
|
|
62
|
+
}, [props.dataSource, pointer, rowSize]);
|
|
63
|
+
|
|
64
|
+
// 监听滚动
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (!self || !placeholder || !props.dataSource || !rowHeight || !tableBody || props.dataSource.length < 10)
|
|
67
|
+
return;
|
|
68
|
+
|
|
69
|
+
const onScroll = () => {
|
|
70
|
+
if (!props.dataSource || !tableBody) return;
|
|
71
|
+
setPointer(Math.floor((props.dataSource.length - rowSize) * (tableBody.scrollTop / (placeholder.clientHeight - tableBody.clientHeight))));
|
|
72
|
+
};
|
|
73
|
+
onScroll();
|
|
74
|
+
|
|
75
|
+
tableBody.addEventListener('scroll', onScroll);
|
|
76
|
+
return () => {
|
|
77
|
+
tableBody.removeEventListener('scroll', onScroll);
|
|
78
|
+
};
|
|
79
|
+
}, [self, placeholder, props.dataSource, rowHeight, rowSize]);
|
|
80
|
+
|
|
81
|
+
// 移动列表
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
if (!self) return;
|
|
84
|
+
|
|
85
|
+
const table = self.querySelector('.ktsAntX-table .ktsAntX-table-body>table') as HTMLDivElement;
|
|
86
|
+
if (!table) return;
|
|
87
|
+
|
|
88
|
+
table.style.top = `${pointer * rowHeight}px`;
|
|
89
|
+
}, [pointer, self, rowHeight]);
|
|
90
|
+
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (!self) return;
|
|
93
|
+
const cont = self.querySelector('.kts-invoice-operate-goods-table-virtual .ktsAntX-table-body');
|
|
94
|
+
if (!cont) return;
|
|
95
|
+
|
|
96
|
+
cont.scrollTop = 0;
|
|
97
|
+
}, [props.dataSource?.length])
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<span className="kts-invoice-operate-goods-table-virtual" ref={(e) => { setSelf(e) }} >
|
|
101
|
+
<TableManual
|
|
102
|
+
{...props}
|
|
103
|
+
dataSource={dataSource}
|
|
104
|
+
// 新版本Table会有输入框无法连续输入的问题,先兼容老版本
|
|
105
|
+
tableComponent={Table as any}
|
|
106
|
+
/>
|
|
107
|
+
</span>
|
|
108
|
+
)
|
|
109
|
+
}
|