kts-component-invoice-operate 3.2.3 → 3.2.5

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.
Files changed (67) hide show
  1. package/dist/Invoice/{ui/digtal/GoodsList.o/ui/AddRowButton → Invoice-digtal/_test/prefab}/index.d.ts +1 -0
  2. package/dist/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.d.ts +1 -1
  3. package/dist/index.esm.js +29 -8
  4. package/dist/index.js +29 -8
  5. package/docs-dist/404.html +33 -0
  6. package/docs-dist/index.html +33 -0
  7. package/docs-dist/static/add.a70623b4.svg +12 -0
  8. package/docs-dist/static/arrowDown.a1cbf0d8.svg +3 -0
  9. package/docs-dist/static/arrowUp.4c482054.svg +3 -0
  10. package/docs-dist/static/auto.a6cd905c.svg +1 -0
  11. package/docs-dist/static/fork.5431267d.svg +12 -0
  12. package/docs-dist/static/magnifier.2b26be6e.svg +1 -0
  13. package/docs-dist/static/plus.4fd1af30.svg +12 -0
  14. package/docs-dist/umi.css +20 -0
  15. package/docs-dist/umi.js +1 -0
  16. package/package.json +1 -1
  17. package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -0
  18. package/src/Invoice/Invoice-digtal/index.md +3 -0
  19. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +12 -2
  20. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +1 -0
  21. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +1 -0
  22. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +1 -0
  23. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +5 -1
  24. package/src/InvoiceTypeModal/dist/index.js +92 -0
  25. package/src/InvoiceTypeModal/index.tsx +8 -2
  26. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/autoFillFn/index.d.ts +0 -35
  27. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/index.d.ts +0 -3
  28. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.d.ts +0 -7
  29. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowEditButton/index.d.ts +0 -6
  30. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.d.ts +0 -4
  31. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.d.ts +0 -7
  32. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.d.ts +0 -7
  33. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +0 -7
  34. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.d.ts +0 -7
  35. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowSaveButton/index.d.ts +0 -6
  36. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/TitleText/index.d.ts +0 -8
  37. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useDeduction/index.d.ts +0 -8
  38. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useOnRow/index.d.ts +0 -8
  39. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useRowSelection/index.d.ts +0 -8
  40. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useWindowClick/index.d.ts +0 -8
  41. package/dist/Invoice/ui/digtal/GoodsList.o/index.d.ts +0 -20
  42. package/dist/Invoice/ui/digtal/GoodsList.o/ui/TableRow/index.d.ts +0 -2
  43. package/dist/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.d.ts +0 -4
  44. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/autoFillFn/index.ts +0 -520
  45. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/index.tsx +0 -624
  46. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.less +0 -10
  47. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.tsx +0 -19
  48. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowEditButton/index.tsx +0 -30
  49. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +0 -43
  50. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +0 -76
  51. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +0 -41
  52. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +0 -34
  53. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.less +0 -13
  54. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.tsx +0 -98
  55. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowSaveButton/index.tsx +0 -14
  56. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/TitleText/index.tsx +0 -20
  57. package/src/Invoice/ui/digtal/GoodsList.o/hook/useDeduction/index.tsx +0 -24
  58. package/src/Invoice/ui/digtal/GoodsList.o/hook/useOnRow/index.tsx +0 -39
  59. package/src/Invoice/ui/digtal/GoodsList.o/hook/useRowSelection/index.tsx +0 -112
  60. package/src/Invoice/ui/digtal/GoodsList.o/hook/useWindowClick/index.tsx +0 -23
  61. package/src/Invoice/ui/digtal/GoodsList.o/index.less +0 -7
  62. package/src/Invoice/ui/digtal/GoodsList.o/index.tsx +0 -132
  63. package/src/Invoice/ui/digtal/GoodsList.o/ui/AddRowButton/index.tsx +0 -66
  64. package/src/Invoice/ui/digtal/GoodsList.o/ui/TableRow/index.tsx +0 -28
  65. package/src/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.less +0 -43
  66. package/src/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.tsx +0 -109
  67. /package/{src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/spot.svg → docs-dist/static/spot.42e620e1.svg} +0 -0
