cloud-web-corejs 1.1.0-dev.71 → 1.1.0-dev.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.1.0-dev.71",
4
+ "version": "1.1.0-dev.73",
5
5
  "scripts": {
6
6
  "build:ace-resources": "node build/build-ace-resources.js",
7
7
  "build:tinymce-resources": "node build/build-tinymce-resources.js",
@@ -74,6 +74,7 @@ methods: {
74
74
  | `prefixIcon` | String | `""` | 前置图标类名 |
75
75
  | `suffixIcon` | String | `el-icon-tickets` | 后置图标类名。有内容并悬停出清空按钮时,这个图标会隐藏。传 `""` 可去掉 |
76
76
  | `popperClass` | String | `""` | 追加到下拉浮层上的类名 |
77
+ | `dropdownMaxWidth` | Number / String | `480` | 下拉最大宽度。最小宽度是输入框宽度,文字超出后换行 |
77
78
  | `itemTemplate` | Function | `null` | `(item) => html`。自定义下拉项 HTML。写了默认插槽时不使用 |
78
79
 
79
80
  `props.label` 是候选项上的字段名,`label` 是当前显示出来的文字,两者不是同一个值。
@@ -153,6 +153,13 @@ export default {
153
153
  type: String,
154
154
  default: "",
155
155
  },
156
+ /**
157
+ * 下拉最大宽度。最小宽度始终是输入框宽度,超出后换行。
158
+ */
159
+ dropdownMaxWidth: {
160
+ type: [Number, String],
161
+ default: 480,
162
+ },
156
163
  },
157
164
  data() {
158
165
  return {
@@ -198,6 +205,9 @@ export default {
198
205
  this.displayValue = this.storedLabel;
199
206
  this.lookupLabel(this.value);
200
207
  },
208
+ mounted() {
209
+ this.syncDropdownWidth();
210
+ },
201
211
  methods: {
202
212
  focus() {
203
213
  const input = this.$refs.input;
@@ -224,6 +234,7 @@ export default {
224
234
  && this._lastSuggestions.length
225
235
  ) {
226
236
  cb(this._lastSuggestions);
237
+ this.syncDropdownWidth();
227
238
  return;
228
239
  }
229
240
  this.lastQueryKeyword = keyword;
@@ -248,6 +259,7 @@ export default {
248
259
  const list = Array.isArray(rows) ? rows : [];
249
260
  this._lastSuggestions = list;
250
261
  cb(list);
262
+ this.syncDropdownWidth();
251
263
  };
252
264
  try {
253
265
  const ret = this.load(keyword, done);
@@ -336,8 +348,37 @@ export default {
336
348
  this.focused = true;
337
349
  const input = this.$refs.input;
338
350
  if (input) input.suggestionDisabled = false;
351
+ this.syncDropdownWidth();
339
352
  this.$emit("focus", event);
340
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
+ },
341
382
  handleBlur(event) {
342
383
  this.focused = false;
343
384
  this.$emit("blur", event);
@@ -410,10 +451,24 @@ export default {
410
451
  display: none;
411
452
  }
412
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
+
413
460
  .base-autocomplete-popper {
414
461
  .el-autocomplete-suggestion__list li {
462
+ height: auto;
463
+ padding-top: 6px;
464
+ padding-bottom: 6px;
415
465
  font-size: 13px;
416
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;
417
472
  }
418
473
  }
419
474
 
@@ -128,6 +128,7 @@ import FormItemWrapper from "./form-item-wrapper";
128
128
  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
+ import settingConfig from "@/settings.js";
131
132
 
132
133
  const BATCH_UPLOAD_API = "/api/v1.0/FileOperation/BatchUploadFilesFromPortal";
133
134
 
@@ -155,6 +156,26 @@ function resolveBatchUploadUrl(domain, uploadApi) {
155
156
  return (domain || "") + api;
156
157
  }
157
158
 
159
+ /** settings.hxFileLocalProxyEnabled 打开且处于 npm run dev 时,把海信绝对地址改写到本地 /hx-file。 */
160
+ function toDevProxyUrl(absoluteUrl) {
161
+ if (settingConfig.hxFileLocalProxyEnabled !== true) return absoluteUrl;
162
+ if (process.env.NODE_ENV !== "development") return absoluteUrl;
163
+ if (typeof window === "undefined" || !absoluteUrl) return absoluteUrl;
164
+ if (!/^https?:\/\//i.test(absoluteUrl)) return absoluteUrl;
165
+ try {
166
+ const parsed = new URL(absoluteUrl);
167
+ return (
168
+ window.location.origin +
169
+ "/hx-file/" +
170
+ parsed.host +
171
+ parsed.pathname +
172
+ parsed.search
173
+ );
174
+ } catch (e) {
175
+ return absoluteUrl;
176
+ }
177
+ }
178
+
158
179
  /**
159
180
  * 批量接口一次只带一个文件(requests[0])。
160
181
  * 外层 code=1000 只表示批次受理,需看明细 code;外层 2020 视为整批失败。
@@ -507,10 +528,12 @@ export default {
507
528
  let token = objx.apiToken;
508
529
  if (token) {
509
530
  this.token = token;
510
- this.uploadUrl = resolveBatchUploadUrl(objx.domain, objx.uploadApi);
511
- this.deleteUrl = objx.domain + objx.deleteApi;
531
+ this.uploadUrl = toDevProxyUrl(
532
+ resolveBatchUploadUrl(objx.domain, objx.uploadApi)
533
+ );
534
+ this.deleteUrl = toDevProxyUrl(objx.domain + objx.deleteApi);
512
535
  // https://crm-dev.hisense.com/api/v1.0/fileoperation/GetFile?fileName=e24a1ad9-6821-41c3-957c-0916077bb97f.jpg
513
- this.viewApiUrl = objx.domain + objx.viewApi;
536
+ this.viewApiUrl = toDevProxyUrl(objx.domain + objx.viewApi);
514
537
  // this.initShowUrl();
515
538
  // this.initCustomConfig();
516
539
  }
@@ -315,6 +315,9 @@ modules = {
315
315
  },
316
316
  mounted: async function () {
317
317
  this.handleOnMounted();
318
+ this.$nextTick(() => {
319
+ this.bindTreeFixedColumnSync();
320
+ });
318
321
  this.bootstrapDynamicColumnsBeforeInit().then(() => {
319
322
  this.initColumnWidgetConfig(() => {
320
323
  this.initTableList();
@@ -322,6 +325,7 @@ modules = {
322
325
  // 可能尚未就绪,结论未必准,之后每次 exportData 会按最新上下文自愈修正
323
326
  this.$nextTick(() => {
324
327
  this.markMaskedColumnsForExport();
328
+ this.bindTreeFixedColumnSync();
325
329
  });
326
330
  });
327
331
  });
@@ -3186,9 +3190,9 @@ modules = {
3186
3190
  parentField: "f_parent",
3187
3191
  transform: true,
3188
3192
  expandAll: true,
3189
- // expandAll 只在首次加载生效;增删节点走 setValue 整表重载并浅克隆
3190
- // 所有行,vxe 按引用匹配的展开记录会全部失效。reserve 按 _X_ROW_KEY
3191
- // 恢复展开状态(克隆保留该键),查询重载会重新生成键,互不干扰。
3193
+ // vxe 的 expandAll 只在首次加载生效。追加行由 addTableData
3194
+ // 展开新父行;reserve 按 _X_ROW_KEY 保留已有行的展开状态
3195
+ // (setValue 浅克隆后按引用匹配的展开记录会失效)。
3192
3196
  reserve: true,
3193
3197
  ...configuredTree,
3194
3198
  transform: true,
@@ -4651,6 +4655,11 @@ modules = {
4651
4655
  addTableData(rows, field) {
4652
4656
  let formDataModel = this.formModel;
4653
4657
  let tableRows = formDataModel[this.fieldKeyName] || [];
4658
+ let previousKeys = this.shouldExpandAddedTreeParents()
4659
+ ? new Set(
4660
+ tableRows.map((item) => item && item._X_ROW_KEY).filter(Boolean)
4661
+ )
4662
+ : null;
4654
4663
  let items;
4655
4664
  if (field) {
4656
4665
  // 用扁平表单数据做去重基准;树表(transform)下 vxe 的 fullData
@@ -4682,7 +4691,54 @@ modules = {
4682
4691
  }
4683
4692
  this.setValue(this.stripTreeContainerRows(tableRows));
4684
4693
  this.$nextTick(() => {
4685
- this.handleWbs();
4694
+ let pending = this.handleWbs();
4695
+ if (!previousKeys) return;
4696
+ let expand = () => this.expandAddedTreeParents(previousKeys);
4697
+ if (pending && typeof pending.then === "function") {
4698
+ pending.then(expand, expand);
4699
+ return;
4700
+ }
4701
+ expand();
4702
+ });
4703
+ },
4704
+ /**
4705
+ * 树表并且 expandAll 为真时,追加的父行需要展开。
4706
+ * expandAll 为假时保持收起。
4707
+ * @returns {Boolean}
4708
+ */
4709
+ shouldExpandAddedTreeParents() {
4710
+ if (!this.widget.options.isTreeTable) return false;
4711
+ let $grid = this.getGridTable();
4712
+ let expandAll = $grid?.treeConfig
4713
+ ? $grid.treeConfig.expandAll
4714
+ : this.widget.options.treeConfig?.expandAll;
4715
+ return !!expandAll;
4716
+ },
4717
+ /**
4718
+ * 只展开本次追加、并且下面挂了子行的父行。已有行的展开状态交给 reserve。
4719
+ * @param {Set} previousKeys 追加前已有行的 _X_ROW_KEY。
4720
+ */
4721
+ expandAddedTreeParents(previousKeys) {
4722
+ if (this.tableDestroyed || !previousKeys) return;
4723
+ let $grid = this.getGridTable();
4724
+ if (!$grid || !$grid.treeConfig || !$grid.treeConfig.expandAll) return;
4725
+ let { rowField, parentField } = this.getTreeFields($grid);
4726
+ let rows = this.formModel[this.fieldKeyName] || [];
4727
+ let added = rows.filter(
4728
+ (row) => row && row._X_ROW_KEY && !previousKeys.has(row._X_ROW_KEY)
4729
+ );
4730
+ if (!added.length) return;
4731
+ added.forEach((row) => {
4732
+ let hasChild = rows.some(
4733
+ (item) =>
4734
+ item
4735
+ && item !== row
4736
+ && !isRootParent(item[parentField])
4737
+ && treeKeyEquals(item[parentField], row[rowField])
4738
+ );
4739
+ if (hasChild) {
4740
+ this.setTreeExpandByRowKey($grid, row._X_ROW_KEY);
4741
+ }
4686
4742
  });
4687
4743
  },
4688
4744
  /** @param {Object} fieldWidget 组件 schema。@param {Object} obj VXE 单元格参数。@returns {String} 表单校验 prop。 */
@@ -6500,6 +6556,70 @@ modules = {
6500
6556
  $grid.setActiveRow(realRow);
6501
6557
  }
6502
6558
  },
6559
+ /**
6560
+ * 树展开/收起后把固定列容器高度对齐到当前表体。
6561
+ * vxe-table 3.5 的 recalculate 只更新 tableHeight,不调用 updateStyle。
6562
+ * 固定列容器仍停在展开前的高度并 overflow:hidden,主表对应单元格又是
6563
+ * fixed--hidden,子行左侧就会空出一块。
6564
+ */
6565
+ syncTreeFixedColumnLayout() {
6566
+ if (this.tableDestroyed) return;
6567
+ let $grid = this.getGridTable();
6568
+ if (!$grid || typeof $grid.updateStyle !== "function") return;
6569
+ let generation = (this.treeFixedLayoutGeneration || 0) + 1;
6570
+ this.treeFixedLayoutGeneration = generation;
6571
+ let apply = () => {
6572
+ if (this.tableDestroyed || this.treeFixedLayoutGeneration !== generation) {
6573
+ return;
6574
+ }
6575
+ let grid = this.getGridTable();
6576
+ if (grid && typeof grid.updateStyle === "function") {
6577
+ grid.updateStyle();
6578
+ }
6579
+ };
6580
+ apply();
6581
+ if (typeof $grid.recalculate !== "function") return;
6582
+ let pending = $grid.recalculate(true);
6583
+ if (pending && typeof pending.then === "function") {
6584
+ pending.then(apply, () => {});
6585
+ }
6586
+ },
6587
+ /**
6588
+ * 包住表格实例的 setTreeExpand。点击展开和业务里的 setTreeExpand /
6589
+ * setAllTreeExpand 最后都进这个方法,展开收尾后再刷一次固定列高度。
6590
+ * @param {Number} retry xTable 尚未挂载时的重试次数。
6591
+ */
6592
+ bindTreeFixedColumnSync(retry = 0) {
6593
+ if (!this.widget.options.isTreeTable || this.tableDestroyed) return;
6594
+ let $grid = this.getGridTable();
6595
+ let $xTable = $grid && $grid.$refs && $grid.$refs.xTable;
6596
+ if (!$xTable || typeof $xTable.setTreeExpand !== "function") {
6597
+ if (retry < 20) {
6598
+ this.$nextTick(() => {
6599
+ this.bindTreeFixedColumnSync(retry + 1);
6600
+ });
6601
+ }
6602
+ return;
6603
+ }
6604
+ if ($xTable.__treeFixedColumnSyncBound) return;
6605
+ let rawSetTreeExpand = $xTable.setTreeExpand;
6606
+ let that = this;
6607
+ $xTable.setTreeExpand = function (...args) {
6608
+ let result = rawSetTreeExpand.apply(this, args);
6609
+ let refresh = () => {
6610
+ if (!that.tableDestroyed) that.syncTreeFixedColumnLayout();
6611
+ };
6612
+ if (result && typeof result.then === "function") {
6613
+ return result.then((value) => {
6614
+ refresh();
6615
+ return value;
6616
+ });
6617
+ }
6618
+ refresh();
6619
+ return result;
6620
+ };
6621
+ $xTable.__treeFixedColumnSyncBound = true;
6622
+ },
6503
6623
  /**
6504
6624
  * 数据源重载后按 _X_ROW_KEY 找回 VXE 内部行并展开。
6505
6625
  * setValue 会浅克隆所有行,旧行引用对 setTreeExpand 是无效操作。