@ticatec/uniface-flexi-module 0.2.5 → 0.2.6

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.
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">import CascadeOptionSelect from "@ticatec/uniface-element/CascadeOptionsSelect";
2
2
  import FlexiField from "../flexi_field/FlexiField";
3
+ import utils from "../../utils";
3
4
  export let field;
4
5
  export let readonly;
5
6
  export let disabled;
@@ -7,7 +8,8 @@ export let variant;
7
8
  $: props = field.props;
8
9
  $: data = field.data;
9
10
  $: events = field.events;
11
+ $: text = field.dataFields['textField'] ? utils.extractFieldValue(field.rawData, field.dataFields['textField']) ?? '' : '';
10
12
  </script>
11
13
 
12
- <CascadeOptionSelect bind:value={data[field.keyField]} variant={variant??field.variant} readonly={readonly || field.isReadonly}
14
+ <CascadeOptionSelect bind:value={data[field.keyField]} variant={variant??field.variant} readonly={readonly || field.isReadonly} {text}
13
15
  disabled={disabled || field.disabled} {...props} {...events}/>
@@ -106,7 +106,7 @@ const buildUnitNumberField = (schema, dictLoader) => {
106
106
  const buildCascadeOptionSelect = (schema, dictLoader) => {
107
107
  const props = schema.props;
108
108
  if (schema.dictName) {
109
- props.options = dictLoader(schema.dictName);
109
+ props.nodes = [dictLoader(schema.dictName)];
110
110
  }
111
111
  return {
112
112
  component: CascadeOptionSelectField,
@@ -22,6 +22,8 @@ export interface FlexiFieldSchema {
22
22
  type: string;
23
23
  /** 字段的名称 */
24
24
  keyField: string;
25
+ /** 其他的数据字段 */
26
+ dataFields: Record<string, string>;
25
27
  /** 字段的名称 */
26
28
  name: string;
27
29
  /** 关联的数据字典项目 */
@@ -49,8 +51,10 @@ export interface FlexiFieldSchema {
49
51
  }
50
52
  export default class FlexiField {
51
53
  #private;
54
+ readonly rawData: any;
52
55
  readonly data: any;
53
56
  readonly keyField: string;
57
+ readonly dataFields: Record<string, string>;
54
58
  readonly component: typeof SvelteComponent;
55
59
  readonly variant?: "" | "outlined" | "filled";
56
60
  visibility: Visibility;
@@ -6,8 +6,10 @@ import i18nRes from "../../i18n-res";
6
6
  import { i18nUtils } from "@ticatec/i18n";
7
7
  export default class FlexiField {
8
8
  #parent;
9
+ rawData;
9
10
  data;
10
11
  keyField;
12
+ dataFields;
11
13
  component;
12
14
  variant;
13
15
  visibility = Visibility.View;
@@ -29,6 +31,7 @@ export default class FlexiField {
29
31
  this.isReadonly = schema.readonly == true;
30
32
  this.disabled = schema.disabled == true;
31
33
  this.required = schema.required == true;
34
+ this.dataFields = schema.dataFields;
32
35
  this.#cell = schema.cell;
33
36
  const card = parent instanceof FlexiCard ? parent : parent.card;
34
37
  if (schema.events) {
@@ -52,6 +55,7 @@ export default class FlexiField {
52
55
  this.#props[key] = (...args) => card[classMethod]?.(...args);
53
56
  }
54
57
  }
58
+ this.rawData = data;
55
59
  const result = utils.getParentAndKey(data, schema.keyField);
56
60
  this.keyField = result?.key;
57
61
  this.data = result?.parent;
package/dist/utils.d.ts CHANGED
@@ -8,5 +8,6 @@ declare const _default: {
8
8
  formatText: (s: string, obj: any) => string;
9
9
  propsFilter: (attrs: any, excludes?: Array<string>) => any;
10
10
  getScopeVariable: (key: string) => any;
11
+ extractFieldValue: (data: any, keyPath: string) => any;
11
12
  };
12
13
  export default _default;
package/dist/utils.js CHANGED
@@ -62,10 +62,19 @@ const getParentAndKey = (data, keyPath) => {
62
62
  return { parent: data, key: keyPath };
63
63
  }
64
64
  };
65
+ /**
66
+ * 萃取字段值
67
+ * @param data
68
+ * @param keyPath
69
+ */
70
+ const extractFieldValue = (data, keyPath) => {
71
+ let nestObj = getParentAndKey(data, keyPath);
72
+ return nestObj.parent[nestObj.key];
73
+ };
65
74
  const formatText = (s, obj) => {
66
75
  return s.replace(/\{\{(.*?)\}\}/g, (_, key) => {
67
76
  key = key.trim();
68
77
  return obj.hasOwnProperty(key) ? String(obj[key]) : `{{${key}}}`;
69
78
  });
70
79
  };
71
- export default { copyAttrs, extractExpression, getParentAndKey, formatText, propsFilter, getScopeVariable };
80
+ export default { copyAttrs, extractExpression, getParentAndKey, formatText, propsFilter, getScopeVariable, extractFieldValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-flexi-module",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "A flexible form framework for Svelte applications with dynamic field types, criteria panels, and modular components",
5
5
  "keywords": [
6
6
  "svelte",