ui-ddy-pc 0.0.1-beta

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 (53) hide show
  1. package/.env.development +4 -0
  2. package/.env.prod +1 -0
  3. package/.env.stage +3 -0
  4. package/.vscode/extensions.json +3 -0
  5. package/README.md +7 -0
  6. package/build/configure/package.json +11 -0
  7. package/index.html +13 -0
  8. package/index.js +4 -0
  9. package/package.json +33 -0
  10. package/src/App.vue +20 -0
  11. package/src/assets/table/empty-data.png +0 -0
  12. package/src/assets/table/magnifier.svg +7 -0
  13. package/src/assets/vue.svg +1 -0
  14. package/src/components/tableTest.vue +101 -0
  15. package/src/components/topSearch/search.vue +302 -0
  16. package/src/components/topSearch/searchItem.vue +80 -0
  17. package/src/components/topSign/topSign.vue +170 -0
  18. package/src/components/topTable/topTable.vue +854 -0
  19. package/src/docs/.vitepress/cache/deps/@theme_index.js +258 -0
  20. package/src/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
  21. package/src/docs/.vitepress/cache/deps/_metadata.json +40 -0
  22. package/src/docs/.vitepress/cache/deps/chunk-KGHB62SH.js +11434 -0
  23. package/src/docs/.vitepress/cache/deps/chunk-KGHB62SH.js.map +7 -0
  24. package/src/docs/.vitepress/cache/deps/chunk-TBELKJNH.js +9088 -0
  25. package/src/docs/.vitepress/cache/deps/chunk-TBELKJNH.js.map +7 -0
  26. package/src/docs/.vitepress/cache/deps/package.json +3 -0
  27. package/src/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +2588 -0
  28. package/src/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  29. package/src/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
  30. package/src/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  31. package/src/docs/.vitepress/cache/deps/vue.js +323 -0
  32. package/src/docs/.vitepress/cache/deps/vue.js.map +7 -0
  33. package/src/docs/.vitepress/config.js +28 -0
  34. package/src/docs/api-examples.md +49 -0
  35. package/src/docs/combinedTable.md +158 -0
  36. package/src/docs/index.md +25 -0
  37. package/src/docs/markdown-examples.md +98 -0
  38. package/src/docs/unitTests/searchTest.vue +109 -0
  39. package/src/main.js +16 -0
  40. package/src/packages/index.js +3 -0
  41. package/src/router/index.js +24 -0
  42. package/src/store/index.js +35 -0
  43. package/src/style.css +73 -0
  44. package/src/utils/common.js +254 -0
  45. package/src/utils/currency.js +256 -0
  46. package/src/utils/errorCode.js +6 -0
  47. package/src/utils/request.js +220 -0
  48. package/src/utils/top.js +233 -0
  49. package/ui-ddy-pc/package.json +11 -0
  50. package/ui-ddy-pc/style.css +1 -0
  51. package/ui-ddy-pc/ui-ddy-pc.js +26436 -0
  52. package/ui-ddy-pc/ui-ddy-pc.umd.cjs +83 -0
  53. package/vite.config.js +54 -0
