cloud-web-corejs 1.1.0-dev.72 → 1.1.0-dev.74

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.72",
4
+ "version": "1.1.0-dev.74",
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",
@@ -153,5 +153,5 @@ loadUserById(id, resolve) {
153
153
  - 关键词为空(含只有空格)时不调用 `load`。
154
154
  - 相同关键词且上次有结果时,不再重复请求。
155
155
  - 未选中新项就失焦:输入框还原为已保存的 `label`,下拉关闭,关键词高亮清除。已保存的 ID 不变。
156
- - 点清空:ID 和名称一起变成 `null`。
156
+ - 点清空:ID 和名称一起变成 `null`,下拉关闭。焦点还在时可以继续输入并重新查询。
157
157
  - `disabled`、`readonly` 时不发起查询。
@@ -336,10 +336,20 @@ export default {
336
336
  this.$emit("update:label", null);
337
337
  this.$emit("change", null, oldValue, null);
338
338
  this.$emit("clear");
339
+ // 清空按钮会把 el-autocomplete 的 activated 关掉,且不会再次触发 focus。
340
+ // 焦点还在时要重新打开,否则继续输入不会再出下拉。
341
+ this.keepSearching();
339
342
  this.$nextTick(() => {
340
343
  this.isSelecting = false;
344
+ this.keepSearching();
341
345
  });
342
346
  },
347
+ keepSearching() {
348
+ const input = this.$refs.input;
349
+ if (!input || !this.focused) return;
350
+ input.activated = true;
351
+ input.suggestionDisabled = false;
352
+ },
343
353
  handleInputChange(text) {
344
354
  if (this.isSelecting) return;
345
355
  this.$emit("input-change", text);
@@ -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 是无效操作。