@zhijiancloud/bpm 0.0.7 → 0.0.8
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 +3 -4
- package/components/.DS_Store +0 -0
- package/components/api/batch-loader.js +0 -61
- package/components/api/index.js +0 -108
- package/components/css/bpmAudit.less +0 -13
- package/components/css/bpmMulFile.less +0 -62
- package/components/css/bpmSelectCheckItem.less +0 -4
- package/components/css/bpmSelectEntranceForm.less +0 -62
- package/components/css/bpmSelectFromForm.less +0 -10
- package/components/css/bpmSelectFromId.less +0 -33
- package/components/css/bpmSelectHouseOwner.less +0 -30
- package/components/css/bpmSignature.less +0 -40
- package/components/css/bpmText.less +0 -39
- package/components/css/common.less +0 -43
- package/components/css/demo.less +0 -3
- package/components/css/demo2.less +0 -3
- package/components/css/index.less +0 -8
- package/components/lib/bpmAudit/index.js +0 -7
- package/components/lib/bpmAudit/src/main.vue +0 -117
- package/components/lib/bpmAudit/src/part/auditor/audit-new.vue +0 -534
- package/components/lib/bpmAudit/src/part/auditor/audit-select.vue +0 -127
- package/components/lib/bpmAudit/src/part/auditor/audit-with-others.vue +0 -634
- package/components/lib/bpmAudit/src/part/auditor.vue +0 -54
- package/components/lib/bpmAudit/src/part/editor.vue +0 -318
- package/components/lib/bpmAudit/src/part/reader.vue +0 -218
- package/components/lib/bpmDateTime/index.js +0 -7
- package/components/lib/bpmDateTime/src/main.vue +0 -82
- package/components/lib/bpmDateTime/src/part/editor.vue +0 -126
- package/components/lib/bpmDateTime/src/part/reader.vue +0 -55
- package/components/lib/bpmField/index.js +0 -7
- package/components/lib/bpmField/src/main.vue +0 -31
- package/components/lib/bpmFieldsFilter/index.js +0 -7
- package/components/lib/bpmFieldsFilter/src/main.vue +0 -324
- package/components/lib/bpmFormField/index.js +0 -7
- package/components/lib/bpmFormField/src/lib/form_mixin.js +0 -818
- package/components/lib/bpmFormField/src/lib/mixin.js +0 -245
- package/components/lib/bpmFormField/src/main.vue +0 -35
- package/components/lib/bpmMulFile/index.js +0 -7
- package/components/lib/bpmMulFile/src/main.vue +0 -85
- package/components/lib/bpmMulFile/src/part/editor.vue +0 -433
- package/components/lib/bpmMulFile/src/part/lib/compressImageUtils.js +0 -226
- package/components/lib/bpmMulFile/src/part/lib/utils.js +0 -281
- package/components/lib/bpmMulFile/src/part/reader.vue +0 -282
- package/components/lib/bpmMulImage/index.js +0 -7
- package/components/lib/bpmMulImage/src/main.vue +0 -86
- package/components/lib/bpmMulImage/src/part/editor.vue +0 -449
- package/components/lib/bpmMulImage/src/part/lib/compressImageUtils.js +0 -226
- package/components/lib/bpmMulImage/src/part/lib/utils.js +0 -281
- package/components/lib/bpmMulImage/src/part/reader.vue +0 -181
- package/components/lib/bpmNumber/index.js +0 -7
- package/components/lib/bpmNumber/src/main.vue +0 -83
- package/components/lib/bpmNumber/src/part/editor.vue +0 -47
- package/components/lib/bpmNumber/src/part/reader.vue +0 -7
- package/components/lib/bpmSelect/index.js +0 -7
- package/components/lib/bpmSelect/src/main.vue +0 -90
- package/components/lib/bpmSelect/src/part/editor.vue +0 -75
- package/components/lib/bpmSelect/src/part/reader.vue +0 -53
- package/components/lib/bpmSelectCheckItem/index.js +0 -7
- package/components/lib/bpmSelectCheckItem/src/main.vue +0 -101
- package/components/lib/bpmSelectCheckItem/src/part/editor.vue +0 -103
- package/components/lib/bpmSelectCheckItem/src/part/reader.vue +0 -7
- package/components/lib/bpmSelectEntranceForm/index.js +0 -7
- package/components/lib/bpmSelectEntranceForm/src/main.vue +0 -529
- package/components/lib/bpmSelectFromField/index.js +0 -7
- package/components/lib/bpmSelectFromField/src/main.vue +0 -98
- package/components/lib/bpmSelectFromField/src/part/editor.vue +0 -96
- package/components/lib/bpmSelectFromField/src/part/reader.vue +0 -7
- package/components/lib/bpmSelectFromForm/index.js +0 -7
- package/components/lib/bpmSelectFromForm/src/main.vue +0 -103
- package/components/lib/bpmSelectFromForm/src/part/editor.vue +0 -178
- package/components/lib/bpmSelectFromForm/src/part/reader.vue +0 -7
- package/components/lib/bpmSelectFromId/index.js +0 -7
- package/components/lib/bpmSelectFromId/src/main.vue +0 -102
- package/components/lib/bpmSelectFromId/src/part/editor.vue +0 -260
- package/components/lib/bpmSelectFromId/src/part/reader.vue +0 -7
- package/components/lib/bpmSelectHouseOwner/index.js +0 -7
- package/components/lib/bpmSelectHouseOwner/src/main.vue +0 -102
- package/components/lib/bpmSelectHouseOwner/src/part/editor.vue +0 -101
- package/components/lib/bpmSelectHouseOwner/src/part/reader.vue +0 -17
- package/components/lib/bpmSelectIssue/index.js +0 -7
- package/components/lib/bpmSelectIssue/src/main.vue +0 -180
- package/components/lib/bpmSignature/index.js +0 -7
- package/components/lib/bpmSignature/src/main.vue +0 -248
- package/components/lib/bpmSubForm/index.js +0 -7
- package/components/lib/bpmSubForm/src/main.vue +0 -203
- package/components/lib/bpmText/index.ts +0 -13
- package/components/lib/bpmText/src/main.vue +0 -87
- package/components/lib/bpmText/src/part/editor.vue +0 -104
- package/components/lib/bpmText/src/part/reader.vue +0 -7
- package/components/lib/bpmTime/index.js +0 -7
- package/components/lib/bpmTime/src/main.vue +0 -83
- package/components/lib/bpmTime/src/part/editor.vue +0 -55
- package/components/lib/bpmTime/src/part/reader.vue +0 -24
- package/components/lib/demo/index.js +0 -7
- package/components/lib/demo/src/main.vue +0 -11
- package/components/lib/demo2/index.js +0 -7
- package/components/lib/demo2/src/main.vue +0 -11
- package/components/lib/field-const.js +0 -472
- package/components/lib/index.ts +0 -102
- package/components/lib/mixins/RemoteSelectReader.vue +0 -55
- package/components/lib/mixins/TextReader.vue +0 -22
- package/components/lib/net.js +0 -21
- package/components/lib/utils.js +0 -89
- package/components/mixins/field_base_mixin.vue +0 -188
- package/components/sfc.d.ts +0 -27
- package/components/vendor/draw.js +0 -240
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="bpm-mul-file-edit">
|
|
3
|
-
<el-upload
|
|
4
|
-
ref="uploader"
|
|
5
|
-
:action="url"
|
|
6
|
-
name="userfile"
|
|
7
|
-
:show-file-list="false"
|
|
8
|
-
multiple
|
|
9
|
-
:limit="maxCount"
|
|
10
|
-
:accept="extensions"
|
|
11
|
-
:before-upload="handleAdd"
|
|
12
|
-
:on-success="onUploaded"
|
|
13
|
-
:on-error="onFail"
|
|
14
|
-
:file-list="fileList"
|
|
15
|
-
>
|
|
16
|
-
<el-button size="small" type="primary" slot="trigger" :disabled="disabled">点击上传</el-button>
|
|
17
|
-
</el-upload>
|
|
18
|
-
<div class="row gutter-sm q-my-sm file-list">
|
|
19
|
-
<template v-if="curVal && curVal.length">
|
|
20
|
-
<viewer
|
|
21
|
-
:images="photo"
|
|
22
|
-
rebuild
|
|
23
|
-
class="row gutter-sm q-my-sm file-list"
|
|
24
|
-
style="width: 100%"
|
|
25
|
-
@inited="inited"
|
|
26
|
-
>
|
|
27
|
-
<div class="col-12 file-box" v-for="item in curVal" :key="item.md5">
|
|
28
|
-
<span class="file-content" @click="previewImg(item)" v-if="isImageFile(item)">
|
|
29
|
-
<img class="preview-img" :src="fileLink(item)" />
|
|
30
|
-
</span>
|
|
31
|
-
<span @click="preview(item)" v-else class="file-content q-mb-xs">
|
|
32
|
-
<div class="text-left text-faded">
|
|
33
|
-
<i
|
|
34
|
-
aria-hidden="true"
|
|
35
|
-
class="q-icon fa fa-file-pdf-o"
|
|
36
|
-
:class="getFileTypeClass(item)"
|
|
37
|
-
></i>
|
|
38
|
-
</div>
|
|
39
|
-
</span>
|
|
40
|
-
<div
|
|
41
|
-
class="relative-position file-link ellipsis"
|
|
42
|
-
:title="item.name"
|
|
43
|
-
>
|
|
44
|
-
{{ item.name }}
|
|
45
|
-
</div>
|
|
46
|
-
<div class="file-remove" @click="remove(item.md5, item)">
|
|
47
|
-
<span class="operation-btn">删除</span>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</viewer>
|
|
51
|
-
</template>
|
|
52
|
-
<template v-else>
|
|
53
|
-
<div class="col-auto" style="padding-top: 0px; font-size: 12px">
|
|
54
|
-
<!-- {{ $z("未发现上传文件", "b2.common.not_found_file") }} -->
|
|
55
|
-
未发现上传文件
|
|
56
|
-
</div>
|
|
57
|
-
</template>
|
|
58
|
-
</div>
|
|
59
|
-
<el-dialog
|
|
60
|
-
:visible.sync="opened"
|
|
61
|
-
class="file-modal"
|
|
62
|
-
:before-close="onHide"
|
|
63
|
-
@open="onOpen"
|
|
64
|
-
title="文件预览"
|
|
65
|
-
:fullscreen="true"
|
|
66
|
-
v-bind="$attrs"
|
|
67
|
-
v-on="$listeners"
|
|
68
|
-
>
|
|
69
|
-
<iframe :src="officeUrl" width="99%" :height="windowH"></iframe>
|
|
70
|
-
</el-dialog>
|
|
71
|
-
<img id="image" src="" style="display: none" />
|
|
72
|
-
<div
|
|
73
|
-
id="container"
|
|
74
|
-
style="height: 100px; width: 109px; display: none"
|
|
75
|
-
></div>
|
|
76
|
-
</div>
|
|
77
|
-
</template>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<script>
|
|
81
|
-
import _ from "lodash";
|
|
82
|
-
import { Upload, Button, Dialog } from "element-ui";
|
|
83
|
-
import { urlAppendParam, isMobile } from "../../../utils";
|
|
84
|
-
|
|
85
|
-
Vue.use(Upload);
|
|
86
|
-
Vue.use(Button);
|
|
87
|
-
Vue.use(Dialog);
|
|
88
|
-
import Vue from "vue";
|
|
89
|
-
import Viewer from "v-viewer";
|
|
90
|
-
import "viewerjs/dist/viewer.css";
|
|
91
|
-
import "font-awesome/css/font-awesome.min.css"
|
|
92
|
-
const piexif = require("piexifjs");
|
|
93
|
-
import { comparessImg, ImageTool } from "./lib/compressImageUtils";
|
|
94
|
-
import { showGPSInfo, getFileType, gethashcode } from "./lib/utils";
|
|
95
|
-
Vue.use(Viewer);
|
|
96
|
-
Viewer.setDefaults({
|
|
97
|
-
Options: {
|
|
98
|
-
inline: true,
|
|
99
|
-
button: true,
|
|
100
|
-
navbar: true,
|
|
101
|
-
title: true,
|
|
102
|
-
toolbar: true,
|
|
103
|
-
tooltip: true,
|
|
104
|
-
movable: true,
|
|
105
|
-
zoomable: true,
|
|
106
|
-
rotatable: true,
|
|
107
|
-
scalable: true,
|
|
108
|
-
transition: true,
|
|
109
|
-
fullscreen: true,
|
|
110
|
-
keyboard: true,
|
|
111
|
-
url: "data-source",
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
var AMap = null;
|
|
115
|
-
export default {
|
|
116
|
-
props: {
|
|
117
|
-
value: {},
|
|
118
|
-
fieldConf: {},
|
|
119
|
-
row: {},
|
|
120
|
-
extensions: {
|
|
121
|
-
type: String,
|
|
122
|
-
default() {
|
|
123
|
-
return ".gif,jpg,.jpeg,.png,.doc,.xlsx,.pdf,.docx,.xls,.dwg";
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
data() {
|
|
128
|
-
return {
|
|
129
|
-
curVal: [],
|
|
130
|
-
fileList: [],
|
|
131
|
-
opened: false,
|
|
132
|
-
officeUrl: "",
|
|
133
|
-
windowH: 0
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
watch: {
|
|
137
|
-
curVal(val) {
|
|
138
|
-
this.$emit("input", val);
|
|
139
|
-
},
|
|
140
|
-
value(){
|
|
141
|
-
this.curVal = this.value
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
computed: {
|
|
145
|
-
url() {
|
|
146
|
-
return _.get(
|
|
147
|
-
this.fieldConf,
|
|
148
|
-
"upload_url",
|
|
149
|
-
"/platform/v1/papi/app_file/upload/"
|
|
150
|
-
);
|
|
151
|
-
},
|
|
152
|
-
photo() {
|
|
153
|
-
let list = [];
|
|
154
|
-
_.each(this.curVal, (item) => {
|
|
155
|
-
if (this.isImageFile(item)) {
|
|
156
|
-
let link = this.fileLink(item, 600);
|
|
157
|
-
list.push(link);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
return list;
|
|
161
|
-
},
|
|
162
|
-
photoMd5s() {
|
|
163
|
-
let list = [];
|
|
164
|
-
_.each(this.curVal, (item) => {
|
|
165
|
-
if (this.isImageFile(item)) {
|
|
166
|
-
list.push(item.md5);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
return list;
|
|
170
|
-
},
|
|
171
|
-
maxCountConf() {
|
|
172
|
-
return _.get(this.fieldConf, "check.max_count");
|
|
173
|
-
},
|
|
174
|
-
maxCount() {
|
|
175
|
-
return this.maxCountConf - this.curVal && this.curVal.length;
|
|
176
|
-
},
|
|
177
|
-
disabled() {
|
|
178
|
-
let val = this.curVal ? this.curVal : []
|
|
179
|
-
return val.length >= this.maxCountConf;
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
created() {
|
|
183
|
-
// getAgent.register();
|
|
184
|
-
},
|
|
185
|
-
mounted() {
|
|
186
|
-
this.curVal = this.value;
|
|
187
|
-
this.windowH = (document.body.clientHeight / 100) * 99 - 50;
|
|
188
|
-
|
|
189
|
-
//获取定位信息,写入图片
|
|
190
|
-
this.appendJs(
|
|
191
|
-
`https://webapi.amap.com/maps?v=1.4.15&key=c2195d5de1c163ebfb118bad93c8bbd3`,
|
|
192
|
-
() => {
|
|
193
|
-
var mapObj = new AMap.Map("container", {
|
|
194
|
-
resizeEnable: true,
|
|
195
|
-
});
|
|
196
|
-
mapObj.plugin("AMap.Geolocation", () => {
|
|
197
|
-
let geolocation = new AMap.Geolocation({
|
|
198
|
-
enableHighAccuracy: true, //是否使用高精度定位,默认:true
|
|
199
|
-
timeout: 10000, //超过10秒后停止定位,默认:无穷大
|
|
200
|
-
maximumAge: 0, //定位结果缓存0毫秒,默认:0
|
|
201
|
-
convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
|
|
202
|
-
showButton: true, //显示定位按钮,默认:true
|
|
203
|
-
buttonPosition: "LB", //定位按钮停靠位置,默认:'LB',左下角
|
|
204
|
-
buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
205
|
-
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
|
|
206
|
-
showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
|
|
207
|
-
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
|
|
208
|
-
zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
209
|
-
});
|
|
210
|
-
mapObj.addControl(geolocation);
|
|
211
|
-
geolocation.getCurrentPosition();
|
|
212
|
-
AMap.event.addListener(geolocation, "complete", (result) => {
|
|
213
|
-
this.position = result.position;
|
|
214
|
-
}); //返回定位信息
|
|
215
|
-
AMap.event.addListener(geolocation, "error", (err) => {
|
|
216
|
-
console.log("定位出错-error", err);
|
|
217
|
-
}); //返回定位出错信息
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
},
|
|
222
|
-
methods: {
|
|
223
|
-
appendJs(url) {
|
|
224
|
-
let link = document.createElement("script");
|
|
225
|
-
let attrMap = {
|
|
226
|
-
type: "text/javascript",
|
|
227
|
-
async: /^http/.test(url) ? "async" : "",
|
|
228
|
-
src: url
|
|
229
|
-
}
|
|
230
|
-
for (var key in attrMap) {
|
|
231
|
-
link[key] = attrMap[key]
|
|
232
|
-
}
|
|
233
|
-
document.head.appendChild(link);
|
|
234
|
-
},
|
|
235
|
-
inited(viewer) {
|
|
236
|
-
viewer.options.view = this.view;
|
|
237
|
-
this.$viewer = viewer;
|
|
238
|
-
},
|
|
239
|
-
view(e) {
|
|
240
|
-
let index = e.detail.index;
|
|
241
|
-
let list = _.filter(this.curVal, (item) => {
|
|
242
|
-
return this.isImageFile(item);
|
|
243
|
-
});
|
|
244
|
-
let item = _.get(list, index);
|
|
245
|
-
showGPSInfo(item);
|
|
246
|
-
},
|
|
247
|
-
previewImg(item) {
|
|
248
|
-
let index = _.indexOf(this.photoMd5s, item.md5);
|
|
249
|
-
this.$viewer.view(index);
|
|
250
|
-
},
|
|
251
|
-
isDwg(item) {
|
|
252
|
-
return _.endsWith(item.name, ".dwg");
|
|
253
|
-
},
|
|
254
|
-
getFileTypeClass(item) {
|
|
255
|
-
let fileSuffix = getFileType(item.type);
|
|
256
|
-
fileSuffix = fileSuffix ? fileSuffix : getFileType(item.name);
|
|
257
|
-
|
|
258
|
-
if (_.endsWith(item.name, ".dwg")) {
|
|
259
|
-
fileSuffix = "dwg";
|
|
260
|
-
}
|
|
261
|
-
let typeMap = {
|
|
262
|
-
document: "fa-file-word-o",
|
|
263
|
-
sheet: "fa-file-excel-o",
|
|
264
|
-
doc: "fa-file-word-o",
|
|
265
|
-
docx: "fa-file-word-o",
|
|
266
|
-
xlsx: "fa-file-excel-o",
|
|
267
|
-
"ms-excel": "fa-file-excel-o",
|
|
268
|
-
dwg: "fa-file-image-o",
|
|
269
|
-
png: "fa-file-image-o",
|
|
270
|
-
jpg: "fa-file-image-o",
|
|
271
|
-
};
|
|
272
|
-
return _.get(typeMap, fileSuffix);
|
|
273
|
-
},
|
|
274
|
-
handleAdd() {
|
|
275
|
-
//图片进行压缩和地理信息写入
|
|
276
|
-
let queue = this.fileList;
|
|
277
|
-
_.each(queue, (file, index) => {
|
|
278
|
-
comparessImg(file, (result, hasExif) => {
|
|
279
|
-
if (result) {
|
|
280
|
-
ImageTool.getSegments(new Blob([file]), (segments) => {
|
|
281
|
-
let newFile = this.dataURLtoFile(result, file.name);
|
|
282
|
-
let exifInfo = ImageTool.getEXIF(segments); //获取exif信息
|
|
283
|
-
if (!_.isEmpty(exifInfo) && hasExif) {
|
|
284
|
-
ImageTool.insertEXIF(newFile, exifInfo, (newImage) => {
|
|
285
|
-
let bolb = new Blob([newImage], {
|
|
286
|
-
type: file.type,
|
|
287
|
-
});
|
|
288
|
-
bolb.name = file.name;
|
|
289
|
-
bolb.lastModifiedDate = new Date();
|
|
290
|
-
this.fileList[index] = bolb;
|
|
291
|
-
});
|
|
292
|
-
} else {
|
|
293
|
-
let zeroth = {};
|
|
294
|
-
let exif = {};
|
|
295
|
-
let gps = {};
|
|
296
|
-
zeroth[piexif.ImageIFD.Make] = "lse";
|
|
297
|
-
//经纬度写入
|
|
298
|
-
let lat = this.position.lat;
|
|
299
|
-
let lng = this.position.lng;
|
|
300
|
-
gps[piexif.GPSIFD.GPSLatitudeRef] = lat < 0 ? "S" : "N";
|
|
301
|
-
gps[piexif.GPSIFD.GPSLatitude] =
|
|
302
|
-
piexif.GPSHelper.degToDmsRational(lat);
|
|
303
|
-
gps[piexif.GPSIFD.GPSLongitudeRef] = lng < 0 ? "W" : "E";
|
|
304
|
-
gps[piexif.GPSIFD.GPSLongitude] =
|
|
305
|
-
piexif.GPSHelper.degToDmsRational(lng);
|
|
306
|
-
//方位角写入
|
|
307
|
-
gps[piexif.GPSIFD.GPSImgDirection] = [123456, 100];
|
|
308
|
-
let exifObj = { "0th": zeroth, Exif: exif, GPS: gps }; // 定义一个 exifObj 对象
|
|
309
|
-
let exifStr = piexif.dump(exifObj); // 通过 piexif 将 exifObj 对象转换为字符串
|
|
310
|
-
let resultBase64 = piexif.insert(exifStr, result);
|
|
311
|
-
let newFile = this.dataURLtoFile(resultBase64, file.name);
|
|
312
|
-
this.fileList[index] = newFile;
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
// this.$refs.uploader.submit();
|
|
319
|
-
},
|
|
320
|
-
dataURLtoFile(dataurl, filename) {
|
|
321
|
-
//将base64转换为文件
|
|
322
|
-
let arr = dataurl.split(","),
|
|
323
|
-
mime = arr[0].match(/:(.*?);/)[1],
|
|
324
|
-
bstr = atob(arr[1]),
|
|
325
|
-
n = bstr.length,
|
|
326
|
-
u8arr = new Uint8Array(n);
|
|
327
|
-
while (n--) {
|
|
328
|
-
u8arr[n] = bstr.charCodeAt(n);
|
|
329
|
-
}
|
|
330
|
-
return new File([u8arr], filename, { type: mime });
|
|
331
|
-
},
|
|
332
|
-
isImageFile(item) {
|
|
333
|
-
return _.startsWith(item.type, "image");
|
|
334
|
-
},
|
|
335
|
-
itemSideImageAttr(item) {
|
|
336
|
-
let attrs = {};
|
|
337
|
-
if (this.isImageFile(item)) {
|
|
338
|
-
attrs.image = this.fileLink(item);
|
|
339
|
-
} else {
|
|
340
|
-
attrs.icon = "fa fa-file";
|
|
341
|
-
}
|
|
342
|
-
return attrs;
|
|
343
|
-
},
|
|
344
|
-
fileLink(item) {
|
|
345
|
-
//获取预览的文件或图片地址
|
|
346
|
-
if (!item || !item.md5) return;
|
|
347
|
-
let isImg = this.isImageFile(item);
|
|
348
|
-
let args = {
|
|
349
|
-
file_md5: item.md5,
|
|
350
|
-
};
|
|
351
|
-
// let token = zj.utils.pageParam().token;
|
|
352
|
-
// if (token) {
|
|
353
|
-
// args.token = token;
|
|
354
|
-
// }
|
|
355
|
-
|
|
356
|
-
if (isImg) {
|
|
357
|
-
// args.webp = 1
|
|
358
|
-
// args.width = 600;
|
|
359
|
-
} else {
|
|
360
|
-
args.is_file = 1;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return urlAppendParam("/platform/v1/papi/web_file/image_view/", args);
|
|
364
|
-
},
|
|
365
|
-
async preview(item) {
|
|
366
|
-
if (item.type == "dwg/dwg") return;
|
|
367
|
-
let res = await zj.net.w.noapi({
|
|
368
|
-
url: `/platform/v1/papi/app_file/download/?file_md5=${item.md5}&webp=0`,
|
|
369
|
-
});
|
|
370
|
-
let preview_url = _.get(res, "url_list.0.path.0");
|
|
371
|
-
let fileSuffix = getFileType(preview_url);
|
|
372
|
-
if (item.type == "application/pdf") fileSuffix = "pdf";
|
|
373
|
-
if (item.type == "application/vnd.ms-excel") fileSuffix = "ms-excel";
|
|
374
|
-
let typeMap = {
|
|
375
|
-
document: "Word.Document",
|
|
376
|
-
docx: "Word.Document",
|
|
377
|
-
doc: "Word.Document",
|
|
378
|
-
sheet: "Excel.Sheet",
|
|
379
|
-
pdf: "pdf",
|
|
380
|
-
xlsx: "Excel.Sheet",
|
|
381
|
-
"ms-excel": "Excel.Sheet",
|
|
382
|
-
};
|
|
383
|
-
let hash = gethashcode();
|
|
384
|
-
let url = `https://${window.location.host}/zj_of/v1/papi/file/read_only/?md5=${item.md5}&type=${typeMap[fileSuffix]}&sign=${hash}`;
|
|
385
|
-
let result = await zj.net.w.noapi({
|
|
386
|
-
url: `/zj_of/v1/papi/file/using_engine/`,
|
|
387
|
-
});
|
|
388
|
-
if (result.engine != "wps")
|
|
389
|
-
url =
|
|
390
|
-
"https://view.officeapps.live.com/op/embed.aspx?src=" +
|
|
391
|
-
encodeURIComponent(preview_url);
|
|
392
|
-
if (fileSuffix == "pdf") {
|
|
393
|
-
let index = preview_url.lastIndexOf(".com");
|
|
394
|
-
preview_url = preview_url.substring(index + 4, preview_url.length);
|
|
395
|
-
preview_url = encodeURIComponent(preview_url);
|
|
396
|
-
if (isMobile())
|
|
397
|
-
url = `/public/app3/bpm/view_pdf.html?url=${preview_url}`;
|
|
398
|
-
else url = `/public/bpm/app/view_pdf.html?url=${preview_url}`;
|
|
399
|
-
}
|
|
400
|
-
this.officeUrl = url;
|
|
401
|
-
this.opened = true;
|
|
402
|
-
},
|
|
403
|
-
onFail(err, file) {
|
|
404
|
-
let message = `${file.name}上传失败`;
|
|
405
|
-
console.log("err:", message)
|
|
406
|
-
},
|
|
407
|
-
onUploaded(response, file) {
|
|
408
|
-
console.log("file", file)
|
|
409
|
-
|
|
410
|
-
let items = _.isArray(this.curVal) ? this.curVal : [];
|
|
411
|
-
|
|
412
|
-
items.push({
|
|
413
|
-
name: file.name,
|
|
414
|
-
type: _.get(file, "raw.type"),
|
|
415
|
-
md5: _.get(response, "data.file_md5"),
|
|
416
|
-
});
|
|
417
|
-
this.curVal = _.cloneDeep(items);
|
|
418
|
-
console.log("this.curVal", this.curVal)
|
|
419
|
-
},
|
|
420
|
-
remove(md5) {
|
|
421
|
-
this.curVal = _.filter(this.curVal, (item) => item.md5 != md5);
|
|
422
|
-
this.$refs.uploader.queue = [];
|
|
423
|
-
},
|
|
424
|
-
onHide() {
|
|
425
|
-
this.opened = false;
|
|
426
|
-
},
|
|
427
|
-
onOpen() {
|
|
428
|
-
this.opened = true;
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
};
|
|
432
|
-
</script>
|
|
433
|
-
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import Exif from 'exif-js'
|
|
2
|
-
// let Orientation
|
|
3
|
-
export function comparessImg(file, callback) {
|
|
4
|
-
//判断是否为图片文件
|
|
5
|
-
if (file.type.indexOf('image') == -1) {
|
|
6
|
-
callback(null)
|
|
7
|
-
} else {
|
|
8
|
-
|
|
9
|
-
let reader = new FileReader();
|
|
10
|
-
let image = new Image();
|
|
11
|
-
reader.readAsDataURL(file);
|
|
12
|
-
reader.onload = function () {
|
|
13
|
-
file.src = this.result;
|
|
14
|
-
image.onload = function () {
|
|
15
|
-
let width = image.width;
|
|
16
|
-
let height = image.height;
|
|
17
|
-
file.width = width;
|
|
18
|
-
file.height = height;
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
image.src = file.src; //页面上显示所选择的图片
|
|
22
|
-
imgCompress(file, {
|
|
23
|
-
quality: 0.4
|
|
24
|
-
}, file, callback)
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function imgCompress(path, obj, file, callback) { //path是指上传的图片,obj是压缩的品质,越低越模糊
|
|
32
|
-
var img = new Image();
|
|
33
|
-
img.src = path.src;
|
|
34
|
-
img.onload = function () {
|
|
35
|
-
var that = this; //这里的this 是把img的对象指向改变为that
|
|
36
|
-
// 默认按比例压缩
|
|
37
|
-
var w = that.width,
|
|
38
|
-
h = that.height,
|
|
39
|
-
scale = w / h;
|
|
40
|
-
w = obj.width || w;
|
|
41
|
-
h = obj.height || (w / scale);
|
|
42
|
-
var quality = 0.7; // 默认图片质量为0.7
|
|
43
|
-
//生成canvas
|
|
44
|
-
var canvas = document.createElement('canvas');
|
|
45
|
-
var ctx = canvas.getContext('2d');
|
|
46
|
-
// 创建属性节点
|
|
47
|
-
var anw = document.createAttribute("width");
|
|
48
|
-
anw.nodeValue = w;
|
|
49
|
-
var anh = document.createAttribute("height");
|
|
50
|
-
anh.nodeValue = h;
|
|
51
|
-
canvas.setAttributeNode(anw);
|
|
52
|
-
canvas.setAttributeNode(anh);
|
|
53
|
-
try {
|
|
54
|
-
Exif.getData(file, function () {
|
|
55
|
-
let GPSLatitude = Exif.getTag(this, 'GPSLatitude')
|
|
56
|
-
// Orientation = Exif.getTag(this, 'Orientation');
|
|
57
|
-
// console.log("Orientation", Orientation)
|
|
58
|
-
// if (Orientation == 6) {
|
|
59
|
-
// // canvas.width= that.height;
|
|
60
|
-
// // canvas.height= that.width;
|
|
61
|
-
// // ctx.rotate(0.5*Math.PI);
|
|
62
|
-
// // ctx.drawImage(that, 0, -h, w, h);
|
|
63
|
-
// }
|
|
64
|
-
// else{
|
|
65
|
-
// ctx.drawImage(that, 0, 0, w, h);
|
|
66
|
-
// }
|
|
67
|
-
ctx.drawImage(that, 0, 0, w, h);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// 图像质量
|
|
71
|
-
if (obj.quality && obj.quality <= 1 && obj.quality > 0) {
|
|
72
|
-
quality = obj.quality;
|
|
73
|
-
}
|
|
74
|
-
// quality值越小,所绘制出的图像越模糊
|
|
75
|
-
var base64 = canvas.toDataURL('image/jpeg', quality);
|
|
76
|
-
// 回调函数返回base64的值
|
|
77
|
-
// debugger
|
|
78
|
-
callback(base64, GPSLatitude)
|
|
79
|
-
})
|
|
80
|
-
} catch (error) {
|
|
81
|
-
ctx.drawImage(that, 0, 0, w, h);
|
|
82
|
-
if (obj.quality && obj.quality <= 1 && obj.quality > 0) {
|
|
83
|
-
quality = obj.quality;
|
|
84
|
-
}
|
|
85
|
-
// quality值越小,所绘制出的图像越模糊
|
|
86
|
-
var base64 = canvas.toDataURL('image/jpeg', quality);
|
|
87
|
-
// 回调函数返回base64的值
|
|
88
|
-
// debugger
|
|
89
|
-
callback(base64, null)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function convertBase64UrlToBlob(urlData) {
|
|
103
|
-
var arr = urlData.split(','),
|
|
104
|
-
mime = arr[0].match(/:(.*?);/)[1],
|
|
105
|
-
bstr = atob(arr[1]),
|
|
106
|
-
n = bstr.length,
|
|
107
|
-
u8arr = new Uint8Array(n);
|
|
108
|
-
while (n--) {
|
|
109
|
-
u8arr[n] = bstr.charCodeAt(n);
|
|
110
|
-
}
|
|
111
|
-
return new Blob([u8arr], {
|
|
112
|
-
type: mime
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
export var ImageTool = {
|
|
118
|
-
|
|
119
|
-
/*
|
|
120
|
-
* @param resizedImg{ArrayBuffer|Blob}
|
|
121
|
-
* @param exifArr{Array|Uint8Array}
|
|
122
|
-
*/
|
|
123
|
-
insertEXIF: function (resizedImg, exifArr, callback) {
|
|
124
|
-
if (resizedImg instanceof Blob) {
|
|
125
|
-
var that = this;
|
|
126
|
-
var fileReader = new FileReader();
|
|
127
|
-
fileReader.onload = function () {
|
|
128
|
-
that.insertEXIF(fileReader.result, exifArr, callback);
|
|
129
|
-
};
|
|
130
|
-
fileReader.readAsArrayBuffer(resizedImg);
|
|
131
|
-
} else {
|
|
132
|
-
var arr = [].slice.call(new Uint8Array(resizedImg), 0);
|
|
133
|
-
if (arr[2] !== 0xff || arr[3] !== 0xe0) {
|
|
134
|
-
// throw new Error("Couldn't find APP0 marker from resized image data.");
|
|
135
|
-
return resizedImg; //不是标准的JPEG文件
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
var app0_length = arr[4] * 256 + arr[5]; //两个字节
|
|
139
|
-
|
|
140
|
-
var newImage = [0xff, 0xd8].concat(exifArr, arr.slice(4 + app0_length)); //合并文件 SOI + EXIF + 去除APP0的图像信息
|
|
141
|
-
|
|
142
|
-
callback(new Uint8Array(newImage));
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
/*
|
|
146
|
-
* @param segments{Array|Uint8Array}
|
|
147
|
-
*/
|
|
148
|
-
getEXIF: function (segments) {
|
|
149
|
-
if (!segments.length) {
|
|
150
|
-
return [];
|
|
151
|
-
}
|
|
152
|
-
var seg = [];
|
|
153
|
-
for (var x = 0; x < segments.length; x++) {
|
|
154
|
-
var s = segments[x];
|
|
155
|
-
//TODO segments
|
|
156
|
-
if (s[0] === 0xff && s[1] === 0xe1) { // app1 exif 0xff 0xe1
|
|
157
|
-
seg = seg.concat(s);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return seg;
|
|
161
|
-
},
|
|
162
|
-
getSegments: function (rawImage, callback) {
|
|
163
|
-
if (rawImage instanceof Blob) {
|
|
164
|
-
var that = this;
|
|
165
|
-
var fileReader = new FileReader();
|
|
166
|
-
fileReader.onload = function () {
|
|
167
|
-
that.getSegments(fileReader.result,
|
|
168
|
-
callback);
|
|
169
|
-
};
|
|
170
|
-
fileReader.readAsArrayBuffer(rawImage);
|
|
171
|
-
} else {
|
|
172
|
-
if (!rawImage.length && !rawImage.byteLength) {
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
175
|
-
var head = 0,
|
|
176
|
-
segments = [];
|
|
177
|
-
var length, endPoint, seg;
|
|
178
|
-
var arr = [].slice.call(new Uint8Array(rawImage), 0);
|
|
179
|
-
let x = 1
|
|
180
|
-
while (x) {
|
|
181
|
-
if (arr[head] === 0xff && arr[head + 1] === 0xda) { //Start of Scan 0xff 0xda SOS
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
if (arr[head] === 0xff && arr[head +
|
|
185
|
-
1] === 0xd8) { //Start of Image 0xff 0xd8 SOI
|
|
186
|
-
head += 2;
|
|
187
|
-
} else { //找到每个marker
|
|
188
|
-
length = arr[head + 2] * 256 + arr[head + 3]; //每个marker 后 的两个字节为 该marker信息的长度
|
|
189
|
-
endPoint = head + length + 2;
|
|
190
|
-
seg = arr.slice(head, endPoint); //截取信息
|
|
191
|
-
head = endPoint;
|
|
192
|
-
segments.push(seg); //将每个marker + 信息 push 进去。
|
|
193
|
-
}
|
|
194
|
-
if (head > arr.length) {
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
callback(segments);
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
/*
|
|
202
|
-
*@param base64{String}
|
|
203
|
-
*/
|
|
204
|
-
decode64: function (base64) {
|
|
205
|
-
var b64 = "data:image/jpeg;base64,";
|
|
206
|
-
if (base64.slice(0, 23) !== b64) {
|
|
207
|
-
return [];
|
|
208
|
-
}
|
|
209
|
-
var binStr = window.atob(base64.replace(b64, ""));
|
|
210
|
-
var buf = new Uint8Array(binStr.length);
|
|
211
|
-
for (var i = 0, len = binStr.length; i < len; i++) {
|
|
212
|
-
buf[i] = binStr.charCodeAt(i);
|
|
213
|
-
}
|
|
214
|
-
return buf;
|
|
215
|
-
},
|
|
216
|
-
/*
|
|
217
|
-
*@param arr{Array}
|
|
218
|
-
*/
|
|
219
|
-
encode64: function (arr) {
|
|
220
|
-
var data = "";
|
|
221
|
-
for (var i = 0, len = arr.length; i < len; i++) {
|
|
222
|
-
data += String.fromCharCode(arr[i]);
|
|
223
|
-
}
|
|
224
|
-
return "data:image/jpeg;base64," + window.btoa(data);
|
|
225
|
-
}
|
|
226
|
-
};
|