cloud-web-corejs 1.0.54-dev.780 → 1.0.54-dev.782
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 +1 -1
- package/src/components/VabUpload/index.vue +242 -239
- package/src/components/VabUpload/mixins.js +1971 -1888
- package/src/components/obsUpload/index.vue +234 -231
- package/src/components/obsUpload/mixins.js +1542 -1476
- package/src/components/vb-tabs/x-tabs.vue +7 -3
- package/src/components/xform/docs//346/240/221/350/241/250rowField/346/224/266/346/225/233-/350/220/275/345/234/260/346/226/207/346/241/243.md +1427 -0
- package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +2 -2
- package/src/components/xform/form-designer/form-widget/dialog/formDrawer.vue +2 -2
- package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +2 -2
- package/src/components/xform/form-designer/form-widget/field-widget/baseAttachment-widget.vue +1 -0
- package/src/components/xform/form-designer/form-widget/field-widget/copy_button-widget.vue +11 -2
- package/src/components/xform/form-designer/form-widget/field-widget/vabUpload-widget.vue +369 -368
- package/src/components/xform/form-designer/setting-panel/property-editor/field-baseAttachment/baseAttachment-fileTypes-editor.vue +23 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload/vabUpload-fileTypes-editor.vue +23 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/fileTypesEditorMixin.js +116 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/fileTypesSelect.vue +176 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +7 -3
- package/src/components/xform/form-render/container-item/data-table-item.vue +1 -1
- package/src/components/xform/form-render/container-item/data-table-mixin.js +1469 -428
- package/src/components/xform/form-render/indexMixin.js +379 -240
- package/src/components/xform/lang/en-US.js +13 -0
- package/src/components/xform/lang/zh-CN.js +13 -0
- package/src/components/xform/mixins/defaultHandle.js +234 -28
- package/src/components/xform/mixins/scriptHttp.js +4 -4
- package/src/components/xform/utils/treeTableUtil.js +1265 -0
- package/src/components/xform/utils/util.js +29 -14
- package/src/microRouter/index.js +3 -0
- package/src/mixins/tableTree/index.js +77 -14
- package/src/utils/menuAdapter.js +277 -277
- package/src/utils/resolveViewComponent.js +203 -198
- package/src/utils/vab.js +6 -3
- package/src/views/user/form/vform/render.vue +17 -2
- package/src/views/user/form/view/list.vue +11 -10
|
@@ -1,368 +1,369 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<form-item-wrapper
|
|
3
|
-
:designer="designer"
|
|
4
|
-
:field="field"
|
|
5
|
-
:rules="rules"
|
|
6
|
-
:design-state="designState"
|
|
7
|
-
:parent-widget="parentWidget"
|
|
8
|
-
:parent-list="parentList"
|
|
9
|
-
:index-of-parent-list="indexOfParentList"
|
|
10
|
-
:sub-form-row-index="subFormRowIndex"
|
|
11
|
-
:sub-form-col-index="subFormColIndex"
|
|
12
|
-
:sub-form-row-id="subFormRowId"
|
|
13
|
-
>
|
|
14
|
-
<div id="uploadImage" class="upload-img" v-if="designState">
|
|
15
|
-
<div
|
|
16
|
-
class="el-upload el-upload--picture"
|
|
17
|
-
style="vertical-align: middle; display: inline-block; float: left"
|
|
18
|
-
>
|
|
19
|
-
<button type="button" class="avatar-uploader">
|
|
20
|
-
<i class="el-icon-plus avatar-uploader-icon"></i>
|
|
21
|
-
</button>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
<baseUpload
|
|
25
|
-
accept="file"
|
|
26
|
-
:file.sync="fieldModel"
|
|
27
|
-
:hidePasteArea.sync="isH5"
|
|
28
|
-
:uploadDialogCustomClass="isH5 ? 'dialog-upload-h5' : null"
|
|
29
|
-
:pickPrivateProfile="false"
|
|
30
|
-
:multi="field.options.limit !== 1"
|
|
31
|
-
:limit="field.options.limit"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
:
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
:
|
|
41
|
-
:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
let
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
[res]
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
reader
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
//
|
|
323
|
-
// const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
this.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<form-item-wrapper
|
|
3
|
+
:designer="designer"
|
|
4
|
+
:field="field"
|
|
5
|
+
:rules="rules"
|
|
6
|
+
:design-state="designState"
|
|
7
|
+
:parent-widget="parentWidget"
|
|
8
|
+
:parent-list="parentList"
|
|
9
|
+
:index-of-parent-list="indexOfParentList"
|
|
10
|
+
:sub-form-row-index="subFormRowIndex"
|
|
11
|
+
:sub-form-col-index="subFormColIndex"
|
|
12
|
+
:sub-form-row-id="subFormRowId"
|
|
13
|
+
>
|
|
14
|
+
<div id="uploadImage" class="upload-img" v-if="designState">
|
|
15
|
+
<div
|
|
16
|
+
class="el-upload el-upload--picture"
|
|
17
|
+
style="vertical-align: middle; display: inline-block; float: left"
|
|
18
|
+
>
|
|
19
|
+
<button type="button" class="avatar-uploader">
|
|
20
|
+
<i class="el-icon-plus avatar-uploader-icon"></i>
|
|
21
|
+
</button>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<baseUpload
|
|
25
|
+
accept="file"
|
|
26
|
+
:file.sync="fieldModel"
|
|
27
|
+
:hidePasteArea.sync="isH5"
|
|
28
|
+
:uploadDialogCustomClass="isH5 ? 'dialog-upload-h5' : null"
|
|
29
|
+
:pickPrivateProfile="false"
|
|
30
|
+
:multi="field.options.limit !== 1"
|
|
31
|
+
:limit="field.options.limit"
|
|
32
|
+
:fileTypes="field.options.fileTypes || []"
|
|
33
|
+
resultType="Array"
|
|
34
|
+
:edit="!field.options.disabled"
|
|
35
|
+
:remove="!field.options.hideRemoveButton"
|
|
36
|
+
@callback="submitFile"
|
|
37
|
+
:hideInfo="field.options.hideFileInfo"
|
|
38
|
+
:hideName="field.options.hideFileName"
|
|
39
|
+
:showSize="!!field.options.showFileSize"
|
|
40
|
+
:createBy="!!field.options.showFileCreateBy"
|
|
41
|
+
:createDate="!!field.options.showFileCreateDate"
|
|
42
|
+
:widgetSize="field.options.fileShowImageSize"
|
|
43
|
+
v-else
|
|
44
|
+
></baseUpload>
|
|
45
|
+
</form-item-wrapper>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
import FormItemWrapper from "./form-item-wrapper";
|
|
50
|
+
import emitter from "../../../../../components/xform/utils/emitter";
|
|
51
|
+
import i18n from "../../../../../components/xform/utils/i18n";
|
|
52
|
+
import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
name: "vabUpload-widget",
|
|
56
|
+
componentName: "FieldWidget", //必须固定为FieldWidget,用于接收父级组件的broadcast事件
|
|
57
|
+
mixins: [emitter, fieldMixin, i18n],
|
|
58
|
+
props: {
|
|
59
|
+
field: Object,
|
|
60
|
+
parentWidget: Object,
|
|
61
|
+
parentList: Array,
|
|
62
|
+
indexOfParentList: Number,
|
|
63
|
+
designer: Object,
|
|
64
|
+
|
|
65
|
+
designState: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false,
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
subFormRowIndex: {
|
|
71
|
+
/* 子表单组件行索引,从0开始计数 */ type: Number,
|
|
72
|
+
default: -1,
|
|
73
|
+
},
|
|
74
|
+
subFormColIndex: {
|
|
75
|
+
/* 子表单组件列索引,从0开始计数 */ type: Number,
|
|
76
|
+
default: -1,
|
|
77
|
+
},
|
|
78
|
+
subFormRowId: {
|
|
79
|
+
/* 子表单组件行Id,唯一id且不可变 */ type: String,
|
|
80
|
+
default: "",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
components: {
|
|
84
|
+
FormItemWrapper,
|
|
85
|
+
},
|
|
86
|
+
inject: ["refList", "globalOptionData", "globalModel", "getFormConfig"],
|
|
87
|
+
data() {
|
|
88
|
+
return {
|
|
89
|
+
oldFieldValue: [], //field组件change之前的值
|
|
90
|
+
fieldModel: [],
|
|
91
|
+
rules: [],
|
|
92
|
+
isH5: false,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
watch: {
|
|
96
|
+
fieldModel(val) {
|
|
97
|
+
this.handleChangeEvent(val);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
computed: {
|
|
101
|
+
formDataId() {
|
|
102
|
+
let formRef = this.getFormRef();
|
|
103
|
+
return formRef.dataId;
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
beforeCreate() {
|
|
107
|
+
/* 这里不能访问方法和属性!! */
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
created() {
|
|
111
|
+
/* 注意:子组件mounted在父组件created之后、父组件mounted之前触发,故子组件mounted需要用到的prop
|
|
112
|
+
需要在父组件created中初始化!! */
|
|
113
|
+
|
|
114
|
+
this.isH5 = this.getFormConfig().layoutType === "H5";
|
|
115
|
+
|
|
116
|
+
this.initFieldModel();
|
|
117
|
+
this.registerToRefList();
|
|
118
|
+
this.initEventHandler();
|
|
119
|
+
this.buildFieldRules();
|
|
120
|
+
|
|
121
|
+
this.handleOnCreated();
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
mounted() {
|
|
125
|
+
this.handleOnMounted();
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
beforeDestroy() {
|
|
129
|
+
this.unregisterFromRefList();
|
|
130
|
+
},
|
|
131
|
+
methods: {
|
|
132
|
+
setValue(val) {
|
|
133
|
+
let data = val || [];
|
|
134
|
+
this.fieldModel = data;
|
|
135
|
+
this.getFormRef().formDataModel[this.fieldKeyName] = data;
|
|
136
|
+
},
|
|
137
|
+
loadDataDefaultHandle() {
|
|
138
|
+
let dataId = this.formDataId;
|
|
139
|
+
if (!dataId) return;
|
|
140
|
+
let reportTemplate = this.getFormRef().reportTemplate;
|
|
141
|
+
let formScriptEnabled = this.field.options.formScriptEnabled || false;
|
|
142
|
+
let scriptCode = this.field.options.formScriptCode || "getList";
|
|
143
|
+
if (!scriptCode) return;
|
|
144
|
+
if (dataId) {
|
|
145
|
+
let accessParam = this.handleCustomEvent(
|
|
146
|
+
this.field.options.formScriptParam
|
|
147
|
+
);
|
|
148
|
+
return this.formHttp({
|
|
149
|
+
// url: "/" + reportTemplate.serviceName + "/form_ins/getList",
|
|
150
|
+
scriptCode: scriptCode,
|
|
151
|
+
data: this.buildFormScriptData(reportTemplate, {
|
|
152
|
+
...accessParam,
|
|
153
|
+
id: dataId,
|
|
154
|
+
}),
|
|
155
|
+
callback: (res) => {
|
|
156
|
+
let rows = res.objx || [];
|
|
157
|
+
this.setValue(rows);
|
|
158
|
+
this.handleCustomEvent(
|
|
159
|
+
this.field.options.formScriptSuccess,
|
|
160
|
+
["res"],
|
|
161
|
+
[res]
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
submitFile(rows, fileInfos) {
|
|
168
|
+
// this.handlLineCode(fileInfos);
|
|
169
|
+
let eventParamNames = ["attachments", "fileInfos"];
|
|
170
|
+
let eventParamValues = [rows, fileInfos];
|
|
171
|
+
this.handleCustomEvent(
|
|
172
|
+
this.field.options.onAfterConfirmFile,
|
|
173
|
+
eventParamNames,
|
|
174
|
+
eventParamValues
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
setValueByUrl(fileUrl) {
|
|
178
|
+
let value = [];
|
|
179
|
+
if (fileUrl) {
|
|
180
|
+
let row = this.parseFileUrl(fileUrl);
|
|
181
|
+
if (row) {
|
|
182
|
+
value.push(row);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.setValue(value);
|
|
186
|
+
},
|
|
187
|
+
parseFileUrl(fileUrl) {
|
|
188
|
+
if (!fileUrl) return null;
|
|
189
|
+
let result = null;
|
|
190
|
+
|
|
191
|
+
// 输入校验
|
|
192
|
+
if (typeof fileUrl !== "string") {
|
|
193
|
+
throw new TypeError("输入必须是字符串格式");
|
|
194
|
+
}
|
|
195
|
+
if (!fileUrl.trim()) {
|
|
196
|
+
throw new Error("URL不能为空");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 基本URL格式验证
|
|
200
|
+
const urlRegex =
|
|
201
|
+
/^(https?:\/\/)?([\w.-]+)(:\d+)?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i;
|
|
202
|
+
if (!urlRegex.test(fileUrl)) {
|
|
203
|
+
throw new Error("无效的URL格式");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 提取域名部分
|
|
207
|
+
const domainRegex = /^(https?:\/\/[^\/]+)/i;
|
|
208
|
+
const domainMatch = fileUrl.match(domainRegex);
|
|
209
|
+
if (!domainMatch) {
|
|
210
|
+
throw new Error("URL缺少协议或域名部分");
|
|
211
|
+
}
|
|
212
|
+
const domain = domainMatch[0];
|
|
213
|
+
|
|
214
|
+
// 提取完整路径
|
|
215
|
+
const url = fileUrl.substring(domain.length);
|
|
216
|
+
if (!url || url === "/") {
|
|
217
|
+
throw new Error("URL缺少文件路径部分");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 提取带扩展名的文件名
|
|
221
|
+
const filenameRegex = /[^\/]+$/;
|
|
222
|
+
const filenameMatch = url.match(filenameRegex);
|
|
223
|
+
if (!filenameMatch) {
|
|
224
|
+
throw new Error("无法从路径中提取文件名");
|
|
225
|
+
}
|
|
226
|
+
const fullFilename = filenameMatch[0];
|
|
227
|
+
|
|
228
|
+
// 验证文件名格式(至少1字符+扩展名)
|
|
229
|
+
const nameFormat = /^.+\..+$/;
|
|
230
|
+
if (!nameFormat.test(fullFilename)) {
|
|
231
|
+
throw new Error(`无效的文件名格式: ${fullFilename}`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 修复点:更可靠的文件名和扩展名分离
|
|
235
|
+
const lastDotIndex = fullFilename.lastIndexOf(".");
|
|
236
|
+
const filenameBase = fullFilename.substring(0, lastDotIndex); // 点之前部分
|
|
237
|
+
const extension = fullFilename.substring(lastDotIndex + 1).toLowerCase(); // 点之后部分
|
|
238
|
+
|
|
239
|
+
// 扩展名验证
|
|
240
|
+
/* const validExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp'];
|
|
241
|
+
if (!validExtensions.includes(extension)) {
|
|
242
|
+
throw new Error(`不支持的扩展名类型: ${extension}`);
|
|
243
|
+
} */
|
|
244
|
+
|
|
245
|
+
let thumbnail = null,
|
|
246
|
+
large = null,
|
|
247
|
+
medium = null,
|
|
248
|
+
source = null;
|
|
249
|
+
if (this.$commonFileUtil.isPicture(extension)) {
|
|
250
|
+
thumbnail = url;
|
|
251
|
+
large = url;
|
|
252
|
+
medium = url;
|
|
253
|
+
source = url;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
result = {
|
|
257
|
+
extension,
|
|
258
|
+
domain,
|
|
259
|
+
url,
|
|
260
|
+
thumbnail,
|
|
261
|
+
large,
|
|
262
|
+
medium,
|
|
263
|
+
source,
|
|
264
|
+
name: fullFilename,
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// 返回结构化对象
|
|
268
|
+
return result;
|
|
269
|
+
},
|
|
270
|
+
/*handlLineCode(fileInfos) {
|
|
271
|
+
let allPromise = [];
|
|
272
|
+
fileInfos.forEach(async fileInfo => {
|
|
273
|
+
await this.processFile(fileInfo.file, (lineCode) => {
|
|
274
|
+
fileInfo.lineCode = lineCode;
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
},
|
|
279
|
+
processFile(file, callback) {
|
|
280
|
+
return new Promise((resolve, reject) => {
|
|
281
|
+
const reader = new FileReader();
|
|
282
|
+
reader.onload = (e) => this.processImage(e.target.result, (lineCode) => {
|
|
283
|
+
resolve(lineCode)
|
|
284
|
+
callback(lineCode)
|
|
285
|
+
});
|
|
286
|
+
reader.onerror = () => {
|
|
287
|
+
resolve(null)
|
|
288
|
+
callback(null)
|
|
289
|
+
this.setError('文件读取失败')
|
|
290
|
+
};
|
|
291
|
+
reader.readAsDataURL(file);
|
|
292
|
+
})
|
|
293
|
+
},
|
|
294
|
+
async processImage(base64, callback) {
|
|
295
|
+
try {
|
|
296
|
+
// 使用 ZXing 3.x 的 API
|
|
297
|
+
const result = await decode(base64, (result, err) => {
|
|
298
|
+
if (err) {
|
|
299
|
+
this.handleError(`条码识别失败: ${err}`);
|
|
300
|
+
callback && callback(null)
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.scannedText = result.text;
|
|
304
|
+
this.loading = false;
|
|
305
|
+
callback && callback(result.text)
|
|
306
|
+
});
|
|
307
|
+
} catch (err) {
|
|
308
|
+
console.error(err);
|
|
309
|
+
callback && callback(null)
|
|
310
|
+
this.handleError(`条码识别失败: ${err.message}`);
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
handleLineCode(fileInfos) {
|
|
314
|
+
fileInfos.forEach(fileInfo => {
|
|
315
|
+
let file = fileInfo.file;
|
|
316
|
+
})
|
|
317
|
+
},
|
|
318
|
+
handleImage(base64, fileName, callback) {
|
|
319
|
+
// 创建 ZXing Scanner
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
// 将 Base64 转换为 ImageLuminanceSource
|
|
323
|
+
// const imageData = Uint8Array.from(atob(base64), c => c.charCodeAt(0));
|
|
324
|
+
// const source = new ZXing.ImageLuminanceSource(imageData, base64.length);
|
|
325
|
+
|
|
326
|
+
decode(base64, (result, err) => {
|
|
327
|
+
if (err) {
|
|
328
|
+
this.handleError(`条码识别失败: ${err}`);
|
|
329
|
+
callback && callback(null)
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
this.scannedText = result.text;
|
|
333
|
+
this.loading = false;
|
|
334
|
+
callback && callback(result.text)
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
handleError(errorMessage) {
|
|
339
|
+
this.error = errorMessage;
|
|
340
|
+
this.loading = false;
|
|
341
|
+
},*/
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
</script>
|
|
345
|
+
|
|
346
|
+
<style lang="scss" scoped>
|
|
347
|
+
@import "~@/styles/global.scss"; //* form-item-wrapper已引入,还需要重复引入吗? *//
|
|
348
|
+
|
|
349
|
+
.full-width-input {
|
|
350
|
+
width: 100% !important;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.hideUploadDiv {
|
|
354
|
+
::v-deep div.el-upload--picture-card {
|
|
355
|
+
/* 隐藏最后的图片上传按钮 */
|
|
356
|
+
display: none;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
::v-deep div.el-upload--text {
|
|
360
|
+
/* 隐藏最后的文件上传按钮 */
|
|
361
|
+
display: none;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
::v-deep div.el-upload__tip {
|
|
365
|
+
/* 隐藏最后的文件上传按钮提示 */
|
|
366
|
+
display: none;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
</style>
|