aldehyde 0.2.486 → 0.2.487

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.
Files changed (35) hide show
  1. package/lib/controls/entry-control.d.ts +1 -0
  2. package/lib/controls/entry-control.d.ts.map +1 -1
  3. package/lib/controls/entry-control.js +2 -0
  4. package/lib/controls/entry-control.js.map +1 -1
  5. package/lib/draw-canvas-edit/components/asset-bar/index.d.ts.map +1 -1
  6. package/lib/draw-canvas-edit/components/asset-bar/index.js +26 -7
  7. package/lib/draw-canvas-edit/components/asset-bar/index.js.map +1 -1
  8. package/lib/draw-canvas-edit/components/asset-bar/index.less +1 -1
  9. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.d.ts.map +1 -1
  10. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.js +9 -5
  11. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.js.map +1 -1
  12. package/lib/draw-canvas-edit/components/render/index.d.ts.map +1 -1
  13. package/lib/draw-canvas-edit/components/render/index.js +1 -1
  14. package/lib/draw-canvas-edit/components/render/index.js.map +1 -1
  15. package/lib/module/dtmpl-edit-card.d.ts +1 -1
  16. package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
  17. package/lib/module/dtmpl-edit-card.js +40 -7
  18. package/lib/module/dtmpl-edit-card.js.map +1 -1
  19. package/lib/module/dtmpl-edit-page.d.ts +1 -1
  20. package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
  21. package/lib/module/dtmpl-edit-page.js +40 -7
  22. package/lib/module/dtmpl-edit-page.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/aldehyde/controls/entry-control.tsx +3 -0
  25. package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.less +1 -1
  26. package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.tsx +19 -6
  27. package/src/aldehyde/draw-canvas-edit/components/render/draws/graph-draw.ts +249 -249
  28. package/src/aldehyde/draw-canvas-edit/components/render/draws/link-draw.ts +1414 -1414
  29. package/src/aldehyde/draw-canvas-edit/components/render/draws/preview-draw.ts +273 -273
  30. package/src/aldehyde/draw-canvas-edit/components/render/draws/ref-line-draw.ts +70 -70
  31. package/src/aldehyde/draw-canvas-edit/components/render/draws/ruler-draw.ts +165 -165
  32. package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-outside-handlers.ts +4 -0
  33. package/src/aldehyde/draw-canvas-edit/components/render/index.ts +0 -1
  34. package/src/aldehyde/module/dtmpl-edit-card.tsx +37 -7
  35. package/src/aldehyde/module/dtmpl-edit-page.tsx +38 -8
