@oinone/kunlun-vue-widget 6.2.0
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/dist/oinone-kunlun-vue-widget.esm.js +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/src/basic/AsyncVueWidget.d.ts +7 -0
- package/dist/types/src/basic/VueFragment.vue.d.ts +2 -0
- package/dist/types/src/basic/VueWidget.d.ts +331 -0
- package/dist/types/src/basic/Widget.d.ts +234 -0
- package/dist/types/src/basic/index.d.ts +3 -0
- package/dist/types/src/data/ActiveRecordsWidget.d.ts +246 -0
- package/dist/types/src/data/PathWidget.d.ts +34 -0
- package/dist/types/src/data/index.d.ts +2 -0
- package/dist/types/src/dsl/DslDefinitionWidget.d.ts +61 -0
- package/dist/types/src/dsl/DslNodeWidget.d.ts +42 -0
- package/dist/types/src/dsl/DslRenderWidget.d.ts +44 -0
- package/dist/types/src/dsl/index.d.ts +3 -0
- package/dist/types/src/feature/index.d.ts +1 -0
- package/dist/types/src/feature/invisible-supported.d.ts +11 -0
- package/dist/types/src/hooks/all-mounted.d.ts +20 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/index.d.ts +9 -0
- package/dist/types/src/token/index.d.ts +2 -0
- package/dist/types/src/typing/WidgetTagContext.d.ts +39 -0
- package/dist/types/src/typing/WidgetTagProps.d.ts +23 -0
- package/dist/types/src/typing/index.d.ts +3 -0
- package/dist/types/src/typing/typing.d.ts +7 -0
- package/dist/types/src/util/dsl-render.d.ts +106 -0
- package/dist/types/src/util/index.d.ts +4 -0
- package/dist/types/src/util/install.d.ts +4 -0
- package/dist/types/src/util/render.d.ts +7 -0
- package/dist/types/src/util/widget-manager.d.ts +4 -0
- package/dist/types/src/view/index.d.ts +161 -0
- package/index.ts +1 -0
- package/package.json +34 -0
- package/rollup.config.js +21 -0
- package/src/basic/AsyncVueWidget.ts +31 -0
- package/src/basic/VueFragment.vue +11 -0
- package/src/basic/VueWidget.ts +997 -0
- package/src/basic/Widget.ts +675 -0
- package/src/basic/index.ts +3 -0
- package/src/data/ActiveRecordsWidget.ts +572 -0
- package/src/data/PathWidget.ts +82 -0
- package/src/data/index.ts +2 -0
- package/src/dsl/DslDefinitionWidget.ts +235 -0
- package/src/dsl/DslNodeWidget.ts +130 -0
- package/src/dsl/DslRenderWidget.ts +106 -0
- package/src/dsl/index.ts +3 -0
- package/src/feature/index.ts +1 -0
- package/src/feature/invisible-supported.ts +29 -0
- package/src/hooks/all-mounted.ts +179 -0
- package/src/hooks/index.ts +1 -0
- package/src/index.ts +9 -0
- package/src/shim-translate.d.ts +7 -0
- package/src/shim-vue.d.ts +6 -0
- package/src/token/index.ts +8 -0
- package/src/typing/WidgetTagContext.ts +53 -0
- package/src/typing/WidgetTagProps.ts +24 -0
- package/src/typing/index.ts +3 -0
- package/src/typing/typing.ts +7 -0
- package/src/util/dsl-render.ts +464 -0
- package/src/util/index.ts +4 -0
- package/src/util/install.ts +29 -0
- package/src/util/render.ts +21 -0
- package/src/util/widget-manager.ts +14 -0
- package/src/view/index.ts +416 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActiveRecord,
|
|
3
|
+
ActiveRecords,
|
|
4
|
+
ActiveRecordsOperator,
|
|
5
|
+
DeleteActiveRecordsByEntityFunction,
|
|
6
|
+
DeleteActiveRecordsByEntityPredict,
|
|
7
|
+
DeleteActiveRecordsFunction,
|
|
8
|
+
FlushActiveRecordsFunction,
|
|
9
|
+
PushActiveRecordsFunction,
|
|
10
|
+
PushActiveRecordsPredict,
|
|
11
|
+
ReloadActiveRecordsFunction,
|
|
12
|
+
RuntimeRelationField,
|
|
13
|
+
SubmitCacheManager,
|
|
14
|
+
UpdateActiveRecordsByEntityFunction,
|
|
15
|
+
UpdateActiveRecordsByEntityPredict,
|
|
16
|
+
UpdateActiveRecordsFunction,
|
|
17
|
+
UpdateEntity
|
|
18
|
+
} from '@oinone/kunlun-engine';
|
|
19
|
+
import { Widget } from '../basic';
|
|
20
|
+
import { PathWidget, PathWidgetProps } from './PathWidget';
|
|
21
|
+
|
|
22
|
+
export interface ActiveRecordsWidgetProps extends PathWidgetProps {
|
|
23
|
+
dataSource?: ActiveRecords | null;
|
|
24
|
+
activeRecords?: ActiveRecords;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 数据记录组件
|
|
29
|
+
*/
|
|
30
|
+
export class ActiveRecordsWidget<
|
|
31
|
+
Props extends ActiveRecordsWidgetProps = ActiveRecordsWidgetProps
|
|
32
|
+
> extends PathWidget<Props> {
|
|
33
|
+
public initialize(props: Props) {
|
|
34
|
+
super.initialize(props);
|
|
35
|
+
const { dataSource, activeRecords } = props;
|
|
36
|
+
this.setCurrentDataSource(dataSource);
|
|
37
|
+
this.setCurrentActiveRecords(activeRecords);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 提交缓存管理器
|
|
43
|
+
* @protected
|
|
44
|
+
*/
|
|
45
|
+
protected get submitCache(): SubmitCacheManager | undefined {
|
|
46
|
+
return (this.metadataRuntimeContext.field as RuntimeRelationField | undefined)?.submitCache;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 上级根数据
|
|
51
|
+
* @protected
|
|
52
|
+
*/
|
|
53
|
+
@Widget.Reactive()
|
|
54
|
+
@Widget.Inject('rootData')
|
|
55
|
+
protected parentRootData: ActiveRecord[] | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 当前根数据
|
|
59
|
+
* @protected
|
|
60
|
+
*/
|
|
61
|
+
@Widget.Reactive()
|
|
62
|
+
private currentRootData: ActiveRecord[] | undefined;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 提供给下级的根数据
|
|
66
|
+
* @protected
|
|
67
|
+
*/
|
|
68
|
+
@Widget.Reactive()
|
|
69
|
+
@Widget.Provide()
|
|
70
|
+
public get rootData(): ActiveRecord[] | undefined {
|
|
71
|
+
return this.currentRootData || this.parentRootData;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public set rootData(rootData: ActiveRecord[] | undefined) {
|
|
75
|
+
this.currentRootData = rootData;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public getCurrentRootData(): ActiveRecord[] | undefined {
|
|
79
|
+
return this.currentRootData;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public setCurrentRootData(rootData: ActiveRecords | undefined) {
|
|
83
|
+
this.currentRootData = ActiveRecordsOperator.repairRecordsNullable(rootData);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Widget.Method()
|
|
87
|
+
@Widget.Inject('reloadRootData')
|
|
88
|
+
protected parentReloadRootData: ReloadActiveRecordsFunction | undefined;
|
|
89
|
+
|
|
90
|
+
@Widget.Reactive()
|
|
91
|
+
@Widget.Provide()
|
|
92
|
+
public reloadRootData(records: ActiveRecords | undefined) {
|
|
93
|
+
if (this.parentReloadRootData && this.currentRootData === undefined) {
|
|
94
|
+
this.parentReloadRootData(records);
|
|
95
|
+
} else {
|
|
96
|
+
this.setCurrentRootData(records);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 上级数据源
|
|
102
|
+
* @protected
|
|
103
|
+
*/
|
|
104
|
+
@Widget.Reactive()
|
|
105
|
+
@Widget.Inject('dataSource')
|
|
106
|
+
protected parentDataSource: ActiveRecord[] | undefined;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 当前数据源
|
|
110
|
+
* @protected
|
|
111
|
+
*/
|
|
112
|
+
@Widget.Reactive()
|
|
113
|
+
private currentDataSource: ActiveRecord[] | null | undefined;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 提供给下级的数据源
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
119
|
+
@Widget.Reactive()
|
|
120
|
+
@Widget.Provide()
|
|
121
|
+
public get dataSource(): ActiveRecord[] | undefined {
|
|
122
|
+
return this.currentDataSource || this.parentDataSource;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public set dataSource(dataSource: ActiveRecord[] | undefined) {
|
|
126
|
+
this.currentDataSource = dataSource;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public getCurrentDataSource(): ActiveRecord[] | null | undefined {
|
|
130
|
+
return this.currentDataSource;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public setCurrentDataSource(dataSource: ActiveRecords | null | undefined) {
|
|
134
|
+
this.currentDataSource = ActiveRecordsOperator.repairRecordsNullable(dataSource as ActiveRecords);
|
|
135
|
+
if (!this.parentRootData) {
|
|
136
|
+
this.currentRootData = this.currentDataSource || undefined;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Widget.Method()
|
|
141
|
+
@Widget.Inject('reloadDataSource')
|
|
142
|
+
protected parentReloadDataSource: ReloadActiveRecordsFunction | undefined;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 重新加载数据源到当前数据源中
|
|
146
|
+
* <pre>
|
|
147
|
+
* @Widget.Method()
|
|
148
|
+
* @Widget.Inject()
|
|
149
|
+
* private reloadDataSource: ReloadActiveRecordsFunction | undefined;
|
|
150
|
+
* </pre>
|
|
151
|
+
*
|
|
152
|
+
* @param records 数据
|
|
153
|
+
*/
|
|
154
|
+
@Widget.Method()
|
|
155
|
+
@Widget.Provide()
|
|
156
|
+
public reloadDataSource(records: ActiveRecords | undefined) {
|
|
157
|
+
if (this.parentReloadDataSource && this.getCurrentDataSource() === undefined) {
|
|
158
|
+
this.parentReloadDataSource(records);
|
|
159
|
+
} else {
|
|
160
|
+
this.setCurrentDataSource(records);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Widget.Method()
|
|
165
|
+
@Widget.Inject('pushDataSource')
|
|
166
|
+
protected parentPushDataSource: PushActiveRecordsFunction | undefined;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 添加数据源到当前数据源中
|
|
170
|
+
* <pre>
|
|
171
|
+
* @Widget.Method()
|
|
172
|
+
* @Widget.Inject()
|
|
173
|
+
* private pushDataSource: PushActiveRecordsFunction | undefined;
|
|
174
|
+
* </pre>
|
|
175
|
+
*
|
|
176
|
+
* @param records 数据
|
|
177
|
+
* @param predict 推送判定
|
|
178
|
+
*/
|
|
179
|
+
@Widget.Method()
|
|
180
|
+
@Widget.Provide()
|
|
181
|
+
public pushDataSource(records: ActiveRecords, predict?: PushActiveRecordsPredict) {
|
|
182
|
+
if (this.parentPushDataSource && this.getCurrentDataSource() === undefined) {
|
|
183
|
+
this.parentPushDataSource(records, predict);
|
|
184
|
+
} else {
|
|
185
|
+
let pushPredict: PushActiveRecordsPredict | undefined = predict;
|
|
186
|
+
const { submitCache } = this;
|
|
187
|
+
if (submitCache && !pushPredict) {
|
|
188
|
+
pushPredict = ActiveRecordsOperator.defaultPushPredict.bind(submitCache);
|
|
189
|
+
}
|
|
190
|
+
const nextDataSource = ActiveRecordsOperator.operator(this.getCurrentDataSource() || undefined, this.submitCache)
|
|
191
|
+
.push(records, pushPredict)
|
|
192
|
+
.get();
|
|
193
|
+
if (!submitCache) {
|
|
194
|
+
this.setCurrentDataSource(nextDataSource);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@Widget.Method()
|
|
200
|
+
@Widget.Inject('updateDataSource')
|
|
201
|
+
protected parentUpdateDataSource: UpdateActiveRecordsFunction | undefined;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 根据索引更新数据源
|
|
205
|
+
* <pre>
|
|
206
|
+
* @Widget.Method()
|
|
207
|
+
* @Widget.Inject()
|
|
208
|
+
* private updateDataSource: UpdateActiveRecordsFunction | undefined;
|
|
209
|
+
* </pre>
|
|
210
|
+
*
|
|
211
|
+
* @param records 数据
|
|
212
|
+
*/
|
|
213
|
+
@Widget.Method()
|
|
214
|
+
@Widget.Provide()
|
|
215
|
+
public updateDataSource(records: UpdateEntity[]) {
|
|
216
|
+
if (this.parentUpdateDataSource && this.getCurrentDataSource() === undefined) {
|
|
217
|
+
this.parentUpdateDataSource(records);
|
|
218
|
+
} else {
|
|
219
|
+
const nextDataSource = ActiveRecordsOperator.operator(this.getCurrentDataSource() || undefined, this.submitCache)
|
|
220
|
+
.update(records)
|
|
221
|
+
.get();
|
|
222
|
+
if (!this.submitCache) {
|
|
223
|
+
this.setCurrentDataSource(nextDataSource);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@Widget.Method()
|
|
229
|
+
@Widget.Inject('updateDataSourceByEntity')
|
|
230
|
+
protected parentUpdateDataSourceByEntity: UpdateActiveRecordsByEntityFunction | undefined;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 根据数据更新数据源
|
|
234
|
+
* <pre>
|
|
235
|
+
* @Widget.Method()
|
|
236
|
+
* @Widget.Inject()
|
|
237
|
+
* private updateDataSourceByEntity: UpdateDataSourceByEntityFunction | undefined;
|
|
238
|
+
* </pre>
|
|
239
|
+
*
|
|
240
|
+
* @param records 数据
|
|
241
|
+
* @param predict 更新判定
|
|
242
|
+
*/
|
|
243
|
+
@Widget.Method()
|
|
244
|
+
@Widget.Provide()
|
|
245
|
+
public updateDataSourceByEntity(records: ActiveRecords, predict?: UpdateActiveRecordsByEntityPredict) {
|
|
246
|
+
if (this.parentUpdateDataSourceByEntity && this.getCurrentDataSource() === undefined) {
|
|
247
|
+
this.parentUpdateDataSourceByEntity(records, predict);
|
|
248
|
+
} else {
|
|
249
|
+
const nextDataSource = ActiveRecordsOperator.operator(this.getCurrentDataSource() || undefined, this.submitCache)
|
|
250
|
+
.updateByEntity(records, predict)
|
|
251
|
+
.get();
|
|
252
|
+
if (!this.submitCache) {
|
|
253
|
+
this.setCurrentDataSource(nextDataSource);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@Widget.Method()
|
|
259
|
+
@Widget.Inject('deleteDataSource')
|
|
260
|
+
protected parentDeleteDataSource: DeleteActiveRecordsFunction | undefined;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 根据索引删除数据源
|
|
264
|
+
* <pre>
|
|
265
|
+
* @Widget.Method()
|
|
266
|
+
* @Widget.Inject()
|
|
267
|
+
* private deleteDataSource: DeleteActiveRecordsFunction | undefined;
|
|
268
|
+
* </pre>
|
|
269
|
+
*
|
|
270
|
+
* @param recordIndexes 数据
|
|
271
|
+
*/
|
|
272
|
+
@Widget.Method()
|
|
273
|
+
@Widget.Provide()
|
|
274
|
+
public deleteDataSource(recordIndexes: number[]) {
|
|
275
|
+
if (this.parentDeleteDataSource && this.getCurrentDataSource() === undefined) {
|
|
276
|
+
this.parentDeleteDataSource(recordIndexes);
|
|
277
|
+
} else {
|
|
278
|
+
const nextDataSource = ActiveRecordsOperator.operator(this.getCurrentDataSource() || undefined, this.submitCache)
|
|
279
|
+
.delete(recordIndexes)
|
|
280
|
+
.get();
|
|
281
|
+
if (!this.submitCache) {
|
|
282
|
+
this.setCurrentDataSource(nextDataSource);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@Widget.Method()
|
|
288
|
+
@Widget.Inject('deleteDataSourceByEntity')
|
|
289
|
+
protected parentDeleteDataSourceByEntity: DeleteActiveRecordsByEntityFunction | undefined;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* 根据数据删除数据源
|
|
293
|
+
* <pre>
|
|
294
|
+
* @Widget.Method()
|
|
295
|
+
* @Widget.Inject()
|
|
296
|
+
* private deleteDataSourceByEntity: DeleteDataSourceByEntityFunction | undefined;
|
|
297
|
+
* </pre>
|
|
298
|
+
*
|
|
299
|
+
* @param records 数据
|
|
300
|
+
* @param predict 删除判定
|
|
301
|
+
*/
|
|
302
|
+
@Widget.Method()
|
|
303
|
+
@Widget.Provide()
|
|
304
|
+
public deleteDataSourceByEntity(records: ActiveRecords, predict?: DeleteActiveRecordsByEntityPredict) {
|
|
305
|
+
if (this.parentDeleteDataSourceByEntity && this.getCurrentDataSource() === undefined) {
|
|
306
|
+
this.parentDeleteDataSourceByEntity(records, predict);
|
|
307
|
+
} else {
|
|
308
|
+
const nextDataSource = ActiveRecordsOperator.operator(this.getCurrentDataSource() || undefined, this.submitCache)
|
|
309
|
+
.deleteByEntity(records, predict)
|
|
310
|
+
.get();
|
|
311
|
+
if (!this.submitCache) {
|
|
312
|
+
this.setCurrentDataSource(nextDataSource);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
@Widget.Method()
|
|
319
|
+
@Widget.Inject('createDataSourceByEntity')
|
|
320
|
+
protected parentCreateDataSourceByEntity: PushActiveRecordsFunction | undefined;
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@Widget.Method()
|
|
324
|
+
@Widget.Provide()
|
|
325
|
+
public createDataSourceByEntity(records:ActiveRecords,predict?:PushActiveRecordsPredict){
|
|
326
|
+
if (this.parentCreateDataSourceByEntity && this.getCurrentDataSource() === undefined) {
|
|
327
|
+
this.parentCreateDataSourceByEntity(records, predict);
|
|
328
|
+
} else {
|
|
329
|
+
const nextDataSource = Array.isArray(records) ? records : [records];
|
|
330
|
+
const oldDataSource = this.getCurrentDataSource() || [];
|
|
331
|
+
this.setCurrentDataSource([...nextDataSource, ...oldDataSource]);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@Widget.Method()
|
|
336
|
+
@Widget.Inject('flushDataSource')
|
|
337
|
+
protected parentFlushDataSource: FlushActiveRecordsFunction | undefined;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* 刷新数据源(数据向上提交)
|
|
341
|
+
* <pre>
|
|
342
|
+
* @Widget.Method()
|
|
343
|
+
* @Widget.Inject()
|
|
344
|
+
* private flushActiveRecords: FlushActiveRecordsFunction | undefined;
|
|
345
|
+
* </pre>
|
|
346
|
+
*/
|
|
347
|
+
@Widget.Method()
|
|
348
|
+
@Widget.Provide()
|
|
349
|
+
public flushDataSource() {
|
|
350
|
+
this.parentFlushDataSource?.();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 上级数据记录,不可直接修改,仅在挂载时加载到当前数据记录
|
|
355
|
+
*/
|
|
356
|
+
@Widget.Reactive()
|
|
357
|
+
@Widget.Inject('activeRecords')
|
|
358
|
+
protected parentActiveRecords: ActiveRecord[] | undefined;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 上级视图数据
|
|
362
|
+
*/
|
|
363
|
+
@Widget.Reactive()
|
|
364
|
+
@Widget.Inject('parentViewActiveRecords')
|
|
365
|
+
protected parentViewActiveRecords: ActiveRecord[] | undefined;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* 当前数据记录,不存在时将进行数据透传
|
|
369
|
+
*/
|
|
370
|
+
@Widget.Reactive()
|
|
371
|
+
private currentActiveRecords: ActiveRecord[] | undefined;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 提供给下级的数据记录
|
|
375
|
+
*/
|
|
376
|
+
@Widget.Reactive()
|
|
377
|
+
@Widget.Provide()
|
|
378
|
+
public get activeRecords(): ActiveRecord[] | undefined {
|
|
379
|
+
return this.currentActiveRecords || this.parentActiveRecords;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
public set activeRecords(activeRecords: ActiveRecord[] | undefined) {
|
|
383
|
+
this.currentActiveRecords = activeRecords;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
public getCurrentActiveRecords(): ActiveRecord[] | undefined {
|
|
387
|
+
return this.currentActiveRecords;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
public setCurrentActiveRecords(activeRecords: ActiveRecords | undefined) {
|
|
391
|
+
if (activeRecords === this.currentActiveRecords) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
this.currentActiveRecords = ActiveRecordsOperator.repairRecordsNullable(activeRecords);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
@Widget.Method()
|
|
399
|
+
@Widget.Inject('reloadActiveRecords')
|
|
400
|
+
protected parentReloadActiveRecords: ReloadActiveRecordsFunction | undefined;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* 重新加载数据记录到当前数据记录中
|
|
404
|
+
* <pre>
|
|
405
|
+
* @Widget.Method()
|
|
406
|
+
* @Widget.Inject()
|
|
407
|
+
* private reloadActiveRecords: ReloadActiveRecordsFunction | undefined;
|
|
408
|
+
* </pre>
|
|
409
|
+
*
|
|
410
|
+
* @param records 数据
|
|
411
|
+
*/
|
|
412
|
+
@Widget.Method()
|
|
413
|
+
@Widget.Provide()
|
|
414
|
+
public reloadActiveRecords(records: ActiveRecords | undefined) {
|
|
415
|
+
if (this.parentReloadActiveRecords && this.getCurrentDataSource() === undefined) {
|
|
416
|
+
this.parentReloadActiveRecords(records);
|
|
417
|
+
} else {
|
|
418
|
+
this.setCurrentActiveRecords(records);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
@Widget.Method()
|
|
423
|
+
@Widget.Inject('pushActiveRecords')
|
|
424
|
+
protected parentPushActiveRecords: PushActiveRecordsFunction | undefined;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 添加数据记录到当前数据记录中
|
|
428
|
+
* <pre>
|
|
429
|
+
* @Widget.Method()
|
|
430
|
+
* @Widget.Inject()
|
|
431
|
+
* private pushActiveRecords: PushActiveRecordsFunction | undefined;
|
|
432
|
+
* </pre>
|
|
433
|
+
*
|
|
434
|
+
* @param records 数据
|
|
435
|
+
* @param predict 推送判定
|
|
436
|
+
*/
|
|
437
|
+
@Widget.Method()
|
|
438
|
+
@Widget.Provide()
|
|
439
|
+
public pushActiveRecords(records: ActiveRecords, predict?: PushActiveRecordsPredict) {
|
|
440
|
+
if (this.parentPushActiveRecords && this.getCurrentDataSource() === undefined) {
|
|
441
|
+
this.parentPushActiveRecords(records, predict);
|
|
442
|
+
} else {
|
|
443
|
+
this.currentActiveRecords = ActiveRecordsOperator.operator(this.currentActiveRecords)
|
|
444
|
+
.push(records, predict)
|
|
445
|
+
.get();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
@Widget.Method()
|
|
450
|
+
@Widget.Inject('updateActiveRecords')
|
|
451
|
+
protected parentUpdateActiveRecords: UpdateActiveRecordsFunction | undefined;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* 根据索引更新数据记录
|
|
455
|
+
* <pre>
|
|
456
|
+
* @Widget.Method()
|
|
457
|
+
* @Widget.Inject()
|
|
458
|
+
* private updateActiveRecords: UpdateActiveRecordsFunction | undefined;
|
|
459
|
+
* </pre>
|
|
460
|
+
*
|
|
461
|
+
* @param records 数据
|
|
462
|
+
*/
|
|
463
|
+
@Widget.Method()
|
|
464
|
+
@Widget.Provide()
|
|
465
|
+
public updateActiveRecords(records: UpdateEntity[]) {
|
|
466
|
+
if (this.parentUpdateActiveRecords && this.getCurrentDataSource() === undefined) {
|
|
467
|
+
this.parentUpdateActiveRecords(records);
|
|
468
|
+
} else {
|
|
469
|
+
this.currentActiveRecords = ActiveRecordsOperator.operator(this.currentActiveRecords).update(records).get();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
@Widget.Method()
|
|
474
|
+
@Widget.Inject('updateActiveRecordsByEntity')
|
|
475
|
+
protected parentUpdateActiveRecordsByEntity: UpdateActiveRecordsByEntityFunction | undefined;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* 根据数据更新数据记录
|
|
479
|
+
* <pre>
|
|
480
|
+
* @Widget.Method()
|
|
481
|
+
* @Widget.Inject()
|
|
482
|
+
* private updateActiveRecordsByEntity: UpdateActiveRecordsByEntityFunction | undefined;
|
|
483
|
+
* </pre>
|
|
484
|
+
*
|
|
485
|
+
* @param records 数据
|
|
486
|
+
* @param updatePredict 更新判定
|
|
487
|
+
*/
|
|
488
|
+
@Widget.Method()
|
|
489
|
+
@Widget.Provide()
|
|
490
|
+
public updateActiveRecordsByEntity(records: ActiveRecords, updatePredict?: UpdateActiveRecordsByEntityPredict) {
|
|
491
|
+
if (this.parentUpdateActiveRecordsByEntity && this.getCurrentDataSource() === undefined) {
|
|
492
|
+
this.parentUpdateActiveRecordsByEntity(records, updatePredict);
|
|
493
|
+
} else {
|
|
494
|
+
this.currentActiveRecords = ActiveRecordsOperator.operator(this.currentActiveRecords)
|
|
495
|
+
.updateByEntity(records, updatePredict)
|
|
496
|
+
.get();
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
@Widget.Method()
|
|
501
|
+
@Widget.Inject('deleteActiveRecords')
|
|
502
|
+
protected parentDeleteActiveRecords: DeleteActiveRecordsFunction | undefined;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* 根据索引删除数据记录
|
|
506
|
+
* <pre>
|
|
507
|
+
* @Widget.Method()
|
|
508
|
+
* @Widget.Inject()
|
|
509
|
+
* private deleteActiveRecords: DeleteActiveRecordsFunction | undefined;
|
|
510
|
+
* </pre>
|
|
511
|
+
*
|
|
512
|
+
* @param recordIndexes 数据
|
|
513
|
+
*/
|
|
514
|
+
@Widget.Method()
|
|
515
|
+
@Widget.Provide()
|
|
516
|
+
public deleteActiveRecords(recordIndexes: number[]) {
|
|
517
|
+
if (this.parentDeleteActiveRecords && this.getCurrentDataSource() === undefined) {
|
|
518
|
+
this.parentDeleteActiveRecords(recordIndexes);
|
|
519
|
+
} else {
|
|
520
|
+
this.currentActiveRecords = ActiveRecordsOperator.operator(this.currentActiveRecords).delete(recordIndexes).get();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
@Widget.Method()
|
|
525
|
+
@Widget.Inject('deleteActiveRecordsByEntity')
|
|
526
|
+
protected parentDeleteActiveRecordsByEntity: DeleteActiveRecordsByEntityFunction | undefined;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* 根据数据删除数据记录
|
|
530
|
+
* <pre>
|
|
531
|
+
* @Widget.Method()
|
|
532
|
+
* @Widget.Inject()
|
|
533
|
+
* private deleteActiveRecordsByEntity: DeleteActiveRecordsByEntityFunction | undefined;
|
|
534
|
+
* </pre>
|
|
535
|
+
*
|
|
536
|
+
* @param records 数据
|
|
537
|
+
* @param predict 删除判定
|
|
538
|
+
*/
|
|
539
|
+
@Widget.Method()
|
|
540
|
+
@Widget.Provide()
|
|
541
|
+
public deleteActiveRecordsByEntity(records: ActiveRecords, predict?: DeleteActiveRecordsByEntityPredict) {
|
|
542
|
+
if (this.parentDeleteActiveRecordsByEntity && this.getCurrentDataSource() === undefined) {
|
|
543
|
+
this.parentDeleteActiveRecordsByEntity(records, predict);
|
|
544
|
+
} else {
|
|
545
|
+
this.currentActiveRecords = ActiveRecordsOperator.operator(this.currentActiveRecords)
|
|
546
|
+
.deleteByEntity(records, predict)
|
|
547
|
+
.get();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
@Widget.Method()
|
|
552
|
+
@Widget.Inject('flushActiveRecords')
|
|
553
|
+
protected parentFlushActiveRecords: FlushActiveRecordsFunction | undefined;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* 刷新数据记录(数据向上提交)
|
|
557
|
+
* <pre>
|
|
558
|
+
* @Widget.Method()
|
|
559
|
+
* @Widget.Inject()
|
|
560
|
+
* private flushActiveRecords: FlushActiveRecordsFunction | undefined;
|
|
561
|
+
* </pre>
|
|
562
|
+
*/
|
|
563
|
+
@Widget.Method()
|
|
564
|
+
@Widget.Provide()
|
|
565
|
+
public flushActiveRecords() {
|
|
566
|
+
if (this.parentFlushActiveRecords && this.getCurrentDataSource() === undefined) {
|
|
567
|
+
this.parentFlushActiveRecords();
|
|
568
|
+
} else {
|
|
569
|
+
this.currentActiveRecords = [];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isNil } from 'lodash-es';
|
|
2
|
+
import { Widget } from '../basic';
|
|
3
|
+
import { DslDefinitionWidgetProps, DslDefinitionWidget } from '../dsl';
|
|
4
|
+
|
|
5
|
+
export interface PathWidgetProps extends DslDefinitionWidgetProps {
|
|
6
|
+
path?: string;
|
|
7
|
+
subPath?: string;
|
|
8
|
+
subIndex?: string | number;
|
|
9
|
+
|
|
10
|
+
__index?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 路径组件
|
|
15
|
+
*/
|
|
16
|
+
export class PathWidget<Props extends PathWidgetProps = PathWidgetProps> extends DslDefinitionWidget<Props> {
|
|
17
|
+
/**
|
|
18
|
+
* 上级路径
|
|
19
|
+
*/
|
|
20
|
+
@Widget.Reactive()
|
|
21
|
+
@Widget.Inject('path')
|
|
22
|
+
protected parentPath: string | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 当前子路径
|
|
26
|
+
*/
|
|
27
|
+
@Widget.Reactive()
|
|
28
|
+
protected subPath: string | undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 当前子路径索引
|
|
32
|
+
*/
|
|
33
|
+
@Widget.Reactive()
|
|
34
|
+
protected subIndex: string | number | undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 当前指定路径
|
|
38
|
+
* @protected
|
|
39
|
+
*/
|
|
40
|
+
@Widget.Reactive()
|
|
41
|
+
protected currentPath: string | undefined;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 完整路径
|
|
45
|
+
*/
|
|
46
|
+
@Widget.Reactive()
|
|
47
|
+
@Widget.Provide()
|
|
48
|
+
public get path() {
|
|
49
|
+
const { parentPath, subPath, subIndex, currentPath } = this;
|
|
50
|
+
if (isNil(currentPath)) {
|
|
51
|
+
let path = parentPath || '';
|
|
52
|
+
if (this.internal) {
|
|
53
|
+
return path;
|
|
54
|
+
}
|
|
55
|
+
if (subPath) {
|
|
56
|
+
if (path) {
|
|
57
|
+
path = `${path}.${subPath}`;
|
|
58
|
+
} else {
|
|
59
|
+
path = subPath;
|
|
60
|
+
}
|
|
61
|
+
if (subIndex != null) {
|
|
62
|
+
path = `${path}[${subIndex}]`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return path;
|
|
66
|
+
}
|
|
67
|
+
return currentPath;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public initialize(props: Props) {
|
|
71
|
+
super.initialize(props);
|
|
72
|
+
const { subPath, subIndex, path } = props;
|
|
73
|
+
this.currentPath = path;
|
|
74
|
+
this.subPath = subPath || this.template?.dslNodeType || '';
|
|
75
|
+
if (isNil(subIndex)) {
|
|
76
|
+
this.subIndex = props.__index;
|
|
77
|
+
} else {
|
|
78
|
+
this.subIndex = subIndex;
|
|
79
|
+
}
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
}
|