kts-component-invoice-operate 3.2.60 → 3.2.61
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/README.md +4 -1
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.d.ts +2 -0
- package/dist/index.esm.js +147 -114
- package/dist/index.js +147 -114
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +3 -0
- package/src/Invoice/_test/endowCode/index.tsx +1 -1
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +24 -21
- package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +16 -1
- package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +12 -1
- package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +56 -37
- package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +16 -1
- package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +14 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.kts-invoice-operate-goods-list-itemName-drag-container {
|
|
1
|
+
.kts-invoice-operate-goods-list-itemName-drag-container-u {
|
|
2
2
|
position: relative;
|
|
3
3
|
|
|
4
4
|
&::after {
|
|
@@ -11,4 +11,19 @@
|
|
|
11
11
|
top : 0;
|
|
12
12
|
z-index : 9999;
|
|
13
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
|
+
}
|
|
14
29
|
}
|
|
@@ -12,8 +12,13 @@ export default function TableRow(props: any) {
|
|
|
12
12
|
|
|
13
13
|
const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, [])
|
|
14
14
|
|
|
15
|
+
/** 当前拖动中的货品索引 */
|
|
15
16
|
const current = controller.useMemo(s => s.goodsListState.drag.current, [])
|
|
16
17
|
|
|
18
|
+
/** 当前拖动中的货品索引 */
|
|
19
|
+
const site = controller.useMemo(s => s.goodsListState.drag.site, [])
|
|
20
|
+
|
|
21
|
+
/** 准备插入的货物索引 */
|
|
17
22
|
const container = controller.useMemo(s => s.goodsListState.drag.container, [])
|
|
18
23
|
|
|
19
24
|
const good = React.useMemo(() => goodsMap?.get(rowKey), [rowKey, goodsMap])
|
|
@@ -40,7 +45,13 @@ export default function TableRow(props: any) {
|
|
|
40
45
|
) : (
|
|
41
46
|
<tr
|
|
42
47
|
{...props}
|
|
43
|
-
className={classnames(
|
|
48
|
+
className={classnames(
|
|
49
|
+
props.className,
|
|
50
|
+
discount,
|
|
51
|
+
(rowKey === container && current)
|
|
52
|
+
? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site
|
|
53
|
+
: undefined
|
|
54
|
+
)}
|
|
44
55
|
/>
|
|
45
56
|
)
|
|
46
57
|
)
|
|
@@ -7,6 +7,7 @@ import { IGood, Invoice } from '../../../../../../../..';
|
|
|
7
7
|
import mounting from "../../../../../../../tools/mounting";
|
|
8
8
|
import { LineAttributeType } from "../../../../../../../InvoiceController";
|
|
9
9
|
import './index.less';
|
|
10
|
+
import { Popover } from "kts-xui";
|
|
10
11
|
|
|
11
12
|
export interface IDragProps {
|
|
12
13
|
record: IGood
|
|
@@ -16,6 +17,8 @@ export default function Drag(props: IDragProps) {
|
|
|
16
17
|
|
|
17
18
|
const { record } = props;
|
|
18
19
|
|
|
20
|
+
const [open, setOpen] = React.useState(false)
|
|
21
|
+
|
|
19
22
|
const controller = Invoice.useInvoiceController();
|
|
20
23
|
|
|
21
24
|
const editGood = controller.useMemo(s => s.goodsListState.editGood, []);
|
|
@@ -23,7 +26,7 @@ export default function Drag(props: IDragProps) {
|
|
|
23
26
|
const disabled = React.useMemo(() => !!editGood, [editGood]);
|
|
24
27
|
|
|
25
28
|
const onMouseDown = React.useCallback(() => {
|
|
26
|
-
if (!controller || !record) return;
|
|
29
|
+
if (!controller || !record || disabled) return;
|
|
27
30
|
controller.run(async s => s.goodsListState.drag.current = record.$index);
|
|
28
31
|
|
|
29
32
|
const rowList = window.document.querySelectorAll<HTMLDivElement>('.kts-invoice-operate-goods-list-digtal');
|
|
@@ -31,32 +34,30 @@ export default function Drag(props: IDragProps) {
|
|
|
31
34
|
const currentGood = controller.state.goodsListState.goodsList.filter(e => e.$index === record.$index)[0];
|
|
32
35
|
mounting(<DragDiv {...currentGood} />)
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function onMouseover(e: MouseEvent) {
|
|
37
|
+
rowList.forEach(e => { e.addEventListener('mousemove', onMousemove) });
|
|
38
|
+
function onMousemove(e: MouseEvent) {
|
|
37
39
|
controller.run(async s => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
+
const rowDom = getRow(e.target);
|
|
41
|
+
const container = s.goodsListState.drag.container = rowDom?.dataset?.rowKey;
|
|
42
|
+
|
|
43
|
+
/** 准备插入的货物 */
|
|
44
|
+
const row = s.goodsListState.goodsMap.get(container); if (!row) return;
|
|
40
45
|
|
|
41
46
|
// 不可以插入自己
|
|
42
47
|
if (container === s.goodsListState.drag.current) {
|
|
43
|
-
s.goodsListState.drag.container = undefined;
|
|
44
|
-
return;
|
|
48
|
+
return s.goodsListState.drag.container = undefined;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
if (!currentGood) return;
|
|
49
|
-
|
|
50
|
-
const row = s.goodsListState.goodsMap.get(container);
|
|
51
|
-
if (!row) return;
|
|
51
|
+
/** 当前拖动中的货品 */
|
|
52
|
+
const currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current); if (!currentGood) return;
|
|
52
53
|
|
|
53
54
|
// 折扣行 不可以插入 自己的被折扣行
|
|
54
55
|
if (currentGood.lineAttribute === LineAttributeType.折扣行) {
|
|
55
56
|
const currentIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(currentGood.$index)
|
|
56
57
|
const containerIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(row.$index)
|
|
57
58
|
if (currentIndex - 1 === containerIndex) {
|
|
58
|
-
s.goodsListState.drag.container = undefined;
|
|
59
|
-
|
|
59
|
+
return s.goodsListState.drag.container = undefined;
|
|
60
|
+
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -65,8 +66,7 @@ export default function Drag(props: IDragProps) {
|
|
|
65
66
|
const currentIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(currentGood.$index)
|
|
66
67
|
const containerIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(row.$index)
|
|
67
68
|
if (currentIndex + 1 === containerIndex) {
|
|
68
|
-
s.goodsListState.drag.container = undefined;
|
|
69
|
-
return;
|
|
69
|
+
return s.goodsListState.drag.container = undefined;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -74,8 +74,15 @@ export default function Drag(props: IDragProps) {
|
|
|
74
74
|
if (row.lineAttribute === LineAttributeType.折扣行) {
|
|
75
75
|
const t = s.goodsListState.goodsList.map(e => e.$index).indexOf(container) - 1;
|
|
76
76
|
s.goodsListState.drag.container = s.goodsListState.goodsList[t].$index;
|
|
77
|
+
s.goodsListState.drag.site = 'u'
|
|
78
|
+
} else if (row.lineAttribute === LineAttributeType.被折扣行) {
|
|
79
|
+
s.goodsListState.drag.site = 'd'
|
|
80
|
+
} else {
|
|
81
|
+
const rect = rowDom.getBoundingClientRect();
|
|
82
|
+
const mouseY = e.clientY - rect.top;
|
|
83
|
+
s.goodsListState.drag.site = mouseY > 25 ? 'd' : 'u';
|
|
77
84
|
}
|
|
78
|
-
})
|
|
85
|
+
})
|
|
79
86
|
|
|
80
87
|
const getRow = (t: any): any => {
|
|
81
88
|
try {
|
|
@@ -85,7 +92,7 @@ export default function Drag(props: IDragProps) {
|
|
|
85
92
|
return getRow(t.parentNode);
|
|
86
93
|
}
|
|
87
94
|
} catch (error) {
|
|
88
|
-
return undefined
|
|
95
|
+
return undefined;
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
}
|
|
@@ -96,7 +103,7 @@ export default function Drag(props: IDragProps) {
|
|
|
96
103
|
insert();
|
|
97
104
|
controller.run(async s => s.goodsListState.drag.current = undefined);
|
|
98
105
|
window.removeEventListener('mouseup', onMouseup);
|
|
99
|
-
rowList.forEach(e => { e.removeEventListener('
|
|
106
|
+
rowList.forEach(e => { e.removeEventListener('mousemove', onMousemove) });
|
|
100
107
|
// window.document.body.removeChild(rowDiv);
|
|
101
108
|
}
|
|
102
109
|
|
|
@@ -104,7 +111,7 @@ export default function Drag(props: IDragProps) {
|
|
|
104
111
|
function insert() {
|
|
105
112
|
mounting(<></>);
|
|
106
113
|
controller.run(async s => {
|
|
107
|
-
const { container, current } = s.goodsListState.drag;
|
|
114
|
+
const { container, current, site } = s.goodsListState.drag;
|
|
108
115
|
if (!container || !current) return;
|
|
109
116
|
if (container !== current) {
|
|
110
117
|
const goodsList = s.goodsListState.goodsList;
|
|
@@ -122,7 +129,7 @@ export default function Drag(props: IDragProps) {
|
|
|
122
129
|
|
|
123
130
|
(() => {
|
|
124
131
|
const g = s.goodsListState.goodsList.filter(e => moveGoods.indexOf(e.$index) < 0);
|
|
125
|
-
const t = g.map(e => e.$index).indexOf(container);
|
|
132
|
+
const t = site === 'u' ? g.map(e => e.$index).indexOf(container) : g.map(e => e.$index).indexOf(container) + 1;
|
|
126
133
|
const m = moveGoods.map(e => goodsMap.get(e)).filter(e => !!e) as IGood[];
|
|
127
134
|
s.goodsListState.goodsList = (g.splice.apply(g, [t, 0, ...m]), g);
|
|
128
135
|
})()
|
|
@@ -135,20 +142,32 @@ export default function Drag(props: IDragProps) {
|
|
|
135
142
|
s.goodsListState.drag.current = undefined;
|
|
136
143
|
})
|
|
137
144
|
}
|
|
138
|
-
}, [controller, record])
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
}, [controller, record, disabled])
|
|
146
|
+
|
|
147
|
+
const renderButton = React.useMemo(() => {
|
|
148
|
+
return (
|
|
149
|
+
<Button
|
|
150
|
+
type='link'
|
|
151
|
+
style={{ padding: 0 }}
|
|
152
|
+
onMouseDown={onMouseDown}
|
|
153
|
+
onClick={e => { e.stopPropagation() }}
|
|
154
|
+
className={"kts-invoice-operate-goods-list-itemName-drag"}
|
|
155
|
+
onMouseOver={controller.saveEditGood}
|
|
156
|
+
>
|
|
157
|
+
<Icon component={I001Svg} />
|
|
158
|
+
</Button>
|
|
159
|
+
)
|
|
160
|
+
}, [onMouseDown, controller])
|
|
161
|
+
|
|
162
|
+
if (disabled) {
|
|
163
|
+
return (
|
|
164
|
+
<Popover content={'您还有未编辑完成的商品'} trigger='focus' >
|
|
165
|
+
{renderButton}
|
|
166
|
+
</Popover>
|
|
167
|
+
)
|
|
168
|
+
} else {
|
|
169
|
+
return renderButton;
|
|
170
|
+
}
|
|
152
171
|
}
|
|
153
172
|
|
|
154
173
|
function DragDiv(props: IGood) {
|
|
@@ -169,7 +188,7 @@ function DragDiv(props: IGood) {
|
|
|
169
188
|
// 移动事件
|
|
170
189
|
React.useEffect(() => {
|
|
171
190
|
|
|
172
|
-
function onMousemove(e: MouseEvent) { setY(e.clientY -
|
|
191
|
+
function onMousemove(e: MouseEvent) { setY(e.clientY - 15) };
|
|
173
192
|
|
|
174
193
|
window.addEventListener('mousemove', onMousemove);
|
|
175
194
|
return () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.kts-invoice-operate-goods-list-itemName-drag-container {
|
|
1
|
+
.kts-invoice-operate-goods-list-itemName-drag-container-u {
|
|
2
2
|
position: relative;
|
|
3
3
|
|
|
4
4
|
&::after {
|
|
@@ -11,4 +11,19 @@
|
|
|
11
11
|
top : 0;
|
|
12
12
|
z-index : 9999;
|
|
13
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
|
+
}
|
|
14
29
|
}
|
|
@@ -12,6 +12,9 @@ export default function TableRow(props: any) {
|
|
|
12
12
|
|
|
13
13
|
const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, [])
|
|
14
14
|
|
|
15
|
+
/** 当前拖动中的货品索引 */
|
|
16
|
+
const site = controller.useMemo(s => s.goodsListState.drag.site, [])
|
|
17
|
+
|
|
15
18
|
const current = controller.useMemo(s => s.goodsListState.drag.current, [])
|
|
16
19
|
|
|
17
20
|
const container = controller.useMemo(s => s.goodsListState.drag.container, [])
|
|
@@ -36,6 +39,16 @@ export default function TableRow(props: any) {
|
|
|
36
39
|
<div style={{ height: 0.5, width: '100%', background: '#E6E6E6', position: 'absolute', bottom: 0 }} />
|
|
37
40
|
</tr>
|
|
38
41
|
) : (
|
|
39
|
-
<tr {...props} className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')} />
|
|
42
|
+
// <tr {...props} className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')} />
|
|
43
|
+
<tr
|
|
44
|
+
{...props}
|
|
45
|
+
className={classnames(
|
|
46
|
+
props.className,
|
|
47
|
+
discount,
|
|
48
|
+
(rowKey === container && current)
|
|
49
|
+
? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site
|
|
50
|
+
: undefined
|
|
51
|
+
)}
|
|
52
|
+
/>
|
|
40
53
|
)
|
|
41
54
|
}
|