cnhis-design-vue 3.1.24-beta.6 → 3.1.24-beta.8
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 +123 -123
- package/es/components/big-table/src/BigTable.vue.d.ts +1 -16
- package/es/components/chunk-upload/src/chunk-upload-new.js +7 -4
- package/es/components/chunk-upload/src/vod-chunk-upload/vod-chunk-upload.js +1 -1
- package/es/components/chunk-upload/src/vod-chunk-upload/vod-chunk-upload.vue.d.ts +0 -1
- package/es/components/index.css +1 -1
- package/es/components/scale-view/src/ScaleView.js +1 -1
- package/es/components/scale-view/src/ScaleView.vue.d.ts +3 -0
- package/es/components/scale-view/src/components/formitem/r-sign.d.ts +34 -0
- package/es/components/scale-view/src/components/formitem/r-sign.js +177 -0
- package/es/components/scale-view/src/components/formitem/r-upload.js +33 -39
- package/es/components/scale-view/src/components/formitem/sign-com.d.ts +63 -0
- package/es/components/scale-view/src/components/formitem/sign-com.js +307 -0
- package/es/components/scale-view/src/components/formitem/standard-modal.d.ts +80 -0
- package/es/components/scale-view/src/components/formitem/standard-modal.js +129 -0
- package/es/components/scale-view/src/hooks/use-component.d.ts +34 -0
- package/es/components/scale-view/src/hooks/use-component.js +18 -14
- package/es/components/scale-view/style/index.css +1 -1
- package/es/components/select-person/src/SelectPerson.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/env.d.ts +24 -24
- package/es/shared/assets/img/failure.js +1 -1
- package/es/shared/assets/img/icon-asc.js +1 -1
- package/es/shared/assets/img/icon-desc.js +1 -1
- package/es/shared/assets/img/no-permission.js +1 -1
- package/es/shared/assets/img/nodata.js +1 -1
- package/es/shared/assets/img/notfound.js +1 -1
- package/es/shared/assets/img/qr.js +1 -1
- package/es/shared/assets/img/success.js +1 -1
- package/es/shared/assets/img/video.js +1 -1
- package/es/shared/assets/img/video_default_cover.js +1 -1
- package/es/shared/assets/img/video_hover.js +1 -1
- package/es/shared/assets/img/video_play_hover.js +1 -1
- package/es/shared/assets/img/xb_big.js +1 -1
- package/es/shared/assets/img/xb_small.js +1 -1
- package/package.json +2 -2
- package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
- package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +0 -1
- package/es/components/bpmn-workflow/types/ModelingModule.d.ts +0 -1
- package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +0 -1
- package/es/components/fabric-chart/src/utils/index.d.ts +0 -6823
- package/es/shared/utils/tapable/index.d.ts +0 -139
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent, reactive, createVNode, resolveComponent, createTextVNode } from 'vue';
|
|
2
2
|
import { NUpload, NUploadDragger, NModal, NIcon, useMessage } from 'naive-ui';
|
|
3
|
+
import { api } from 'v-viewer';
|
|
3
4
|
import { CameraOutline, Add } from '@vicons/ionicons5';
|
|
4
5
|
|
|
5
6
|
var RUpload = defineComponent({
|
|
@@ -41,14 +42,12 @@ var RUpload = defineComponent({
|
|
|
41
42
|
const type = props.item.type;
|
|
42
43
|
const limitPic = ((_b = (_a = props.item) == null ? void 0 : _a.setting) == null ? void 0 : _b.limitPic) || 1;
|
|
43
44
|
const max = isNaN(limitPic) ? void 0 : +limitPic;
|
|
44
|
-
|
|
45
|
+
const state = reactive({
|
|
45
46
|
defaultFileList: [],
|
|
46
|
-
fileList: []
|
|
47
|
-
previewVisible: false,
|
|
48
|
-
previewImage: ""
|
|
47
|
+
fileList: []
|
|
49
48
|
});
|
|
50
49
|
const handleDef = () => {
|
|
51
|
-
|
|
50
|
+
const value = props.form[props.item.val_key];
|
|
52
51
|
if (!value)
|
|
53
52
|
return;
|
|
54
53
|
value.forEach((v) => {
|
|
@@ -61,10 +60,10 @@ var RUpload = defineComponent({
|
|
|
61
60
|
handleDef();
|
|
62
61
|
const beforeUpload = (info) => {
|
|
63
62
|
var _a2;
|
|
64
|
-
|
|
63
|
+
const {
|
|
65
64
|
file: file2
|
|
66
65
|
} = info;
|
|
67
|
-
|
|
66
|
+
const size = ((_a2 = file2.file) == null ? void 0 : _a2.size) || 0;
|
|
68
67
|
const isJpgOrPng = file2.type === "image/jpeg" || file2.type === "image/png";
|
|
69
68
|
if (!isJpgOrPng) {
|
|
70
69
|
message.error("\u4EC5\u652F\u6301jpeg/png\u683C\u5F0F");
|
|
@@ -77,10 +76,10 @@ var RUpload = defineComponent({
|
|
|
77
76
|
};
|
|
78
77
|
const beforeUploadFile = (info) => {
|
|
79
78
|
var _a2;
|
|
80
|
-
|
|
79
|
+
const {
|
|
81
80
|
file: file2
|
|
82
81
|
} = info;
|
|
83
|
-
|
|
82
|
+
const size = ((_a2 = file2.file) == null ? void 0 : _a2.size) || 0;
|
|
84
83
|
const isLt2M = size / 1024 / 1024 < 50;
|
|
85
84
|
if (!isLt2M) {
|
|
86
85
|
message.error("\u4E0A\u4F20\u56FE\u7247\u9650\u5236\u572850MB\u4EE5\u5185");
|
|
@@ -104,13 +103,13 @@ var RUpload = defineComponent({
|
|
|
104
103
|
}
|
|
105
104
|
};
|
|
106
105
|
const handleUploadFinish = (options) => {
|
|
107
|
-
|
|
106
|
+
const {
|
|
108
107
|
event,
|
|
109
108
|
file
|
|
110
109
|
} = options;
|
|
111
110
|
const res = eval("(" + event.target.response + ")");
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
const matchIndex = state.fileList.findIndex((v) => v.uid === file.id);
|
|
112
|
+
const matchItem = state.fileList[matchIndex];
|
|
114
113
|
if (res.result !== "SUCCESS") {
|
|
115
114
|
file.status = "error";
|
|
116
115
|
matchIndex > -1 && state.fileList.splice(matchIndex, 1);
|
|
@@ -123,24 +122,32 @@ var RUpload = defineComponent({
|
|
|
123
122
|
context.emit("scaleChange", state.fileList, props.item);
|
|
124
123
|
};
|
|
125
124
|
const handleUploadRemove = (options2) => {
|
|
126
|
-
|
|
125
|
+
const {
|
|
127
126
|
file: file2
|
|
128
127
|
} = options2;
|
|
129
128
|
if (file2.status === "finished") {
|
|
130
|
-
|
|
129
|
+
const curIndex = state.fileList.findIndex((v) => v.uid === file2.id);
|
|
131
130
|
curIndex > -1 && state.fileList.splice(curIndex, 1);
|
|
132
131
|
context.emit("scaleChange", state.fileList, props.item);
|
|
133
132
|
}
|
|
134
133
|
};
|
|
135
134
|
const handlePreview = (file2) => {
|
|
136
|
-
|
|
135
|
+
const fileList = state.fileList;
|
|
137
136
|
if (!fileList.length)
|
|
138
137
|
return;
|
|
139
|
-
|
|
140
|
-
if (
|
|
138
|
+
const matchIndex2 = fileList.findIndex((v) => v.uid === file2.id);
|
|
139
|
+
if (!~matchIndex2)
|
|
140
|
+
return;
|
|
141
|
+
const imgs = fileList.map((v) => v.url).filter(Boolean);
|
|
142
|
+
if (!imgs.length)
|
|
141
143
|
return;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
api({
|
|
145
|
+
images: imgs,
|
|
146
|
+
options: {
|
|
147
|
+
toolbar: true,
|
|
148
|
+
initialViewIndex: matchIndex2
|
|
149
|
+
}
|
|
150
|
+
});
|
|
144
151
|
};
|
|
145
152
|
const renderPicture = () => {
|
|
146
153
|
return createVNode(resolveComponent("n-upload"), {
|
|
@@ -155,9 +162,10 @@ var RUpload = defineComponent({
|
|
|
155
162
|
"on-change": handleUploadChange,
|
|
156
163
|
"on-finish": handleUploadFinish,
|
|
157
164
|
"on-remove": handleUploadRemove,
|
|
158
|
-
"on-preview": handlePreview
|
|
165
|
+
"on-preview": handlePreview,
|
|
166
|
+
"show-trigger": !props.isLock
|
|
159
167
|
}, {
|
|
160
|
-
default: () => [createVNode("div", {
|
|
168
|
+
default: () => [!props.isLock && createVNode("div", {
|
|
161
169
|
"class": "upload-img-wrap"
|
|
162
170
|
}, [createVNode(NIcon, {
|
|
163
171
|
"class": "prompt-icon",
|
|
@@ -177,9 +185,10 @@ var RUpload = defineComponent({
|
|
|
177
185
|
"on-before-upload": beforeUploadFile,
|
|
178
186
|
"on-change": handleUploadChange,
|
|
179
187
|
"on-finish": handleUploadFinish,
|
|
180
|
-
"on-remove": handleUploadRemove
|
|
188
|
+
"on-remove": handleUploadRemove,
|
|
189
|
+
"show-trigger": !props.isLock
|
|
181
190
|
}, {
|
|
182
|
-
default: () => [createVNode(resolveComponent("n-upload-dragger"), null, {
|
|
191
|
+
default: () => [!props.isLock && createVNode(resolveComponent("n-upload-dragger"), null, {
|
|
183
192
|
default: () => [createVNode("div", {
|
|
184
193
|
"class": "dragger-upload-text"
|
|
185
194
|
}, [createVNode(NIcon, {
|
|
@@ -190,27 +199,12 @@ var RUpload = defineComponent({
|
|
|
190
199
|
})]
|
|
191
200
|
});
|
|
192
201
|
};
|
|
193
|
-
const renderModal = () => {
|
|
194
|
-
return createVNode(resolveComponent("n-modal"), {
|
|
195
|
-
"show": state.previewVisible,
|
|
196
|
-
"onUpdate:show": ($event) => state.previewVisible = $event,
|
|
197
|
-
"preset": "card",
|
|
198
|
-
"style": {
|
|
199
|
-
width: "520px"
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
default: () => [createVNode("img", {
|
|
203
|
-
"src": state.previewImage,
|
|
204
|
-
"style": "width: 100%"
|
|
205
|
-
}, null)]
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
202
|
const renderDom = () => {
|
|
209
203
|
return createVNode("div", {
|
|
210
204
|
"class": ["c-scale-upload", {
|
|
211
205
|
"scale-upload-file": type === "UPFILE"
|
|
212
206
|
}]
|
|
213
|
-
}, [type === "UPFILE" && renderFile(), type === "UPPICTURE" && renderPicture()
|
|
207
|
+
}, [type === "UPFILE" && renderFile(), type === "UPPICTURE" && renderPicture()]);
|
|
214
208
|
};
|
|
215
209
|
return () => {
|
|
216
210
|
return renderDom();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
width: {
|
|
3
|
+
type: NumberConstructor;
|
|
4
|
+
default: number;
|
|
5
|
+
};
|
|
6
|
+
height: {
|
|
7
|
+
type: NumberConstructor;
|
|
8
|
+
default: number;
|
|
9
|
+
};
|
|
10
|
+
lineWidth: {
|
|
11
|
+
type: NumberConstructor;
|
|
12
|
+
default: number;
|
|
13
|
+
};
|
|
14
|
+
lineColor: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
bgColor: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
isCrop: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
}, {
|
|
27
|
+
renderContent: () => JSX.Element;
|
|
28
|
+
generate: () => Promise<unknown>;
|
|
29
|
+
reset: () => void;
|
|
30
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
31
|
+
width: {
|
|
32
|
+
type: NumberConstructor;
|
|
33
|
+
default: number;
|
|
34
|
+
};
|
|
35
|
+
height: {
|
|
36
|
+
type: NumberConstructor;
|
|
37
|
+
default: number;
|
|
38
|
+
};
|
|
39
|
+
lineWidth: {
|
|
40
|
+
type: NumberConstructor;
|
|
41
|
+
default: number;
|
|
42
|
+
};
|
|
43
|
+
lineColor: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
bgColor: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
isCrop: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
}>> & {}, {
|
|
56
|
+
height: number;
|
|
57
|
+
width: number;
|
|
58
|
+
lineWidth: number;
|
|
59
|
+
lineColor: string;
|
|
60
|
+
bgColor: string;
|
|
61
|
+
isCrop: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
export default _default;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { defineComponent, ref, reactive, computed, onBeforeMount, onUnmounted, onMounted, createVNode, createTextVNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
var SignCom = defineComponent({
|
|
4
|
+
name: "SignCom",
|
|
5
|
+
props: {
|
|
6
|
+
width: {
|
|
7
|
+
type: Number,
|
|
8
|
+
default: 620
|
|
9
|
+
},
|
|
10
|
+
height: {
|
|
11
|
+
type: Number,
|
|
12
|
+
default: 300
|
|
13
|
+
},
|
|
14
|
+
lineWidth: {
|
|
15
|
+
type: Number,
|
|
16
|
+
default: 4
|
|
17
|
+
},
|
|
18
|
+
lineColor: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "#000000"
|
|
21
|
+
},
|
|
22
|
+
bgColor: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
isCrop: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [],
|
|
32
|
+
setup(props) {
|
|
33
|
+
const canvasRef = ref(null);
|
|
34
|
+
const canvasTxt = ref();
|
|
35
|
+
const resultImg = ref();
|
|
36
|
+
const hasDrew = ref(false);
|
|
37
|
+
const drawObj = reactive({
|
|
38
|
+
points: [],
|
|
39
|
+
startX: 0,
|
|
40
|
+
startY: 0,
|
|
41
|
+
isDrawing: false,
|
|
42
|
+
sratio: 1
|
|
43
|
+
});
|
|
44
|
+
const ratio = computed(() => {
|
|
45
|
+
return props.height / props.width;
|
|
46
|
+
});
|
|
47
|
+
const myBg = computed(() => {
|
|
48
|
+
return props.bgColor ? props.bgColor : "rgba(255, 255, 255, 0)";
|
|
49
|
+
});
|
|
50
|
+
const drawGrid = (context, color, stepx, stepy) => {
|
|
51
|
+
context.save();
|
|
52
|
+
context.fillStyle = "white";
|
|
53
|
+
console.log(context);
|
|
54
|
+
context.fillRect(0, 0, context.canvas.width, context.canvas.height);
|
|
55
|
+
context.lineWidth = 0.5;
|
|
56
|
+
context.strokeStyle = color;
|
|
57
|
+
for (let i = stepx; i < context.canvas.width; i += stepx) {
|
|
58
|
+
context.beginPath();
|
|
59
|
+
context.moveTo(i, 0);
|
|
60
|
+
context.lineTo(i, context.canvas.height);
|
|
61
|
+
context.closePath();
|
|
62
|
+
context.stroke();
|
|
63
|
+
}
|
|
64
|
+
for (let j = stepy; j < context.canvas.height; j += stepy) {
|
|
65
|
+
context.beginPath();
|
|
66
|
+
context.moveTo(0, j);
|
|
67
|
+
context.lineTo(context.canvas.width, j);
|
|
68
|
+
context.closePath();
|
|
69
|
+
context.stroke();
|
|
70
|
+
}
|
|
71
|
+
context.restore();
|
|
72
|
+
};
|
|
73
|
+
const drawStart = (obj) => {
|
|
74
|
+
drawObj.startX = obj.x;
|
|
75
|
+
drawObj.startY = obj.y;
|
|
76
|
+
canvasTxt.value.beginPath();
|
|
77
|
+
canvasTxt.value.moveTo(drawObj.startX, drawObj.startY);
|
|
78
|
+
canvasTxt.value.lineTo(obj.x, obj.y);
|
|
79
|
+
canvasTxt.value.lineCap = "round";
|
|
80
|
+
canvasTxt.value.lineJoin = "round";
|
|
81
|
+
canvasTxt.value.lineWidth = props.lineWidth * drawObj.sratio;
|
|
82
|
+
canvasTxt.value.stroke();
|
|
83
|
+
canvasTxt.value.closePath();
|
|
84
|
+
drawObj.points.push(obj);
|
|
85
|
+
};
|
|
86
|
+
const drawMove = (obj) => {
|
|
87
|
+
canvasTxt.value.beginPath();
|
|
88
|
+
canvasTxt.value.moveTo(drawObj.startX, drawObj.startY);
|
|
89
|
+
canvasTxt.value.lineTo(obj.x, obj.y);
|
|
90
|
+
canvasTxt.value.strokeStyle = props.lineColor;
|
|
91
|
+
canvasTxt.value.lineWidth = props.lineWidth * drawObj.sratio;
|
|
92
|
+
canvasTxt.value.lineCap = "round";
|
|
93
|
+
canvasTxt.value.lineJoin = "round";
|
|
94
|
+
canvasTxt.value.stroke();
|
|
95
|
+
canvasTxt.value.closePath();
|
|
96
|
+
drawObj.startY = obj.y;
|
|
97
|
+
drawObj.startX = obj.x;
|
|
98
|
+
drawObj.points.push(obj);
|
|
99
|
+
};
|
|
100
|
+
const drawEnd = (obj) => {
|
|
101
|
+
canvasTxt.value.beginPath();
|
|
102
|
+
canvasTxt.value.moveTo(drawObj.startX, drawObj.startY);
|
|
103
|
+
canvasTxt.value.lineCap = "round";
|
|
104
|
+
canvasTxt.value.lineJoin = "round";
|
|
105
|
+
canvasTxt.value.stroke();
|
|
106
|
+
canvasTxt.value.closePath();
|
|
107
|
+
drawObj.points.push(obj);
|
|
108
|
+
drawObj.points.push({
|
|
109
|
+
x: -1,
|
|
110
|
+
y: -1
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const mouseDown = (e) => {
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
drawObj.isDrawing = true;
|
|
116
|
+
hasDrew.value = true;
|
|
117
|
+
const obj = {
|
|
118
|
+
x: e.offsetX,
|
|
119
|
+
y: e.offsetY
|
|
120
|
+
};
|
|
121
|
+
drawStart(obj);
|
|
122
|
+
};
|
|
123
|
+
const mouseMove = (e) => {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
if (!drawObj.isDrawing)
|
|
126
|
+
return;
|
|
127
|
+
const obj = {
|
|
128
|
+
x: e.offsetX,
|
|
129
|
+
y: e.offsetY
|
|
130
|
+
};
|
|
131
|
+
drawMove(obj);
|
|
132
|
+
};
|
|
133
|
+
const mouseUp = (e) => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
const obj = {
|
|
136
|
+
x: e.offsetX,
|
|
137
|
+
y: e.offsetY
|
|
138
|
+
};
|
|
139
|
+
drawEnd(obj);
|
|
140
|
+
drawObj.isDrawing = false;
|
|
141
|
+
};
|
|
142
|
+
const touchStart = (e) => {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
hasDrew.value = true;
|
|
145
|
+
if (e.touches.length === 1) {
|
|
146
|
+
const obj = {
|
|
147
|
+
x: e.targetTouches[0].clientX - canvasRef.value.getBoundingClientRect().left,
|
|
148
|
+
y: e.targetTouches[0].clientY - canvasRef.value.getBoundingClientRect().top
|
|
149
|
+
};
|
|
150
|
+
drawStart(obj);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const touchMove = (e) => {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
if (e.touches.length !== 1)
|
|
156
|
+
return;
|
|
157
|
+
const obj = {
|
|
158
|
+
x: e.targetTouches[0].clientX - canvasRef.value.getBoundingClientRect().left,
|
|
159
|
+
y: e.targetTouches[0].clientY - canvasRef.value.getBoundingClientRect().top
|
|
160
|
+
};
|
|
161
|
+
drawMove(obj);
|
|
162
|
+
};
|
|
163
|
+
const touchEnd = (e) => {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
if (e.touches.length !== 1)
|
|
166
|
+
return;
|
|
167
|
+
const obj = {
|
|
168
|
+
x: e.targetTouches[0].clientX - canvasRef.value.getBoundingClientRect().left,
|
|
169
|
+
y: e.targetTouches[0].clientY - canvasRef.value.getBoundingClientRect().top
|
|
170
|
+
};
|
|
171
|
+
drawEnd(obj);
|
|
172
|
+
};
|
|
173
|
+
const getCropArea = (imgData) => {
|
|
174
|
+
let topX = canvasRef.value.width;
|
|
175
|
+
let btmX = 0;
|
|
176
|
+
let topY = canvasRef.value.height;
|
|
177
|
+
let btnY = 0;
|
|
178
|
+
for (let i = 0; i < canvasRef.value.width; i++) {
|
|
179
|
+
for (let j = 0; j < canvasRef.value.height; j++) {
|
|
180
|
+
const pos = (i + canvasRef.value.width * j) * 4;
|
|
181
|
+
if (imgData[pos] > 0 || imgData[pos + 1] > 0 || imgData[pos + 2] || imgData[pos + 3] > 0) {
|
|
182
|
+
btnY = Math.max(j, btnY);
|
|
183
|
+
btmX = Math.max(i, btmX);
|
|
184
|
+
topY = Math.min(j, topY);
|
|
185
|
+
topX = Math.min(i, topX);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
topX++;
|
|
190
|
+
btmX++;
|
|
191
|
+
topY++;
|
|
192
|
+
btnY++;
|
|
193
|
+
const data = [topX, topY, btmX, btnY];
|
|
194
|
+
return data;
|
|
195
|
+
};
|
|
196
|
+
const getImgSize = (url) => {
|
|
197
|
+
const strLength = url.length;
|
|
198
|
+
const strNum = strLength - strLength / 8 * 2;
|
|
199
|
+
return Math.floor(strNum);
|
|
200
|
+
};
|
|
201
|
+
const randomId = () => {
|
|
202
|
+
const str = Math.random() * 1e10 + "";
|
|
203
|
+
return parseInt(str).toString(36);
|
|
204
|
+
};
|
|
205
|
+
const generate = () => {
|
|
206
|
+
const pm = new Promise((resolve, reject) => {
|
|
207
|
+
if (!hasDrew.value) {
|
|
208
|
+
reject("Warning: Not Signned!");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const resImgData = canvasTxt.value.getImageData(0, 0, canvasRef.value.width, canvasRef.value.height);
|
|
212
|
+
canvasTxt.value.globalCompositeOperation = "destination-over";
|
|
213
|
+
canvasTxt.value.fillStyle = myBg.value;
|
|
214
|
+
canvasTxt.value.fillRect(0, 0, canvasRef.value.width, canvasRef.value.height);
|
|
215
|
+
let resultImg2 = canvasRef.value.toDataURL();
|
|
216
|
+
canvasTxt.value.clearRect(0, 0, canvasRef.value.width, canvasRef.value.height);
|
|
217
|
+
canvasTxt.value.putImageData(resImgData, 0, 0);
|
|
218
|
+
canvasTxt.value.globalCompositeOperation = "source-over";
|
|
219
|
+
if (props.isCrop) {
|
|
220
|
+
const crop_area = getCropArea(resImgData.data);
|
|
221
|
+
let crop_canvas = document.createElement("canvas");
|
|
222
|
+
const crop_ctx = crop_canvas.getContext("2d");
|
|
223
|
+
crop_canvas.width = crop_area[2] - crop_area[0];
|
|
224
|
+
crop_canvas.height = crop_area[3] - crop_area[1];
|
|
225
|
+
const crop_imgData = canvasTxt.value.getImageData(...crop_area);
|
|
226
|
+
for (let i = 0; i < crop_imgData.data.length; i += 4) {
|
|
227
|
+
if (crop_imgData.data[i] > 200) {
|
|
228
|
+
crop_imgData.data[i] = 255;
|
|
229
|
+
crop_imgData.data[i + 1] = 255;
|
|
230
|
+
crop_imgData.data[i + 2] = 255;
|
|
231
|
+
crop_imgData.data[i + 3] = 255;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
crop_ctx.globalCompositeOperation = "destination-over";
|
|
235
|
+
crop_ctx.putImageData(crop_imgData, 0, 0);
|
|
236
|
+
crop_ctx.fillStyle = myBg.value;
|
|
237
|
+
crop_ctx.fillRect(0, 0, crop_canvas.width, crop_canvas.height);
|
|
238
|
+
resultImg2 = crop_canvas.toDataURL();
|
|
239
|
+
crop_canvas = null;
|
|
240
|
+
}
|
|
241
|
+
const obj = {
|
|
242
|
+
name: randomId(),
|
|
243
|
+
url: resultImg2,
|
|
244
|
+
size: getImgSize(resultImg2)
|
|
245
|
+
};
|
|
246
|
+
resolve(obj);
|
|
247
|
+
});
|
|
248
|
+
return pm;
|
|
249
|
+
};
|
|
250
|
+
const reset = () => {
|
|
251
|
+
canvasTxt.value.clearRect(0, 0, canvasRef.value.width, canvasRef.value.height);
|
|
252
|
+
drawGrid(canvasTxt.value, "rgb(240, 240, 240)", 16, 16);
|
|
253
|
+
drawObj.points = [];
|
|
254
|
+
hasDrew.value = false;
|
|
255
|
+
resultImg.value = "";
|
|
256
|
+
};
|
|
257
|
+
const resizeHandler = () => {
|
|
258
|
+
canvasRef.value.style.width = props.width + "px";
|
|
259
|
+
const realw = parseFloat(window.getComputedStyle(canvasRef.value).width);
|
|
260
|
+
canvasRef.value.style.height = ratio.value * realw + "px";
|
|
261
|
+
canvasTxt.value = canvasRef.value.getContext("2d");
|
|
262
|
+
canvasTxt.value.globalAlpha = 1;
|
|
263
|
+
};
|
|
264
|
+
onBeforeMount(() => {
|
|
265
|
+
window.addEventListener("resize", resizeHandler);
|
|
266
|
+
});
|
|
267
|
+
onUnmounted(() => {
|
|
268
|
+
window.removeEventListener("resize", resizeHandler);
|
|
269
|
+
});
|
|
270
|
+
onMounted(() => {
|
|
271
|
+
canvasRef.value.height = props.height;
|
|
272
|
+
canvasRef.value.width = props.width;
|
|
273
|
+
resizeHandler();
|
|
274
|
+
drawGrid(canvasTxt.value, "rgb(240, 240, 240)", 16, 16);
|
|
275
|
+
document.onmouseup = () => {
|
|
276
|
+
drawObj.isDrawing = false;
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
const renderCanvas = () => {
|
|
280
|
+
return createVNode("canvas", {
|
|
281
|
+
"class": "sign-canvas",
|
|
282
|
+
"ref": canvasRef,
|
|
283
|
+
"onMousedown": mouseDown,
|
|
284
|
+
"onMousemove": mouseMove,
|
|
285
|
+
"onMouseup": mouseUp,
|
|
286
|
+
"onTouchstart": touchStart,
|
|
287
|
+
"onTouchmove": touchMove,
|
|
288
|
+
"onTouchend": touchEnd
|
|
289
|
+
}, null);
|
|
290
|
+
};
|
|
291
|
+
const renderContent = () => {
|
|
292
|
+
return createVNode("div", {
|
|
293
|
+
"class": "sign-com-wrap"
|
|
294
|
+
}, [createVNode("span", null, [createTextVNode("\u63D0\u793A\uFF1A\u8BF7\u5728\u4EE5\u4E0B\u533A\u57DF\u5185\u7B7E\u540D\uFF0CPC\u7535\u8111\u8BBE\u5907\u4F7F\u7528\u9F20\u6807\u7B7E\u5B57\u3002")]), renderCanvas()]);
|
|
295
|
+
};
|
|
296
|
+
return {
|
|
297
|
+
renderContent,
|
|
298
|
+
generate,
|
|
299
|
+
reset
|
|
300
|
+
};
|
|
301
|
+
},
|
|
302
|
+
render() {
|
|
303
|
+
return this.renderContent();
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
export { SignCom as default };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
title: {
|
|
3
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
changeSize: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: boolean;
|
|
9
|
+
};
|
|
10
|
+
closable: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: boolean;
|
|
13
|
+
};
|
|
14
|
+
modalWidth: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
modalHeight: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
handleOk: {
|
|
23
|
+
type: FunctionConstructor;
|
|
24
|
+
default: () => void;
|
|
25
|
+
};
|
|
26
|
+
cancel: {
|
|
27
|
+
type: FunctionConstructor;
|
|
28
|
+
default: () => void;
|
|
29
|
+
};
|
|
30
|
+
visible: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("onClose" | "update:visible")[], "onClose" | "update:visible", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
35
|
+
title: {
|
|
36
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
changeSize: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
43
|
+
closable: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
modalWidth: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
modalHeight: {
|
|
52
|
+
type: StringConstructor;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
55
|
+
handleOk: {
|
|
56
|
+
type: FunctionConstructor;
|
|
57
|
+
default: () => void;
|
|
58
|
+
};
|
|
59
|
+
cancel: {
|
|
60
|
+
type: FunctionConstructor;
|
|
61
|
+
default: () => void;
|
|
62
|
+
};
|
|
63
|
+
visible: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: boolean;
|
|
66
|
+
};
|
|
67
|
+
}>> & {
|
|
68
|
+
onOnClose?: ((...args: any[]) => any) | undefined;
|
|
69
|
+
"onUpdate:visible"?: ((...args: any[]) => any) | undefined;
|
|
70
|
+
}, {
|
|
71
|
+
closable: boolean;
|
|
72
|
+
visible: boolean;
|
|
73
|
+
handleOk: Function;
|
|
74
|
+
title: string | Function;
|
|
75
|
+
modalWidth: string;
|
|
76
|
+
modalHeight: string;
|
|
77
|
+
changeSize: boolean;
|
|
78
|
+
cancel: Function;
|
|
79
|
+
}>;
|
|
80
|
+
export default _default;
|