@@ -1,70 +1,70 @@
1
- import Konva from 'konva';
2
- import { BaseDraw, Draw, Handler, Render } from '../types';
3
-
4
- // 参考线
5
-
6
- export interface RefLineDrawOption {
7
- padding: number
8
- }
9
-
10
- export class RefLineDraw extends BaseDraw implements Draw, Handler {
11
- option: RefLineDrawOption;
12
-
13
- constructor(render: Render, layer: Konva.Layer, option: RefLineDrawOption) {
14
- super(render, layer);
15
- this.option = option;
16
- this.group.listening(false);
17
- }
18
-
19
- override draw() {
20
- this.clear();
21
- const stageState = this.render.getStageState();
22
- const group = new Konva.Group();
23
- const pos = this.render.stage.getPointerPosition();
24
- if (pos) {
25
- if (pos.y >= this.option.padding) {
26
- // 横
27
- group.add(
28
- new Konva.Line({
29
- name: this.constructor.name,
30
- points: [
31
- [this.render.toStageValue(-stageState.x), this.render.toStageValue(pos.y - stageState.y)],
32
- [this.render.toStageValue(stageState.width - stageState.x + this.render.rulerSize), this.render.toStageValue(pos.y - stageState.y)]
33
- ].flat(),
34
- stroke: 'rgba(255,0,0,0.2)',
35
- strokeWidth: this.render.toStageValue(1),
36
- listening: false
37
- })
38
- );
39
- }
40
- if (pos.x >= this.option.padding) {
41
- // 竖
42
- group.add(
43
- new Konva.Line({
44
- name: this.constructor.name,
45
- points: [
46
- [this.render.toStageValue(pos.x - stageState.x), this.render.toStageValue(-stageState.y)],
47
- [this.render.toStageValue(pos.x - stageState.x), this.render.toStageValue(stageState.height - stageState.y + this.render.rulerSize)]
48
- ].flat(),
49
- stroke: 'rgba(255,0,0,0.2)',
50
- strokeWidth: this.render.toStageValue(1),
51
- listening: false
52
- })
53
- );
54
- }
55
- }
56
- this.group.add(group);
57
- }
58
- handlers = {
59
- dom: {
60
- mousemove: () => {
61
- // 更新参考线
62
- this.draw();
63
- },
64
- mouseout: () => {
65
- // 清除参考线
66
- this.clear();
67
- }
68
- }
69
- }
70
- }
1
+ import Konva from 'konva';
2
+ import { BaseDraw, Draw, Handler, Render } from '../types';
3
+
4
+ // 参考线
5
+
6
+ export interface RefLineDrawOption {
7
+ padding: number
8
+ }
9
+
10
+ export class RefLineDraw extends BaseDraw implements Draw, Handler {
11
+ option: RefLineDrawOption;
12
+
13
+ constructor(render: Render, layer: Konva.Layer, option: RefLineDrawOption) {
14
+ super(render, layer);
15
+ this.option = option;
16
+ this.group.listening(false);
17
+ }
18
+
19
+ override draw() {
20
+ this.clear();
21
+ const stageState = this.render.getStageState();
22
+ const group = new Konva.Group();
23
+ const pos = this.render.stage.getPointerPosition();
24
+ if (pos) {
25
+ if (pos.y >= this.option.padding) {
26
+ // 横
27
+ group.add(
28
+ new Konva.Line({
29
+ name: this.constructor.name,
30
+ points: [
31
+ [this.render.toStageValue(-stageState.x), this.render.toStageValue(pos.y - stageState.y)],
32
+ [this.render.toStageValue(stageState.width - stageState.x + this.render.rulerSize), this.render.toStageValue(pos.y - stageState.y)]
33
+ ].flat(),
34
+ stroke: 'rgba(255,0,0,0.2)',
35
+ strokeWidth: this.render.toStageValue(1),
36
+ listening: false
37
+ })
38
+ );
39
+ }
40
+ if (pos.x >= this.option.padding) {
41
+ // 竖
42
+ group.add(
43
+ new Konva.Line({
44
+ name: this.constructor.name,
45
+ points: [
46
+ [this.render.toStageValue(pos.x - stageState.x), this.render.toStageValue(-stageState.y)],
47
+ [this.render.toStageValue(pos.x - stageState.x), this.render.toStageValue(stageState.height - stageState.y + this.render.rulerSize)]
48
+ ].flat(),
49
+ stroke: 'rgba(255,0,0,0.2)',
50
+ strokeWidth: this.render.toStageValue(1),
51
+ listening: false
52
+ })
53
+ );
54
+ }
55
+ }
56
+ this.group.add(group);
57
+ }
58
+ handlers = {
59
+ dom: {
60
+ mousemove: () => {
61
+ // 更新参考线
62
+ this.draw();
63
+ },
64
+ mouseout: () => {
65
+ // 清除参考线
66
+ this.clear();
67
+ }
68
+ }
69
+ }
70
+ }
@@ -1,165 +1,165 @@
1
- import Konva from 'konva';
2
- import { BaseDraw, Render, Draw } from '../types';
3
-
4
- // 画布比例尺
5
-
6
- export interface RulerDrawOption {
7
- size: number
8
- }
9
-
10
- export class RulerDraw extends BaseDraw implements Draw {
11
- option: RulerDrawOption;
12
-
13
- constructor(render: Render, layer: Konva.Layer, option: RulerDrawOption) {
14
- super(render, layer);
15
- this.option = option;
16
- this.group.listening(false);
17
- }
18
-
19
- override draw() {
20
- this.clear();
21
- const stageState = this.render.getStageState();
22
- // 格子大小
23
- const cellSize = 20;
24
- const fontSizeMax = 12;
25
- const lenX = Math.ceil(this.render.toStageValue(stageState.width) / cellSize); // 列数
26
- const lenY = Math.ceil(this.render.toStageValue(stageState.height) / cellSize); // 行数
27
- const startX = -Math.ceil(this.render.toStageValue(stageState.x - this.option.size) / cellSize);
28
- const startY = -Math.ceil(this.render.toStageValue(stageState.y - this.option.size) / cellSize);
29
- const group = new Konva.Group();
30
- // 比例尺 - 上
31
- const groupTop = new Konva.Group({
32
- x: this.render.toStageValue(-stageState.x + this.option.size),
33
- y: this.render.toStageValue(-stageState.y),
34
- width: this.render.toStageValue(stageState.width - this.option.size + this.render.rulerSize),
35
- height: this.render.toStageValue(this.option.size)
36
- });
37
- // 比例尺 - 左
38
- const groupLeft = new Konva.Group({
39
- x: this.render.toStageValue(-stageState.x),
40
- y: this.render.toStageValue(-stageState.y + this.option.size),
41
- width: this.render.toStageValue(this.option.size),
42
- height: this.render.toStageValue(stageState.height - this.option.size + this.render.rulerSize)
43
- });
44
- {
45
- groupTop.add(
46
- // 上
47
- new Konva.Rect({
48
- name: this.constructor.name,
49
- x: 0,
50
- y: 0,
51
- width: groupTop.width(),
52
- height: groupTop.height(),
53
- fill: '#ddd'
54
- })
55
- );
56
- for (let x = lenX + startX - 1; x >= startX; x--) {
57
- const nx = -groupTop.x() + cellSize * x;
58
- const long = (this.render.toStageValue(this.option.size) / 5) * 4;
59
- const short = (this.render.toStageValue(this.option.size) / 5) * 3;
60
- if (nx >= 0) {
61
- groupTop.add(
62
- new Konva.Line({
63
- name: this.constructor.name,
64
- points: [
65
- [nx, x % 5 ? long : short],
66
- [nx, this.render.toStageValue(this.option.size)]
67
- ].flat(),
68
- stroke: '#999',
69
- strokeWidth: this.render.toStageValue(1),
70
- listening: false
71
- })
72
- );
73
- if (x % 5 === 0) {
74
- let fontSize = fontSizeMax;
75
- const text = new Konva.Text({
76
- name: this.constructor.name,
77
- y: this.render.toStageValue(this.option.size / 2 - fontSize),
78
- text: (x * cellSize).toString(),
79
- fontSize: this.render.toStageValue(fontSize),
80
- fill: '#999',
81
- align: 'center',
82
- verticalAlign: 'middle',
83
- lineHeight: 1.6
84
- });
85
- while (this.render.toStageValue(text.width()) > this.render.toStageValue(cellSize) * 4.6) {
86
- fontSize -= 1;
87
- text.fontSize(this.render.toStageValue(fontSize));
88
- text.y(this.render.toStageValue(this.option.size / 2 - fontSize));
89
- }
90
- text.x(nx - text.width() / 2);
91
- groupTop.add(text);
92
- }
93
- }
94
- }
95
- }
96
- {
97
- groupLeft.add(
98
- // 左
99
- new Konva.Rect({
100
- name: this.constructor.name,
101
- x: 0,
102
- y: 0,
103
- width: groupLeft.width(),
104
- height: groupLeft.height(),
105
- fill: '#ddd'
106
- })
107
- );
108
- for (let y = lenY + startY - 1; y >= startY; y--) {
109
- const ny = -groupLeft.y() + cellSize * y;
110
- const long = (this.render.toStageValue(this.option.size) / 5) * 4;
111
- const short = (this.render.toStageValue(this.option.size) / 5) * 3;
112
- if (ny >= 0) {
113
- groupLeft.add(
114
- new Konva.Line({
115
- name: this.constructor.name,
116
- points: [
117
- [y % 5 ? long : short, ny],
118
- [this.render.toStageValue(this.option.size), ny]
119
- ].flat(),
120
- stroke: '#999',
121
- strokeWidth: this.render.toStageValue(1),
122
- listening: false
123
- })
124
- );
125
- if (y % 5 === 0) {
126
- let fontSize = fontSizeMax;
127
- const text = new Konva.Text({
128
- name: this.constructor.name,
129
- x: 0,
130
- y: ny,
131
- text: (y * cellSize).toString(),
132
- fontSize: this.render.toStageValue(fontSize),
133
- fill: '#999',
134
- align: 'right',
135
- verticalAlign: 'bottom',
136
- lineHeight: 1.6,
137
- wrap: 'none'
138
- });
139
- while (text.width() > short * 0.8) {
140
- fontSize -= 1;
141
- text.fontSize(this.render.toStageValue(fontSize));
142
- }
143
- text.y(ny - text.height() / 2);
144
- text.width(short - this.render.toStageValue(1));
145
- groupLeft.add(text);
146
- }
147
- }
148
- }
149
- }
150
- group.add(
151
- // 角
152
- new Konva.Rect({
153
- name: this.constructor.name,
154
- x: this.render.toStageValue(-stageState.x),
155
- y: this.render.toStageValue(-stageState.y),
156
- width: this.render.toStageValue(this.option.size),
157
- height: this.render.toStageValue(this.option.size),
158
- fill: '#ddd'
159
- })
160
- );
161
- group.add(groupTop);
162
- group.add(groupLeft);
163
- this.group.add(group);
164
- }
165
- }
1
+ import Konva from 'konva';
2
+ import { BaseDraw, Render, Draw } from '../types';
3
+
4
+ // 画布比例尺
5
+
6
+ export interface RulerDrawOption {
7
+ size: number
8
+ }
9
+
10
+ export class RulerDraw extends BaseDraw implements Draw {
11
+ option: RulerDrawOption;
12
+
13
+ constructor(render: Render, layer: Konva.Layer, option: RulerDrawOption) {
14
+ super(render, layer);
15
+ this.option = option;
16
+ this.group.listening(false);
17
+ }
18
+
19
+ override draw() {
20
+ this.clear();
21
+ const stageState = this.render.getStageState();
22
+ // 格子大小
23
+ const cellSize = 20;
24
+ const fontSizeMax = 12;
25
+ const lenX = Math.ceil(this.render.toStageValue(stageState.width) / cellSize); // 列数
26
+ const lenY = Math.ceil(this.render.toStageValue(stageState.height) / cellSize); // 行数
27
+ const startX = -Math.ceil(this.render.toStageValue(stageState.x - this.option.size) / cellSize);
28
+ const startY = -Math.ceil(this.render.toStageValue(stageState.y - this.option.size) / cellSize);
29
+ const group = new Konva.Group();
30
+ // 比例尺 - 上
31
+ const groupTop = new Konva.Group({
32
+ x: this.render.toStageValue(-stageState.x + this.option.size),
33
+ y: this.render.toStageValue(-stageState.y),
34
+ width: this.render.toStageValue(stageState.width - this.option.size + this.render.rulerSize),
35
+ height: this.render.toStageValue(this.option.size)
36
+ });
37
+ // 比例尺 - 左
38
+ const groupLeft = new Konva.Group({
39
+ x: this.render.toStageValue(-stageState.x),
40
+ y: this.render.toStageValue(-stageState.y + this.option.size),
41
+ width: this.render.toStageValue(this.option.size),
42
+ height: this.render.toStageValue(stageState.height - this.option.size + this.render.rulerSize)
43
+ });
44
+ {
45
+ groupTop.add(
46
+ // 上
47
+ new Konva.Rect({
48
+ name: this.constructor.name,
49
+ x: 0,
50
+ y: 0,
51
+ width: groupTop.width(),
52
+ height: groupTop.height(),
53
+ fill: '#ddd'
54
+ })
55
+ );
56
+ for (let x = lenX + startX - 1; x >= startX; x--) {
57
+ const nx = -groupTop.x() + cellSize * x;
58
+ const long = (this.render.toStageValue(this.option.size) / 5) * 4;
59
+ const short = (this.render.toStageValue(this.option.size) / 5) * 3;
60
+ if (nx >= 0) {
61
+ groupTop.add(
62
+ new Konva.Line({
63
+ name: this.constructor.name,
64
+ points: [
65
+ [nx, x % 5 ? long : short],
66
+ [nx, this.render.toStageValue(this.option.size)]
67
+ ].flat(),
68
+ stroke: '#999',
69
+ strokeWidth: this.render.toStageValue(1),
70
+ listening: false
71
+ })
72
+ );
73
+ if (x % 5 === 0) {
74
+ let fontSize = fontSizeMax;
75
+ const text = new Konva.Text({
76
+ name: this.constructor.name,
77
+ y: this.render.toStageValue(this.option.size / 2 - fontSize),
78
+ text: (x * cellSize).toString(),
79
+ fontSize: this.render.toStageValue(fontSize),
80
+ fill: '#999',
81
+ align: 'center',
82
+ verticalAlign: 'middle',
83
+ lineHeight: 1.6
84
+ });
85
+ while (this.render.toStageValue(text.width()) > this.render.toStageValue(cellSize) * 4.6) {
86
+ fontSize -= 1;
87
+ text.fontSize(this.render.toStageValue(fontSize));
88
+ text.y(this.render.toStageValue(this.option.size / 2 - fontSize));
89
+ }
90
+ text.x(nx - text.width() / 2);
91
+ groupTop.add(text);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ {
97
+ groupLeft.add(
98
+ // 左
99
+ new Konva.Rect({
100
+ name: this.constructor.name,
101
+ x: 0,
102
+ y: 0,
103
+ width: groupLeft.width(),
104
+ height: groupLeft.height(),
105
+ fill: '#ddd'
106
+ })
107
+ );
108
+ for (let y = lenY + startY - 1; y >= startY; y--) {
109
+ const ny = -groupLeft.y() + cellSize * y;
110
+ const long = (this.render.toStageValue(this.option.size) / 5) * 4;
111
+ const short = (this.render.toStageValue(this.option.size) / 5) * 3;
112
+ if (ny >= 0) {
113
+ groupLeft.add(
114
+ new Konva.Line({
115
+ name: this.constructor.name,
116
+ points: [
117
+ [y % 5 ? long : short, ny],
118
+ [this.render.toStageValue(this.option.size), ny]
119
+ ].flat(),
120
+ stroke: '#999',
121
+ strokeWidth: this.render.toStageValue(1),
122
+ listening: false
123
+ })
124
+ );
125
+ if (y % 5 === 0) {
126
+ let fontSize = fontSizeMax;
127
+ const text = new Konva.Text({
128
+ name: this.constructor.name,
129
+ x: 0,
130
+ y: ny,
131
+ text: (y * cellSize).toString(),
132
+ fontSize: this.render.toStageValue(fontSize),
133
+ fill: '#999',
134
+ align: 'right',
135
+ verticalAlign: 'bottom',
136
+ lineHeight: 1.6,
137
+ wrap: 'none'
138
+ });
139
+ while (text.width() > short * 0.8) {
140
+ fontSize -= 1;
141
+ text.fontSize(this.render.toStageValue(fontSize));
142
+ }
143
+ text.y(ny - text.height() / 2);
144
+ text.width(short - this.render.toStageValue(1));
145
+ groupLeft.add(text);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ group.add(
151
+ // 角
152
+ new Konva.Rect({
153
+ name: this.constructor.name,
154
+ x: this.render.toStageValue(-stageState.x),
155
+ y: this.render.toStageValue(-stageState.y),
156
+ width: this.render.toStageValue(this.option.size),
157
+ height: this.render.toStageValue(this.option.size),
158
+ fill: '#ddd'
159
+ })
160
+ );
161
+ group.add(groupTop);
162
+ group.add(groupLeft);
163
+ this.group.add(group);
164
+ }
165
+ }
@@ -21,6 +21,7 @@ export class DragOutsideHandlers implements Handler {
21
21
  },
22
22
  drop: async (e: GlobalEventHandlersEventMap['drop']) => {
23
23
  const componentItem = JSON.parse(e.dataTransfer?.getData('componentItem') || '{}');
24
+ const defaultValues = JSON.parse(e.dataTransfer?.getData('defaultValues') || '{}');
24
25
  const src = e.dataTransfer?.getData('src');
25
26
  const componentType = e.dataTransfer?.getData('componentType'); // 组件类型
26
27
  const showPoints = e.dataTransfer?.getData('showPoints'); // 是否显示连接点
@@ -56,6 +57,9 @@ export class DragOutsideHandlers implements Handler {
56
57
  group.setAttrs({ x, y });
57
58
  // 更新坐标记录
58
59
  this.render.setAssetSettings(group, this.render.getAssetSettings(group), false);
60
+ if (Object.keys(defaultValues).length > 0) { // 设置默认值
61
+ this.render.setAssetSettings(group, { ...this.render.getAssetSettings(group), ...defaultValues }, false);
62
+ }
59
63
  // 设置连接点
60
64
  this.render.componentFactory.createComponentLinkPoints({ group, points, showPoints });
61
65
  // 组件鼠标移入移出事件
@@ -551,7 +551,6 @@ export class Render {
551
551
  fontSize: base.fontSize || this.getPageSettings().fontSize,
552
552
  textFill: base.textFill || this.getPageSettings().textFill,
553
553
  // 绘制图形,默认不填充
554
- fill: base.fill || "transparent",
555
554
  x: parseFloat((asset?.position().x ?? 0).toFixed(1)),
556
555
  y: parseFloat((asset?.position().y ?? 0).toFixed(1)),
557
556
  rotation: parseFloat((asset?.rotation() ?? 0).toFixed(1)),
@@ -12,6 +12,7 @@ import HcserviceV3 from "../tmpl/hcservice-v3";
12
12
  import Action from "../controls/action";
13
13
  import { LocaleContext } from "../locale/LocaleProvider";
14
14
  import TmplConfigAnalysis from "../tmpl/tmpl-config-analysis";
15
+ import { relValueFieldExtControlType } from "../controls/entry-control";
15
16
 
16
17
  interface DtmplEditCardProps extends DtmplBaseProps {
17
18
  onOk?: (code: string) => void;
@@ -73,6 +74,7 @@ export default class DtmplEditCard extends React.PureComponent<
73
74
  if (prevProps.sourceId != this.props.sourceId || dtmplConfig == null || (!this.props.code && prevProps.code)) {
74
75
  await this.loadConfigData();
75
76
  } else if (prevProps.sourceId != this.props.sourceId || queryingCode != code || !dtmplData) {
77
+ await this.handleBuildInFuncFields(dtmplConfig);
76
78
  //防止反复请求 code
77
79
  if (code) {
78
80
  await this.loadCodeData(dtmplConfig, code);
@@ -108,6 +110,7 @@ export default class DtmplEditCard extends React.PureComponent<
108
110
  addTmplId
109
111
  );
110
112
  }
113
+ await this.handleBuildInFuncFields(dtmplConfig);
111
114
  this.handleRelValueField(dtmplConfig);
112
115
  if (dtmplConfig.entity) {
113
116
  let dtmplData = dtmplConfig.entity;
@@ -224,7 +227,14 @@ export default class DtmplEditCard extends React.PureComponent<
224
227
  // 表单关联项secondCriterion处理start
225
228
  getSubDtmplData = async (valueField, code) => {
226
229
  const { serverKey } = this.props;
227
- const dtmplData = await HcserviceV3.requestDtmplData(serverKey, valueField.id, code.split("@R@")[0], null);
230
+ let dtmplData = null;
231
+ if (valueField.extRefPageId) { // 存在extRefPageId(扩展关联页面),则优先使用extRefPageId(例如:枚举值无指向页面,使用扩展关联页面)
232
+ const { entities } = await HcserviceV3.requestLtmplQueryTop(null, valueField.extRefPageId, { top: 1, secondCriterion: code.split("@R@")[0] }) || {};
233
+ dtmplData = entities?.[0];
234
+ } else { // 查询字段指向页面的数据
235
+ dtmplData = await HcserviceV3.requestDtmplData(serverKey, valueField.id, code.split("@R@")[0], null);
236
+ }
237
+ if (!dtmplData) return null;
228
238
  const subField = valueField.subRelValueField;
229
239
  const subData = dtmplData.fieldMap[subField.id];
230
240
  if (subField.subRelValueField && subData) { // 存在下级关联项
@@ -235,17 +245,21 @@ export default class DtmplEditCard extends React.PureComponent<
235
245
 
236
246
  getSecondCriteria = async (field) => {
237
247
  const { parentFormInstance } = this.props;
238
- const { relValueField, relValueField3, baseCriteria = {} } = field;
248
+ const { relValueField, relValueField3, baseCriteria = {}, relMinValueField, relMaxValueField } = field;
239
249
  const temForm = parentFormInstance || this.formRef.current;
240
- if (relValueField && temForm) {
250
+ if (relValueField && temForm) { // 设置默认值或查询次条件
241
251
  let relValueData = temForm.getFieldValue(relValueField.id);
242
252
  if (relValueField.subRelValueField && relValueData) {
243
253
  relValueData = await this.getSubDtmplData(relValueField, relValueData);
244
254
  }
245
- field.baseCriteria = { ...(baseCriteria || {}), "secondCriterion": relValueData };
255
+ if (!relValueFieldExtControlType.includes(field.extControlType)) {
256
+ field.defaultValue = relValueData; // 非关系型字段填充默认值
257
+ } else {
258
+ field.baseCriteria = { ...(baseCriteria || {}), "secondCriterion": relValueData };
259
+ }
246
260
  field.configChanged = true;
247
261
  }
248
- if (relValueField3 && temForm) {
262
+ if (relValueField3 && temForm) { // 设置查询三条件
249
263
  let relValueData = temForm.getFieldValue(relValueField3.id);
250
264
  if (relValueField3.subRelValueField && relValueData) {
251
265
  relValueData = await this.getSubDtmplData(relValueField3, relValueData);
@@ -253,6 +267,22 @@ export default class DtmplEditCard extends React.PureComponent<
253
267
  field.baseCriteria = { ...(field.baseCriteria || {}), "thirdCriterion": relValueData };
254
268
  field.configChanged = true;
255
269
  }
270
+ if (relMinValueField && temForm) { // 设置最小值
271
+ let relValueData = temForm.getFieldValue(relMinValueField.id);
272
+ if (relMinValueField.subRelValueField && relValueData) {
273
+ relValueData = await this.getSubDtmplData(relMinValueField, relValueData);
274
+ }
275
+ field.min = relValueData;
276
+ field.configChanged = true;
277
+ }
278
+ if (relMaxValueField && temForm) { // 设置最大值
279
+ let relValueData = temForm.getFieldValue(relMaxValueField.id);
280
+ if (relMaxValueField.subRelValueField && relValueData) {
281
+ relValueData = await this.getSubDtmplData(relMaxValueField, relValueData);
282
+ }
283
+ field.max = relValueData;
284
+ field.configChanged = true;
285
+ }
256
286
  return field;
257
287
  }
258
288
  // 表单关联项secondCriterion处理end
@@ -292,8 +322,8 @@ export default class DtmplEditCard extends React.PureComponent<
292
322
  };
293
323
 
294
324
  //关联取值:根据 parentFormInstance / this.formRef 完善 dtmplConfig
295
- handleBuildInFuncFields = async () => {
296
- const { dtmplConfig } = this.state;
325
+ handleBuildInFuncFields = async (tDtmplConfig?: DtmplConfig) => {
326
+ const dtmplConfig = tDtmplConfig || this.state.dtmplConfig;
297
327
  if (dtmplConfig) {
298
328
  if (!dtmplConfig.buildInFuncFields) {
299
329
  dtmplConfig.buildInFuncFields = TmplConfigAnalysis.buildInFuncFields(dtmplConfig);