emacroh5lib 1.0.21 → 1.0.22

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.21",
3
+ "version": "1.0.22",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -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,16 +42,18 @@ export namespace EMacro {
40
42
  }
41
43
 
42
44
  // 文件上传
43
- public static uploadFiles(files, postFunc, errFunc: (err) => {}) {
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
59
  setTimeout(async () => {
@@ -59,15 +63,15 @@ export namespace EMacro {
59
63
  'chunksLength': chunksLength, // 分片长度
60
64
  'sliceSize': sliceSize, // 分片大小
61
65
  'chunkSize': chunk.size, // 当前分片实际大小
62
- 'fileSize': file.file.size, // 文件总大小
63
- 'fileName': file.file.name, // 文件名
66
+ 'fileSize': file.size, // 文件总大小
67
+ 'fileName': file.name, // 文件名
64
68
  'data': base64.split(';base64,')[1], // 文件数据
65
- 'lastModifiedDate': file.file.lastModifiedDate, // 最后修改时间
69
+ 'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
66
70
  'dataType': 'base64' // 数据的类型
67
71
  }
68
72
  postFunc(data)
69
73
  }).catch((err) => {
70
- errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.file.name })
74
+ errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.name })
71
75
  })
72
76
  }, 10);
73
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,40 @@ 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
+
215
+ EMacro.File.uploadFiles(files, file => {
216
+
217
+
218
+ file.savePath = "C:\\MES\\EMacroAndroidServer_Windows_v1.1\\EMacroAssets\\file\\" + file.fileName
219
+
220
+
221
+ let postData = { 'id': 0, 'message': '', 'action': 'uploadSOPFile', 'user': {}, 'data': file }
222
+ axios.post("http://121.228.113.68:8019/H5/prod/Command/requestVueData", postData, {
223
+ timeout: 6000,
224
+ headers: {
225
+ Authorization: "Basic RU1hY3JvOkVNYWNybw==",
226
+ "Content-Type": "application/json;charset=UTF-8",
227
+ }
228
+ }).then(data => {
229
+
230
+ console.log("上传返回", data);
231
+
232
+ }).catch(err => {
233
+ console.error("上传错误: ", err);
234
+ })
235
+
236
+ })
237
+
238
+ }).catch(err => {
239
+ console.error(err);
240
+ })
241
+
242
+ }
243
+
202
244
  activateEv(index) {
203
245
  console.log("activateEv index", index);
204
246
  }