cloud-web-corejs 1.1.0-dev.70 → 1.1.0-dev.72
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
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# base-autocomplete 自动完成
|
|
2
|
+
|
|
3
|
+
Vue 页面用的远程搜索输入框。输入框展示名称,`v-model` 存 ID。取数方式和 `el-tree` 的 `load` 一样:页面自己请求,再把结果交给组件。
|
|
4
|
+
|
|
5
|
+
- 组件位置:`src/components/baseAutocomplete/`
|
|
6
|
+
- 全局注册名:`base-autocomplete`(`src/app-bootstrap.js`、`src/app-bootstrap.sync.js`)
|
|
7
|
+
- 示例页面:`src/views/demo/autocomplete/index.vue`(路由 `/#/demo/autocomplete`)
|
|
8
|
+
|
|
9
|
+
和 xform 里的「自动完成」字段不是同一个组件。本组件给普通 Vue 页面用,不读取表单设计器的 `script-code`。
|
|
10
|
+
|
|
11
|
+
## 快速上手
|
|
12
|
+
|
|
13
|
+
按姓名查用户。下拉只显示姓名,输入的关键词会高亮。
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<base-autocomplete
|
|
17
|
+
v-model="form.userId"
|
|
18
|
+
:label.sync="form.nickName"
|
|
19
|
+
:props="userProps"
|
|
20
|
+
:load="loadUser"
|
|
21
|
+
placeholder="输入姓名搜索"
|
|
22
|
+
/>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
data() {
|
|
27
|
+
return {
|
|
28
|
+
userProps: { value: "id", label: "nickName" },
|
|
29
|
+
form: { userId: null, nickName: null },
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
methods: {
|
|
33
|
+
loadUser(keyword, resolve) {
|
|
34
|
+
this.$http({
|
|
35
|
+
url: USER_PREFIX + "/user/listCurrentPage",
|
|
36
|
+
method: "post",
|
|
37
|
+
isLoading: false,
|
|
38
|
+
data: {
|
|
39
|
+
current: 1,
|
|
40
|
+
size: 20,
|
|
41
|
+
searchCount: false,
|
|
42
|
+
enabled: true,
|
|
43
|
+
nickName: keyword,
|
|
44
|
+
},
|
|
45
|
+
success: (res) => {
|
|
46
|
+
const rows = (res.objx && res.objx.records) || res.objx || [];
|
|
47
|
+
resolve(Array.isArray(rows) ? rows : []);
|
|
48
|
+
},
|
|
49
|
+
fail: () => resolve([]),
|
|
50
|
+
error: () => resolve([]),
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
选中后 `form.userId` 是用户 ID,`form.nickName` 是姓名。输入了但没选中就离开输入框时,文字会还原成已保存的姓名,下拉和高亮会关掉。
|
|
57
|
+
|
|
58
|
+
## 属性
|
|
59
|
+
|
|
60
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `value` / `v-model` | any | `null` | 选中项的 ID |
|
|
63
|
+
| `label` | any | `null` | 输入框展示文字。用 `.sync` 写回 |
|
|
64
|
+
| `props` | Object | `{ value: "id", label: "name" }` | `value` 是候选项里的 ID 字段,`label` 是展示字段 |
|
|
65
|
+
| `load` | Function | `null` | `(keyword, resolve) => void`。请求完成后 `resolve(列表)`。也可以返回 `Promise<数组>` |
|
|
66
|
+
| `loadById` | Function | `null` | `(id, resolve) => void`。只有 ID、没有名称时反查。`resolve` 一条记录或数组的第一项 |
|
|
67
|
+
| `placeholder` | String | `请输入关键词搜索` | 占位文字 |
|
|
68
|
+
| `disabled` | Boolean | `false` | 禁用:变灰、不能聚焦、不查询、不出现清空按钮 |
|
|
69
|
+
| `readonly` | Boolean | `false` | 只读:可以聚焦和选中文字,不能输入、不查询、不出现清空按钮 |
|
|
70
|
+
| `clearable` | Boolean | `true` | 有内容时悬停显示清空按钮 |
|
|
71
|
+
| `debounce` | Number | `300` | 输入防抖毫秒数 |
|
|
72
|
+
| `triggerOnFocus` | Boolean | `false` | 聚焦且输入框为空时是否查询。默认空内容不查询 |
|
|
73
|
+
| `size` | String | `""` | 传给 `el-autocomplete`。留空则跟随 Element 当前尺寸 |
|
|
74
|
+
| `prefixIcon` | String | `""` | 前置图标类名 |
|
|
75
|
+
| `suffixIcon` | String | `el-icon-tickets` | 后置图标类名。有内容并悬停出清空按钮时,这个图标会隐藏。传 `""` 可去掉 |
|
|
76
|
+
| `popperClass` | String | `""` | 追加到下拉浮层上的类名 |
|
|
77
|
+
| `dropdownMaxWidth` | Number / String | `480` | 下拉最大宽度。最小宽度是输入框宽度,文字超出后换行 |
|
|
78
|
+
| `itemTemplate` | Function | `null` | `(item) => html`。自定义下拉项 HTML。写了默认插槽时不使用 |
|
|
79
|
+
|
|
80
|
+
`props.label` 是候选项上的字段名,`label` 是当前显示出来的文字,两者不是同一个值。
|
|
81
|
+
|
|
82
|
+
## 事件
|
|
83
|
+
|
|
84
|
+
| 事件 | 时机 | 参数 |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `input` | 选中或清空 | ID。配合 `v-model` |
|
|
87
|
+
| `update:label` | 选中、清空,或按 ID 反查出名称 | 展示文字。配合 `label.sync` |
|
|
88
|
+
| `select` | 选中一项 | 选中的那一行。其他字段在这里回填 |
|
|
89
|
+
| `change` | 选中或清空 | `(id, oldId, row)`。清空时 `id`、`row` 为 `null` |
|
|
90
|
+
| `clear` | 点击清空 | 无 |
|
|
91
|
+
| `input-change` | 输入框文字变化,且不是选中引起的 | 当前输入文本 |
|
|
92
|
+
| `focus` / `blur` | 聚焦、失焦 | 原生事件 |
|
|
93
|
+
|
|
94
|
+
只处理选中用 `select`。其他字段也在 `select` 里写。选中和清空都要处理用 `change`,只处理清空用 `clear`。
|
|
95
|
+
|
|
96
|
+
```vue
|
|
97
|
+
<base-autocomplete
|
|
98
|
+
v-model="form.userId"
|
|
99
|
+
:label.sync="form.nickName"
|
|
100
|
+
:props="{ value: 'id', label: 'nickName' }"
|
|
101
|
+
:load="loadUser"
|
|
102
|
+
@select="handleSelect"
|
|
103
|
+
@clear="handleClear"
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
handleSelect(row) {
|
|
109
|
+
this.form.loginAccount = row.loginAccount;
|
|
110
|
+
},
|
|
111
|
+
handleClear() {
|
|
112
|
+
this.form.loginAccount = null;
|
|
113
|
+
},
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 按 ID 回显名称
|
|
117
|
+
|
|
118
|
+
编辑页只有 ID、名称还没带上时,传 `load-by-id`。名称已经有值时不会再请求。
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
loadUserById(id, resolve) {
|
|
122
|
+
this.$http({
|
|
123
|
+
url: USER_PREFIX + "/user/get",
|
|
124
|
+
method: "post",
|
|
125
|
+
isLoading: false,
|
|
126
|
+
data: { id: id },
|
|
127
|
+
success: (res) => resolve(res.objx || null),
|
|
128
|
+
fail: () => resolve(null),
|
|
129
|
+
error: () => resolve(null),
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 下拉展示
|
|
135
|
+
|
|
136
|
+
默认用 `props.label` 对应的字段做下拉文字,并把当前输入的关键词标成蓝色加粗。匹配不区分大小写。
|
|
137
|
+
|
|
138
|
+
自己写默认插槽后,组件不再套这层高亮:
|
|
139
|
+
|
|
140
|
+
```vue
|
|
141
|
+
<base-autocomplete :load="loadUser" :props="userProps" v-model="form.userId" :label.sync="form.nickName">
|
|
142
|
+
<template slot-scope="{ item }">
|
|
143
|
+
<span>{{ item.nickName }}</span>
|
|
144
|
+
<span>{{ item.loginAccount }}</span>
|
|
145
|
+
</template>
|
|
146
|
+
</base-autocomplete>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
还可以用 `prefix`、`suffix`、`prepend`、`append` 插槽,对应 `el-input` 的同名插槽。
|
|
150
|
+
|
|
151
|
+
## 行为说明
|
|
152
|
+
|
|
153
|
+
- 关键词为空(含只有空格)时不调用 `load`。
|
|
154
|
+
- 相同关键词且上次有结果时,不再重复请求。
|
|
155
|
+
- 未选中新项就失焦:输入框还原为已保存的 `label`,下拉关闭,关键词高亮清除。已保存的 ID 不变。
|
|
156
|
+
- 点清空:ID 和名称一起变成 `null`。
|
|
157
|
+
- `disabled`、`readonly` 时不发起查询。
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
import {
|
|
47
47
|
hasValue,
|
|
48
48
|
trimText,
|
|
49
|
-
collectFill,
|
|
50
49
|
highlightKeyword,
|
|
51
50
|
} from "./query";
|
|
52
51
|
|
|
@@ -110,14 +109,6 @@ export default {
|
|
|
110
109
|
type: Function,
|
|
111
110
|
default: null,
|
|
112
111
|
},
|
|
113
|
-
fillConfig: {
|
|
114
|
-
type: Array,
|
|
115
|
-
default: () => [],
|
|
116
|
-
},
|
|
117
|
-
data: {
|
|
118
|
-
type: Object,
|
|
119
|
-
default: null,
|
|
120
|
-
},
|
|
121
112
|
itemTemplate: {
|
|
122
113
|
type: Function,
|
|
123
114
|
default: null,
|
|
@@ -162,6 +153,13 @@ export default {
|
|
|
162
153
|
type: String,
|
|
163
154
|
default: "",
|
|
164
155
|
},
|
|
156
|
+
/**
|
|
157
|
+
* 下拉最大宽度。最小宽度始终是输入框宽度,超出后换行。
|
|
158
|
+
*/
|
|
159
|
+
dropdownMaxWidth: {
|
|
160
|
+
type: [Number, String],
|
|
161
|
+
default: 480,
|
|
162
|
+
},
|
|
165
163
|
},
|
|
166
164
|
data() {
|
|
167
165
|
return {
|
|
@@ -207,6 +205,9 @@ export default {
|
|
|
207
205
|
this.displayValue = this.storedLabel;
|
|
208
206
|
this.lookupLabel(this.value);
|
|
209
207
|
},
|
|
208
|
+
mounted() {
|
|
209
|
+
this.syncDropdownWidth();
|
|
210
|
+
},
|
|
210
211
|
methods: {
|
|
211
212
|
focus() {
|
|
212
213
|
const input = this.$refs.input;
|
|
@@ -233,6 +234,7 @@ export default {
|
|
|
233
234
|
&& this._lastSuggestions.length
|
|
234
235
|
) {
|
|
235
236
|
cb(this._lastSuggestions);
|
|
237
|
+
this.syncDropdownWidth();
|
|
236
238
|
return;
|
|
237
239
|
}
|
|
238
240
|
this.lastQueryKeyword = keyword;
|
|
@@ -257,6 +259,7 @@ export default {
|
|
|
257
259
|
const list = Array.isArray(rows) ? rows : [];
|
|
258
260
|
this._lastSuggestions = list;
|
|
259
261
|
cb(list);
|
|
262
|
+
this.syncDropdownWidth();
|
|
260
263
|
};
|
|
261
264
|
try {
|
|
262
265
|
const ret = this.load(keyword, done);
|
|
@@ -315,13 +318,6 @@ export default {
|
|
|
315
318
|
this.displayValue = label;
|
|
316
319
|
this.$emit("input", id);
|
|
317
320
|
this.$emit("update:label", label);
|
|
318
|
-
const filled = collectFill(row, this.fillConfig);
|
|
319
|
-
if (this.data) {
|
|
320
|
-
Object.keys(filled).forEach((key) => {
|
|
321
|
-
this.$set(this.data, key, filled[key]);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
this.$emit("fill", filled, row);
|
|
325
321
|
this.$emit("select", row);
|
|
326
322
|
this.$emit("change", id, oldValue, row);
|
|
327
323
|
} finally {
|
|
@@ -352,8 +348,37 @@ export default {
|
|
|
352
348
|
this.focused = true;
|
|
353
349
|
const input = this.$refs.input;
|
|
354
350
|
if (input) input.suggestionDisabled = false;
|
|
351
|
+
this.syncDropdownWidth();
|
|
355
352
|
this.$emit("focus", event);
|
|
356
353
|
},
|
|
354
|
+
syncDropdownWidth() {
|
|
355
|
+
this.$nextTick(() => {
|
|
356
|
+
const ac = this.$refs.input;
|
|
357
|
+
if (!ac || !ac.$el) return;
|
|
358
|
+
const popper = ac.$refs.suggestions && ac.$refs.suggestions.$el;
|
|
359
|
+
if (!popper) return;
|
|
360
|
+
const inputWidth = ac.$el.offsetWidth;
|
|
361
|
+
if (inputWidth) {
|
|
362
|
+
popper.style.setProperty(
|
|
363
|
+
"--base-autocomplete-min-width",
|
|
364
|
+
inputWidth + "px"
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
const maxWidth = this.dropdownMaxWidth;
|
|
368
|
+
let maxText = "";
|
|
369
|
+
if (typeof maxWidth === "number") {
|
|
370
|
+
maxText = maxWidth + "px";
|
|
371
|
+
} else if (maxWidth) {
|
|
372
|
+
maxText = String(maxWidth);
|
|
373
|
+
}
|
|
374
|
+
if (maxText) {
|
|
375
|
+
popper.style.setProperty("--base-autocomplete-max-width", maxText);
|
|
376
|
+
}
|
|
377
|
+
if (ac.$refs.suggestions.updatePopper) {
|
|
378
|
+
ac.$refs.suggestions.updatePopper();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
},
|
|
357
382
|
handleBlur(event) {
|
|
358
383
|
this.focused = false;
|
|
359
384
|
this.$emit("blur", event);
|
|
@@ -426,10 +451,24 @@ export default {
|
|
|
426
451
|
display: none;
|
|
427
452
|
}
|
|
428
453
|
|
|
454
|
+
.base-autocomplete-popper.el-autocomplete-suggestion {
|
|
455
|
+
width: auto !important;
|
|
456
|
+
min-width: var(--base-autocomplete-min-width) !important;
|
|
457
|
+
max-width: var(--base-autocomplete-max-width, 480px) !important;
|
|
458
|
+
}
|
|
459
|
+
|
|
429
460
|
.base-autocomplete-popper {
|
|
430
461
|
.el-autocomplete-suggestion__list li {
|
|
462
|
+
height: auto;
|
|
463
|
+
padding-top: 6px;
|
|
464
|
+
padding-bottom: 6px;
|
|
431
465
|
font-size: 13px;
|
|
432
466
|
line-height: 1.6;
|
|
467
|
+
white-space: normal;
|
|
468
|
+
word-break: break-word;
|
|
469
|
+
overflow-wrap: anywhere;
|
|
470
|
+
overflow: visible;
|
|
471
|
+
text-overflow: unset;
|
|
433
472
|
}
|
|
434
473
|
}
|
|
435
474
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vue
|
|
2
|
+
* Vue 页面自动完成的展示。取数由页面的 load 回调完成。
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export function hasValue(val) {
|
|
@@ -11,24 +11,6 @@ export function trimText(value) {
|
|
|
11
11
|
return String(value).trim();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* 选中回填。兼容 target/source 与 targetFormField/sourceField。
|
|
16
|
-
*/
|
|
17
|
-
export function collectFill(item, fillConfig) {
|
|
18
|
-
const filled = {};
|
|
19
|
-
const list = Array.isArray(fillConfig) ? fillConfig : [];
|
|
20
|
-
list.forEach((cfg) => {
|
|
21
|
-
if (!cfg) return;
|
|
22
|
-
const target = trimText(
|
|
23
|
-
cfg.target || cfg.targetFormField || cfg.targetField
|
|
24
|
-
);
|
|
25
|
-
const source = trimText(cfg.source || cfg.sourceField);
|
|
26
|
-
if (!target) return;
|
|
27
|
-
filled[target] = source ? (item ? item[source] ?? null : null) : null;
|
|
28
|
-
});
|
|
29
|
-
return filled;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
14
|
export function escapeHtml(str) {
|
|
33
15
|
const map = {
|
|
34
16
|
"&": "&",
|
|
@@ -129,6 +129,76 @@ import emitter from "../../../../../components/xform/utils/emitter";
|
|
|
129
129
|
import i18n from "../../../../../components/xform/utils/i18n";
|
|
130
130
|
import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
|
|
131
131
|
|
|
132
|
+
const BATCH_UPLOAD_API = "/api/v1.0/FileOperation/BatchUploadFilesFromPortal";
|
|
133
|
+
|
|
134
|
+
function parseJsonValue(value) {
|
|
135
|
+
if (value == null || value === "") return null;
|
|
136
|
+
if (typeof value === "object") return value;
|
|
137
|
+
if (typeof value !== "string") return null;
|
|
138
|
+
try {
|
|
139
|
+
return JSON.parse(value);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 配置仍返回旧地址时,换成批量上传;已是批量地址则原样使用。 */
|
|
146
|
+
function resolveBatchUploadUrl(domain, uploadApi) {
|
|
147
|
+
let api = uploadApi || "";
|
|
148
|
+
if (!/BatchUploadFilesFromPortal/i.test(api)) {
|
|
149
|
+
if (/UploadFilesFromPortal/i.test(api)) {
|
|
150
|
+
api = api.replace(/UploadFilesFromPortal/i, "BatchUploadFilesFromPortal");
|
|
151
|
+
} else {
|
|
152
|
+
api = BATCH_UPLOAD_API;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return (domain || "") + api;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 批量接口一次只带一个文件(requests[0])。
|
|
160
|
+
* 外层 code=1000 只表示批次受理,需看明细 code;外层 2020 视为整批失败。
|
|
161
|
+
*/
|
|
162
|
+
function adaptHisenseBatchUploadResponse(responseData) {
|
|
163
|
+
const body = responseData || {};
|
|
164
|
+
const outerCode = Number(body.code);
|
|
165
|
+
const fail = (message) => ({
|
|
166
|
+
success: false,
|
|
167
|
+
message: message || "上传失败",
|
|
168
|
+
fullResponse: body,
|
|
169
|
+
data: null,
|
|
170
|
+
});
|
|
171
|
+
if (outerCode !== 1000) {
|
|
172
|
+
return fail(body.message);
|
|
173
|
+
}
|
|
174
|
+
const parsed = parseJsonValue(body.data);
|
|
175
|
+
if (parsed && !Array.isArray(parsed) && parsed.filename) {
|
|
176
|
+
return {
|
|
177
|
+
success: true,
|
|
178
|
+
message: body.message || "ok",
|
|
179
|
+
fullResponse: body,
|
|
180
|
+
data: parsed,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (!Array.isArray(parsed) || !parsed.length) {
|
|
184
|
+
return fail(body.message);
|
|
185
|
+
}
|
|
186
|
+
const item = parsed[0] || {};
|
|
187
|
+
if (Number(item.code) !== 1000) {
|
|
188
|
+
return fail(item.message || body.message);
|
|
189
|
+
}
|
|
190
|
+
const fileInfo = parseJsonValue(item.data);
|
|
191
|
+
if (!fileInfo) {
|
|
192
|
+
return fail(item.message || body.message);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
message: item.message || "ok",
|
|
197
|
+
fullResponse: body,
|
|
198
|
+
data: fileInfo,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
132
202
|
export default {
|
|
133
203
|
name: "vabUpload2-widget",
|
|
134
204
|
componentName: "FieldWidget", //必须固定为FieldWidget,用于接收父级组件的broadcast事件
|
|
@@ -159,25 +229,7 @@ export default {
|
|
|
159
229
|
},
|
|
160
230
|
responseAdapter: {
|
|
161
231
|
type: Function,
|
|
162
|
-
default
|
|
163
|
-
// 默认适配器:假设返回格式为
|
|
164
|
-
/* {
|
|
165
|
-
"code": 1000,
|
|
166
|
-
"message": "ok",
|
|
167
|
-
"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\":\"\"}"
|
|
168
|
-
} */
|
|
169
|
-
let data = null;
|
|
170
|
-
if (responseData.code === 1000 && responseData.data) {
|
|
171
|
-
data = JSON.parse(responseData.data);
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
success: responseData.code === 1000,
|
|
175
|
-
// url: responseData.objx?.url,
|
|
176
|
-
message: responseData.message || "success",
|
|
177
|
-
fullResponse: responseData,
|
|
178
|
-
data: data,
|
|
179
|
-
};
|
|
180
|
-
},
|
|
232
|
+
default: adaptHisenseBatchUploadResponse,
|
|
181
233
|
},
|
|
182
234
|
},
|
|
183
235
|
components: {
|
|
@@ -455,7 +507,7 @@ export default {
|
|
|
455
507
|
let token = objx.apiToken;
|
|
456
508
|
if (token) {
|
|
457
509
|
this.token = token;
|
|
458
|
-
this.uploadUrl = objx.domain
|
|
510
|
+
this.uploadUrl = resolveBatchUploadUrl(objx.domain, objx.uploadApi);
|
|
459
511
|
this.deleteUrl = objx.domain + objx.deleteApi;
|
|
460
512
|
// https://crm-dev.hisense.com/api/v1.0/fileoperation/GetFile?fileName=e24a1ad9-6821-41c3-957c-0916077bb97f.jpg
|
|
461
513
|
this.viewApiUrl = objx.domain + objx.viewApi;
|
|
@@ -528,8 +580,9 @@ export default {
|
|
|
528
580
|
let source;
|
|
529
581
|
|
|
530
582
|
var form = new FormData();
|
|
531
|
-
//
|
|
532
|
-
|
|
583
|
+
// 一个文件一次请求,索引固定为 0
|
|
584
|
+
const fieldPrefix = "requests[0].";
|
|
585
|
+
form.append(fieldPrefix + "File", fileObj);
|
|
533
586
|
|
|
534
587
|
let customParam = {};
|
|
535
588
|
let entityId = this.formDataId;
|
|
@@ -547,8 +600,10 @@ export default {
|
|
|
547
600
|
Object.assign(customParam, uploadParam);
|
|
548
601
|
if (customParam) {
|
|
549
602
|
Object.keys(customParam).forEach((key) => {
|
|
603
|
+
if (key === "file" || key === "File") return;
|
|
604
|
+
let fieldKey = key.indexOf("requests[") === 0 ? key : fieldPrefix + key;
|
|
550
605
|
let value = customParam[key];
|
|
551
|
-
form.append(
|
|
606
|
+
form.append(fieldKey, value);
|
|
552
607
|
});
|
|
553
608
|
}
|
|
554
609
|
|