@@ -1,132 +0,0 @@
1
-
2
- import React from 'react';
3
- import { Form } from 'kts-components-antd-x3';
4
- import { decorator } from 'grey-react-box';
5
- import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
6
- import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
7
- import { Switch, Button, Input } from 'kts-xui';
8
- import TableVirtual from './ui/TableVirtual';
9
- import TableRow from './ui/TableRow';
10
- import AddRowButton from './ui/AddRowButton';
11
- import useColumns from './hook/useColumns';
12
- import useOnRow from './hook/useOnRow';
13
- import useDeduction from './hook/useDeduction';
14
- import useWindowClick from './hook/useWindowClick';
15
- import useRowSelection from './hook/useRowSelection';
16
- import Invoice from '../../..';
17
-
18
- import './index.less';
19
-
20
- export interface IGoodsListProps {
21
-
22
- /** 扩展部分 */
23
- menuExpansion?: React.ReactNode;
24
-
25
- /** 产品最大数 */
26
- goodMax?: number;
27
-
28
- /** 扣除额 */
29
- deduction?: number;
30
-
31
- /** 是否能添加折扣行 */
32
- isAddDiscount?: boolean;
33
-
34
- /** 是否可以切换(含税/不含税)状态 */
35
- isSwitchTax?: boolean;
36
- }
37
-
38
- /**
39
- * 货物列表
40
- */
41
- export default class GoodsList extends React.Component<IGoodsListProps>{
42
- render() {
43
- return <Main {...this.props} />
44
- }
45
- }
46
-
47
- const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Form.create())(props => {
48
-
49
- const controller = Invoice.useInvoiceController();
50
-
51
- const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
52
-
53
- const isprefab = controller.useMemo(s => s.model === 'prefab', []);
54
-
55
- const dataSource = controller.useMemo(s => s.goodsListState.goodsList, [])
56
-
57
- const searchValue = controller.useMemo(s => s.goodsListState.searchValue, [])
58
-
59
- const isTaxIncluded = controller.useMemo(s => s.goodsListState.isTaxIncluded, [])
60
-
61
- const dataSourceSearch = React.useMemo(() => controller.getGoodsSearch(dataSource, searchValue, isTaxIncluded), [dataSource, searchValue, controller, isTaxIncluded])
62
-
63
- const onRow = useOnRow();
64
-
65
- useDeduction(controller, props.deduction);
66
- useWindowClick(controller);
67
-
68
- /** 清空自动赋码缓存 */
69
- React.useEffect(() => {
70
- controller.run(async s => { s.goodsListState.endowCode.cache = {} });
71
- }, [controller])
72
-
73
- /** 注册 from 对象 */
74
- React.useEffect(() => {
75
- controller.pipeline<WrappedFormUtils>(async (s, form) => { s.goodsListState = { ...s.goodsListState, form } })(props.form);
76
- }, [controller, props.form]);
77
-
78
- // 跟新 货物
79
- React.useEffect(() => {
80
- controller.run(async (s) => {
81
- s.goodsListState.goodsMap = new Map();
82
- goodsList.forEach((e) => { s.goodsListState.goodsMap.set(e.$index, e); });
83
- });
84
- }, [controller, goodsList]);
85
-
86
- /** props 产品最大数 更新 */
87
- React.useEffect(() => {
88
- controller.pipeline(async s => { s.goodsListState.goodMax = props.goodMax })()
89
- }, [controller, props.goodMax])
90
-
91
- /** props 是否能添加折扣行 更新 */
92
- React.useEffect(() => {
93
- controller.pipeline(async s => { s.goodsListState.isAddDiscount = props.isAddDiscount })()
94
- }, [controller, props.goodMax])
95
-
96
- /** props 是否可以切换(含税/不含税)状态 更新 */
97
- React.useEffect(() => {
98
- controller.pipeline(async s => { s.goodsListState.isSwitchTax = props.isSwitchTax })()
99
- }, [controller, props.isSwitchTax])
100
-
101
- return (
102
- <>
103
- <div className='kts-invoice-operate-goods-list-menu' >
104
- <AddRowButton />
105
- <Button size='small'>删除</Button>
106
- <Button size='small'>增加折扣</Button>
107
- <Switch title='含税' />
108
- <Input placeholder='请输入项目名称、规格型号、金额(含税)搜索' style={{ width: 400 }} />
109
- <div style={{ flex: 1 }} />
110
- <Button size='small' >重选发票类型</Button>
111
- <Button size='small'>清空重填</Button>
112
- </div>
113
- <div className='kts-invoice-operate-goods-list-table' >
114
- <TableVirtual
115
- size="small"
116
- rowKey="$index"
117
- scroll={{ y: 280 }}
118
- pagination={false}
119
- dataSource={dataSourceSearch}
120
- components={{ body: { row: TableRow } }}
121
- rowSelection={useRowSelection()}
122
- columns={useColumns(props.form)}
123
- onRow={record => ({
124
- onClick: () => {
125
- onRow.onClick(record);
126
- },
127
- })}
128
- />
129
- </div>
130
- </>
131
- )
132
- })
@@ -1,66 +0,0 @@
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.goodsListState.goodsList.length, []);
15
-
16
- /** 搜索条件 */
17
- const searchValue = controller.useMemo(s => s.goodsListState.searchValue, []);
18
-
19
- /** 搜索条件 */
20
- const isAddRow = controller.useMemo(s => s.goodsListState.isAddRow, []);
21
-
22
- /** 产品最大数 */
23
- const goodMax = controller.useMemo(s => s.goodsListState.goodMax, []);
24
-
25
- /** 按钮是否禁用 */
26
- const disabled = React.useMemo(() => typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue, [goodMax, goodsNum, searchValue])
27
-
28
- const onClick = React.useCallback(async () => {
29
- await addGood(controller);
30
- await rollBottom(controller, rootElement);
31
- }, [controller, rootElement]);
32
-
33
- if (isAddRow === false) return <></>;
34
- if (model === 'prefab') return <></>;
35
- if (model === 'readOnly') return <></>;
36
-
37
- return (
38
- <Button onClick={onClick} disabled={disabled} size='small'>
39
- 添加行
40
- </Button>
41
- );
42
- };
43
-
44
- /** 添加一个空货物 */
45
- async function addGood(controller: InvoiceController) {
46
- await controller.saveEditGood();
47
- await controller.wait();
48
- await controller.run(async (s) => {
49
- if (s.goodsListState.editGood) {
50
- message.error({
51
- content: '你正在编辑一个货物',
52
- key: '你正在编辑一个货物',
53
- });
54
- return;
55
- }
56
- s.goodsListState.editGood = await controller.addGood({ taxRate: s.goodsListState.defaultRate, lineAttribute: LineAttributeType.正常 });
57
- });
58
- }
59
-
60
- /** 货物列表,滚动到底部 */
61
- async function rollBottom(controller: InvoiceController, rootElement: HTMLDivElement | null | undefined) {
62
- await controller.wait();
63
- const cont = rootElement?.querySelector('.ktsAntX-table-body');
64
- if (!cont) return;
65
- cont.scrollTop = cont.scrollHeight;
66
- }
@@ -1,28 +0,0 @@
1
- import React from "react";
2
- import Invoice from '../../../../..';
3
- import { LineAttributeType } from '../../../../../InvoiceController'
4
- import classnames from 'classnames'
5
-
6
- export default function TableRow(props: any) {
7
-
8
- const controller = Invoice.useInvoiceController();
9
-
10
- const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, [])
11
-
12
- const discount = React.useMemo(() => {
13
- const i = goodsMap.get(props['data-row-key']);
14
- if (!i) return undefined;
15
-
16
- if (i.lineAttribute === LineAttributeType.折扣行) {
17
- return 'kts-invoice-operate-goods-be-discount'
18
- } else if (i.lineAttribute === LineAttributeType.被折扣行) {
19
- return 'kts-invoice-operate-goods-discount'
20
- } else {
21
- return undefined;
22
- }
23
- }, [props['data-row-key'], goodsMap])
24
-
25
- return (
26
- <tr {...props} className={classnames(props.className, discount)} />
27
- )
28
- }
@@ -1,43 +0,0 @@
1
- .kts-invoice-operate-goods-table-virtual-digtal {
2
-
3
- .ktsAntX-table-body {
4
- height: 280px;
5
- }
6
-
7
- .ktsAntX-table .ktsAntX-table-thead>tr>th {
8
- color: #9F603D;
9
- }
10
-
11
- .ktsAntX-table.ktsAntX-table-bordered>.ktsAntX-table-container>.ktsAntX-table-header>table>thead>tr>th {
12
- padding : 0 10px;
13
- height : 32px;
14
- background: #f4f4f4;
15
- }
16
-
17
- .ktsAntX-table.ktsAntX-table-bordered>.ktsAntX-table-container>.ktsAntX-table-body>table>tbody>tr>td {
18
- padding: 0;
19
- height : 32px;
20
- }
21
-
22
- .ktsAntX-table .ktsAntX-table-body {
23
- position: relative;
24
- }
25
-
26
- .ktsAntX-table .ktsAntX-table-body>table {
27
- position: absolute;
28
- left : 0;
29
- top : 0;
30
- }
31
-
32
- .ktsAntX-table .ktsAntX-table-tbody {
33
- position: relative;
34
- }
35
-
36
- .ktsAntX-checkbox-wrapper .ktsAntX-checkbox-inner {
37
- width : 16px;
38
- height : 16px;
39
- border : 1px solid #d9d9d9;
40
- border-radius: 2px;
41
- top : 1px;
42
- }
43
- }
@@ -1,109 +0,0 @@
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 33;
22
-
23
- const td = self.querySelector('.ktsAntX-table-tbody .ktsAntX-table-row');
24
- if (!td) return 33;
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)
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-digtal" ref={(e) => { setSelf(e) }} >
101
- <TableManual
102
- {...props}
103
- dataSource={dataSource}
104
- // 新版本Table会有输入框无法连续输入的问题,先兼容老版本
105
- tableComponent={Table as any}
106
- />
107
- </span>
108
- )
109
- }