@@ -0,0 +1,170 @@
1
+ <template>
2
+ <div class="sign-container" :style="setDynamicVars">
3
+ <div class="canvas-container">
4
+ <canvas ref="canvasRef" @mousemove="draw" @mousedown="startDrawing" @mouseup="finishDrawing" id="canvas-id"
5
+ canvas-id="canvas-id" :class="{ 'uni-canvas-style': isUniCanvas() }"></canvas>
6
+ </div>
7
+ <div class="actions-box">
8
+ <button @click="clearCanvas" class="commn-btn">清除</button>
9
+ <button @click="saveSignature" class="commn-btn">保存</button>
10
+ <button @click="undo" class="commn-btn">撤销</button>
11
+ </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ export default {
17
+ data() {
18
+ return {
19
+ ctx: null,
20
+ signatureImage: '',
21
+ actionHeight: 0,
22
+ isDrawing: false,
23
+ paths: [], // 保存绘制的路径数据
24
+ currentPath: [],
25
+ }
26
+ },
27
+ methods: {
28
+ startDrawing(event) {
29
+ this.isDrawing = true;
30
+ this.currentPath = []; // 创建新的路径
31
+ const rect = this.$refs.canvasRef.getBoundingClientRect();
32
+ // 修正按下位置相对于画布的位置
33
+ const x = (event.clientX - rect.left) * (this.$refs.canvasRef.width / rect.width);
34
+ const y = (event.clientY - rect.top) * (this.$refs.canvasRef.height / rect.height);
35
+ this.ctx.beginPath();
36
+ this.ctx.moveTo(x, y);
37
+ this.currentPath.push({ x, y });
38
+ },
39
+
40
+ draw(event) {
41
+ if (!this.isDrawing) return;
42
+ if (this.currentPath.length > 0) {
43
+ const rect = this.$refs.canvasRef.getBoundingClientRect();
44
+ const x = (event.clientX - rect.left) * (this.$refs.canvasRef.width / rect.width);
45
+ const y = (event.clientY - rect.top) * (this.$refs.canvasRef.height / rect.height);
46
+ this.ctx.lineWidth = 2;
47
+
48
+ this.ctx.strokeStyle = "#000000";//线条的颜色
49
+ this.ctx.lineTo(x, y);
50
+ this.ctx.stroke();
51
+
52
+ // 将路径数据保存到数组中
53
+ this.currentPath.push({ x, y });
54
+ }
55
+ },
56
+ undo() {
57
+ this.paths.pop(); // 删除最后一条路径
58
+ // 清空画布
59
+ this.ctx.clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height);
60
+ // 重新绘制除最后一条路径之外的所有路径
61
+ for (let path of this.paths) {
62
+ for (let i = 0; i < path.length - 1; i++) {
63
+ const { x, y } = path[i];
64
+ if (i === 0) {
65
+ this.ctx.beginPath();
66
+ this.ctx.moveTo(x, y);
67
+ } else {
68
+ this.ctx.lineTo(x, y);
69
+ this.ctx.stroke();
70
+ }
71
+ }
72
+ }
73
+ },
74
+ finishDrawing(event) {
75
+ if (this.currentPath.length > 0) {
76
+ this.paths.push(this.currentPath); // 将当前路径添加到路径数组
77
+ }
78
+ this.isDrawing = false;
79
+ },
80
+
81
+ clearCanvas() {
82
+ this.ctx.clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height);
83
+ this.signatureImage = '';
84
+ this.paths = []; // 清空路径记录
85
+ this.$emit('saveSignature', '', false)
86
+ },
87
+
88
+ saveSignature() {
89
+ // toDo: uni框架转成的base64无type前缀 需统一
90
+ this.signatureImage = this.$refs.canvasRef.toDataURL();
91
+ this.$emit('saveSignature', this.signatureImage, true)
92
+ },
93
+ isUniCanvas() {
94
+ return this.$refs.canvasRef?.getContext ? false : true
95
+ }
96
+ },
97
+ computed: {
98
+ setDynamicVars() {
99
+ return {
100
+ "--action-height": `${this.actionHeight}px`
101
+ };
102
+ }
103
+ },
104
+ watch: {
105
+ setDynamicVars(newVal) {
106
+ let canvasContainer = document.querySelector('.canvas-container');
107
+ if (canvasContainer) {
108
+ // 解决锯齿及模糊
109
+ this.$refs.canvasRef.width = canvasContainer.offsetWidth
110
+ this.$refs.canvasRef.height = canvasContainer.offsetHeight - this.actionHeight
111
+ }
112
+ }
113
+ },
114
+ mounted() {
115
+ this.actionHeight = document.querySelector('.actions-box')?.offsetHeight;
116
+ this.ctx = this.$refs.canvasRef.getContext('2d');
117
+ }
118
+ }
119
+ </script>
120
+
121
+
122
+ <style lang="scss" scoped>
123
+ .sign-container {
124
+ width: 100%;
125
+ height: 100%;
126
+
127
+ .canvas-container {
128
+ position: relative;
129
+ width: 100%;
130
+ height: calc(100% - var(--action-height));
131
+ border: 1px solid;
132
+
133
+ #canvas-id {
134
+ width: 100%;
135
+ height: 100%;
136
+ }
137
+ }
138
+
139
+ .actions-box {
140
+ width: 100%;
141
+ bottom: constant(safe-area-inset-bottom);
142
+ bottom: env(safe-area-inset-bottom);
143
+ background: #fff;
144
+ display: flex;
145
+ justify-content: space-evenly;
146
+ padding: 10px 0 10px 0;
147
+ padding: 10px 0 10px 0;
148
+
149
+ .commn-btn {
150
+ background: #409EFF;
151
+ border-color: #409EFF;
152
+ color: #FFF;
153
+ border-radius: 4px;
154
+ padding: 10px 20px;
155
+ border: 1px solid #DCDFE6;
156
+ font-size: 14px;
157
+
158
+ &:hover {
159
+ background: #66b1ff;
160
+ border-color: #66b1ff;
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ .uni-canvas-style {
167
+ width: 100%;
168
+ height: 100%;
169
+ }
170
+ </style>