emacroh5lib 1.0.83 → 1.0.85

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emacroh5lib",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -95,7 +95,6 @@
95
95
  "register-service-worker": "^1.7.2",
96
96
  "sync-task-queue": "^1.0.4",
97
97
  "three": "^0.139.2",
98
- "types": "file:../../browser-md5-file",
99
98
  "typings": "^2.1.1",
100
99
  "vue": "^2.6.14",
101
100
  "vue-class-component": "^7.2.3",
@@ -103,7 +102,6 @@
103
102
  "vue-property-decorator": "^9.1.2",
104
103
  "vue-tsx-support": "^3.2.0",
105
104
  "vuex": "^3.6.2",
106
- "xlsx": "^0.18.5",
107
- "xlsx-style": "^0.8.13"
105
+ "xlsx": "^0.18.5"
108
106
  }
109
- }
107
+ }
@@ -0,0 +1,29 @@
1
+ <!-- 下拉可编辑输入框 -->
2
+ <div style="position:relative;">
3
+ <select v-model='faultAction' onchange="this.nextElementSibling.value=''">
4
+ <option v-for="(item, index) in optionListAction">{{ fieldsMap[item] || $t(item) }}</option>
5
+ </select>
6
+ <input class="select-input" type="text" value="" autocomplete="off" @input="(item)=>{this.faultAction = item.target.value}" />
7
+ </div>
8
+
9
+
10
+
11
+ .select-input {
12
+ position: absolute;
13
+ top: 0px;
14
+ left: 0px;
15
+ right: 5px;
16
+ height: 100%;
17
+ padding: 0px;
18
+ margin-left: 5px;
19
+ font-size: 17px !important;
20
+ border: none !important;
21
+ background-color: transparent;
22
+ outline: transparent !important;
23
+ border: transparent !important;
24
+ box-shadow: none !important;
25
+
26
+ &:focus {
27
+ outline: none;
28
+ }
29
+ }
@@ -0,0 +1,189 @@
1
+ /**
2
+ * echarts tooltip 自动轮播
3
+ * @author dalalalalaa
4
+ * @param chart
5
+ * @param chartOption
6
+ * @param options
7
+ * {
8
+ * interval 轮播时间间隔,单位毫秒,默认为2000
9
+ * loopSeries boolean类型,默认为false。
10
+ * true表示循环所有series的tooltip,false则显示指定seriesIndex的tooltip
11
+ * seriesIndex 默认为0,指定某个系列(option中的series索引)循环显示tooltip,
12
+ * 当loopSeries为true时,从seriesIndex系列开始执行.
13
+ * }
14
+ * @returns {{clearLoop: clearLoop}}
15
+ */
16
+ const loopShowTooltip = function (chart, chartOption, options) {
17
+ var defaultOptions = {
18
+ interval: 3000,
19
+ loopSeries: true,
20
+ seriesIndex: 0,
21
+ updateData: null,
22
+ };
23
+
24
+ if (!chart) {
25
+ return {};
26
+ }
27
+ if (!chartOption) {
28
+ chartOption = chart.getOption();
29
+ }
30
+
31
+ var dataIndex = 0; // 数据索引,初始化为-1,是为了判断是否是第一次执行
32
+ var seriesIndex = 0; // 系列索引
33
+ var timeTicket = 0;
34
+ var seriesLen = chartOption.series.length; // 系列个数
35
+ var dataLen = 0; // 某个系列数据个数
36
+ var chartType; // 系列类型
37
+ var first = true;
38
+
39
+ // 不循环series时seriesIndex指定显示tooltip的系列,不指定默认为0,指定多个则默认为第一个
40
+ // 循环series时seriesIndex指定循环的series,不指定则从0开始循环所有series,指定单个则相当于不循环,指定多个
41
+ // 要不要添加开始series索引和开始的data索引?
42
+
43
+ if (options) {
44
+ options.interval = options.interval || defaultOptions.interval;
45
+ options.loopSeries = options.loopSeries || defaultOptions.loopSeries;
46
+ options.seriesIndex = options.seriesIndex || defaultOptions.seriesIndex;
47
+ options.updateData = options.updateData || defaultOptions.updateData;
48
+ } else {
49
+ options = defaultOptions;
50
+ }
51
+
52
+ // 如果设置的seriesIndex无效,则默认为0
53
+ if (options.seriesIndex < 0 || options.seriesIndex >= seriesLen) {
54
+ seriesIndex = 0;
55
+ } else {
56
+ seriesIndex = options.seriesIndex;
57
+ }
58
+
59
+ function autoShowTip() {
60
+ function showTip() {
61
+ // 判断是否更新数据
62
+ if (
63
+ dataIndex === 0 &&
64
+ !first &&
65
+ typeof options.updateData === 'function'
66
+ ) {
67
+ options.updateData();
68
+ chart.setOption(chartOption);
69
+ }
70
+
71
+ var series = chartOption.series;
72
+ chartType = series[seriesIndex].type; // 系列类型
73
+ dataLen = series[seriesIndex].data.length; // 某个系列的数据个数
74
+
75
+ var tipParams = { seriesIndex: seriesIndex };
76
+ switch (chartType) {
77
+ case 'map':
78
+ case 'pie':
79
+ case 'chord':
80
+ tipParams.name = series[seriesIndex].data[dataIndex].name;
81
+ break;
82
+ case 'radar': // 雷达图
83
+ tipParams.seriesIndex = seriesIndex;
84
+ tipParams.dataIndex = dataIndex;
85
+ break;
86
+ default:
87
+ tipParams.dataIndex = dataIndex;
88
+ break;
89
+ }
90
+
91
+ if (chartType === 'pie' || chartType === 'radar') {
92
+ // 取消之前高亮的图形
93
+ chart.dispatchAction({
94
+ type: 'downplay',
95
+ seriesIndex: options.loopSeries
96
+ ? seriesIndex === 0
97
+ ? seriesLen - 1
98
+ : seriesIndex - 1
99
+ : seriesIndex,
100
+ dataIndex: dataIndex === 0 ? dataLen - 1 : dataIndex - 1,
101
+ });
102
+
103
+ // 高亮当前图形
104
+ chart.dispatchAction({
105
+ type: 'highlight',
106
+ seriesIndex: seriesIndex,
107
+ dataIndex: dataIndex,
108
+ });
109
+ }
110
+
111
+ // 显示 tooltip
112
+ tipParams.type = 'showTip';
113
+ chart.dispatchAction(tipParams);
114
+
115
+ dataIndex = (dataIndex + 1) % dataLen;
116
+ if (options.loopSeries && dataIndex === 0 && !first) {
117
+ // 数据索引归0表示当前系列数据已经循环完
118
+ seriesIndex = (seriesIndex + 1) % seriesLen;
119
+ }
120
+
121
+ first = false;
122
+ }
123
+
124
+ showTip();
125
+ timeTicket = setInterval(showTip, options.interval);
126
+ }
127
+
128
+ // 关闭轮播
129
+ function stopAutoShow() {
130
+ if (timeTicket) {
131
+ clearInterval(timeTicket);
132
+ timeTicket = 0;
133
+
134
+ if (chartType === 'pie' || chartType === 'radar') {
135
+ // 取消高亮的图形
136
+ chart.dispatchAction({
137
+ type: 'downplay',
138
+ seriesIndex: options.loopSeries
139
+ ? seriesIndex === 0
140
+ ? seriesLen - 1
141
+ : seriesIndex - 1
142
+ : seriesIndex,
143
+ dataIndex: dataIndex === 0 ? dataLen - 1 : dataIndex - 1,
144
+ });
145
+ }
146
+ }
147
+ }
148
+
149
+ var zRender = chart.getZr();
150
+
151
+ function zRenderMouseMove(param) {
152
+ if (param.event) {
153
+ // 阻止canvas上的鼠标移动事件冒泡
154
+ param.event.cancelBubble = true;
155
+ }
156
+
157
+ stopAutoShow();
158
+ }
159
+
160
+ // 离开echarts图时恢复自动轮播
161
+ function zRenderGlobalOut() {
162
+ if (!timeTicket) {
163
+ autoShowTip();
164
+ }
165
+ }
166
+
167
+ // 鼠标在echarts图上时停止轮播
168
+ chart.on('mousemove', stopAutoShow);
169
+ zRender.on('mousemove', zRenderMouseMove);
170
+ zRender.on('globalout', zRenderGlobalOut);
171
+
172
+ autoShowTip();
173
+
174
+ return {
175
+ clearLoop: function () {
176
+ if (timeTicket) {
177
+ clearInterval(timeTicket);
178
+ timeTicket = 0;
179
+ }
180
+ chart.off('mousemove', stopAutoShow);
181
+ zRender.off('mousemove', zRenderMouseMove);
182
+ zRender.off('globalout', zRenderGlobalOut);
183
+ },
184
+ };
185
+ };
186
+
187
+
188
+ export { loopShowTooltip };
189
+
@@ -1,9 +1,16 @@
1
1
 
