@gct-paas/word 0.1.57 → 0.1.58

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.
@@ -85,6 +85,7 @@ export declare class DataManager {
85
85
  private scheduleLayout;
86
86
  getLabelPath(path: JsonPath): JsonPath;
87
87
  getHrefPath(path: JsonPath): JsonPath;
88
+ getIdPath(path: JsonPath): JsonPath;
88
89
  getFieldRuntimeSpecificConfigKeys(): string[];
89
90
  getRuntimeSpecificConfig(): [string, FieldRuntimeSpecificConfig][];
90
91
  setRuntimeSpecificConfig(entries: any): void;
@@ -121,6 +122,8 @@ export declare class DataManager {
121
122
  getLabel<T = any>(path: JsonPath): T | undefined;
122
123
  /** 获取与 value 并存的超链接 href;无或不可链时为 null/undefined */
123
124
  getHref<T = string>(path: JsonPath): T | null | undefined;
125
+ /** 获取与 value 并存的批次唯一标识;老数据可能为空 */
126
+ getId<T = string>(path: JsonPath): T | null | undefined;
124
127
  /** 子表数组路径下未软删行数 */
125
128
  countActiveSubtableRows(arrayPath: JsonPath): number;
126
129
  /**
@@ -328,7 +331,7 @@ export declare class DataManager {
328
331
  * @param runtimeValuePath 版面解析后的具体路径(可选)
329
332
  */
330
333
  removeFieldBindingData(designValuePath: JsonPath, runtimeValuePath?: JsonPath): void;
331
- /** 收集与字段绑定相关的路径(含 value / label / href 及通配符变体) */
334
+ /** 收集与字段绑定相关的路径(含 value / label / href / id 及通配符变体) */
332
335
  private collectFieldBindingPaths;
333
336
  /** 收集可从 rawData 删除的具体路径(跳过含通配符的设计路径) */
334
337
  private collectConcreteRawDataPaths;
@@ -2,11 +2,14 @@
2
2
  export declare const LABEL_SUFFIX = "_lb_";
3
3
  /** 与 rawData 并存的外链 href 后缀(超链接字段) */
4
4
  export declare const HREF_SUFFIX = "_href_";
5
+ /** 与 rawData 并存的 id 后缀(批次字段,如 material_no_ → material_no__id_) */
6
+ export declare const ID_SUFFIX = "_id_";
5
7
  /** 版面超链接文字颜色 */
6
8
  export declare const HYPERLINK_TEXT_COLOR = "#0563c1";
7
9
  export declare function getLabelPath(path: string): string;
8
10
  export declare function getHrefPath(path: string): string;
9
- /** 派生数据路径(label / href),不参与 changedMap / 业务副作用 */
11
+ export declare function getIdPath(path: string): string;
12
+ /** 派生数据路径(label / href / id),不参与 changedMap / 业务副作用 */
10
13
  export declare function isDerivedDataPath(path: string): boolean;
11
14
  /** 子表行内仅前端使用、不参与提交的字段 */
12
15
  export declare const ROW_RUNTIME_META_KEYS: Set<string>;
@@ -0,0 +1,9 @@
1
+ import { Doc } from '../../view/Doc';
2
+ import { WidgetMeta } from '../../widget/widget-meta';
3
+ import { DataEnricherRegistration } from '../enricher-types';
4
+ type IdEnricherOptions = Omit<DataEnricherRegistration, 'enrich'> & {
5
+ doc: Doc;
6
+ widgetMeta: WidgetMeta;
7
+ };
8
+ export declare function createIdEnricher(reg: IdEnricherOptions): DataEnricherRegistration;
9
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { EmitSource } from './emit-source';
2
- export type PipelineLogNS = 'data.emit' | 'pipeline.hydrate' | 'pipeline.onChange' | 'pipeline.deps' | 'enricher.label' | 'enricher.hyperlink' | 'pipeline.afterFlush' | 'table.runtime' | 'init.lifecycle' | 'submit.prepare';
2
+ export type PipelineLogNS = 'data.emit' | 'pipeline.hydrate' | 'pipeline.onChange' | 'pipeline.deps' | 'enricher.label' | 'enricher.hyperlink' | 'enricher.id' | 'pipeline.afterFlush' | 'table.runtime' | 'init.lifecycle' | 'submit.prepare';
3
3
  export type PipelineLogLevel = 'debug' | 'info' | 'warn' | 'error';
4
4
  export interface PipelineLogEvent {
5
5
  ns: PipelineLogNS;
@@ -39,7 +39,7 @@ export interface JoinRule {
39
39
  export interface ApiRule {
40
40
  type: 'api';
41
41
  /** 请求函数 key */
42
- fetcher: 'ref' | 'lot2sn' | 'rdo2ref' | 'ref2lot2sn';
42
+ fetcher: 'ref' | 'rdo2ref' | 'ref2lot2sn';
43
43
  /** 仅主模型字段可发起请求 */
44
44
  onlyMainModelFieldsCanRequest: boolean;
45
45
  /** 失败时的默认 label */
@@ -65,7 +65,11 @@ export interface HyperlinkRule {
65
65
  export interface LabelRule {
66
66
  type: 'label';
67
67
  }
68
- export type ValueChangeRule = HyperlinkRule | LabelRule;
68
+ /** 值变化后补全批次唯一标识(companion `_id_` 字段) */
69
+ export interface IdRule {
70
+ type: 'id';
71
+ }
72
+ export type ValueChangeRule = HyperlinkRule | LabelRule | IdRule;
69
73
  /** 将 manifest 中的 onValueChangeRule 规范为数组 */
70
74
  export declare function normalizeValueChangeRules(rule?: ValueChangeRule | ValueChangeRule[]): ValueChangeRule[];
71
75
  export type ComputedRule = PriorityRule | ResolveRule | MapRule | JoinRule | ApiRule;
@@ -74,6 +78,6 @@ export interface FieldComputedConfig {
74
78
  propRules?: Record<string, ComputedRule>;
75
79
  /** 写入 dataManager 的派生规则 */
76
80
  defaultValueRule?: ComputedRule;
77
- /** 填报值变化后的 enrich(超链接 _href_、展示标签 _lb_) */
81
+ /** 填报值变化后的 enrich(超链接 _href_、展示标签 _lb_、批次 _id_) */
78
82
  onValueChangeRule?: ValueChangeRule | ValueChangeRule[];
79
83
  }
@@ -62,6 +62,6 @@ export declare class LinkageEngine {
62
62
  buildFillFromOption(ctx: TableRuntimeContext, fieldKey: string, rowIndex: number, selectedOption: Record<string, unknown>): Record<string, unknown>;
63
63
  /** 将单条 FieldOptionFillDef 映射写入 updates */
64
64
  private applyOptionFillDef;
65
- /** 构建字段清空更新对象(同时清值与 _lb_ 标签) */
65
+ /** 构建字段清空更新对象(同时清值、_lb_ 标签与 companion _id_) */
66
66
  private buildClearUpdates;
67
67
  }
package/dist/index.es.js CHANGED
@@ -33385,6 +33385,7 @@ function normalizeValueChangeRules(rule) {
33385
33385
  }
33386
33386
  const LABEL_SUFFIX = "_lb_";
33387
33387
  const HREF_SUFFIX = "_href_";
33388
+ const ID_SUFFIX = "_id_";
33388
33389
  const HYPERLINK_TEXT_COLOR = "#0563c1";
33389
33390
  function getLabelPath(path) {
33390
33391
  return path + LABEL_SUFFIX;
@@ -33392,8 +33393,11 @@ function getLabelPath(path) {
33392
33393
  function getHrefPath(path) {
33393
33394
  return path + HREF_SUFFIX;
33394
33395
  }
33396
+ function getIdPath(path) {
33397
+ return path + ID_SUFFIX;
33398
+ }
33395
33399
  function isDerivedDataPath(path) {
33396
- return path.endsWith(LABEL_SUFFIX) || path.endsWith(HREF_SUFFIX);
33400
+ return path.endsWith(LABEL_SUFFIX) || path.endsWith(HREF_SUFFIX) || path.endsWith(ID_SUFFIX);
33397
33401
  }
33398
33402
  const ROW_RUNTIME_META_KEYS = /* @__PURE__ */ new Set([
33399
33403
  "row_source_",
@@ -34167,7 +34171,7 @@ const apiFetchers = {
34167
34171
  cachePrefix: "lot2sn",
34168
34172
  cacheTTL: 5 * 60 * 1e3,
34169
34173
  fetchDataList: async (params) => {
34170
- const { queryData = {}, pageNo = 1, pageSize = 20 } = params;
34174
+ const { queryData = {}, exp, pageNo = 1, pageSize = 20 } = params;
34171
34175
  const result = await api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey(
34172
34176
  {
34173
34177
  modelCategory: API_CONFIG.ENTITY_CATEGORY,
@@ -34176,6 +34180,7 @@ const apiFetchers = {
34176
34180
  },
34177
34181
  {},
34178
34182
  {
34183
+ exp,
34179
34184
  query: queryData,
34180
34185
  pageSize,
34181
34186
  pageNo
@@ -34188,28 +34193,6 @@ const apiFetchers = {
34188
34193
  totalCount: totalCount || 0
34189
34194
  };
34190
34195
  },
34191
- fetchOne: async (id) => {
34192
- if (!id) return {};
34193
- const result = await api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey(
34194
- {
34195
- modelCategory: API_CONFIG.ENTITY_CATEGORY,
34196
- modelKey: API_CONFIG.LOT_DEFAULTS.modelKey,
34197
- bsKey: API_CONFIG.LOT_DEFAULTS.bsKey
34198
- },
34199
- {},
34200
- {
34201
- query: { "name_.like": id },
34202
- pageSize: 20,
34203
- pageNo: 1
34204
- }
34205
- );
34206
- const { data = [], totalPage, dict, totalCount } = result || {};
34207
- return {
34208
- data: transformSourceDataList(data || [], dict) || [],
34209
- totalPage,
34210
- totalCount: totalCount || 0
34211
- };
34212
- },
34213
34196
  transformers: {
34214
34197
  toOptions(items) {
34215
34198
  const transformer = createTransformer("name_", "name_");
@@ -34336,11 +34319,7 @@ const apiFetchers = {
34336
34319
  cachePrefix: "productRdo2ref",
34337
34320
  cacheTTL: 5 * 60 * 1e3,
34338
34321
  fetchDataList: async (params) => {
34339
- const {
34340
- queryData = {},
34341
- pageNo = 1,
34342
- pageSize = 20
34343
- } = params;
34322
+ const { queryData = {}, pageNo = 1, pageSize = 20 } = params;
34344
34323
  const result = await api.apaas.modelComprehensive.postBizServiceGeneralModelCategoryModelKeyBsKey(
34345
34324
  {
34346
34325
  modelCategory: API_CONFIG.ENTITY_CATEGORY,
@@ -34374,20 +34353,12 @@ function fieldNeedsLabelEnrichment(fieldType, manifest2) {
34374
34353
  if (rules2.some((rule) => rule.type === "label")) return true;
34375
34354
  return false;
34376
34355
  }
34377
- function getRowPathFromFieldPath(path) {
34378
- const parsed = parseValuePath(path);
34379
- if (!parsed.isSubTable) return "$";
34380
- const normalized = path.replace(/^\$\./, "");
34381
- const lastDot = normalized.lastIndexOf(".");
34382
- if (lastDot < 0) return "$";
34383
- return `$.${normalized.slice(0, lastDot)}`;
34384
- }
34385
34356
  function getDictFieldKey(path, fieldBinding) {
34386
34357
  const parsed = parseValuePath(path);
34387
34358
  return parsed.fieldKey || getLastSegment(fieldBinding.fieldLink) || "";
34388
34359
  }
34389
34360
  function readDictLabel(dataManager, path, fieldBinding, value, dictFieldKey) {
34390
- const rowPath = getRowPathFromFieldPath(path);
34361
+ const rowPath = getBeforeBracket(path);
34391
34362
  const row = rowPath ? dataManager.get(rowPath) : dataManager.getRawData();
34392
34363
  const fieldKey = dictFieldKey || getDictFieldKey(path, fieldBinding);
34393
34364
  const dict = row?._DICT?.[fieldKey];
@@ -34435,7 +34406,7 @@ async function readApiLabel(strategy, value, fieldBinding, loadFieldByKey) {
34435
34406
  refModelKey: fieldInfo?.bindInfo
34436
34407
  };
34437
34408
  try {
34438
- const isSingle = strategy.fetcher === "rdo2ref" || strategy.fetcher === "ref2lot2sn" || strategy.fetcher === "lot2sn";
34409
+ const isSingle = strategy.fetcher === "rdo2ref" || strategy.fetcher === "ref2lot2sn";
34439
34410
  const result = isSingle ? await fetcher.getOptionById(String(value), params) : await fetcher.getOptionByIds(getValue$1(value, true), params);
34440
34411
  const list = Array.isArray(result) ? result : result ? [result] : [];
34441
34412
  const labels = list.map((item) => item?.label).filter(Boolean);
@@ -35691,13 +35662,14 @@ class LinkageEngine {
35691
35662
  if (isBlank(value)) return;
35692
35663
  updates[`${rowPath}.${def.toField}`] = value;
35693
35664
  }
35694
- /** 构建字段清空更新对象(同时清值与 _lb_ 标签) */
35665
+ /** 构建字段清空更新对象(同时清值、_lb_ 标签与 companion _id_) */
35695
35666
  buildClearUpdates(rowPath, clearFieldKeys) {
35696
35667
  const updates = {};
35697
35668
  for (const clearFieldKey of clearFieldKeys) {
35698
35669
  const fieldPath = `${rowPath}.${clearFieldKey}`;
35699
35670
  updates[fieldPath] = void 0;
35700
35671
  updates[getLabelPath(fieldPath)] = void 0;
35672
+ updates[getIdPath(fieldPath)] = void 0;
35701
35673
  }
35702
35674
  return updates;
35703
35675
  }
@@ -36067,6 +36039,7 @@ const NS_LABEL = {
36067
36039
  "pipeline.deps": "依赖刷新",
36068
36040
  "enricher.label": "标签增强",
36069
36041
  "enricher.hyperlink": "超链接增强",
36042
+ "enricher.id": "批次内置ID",
36070
36043
  "pipeline.afterFlush": "业务收尾",
36071
36044
  "table.runtime": "业务子表",
36072
36045
  "init.lifecycle": "文档初始化",
@@ -36345,6 +36318,76 @@ function createHyperlinkEnricher(reg) {
36345
36318
  }
36346
36319
  };
36347
36320
  }
36321
+ function resolveProductId(doc, path) {
36322
+ const dataManager = doc.dataManager;
36323
+ const rowPath = getBeforeBracket(path);
36324
+ if (rowPath) {
36325
+ const row = dataManager.get(rowPath);
36326
+ const productId = row?.product_id_;
36327
+ return productId != null && productId !== "" ? String(productId) : void 0;
36328
+ }
36329
+ const fromParams = doc.paramsConfig?.productId ?? doc.paramsConfig?.product_id_;
36330
+ return fromParams != null && fromParams !== "" ? String(fromParams) : void 0;
36331
+ }
36332
+ function shouldPreservePersistedId(dataManager, valuePath, ctx) {
36333
+ if (ctx?.batchSource !== "hydrate") return false;
36334
+ if (ctx.oldValue !== ctx.newValue) return false;
36335
+ return isPresent(dataManager.get(getIdPath(valuePath)));
36336
+ }
36337
+ function extractCompanionId(result) {
36338
+ if (result == null || result === "" || result === false) return null;
36339
+ if (typeof result === "string" || typeof result === "number") return String(result);
36340
+ if (typeof result === "object") {
36341
+ const record = result;
36342
+ const id = record.id_ ?? record.id;
36343
+ return id != null && id !== "" ? String(id) : null;
36344
+ }
36345
+ return null;
36346
+ }
36347
+ async function resolveLotCompanionId(path, value, productId) {
36348
+ if (value == null || value === "") return null;
36349
+ try {
36350
+ const result = await api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey(
36351
+ {
36352
+ bsKey: "biz_get_single_production_identification",
36353
+ modelKey: "em_production_identification",
36354
+ modelCategory: "entity"
36355
+ },
36356
+ {
36357
+ name_: value,
36358
+ ...productId ? { product_id_: productId } : {}
36359
+ },
36360
+ {}
36361
+ );
36362
+ return extractCompanionId(result);
36363
+ } catch {
36364
+ return null;
36365
+ }
36366
+ }
36367
+ function createIdEnricher(reg) {
36368
+ const { doc, widgetMeta, ...rest } = reg;
36369
+ return {
36370
+ ...rest,
36371
+ id: rest.id || `id:${rest.valuePathTemplate}`,
36372
+ enrich: async (path, value, ctx) => {
36373
+ const dataManager = doc.dataManager;
36374
+ const idPath = getIdPath(path);
36375
+ if (shouldPreservePersistedId(dataManager, path, ctx)) return;
36376
+ if (value == null || value === "") {
36377
+ return { [idPath]: null };
36378
+ }
36379
+ if (isPresent(dataManager.get(idPath))) return;
36380
+ const productId = resolveProductId(doc, path);
36381
+ const id = await withRequestCache.handleRequest(
36382
+ "id_enrich_resolve",
36383
+ { path, value, productId },
36384
+ ({ path: reqPath, value: reqValue, productId: reqProductId }) => resolveLotCompanionId(reqPath, reqValue, reqProductId),
36385
+ 30 * 1e3
36386
+ );
36387
+ return { [idPath]: id };
36388
+ }
36389
+ };
36390
+ }
36348
36391
  class Hooks {
36349
36392
  /**
36350
36393
  * @callback HookCallback
@@ -84101,6 +84144,17 @@ function buildFieldEnricherRegistrations(instances, ctx, doc) {
84101
84144
  })
84102
84145
  );
84103
84146
  }
84147
+ if (valueChangeRules.some((rule) => rule.type === "id")) {
84148
+ regs.push(
84149
+ createIdEnricher({
84150
+ id: `id:${valuePath}`,
84151
+ valuePathTemplate: valuePath,
84152
+ match: createValuePathMatcher(valuePath),
84153
+ doc,
84154
+ widgetMeta: instance2.widgetMeta
84155
+ })
84156
+ );
84157
+ }
84104
84158
  if (fieldNeedsLabelEnrichment(fieldMeta.fieldType, manifest2)) {
84105
84159
  const enricherProps = resolveEnricherWidgetProps(instance2, manifest2);
84106
84160
  regs.push(
@@ -84169,7 +84223,12 @@ function collectSubtableRowEnrichPaths(instances, subFieldKey, rowIndexes) {
84169
84223
  if (parsed.parentFieldKey !== subFieldKey) continue;
84170
84224
  for (const rowIndex of uniqueIndexes) {
84171
84225
  paths.add(
84172
- replacePathIndexPlaceholders({ templatePath: valuePath, n: rowIndex, y: rowIndex, x: rowIndex })
84226
+ replacePathIndexPlaceholders({
84227
+ templatePath: valuePath,
84228
+ n: rowIndex,
84229
+ y: rowIndex,
84230
+ x: rowIndex
84231
+ })
84173
84232
  );
84174
84233
  }
84175
84234
  }
@@ -85159,9 +85218,10 @@ const optionsMapEnumConfig = {
85159
85218
  };
85160
85219
  const labelOnValueChangeRule = { type: "label" };
85161
85220
  const hyperlinkOnValueChangeRule = { type: "hyperlink" };
85162
- const hyperlinkAndLabelOnValueChangeRules = [
85221
+ const idOnValueChangeRule = { type: "id" };
85222
+ const hyperlinkAndIdOnValueChangeRules = [
85163
85223
  hyperlinkOnValueChangeRule,
85164
- labelOnValueChangeRule
85224
+ idOnValueChangeRule
85165
85225
  ];
85166
85226
  function mergeCheckTableItemInfosIntoDefaults(defaultsMap, region, infos, layoutColumnCount) {
85167
85227
  applySubFieldDefaults(defaultsMap, region, infos, layoutColumnCount ?? 0);
@@ -101033,7 +101093,7 @@ class PostChangePipeline {
101033
101093
  }
101034
101094
  }
101035
101095
  if (Object.keys(updates).length) {
101036
- const enrichLogNs = enricherIds.some((id) => id.startsWith("label")) ? "enricher.label" : "enricher.hyperlink";
101096
+ const enrichLogNs = enricherIds.some((id) => id.startsWith("label")) ? "enricher.label" : enricherIds.some((id) => id.startsWith("id")) ? "enricher.id" : "enricher.hyperlink";
101037
101097
  createPipelineLogger(enrichLogNs, { batchId, path }).debug(
101038
101098
  `写回增强字段:${Object.keys(updates).join("、")}`,
101039
101099
  { enricherId: enricherIds.join(","), keys: Object.keys(updates) }
@@ -101230,6 +101290,9 @@ class DataManager {
101230
101290
  getHrefPath(path) {
101231
101291
  return getHrefPath(path);
101232
101292
  }
101293
+ getIdPath(path) {
101294
+ return getIdPath(path);
101295
+ }
101233
101296
  getFieldRuntimeSpecificConfigKeys() {
101234
101297
  return [...this.fieldRuntimeConfigByPath.keys()];
101235
101298
  }
@@ -101423,6 +101486,10 @@ class DataManager {
101423
101486
  getHref(path) {
101424
101487
  return this.get(this.getHrefPath(path));
101425
101488
  }
101489
+ /** 获取与 value 并存的批次唯一标识;老数据可能为空 */
101490
+ getId(path) {
101491
+ return this.get(this.getIdPath(path));
101492
+ }
101426
101493
  /** 子表数组路径下未软删行数 */
101427
101494
  countActiveSubtableRows(arrayPath) {
101428
101495
  const rows = this.getByPath(this.rawData, arrayPath);
@@ -102476,9 +102543,14 @@ class DataManager {
102476
102543
  }
102477
102544
  this.removeFieldDependencies(designValuePath);
102478
102545
  }
102479
- /** 收集与字段绑定相关的路径(含 value / label / href 及通配符变体) */
102546
+ /** 收集与字段绑定相关的路径(含 value / label / href / id 及通配符变体) */
102480
102547
  collectFieldBindingPaths(designValuePath) {
102481
- const bases = [designValuePath, getLabelPath(designValuePath), getHrefPath(designValuePath)];
102548
+ const bases = [
102549
+ designValuePath,
102550
+ getLabelPath(designValuePath),
102551
+ getHrefPath(designValuePath),
102552
+ getIdPath(designValuePath)
102553
+ ];
102482
102554
  const wildcardKeys = new Set(bases.map((path) => this.convertPathToWildcard(path)));
102483
102555
  const result = new Set(bases);
102484
102556
  const scanTargets = [
@@ -102501,15 +102573,19 @@ class DataManager {
102501
102573
  paths.add(path);
102502
102574
  paths.add(getLabelPath(path));
102503
102575
  paths.add(getHrefPath(path));
102576
+ paths.add(getIdPath(path));
102504
102577
  }
102505
102578
  return [...paths];
102506
102579
  }
102507
102580
  /** 移除字段注册的组件依赖 */
102508
102581
  removeFieldDependencies(designValuePath) {
102509
102582
  const wildcardKeys = new Set(
102510
- [designValuePath, getLabelPath(designValuePath), getHrefPath(designValuePath)].map(
102511
- (path) => this.convertPathToWildcard(path)
102512
- )
102583
+ [
102584
+ designValuePath,
102585
+ getLabelPath(designValuePath),
102586
+ getHrefPath(designValuePath),
102587
+ getIdPath(designValuePath)
102588
+ ].map((path) => this.convertPathToWildcard(path))
102513
102589
  );
102514
102590
  const nodes = this.collectDepNodes();
102515
102591
  const removedKeys = /* @__PURE__ */ new Set();
@@ -110011,11 +110087,14 @@ function transformTreeData(options = [], currentValue) {
110011
110087
  });
110012
110088
  return { data: treeData, highlightIdx };
110013
110089
  }
110014
- function transformLotData(options = [], currentValue) {
110090
+ function transformLotData(options = [], currentValue, currentId) {
110015
110091
  const highlightIdx = { index: [] };
110016
110092
  const values = Array.isArray(currentValue) ? currentValue.filter((v) => !isNil(v)) : [currentValue].filter((v) => !isNil(v));
110093
+ const preferId = !!currentId;
110017
110094
  const showOptions = (options || []).map((item, index2) => {
110018
- if (values.includes(item.value)) {
110095
+ const matchedById = preferId && item._item?.id_ === currentId;
110096
+ const matchedByValue = !preferId && values.includes(item.value);
110097
+ if (matchedById || matchedByValue) {
110019
110098
  highlightIdx.index.push(index2);
110020
110099
  }
110021
110100
  return {
@@ -121338,12 +121417,7 @@ const manifest$F = {
121338
121417
  ...commonDefaultProps
121339
121418
  },
121340
121419
  computed: {
121341
- defaultValueRule: {
121342
- type: "api",
121343
- fetcher: "lot2sn",
121344
- onlyMainModelFieldsCanRequest: true
121345
- },
121346
- onValueChangeRule: labelOnValueChangeRule
121420
+ onValueChangeRule: idOnValueChangeRule
121347
121421
  }
121348
121422
  };
121349
121423
  const __vite_glob_0_24 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -121964,12 +122038,7 @@ const manifest$f = {
121964
122038
  ...commonDefaultProps
121965
122039
  },
121966
122040
  computed: {
121967
- defaultValueRule: {
121968
- type: "api",
121969
- fetcher: "lot2sn",
121970
- onlyMainModelFieldsCanRequest: true
121971
- },
121972
- onValueChangeRule: [...hyperlinkAndLabelOnValueChangeRules]
122041
+ onValueChangeRule: [...hyperlinkAndIdOnValueChangeRules]
121973
122042
  }
121974
122043
  };
121975
122044
  const __vite_glob_0_50 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -122117,12 +122186,7 @@ const manifest$9 = {
122117
122186
  ...commonDefaultProps
122118
122187
  },
122119
122188
  computed: {
122120
- defaultValueRule: {
122121
- type: "api",
122122
- fetcher: "lot2sn",
122123
- onlyMainModelFieldsCanRequest: true
122124
- },
122125
- onValueChangeRule: [...hyperlinkAndLabelOnValueChangeRules]
122189
+ onValueChangeRule: [...hyperlinkAndIdOnValueChangeRules]
122126
122190
  }
122127
122191
  };
122128
122192
  const __vite_glob_0_56 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -122253,6 +122317,9 @@ const filterFn = (f) => {
122253
122317
  ].includes(f.key)) {
122254
122318
  return false;
122255
122319
  }
122320
+ if (f.createType === "BUILTIN" && f.key && f.key.endsWith(ID_SUFFIX) && f.type === FIELD_TYPE.TEXT) {
122321
+ return false;
122322
+ }
122256
122323
  return true;
122257
122324
  };
122258
122325
  const FieldIconFallbackMap = {
@@ -136024,6 +136091,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
136024
136091
  columns: {},
136025
136092
  tableData: {},
136026
136093
  modelValue: {},
136094
+ selectedId: {},
136027
136095
  loading: { type: Boolean },
136028
136096
  height: { default: "100%" },
136029
136097
  autoResize: { type: Boolean, default: true },
@@ -136056,6 +136124,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
136056
136124
  return result;
136057
136125
  });
136058
136126
  const rowClassName = ({ row }) => {
136127
+ if (props.selectedId) {
136128
+ return row._item?.id_ === props.selectedId ? "row--active" : "";
136129
+ }
136059
136130
  return selectedIds.value.has(row.__VALUE__) ? "row--active" : "";
136060
136131
  };
136061
136132
  const onCellClick = ({ row }) => {
@@ -136127,7 +136198,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
136127
136198
  };
136128
136199
  }
136129
136200
  });
136130
- const BaseVxeTable = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-8ae65aef"]]);
136201
+ const BaseVxeTable = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-c169ed2c"]]);
136131
136202
  const DEVICE_TYPE_MODEL_KEY = "em_device_type";
136132
136203
  const ENTITY_CATEGORY = "entity";
136133
136204
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
@@ -136431,35 +136502,39 @@ function shouldEnableLinkage(doc, clickedFieldType, clickedKey) {
136431
136502
  return key === clickedKey && fieldMeta.fieldType === targetLinkedFieldType;
136432
136503
  });
136433
136504
  }
136434
- function buildLikeQuery(fields2, keyword, query) {
136435
- if (!keyword?.trim()) {
136436
- return {
136437
- queryData: { ...query },
136438
- exp: ""
136439
- };
136505
+ function buildLikeQuery(fields2, keyword, query = {}) {
136506
+ const resultQuery = {
136507
+ ...query
136508
+ };
136509
+ const queryExp = Object.keys(query);
136510
+ let likeExp = "";
136511
+ if (keyword?.trim()) {
136512
+ fields2.forEach((field) => {
136513
+ const key = field.includes(".") ? field : `${field}.iLike`;
136514
+ resultQuery[key] = keyword;
136515
+ });
136516
+ likeExp = `OR(${fields2.map((field) => field.includes(".") ? field : `${field}.iLike`).join(",")})`;
136440
136517
  }
136441
- const queryData = fields2.reduce(
136442
- (prev, field) => {
136443
- const expKey = field.includes(".") ? field : field + ".iLike";
136444
- prev[expKey] = keyword;
136445
- return prev;
136446
- },
136447
- {
136448
- ...query
136449
- }
136450
- );
136451
- const exp = `OR(${fields2.map((k) => `${k}.iLike`).join(",")})`;
136452
- return { queryData, exp };
136518
+ const baseExp = queryExp.length ? `OR(${queryExp.join(",")})` : "";
136519
+ let exp = "";
136520
+ if (baseExp && likeExp) {
136521
+ exp = `AND(${baseExp},${likeExp})`;
136522
+ } else {
136523
+ exp = baseExp || likeExp;
136524
+ }
136525
+ return {
136526
+ queryData: resultQuery,
136527
+ exp
136528
+ };
136453
136529
  }
136454
136530
  const selectStrategyMap = {
136455
136531
  [FIELD_TYPE.MATERIAL_NO]: {
136456
136532
  columnsKey: "lot-sn",
136457
136533
  fetcher: "lot2sn",
136458
136534
  allowManualInput: true,
136535
+ persistOptionId: true,
136459
136536
  buildQuery({ keyword, extraParams }) {
136460
- return buildLikeQuery(["name_"], keyword, {
136461
- ...extraParams
136462
- });
136537
+ return buildLikeQuery(["name_"], keyword, { "product_id_.isNotNull": null, ...extraParams });
136463
136538
  },
136464
136539
  transform: transformLotData
136465
136540
  },
@@ -136467,8 +136542,9 @@ const selectStrategyMap = {
136467
136542
  columnsKey: "lot-sn",
136468
136543
  fetcher: "lot2sn",
136469
136544
  allowManualInput: true,
136470
- buildQuery({ keyword }) {
136471
- return buildLikeQuery(["name_"], keyword, {});
136545
+ persistOptionId: true,
136546
+ buildQuery({ keyword, extraParams }) {
136547
+ return buildLikeQuery(["name_"], keyword, { "product_id_.isNotNull": null, ...extraParams });
136472
136548
  },
136473
136549
  transform: transformLotData
136474
136550
  },
@@ -136476,8 +136552,9 @@ const selectStrategyMap = {
136476
136552
  columnsKey: "lot-sn",
136477
136553
  fetcher: "lot2sn",
136478
136554
  allowManualInput: true,
136479
- buildQuery({ keyword }) {
136480
- return buildLikeQuery(["name_"], keyword, {});
136555
+ persistOptionId: true,
136556
+ buildQuery({ keyword, extraParams }) {
136557
+ return buildLikeQuery(["name_"], keyword, { "product_id_.isNotNull": null, ...extraParams });
136481
136558
  },
136482
136559
  transform: transformLotData
136483
136560
  },
@@ -136687,6 +136764,11 @@ function useTableDropdown(props, searchFilters) {
136687
136764
  const strategy = computed(() => getSelectStrategy(widgetProps.value, fieldMeta.value?.fieldType));
136688
136765
  const isDeviceField = computed(() => fieldInfo.value?.type === FIELD_TYPE.DEVICE);
136689
136766
  const columns2 = computed(() => getColumns(strategy.value.columnsKey, strategy.value.isTree));
136767
+ const selectedId = computed(() => {
136768
+ if (!runtimeValuePath.value) return void 0;
136769
+ const id = docInst.value.dataManager.get(getIdPath(runtimeValuePath.value));
136770
+ return id != null && id !== "" ? String(id) : void 0;
136771
+ });
136690
136772
  const businessLinkage = computed(
136691
136773
  () => new TableRuntime(docInst.value).resolveSelectLinkage({
136692
136774
  subFieldKey: fieldMeta.value?.subFieldKey,
@@ -136799,7 +136881,7 @@ function useTableDropdown(props, searchFilters) {
136799
136881
  pageNo,
136800
136882
  pageSize
136801
136883
  });
136802
- const info = transform(res.options ?? [], props.modelValue);
136884
+ const info = transform(res.options ?? [], props.modelValue, selectedId.value);
136803
136885
  return {
136804
136886
  data: info.data || [],
136805
136887
  totalPage: Number(res?.totalPage ?? 0),
@@ -136808,6 +136890,7 @@ function useTableDropdown(props, searchFilters) {
136808
136890
  };
136809
136891
  };
136810
136892
  const allowManualInput = computed(() => strategy.value.allowManualInput ?? false);
136893
+ const persistOptionId = computed(() => !!strategy.value.persistOptionId);
136811
136894
  return {
136812
136895
  fetcher,
136813
136896
  columns: columns2,
@@ -136818,7 +136901,9 @@ function useTableDropdown(props, searchFilters) {
136818
136901
  enableLinkage,
136819
136902
  clearValuePath,
136820
136903
  allowManualInput,
136821
- isDeviceField
136904
+ isDeviceField,
136905
+ selectedId,
136906
+ persistOptionId
136822
136907
  };
136823
136908
  }
136824
136909
  const _hoisted_1$7 = { class: "table-dropdown" };
@@ -136854,7 +136939,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
136854
136939
  columns: columns2,
136855
136940
  fetcher: baseFetcher,
136856
136941
  allowManualInput,
136857
- isDeviceField
136942
+ isDeviceField,
136943
+ selectedId,
136944
+ persistOptionId
136858
136945
  } = useTableDropdown(props, searchFilters);
136859
136946
  const fetcher = (opts) => baseFetcher({ ...opts, deviceTypeId: deviceTypeId.value });
136860
136947
  const showManualInputBtn = computed(() => allowManualInput.value && !!keyword.value?.trim());
@@ -136889,6 +136976,10 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
136889
136976
  const onChangeSelect = (row) => {
136890
136977
  const { __VALUE__ } = row || {};
136891
136978
  const data = setValue(__VALUE__ ? __VALUE__ : void 0, runtimeValuePath.value);
136979
+ if (persistOptionId.value) {
136980
+ const idPath = getIdPath(runtimeValuePath.value);
136981
+ Object.assign(data, setValue(row?._item?.id_ ?? void 0, idPath));
136982
+ }
136892
136983
  if (clearValuePath.value) {
136893
136984
  const clearData = setValue(void 0, clearValuePath.value);
136894
136985
  Object.assign(data, clearData);
@@ -136987,10 +137078,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
136987
137078
  columns: unref(columns2),
136988
137079
  tableData: unref(tableData),
136989
137080
  modelValue: __props.modelValue,
137081
+ selectedId: unref(selectedId),
136990
137082
  loading: unref(loading),
136991
137083
  "show-row-selection-mode": "",
136992
137084
  onChangeSelect
136993
- }, null, 8, ["columns", "tableData", "modelValue", "loading"]),
137085
+ }, null, 8, ["columns", "tableData", "modelValue", "selectedId", "loading"]),
136994
137086
  unref(hasData) ? (openBlock(), createBlock(paginationControl, {
136995
137087
  key: 2,
136996
137088
  pagination: unref(pagination),
@@ -81,6 +81,4 @@ export declare const apiFetchers: {
81
81
  /** 产品但要 ref */
82
82
  productRdo2ref: APIFetcher;
83
83
  };
84
- /** 清除指定类型的缓存 */
85
- export declare function clearApiFetcherCache(type: 'dept' | 'user' | 'ref' | 'lot2sn' | 'ref2lot2sn' | 'all'): void;
86
84
  export type { FetcherConfig, RequestParams, OptionResult, Option };
@@ -34,15 +34,16 @@ export declare function transformTreeData(options?: any[], currentValue?: string
34
34
  * 用于批次/表格数据场景,将原始数据转换为表格行数据
35
35
  *
36
36
  * @param options - 原始选项数据
37
- * @param currentValue - 当前选中的值
37
+ * @param currentValue - 当前选中的值(批次号 name)
38
+ * @param currentId - companion `_id_`;有值时优先按 id 高亮,老数据无 id 时回退 name
38
39
  * @returns 转换后的数据和高亮索引
39
40
  *
40
41
  * @example
41
42
  * ```typescript
42
- * const { data, highlightIdx } = transformLotData(options, 'lot-123');
43
+ * const { data, highlightIdx } = transformLotData(options, 'lot-123', 'id-xxx');
43
44
  * ```
44
45
  */
45
- export declare function transformLotData(options?: Option[], currentValue?: string | string[]): {
46
+ export declare function transformLotData(options?: Option[], currentValue?: string | string[], currentId?: string): {
46
47
  data: any[];
47
48
  highlightIdx: {
48
49
  index: number[];
@@ -2,6 +2,8 @@ type __VLS_Props = {
2
2
  columns: any[];
3
3
  tableData: any[];
4
4
  modelValue?: string;
5
+ /** 批次 companion id,优先于 modelValue 做行高亮 */
6
+ selectedId?: string;
5
7
  loading: boolean;
6
8
  height?: string;
7
9
  autoResize?: boolean;
@@ -19,4 +19,6 @@ export declare function useTableDropdown(props: any, searchFilters?: MaybeRef<Ta
19
19
  clearValuePath: import('vue').ComputedRef<string | undefined>;
20
20
  allowManualInput: import('vue').ComputedRef<boolean>;
21
21
  isDeviceField: import('vue').ComputedRef<boolean>;
22
+ selectedId: import('vue').ComputedRef<string | undefined>;
23
+ persistOptionId: import('vue').ComputedRef<boolean>;
22
24
  };
@@ -202,6 +202,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
202
202
  readonly columns: any[];
203
203
  readonly tableData: any[];
204
204
  readonly modelValue?: string | undefined;
205
+ readonly selectedId?: string | undefined;
205
206
  readonly loading: boolean;
206
207
  readonly height?: string | undefined;
207
208
  readonly autoResize?: boolean | undefined;
@@ -241,6 +242,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
241
242
  columns: any[];
242
243
  tableData: any[];
243
244
  modelValue?: string;
245
+ selectedId?: string;
244
246
  loading: boolean;
245
247
  height?: string;
246
248
  autoResize?: boolean;
@@ -287,6 +289,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
287
289
  columns: any[];
288
290
  tableData: any[];
289
291
  modelValue?: string;
292
+ selectedId?: string;
290
293
  loading: boolean;
291
294
  height?: string;
292
295
  autoResize?: boolean;
@@ -26,8 +26,10 @@ export interface SelectStrategy {
26
26
  clearFieldId?: string;
27
27
  /** 搜索无匹配时允许将输入关键字作为值写入 */
28
28
  allowManualInput?: boolean;
29
+ /** 下拉选中时同步写入 companion `_id_`(批次字段) */
30
+ persistOptionId?: boolean;
29
31
  buildQuery?: (ctx: SelectQueryContext) => SelectQueryResult;
30
- transform: (options: any[], value?: string) => any;
32
+ transform: (options: any[], value?: string, currentId?: string) => any;
31
33
  }
32
34
  /**
33
35
  * 判断指定字段是否需要开启【报废/不良】分类 ->原因单向数据联动
@@ -197,6 +197,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
197
197
  readonly columns: any[];
198
198
  readonly tableData: any[];
199
199
  readonly modelValue?: string | undefined;
200
+ readonly selectedId?: string | undefined;
200
201
  readonly loading: boolean;
201
202
  readonly height?: string | undefined;
202
203
  readonly autoResize?: boolean | undefined;
@@ -236,6 +237,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
236
237
  columns: any[];
237
238
  tableData: any[];
238
239
  modelValue?: string;
240
+ selectedId?: string;
239
241
  loading: boolean;
240
242
  height?: string;
241
243
  autoResize?: boolean;
@@ -282,6 +284,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
282
284
  columns: any[];
283
285
  tableData: any[];
284
286
  modelValue?: string;
287
+ selectedId?: string;
285
288
  loading: boolean;
286
289
  height?: string;
287
290
  autoResize?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ComponentDependency } from '../../../../shared/panel/modules/field-dependency-module/types';
2
- import { MapRule, PriorityRule, ResolveRule, HyperlinkRule, LabelRule } from '../../../../../domain/field/field-props-schema-type';
2
+ import { MapRule, PriorityRule, ResolveRule, HyperlinkRule, LabelRule, IdRule } from '../../../../../domain/field/field-props-schema-type';
3
3
  import { FieldNodeRenderers } from '../../../../../domain/widget/component-type';
4
4
  export declare const commonDefaultRenderers: FieldNodeRenderers;
5
5
  export declare const commonDefaultProps: {
@@ -78,5 +78,9 @@ export declare const optionsMapEnumConfig: MapRule;
78
78
  export declare const labelOnValueChangeRule: LabelRule;
79
79
  /** 值变化后补全可点击 _href_ */
80
80
  export declare const hyperlinkOnValueChangeRule: HyperlinkRule;
81
+ /** 值变化后补全批次唯一标识 _id_ */
82
+ export declare const idOnValueChangeRule: IdRule;
81
83
  /** 同时补全 _href_ 与 _lb_(如批次号等追溯字段) */
82
84
  export declare const hyperlinkAndLabelOnValueChangeRules: readonly [HyperlinkRule, LabelRule];
85
+ /** 批次号:补全 _href_ 与 _id_ */
86
+ export declare const hyperlinkAndIdOnValueChangeRules: readonly [HyperlinkRule, IdRule];
package/dist/word.css CHANGED
@@ -12501,7 +12501,7 @@ svg.portrait-icon[data-v-8bdb451e] {
12501
12501
  width: 100%;
12502
12502
  height: 248px;
12503
12503
  }
12504
- .base-vxe-table-wrapper[data-v-8ae65aef] {
12504
+ .base-vxe-table-wrapper[data-v-c169ed2c] {
12505
12505
  display: flex;
12506
12506
  flex-direction: column;
12507
12507
  flex: 1;
@@ -12509,10 +12509,10 @@ svg.portrait-icon[data-v-8bdb451e] {
12509
12509
  width: 800px;
12510
12510
  height: 360px;
12511
12511
  }
12512
- .base-vxe-table-wrapper[data-v-8ae65aef] .dropdown-vxe-table .row--active {
12512
+ .base-vxe-table-wrapper[data-v-c169ed2c] .dropdown-vxe-table .row--active {
12513
12513
  background: #e6f7ff;
12514
12514
  }
12515
- .base-vxe-table-wrapper .vxe-grid-empty-word[data-v-8ae65aef] {
12515
+ .base-vxe-table-wrapper .vxe-grid-empty-word[data-v-c169ed2c] {
12516
12516
  display: flex;
12517
12517
  flex-direction: column;
12518
12518
  align-items: center;
@@ -12520,7 +12520,7 @@ svg.portrait-icon[data-v-8bdb451e] {
12520
12520
  color: rgba(0, 0, 0, 0.45);
12521
12521
  margin: 32px 0;
12522
12522
  }
12523
- .base-vxe-table-wrapper .vxe-grid-empty-word > img[data-v-8ae65aef] {
12523
+ .base-vxe-table-wrapper .vxe-grid-empty-word > img[data-v-c169ed2c] {
12524
12524
  width: 60px;
12525
12525
  margin-bottom: 12px;
12526
12526
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",