cloud-web-corejs 1.0.129 → 1.0.130
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/view.vue +138 -55
- package/src/components/baseInputExport/mixins.js +1 -1
- package/src/components/errorMsg/mixins.js +1 -2
- package/src/components/excelImport/mixins.js +2 -1
- package/src/components/jsonImport/mixins.js +2 -1
- package/src/components/langImport/mixins.js +17 -16
- package/src/components/wf/content.vue +772 -411
- package/src/components/wf/mixins/wfFlowEleScriptDialog.js +3 -0
- package/src/components/wf/wf.js +1 -1
- package/src/components/wf/wfFlowEleScriptDialog.vue +89 -0
- package/src/components/xform/form-designer/designer.js +3 -2
- package/src/components/xform/form-designer/form-widget/container-widget/containerMixin.js +3 -3
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +9 -9
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-widget.vue +4 -1
- package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +2 -1
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +3 -1
- package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +17 -4
- package/src/components/xform/form-designer/form-widget/field-widget/import-button-widget.vue +4 -0
- package/src/components/xform/form-designer/form-widget/field-widget/oplog-widget.vue +185 -0
- package/src/components/xform/form-designer/form-widget/field-widget/print-button-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/print-detail-button-widget.vue +108 -0
- package/src/components/xform/form-designer/form-widget/field-widget/singleUpload-widget.vue +145 -0
- package/src/components/xform/form-designer/form-widget/field-widget/status-widget.vue +13 -4
- package/src/components/xform/form-designer/form-widget/field-widget/vabUpload2-widget.vue +725 -0
- package/src/components/xform/form-designer/indexMixin.js +3 -2
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +1 -1
- package/src/components/xform/form-designer/setting-panel/option-items-setting.vue +376 -366
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/columnRenderDialog.vue +0 -1
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +372 -253
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +9 -43
- package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import-button-editor.vue +7 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-button-editor.vue +8 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-detail-button-editor.vue +91 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-status/field-status-editor.vue +37 -30
- package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload2/field-vabUpload2-editor.vue +62 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/formScriptEnabled-editor.vue +19 -14
- package/src/components/xform/form-designer/setting-panel/property-editor/oplog-editor.vue +31 -0
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +5 -1
- package/src/components/xform/form-designer/widget-panel/indexMixin.js +19 -19
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +132 -0
- package/src/components/xform/form-render/container-item/containerItemMixin.js +12 -11
- package/src/components/xform/lang/zh-CN.js +3 -0
- package/src/components/xform/utils/util.js +1 -1451
- package/src/utils/request.js +1 -1
- package/src/utils/vab.js +1 -1
- package/src/views/user/notify_message/dialog.vue +24 -19
- package/src/views/user/outLink/form_view.vue +211 -211
- package/src/views/user/wf/wfReport/index.vue +448 -0
- package/src/views/user/wf/wf_manage/list.vue +344 -251
- package/src/views/user/wf/wf_transfer_setting/edit.vue +229 -0
- package/src/views/user/wf/wf_transfer_setting/list.vue +308 -0
@@ -0,0 +1,725 @@
|
|
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
|
+
<template v-else>
|
25
|
+
<div id="uploadImage" class="widgetSize2">
|
26
|
+
<div
|
27
|
+
class="upload-list"
|
28
|
+
model="singer"
|
29
|
+
v-for="(attachment, index) in fieldModel"
|
30
|
+
:key="index"
|
31
|
+
style="display: inline-block; vertical-align: middle; float: left"
|
32
|
+
>
|
33
|
+
<div class="upload-box">
|
34
|
+
<ul class="el-upload-list el-upload-list--picture">
|
35
|
+
<li tabindex="0" class="el-upload-list__item">
|
36
|
+
<div>
|
37
|
+
<div class="el-upload-list__item-thumbnail">
|
38
|
+
<div
|
39
|
+
class="show-video"
|
40
|
+
v-if="hasPreview(attachment)"
|
41
|
+
@click="openPreview(attachment, index)"
|
42
|
+
>
|
43
|
+
<i class="icon-chakan"></i>
|
44
|
+
</div>
|
45
|
+
<p>
|
46
|
+
<el-image
|
47
|
+
:src="getShowUrl(attachment)"
|
48
|
+
@click="openPreview(attachment, index)"
|
49
|
+
:z-index="999999"
|
50
|
+
/>
|
51
|
+
</p>
|
52
|
+
</div>
|
53
|
+
<div class="el-upload-list__item-name">
|
54
|
+
<el-tooltip
|
55
|
+
:enterable="false"
|
56
|
+
class="item"
|
57
|
+
effect="dark"
|
58
|
+
:content="attachment.name"
|
59
|
+
placement="top"
|
60
|
+
>
|
61
|
+
<p v-if="$attrs.hideName !== true">
|
62
|
+
{{ attachment.name }}
|
63
|
+
</p>
|
64
|
+
</el-tooltip>
|
65
|
+
</div>
|
66
|
+
<div class="el-upload-list__item-status-label">
|
67
|
+
<i class="el-icon-upload-success el-icon-check"></i>
|
68
|
+
</div>
|
69
|
+
<div
|
70
|
+
class="el-icon-close"
|
71
|
+
@click="deleteFile(index)"
|
72
|
+
v-if="!field.options.disabled"
|
73
|
+
>
|
74
|
+
<i
|
75
|
+
class="el-tooltip iconfont iconshanchu"
|
76
|
+
aria-describedby="el-tooltip-6144"
|
77
|
+
tabindex="0"
|
78
|
+
></i>
|
79
|
+
</div>
|
80
|
+
<div class="el-icon-tagEdit">
|
81
|
+
<el-tooltip
|
82
|
+
class="item"
|
83
|
+
effect="dark"
|
84
|
+
:content="$t2('下载', 'system.button.download')"
|
85
|
+
placement="top"
|
86
|
+
>
|
87
|
+
<i class="el-icon-download" @click="downloadFile(attachment)"></i>
|
88
|
+
</el-tooltip>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
</li>
|
92
|
+
</ul>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
<div
|
96
|
+
v-if="!field.options.disabled"
|
97
|
+
class="el-upload el-upload--picture"
|
98
|
+
style="vertical-align: middle; display: inline-block; float: left"
|
99
|
+
>
|
100
|
+
<el-upload
|
101
|
+
ref="upload"
|
102
|
+
class="upload-demo"
|
103
|
+
action="https://jsonplaceholder.typicode.com/posts/"
|
104
|
+
:http-request="uploadSectionFile"
|
105
|
+
:limit="1"
|
106
|
+
>
|
107
|
+
<button type="button" class="avatar-uploader">
|
108
|
+
<i class="el-icon-plus avatar-uploader-icon"></i>
|
109
|
+
</button>
|
110
|
+
<div slot="file" slot-scope="{ file }"></div>
|
111
|
+
</el-upload>
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
<el-image-viewer
|
115
|
+
v-if="showViewer"
|
116
|
+
:on-close="closeViewer"
|
117
|
+
:initial-index.sync="chooseIndex"
|
118
|
+
:url-list="imageRows"
|
119
|
+
/>
|
120
|
+
</template>
|
121
|
+
</form-item-wrapper>
|
122
|
+
</template>
|
123
|
+
|
124
|
+
<script>
|
125
|
+
import FormItemWrapper from "./form-item-wrapper";
|
126
|
+
import emitter from "../../../../../components/xform/utils/emitter";
|
127
|
+
import i18n from "../../../../../components/xform/utils/i18n";
|
128
|
+
import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
|
129
|
+
|
130
|
+
export default {
|
131
|
+
name: "vabUpload2-widget",
|
132
|
+
componentName: "FieldWidget", //必须固定为FieldWidget,用于接收父级组件的broadcast事件
|
133
|
+
mixins: [emitter, fieldMixin, i18n],
|
134
|
+
props: {
|
135
|
+
field: Object,
|
136
|
+
parentWidget: Object,
|
137
|
+
parentList: Array,
|
138
|
+
indexOfParentList: Number,
|
139
|
+
designer: Object,
|
140
|
+
|
141
|
+
designState: {
|
142
|
+
type: Boolean,
|
143
|
+
default: false,
|
144
|
+
},
|
145
|
+
|
146
|
+
subFormRowIndex: {
|
147
|
+
/* 子表单组件行索引,从0开始计数 */ type: Number,
|
148
|
+
default: -1,
|
149
|
+
},
|
150
|
+
subFormColIndex: {
|
151
|
+
/* 子表单组件列索引,从0开始计数 */ type: Number,
|
152
|
+
default: -1,
|
153
|
+
},
|
154
|
+
subFormRowId: {
|
155
|
+
/* 子表单组件行Id,唯一id且不可变 */ type: String,
|
156
|
+
default: "",
|
157
|
+
},
|
158
|
+
responseAdapter: {
|
159
|
+
type: Function,
|
160
|
+
default(responseData, file) {
|
161
|
+
// 默认适配器:假设返回格式为
|
162
|
+
/* {
|
163
|
+
"code": 1000,
|
164
|
+
"message": "ok",
|
165
|
+
"data": "{\"name\":\"8aafaaad-f033-4f46-a8f3-fe2639204f6a-source.jpg\",\"size\":186847,\"date\":1754711199966,\"id\":\"f3056c29-f65a-4d1b-8778-c2df5fa53775\",\"filename\":\"f3056c29-f65a-4d1b-8778-c2df5fa53775.jpg\",\"user\":\"1\",\"type\":\"工单\",\"url\":\"\"}"
|
166
|
+
} */
|
167
|
+
let data = null;
|
168
|
+
if (responseData.code === 1000 && responseData.data) {
|
169
|
+
data = JSON.parse(responseData.data);
|
170
|
+
}
|
171
|
+
return {
|
172
|
+
success: responseData.code === 1000,
|
173
|
+
// url: responseData.objx?.url,
|
174
|
+
message: responseData.message || "success",
|
175
|
+
fullResponse: responseData,
|
176
|
+
data: data,
|
177
|
+
};
|
178
|
+
},
|
179
|
+
},
|
180
|
+
},
|
181
|
+
components: {
|
182
|
+
FormItemWrapper,
|
183
|
+
ElImageViewer: () => import("@base/components/VabUpload/image-viewer"),
|
184
|
+
},
|
185
|
+
inject: ["refList", "globalOptionData", "globalModel", "getFormConfig"],
|
186
|
+
data() {
|
187
|
+
return {
|
188
|
+
oldFieldValue: [], //field组件change之前的值
|
189
|
+
fieldModel: [],
|
190
|
+
rules: [],
|
191
|
+
isH5: false,
|
192
|
+
|
193
|
+
uploadUrl: null,
|
194
|
+
|
195
|
+
token: null,
|
196
|
+
deleteUrl: null,
|
197
|
+
viewApiUrl: null,
|
198
|
+
imageMap: {},
|
199
|
+
imageRows: [],
|
200
|
+
chooseIndex: -1,
|
201
|
+
showViewer: false,
|
202
|
+
};
|
203
|
+
},
|
204
|
+
watch: {
|
205
|
+
fieldModel(val) {
|
206
|
+
this.handleChangeEvent(val);
|
207
|
+
},
|
208
|
+
},
|
209
|
+
computed: {
|
210
|
+
formDataId() {
|
211
|
+
let formRef = this.getFormRef();
|
212
|
+
return formRef.dataId;
|
213
|
+
},
|
214
|
+
},
|
215
|
+
beforeCreate() {
|
216
|
+
/* 这里不能访问方法和属性!! */
|
217
|
+
},
|
218
|
+
|
219
|
+
created() {
|
220
|
+
/* 注意:子组件mounted在父组件created之后、父组件mounted之前触发,故子组件mounted需要用到的prop
|
221
|
+
需要在父组件created中初始化!! */
|
222
|
+
|
223
|
+
this.isH5 = this.getFormConfig().layoutType === "H5";
|
224
|
+
|
225
|
+
this.initFieldModel();
|
226
|
+
this.registerToRefList();
|
227
|
+
this.initEventHandler();
|
228
|
+
this.buildFieldRules();
|
229
|
+
|
230
|
+
this.handleOnCreated();
|
231
|
+
},
|
232
|
+
|
233
|
+
mounted() {
|
234
|
+
this.initUploadInfo();
|
235
|
+
this.handleOnMounted();
|
236
|
+
},
|
237
|
+
|
238
|
+
beforeDestroy() {
|
239
|
+
this.unregisterFromRefList();
|
240
|
+
},
|
241
|
+
methods: {
|
242
|
+
//begin
|
243
|
+
closeViewer() {
|
244
|
+
this.showViewer = false;
|
245
|
+
},
|
246
|
+
hasPreview(attachment) {
|
247
|
+
return this.$commonFileUtil.isPictureFile(attachment.name);
|
248
|
+
},
|
249
|
+
openPreview(attachment, index) {
|
250
|
+
let typeStr = Object.prototype.toString.call(attachment);
|
251
|
+
let url =
|
252
|
+
typeStr == "[object Object]" ? attachment.domain + attachment.url : attachment;
|
253
|
+
if (this.$commonFileUtil.isPictureFile(attachment.name)) {
|
254
|
+
this.openImagePreView(index);
|
255
|
+
}
|
256
|
+
},
|
257
|
+
openImagePreView(index) {
|
258
|
+
// this.chooseIndex = index;
|
259
|
+
let pictureIndex = -1;
|
260
|
+
let rows = [];
|
261
|
+
|
262
|
+
this.fieldModel.forEach((item, i) => {
|
263
|
+
if (this.$commonFileUtil.isPictureFile(item.name)) {
|
264
|
+
rows.push(item.showUrl);
|
265
|
+
}
|
266
|
+
});
|
267
|
+
this.fieldModel.find((item, i) => {
|
268
|
+
if (this.$commonFileUtil.isPictureFile(item.name)) {
|
269
|
+
pictureIndex++;
|
270
|
+
}
|
271
|
+
return index == i;
|
272
|
+
});
|
273
|
+
let attachment = this.fieldModel[index];
|
274
|
+
const toDo = () => {
|
275
|
+
this.chooseIndex = 0;
|
276
|
+
this.imageRows = [attachment.showUrl];
|
277
|
+
this.showViewer = true;
|
278
|
+
};
|
279
|
+
|
280
|
+
if (!attachment.showUrl) {
|
281
|
+
this.initShowImageUrl(attachment, () => {
|
282
|
+
toDo();
|
283
|
+
});
|
284
|
+
} else {
|
285
|
+
toDo();
|
286
|
+
}
|
287
|
+
},
|
288
|
+
getAttachmentName(attachment) {
|
289
|
+
let name = null;
|
290
|
+
let typeStr = Object.prototype.toString.call(attachment);
|
291
|
+
if (typeStr == "[object Object]") {
|
292
|
+
name = attachment.name;
|
293
|
+
} else {
|
294
|
+
let url = attachment;
|
295
|
+
if (url) {
|
296
|
+
var i = url.lastIndexOf("/");
|
297
|
+
if (i >= 0) {
|
298
|
+
name = url.substring(i + 1, url.length);
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
return name;
|
303
|
+
},
|
304
|
+
getShowUrl(attachment) {
|
305
|
+
return this.$commonFileUtil.getFileIconRequire(attachment.name);
|
306
|
+
/* if (this.$commonFileUtil.isPictureFile(attachment.name)) {
|
307
|
+
return attachment.showUrl;
|
308
|
+
} else {
|
309
|
+
return this.$commonFileUtil.getFileIconRequire(attachment.name);
|
310
|
+
} */
|
311
|
+
},
|
312
|
+
initShowUrl() {
|
313
|
+
let rows = this.fieldModel;
|
314
|
+
rows.forEach((row) => {
|
315
|
+
if (!row.showUrl) {
|
316
|
+
this.initShowImageUrl(row);
|
317
|
+
}
|
318
|
+
});
|
319
|
+
},
|
320
|
+
deleteFile(index) {
|
321
|
+
let attachment = this.fieldModel[index];
|
322
|
+
let filename = attachment.filename;
|
323
|
+
if (!filename || !this.deleteUrl) return;
|
324
|
+
let entityId = this.formDataId;
|
325
|
+
|
326
|
+
let reqData = {
|
327
|
+
entityName: "msdyn_workorder",
|
328
|
+
entityId,
|
329
|
+
backendwriteback: "10",
|
330
|
+
};
|
331
|
+
|
332
|
+
let deleteParam =
|
333
|
+
this.handleCustomEvent(this.field.options.vabupload2_deleteParam) || {};
|
334
|
+
Object.assign(reqData, deleteParam);
|
335
|
+
|
336
|
+
this.getFormRef().$http({
|
337
|
+
url: this.deleteUrl + "?fileName=" + filename,
|
338
|
+
method: "post",
|
339
|
+
data: reqData,
|
340
|
+
// responseType: "RAW",
|
341
|
+
headers: {
|
342
|
+
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
343
|
+
Authorization: `Bearer ${this.token}`,
|
344
|
+
},
|
345
|
+
useToken: false,
|
346
|
+
// responseType: "blob",
|
347
|
+
resultType: "other",
|
348
|
+
isLoading: true,
|
349
|
+
callback: (res, response) => {
|
350
|
+
if (res.code === 1000) {
|
351
|
+
this.fieldModel.splice(index, 1);
|
352
|
+
} else {
|
353
|
+
this.$baseAlert(res.message);
|
354
|
+
}
|
355
|
+
},
|
356
|
+
});
|
357
|
+
},
|
358
|
+
downloadFile(attachment) {
|
359
|
+
const toDo = () => {
|
360
|
+
const a = document.createElement("a");
|
361
|
+
a.download = attachment.name;
|
362
|
+
a.href = attachment.showUrl;
|
363
|
+
a.click();
|
364
|
+
};
|
365
|
+
if (!attachment.showUrl) {
|
366
|
+
this.initShowImageUrl(attachment, () => {
|
367
|
+
toDo();
|
368
|
+
});
|
369
|
+
} else {
|
370
|
+
toDo();
|
371
|
+
}
|
372
|
+
|
373
|
+
// this.$commonFileUtil.downloadFile(attachment.showUrl);
|
374
|
+
},
|
375
|
+
initUploadInfo() {
|
376
|
+
this.getHxFileUploadConfig({
|
377
|
+
success: (res) => {
|
378
|
+
// {"apiToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5YzcyNTE5OS00NDdlLTQ5OTMtOGRjYy1iMWM2NjY0YmJhNDAiLCJuYW1lIjoiOWM3MjUxOTktNDQ3ZS00OTkzLThkY2MtYjFjNjY2NGJiYTQwIiwibmJmIjoxNzU0NjE1ODE1LCJleHAiOjE3NTQ3MDIyMTUsImlzcyI6IlB3YyIsImF1ZCI6IkFTLkNSTS5TZXJ2aWNlLkFwaSJ9.CX2oy7P2PPwCPy-UdhNGaTiSfBHUiVgeK13N91NRcMc","domain":"https://crm-dev.hisense.com","uploadApi":"/api/v1.0/fileoperation/UploadFilesFromPortal","deleteApi":"/api/v1.0/fileoperation/delfile"}
|
379
|
+
let objx = res.objx || {};
|
380
|
+
let token = objx.apiToken;
|
381
|
+
if (token) {
|
382
|
+
this.token = token;
|
383
|
+
this.uploadUrl = objx.domain + objx.uploadApi;
|
384
|
+
this.deleteUrl = objx.domain + objx.deleteApi;
|
385
|
+
// https://crm-dev.hisense.com/api/v1.0/fileoperation/GetFile?fileName=e24a1ad9-6821-41c3-957c-0916077bb97f.jpg
|
386
|
+
this.viewApiUrl = objx.domain + objx.viewApi;
|
387
|
+
// this.initShowUrl();
|
388
|
+
// this.initCustomConfig();
|
389
|
+
}
|
390
|
+
},
|
391
|
+
});
|
392
|
+
},
|
393
|
+
getHxFileUploadConfig(option) {
|
394
|
+
let scriptCode =
|
395
|
+
this.field.options.vabupload2_scriptCode || "/intf/getHxFileUploadConfig";
|
396
|
+
return this.formHttp({
|
397
|
+
scriptCode,
|
398
|
+
data: {},
|
399
|
+
...option,
|
400
|
+
});
|
401
|
+
},
|
402
|
+
initHttpToekn() {
|
403
|
+
return this.getHxFileUploadConfig({
|
404
|
+
success: (res) => {
|
405
|
+
// {"apiToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5YzcyNTE5OS00NDdlLTQ5OTMtOGRjYy1iMWM2NjY0YmJhNDAiLCJuYW1lIjoiOWM3MjUxOTktNDQ3ZS00OTkzLThkY2MtYjFjNjY2NGJiYTQwIiwibmJmIjoxNzU0NjE1ODE1LCJleHAiOjE3NTQ3MDIyMTUsImlzcyI6IlB3YyIsImF1ZCI6IkFTLkNSTS5TZXJ2aWNlLkFwaSJ9.CX2oy7P2PPwCPy-UdhNGaTiSfBHUiVgeK13N91NRcMc","domain":"https://crm-dev.hisense.com","uploadApi":"/api/v1.0/fileoperation/UploadFilesFromPortal","deleteApi":"/api/v1.0/fileoperation/delfile"}
|
406
|
+
let objx = res.objx || {};
|
407
|
+
let token = objx.apiToken;
|
408
|
+
if (token) {
|
409
|
+
this.token = token;
|
410
|
+
}
|
411
|
+
},
|
412
|
+
});
|
413
|
+
},
|
414
|
+
initCustomConfig() {
|
415
|
+
// let paramCode = this.moduleType;
|
416
|
+
let paramCode = "haixin";
|
417
|
+
this.getFormRef().$http({
|
418
|
+
url: USER_PREFIX + "/logic_param/getParamValue",
|
419
|
+
method: "post",
|
420
|
+
data: {
|
421
|
+
paramCode,
|
422
|
+
paramType: 2,
|
423
|
+
},
|
424
|
+
success: (res) => {
|
425
|
+
let logic_param = res.objx;
|
426
|
+
let customConfig = logic_param?.paramValue
|
427
|
+
? JSON.parse(logic_param.paramValue)
|
428
|
+
: null;
|
429
|
+
this.customConfig = customConfig;
|
430
|
+
},
|
431
|
+
});
|
432
|
+
},
|
433
|
+
generateId() {
|
434
|
+
return Math.floor(
|
435
|
+
Math.random() * 100000 + Math.random() * 20000 + Math.random() * 5000
|
436
|
+
);
|
437
|
+
},
|
438
|
+
//自定义上传
|
439
|
+
async uploadSectionFile(param, isCustom, uploadConfig) {
|
440
|
+
let customConfig = this.customConfig || {};
|
441
|
+
let customEnabled = this.customEnabled || false;
|
442
|
+
/* if (customEnabled && !this.uploadUrl) {
|
443
|
+
if(customConfig.uploadUrl){
|
444
|
+
this.uploadUrl = customConfig.uploadUrl;
|
445
|
+
}else{
|
446
|
+
await this.initUploadUrl();
|
447
|
+
}
|
448
|
+
|
449
|
+
} */
|
450
|
+
let that = this;
|
451
|
+
var fileObj = param.file;
|
452
|
+
|
453
|
+
let source;
|
454
|
+
|
455
|
+
var form = new FormData();
|
456
|
+
// 文件对象
|
457
|
+
form.append("file", fileObj);
|
458
|
+
|
459
|
+
let customParam = {};
|
460
|
+
let entityId = this.formDataId;
|
461
|
+
customParam = {
|
462
|
+
fileName: fileObj.name,
|
463
|
+
entityName: "msdyn_workorder",
|
464
|
+
entityId,
|
465
|
+
backendwriteback: "10",
|
466
|
+
fileCategory: "工单",
|
467
|
+
user: window.$vueRoot.$store.getters.nickName,
|
468
|
+
// user: "1",
|
469
|
+
};
|
470
|
+
let uploadParam =
|
471
|
+
this.handleCustomEvent(this.field.options.vabupload2_uploadParam) || {};
|
472
|
+
Object.assign(customParam, uploadParam);
|
473
|
+
if (customParam) {
|
474
|
+
Object.keys(customParam).forEach((key) => {
|
475
|
+
let value = customParam[key];
|
476
|
+
form.append(key, value);
|
477
|
+
});
|
478
|
+
}
|
479
|
+
|
480
|
+
let target = that.$refs.upload;
|
481
|
+
let file = target ? target.getFile(fileObj) : null;
|
482
|
+
if (file) {
|
483
|
+
file.status = "uploading";
|
484
|
+
}
|
485
|
+
|
486
|
+
let isLoading = uploadConfig?.isLoading === true;
|
487
|
+
var uploadUrl = this.uploadUrl;
|
488
|
+
target.clearFiles();
|
489
|
+
if (uploadUrl) {
|
490
|
+
var abort;
|
491
|
+
|
492
|
+
let config = {
|
493
|
+
useToken: false,
|
494
|
+
isLoading: true,
|
495
|
+
headers: {
|
496
|
+
"Content-Type": "multipart/form-data",
|
497
|
+
Authorization: `Bearer ${this.token}`,
|
498
|
+
},
|
499
|
+
/* cancelToken: new imFun.axios.CancelToken(function executor(c) {
|
500
|
+
if (!isCustom) {
|
501
|
+
abort = c;
|
502
|
+
if (file) file.abort = c;
|
503
|
+
}
|
504
|
+
}), */
|
505
|
+
onUploadProgress: (progressEvent) => {
|
506
|
+
if (isCustom || file) {
|
507
|
+
// progressEvent.loaded:已上传文件大小
|
508
|
+
// progressEvent.total:被上传文件的总大小
|
509
|
+
progressEvent.percent = Math.floor(
|
510
|
+
(progressEvent.loaded * 100) / progressEvent.total
|
511
|
+
);
|
512
|
+
}
|
513
|
+
},
|
514
|
+
failMsg: false,
|
515
|
+
}; //添加请求头
|
516
|
+
|
517
|
+
if (customEnabled && config?.httpConfig) {
|
518
|
+
config = extendDeeply(config, config.httpConfig);
|
519
|
+
}
|
520
|
+
|
521
|
+
let req = this.getFormRef()
|
522
|
+
.$http.post(uploadUrl, form, config)
|
523
|
+
.then((res1) => {
|
524
|
+
uploadConfig && uploadConfig.callback && uploadConfig.callback(res1, fileObj);
|
525
|
+
|
526
|
+
const adaptedResponse = this.responseAdapter(res1);
|
527
|
+
|
528
|
+
if (!isCustom) {
|
529
|
+
if (adaptedResponse.success) {
|
530
|
+
// this.initShowImageUrl(adaptedResponse.data)
|
531
|
+
if (adaptedResponse.data) {
|
532
|
+
let fileInfo = {
|
533
|
+
...adaptedResponse.data,
|
534
|
+
showUrl: null,
|
535
|
+
};
|
536
|
+
this.fieldModel.push(fileInfo);
|
537
|
+
// this.initShowUrl();
|
538
|
+
}
|
539
|
+
} else {
|
540
|
+
// param.onError(new Error(res1.content || '上传异常'));
|
541
|
+
this.$baseAlert(adaptedResponse.message);
|
542
|
+
}
|
543
|
+
}
|
544
|
+
});
|
545
|
+
}
|
546
|
+
},
|
547
|
+
initShowImageUrl(attachment, callback) {
|
548
|
+
let filename = attachment.filename;
|
549
|
+
if (!filename || !this.viewApiUrl) return;
|
550
|
+
this.getFormRef().$http({
|
551
|
+
url: this.viewApiUrl + filename,
|
552
|
+
method: "get",
|
553
|
+
data: {},
|
554
|
+
// responseType: "RAW",
|
555
|
+
headers: {
|
556
|
+
// "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
557
|
+
Authorization: `Bearer ${this.token}`,
|
558
|
+
},
|
559
|
+
useToken: false,
|
560
|
+
responseType: "blob",
|
561
|
+
resultType: "other",
|
562
|
+
isLoading: true,
|
563
|
+
callback: (res, response) => {
|
564
|
+
if (res.type === "application/json") {
|
565
|
+
let reader = new FileReader();
|
566
|
+
reader.readAsText(res, "utf-8");
|
567
|
+
reader.onload = (e) => {
|
568
|
+
// JSON.parse(reader.result) 转译后的json数据
|
569
|
+
let result = JSON.parse(reader.result);
|
570
|
+
this.$baseAlert(result.message);
|
571
|
+
// 处理相关逻辑...
|
572
|
+
};
|
573
|
+
} else {
|
574
|
+
const blobUrl = window.URL.createObjectURL(res);
|
575
|
+
attachment.showUrl = blobUrl;
|
576
|
+
attachment.url = blobUrl;
|
577
|
+
callback && callback();
|
578
|
+
}
|
579
|
+
},
|
580
|
+
});
|
581
|
+
},
|
582
|
+
//end
|
583
|
+
|
584
|
+
setValue(val) {
|
585
|
+
let data = val || [];
|
586
|
+
data.forEach((item) => {
|
587
|
+
if (!item.hasOwnProperty("showUrl")) {
|
588
|
+
item.showUrl = null;
|
589
|
+
}
|
590
|
+
});
|
591
|
+
this.fieldModel = data;
|
592
|
+
this.getFormRef().formDataModel[this.fieldKeyName] = data;
|
593
|
+
this.initShowUrl();
|
594
|
+
},
|
595
|
+
|
596
|
+
submitFile(rows, fileInfos) {
|
597
|
+
// this.handlLineCode(fileInfos);
|
598
|
+
let eventParamNames = ["attachments", "fileInfos"];
|
599
|
+
let eventParamValues = [rows, fileInfos];
|
600
|
+
this.handleCustomEvent(
|
601
|
+
this.field.options.onAfterConfirmFile,
|
602
|
+
eventParamNames,
|
603
|
+
eventParamValues
|
604
|
+
);
|
605
|
+
},
|
606
|
+
setValueByUrl(fileUrl) {
|
607
|
+
let value = [];
|
608
|
+
if (fileUrl) {
|
609
|
+
let row = this.parseFileUrl(fileUrl);
|
610
|
+
if (row) {
|
611
|
+
value.push(row);
|
612
|
+
}
|
613
|
+
}
|
614
|
+
this.setValue(value);
|
615
|
+
},
|
616
|
+
parseFileUrl(fileUrl) {
|
617
|
+
if (!fileUrl) return null;
|
618
|
+
let result = null;
|
619
|
+
|
620
|
+
// 输入校验
|
621
|
+
if (typeof fileUrl !== "string") {
|
622
|
+
throw new TypeError("输入必须是字符串格式");
|
623
|
+
}
|
624
|
+
if (!fileUrl.trim()) {
|
625
|
+
throw new Error("URL不能为空");
|
626
|
+
}
|
627
|
+
|
628
|
+
// 基本URL格式验证
|
629
|
+
const urlRegex = /^(https?:\/\/)?([\w.-]+)(:\d+)?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i;
|
630
|
+
if (!urlRegex.test(fileUrl)) {
|
631
|
+
throw new Error("无效的URL格式");
|
632
|
+
}
|
633
|
+
|
634
|
+
// 提取域名部分
|
635
|
+
const domainRegex = /^(https?:\/\/[^\/]+)/i;
|
636
|
+
const domainMatch = fileUrl.match(domainRegex);
|
637
|
+
if (!domainMatch) {
|
638
|
+
throw new Error("URL缺少协议或域名部分");
|
639
|
+
}
|
640
|
+
const domain = domainMatch[0];
|
641
|
+
|
642
|
+
// 提取完整路径
|
643
|
+
const url = fileUrl.substring(domain.length);
|
644
|
+
if (!url || url === "/") {
|
645
|
+
throw new Error("URL缺少文件路径部分");
|
646
|
+
}
|
647
|
+
|
648
|
+
// 提取带扩展名的文件名
|
649
|
+
const filenameRegex = /[^\/]+$/;
|
650
|
+
const filenameMatch = url.match(filenameRegex);
|
651
|
+
if (!filenameMatch) {
|
652
|
+
throw new Error("无法从路径中提取文件名");
|
653
|
+
}
|
654
|
+
const fullFilename = filenameMatch[0];
|
655
|
+
|
656
|
+
// 验证文件名格式(至少1字符+扩展名)
|
657
|
+
const nameFormat = /^.+\..+$/;
|
658
|
+
if (!nameFormat.test(fullFilename)) {
|
659
|
+
throw new Error(`无效的文件名格式: ${fullFilename}`);
|
660
|
+
}
|
661
|
+
|
662
|
+
// 修复点:更可靠的文件名和扩展名分离
|
663
|
+
const lastDotIndex = fullFilename.lastIndexOf(".");
|
664
|
+
const filenameBase = fullFilename.substring(0, lastDotIndex); // 点之前部分
|
665
|
+
const extension = fullFilename.substring(lastDotIndex + 1).toLowerCase(); // 点之后部分
|
666
|
+
|
667
|
+
// 扩展名验证
|
668
|
+
/* const validExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp'];
|
669
|
+
if (!validExtensions.includes(extension)) {
|
670
|
+
throw new Error(`不支持的扩展名类型: ${extension}`);
|
671
|
+
} */
|
672
|
+
|
673
|
+
let thumbnail = null,
|
674
|
+
large = null,
|
675
|
+
medium = null,
|
676
|
+
source = null;
|
677
|
+
if (this.$commonFileUtil.isPicture(extension)) {
|
678
|
+
thumbnail = url;
|
679
|
+
large = url;
|
680
|
+
medium = url;
|
681
|
+
source = url;
|
682
|
+
}
|
683
|
+
|
684
|
+
result = {
|
685
|
+
extension,
|
686
|
+
domain,
|
687
|
+
url,
|
688
|
+
thumbnail,
|
689
|
+
large,
|
690
|
+
medium,
|
691
|
+
source,
|
692
|
+
name: fullFilename,
|
693
|
+
};
|
694
|
+
|
695
|
+
// 返回结构化对象
|
696
|
+
return result;
|
697
|
+
},
|
698
|
+
},
|
699
|
+
};
|
700
|
+
</script>
|
701
|
+
|
702
|
+
<style lang="scss" scoped>
|
703
|
+
@import "~@/styles/global.scss"; //* form-item-wrapper已引入,还需要重复引入吗? *//
|
704
|
+
|
705
|
+
.full-width-input {
|
706
|
+
width: 100% !important;
|
707
|
+
}
|
708
|
+
|
709
|
+
.hideUploadDiv {
|
710
|
+
::v-deep div.el-upload--picture-card {
|
711
|
+
/* 隐藏最后的图片上传按钮 */
|
712
|
+
display: none;
|
713
|
+
}
|
714
|
+
|
715
|
+
::v-deep div.el-upload--text {
|
716
|
+
/* 隐藏最后的文件上传按钮 */
|
717
|
+
display: none;
|
718
|
+
}
|
719
|
+
|
720
|
+
::v-deep div.el-upload__tip {
|
721
|
+
/* 隐藏最后的文件上传按钮提示 */
|
722
|
+
display: none;
|
723
|
+
}
|
724
|
+
}
|
725
|
+
</style>
|