amis 1.8.0-beta.1 → 1.8.0-beta.5
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/lib/SchemaRenderer.js +19 -3
- package/lib/SchemaRenderer.js.map +2 -2
- package/lib/WithRootStore.d.ts +18 -0
- package/lib/WithStore.js +2 -1
- package/lib/WithStore.js.map +2 -2
- package/lib/actions/CmptAction.js +14 -3
- package/lib/actions/CmptAction.js.map +2 -2
- package/lib/components/AssociatedSelection.js +9 -2
- package/lib/components/AssociatedSelection.js.map +2 -2
- package/lib/components/BarCode.js +1 -1
- package/lib/components/BarCode.js.map +2 -2
- package/lib/components/Checkbox.d.ts +24 -23
- package/lib/components/Checkbox.js +6 -2
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/DatePicker.js +16 -5
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/DateRangePicker.d.ts +94 -84
- package/lib/components/DateRangePicker.js +259 -7
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/MonthRangePicker.d.ts +84 -84
- package/lib/components/Radios.d.ts +22 -22
- package/lib/components/Radios.js +3 -5
- package/lib/components/Radios.js.map +2 -2
- package/lib/components/Range.d.ts +2 -2
- package/lib/components/Range.js +24 -11
- package/lib/components/Range.js.map +2 -2
- package/lib/components/Steps.d.ts +6 -0
- package/lib/components/Steps.js +13 -9
- package/lib/components/Steps.js.map +2 -2
- package/lib/components/calendar/Calendar.js +2 -14
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/calendar/YearsView.js +3 -3
- package/lib/components/calendar/YearsView.js.map +2 -2
- package/lib/factory.d.ts +4 -0
- package/lib/factory.js +9 -0
- package/lib/factory.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +13 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +13 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +13 -0
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +2 -0
- package/lib/renderers/Action.js +23 -5
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/CRUD.d.ts +8 -0
- package/lib/renderers/CRUD.js +11 -4
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Carousel.d.ts +1 -0
- package/lib/renderers/Carousel.js +13 -1
- package/lib/renderers/Carousel.js.map +2 -2
- package/lib/renderers/Form/Checkbox.d.ts +5 -2
- package/lib/renderers/Form/Checkbox.js +2 -2
- package/lib/renderers/Form/Checkbox.js.map +2 -2
- package/lib/renderers/Form/Checkboxes.d.ts +7 -2
- package/lib/renderers/Form/Checkboxes.js +101 -12
- package/lib/renderers/Form/Checkboxes.js.map +2 -2
- package/lib/renderers/Form/Combo.js +3 -2
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/InputCity.d.ts +3 -0
- package/lib/renderers/Form/InputCity.js +44 -2
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.d.ts +5 -0
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +6 -3
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.js +6 -3
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputRange.js +13 -14
- package/lib/renderers/Form/InputRange.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +11 -6
- package/lib/renderers/Form/Item.js +3 -1
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/index.d.ts +1 -0
- package/lib/renderers/Form/index.js +1 -1
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Form/wrapControl.d.ts +9 -0
- package/lib/renderers/Form/wrapControl.js +1 -1
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Nav.js +2 -2
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Steps.d.ts +8 -0
- package/lib/renderers/Steps.js +2 -2
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +10 -5
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +4 -0
- package/lib/renderers/Tabs.js +22 -6
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/Wizard.d.ts +6 -3
- package/lib/renderers/Wizard.js +257 -152
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/crud.d.ts +1 -0
- package/lib/store/crud.js +33 -7
- package/lib/store/crud.js.map +2 -2
- package/lib/store/formItem.js +1 -1
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/index.d.ts +5 -0
- package/lib/store/index.js +14 -0
- package/lib/store/index.js.map +2 -2
- package/lib/store/table.js +2 -2
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +278 -17
- package/lib/themes/ang.css +286 -17
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +278 -17
- package/lib/themes/antd.css +286 -17
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +278 -17
- package/lib/themes/cxd.css +286 -17
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +278 -17
- package/lib/themes/dark.css +286 -17
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +278 -17
- package/lib/themes/default.css +286 -17
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/columnsSplit.d.ts +1 -0
- package/lib/utils/columnsSplit.js +40 -0
- package/lib/utils/columnsSplit.js.map +13 -0
- package/lib/utils/debug.d.ts +1 -1
- package/lib/utils/debug.js +16 -22
- package/lib/utils/debug.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +237 -29
- package/scss/_properties.scss +10 -1
- package/scss/components/_barcode.scss +1 -1
- package/scss/components/_carousel.scss +1 -0
- package/scss/components/_debug.scss +3 -3
- package/scss/components/_steps.scss +199 -8
- package/scss/components/form/_checks.scss +122 -1
- package/scss/components/form/_date.scss +2 -1
- package/scss/components/form/_editor.scss +2 -1
- package/scss/components/form/_form.scss +16 -0
- package/sdk/ang-ie11.css +335 -18
- package/sdk/ang.css +343 -18
- package/sdk/antd-ie11.css +335 -18
- package/sdk/antd.css +343 -18
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +335 -18
- package/sdk/cxd.css +343 -18
- package/sdk/dark-ie11.css +335 -18
- package/sdk/dark.css +343 -18
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +13 -0
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +335 -18
- package/sdk/sdk.css +343 -18
- package/sdk/sdk.js +1289 -1287
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/SchemaRenderer.tsx +32 -14
- package/src/WithStore.tsx +3 -1
- package/src/actions/CmptAction.ts +18 -0
- package/src/components/AssociatedSelection.tsx +9 -3
- package/src/components/BarCode.tsx +2 -2
- package/src/components/Checkbox.tsx +11 -5
- package/src/components/DatePicker.tsx +21 -4
- package/src/components/DateRangePicker.tsx +295 -6
- package/src/components/Radios.tsx +6 -17
- package/src/components/Range.tsx +26 -12
- package/src/components/Steps.tsx +28 -27
- package/src/components/calendar/Calendar.tsx +2 -15
- package/src/components/calendar/YearsView.tsx +3 -4
- package/src/factory.tsx +16 -0
- package/src/locale/de-DE.ts +13 -0
- package/src/locale/en-US.ts +13 -0
- package/src/locale/zh-CN.ts +13 -0
- package/src/renderers/Action.tsx +22 -1
- package/src/renderers/CRUD.tsx +22 -4
- package/src/renderers/Carousel.tsx +8 -0
- package/src/renderers/Form/Checkbox.tsx +11 -2
- package/src/renderers/Form/Checkboxes.tsx +106 -23
- package/src/renderers/Form/Combo.tsx +2 -3
- package/src/renderers/Form/InputCity.tsx +33 -4
- package/src/renderers/Form/InputDateRange.tsx +8 -1
- package/src/renderers/Form/InputFile.tsx +7 -3
- package/src/renderers/Form/InputImage.tsx +7 -3
- package/src/renderers/Form/InputRange.tsx +18 -16
- package/src/renderers/Form/Item.tsx +1 -0
- package/src/renderers/Form/index.tsx +2 -1
- package/src/renderers/Form/wrapControl.tsx +1 -1
- package/src/renderers/Nav.tsx +1 -1
- package/src/renderers/Steps.tsx +14 -0
- package/src/renderers/Table/index.tsx +15 -4
- package/src/renderers/Tabs.tsx +75 -28
- package/src/renderers/Wizard.tsx +154 -93
- package/src/store/crud.ts +40 -5
- package/src/store/formItem.ts +1 -2
- package/src/store/index.ts +20 -0
- package/src/store/table.ts +2 -2
- package/src/types.ts +3 -1
- package/src/utils/columnsSplit.tsx +57 -0
- package/src/utils/debug.tsx +17 -24
package/src/renderers/Tabs.tsx
CHANGED
@@ -264,7 +264,11 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
264
264
|
|
265
265
|
// 初始化 tabs 数组,当从 source 获取数据源时
|
266
266
|
@autobind
|
267
|
-
initTabArray(
|
267
|
+
initTabArray(
|
268
|
+
tabs: Array<TabSource>,
|
269
|
+
source?: string,
|
270
|
+
data?: any
|
271
|
+
): [Array<TabSource>, boolean] {
|
268
272
|
if (!tabs) {
|
269
273
|
return [[], false];
|
270
274
|
}
|
@@ -325,16 +329,28 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
325
329
|
let localTabs = this.state.localTabs;
|
326
330
|
|
327
331
|
// 响应外部修改 tabs
|
328
|
-
const isTabsModified = isObjectShallowModified(
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
332
|
+
const isTabsModified = isObjectShallowModified(
|
333
|
+
{
|
334
|
+
tabs: props.tabs,
|
335
|
+
source: resolveVariableAndFilter(props.source, props.data, '| raw')
|
336
|
+
},
|
337
|
+
{
|
338
|
+
tabs: preProps.tabs,
|
339
|
+
source: resolveVariableAndFilter(
|
340
|
+
preProps.source,
|
341
|
+
preProps.data,
|
342
|
+
'| raw'
|
343
|
+
)
|
344
|
+
},
|
345
|
+
false
|
346
|
+
);
|
335
347
|
|
336
348
|
if (isTabsModified) {
|
337
|
-
const [newLocalTabs, isFromSource] = this.initTabArray(
|
349
|
+
const [newLocalTabs, isFromSource] = this.initTabArray(
|
350
|
+
props.tabs,
|
351
|
+
props.source,
|
352
|
+
props.data
|
353
|
+
);
|
338
354
|
|
339
355
|
this.setState({
|
340
356
|
localTabs: newLocalTabs,
|
@@ -343,7 +359,11 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
343
359
|
localTabs = newLocalTabs;
|
344
360
|
}
|
345
361
|
|
346
|
-
if (
|
362
|
+
if (
|
363
|
+
props.location &&
|
364
|
+
preProps.location &&
|
365
|
+
props.location.hash !== preProps.location.hash
|
366
|
+
) {
|
347
367
|
const hash = props.location.hash.substring(1);
|
348
368
|
if (!hash) {
|
349
369
|
return;
|
@@ -464,7 +484,10 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
464
484
|
tab.hash ? tab.hash === key : index === key
|
465
485
|
);
|
466
486
|
|
467
|
-
if (
|
487
|
+
if (
|
488
|
+
localTabs[tabIndex] &&
|
489
|
+
!isVisible(localTabs[tabIndex], this.props.data)
|
490
|
+
) {
|
468
491
|
let len = localTabs.length;
|
469
492
|
let i = tabIndex - 1 + len;
|
470
493
|
let tries = len - 1;
|
@@ -491,11 +514,14 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
491
514
|
body: '新增tab 内容'
|
492
515
|
} as TabSource);
|
493
516
|
|
494
|
-
this.setState(
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
517
|
+
this.setState(
|
518
|
+
{
|
519
|
+
localTabs: localTabs
|
520
|
+
},
|
521
|
+
() => {
|
522
|
+
this.switchTo(this.state.localTabs.length - 1);
|
523
|
+
}
|
524
|
+
);
|
499
525
|
}
|
500
526
|
|
501
527
|
@autobind
|
@@ -520,20 +546,23 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
520
546
|
}
|
521
547
|
|
522
548
|
@autobind
|
523
|
-
async handleDragChange(e: any){
|
549
|
+
async handleDragChange(e: any) {
|
524
550
|
const activeTab = this.resolveTabByKey(this.activeKey);
|
525
551
|
const originTabs: TabSource[] = this.state.localTabs.concat();
|
526
552
|
|
527
553
|
originTabs.splice(e.newIndex, 0, originTabs.splice(e.oldIndex, 1)[0]);
|
528
554
|
|
529
|
-
this.setState(
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
555
|
+
this.setState(
|
556
|
+
{
|
557
|
+
localTabs: originTabs
|
558
|
+
},
|
559
|
+
() => {
|
560
|
+
if (activeTab) {
|
561
|
+
const newActiveTabIndex = originTabs.indexOf(activeTab);
|
562
|
+
this.switchTo(newActiveTabIndex);
|
563
|
+
}
|
535
564
|
}
|
536
|
-
|
565
|
+
);
|
537
566
|
}
|
538
567
|
|
539
568
|
@autobind
|
@@ -571,9 +600,12 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
571
600
|
@autobind
|
572
601
|
async handleChange(key: any, name: any) {
|
573
602
|
const {dispatchEvent, data, onChange} = this.props;
|
574
|
-
const rendererEvent = await dispatchEvent(
|
575
|
-
|
576
|
-
|
603
|
+
const rendererEvent = await dispatchEvent(
|
604
|
+
'change',
|
605
|
+
createObject(data, {
|
606
|
+
value: key
|
607
|
+
})
|
608
|
+
);
|
577
609
|
if (rendererEvent?.prevented) {
|
578
610
|
return;
|
579
611
|
}
|
@@ -772,4 +804,19 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
772
804
|
@Renderer({
|
773
805
|
type: 'tabs'
|
774
806
|
})
|
775
|
-
export class TabsRenderer extends Tabs {
|
807
|
+
export class TabsRenderer extends Tabs {
|
808
|
+
static contextType = ScopedContext;
|
809
|
+
|
810
|
+
constructor(props: TabsProps, context: IScopedContext) {
|
811
|
+
super(props);
|
812
|
+
|
813
|
+
const scoped = context;
|
814
|
+
scoped.registerComponent(this);
|
815
|
+
}
|
816
|
+
|
817
|
+
componentWillUnmount() {
|
818
|
+
super.componentWillUnmount?.();
|
819
|
+
const scoped = this.context as IScopedContext;
|
820
|
+
scoped.unRegisterComponent(this);
|
821
|
+
}
|
822
|
+
}
|
package/src/renderers/Wizard.tsx
CHANGED
@@ -253,7 +253,8 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
253
253
|
}
|
254
254
|
})
|
255
255
|
.then(value => {
|
256
|
-
|
256
|
+
this.handleInitEvent(store.data)
|
257
|
+
|
257
258
|
const state = {
|
258
259
|
currentStep:
|
259
260
|
typeof this.props.startStep === 'string'
|
@@ -291,7 +292,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
291
292
|
? parseInt(tokenize(this.props.startStep, this.props.data))
|
292
293
|
: 1
|
293
294
|
},
|
294
|
-
() =>
|
295
|
+
() => this.handleInitEvent(store.data)
|
295
296
|
);
|
296
297
|
}
|
297
298
|
|
@@ -336,6 +337,19 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
336
337
|
this.unSensor && this.unSensor();
|
337
338
|
}
|
338
339
|
|
340
|
+
async dispatchEvent(action: string, value?: object) {
|
341
|
+
const {dispatchEvent, data} = this.props;
|
342
|
+
|
343
|
+
const rendererEvent = await dispatchEvent(action, createObject(data, value ? {value} : {}));
|
344
|
+
|
345
|
+
return rendererEvent?.prevented ?? false;
|
346
|
+
}
|
347
|
+
|
348
|
+
async handleInitEvent(data: any) {
|
349
|
+
const {onInit} = this.props;
|
350
|
+
(await this.dispatchEvent('inited', data)) && onInit && onInit(data);
|
351
|
+
}
|
352
|
+
|
339
353
|
@autobind
|
340
354
|
affixDetect() {
|
341
355
|
if (
|
@@ -364,11 +378,15 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
364
378
|
affixed ? affixDom.classList.add('in') : affixDom.classList.remove('in');
|
365
379
|
}
|
366
380
|
|
367
|
-
gotoStep(index: number) {
|
381
|
+
async gotoStep(index: number) {
|
368
382
|
const steps = this.props.steps || [];
|
369
383
|
index = Math.max(Math.min(steps.length, index), 1);
|
370
384
|
|
371
385
|
if (index != this.state.currentStep) {
|
386
|
+
if (await this.dispatchEvent('stepChange')) {
|
387
|
+
return
|
388
|
+
}
|
389
|
+
|
372
390
|
this.setState({
|
373
391
|
currentStep: index,
|
374
392
|
completeStep: Math.max(this.state.completeStep, index - 1)
|
@@ -517,9 +535,9 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
517
535
|
throwErrors: boolean = false,
|
518
536
|
delegate?: IScopedContext
|
519
537
|
) {
|
520
|
-
const {onAction, store, env} = this.props;
|
538
|
+
const {onAction, store, env, steps} = this.props;
|
521
539
|
|
522
|
-
if (action.actionType === 'next' || action.type === 'submit') {
|
540
|
+
if (action.actionType === 'next' || action.type === 'submit' || action.actionType === 'step-submit') {
|
523
541
|
this.form.doAction(
|
524
542
|
{
|
525
543
|
...action,
|
@@ -572,6 +590,14 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
572
590
|
});
|
573
591
|
} else if (action.actionType === 'reload') {
|
574
592
|
action.target && this.reloadTarget(action.target, data);
|
593
|
+
} else if (action.actionType === 'goto-step') {
|
594
|
+
const targetStep = (data as any).step;
|
595
|
+
|
596
|
+
if (targetStep !== undefined && targetStep <= steps.length && targetStep >= 0) {
|
597
|
+
this.gotoStep((data as any).step);
|
598
|
+
}
|
599
|
+
} else if (action.actionType === 'submit') {
|
600
|
+
this.finalSubmit()
|
575
601
|
} else if (onAction) {
|
576
602
|
onAction(e, action, data, throwErrors, delegate || this.context);
|
577
603
|
}
|
@@ -601,9 +627,17 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
601
627
|
}
|
602
628
|
|
603
629
|
@autobind
|
604
|
-
handleChange(values: object) {
|
630
|
+
async handleChange(values: object) {
|
605
631
|
const {store} = this.props;
|
606
632
|
|
633
|
+
const previous = store.data;
|
634
|
+
const final = {...previous, ...values};
|
635
|
+
|
636
|
+
if (await this.dispatchEvent('change', final)) {
|
637
|
+
return;
|
638
|
+
}
|
639
|
+
|
640
|
+
|
607
641
|
store.updateData(values);
|
608
642
|
}
|
609
643
|
|
@@ -630,9 +664,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
630
664
|
store.updateData(reseted);
|
631
665
|
}
|
632
666
|
|
633
|
-
|
634
|
-
@autobind
|
635
|
-
handleSubmit(values: object, action: Action) {
|
667
|
+
async finalSubmit(values: object = {}, action: Action = {type: 'submit'}) {
|
636
668
|
const {
|
637
669
|
store,
|
638
670
|
steps,
|
@@ -646,10 +678,118 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
646
678
|
onFinished
|
647
679
|
} = this.props;
|
648
680
|
|
681
|
+
if (await this.dispatchEvent('finished', store.data)) {
|
682
|
+
return;
|
683
|
+
}
|
684
|
+
|
649
685
|
const step = steps[this.state.currentStep - 1];
|
650
686
|
store.updateData(values);
|
651
687
|
|
688
|
+
|
689
|
+
// 最后一步
|
690
|
+
if (target) {
|
691
|
+
this.submitToTarget(target, store.data);
|
692
|
+
this.setState({completeStep: steps.length});
|
693
|
+
} else if (action.api || step.api || api) {
|
694
|
+
let finnalAsyncApi = action.asyncApi || step.asyncApi || asyncApi;
|
695
|
+
|
696
|
+
isEffectiveApi(finnalAsyncApi, store.data) &&
|
697
|
+
store.updateData({
|
698
|
+
[finishedField || 'finished']: false
|
699
|
+
});
|
700
|
+
|
701
|
+
const formStore = this.form
|
702
|
+
? (this.form.props.store as IFormStore)
|
703
|
+
: store;
|
704
|
+
store.markSaving(true);
|
705
|
+
|
706
|
+
formStore
|
707
|
+
.saveRemote(action.api || step.api || api!, store.data, {
|
708
|
+
onSuccess: () => {
|
709
|
+
this.dispatchEvent('submitSucc', store.data);
|
710
|
+
|
711
|
+
if (
|
712
|
+
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
713
|
+
store.data[finishedField || 'finished']
|
714
|
+
) {
|
715
|
+
return;
|
716
|
+
}
|
717
|
+
|
718
|
+
return until(
|
719
|
+
() => store.checkRemote(finnalAsyncApi as Api, store.data),
|
720
|
+
(ret: any) => ret && ret[finishedField || 'finished'],
|
721
|
+
cancel => (this.asyncCancel = cancel)
|
722
|
+
);
|
723
|
+
},
|
724
|
+
onFailed: json => this.dispatchEvent('submitFail', json)
|
725
|
+
})
|
726
|
+
.then(async value => {
|
727
|
+
const feedback = action.feedback;
|
728
|
+
if (feedback && isVisible(feedback, value)) {
|
729
|
+
const confirmed = await this.openFeedback(feedback, value);
|
730
|
+
|
731
|
+
// 如果 feedback 配置了,取消就跳过原有逻辑。
|
732
|
+
if (feedback.skipRestOnCancel && !confirmed) {
|
733
|
+
throw new SkipOperation();
|
734
|
+
} else if (feedback.skipRestOnConfirm && confirmed) {
|
735
|
+
throw new SkipOperation();
|
736
|
+
}
|
737
|
+
}
|
738
|
+
|
739
|
+
this.setState({completeStep: steps.length});
|
740
|
+
store.updateData({
|
741
|
+
...store.data,
|
742
|
+
...value
|
743
|
+
});
|
744
|
+
store.markSaving(false);
|
745
|
+
|
746
|
+
if (value && typeof value.step === 'number') {
|
747
|
+
this.gotoStep(value.step);
|
748
|
+
} else if (onFinished && onFinished(value, action) === false) {
|
749
|
+
// 如果是 false 后面的操作就不执行
|
750
|
+
return value;
|
751
|
+
}
|
752
|
+
|
753
|
+
const finalRedirect =
|
754
|
+
(action.redirect || step.redirect || redirect) &&
|
755
|
+
filter(action.redirect || step.redirect || redirect, store.data);
|
756
|
+
|
757
|
+
if (finalRedirect) {
|
758
|
+
env.jumpTo(finalRedirect, action);
|
759
|
+
} else if (action.reload || step.reload || reload) {
|
760
|
+
this.reloadTarget(
|
761
|
+
action.reload || step.reload || reload!,
|
762
|
+
store.data
|
763
|
+
);
|
764
|
+
}
|
765
|
+
|
766
|
+
return value;
|
767
|
+
})
|
768
|
+
.catch(error => {
|
769
|
+
this.dispatchEvent('submitFail', error)
|
770
|
+
store.markSaving(false);
|
771
|
+
console.error(error);
|
772
|
+
});
|
773
|
+
} else {
|
774
|
+
onFinished && onFinished(store.data, action);
|
775
|
+
this.setState({completeStep: steps.length});
|
776
|
+
}
|
777
|
+
}
|
778
|
+
|
779
|
+
// 接管里面 form 的提交,不能直接让 form 提交,因为 wizard 自己需要知道进度。
|
780
|
+
@autobind
|
781
|
+
async handleSubmit(values: object, action: Action) {
|
782
|
+
const {
|
783
|
+
store,
|
784
|
+
steps,
|
785
|
+
finishedField
|
786
|
+
} = this.props;
|
787
|
+
|
788
|
+
|
652
789
|
if (this.state.currentStep < steps.length) {
|
790
|
+
const step = steps[this.state.currentStep - 1];
|
791
|
+
store.updateData(values);
|
792
|
+
|
653
793
|
let finnalAsyncApi = action.asyncApi || step.asyncApi;
|
654
794
|
|
655
795
|
isEffectiveApi(finnalAsyncApi, store.data) &&
|
@@ -661,6 +801,8 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
661
801
|
store
|
662
802
|
.saveRemote(action.api || step.api!, store.data, {
|
663
803
|
onSuccess: () => {
|
804
|
+
this.dispatchEvent('stepSubmitSucc', store.data);
|
805
|
+
|
664
806
|
if (
|
665
807
|
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
666
808
|
store.data[finishedField || 'finished']
|
@@ -675,6 +817,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
675
817
|
);
|
676
818
|
},
|
677
819
|
onFailed: json => {
|
820
|
+
this.dispatchEvent('stepSubmitFail', json);
|
678
821
|
if (json.status === 422 && json.errors && this.form) {
|
679
822
|
this.form.props.store.setFormItemErrors(json.errors);
|
680
823
|
}
|
@@ -700,6 +843,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
700
843
|
);
|
701
844
|
})
|
702
845
|
.catch(reason => {
|
846
|
+
this.dispatchEvent('stepSubmitFail', reason);
|
703
847
|
if (reason instanceof SkipOperation) {
|
704
848
|
return;
|
705
849
|
}
|
@@ -709,90 +853,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
709
853
|
this.gotoStep(this.state.currentStep + 1);
|
710
854
|
}
|
711
855
|
} else {
|
712
|
-
|
713
|
-
if (target) {
|
714
|
-
this.submitToTarget(target, store.data);
|
715
|
-
this.setState({completeStep: steps.length});
|
716
|
-
} else if (action.api || step.api || api) {
|
717
|
-
let finnalAsyncApi = action.asyncApi || step.asyncApi || asyncApi;
|
718
|
-
|
719
|
-
isEffectiveApi(finnalAsyncApi, store.data) &&
|
720
|
-
store.updateData({
|
721
|
-
[finishedField || 'finished']: false
|
722
|
-
});
|
723
|
-
|
724
|
-
const formStore = this.form
|
725
|
-
? (this.form.props.store as IFormStore)
|
726
|
-
: store;
|
727
|
-
store.markSaving(true);
|
728
|
-
|
729
|
-
formStore
|
730
|
-
.saveRemote(action.api || step.api || api!, store.data, {
|
731
|
-
onSuccess: () => {
|
732
|
-
if (
|
733
|
-
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
734
|
-
store.data[finishedField || 'finished']
|
735
|
-
) {
|
736
|
-
return;
|
737
|
-
}
|
738
|
-
|
739
|
-
return until(
|
740
|
-
() => store.checkRemote(finnalAsyncApi as Api, store.data),
|
741
|
-
(ret: any) => ret && ret[finishedField || 'finished'],
|
742
|
-
cancel => (this.asyncCancel = cancel)
|
743
|
-
);
|
744
|
-
}
|
745
|
-
})
|
746
|
-
.then(async value => {
|
747
|
-
const feedback = action.feedback;
|
748
|
-
if (feedback && isVisible(feedback, value)) {
|
749
|
-
const confirmed = await this.openFeedback(feedback, value);
|
750
|
-
|
751
|
-
// 如果 feedback 配置了,取消就跳过原有逻辑。
|
752
|
-
if (feedback.skipRestOnCancel && !confirmed) {
|
753
|
-
throw new SkipOperation();
|
754
|
-
} else if (feedback.skipRestOnConfirm && confirmed) {
|
755
|
-
throw new SkipOperation();
|
756
|
-
}
|
757
|
-
}
|
758
|
-
|
759
|
-
this.setState({completeStep: steps.length});
|
760
|
-
store.updateData({
|
761
|
-
...store.data,
|
762
|
-
...value
|
763
|
-
});
|
764
|
-
store.markSaving(false);
|
765
|
-
|
766
|
-
if (value && typeof value.step === 'number') {
|
767
|
-
this.gotoStep(value.step);
|
768
|
-
} else if (onFinished && onFinished(value, action) === false) {
|
769
|
-
// 如果是 false 后面的操作就不执行
|
770
|
-
return value;
|
771
|
-
}
|
772
|
-
|
773
|
-
const finalRedirect =
|
774
|
-
(action.redirect || step.redirect || redirect) &&
|
775
|
-
filter(action.redirect || step.redirect || redirect, store.data);
|
776
|
-
|
777
|
-
if (finalRedirect) {
|
778
|
-
env.jumpTo(finalRedirect, action);
|
779
|
-
} else if (action.reload || step.reload || reload) {
|
780
|
-
this.reloadTarget(
|
781
|
-
action.reload || step.reload || reload!,
|
782
|
-
store.data
|
783
|
-
);
|
784
|
-
}
|
785
|
-
|
786
|
-
return value;
|
787
|
-
})
|
788
|
-
.catch(e => {
|
789
|
-
store.markSaving(false);
|
790
|
-
console.error(e);
|
791
|
-
});
|
792
|
-
} else {
|
793
|
-
onFinished && onFinished(store.data, action);
|
794
|
-
this.setState({completeStep: steps.length});
|
795
|
-
}
|
856
|
+
this.finalSubmit(values, action);
|
796
857
|
}
|
797
858
|
|
798
859
|
return false;
|
package/src/store/crud.ts
CHANGED
@@ -16,12 +16,14 @@ import {
|
|
16
16
|
isObjectShallowModified,
|
17
17
|
sortArray,
|
18
18
|
isEmpty,
|
19
|
-
qsstringify
|
19
|
+
qsstringify,
|
20
|
+
getVariable
|
20
21
|
} from '../utils/helper';
|
21
22
|
import {Api, Payload, fetchOptions, Action, ApiObject} from '../types';
|
22
23
|
import pick from 'lodash/pick';
|
23
24
|
import {resolveVariableAndFilter} from '../utils/tpl-builtin';
|
24
25
|
import {normalizeApiResponseData} from '../utils/api';
|
26
|
+
import {matchSorter} from 'match-sorter';
|
25
27
|
|
26
28
|
class ServerError extends Error {
|
27
29
|
type = 'ServerError';
|
@@ -139,6 +141,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
139
141
|
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
|
140
142
|
loadDataMode?: boolean;
|
141
143
|
syncResponse2Query?: boolean;
|
144
|
+
columns?: Array<any>;
|
142
145
|
}
|
143
146
|
) => Promise<any> = flow(function* getInitData(
|
144
147
|
api: Api,
|
@@ -150,6 +153,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
150
153
|
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
|
151
154
|
loadDataMode?: boolean;
|
152
155
|
syncResponse2Query?: boolean;
|
156
|
+
columns?: Array<any>;
|
153
157
|
} = {}
|
154
158
|
) {
|
155
159
|
try {
|
@@ -165,6 +169,21 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
165
169
|
)
|
166
170
|
: self.items.concat();
|
167
171
|
|
172
|
+
if (Array.isArray(options.columns)) {
|
173
|
+
options.columns.forEach((column: any) => {
|
174
|
+
let value: any;
|
175
|
+
if (
|
176
|
+
column.searchable &&
|
177
|
+
column.name &&
|
178
|
+
(value = getVariable(self.query, column.name))
|
179
|
+
) {
|
180
|
+
items = matchSorter(items, value, {
|
181
|
+
keys: [column.name]
|
182
|
+
});
|
183
|
+
}
|
184
|
+
});
|
185
|
+
}
|
186
|
+
|
168
187
|
if (self.query.orderBy) {
|
169
188
|
const dir = /desc/i.test(self.query.orderDir) ? -1 : 1;
|
170
189
|
items = sortArray(items, self.query.orderBy, dir);
|
@@ -263,7 +282,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
263
282
|
}
|
264
283
|
|
265
284
|
// 点击加载更多数据
|
266
|
-
let rowsData = [];
|
285
|
+
let rowsData: Array<any> = [];
|
267
286
|
if (options.loadDataMode && Array.isArray(self.data.items)) {
|
268
287
|
rowsData = self.data.items.concat(items);
|
269
288
|
} else {
|
@@ -282,16 +301,32 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
282
301
|
if (options.loadDataOnce) {
|
283
302
|
// 记录原始集合,后续可能基于原始数据做排序查找。
|
284
303
|
data.itemsRaw = oItems || oRows;
|
304
|
+
let filteredItems = rowsData.concat();
|
305
|
+
|
306
|
+
if (Array.isArray(options.columns)) {
|
307
|
+
options.columns.forEach((column: any) => {
|
308
|
+
let value: any;
|
309
|
+
if (
|
310
|
+
column.searchable &&
|
311
|
+
column.name &&
|
312
|
+
(value = getVariable(self.query, column.name))
|
313
|
+
) {
|
314
|
+
filteredItems = matchSorter(filteredItems, value, {
|
315
|
+
keys: [column.name]
|
316
|
+
});
|
317
|
+
}
|
318
|
+
});
|
319
|
+
}
|
285
320
|
|
286
321
|
if (self.query.orderBy) {
|
287
322
|
const dir = /desc/i.test(self.query.orderDir) ? -1 : 1;
|
288
|
-
|
323
|
+
filteredItems = sortArray(filteredItems, self.query.orderBy, dir);
|
289
324
|
}
|
290
|
-
data.items =
|
325
|
+
data.items = filteredItems.slice(
|
291
326
|
(self.page - 1) * self.perPage,
|
292
327
|
self.page * self.perPage
|
293
328
|
);
|
294
|
-
data.count = data.total =
|
329
|
+
data.count = data.total = filteredItems.length;
|
295
330
|
}
|
296
331
|
|
297
332
|
if (Array.isArray(columns)) {
|
package/src/store/formItem.ts
CHANGED
@@ -723,8 +723,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
|
723
723
|
// 插入新的子节点,用于之后BaseSelection.resolveSelected查找
|
724
724
|
if (Array.isArray(topOption.children)) {
|
725
725
|
const children = topOption.children.concat();
|
726
|
-
|
727
|
-
flattenTree(topOption.leftOptions).forEach(item => {
|
726
|
+
flattenTree(newLeftOptions).forEach(item => {
|
728
727
|
if (!findTree(topOption.children, node => node.ref === item.value)) {
|
729
728
|
children.push({ref: item.value, defer: true});
|
730
729
|
}
|
package/src/store/index.ts
CHANGED
@@ -44,6 +44,10 @@ export const RendererStore = types
|
|
44
44
|
.model('RendererStore', {
|
45
45
|
storeType: 'RendererStore'
|
46
46
|
})
|
47
|
+
.props({
|
48
|
+
visibleState: types.optional(types.frozen(), {}),
|
49
|
+
disableState: types.optional(types.frozen(), {})
|
50
|
+
})
|
47
51
|
.views(self => ({
|
48
52
|
get fetcher() {
|
49
53
|
return getEnv(self).fetcher;
|
@@ -91,6 +95,22 @@ export const RendererStore = types
|
|
91
95
|
removeStore(store: IStoreNode) {
|
92
96
|
// store.dispose();
|
93
97
|
removeStore(store);
|
98
|
+
},
|
99
|
+
|
100
|
+
setVisible(id: string, value: boolean) {
|
101
|
+
const state = {
|
102
|
+
...self.visibleState,
|
103
|
+
[id]: value
|
104
|
+
};
|
105
|
+
self.visibleState = state;
|
106
|
+
},
|
107
|
+
|
108
|
+
setDisable(id: string, value: boolean) {
|
109
|
+
const state = {
|
110
|
+
...self.disableState,
|
111
|
+
[id]: value
|
112
|
+
};
|
113
|
+
self.disableState = state;
|
94
114
|
}
|
95
115
|
}));
|
96
116
|
|
package/src/store/table.ts
CHANGED
@@ -899,7 +899,7 @@ export const TableStore = iRendererStore
|
|
899
899
|
: {
|
900
900
|
item
|
901
901
|
};
|
902
|
-
const id = item.
|
902
|
+
const id = item.__id ?? guid();
|
903
903
|
|
904
904
|
return {
|
905
905
|
// id: String(item && (item as any)[self.primaryField] || `${pindex}-${depth}-${key}`),
|
@@ -941,7 +941,7 @@ export const TableStore = iRendererStore
|
|
941
941
|
|
942
942
|
let arr: Array<SRow> = rows.map((item, index) => {
|
943
943
|
let id = String(
|
944
|
-
getEntryId ? getEntryId(item, index) : item.
|
944
|
+
getEntryId ? getEntryId(item, index) : item.__id ?? guid()
|
945
945
|
);
|
946
946
|
return {
|
947
947
|
// id: getEntryId ? getEntryId(item, key) : String(item && (item as any)[self.primaryField] || `${key}-1-${key}`),
|
package/src/types.ts
CHANGED