2
- import * as XLSX from "xlsx";
2
+ import XLSX from "xlsx";
3
+ // import XLSX from "./dist/xlsx.js";
4
+
5
+
6
+
7
+ // const XLSX = require("./dist/xlsx.js")
3
8
  import BMF from 'browser-md5-file';
4
9
 
5
10
  import createTaskQueue from 'sync-task-queue'
6
11
 
12
+ import { saveAs } from 'file-saver';
13
+
7
14
  export namespace EMacro {
8
15
 
9
16
  export const version = "1.72"
@@ -147,6 +154,31 @@ export namespace EMacro {
147
154
  })
148
155
  }
149
156
 
157
+ // type: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string'
158
+ public static toExcel(data, type) {
159
+ let workbook = XLSX.read(data, { type: type });
160
+ return workbook;
161
+ }
162
+
163
+ public static downloadExcel(workbook, name) {
164
+
165
+ /* bookType can be 'xlsx' or 'xlsm' or 'xlsb' */
166
+ const wopts:any = { bookType: 'xls', bookSST: false, type: 'binary', cellStyles: true };
167
+
168
+ var wbout = XLSX.write(workbook, wopts);
169
+
170
+ function s2ab(s) {
171
+ var buf = new ArrayBuffer(s.length);
172
+ var view = new Uint8Array(buf);
173
+ for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
174
+ return buf;
175
+ }
176
+
177
+ /* the saveAs call downloads a file on the local machine */
178
+ saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), name)
179
+
180
+ }
181
+
150
182
  }
