fl-web-component 2.0.0-beta.9 → 2.0.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.
Files changed (34) hide show
  1. package/README.md +5 -0
  2. package/dist/fl-web-component.common.js +34766 -1686
  3. package/dist/fl-web-component.common.js.map +1 -1
  4. package/dist/fl-web-component.css +1 -1
  5. package/package.json +4 -15
  6. package/packages/components/com-card/index.vue +1 -1
  7. package/packages/components/com-flcanvas/components/bspline.js +31 -34
  8. package/packages/components/com-flcanvas/components/entityFormatting.js +810 -823
  9. package/packages/components/com-flcanvas/components/round10.js +17 -17
  10. package/packages/components/com-flcanvas/index.vue +314 -333
  11. package/packages/components/com-formDialog/index.vue +6 -4
  12. package/packages/components/com-graphics/component/ann-tool.vue +263 -208
  13. package/packages/components/com-graphics/index.vue +374 -773
  14. package/packages/components/com-graphics/pid.vue +304 -295
  15. package/packages/components/com-table/column-default.vue +2 -3
  16. package/packages/components/com-table/column-dynamic.vue +7 -4
  17. package/packages/components/com-table/column.vue +1 -2
  18. package/packages/components/com-table/index.vue +6 -5
  19. package/packages/components/com-tabs/index.vue +1 -2
  20. package/packages/components/com-tiles/index.vue +134 -136
  21. package/packages/components/com-treeDynamic/index.vue +1 -1
  22. package/packages/utils/StreamLoader.js +95 -36
  23. package/packages/utils/StreamLoaderParser.worker.js +9 -14
  24. package/src/main.js +2 -8
  25. package/src/utils/cloud.js +28 -28
  26. package/src/utils/cursor.js +11 -9
  27. package/src/utils/flgltf-parser.js +257 -245
  28. package/src/utils/instance-parser.js +20 -22
  29. package/src/utils/mini-devtool.js +94 -39
  30. package/src/utils/threejs/measure-angle.js +51 -13
  31. package/src/utils/threejs/measure-area.js +44 -13
  32. package/src/utils/threejs/measure-distance.js +43 -12
  33. package/src/utils/threejs/rain-shader.js +10 -10
  34. package/src/utils/threejs/snow-shader.js +9 -9
@@ -6,337 +6,346 @@
6
6
  </div>
7
7
  <embed v-show="canvasShow" type="image/svg+xml" id="svg-tigger" :src="currentSvg" />
8
8
  </div>
9
-
10
9
  </template>
11
10
  <script>
