@zgfe/modules-settings 2.0.0-zhongyuan.8 → 2.1.0-zhongyuan-set.1
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 +33 -33
- package/es/components/card/index.less +87 -87
- package/es/components/importMetaDialog/index.d.ts +13 -0
- package/es/components/importMetaDialog/index.js +217 -0
- package/es/components/importMetaDialog/styles/index.less +115 -0
- package/es/components/pageLoading/index.less +7 -7
- package/es/components/picCircleSelect/bak/index copy 2.tsx.bak +92 -92
- package/es/components/picCircleSelect/bak/index copy 3.tsx.bak +58 -58
- package/es/components/picCircleSelect/bak/index copy 4.tsx.bak +66 -66
- package/es/components/picCircleSelect/bak/index copy 5.tsx.bak +116 -116
- package/es/components/picCircleSelect/bak/index copy 6.tsx.bak +116 -116
- package/es/components/picCircleSelect/bak/index copy.tsx.bak +41 -41
- package/es/components/picCircleSelect/bak/index.tsx.bak +48 -48
- package/es/components/picCircleSelect/bak/index1.tsx.bak +46 -46
- package/es/components/picCircleSelect/bak/index2.tsx.bak +104 -104
- package/es/components/picCircleSelect/index.less +37 -37
- package/es/components/processCanvas/styles/customNode.less +149 -149
- package/es/components/processCanvas/styles/index.less +34 -34
- package/es/components/settingTabs/index.less +51 -51
- package/es/constants/api.d.ts +30 -0
- package/es/constants/api.js +43 -1
- package/es/constants/icons/demo.css +539 -539
- package/es/constants/icons/demo_index.html +9871 -9871
- package/es/constants/icons/iconfont.css +1699 -1699
- package/es/constants/icons/iconfont.json +2956 -2956
- package/es/global.d.ts +4 -4
- package/es/modules/appSettings/dataAccessFilter/index.js +2 -1
- package/es/modules/appSettings/dataAccessFilter/index.less +5 -5
- package/es/modules/appSettings/virtualSource/styles/index.less +28 -28
- package/es/modules/appSettings/virtualSource/styles/table.less +51 -51
- package/es/modules/companySetting/appList/index.less +126 -126
- package/es/modules/companySetting/application/applicationForm.d.ts +1 -0
- package/es/modules/companySetting/application/applicationForm.js +34 -4
- package/es/modules/companySetting/application/index.d.ts +13 -0
- package/es/modules/companySetting/application/index.js +276 -104
- package/es/modules/companySetting/application/index.less +144 -126
- package/es/modules/companySetting/business/index.less +92 -92
- package/es/modules/companySetting/cost/index.less +38 -38
- package/es/modules/companySetting/department/index.less +157 -157
- package/es/modules/companySetting/edit/styles/authConfig.less +3 -3
- package/es/modules/companySetting/edit/styles/authGroup.less +10 -10
- package/es/modules/companySetting/edit/styles/authModule.less +82 -82
- package/es/modules/companySetting/edit/styles/user.less +54 -54
- package/es/modules/companySetting/edit/styles/userGroup.less +44 -44
- package/es/modules/companySetting/index.js +37 -33
- package/es/modules/companySetting/index.less +90 -90
- package/es/modules/companySetting/info/index.less +42 -42
- package/es/modules/companySetting/mainPart/images/img2.svg +12 -12
- package/es/modules/companySetting/mainPart/index.less +239 -239
- package/es/modules/companySetting/operationLog/index.js +22 -5
- package/es/modules/companySetting/operationLog/index.less +33 -33
- package/es/modules/companySetting/role/index.less +296 -296
- package/es/modules/companySetting/role/setDataRangeDialog/index.less +37 -37
- package/es/modules/companySetting/style/common.less +79 -79
- package/es/modules/companySetting/style/reset.less +117 -117
- package/es/modules/companySetting/user/index.js +36 -24
- package/es/modules/companySetting/user/invite.js +47 -100
- package/es/modules/companySetting/virtualApp/styles/config.less +37 -37
- package/es/modules/companySetting/virtualApp/styles/index.less +21 -21
- package/es/modules/companySetting/virtualApp/styles/list.less +28 -28
- package/es/modules/companySetting/virtualApp/styles/sourceItem.less +33 -33
- package/es/modules/companySetting/virtualApp/styles/table.less +44 -44
- package/es/modules/companySetting/wechatBinding/index.less +58 -58
- package/es/modules/createDemand/constants.d.ts +15 -2
- package/es/modules/createDemand/constants.js +57 -4
- package/es/modules/createDemand/demo/selectPoint.js +1 -2
- package/es/modules/createDemand/index.d.ts +0 -1
- package/es/modules/createDemand/index.js +793 -179
- package/es/modules/createDemand/styles/index.less +403 -277
- package/es/modules/createDemand_bf/demo/index.js +0 -1
- package/es/modules/createDemand_bf/index.js +0 -1
- package/es/modules/createDemand_bf/styles/index.less +222 -222
- package/es/modules/createProcess/components/index.less +52 -52
- package/es/modules/createProcess/index.less +114 -114
- package/es/modules/createProcess/title/index.less +53 -53
- package/es/modules/dealDemand/demo/index.js +0 -1
- package/es/modules/dealDemand/demo/selectPoint.js +1 -1
- package/es/modules/dealDemand/index.js +0 -2
- package/es/modules/dealDemand/styles/index.less +265 -265
- package/es/modules/demandManage/index.js +174 -163
- package/es/modules/demandManage/styles/index.less +155 -210
- package/es/modules/getPassword/index.less +122 -122
- package/es/modules/messageList/index.d.ts +1 -1
- package/es/modules/messageList/index.js +6 -6
- package/es/modules/messageList/index.less +81 -81
- package/es/modules/personalSetting/demo/index.d.ts +3 -0
- package/es/modules/personalSetting/demo/index.js +12 -0
- package/es/modules/personalSetting/index.js +11 -1
- package/es/modules/personalSetting/info/index.js +23 -5
- package/es/modules/personalSetting/securityLog/index.less +11 -11
- package/es/modules/personalSetting/styles/unbinding.less +73 -73
- package/es/modules/pointMap/ImportModal/styles/index.less +91 -91
- package/es/modules/pointMap/createMetaDrawer.d.ts +5 -0
- package/es/modules/pointMap/createMetaDrawer.js +825 -0
- package/es/modules/pointMap/editTxt/index.less +55 -55
- package/es/modules/pointMap/pageInfo.js +401 -179
- package/es/modules/pointMap/record.d.ts +7 -0
- package/es/modules/pointMap/record.js +521 -0
- package/es/modules/pointMap/styles/index.less +165 -38
- package/es/modules/pointMap/styles/pageInfo.less +439 -244
- package/es/modules/pointMap/styles/tree.css +28 -9
- package/es/modules/pointMap/styles/tree.less +33 -8
- package/es/modules/pointMap/tree.js +232 -88
- package/es/modules/pointMap/types.d.ts +88 -0
- package/es/modules/pointMap/types.js +1 -0
- package/es/modules/systemSetting/Dictionary.d.ts +5 -2
- package/es/modules/systemSetting/Dictionary.js +54 -370
- package/es/modules/systemSetting/approvalmanage/approvalStrategy/index.less +14 -14
- package/es/modules/systemSetting/approvalmanage/index.less +5 -5
- package/es/modules/systemSetting/approvalmanage/processManage/index.less +39 -39
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/create.d.ts +9 -0
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/create.js +245 -0
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/css/index.less +48 -0
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/index.d.ts +4 -0
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/index.js +207 -0
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/type/index.d.ts +10 -0
- package/es/modules/systemSetting/dictionaryItem/dictionaryManagement/type/index.js +1 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/create.d.ts +10 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/create.js +124 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/css/index.less +32 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/index.d.ts +7 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/index.js +264 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/type/index.d.ts +9 -0
- package/es/modules/systemSetting/dictionaryItem/eventTagManagement/type/index.js +1 -0
- package/es/modules/systemSetting/document-setting/index.js +7 -6
- package/es/modules/systemSetting/index.js +16 -16
- package/es/modules/systemSetting/notice/configItem/index.less +21 -21
- package/es/modules/systemSetting/notice/edit/index.less +26 -26
- package/es/types/personal.d.ts +1 -0
- package/package.json +3 -3
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import { Spin } from 'antd';
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import './index.less';
|
|
4
|
-
export const classPrefix = 'setting-pic-circle-select';
|
|
5
|
-
const tools = [
|
|
6
|
-
{
|
|
7
|
-
name: 'arrow',
|
|
8
|
-
text: '添加箭头',
|
|
9
|
-
icon: 'icon-tianjiajiantou1',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: 'text',
|
|
13
|
-
text: '添加文字',
|
|
14
|
-
icon: 'icon-tianjiawenzi1',
|
|
15
|
-
},
|
|
16
|
-
];
|
|
17
|
-
const PageLoading: React.FC = () => {
|
|
18
|
-
const [size, setSize] = useState({ width: 500, height: 500 });
|
|
19
|
-
const [currentTool, setCurrentTool] = useState<string>();
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
init();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const init = () => {
|
|
26
|
-
loadImage('./images/zg_regist_top.png').then(() => {
|
|
27
|
-
this.initCanvas();
|
|
28
|
-
this.initCanvasEvent();
|
|
29
|
-
this.initEditors();
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const loadImage = (img: string) => {
|
|
34
|
-
return new Promise((resolve) => {
|
|
35
|
-
// if (utils.isImageBase64(img)) {
|
|
36
|
-
const imgEle = document.createElement('img');
|
|
37
|
-
imgEle.src = img;
|
|
38
|
-
imgEle.onload = () => {
|
|
39
|
-
// this.imgWidth = imgEle.width
|
|
40
|
-
// this.imgHeight = imgEle.height
|
|
41
|
-
// let scale = 1
|
|
42
|
-
// if (!this.primitiveSize && this.imgWidth > this.width) {
|
|
43
|
-
// scale = (this.width - 52) / this.imgWidth
|
|
44
|
-
// this.imgWidth = scale * this.imgWidth
|
|
45
|
-
// this.imgHeight = scale * this.imgHeight
|
|
46
|
-
// }
|
|
47
|
-
// this.imgObj = new fabric.Image(imgEle, {
|
|
48
|
-
// left: 0,
|
|
49
|
-
// top: 0,
|
|
50
|
-
// selectable: false,
|
|
51
|
-
// scaleX: scale,
|
|
52
|
-
// scaleY: scale
|
|
53
|
-
// })
|
|
54
|
-
resolve();
|
|
55
|
-
};
|
|
56
|
-
// } else if (utils.isURL(img)) {
|
|
57
|
-
// const that = this
|
|
58
|
-
// fabric.Image.fromURL(img, function(imgObj) {
|
|
59
|
-
// that.imgWidth = imgObj.width
|
|
60
|
-
// that.imgHeight = imgObj.height
|
|
61
|
-
// imgObj.set('selectable', false)
|
|
62
|
-
// that.imgObj = imgObj
|
|
63
|
-
// that.loading = false
|
|
64
|
-
// resolve()
|
|
65
|
-
// })
|
|
66
|
-
// }
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const selectTool = (tool: string) => {
|
|
71
|
-
setCurrentTool(tool);
|
|
72
|
-
};
|
|
73
|
-
return (
|
|
74
|
-
<div style={size}>
|
|
75
|
-
<div className="img-container" style={size}>
|
|
76
|
-
<canvas id="c"></canvas>
|
|
77
|
-
</div>
|
|
78
|
-
<ul className="tool-bar">
|
|
79
|
-
<li>操作</li>
|
|
80
|
-
{tools.map((item, i) => {
|
|
81
|
-
return (
|
|
82
|
-
<li key={i} onClick={() => selectTool(item.name)}>
|
|
83
|
-
{item.text}
|
|
84
|
-
</li>
|
|
85
|
-
);
|
|
86
|
-
})}
|
|
87
|
-
</ul>
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default PageLoading;
|
|
1
|
+
import { Spin } from 'antd';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export const classPrefix = 'setting-pic-circle-select';
|
|
5
|
+
const tools = [
|
|
6
|
+
{
|
|
7
|
+
name: 'arrow',
|
|
8
|
+
text: '添加箭头',
|
|
9
|
+
icon: 'icon-tianjiajiantou1',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'text',
|
|
13
|
+
text: '添加文字',
|
|
14
|
+
icon: 'icon-tianjiawenzi1',
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
const PageLoading: React.FC = () => {
|
|
18
|
+
const [size, setSize] = useState({ width: 500, height: 500 });
|
|
19
|
+
const [currentTool, setCurrentTool] = useState<string>();
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
init();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const init = () => {
|
|
26
|
+
loadImage('./images/zg_regist_top.png').then(() => {
|
|
27
|
+
this.initCanvas();
|
|
28
|
+
this.initCanvasEvent();
|
|
29
|
+
this.initEditors();
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const loadImage = (img: string) => {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
// if (utils.isImageBase64(img)) {
|
|
36
|
+
const imgEle = document.createElement('img');
|
|
37
|
+
imgEle.src = img;
|
|
38
|
+
imgEle.onload = () => {
|
|
39
|
+
// this.imgWidth = imgEle.width
|
|
40
|
+
// this.imgHeight = imgEle.height
|
|
41
|
+
// let scale = 1
|
|
42
|
+
// if (!this.primitiveSize && this.imgWidth > this.width) {
|
|
43
|
+
// scale = (this.width - 52) / this.imgWidth
|
|
44
|
+
// this.imgWidth = scale * this.imgWidth
|
|
45
|
+
// this.imgHeight = scale * this.imgHeight
|
|
46
|
+
// }
|
|
47
|
+
// this.imgObj = new fabric.Image(imgEle, {
|
|
48
|
+
// left: 0,
|
|
49
|
+
// top: 0,
|
|
50
|
+
// selectable: false,
|
|
51
|
+
// scaleX: scale,
|
|
52
|
+
// scaleY: scale
|
|
53
|
+
// })
|
|
54
|
+
resolve();
|
|
55
|
+
};
|
|
56
|
+
// } else if (utils.isURL(img)) {
|
|
57
|
+
// const that = this
|
|
58
|
+
// fabric.Image.fromURL(img, function(imgObj) {
|
|
59
|
+
// that.imgWidth = imgObj.width
|
|
60
|
+
// that.imgHeight = imgObj.height
|
|
61
|
+
// imgObj.set('selectable', false)
|
|
62
|
+
// that.imgObj = imgObj
|
|
63
|
+
// that.loading = false
|
|
64
|
+
// resolve()
|
|
65
|
+
// })
|
|
66
|
+
// }
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const selectTool = (tool: string) => {
|
|
71
|
+
setCurrentTool(tool);
|
|
72
|
+
};
|
|
73
|
+
return (
|
|
74
|
+
<div style={size}>
|
|
75
|
+
<div className="img-container" style={size}>
|
|
76
|
+
<canvas id="c"></canvas>
|
|
77
|
+
</div>
|
|
78
|
+
<ul className="tool-bar">
|
|
79
|
+
<li>操作</li>
|
|
80
|
+
{tools.map((item, i) => {
|
|
81
|
+
return (
|
|
82
|
+
<li key={i} onClick={() => selectTool(item.name)}>
|
|
83
|
+
{item.text}
|
|
84
|
+
</li>
|
|
85
|
+
);
|
|
86
|
+
})}
|
|
87
|
+
</ul>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default PageLoading;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const RectangleDrawer = () => {
|
|
4
|
-
const canvasRef = useRef(null);
|
|
5
|
-
let isDrawing = false;
|
|
6
|
-
let startX, startY, stopX, stopY;
|
|
7
|
-
let drawingSurfaceImageData = null;
|
|
8
|
-
|
|
9
|
-
const saveData = () => {
|
|
10
|
-
const canvas = canvasRef.current;
|
|
11
|
-
const context = canvas.getContext('2d');
|
|
12
|
-
drawingSurfaceImageData = context.getImageData(0, 0, 400, 400);
|
|
13
|
-
context.putImageData(drawingSurfaceImageData, 0, 0);
|
|
14
|
-
// restoreData()
|
|
15
|
-
};
|
|
16
|
-
const restoreData = () => {
|
|
17
|
-
const canvas = canvasRef.current;
|
|
18
|
-
const context = canvas.getContext('2d');
|
|
19
|
-
console.log('drawingSurfaceImageData', drawingSurfaceImageData);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
const canvas = canvasRef.current;
|
|
24
|
-
const context = canvas.getContext('2d');
|
|
25
|
-
|
|
26
|
-
canvas.addEventListener('mousedown', (e) => {
|
|
27
|
-
isDrawing = true;
|
|
28
|
-
startX = e.offsetX;
|
|
29
|
-
startY = e.offsetY;
|
|
30
|
-
// drawingSurfaceImageData && restoreData()
|
|
31
|
-
saveData();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
canvas.addEventListener('mousemove', (e) => {
|
|
35
|
-
if (isDrawing) {
|
|
36
|
-
restoreData();
|
|
37
|
-
stopX = e.offsetX;
|
|
38
|
-
stopY = e.offsetY;
|
|
39
|
-
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
40
|
-
context.putImageData(drawingSurfaceImageData, 0, 0);
|
|
41
|
-
context.strokeRect(startX, startY, stopX - startX, stopY - startY);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
canvas.addEventListener('mouseup', () => {
|
|
46
|
-
isDrawing = false;
|
|
47
|
-
saveData();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
canvas.addEventListener('mouseleave', () => {
|
|
51
|
-
isDrawing = false;
|
|
52
|
-
});
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
return <canvas ref={canvasRef} width={400} height={400} style={{ border: '1px solid #000' }} />;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default RectangleDrawer;
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const RectangleDrawer = () => {
|
|
4
|
+
const canvasRef = useRef(null);
|
|
5
|
+
let isDrawing = false;
|
|
6
|
+
let startX, startY, stopX, stopY;
|
|
7
|
+
let drawingSurfaceImageData = null;
|
|
8
|
+
|
|
9
|
+
const saveData = () => {
|
|
10
|
+
const canvas = canvasRef.current;
|
|
11
|
+
const context = canvas.getContext('2d');
|
|
12
|
+
drawingSurfaceImageData = context.getImageData(0, 0, 400, 400);
|
|
13
|
+
context.putImageData(drawingSurfaceImageData, 0, 0);
|
|
14
|
+
// restoreData()
|
|
15
|
+
};
|
|
16
|
+
const restoreData = () => {
|
|
17
|
+
const canvas = canvasRef.current;
|
|
18
|
+
const context = canvas.getContext('2d');
|
|
19
|
+
console.log('drawingSurfaceImageData', drawingSurfaceImageData);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const canvas = canvasRef.current;
|
|
24
|
+
const context = canvas.getContext('2d');
|
|
25
|
+
|
|
26
|
+
canvas.addEventListener('mousedown', (e) => {
|
|
27
|
+
isDrawing = true;
|
|
28
|
+
startX = e.offsetX;
|
|
29
|
+
startY = e.offsetY;
|
|
30
|
+
// drawingSurfaceImageData && restoreData()
|
|
31
|
+
saveData();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
canvas.addEventListener('mousemove', (e) => {
|
|
35
|
+
if (isDrawing) {
|
|
36
|
+
restoreData();
|
|
37
|
+
stopX = e.offsetX;
|
|
38
|
+
stopY = e.offsetY;
|
|
39
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
40
|
+
context.putImageData(drawingSurfaceImageData, 0, 0);
|
|
41
|
+
context.strokeRect(startX, startY, stopX - startX, stopY - startY);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
canvas.addEventListener('mouseup', () => {
|
|
46
|
+
isDrawing = false;
|
|
47
|
+
saveData();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
canvas.addEventListener('mouseleave', () => {
|
|
51
|
+
isDrawing = false;
|
|
52
|
+
});
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
return <canvas ref={canvasRef} width={400} height={400} style={{ border: '1px solid #000' }} />;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default RectangleDrawer;
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const DraggableRect = () => {
|
|
4
|
-
const canvasRef = useRef(null);
|
|
5
|
-
let rect = { x: 50, y: 50, width: 100, height: 50 };
|
|
6
|
-
let dragging = false;
|
|
7
|
-
let draggingx = 0;
|
|
8
|
-
let draggingy = 0;
|
|
9
|
-
// const [rect, setRect] = useState({ x: 50, y: 50, width: 100, height: 50 });
|
|
10
|
-
// const [dragging, setDragging] = useState(false);
|
|
11
|
-
|
|
12
|
-
const drawRect = (rect) => {
|
|
13
|
-
const ctx = canvasRef.current.getContext('2d');
|
|
14
|
-
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
|
|
15
|
-
ctx.beginPath();
|
|
16
|
-
ctx.rect(rect.x, rect.y, rect.width, rect.height);
|
|
17
|
-
ctx.stroke();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const handleMouseDown = (e) => {
|
|
21
|
-
console.log('handleMouseDown', e, e.target);
|
|
22
|
-
|
|
23
|
-
const { x, y } = e;
|
|
24
|
-
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
25
|
-
draggingx = x - left - rect.x;
|
|
26
|
-
draggingy = y - top - rect.y;
|
|
27
|
-
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
28
|
-
dragging = true;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const handleMouseMove = (e) => {
|
|
32
|
-
if (dragging) {
|
|
33
|
-
const { x, y } = e;
|
|
34
|
-
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
35
|
-
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
36
|
-
drawRect(rect);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const handleMouseUp = () => {
|
|
41
|
-
dragging = false;
|
|
42
|
-
drawRect(rect);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// 组件挂载后,绘制矩形
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
drawRect(rect);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
// 鼠标事件绑定
|
|
51
|
-
React.useEffect(() => {
|
|
52
|
-
const canvas = canvasRef.current;
|
|
53
|
-
canvas.addEventListener('mousedown', handleMouseDown);
|
|
54
|
-
canvas.addEventListener('mousemove', handleMouseMove);
|
|
55
|
-
canvas.addEventListener('mouseup', handleMouseUp);
|
|
56
|
-
return () => {
|
|
57
|
-
canvas.removeEventListener('mousedown', handleMouseDown);
|
|
58
|
-
canvas.removeEventListener('mousemove', handleMouseMove);
|
|
59
|
-
canvas.removeEventListener('mouseup', handleMouseUp);
|
|
60
|
-
};
|
|
61
|
-
}, []);
|
|
62
|
-
|
|
63
|
-
return <canvas ref={canvasRef} width={500} height={500} style={{ border: '1px solid #000' }} />;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export default DraggableRect;
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const DraggableRect = () => {
|
|
4
|
+
const canvasRef = useRef(null);
|
|
5
|
+
let rect = { x: 50, y: 50, width: 100, height: 50 };
|
|
6
|
+
let dragging = false;
|
|
7
|
+
let draggingx = 0;
|
|
8
|
+
let draggingy = 0;
|
|
9
|
+
// const [rect, setRect] = useState({ x: 50, y: 50, width: 100, height: 50 });
|
|
10
|
+
// const [dragging, setDragging] = useState(false);
|
|
11
|
+
|
|
12
|
+
const drawRect = (rect) => {
|
|
13
|
+
const ctx = canvasRef.current.getContext('2d');
|
|
14
|
+
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
|
|
15
|
+
ctx.beginPath();
|
|
16
|
+
ctx.rect(rect.x, rect.y, rect.width, rect.height);
|
|
17
|
+
ctx.stroke();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const handleMouseDown = (e) => {
|
|
21
|
+
console.log('handleMouseDown', e, e.target);
|
|
22
|
+
|
|
23
|
+
const { x, y } = e;
|
|
24
|
+
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
25
|
+
draggingx = x - left - rect.x;
|
|
26
|
+
draggingy = y - top - rect.y;
|
|
27
|
+
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
28
|
+
dragging = true;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleMouseMove = (e) => {
|
|
32
|
+
if (dragging) {
|
|
33
|
+
const { x, y } = e;
|
|
34
|
+
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
35
|
+
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
36
|
+
drawRect(rect);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleMouseUp = () => {
|
|
41
|
+
dragging = false;
|
|
42
|
+
drawRect(rect);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// 组件挂载后,绘制矩形
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
drawRect(rect);
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
// 鼠标事件绑定
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
const canvas = canvasRef.current;
|
|
53
|
+
canvas.addEventListener('mousedown', handleMouseDown);
|
|
54
|
+
canvas.addEventListener('mousemove', handleMouseMove);
|
|
55
|
+
canvas.addEventListener('mouseup', handleMouseUp);
|
|
56
|
+
return () => {
|
|
57
|
+
canvas.removeEventListener('mousedown', handleMouseDown);
|
|
58
|
+
canvas.removeEventListener('mousemove', handleMouseMove);
|
|
59
|
+
canvas.removeEventListener('mouseup', handleMouseUp);
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
|
|
63
|
+
return <canvas ref={canvasRef} width={500} height={500} style={{ border: '1px solid #000' }} />;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default DraggableRect;
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const DraggableRect = () => {
|
|
4
|
-
const canvasRef = useRef(null);
|
|
5
|
-
let rect: any = [];
|
|
6
|
-
let dragging = false;
|
|
7
|
-
let draggingx = 0;
|
|
8
|
-
let draggingy = 0;
|
|
9
|
-
let isAdd = true;
|
|
10
|
-
let isDrawing = false;
|
|
11
|
-
let startX, startY, stopX, stopY;
|
|
12
|
-
let index = undefined;
|
|
13
|
-
// const [rect, setRect] = useState({ x: 50, y: 50, width: 100, height: 50 });
|
|
14
|
-
// const [dragging, setDragging] = useState(false);
|
|
15
|
-
|
|
16
|
-
const drawRect = (rect: any) => {
|
|
17
|
-
const ctx = canvasRef.current.getContext('2d');
|
|
18
|
-
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
|
|
19
|
-
ctx.beginPath();
|
|
20
|
-
console.log('rect', rect);
|
|
21
|
-
|
|
22
|
-
rect.map((item) => {
|
|
23
|
-
ctx.rect(item.x, item.y, item.w, item.h);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
ctx.stroke();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const handleMouseDown = (e) => {
|
|
30
|
-
if (isAdd) {
|
|
31
|
-
isDrawing = true;
|
|
32
|
-
startX = e.offsetX;
|
|
33
|
-
startY = e.offsetY;
|
|
34
|
-
} else {
|
|
35
|
-
console.log('handleMouseDown', e, e.target);
|
|
36
|
-
|
|
37
|
-
const { x, y } = e;
|
|
38
|
-
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
39
|
-
draggingx = x - left - rect.x;
|
|
40
|
-
draggingy = y - top - rect.y;
|
|
41
|
-
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
42
|
-
dragging = true;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const handleMouseMove = (e) => {
|
|
47
|
-
if (isAdd) {
|
|
48
|
-
if (isDrawing) {
|
|
49
|
-
stopX = e.offsetX;
|
|
50
|
-
stopY = e.offsetY;
|
|
51
|
-
drawRect([...rect, { x: startX, y: startY, w: stopX - startX, h: stopY - startY }]);
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
if (dragging) {
|
|
55
|
-
const { x, y } = e;
|
|
56
|
-
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
57
|
-
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
58
|
-
drawRect(rect);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const handleMouseUp = () => {
|
|
64
|
-
if (isAdd) {
|
|
65
|
-
rect.push({ x: startX, y: startY, w: stopX - startX, h: stopY - startY });
|
|
66
|
-
} else {
|
|
67
|
-
}
|
|
68
|
-
isDrawing = false;
|
|
69
|
-
dragging = false;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const handleMouseleave = () => {
|
|
73
|
-
isDrawing = false;
|
|
74
|
-
dragging = false;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const handleMouseClick = (e) => {
|
|
78
|
-
// isAdd = false
|
|
79
|
-
// rect.map(item => {
|
|
80
|
-
// const { x, y } = e;
|
|
81
|
-
// const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
82
|
-
// draggingx = x - left
|
|
83
|
-
// draggingy = y - top
|
|
84
|
-
// if () = {
|
|
85
|
-
// }
|
|
86
|
-
// rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy};
|
|
87
|
-
// dragging = true;
|
|
88
|
-
// })
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// 组件挂载后,绘制矩形
|
|
92
|
-
React.useEffect(() => {
|
|
93
|
-
drawRect(rect);
|
|
94
|
-
}, []);
|
|
95
|
-
|
|
96
|
-
// 鼠标事件绑定
|
|
97
|
-
React.useEffect(() => {
|
|
98
|
-
const canvas = canvasRef.current;
|
|
99
|
-
canvas.addEventListener('mousedown', handleMouseDown);
|
|
100
|
-
canvas.addEventListener('mousemove', handleMouseMove);
|
|
101
|
-
canvas.addEventListener('mouseup', handleMouseUp);
|
|
102
|
-
canvas.addEventListener('mouseleave', handleMouseleave);
|
|
103
|
-
canvas.addEventListener('click', handleMouseClick);
|
|
104
|
-
return () => {
|
|
105
|
-
canvas.removeEventListener('mousedown', handleMouseDown);
|
|
106
|
-
canvas.removeEventListener('mousemove', handleMouseMove);
|
|
107
|
-
canvas.removeEventListener('mouseup', handleMouseUp);
|
|
108
|
-
canvas.removeEventListener('mouseleave', handleMouseleave);
|
|
109
|
-
canvas.addEventListener('click', handleMouseClick);
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
|
-
|
|
113
|
-
return <canvas ref={canvasRef} width={500} height={500} style={{ border: '1px solid #000' }} />;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export default DraggableRect;
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const DraggableRect = () => {
|
|
4
|
+
const canvasRef = useRef(null);
|
|
5
|
+
let rect: any = [];
|
|
6
|
+
let dragging = false;
|
|
7
|
+
let draggingx = 0;
|
|
8
|
+
let draggingy = 0;
|
|
9
|
+
let isAdd = true;
|
|
10
|
+
let isDrawing = false;
|
|
11
|
+
let startX, startY, stopX, stopY;
|
|
12
|
+
let index = undefined;
|
|
13
|
+
// const [rect, setRect] = useState({ x: 50, y: 50, width: 100, height: 50 });
|
|
14
|
+
// const [dragging, setDragging] = useState(false);
|
|
15
|
+
|
|
16
|
+
const drawRect = (rect: any) => {
|
|
17
|
+
const ctx = canvasRef.current.getContext('2d');
|
|
18
|
+
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
|
|
19
|
+
ctx.beginPath();
|
|
20
|
+
console.log('rect', rect);
|
|
21
|
+
|
|
22
|
+
rect.map((item) => {
|
|
23
|
+
ctx.rect(item.x, item.y, item.w, item.h);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
ctx.stroke();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handleMouseDown = (e) => {
|
|
30
|
+
if (isAdd) {
|
|
31
|
+
isDrawing = true;
|
|
32
|
+
startX = e.offsetX;
|
|
33
|
+
startY = e.offsetY;
|
|
34
|
+
} else {
|
|
35
|
+
console.log('handleMouseDown', e, e.target);
|
|
36
|
+
|
|
37
|
+
const { x, y } = e;
|
|
38
|
+
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
39
|
+
draggingx = x - left - rect.x;
|
|
40
|
+
draggingy = y - top - rect.y;
|
|
41
|
+
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
42
|
+
dragging = true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleMouseMove = (e) => {
|
|
47
|
+
if (isAdd) {
|
|
48
|
+
if (isDrawing) {
|
|
49
|
+
stopX = e.offsetX;
|
|
50
|
+
stopY = e.offsetY;
|
|
51
|
+
drawRect([...rect, { x: startX, y: startY, w: stopX - startX, h: stopY - startY }]);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
if (dragging) {
|
|
55
|
+
const { x, y } = e;
|
|
56
|
+
const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
57
|
+
rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy };
|
|
58
|
+
drawRect(rect);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleMouseUp = () => {
|
|
64
|
+
if (isAdd) {
|
|
65
|
+
rect.push({ x: startX, y: startY, w: stopX - startX, h: stopY - startY });
|
|
66
|
+
} else {
|
|
67
|
+
}
|
|
68
|
+
isDrawing = false;
|
|
69
|
+
dragging = false;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const handleMouseleave = () => {
|
|
73
|
+
isDrawing = false;
|
|
74
|
+
dragging = false;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleMouseClick = (e) => {
|
|
78
|
+
// isAdd = false
|
|
79
|
+
// rect.map(item => {
|
|
80
|
+
// const { x, y } = e;
|
|
81
|
+
// const { left, top } = canvasRef.current.getBoundingClientRect();
|
|
82
|
+
// draggingx = x - left
|
|
83
|
+
// draggingy = y - top
|
|
84
|
+
// if () = {
|
|
85
|
+
// }
|
|
86
|
+
// rect = { ...rect, x: x - left - draggingx, y: y - top - draggingy};
|
|
87
|
+
// dragging = true;
|
|
88
|
+
// })
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// 组件挂载后,绘制矩形
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
drawRect(rect);
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
// 鼠标事件绑定
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
const canvas = canvasRef.current;
|
|
99
|
+
canvas.addEventListener('mousedown', handleMouseDown);
|
|
100
|
+
canvas.addEventListener('mousemove', handleMouseMove);
|
|
101
|
+
canvas.addEventListener('mouseup', handleMouseUp);
|
|
102
|
+
canvas.addEventListener('mouseleave', handleMouseleave);
|
|
103
|
+
canvas.addEventListener('click', handleMouseClick);
|
|
104
|
+
return () => {
|
|
105
|
+
canvas.removeEventListener('mousedown', handleMouseDown);
|
|
106
|
+
canvas.removeEventListener('mousemove', handleMouseMove);
|
|
107
|
+
canvas.removeEventListener('mouseup', handleMouseUp);
|
|
108
|
+
canvas.removeEventListener('mouseleave', handleMouseleave);
|
|
109
|
+
canvas.addEventListener('click', handleMouseClick);
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
return <canvas ref={canvasRef} width={500} height={500} style={{ border: '1px solid #000' }} />;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default DraggableRect;
|