151
183
 
152
184
  export const fullScreen = (docElm: any = null) => {
@@ -251,12 +283,12 @@ export namespace EMacro {
251
283
  return base64;
252
284
  }
253
285
 
254
- export function getType(values){
286
+ export function getType(values) {
255
287
  return Object
256
288
  .prototype
257
289
  .toString
258
290
  .call(values)
259
- .replace(/\[(\S+) (\S+)\]/,'$2')
291
+ .replace(/\[(\S+) (\S+)\]/, '$2')
260
292
  }
261
293
 
262
294
  export const extensionToLowerCase = (fileName: string) => {
@@ -13,7 +13,6 @@ import { Component, Prop, Vue } from "vue-property-decorator";
13
13
  import $ from "jquery";
14
14
 
15
15
  import { saveAs } from 'file-saver';
16
- import XLSX from "xlsx-style";
17
16
 
18
17
  import * as echarts from "echarts";
19
18
 
@@ -3,7 +3,7 @@
3
3
  <div class="duo-viewer-mask">
4
4
  <div id="WebGL-output" class="duo-viewer-mask__image" :style="viewerStyle()" v-loading="loading"
5
5
  element-loading-text="模型加载中" element-loading-spinner="el-icon-loading"
6
- element-loading-background="rgba(0, 0, 0, 0.8)">
6
+ element-loading-background="rgba(0, 0, 0, 0.0)">
7
7
  </div>
8
8
  </div>
9
9
  <div class="duo-viewer-footer" v-if="showThumbnail">
@@ -128,6 +128,10 @@
128
128
  showThumbnail: {
129
129
  type: Boolean,
130
130
  default: false,
131
+ },
132
+ background: {
133
+ type: Number,
134
+ default: 0xb9d3ff,
131
135
  }
132
136
  },
133
137
  computed: {
@@ -159,7 +163,7 @@
159
163
  mounted() {
160
164
 
161
165
  // this.show = true
162
-
166
+
163
167
 
164
168
 
165
169
  // Message.success("按键提示 ");
@@ -182,8 +186,6 @@
182
186
  return scale;
183
187
  },
184
188
 
185
-
186
-
187
189
  viewerStyle() {
188
190
  return `width:${this.width};height:${this.height};`
189
191
  },
@@ -363,8 +365,10 @@
363
365
 
364
366
  // 计算空间两点中点
365
367
  getCenterPosition(A, B) {
366
- let pos = { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2, z: (A.z + B.z) / 2 }
367
- return pos
368
+ if (A.z == null || B.z == null) {
369
+ return { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2 }
370
+ }
371
+ return { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2, z: (A.z + B.z) / 2 }
368
372
  },
369
373
 
370
374
 
@@ -407,6 +411,12 @@
407
411
  this.loading = false
408
412
 
409
413
 
414
+ const keyEvent = new KeyboardEvent('keydown', {
415
+ bubbles: true, cancelable: true, keyCode: 90
416
+ });
417
+ document.dispatchEvent(keyEvent);
418
+
419
+
410
420
 
411
421
 
412
422
 
@@ -742,6 +752,7 @@
742
752
  this.gl.pointLight = pointLight
743
753
  pointLight.position.set(200, 300, 10); //点光源位置,参数分别代表:
744
754
  this.gl.scene.add(pointLight);
755
+ this.gl.scene.background = null;
745
756
  //环境光
746
757
  let ambient = new THREE.AmbientLight(0x444444, 1);
747
758
  this.gl.ambient = ambient
@@ -761,9 +772,9 @@
761
772
  /**
762
773
  * 创建渲染器对象
763
774
  */
764
- this.gl.renderer = new THREE.WebGLRenderer();
775
+ this.gl.renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
765
776
  this.gl.renderer.setSize(width, height); //设置渲染区域尺寸
766
- this.gl.renderer.setClearColor(0xb9d3ff, 1); //设置背景颜色
777
+ this.gl.renderer.setClearColor(this.background, this.background == null ? 0 : 1); //设置背景颜色
767
778
 
768
779
  this.gl.WebGLoutput.innerHTML = ""
769
780
  this.gl.renderer.domElement.style.width = "100%"
@@ -850,6 +861,20 @@
850
861
  })
851
862
 
852
863
 
864
+ document.addEventListener("keydown", event => {
865
+
866
+ if (event.key == '') {
867
+ const gl = this.gl
868
+ const zd = gl.camera.position.z !== 0 ? -gl.camera.position.z : -d
869
+ gl.camera.position.set(0, 0, zd);
870
+ gl.camera.lookAt(new THREE.Vector3(0, 0, 0));
871
+ gl.ambient.position.set(0, 0, zd);
872
+ gl.pointLight.position.set(0, 0, zd);
873
+ gl.axialDirection = zd > 0 ? 'z' : '-z';
874
+ }
875
+
876
+ })
877
+
853
878
 
854
879
  document.addEventListener("keyup", event => {
855
880
 
@@ -29,6 +29,7 @@
29
29
  z-index: 8;
30
30
  /* transition-property: transform, height, width; */
31
31
  transition-duration: 0.3s, 0.3s, 0.3s;
32
+ background: transparent;
32
33
  }
33
34
  .duo-viewer-footer {
34
35
  position: absolute;
@@ -1,6 +1,5 @@
1
1
 
2
- import * as XLSX from 'xlsx'
3
- import * as XLSXS from 'xlsx-style'
2
+ import * as XLSX from 'xlsx'
4
3
  import { saveAs } from 'file-saver'
5
4
  import { BookType } from 'xlsx';
6
5
 
@@ -6,10 +6,11 @@
6
6
  <button @click="exportExcel($event)">透过Excel模板导出表格</button>
7
7
  <button @click="selectFile($event)">选择文件</button>
8
8
  <button @click="fileMD5($event)">文件MD5</button>
9
+ <button @click="excelTest()">Excel测试</button>
9
10
 
10
11
  <image-viewer :list="srcList" @open="openCallback" @close="closeCallback" :show.sync="showViewer"
11
12
  :currentIndex="currentIndex" />
12
-
13
+
13
14
  <div class="list" id="list" v-if="false">
14
15
  <DragResizeView v-for="(rect, index) in rects" :key="index" :isStorage="true" :name="rect.name" :w="rect.width"
15
16
  :h="rect.height" :x="rect.left" :y="rect.top" :parentW="listWidth" :parentH="listHeight" :axis="rect.axis"
@@ -25,9 +26,9 @@
25
26
  <Draw v-if="false">
26
27
  <div class="filler2">111</div>
27
28
  </Draw>
28
-
29
+
29
30
  <!-- <video-viewer :list="srcList" :show.sync="showVideoViewer" width="80%" height="80%" /> -->
30
- <model-viewer :list="modelList" :show.sync="showModelViewer" width="80%" height="80%" />
31
+ <model-viewer :list="modelList" :show.sync="showModelViewer" width="90%" height="90%" :background="null" />
31
32
 
32
33
  </div>
33
34
  </template>
@@ -46,6 +47,7 @@
46
47
  import LAY_EXCEL from 'lay-excel';
47
48
  import BMF from 'browser-md5-file';
48
49
  import { info } from "console";
50
+ import base64 from "./txt.js";
49
51
 
50
52
 
51
53
  @Component({
@@ -62,6 +64,7 @@
62
64
  })
63
65
  export default class TestView extends Vue {
64
66
 
67
+
65
68
  public currentIndex: Number = 0; // 打开图片查看器时,需要定位到的图片的索引
66
69
  public srcList: Array<String> = [
67
70
  "http://emacrosys.cn:8069/H5/GetFile?type=0&path=C:\\SOP\\PCB001\\看板整体图.png",
@@ -190,6 +193,21 @@
190
193
  }
191
194
  ]
192
195
 
196
+
197
+ public excelTest() {
198
+
199
+ console.log("测试", base64);
200
+ const workbook = EMacro.File.toExcel(base64, "base64")
201
+ // console.log("测试", workbook.Sheets["Sheet1"]["A23"]);
202
+
203
+ // workbook.Sheets["Sheet1"]["A23"].v = "测试abc"
204
+ // console.log("测试", workbook.Sheets["Sheet1"]["A23"]);
205
+ // console.log("测试", workbook);
206
+
207
+ EMacro.File.downloadExcel(workbook, "Report2222.xls");
208
+
209
+ }
210
+
193
211
  public exportExcel(e): void {
194
212
  console.log('event', e);
195
213
 
@@ -292,22 +310,16 @@
292
310
  if (files == null) {
293
311
  return
294
312
  }
295
-
296
313
  EMacro.File.getFileMD5(files[0]).then(md5 => {
297
-
298
314
  console.log("文件MD5", md5);
299
-
300
315
  })
301
316
 
302
-
303
317
  // new MD5().update(buffer).digest()
304
318
 
305
-
306
319
  // const hash = crypto
307
320
  // .createHash('md5')
308
321
  // .update(files[0], 'utf8')
309
322
  // .digest('hex');
310
-
311
323
  })
312
324
 
313
325