12
- import svgPanZoom from 'svg-pan-zoom';
13
- import html2canvas from 'html2canvas';
14
- import AnnTool from './component/ann-tool.vue'
15
- var svgCon = {},
16
- svgTigger = {},
17
- svgEmbed = {};
18
- var preTargetCon = [],
19
- preTargetStyle = [];
20
- var firstTime = 0,
21
- lastTime = 0;
22
- var inspectionRect = null,
23
- pointerRect = null;
24
- export default {
25
- name: 'FlSvg',
26
- props: {
27
- src: {
28
- typeof: String,
29
- default: ''
30
- }
31
- },
32
- watch: {
33
- src(newVal) {
34
- this.currentSvg = newVal
35
- }
36
- },
37
- components: {
38
- AnnTool
39
- },
40
- data() {
41
- return {
42
- currentSvg: '',
43
- activeObj: null,
44
- canvasShow: true,
45
- toolbarShow: false,
46
- svgInitStyle: {}
47
- };
11
+ import svgPanZoom from 'svg-pan-zoom';
12
+ import html2canvas from 'html2canvas';
13
+ import AnnTool from './component/ann-tool.vue';
14
+ var svgCon = {},
15
+ svgTigger = {},
16
+ svgEmbed = {};
17
+ var preTargetCon = [],
18
+ preTargetStyle = [];
19
+ var firstTime = 0,
20
+ lastTime = 0;
21
+ var inspectionRect = null,
22
+ pointerRect = null;
23
+ export default {
24
+ name: 'FlSvg',
25
+ props: {
26
+ src: {
27
+ typeof: String,
28
+ default: '',
48
29
  },
49
- created() {
50
- this.currentSvg = this.src
30
+ },
31
+ watch: {
32
+ src(newVal) {
33
+ this.currentSvg = newVal;
51
34
  },
52
- mounted() {
53
- this.$nextTick(() => {
54
- svgEmbed = document.getElementById('svg-tigger');
55
- svgEmbed.style.width = this.$refs.svgComponent.clientWidth + 'px'
56
- svgEmbed.style.height = this.$refs.svgComponent.clientHeight + 'px'
57
- svgEmbed.addEventListener('resize', () => {
58
- this.onWindowResize;
35
+ },
36
+ components: {
37
+ AnnTool,
38
+ },
39
+ data() {
40
+ return {
41
+ currentSvg: '',
42
+ activeObj: null,
43
+ canvasShow: true,
44
+ toolbarShow: false,
45
+ svgInitStyle: {},
46
+ };
47
+ },
48
+ created() {
49
+ this.currentSvg = this.src;
50
+ },
51
+ mounted() {
52
+ this.$nextTick(() => {
53
+ svgEmbed = document.getElementById('svg-tigger');
54
+ svgEmbed.style.width = this.$refs.svgComponent.clientWidth + 'px';
55
+ svgEmbed.style.height = this.$refs.svgComponent.clientHeight + 'px';
56
+ svgEmbed.addEventListener('resize', () => {
57
+ this.onWindowResize;
58
+ });
59
+ svgEmbed.addEventListener('load', () => {
60
+ preTargetCon.splice(0);
61
+ preTargetStyle.splice(0);
62
+ svgTigger = svgPanZoom('#svg-tigger', {
63
+ viewportSelector: '.svg-pan-zoom_viewport',
64
+ panEnabled: true,
65
+ zoomEnabled: true,
66
+ preventMouseEventsDefault: false,
67
+ fit: true,
68
+ center: true,
59
69
  });
60
- svgEmbed.addEventListener('load', () => {
61
- preTargetCon.splice(0)
62
- preTargetStyle.splice(0)
63
- svgTigger = svgPanZoom('#svg-tigger', {
64
- viewportSelector: '.svg-pan-zoom_viewport',
65
- panEnabled: true,
66
- zoomEnabled: true,
67
- preventMouseEventsDefault: false,
68
- fit: true,
69
- center: true
70
- });
71
- svgCon = svgEmbed.getSVGDocument().querySelector('svg');
72
- svgCon.style = 'cursor: pointer;user-select: none;';
73
- this.svgInitStyle = svgEmbed.getSVGDocument().getElementsByClassName("svg-pan-zoom_viewport")[0].getBoundingClientRect()
74
- svgCon.setAttribute('viewBox', '0 0 ' + svgEmbed.offsetWidth + ' ' + svgEmbed.offsetHeight);
75
- inspectionRect = svgCon.createSVGRect();
76
- inspectionRect.width = 10;
77
- inspectionRect.height = 10;
78
- pointerRect = svgCon.createSVGPoint();
79
- this.onWindowResize();
80
- // 禁止右键菜单栏
81
- svgCon.addEventListener('contextmenu', e => {
82
- e.preventDefault();
83
- });
84
- // 鼠标的按下与抬起事件
85
- svgCon.addEventListener('mousedown', this.mousedown);
86
- svgCon.addEventListener('mouseup', this.mouseup);
87
- // 加载完成后会通知
88
- this.$emit('loaded');
70
+ svgCon = svgEmbed.getSVGDocument().querySelector('svg');
71
+ svgCon.style = 'cursor: pointer;user-select: none;';
72
+ this.svgInitStyle = svgEmbed
73
+ .getSVGDocument()
74
+ .getElementsByClassName('svg-pan-zoom_viewport')[0]
75
+ .getBoundingClientRect();
76
+ svgCon.setAttribute('viewBox', '0 0 ' + svgEmbed.offsetWidth + ' ' + svgEmbed.offsetHeight);
77
+ inspectionRect = svgCon.createSVGRect();
78
+ inspectionRect.width = 10;
79
+ inspectionRect.height = 10;
80
+ pointerRect = svgCon.createSVGPoint();
81
+ this.onWindowResize();
82
+ // 禁止右键菜单栏
83
+ svgCon.addEventListener('contextmenu', e => {
84
+ e.preventDefault();
89
85
  });
90
- })
91
-
86
+ // 鼠标的按下与抬起事件
87
+ svgCon.addEventListener('mousedown', this.mousedown);
88
+ svgCon.addEventListener('mouseup', this.mouseup);
89
+ // 加载完成后会通知
90
+ this.$emit('loaded');
91
+ });
92
+ });
93
+ },
94
+ methods: {
95
+ changeSvg(url) {
96
+ this.$set(this, 'currentSvg', url);
97
+ preTargetCon.splice(0);
98
+ preTargetStyle.splice(0);
92
99
  },
93
- methods: {
94
- changeSvg(url) {
95
- this.$set(this, 'currentSvg', url)
96
- preTargetCon.splice(0)
97
- preTargetStyle.splice(0)
98
- },
99
- // 改变窗口大小
100
- onWindowResize() {
101
- svgCon.removeAttribute('width');
102
- svgCon.removeAttribute('height');
103
- },
104
- // 鼠标按下
105
- mousedown() {
106
- firstTime = new Date().getTime();
107
- },
108
- // 鼠标抬起
109
- mouseup(evt) {
110
- evt.stopPropagation()
111
- lastTime = new Date().getTime();
112
- let targetElement = null;
113
- // 判断鼠标按下到抬起的时间间隔是否超过300ms 没有超过 则判断为点击
114
- if (lastTime - firstTime <= 300) {
115
- if (evt.target.nodeName !== 'svg') {
116
- targetElement = evt.target;
117
- } else {
118
- pointerRect.x = evt.clientX;
119
- pointerRect.y = evt.clientY;
120
- const tp = pointerRect.matrixTransform(svgCon.getScreenCTM());
121
- inspectionRect.x = tp.x;
122
- inspectionRect.y = tp.y;
123
- const intersectionList = svgCon.getIntersectionList(inspectionRect, null);
124
- targetElement =
125
- intersectionList.length > 0 ? intersectionList[intersectionList.length - 1] : null;
126
- }
127
- if (targetElement && !targetElement.id) {
128
- this.searchSvgId(targetElement.parentNode)
129
- } else {
130
- this.activeObj = targetElement
131
- }
132
- if (evt.button === 0) {
133
- this.$emit('leftClick', this.activeObj);
134
- } else if (evt.button === 2) {
135
- console.log('rightClick')
136
- this.$emit('rightClick', {
137
- event: evt,
138
- targetObj: this.activeObj
139
- });
140
- }
100
+ // 改变窗口大小
101
+ onWindowResize() {
102
+ svgCon.removeAttribute('width');
103
+ svgCon.removeAttribute('height');
104
+ },
105
+ // 鼠标按下
106
+ mousedown() {
107
+ firstTime = new Date().getTime();
108
+ },
109
+ // 鼠标抬起
110
+ mouseup(evt) {
111
+ evt.stopPropagation();
112
+ lastTime = new Date().getTime();
113
+ let targetElement = null;
114
+ // 判断鼠标按下到抬起的时间间隔是否超过300ms 没有超过 则判断为点击
115
+ if (lastTime - firstTime <= 300) {
116
+ if (evt.target.nodeName !== 'svg') {
117
+ targetElement = evt.target;
118
+ } else {
119
+ pointerRect.x = evt.clientX;
120
+ pointerRect.y = evt.clientY;
121
+ const tp = pointerRect.matrixTransform(svgCon.getScreenCTM());
122
+ inspectionRect.x = tp.x;
123
+ inspectionRect.y = tp.y;
124
+ const intersectionList = svgCon.getIntersectionList(inspectionRect, null);
125
+ targetElement =
126
+ intersectionList.length > 0 ? intersectionList[intersectionList.length - 1] : null;
141
127
  }
142
- },
143
- // 查找对象的id
144
- searchSvgId(dom) {
145
- if (!dom.id) {
146
- this.searchSvgId(dom.parentNode)
147
- } else if (dom.id) {
148
- this.activeObj = dom
128
+ if (targetElement && !targetElement.id) {
129
+ this.searchSvgId(targetElement.parentNode);
130
+ } else {
131
+ this.activeObj = targetElement;
149
132
  }
150
- },
151
- // 高亮目标元素
152
- /*
133
+ if (evt.button === 0) {
134
+ this.$emit('leftClick', this.activeObj);
135
+ } else if (evt.button === 2) {
136
+ console.log('rightClick');
137
+ this.$emit('rightClick', {
138
+ event: evt,
139
+ targetObj: this.activeObj,
140
+ });
141
+ }
142
+ }
143
+ },
144
+ // 查找对象的id
145
+ searchSvgId(dom) {
146
+ if (!dom.id) {
147
+ this.searchSvgId(dom.parentNode);
148
+ } else if (dom.id) {
149
+ this.activeObj = dom;
150
+ }
151
+ },
152
+ // 高亮目标元素
153
+ /*
153
154
  参数:svgIds: [], 需要高亮的id的集合, flag: true / false, 是否要定位目标元素, color: '', 高亮的颜色
154
155
  */
155
- highLight(svgIds, flag = false, color) {
156
- if (svgIds === null || svgIds === undefined) {
157
- throw new Error('svgIds should be an array');
158
- } else {
159
- for (let index = 0; index < svgIds.length; index++) {
160
- let element = svgIds[index];
161
- let targetCon = svgCon.getElementById(element.svgId);
162
- console.log(targetCon)
163
- if (!targetCon) return;
164
- this.depthTraversal(targetCon.children, color);
165
- }
166
- if (flag) {
167
- svgTigger.reset();
168
- let firstCon = svgCon.getElementById(svgIds[0].svgId);
169
- setTimeout(() => {
170
- svgTigger.zoomAtPoint(4, {
171
- x: firstCon.getBoundingClientRect().x,
172
- y: firstCon.getBoundingClientRect().y,
173
- });
174
- }, 100);
175
- }
156
+ highLight(svgIds, flag = false, color) {
157
+ if (svgIds === null || svgIds === undefined) {
158
+ throw new Error('svgIds should be an array');
159
+ } else {
160
+ for (let index = 0; index < svgIds.length; index++) {
161
+ let element = svgIds[index];
162
+ let targetCon = svgCon.getElementById(element.svgId);
163
+ console.log(targetCon);
164
+ if (!targetCon) return;
165
+ this.depthTraversal(targetCon.children, color);
176
166
  }
177
- },
178
- // pid组高亮 深度遍历
179
- depthTraversal(svgCon, color) {
180
-
181
- for (let i = 0; i < svgCon.length; i++) {
182
- if (svgCon[i].children.length > 0) {
183
- this.depthTraversal(svgCon[i].children, color);
184
- } else {
185
- preTargetCon.push(svgCon[i]);
186
- preTargetStyle.push({
187
- // fillOpacity: svgCon[i].style.fillOpacity,
188
- stroke: svgCon[i].style.stroke,
189
- // strokeWidth: svgCon[i].style.strokeWidth,
190
- fill: svgCon[i].style.fill
167
+ if (flag) {
168
+ svgTigger.reset();
169
+ let firstCon = svgCon.getElementById(svgIds[0].svgId);
170
+ setTimeout(() => {
171
+ svgTigger.zoomAtPoint(4, {
172
+ x: firstCon.getBoundingClientRect().x,
173
+ y: firstCon.getBoundingClientRect().y,
191
174
  });
192
- // svgCon[i].style.fillOpacity = '0';
193
- svgCon[i].style.stroke = color;
194
- if (svgCon[i].nodeName === 'text' || (svgCon[i].style.fill && svgCon[i].style.fill!== 'none')) {
195
- (svgCon[i].style.fill = color)
196
- }
197
- // svgCon[i].style.strokeWidth = 0.5;
198
- }
175
+ }, 100);
199
176
  }
200
- },
201
- // 清除上一次的高亮
202
- resetHightLight() {
203
- for (let i = 0; i < preTargetCon.length; i++) {
204
- // preTargetCon[i].style.fillOpacity = preTargetStyle[i].fillOpacity;
205
- preTargetCon[i].style.stroke = preTargetStyle[i].stroke;
206
- // preTargetCon[i].style.strokeWidth = preTargetStyle[i].strokeWidth;
207
- preTargetCon[i].style.fill = preTargetStyle[i].fill
177
+ }
178
+ },
179
+ // pid组高亮 深度遍历
180
+ depthTraversal(svgCon, color) {
181
+ for (let i = 0; i < svgCon.length; i++) {
182
+ if (svgCon[i].children.length > 0) {
183
+ this.depthTraversal(svgCon[i].children, color);
184
+ } else {
185
+ preTargetCon.push(svgCon[i]);
186
+ preTargetStyle.push({
187
+ // fillOpacity: svgCon[i].style.fillOpacity,
188
+ stroke: svgCon[i].style.stroke,
189
+ // strokeWidth: svgCon[i].style.strokeWidth,
190
+ fill: svgCon[i].style.fill,
191
+ });
192
+ // svgCon[i].style.fillOpacity = '0';
193
+ svgCon[i].style.stroke = color;
194
+ if (
195
+ svgCon[i].nodeName === 'text' ||
196
+ (svgCon[i].style.fill && svgCon[i].style.fill !== 'none')
197
+ ) {
198
+ svgCon[i].style.fill = color;
199
+ }
200
+ // svgCon[i].style.strokeWidth = 0.5;
208
201
  }
209
- preTargetStyle.splice(0);
210
- preTargetCon.splice(0);
211
- },
212
- // 修改颜色要区分text text填充为fill
213
- // 设置对象的属性 obj是需要被修改的对象, properties是需要修改的属性{}
214
- setPorperty(obj, properties) {
215
- if (obj.children.length > 0) {
216
- let arr = obj.children
217
- for (let index = 0; index < arr.length; index++) {
218
- const element = arr[index]
219
- if (element.nodeName !== 'g') {
220
- for (const key in properties) {
221
- // 记录一下原始状态
222
- element.setAttribute(`data-${key}`, element['style'][key])
223
- if (key === 'fill') {
224
- if (element.nodeName === 'text' || (element.style.fill && element.style.fill !== 'none')) {
225
- element['style']['fill'] = properties[key]
226
- }
227
- } else {
228
- element['style'][key] = properties[key]
202
+ }
203
+ },
204
+ // 清除上一次的高亮
205
+ resetHightLight() {
206
+ for (let i = 0; i < preTargetCon.length; i++) {
207
+ // preTargetCon[i].style.fillOpacity = preTargetStyle[i].fillOpacity;
208
+ preTargetCon[i].style.stroke = preTargetStyle[i].stroke;
209
+ // preTargetCon[i].style.strokeWidth = preTargetStyle[i].strokeWidth;
210
+ preTargetCon[i].style.fill = preTargetStyle[i].fill;
211
+ }
212
+ preTargetStyle.splice(0);
213
+ preTargetCon.splice(0);
214
+ },
215
+ // 修改颜色要区分text text填充为fill
216
+ // 设置对象的属性 obj是需要被修改的对象, properties是需要修改的属性{}
217
+ setPorperty(obj, properties) {
218
+ if (obj.children.length > 0) {
219
+ let arr = obj.children;
220
+ for (let index = 0; index < arr.length; index++) {
221
+ const element = arr[index];
222
+ if (element.nodeName !== 'g') {
223
+ for (const key in properties) {
224
+ // 记录一下原始状态
225
+ element.setAttribute(`data-${key}`, element['style'][key]);
226
+ if (key === 'fill') {
227
+ if (
228
+ element.nodeName === 'text' ||
229
+ (element.style.fill && element.style.fill !== 'none')
230
+ ) {
231
+ element['style']['fill'] = properties[key];
229
232
  }
233
+ } else {
234
+ element['style'][key] = properties[key];
230
235
  }
231
236
  }
232
- if (element.children && element.children.length > 0) {
233
- this.setPorperty(element, properties)
234
- }
235
237
  }
236
- } else {
237
- if (obj.nodeName !== 'g') {
238
- for (const key in properties) {
239
- if (key === 'fill') {
240
- if (element.nodeName === 'text' || (element.style.fill && element.style.fill !== 'none')) {
241
- element['style']['fill'] = properties[fill]
242
- }
243
- } else {
244
- element['style'][key] = properties[key]
245
- }
246
- }
238
+ if (element.children && element.children.length > 0) {
239
+ this.setPorperty(element, properties);
247
240
  }
248
-
249
241
  }
250
- },
251
- resetPorperty(obj, properties) {
252
- if (obj.children.length > 0) {
253
- let arr = obj.children
254
- for (let index = 0; index < arr.length; index++) {
255
- const element = arr[index]
256
- if (element.nodeName !== 'g') {
257
- properties.forEach(item => {
258
- element['style'][item] = element.getAttribute(`data-${item}`)
259
- })
260
- }
261
- if (element.children && element.children.length > 0) {
262
- this.resetPorperty(element, properties)
242
+ } else {
243
+ if (obj.nodeName !== 'g') {
244
+ for (const key in properties) {
245
+ if (key === 'fill') {
246
+ if (
247
+ element.nodeName === 'text' ||
248
+ (element.style.fill && element.style.fill !== 'none')
249
+ ) {
250
+ element['style']['fill'] = properties[fill];
251
+ }
252
+ } else {
253
+ element['style'][key] = properties[key];
263
254
  }
264
255
  }
265
- } else {
266
- if (obj.nodeName !== 'g') {
267
- properties.forEach(item => {
268
- element['style'][item] = element.getAttribute(`data-${item}`)
269
- })
256
+ }
257
+ }
258
+ },
259
+ resetPorperty(obj, properties) {
260
+ if (obj.children.length > 0) {
261
+ let arr = obj.children;
262
+ for (let index = 0; index < arr.length; index++) {
263
+ const element = arr[index];
264
+ if (element.nodeName !== 'g') {
265
+ properties.forEach(item => {
266
+ element['style'][item] = element.getAttribute(`data-${item}`);
267
+ });
268
+ }
269
+ if (element.children && element.children.length > 0) {
270
+ this.resetPorperty(element, properties);
270
271
  }
271
272
  }
272
- },
273
- getAllNode() {
274
- let node = svgCon.querySelector('.svg-pan-zoom_viewport')
275
- if (node) {
276
- return node.children
277
- } else {
278
- return []
273
+ } else {
274
+ if (obj.nodeName !== 'g') {
275
+ properties.forEach(item => {
276
+ element['style'][item] = element.getAttribute(`data-${item}`);
277
+ });
279
278
  }
280
- },
281
- getNodeById(id) {
282
- return svgCon.getElementById(id)
283
- },
284
- // 更新图纸/切换图纸
285
- /*
279
+ }
280
+ },
281
+ getAllNode() {
282
+ let node = svgCon.querySelector('.svg-pan-zoom_viewport');
283
+ if (node) {
284
+ return node.children;
285
+ } else {
286
+ return [];
287
+ }
288
+ },
289
+ getNodeById(id) {
290
+ return svgCon.getElementById(id);
291
+ },
292
+ // 更新图纸/切换图纸
293
+ /*
286
294
  参数:url: 图纸的路径
287
295
  */
288
- switchSvg(url) {
289
- this.$set(this, 'currentSvg', url);
290
- preTargetCon.splice(0);
291
- preTargetStyle.splice(0);
292
- inspectionRect = null;
293
- pointerRect = null;
294
- },
295
- // 图纸恢复到主视图
296
- resetView() {
297
- svgTigger.reset()
298
- },
299
- saveCanvas(canvasStyle) {
300
- this.$refs.AnnToolbar.toolbarShow = false // 关闭画板工具条
301
- svgTigger.reset()
302
- svgTigger.zoom(canvasStyle.width / this.svgInitStyle.width)
303
- svgTigger.pan({ x: -(canvasStyle.scrollLeft), y: -(canvasStyle.scrollTop) })
304
- this.$nextTick(() => {
305
- this.screenShot() // 保存批注
306
- })
307
- },
308
- // 截图导出
309
- screenShot() {
310
- let shotObj = this.$refs.svgComponent
311
- html2canvas(shotObj, { allowTaint: true, useCORS: true}).then(canvas => {
312
- const link = document.createElement('a');
313
- link.href = canvas.toDataURL('image/png');
314
- link.download = 'screenshot.png';
315
- link.click();
316
- })
317
- },
318
- // 打开批注模式
319
- openAnnToolbar() {
320
- console.log('openAnnToolbar')
321
- this.canvasShow = false
322
- this.toolbarShow = true
323
- },
324
- closeAnnMode() {
325
- this.canvasShow = true
326
- this.toolbarShow = false
327
- this.$emit('closeAnn')
328
- }
296
+ switchSvg(url) {
297
+ this.$set(this, 'currentSvg', url);
298
+ preTargetCon.splice(0);
299
+ preTargetStyle.splice(0);
300
+ inspectionRect = null;
301
+ pointerRect = null;
302
+ },
303
+ // 图纸恢复到主视图
304
+ resetView() {
305
+ svgTigger.reset();
306
+ },
307
+ saveCanvas(canvasStyle) {
308
+ this.$refs.AnnToolbar.toolbarShow = false; // 关闭画板工具条
309
+ svgTigger.reset();
310
+ svgTigger.zoom(canvasStyle.width / this.svgInitStyle.width);
311
+ svgTigger.pan({ x: -canvasStyle.scrollLeft, y: -canvasStyle.scrollTop });
312
+ this.$nextTick(() => {
313
+ this.screenShot(); // 保存批注
314
+ });
315
+ },
316
+ // 截图导出
317
+ screenShot() {
318
+ let shotObj = this.$refs.svgComponent;
319
+ html2canvas(shotObj, { allowTaint: true, useCORS: true }).then(canvas => {
320
+ const link = document.createElement('a');
321
+ link.href = canvas.toDataURL('image/png');
322
+ link.download = 'screenshot.png';
323
+ link.click();
324
+ });
325
+ },
326
+ // 打开批注模式
327
+ openAnnToolbar() {
328
+ console.log('openAnnToolbar');
329
+ this.canvasShow = false;
330
+ this.toolbarShow = true;
331
+ },
332
+ closeAnnMode() {
333
+ this.canvasShow = true;
334
+ this.toolbarShow = false;
335
+ this.$emit('closeAnn');
329
336
  },
330
- };
337
+ },
338
+ };
331
339
  </script>
332
340
  <style lang="scss" scoped>
333
- #svg-component, #svg-tigger {
341
+ #svg-component,
342
+ #svg-tigger {
334
343
  cursor: pointer;
335
344
  height: 100%;
336
345
  width: 100%;
337
346
  position: relative;
338
347
  }
339
- #toolbar-show{
348
+ #toolbar-show {
340
349
  z-index: 20;
341
350
  position: absolute;
342
351
  width: 100%;
@@ -21,8 +21,7 @@
21
21
  key="index"
22
22
  :index="indexMethod"
23
23
  align="center"
24
- >
25
- </component>
24
+ ></component>
26
25
  </div>
27
26
  </template>
28
27
 
@@ -57,7 +56,7 @@ export default {
57
56
  rowDrop() {
58
57
  if (!this.comTable.$refs.table) return;
59
58
  const el = this.comTable.$refs.table.$el.querySelectorAll(this.config.dropRowClass)[0];
60
- this.comTable.tableDrop('row', el, (evt) => {
59
+ this.comTable.tableDrop('row', el, evt => {
61
60
  const oldIndex = evt.oldIndex;
62
61
  const newIndex = evt.newIndex;
63
62
  const targetRow = this.comTable.list.splice(oldIndex, 1)[0];