emacroh5lib 1.0.20 → 1.0.23

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.20",
3
+ "version": "1.0.23",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@ export namespace EMacro {
9
9
 
10
10
  public static getFileMD5(file: File): string {
11
11
 
12
- throw "NG"
12
+ throw "NG"
13
13
  }
14
14
 
15
15
  private static getBase64(blob) {
@@ -22,7 +22,9 @@ export namespace EMacro {
22
22
  }
23
23
 
24
24
  public static getFileChunks(file: any): any {
25
- let { size } = file
25
+
26
+ let {size} = file
27
+
26
28
  const sliceSize = 1024 * 1024 * 2;
27
29
  let totalChunks = Math.ceil(size / sliceSize)
28
30
  let fileChunks = new Array<any>()
@@ -40,19 +42,20 @@ export namespace EMacro {
40
42
  }
41
43
 
42
44
  // 文件上传
43
- public static uploadFiles(files, savePath, postFunc, errFunc, uploadedFunc) {
45
+ public static uploadFiles(files, postFunc, errFunc = (err) => {
46
+ console.error(err);
47
+ }) {
44
48
 
45
49
  if (files[0].fileName == "" || files[0].fileSize == "" || files[0].fileSize == 0) {
46
- throw new Error("请选择要上传的文件")
50
+ throw new Error("文件列表为空")
47
51
  }
48
52
 
49
53
  let that = this
50
54
  for (let i = 0; i < files.length; i++) {
51
- const file = files[i];
52
- let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file.file)
55
+ const file = files[i];
56
+ let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file)
53
57
  for (let index in fileChunks) {
54
58
  let chunk = fileChunks[Number(index)]
55
-
56
59
  setTimeout(async () => {
57
60
  await File.getBase64(chunk).then((base64: any) => {
58
61
  let data = {
@@ -60,16 +63,15 @@ export namespace EMacro {
60
63
  'chunksLength': chunksLength, // 分片长度
61
64
  'sliceSize': sliceSize, // 分片大小
62
65
  'chunkSize': chunk.size, // 当前分片实际大小
63
- 'fileSize': file.file.size, // 文件总大小
64
- 'fileName': file.file.name, // 文件名
66
+ 'fileSize': file.size, // 文件总大小
67
+ 'fileName': file.name, // 文件名
65
68
  'data': base64.split(';base64,')[1], // 文件数据
66
- 'lastModifiedDate': file.file.lastModifiedDate, // 最后修改时间
67
- 'dataType': 'base64', // 数据的类型
68
- 'savePath': savePath
69
+ 'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
70
+ 'dataType': 'base64' // 数据的类型
69
71
  }
70
72
  postFunc(data)
71
73
  }).catch((err) => {
72
- errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.file.name })
74
+ errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.name })
73
75
  })
74
76
  }, 10);
75
77
  }
@@ -3,15 +3,18 @@
3
3
 
4
4
  <button @click="handleOpen">打开查看器</button>
5
5
  <button @click="exportExcel($event)">透过Excel模板导出表格</button>
6
+ <button @click="selectFile($event)">选择文件</button>
6
7
 
7
8
  <image-viewer :list="srcList" @open="openCallback" @close="closeCallback" :show.sync="showViewer"
8
9
  :currentIndex="currentIndex" />
9
10
 
10
11
 
12
+
13
+
11
14
  <div class="list" id="list">
12
15
 
13
- <DragResizeView v-for="(rect, index) in rects" :key="index" :isStorage="true" :name="rect.name" :w="rect.width" :h="rect.height"
14
- :x="rect.left" :y="rect.top" :parentW="listWidth" :parentH="listHeight" :axis="rect.axis"
16
+ <DragResizeView v-for="(rect, index) in rects" :key="index" :isStorage="true" :name="rect.name" :w="rect.width"
17
+ :h="rect.height" :x="rect.left" :y="rect.top" :parentW="listWidth" :parentH="listHeight" :axis="rect.axis"
15
18
  :isActive="rect.active" :minw="rect.minw" :minh="rect.minh" :isDraggable="rect.draggable"
16
19
  :isResizable="rect.resizable" :parentLimitation="rect.parentLim" :snapToGrid="rect.snapToGrid"
17
20
  :aspectRatio="rect.aspectRatio" :z="rect.zIndex" :contentClass="rect.class" v-on:activated="activateEv(index)"
@@ -37,10 +40,15 @@ import DragResizeView from "@/views/DragResizeView/index.vue";
37
40
  import Draw from "@/views/Draw/index.vue";
38
41
 
39
42
  import { formatJson, export_json_to_excel, number_to_excel, testToExcel } from "./Export2Excel"
43
+ import { EMacro } from "../../utilities/File";
44
+
45
+ import axios from 'axios'
46
+ import Cookie from 'js-cookie'
40
47
 
41
48
 
42
49
 
43
50
  import LAY_EXCEL from 'lay-excel';
51
+ import { error } from "jquery";
44
52
 
45
53
  @Component({
46
54
  components: {
@@ -199,6 +207,37 @@ export default class TestView extends Vue {
199
207
  LAY_EXCEL.exportExcel(list, '表格导出.xlsx', 'xlsx')
200
208
  }
201
209
 
210
+ public selectFile(e) {
211
+
212
+
213
+ EMacro.File.selectFile().then((files) => {
214
+ EMacro.File.uploadFiles(files, file => {
215
+
216
+ file.savePath = "C:\\MES\\EMacroAndroidServer_Windows_v1.1\\EMacroAssets\\file\\" + file.fileName
217
+
218
+ let postData = { 'id': 0, 'message': '', 'action': 'uploadSOPFile', 'user': {}, 'data': file }
219
+ axios.post("http://121.228.113.68:8019/H5/prod/Command/requestVueData", postData, {
220
+ timeout: 6000,
221
+ headers: {
222
+ Authorization: "Basic RU1hY3JvOkVNYWNybw==",
223
+ "Content-Type": "application/json;charset=UTF-8",
224
+ }
225
+ }).then(data => {
226
+
227
+ console.log("上传返回", data);
228
+
229
+ }).catch(err => {
230
+ console.error("上传错误: ", err);
231
+ })
232
+
233
+ })
234
+
235
+ }).catch(err => {
236
+ console.error(err);
237
+ })
238
+
239
+ }
240
+
202
241
  activateEv(index) {
203
242
  console.log("activateEv index", index);
204
243
  }
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "declarationMap": false, // 是否生成声明文件map文件(便于调试)
12
12
  "moduleResolution": "node",
13
13
  "module": "esnext",
14
- "target": "es6", // 转化成的目标语言
14
+ "target": "esnext", // 转化成的目标语言
15
15
  "baseUrl": "./",
16
16
  "strict": true,
17
17
  "jsx": "preserve",