@vyr/element-plus 0.0.1
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/package.json +24 -0
- package/src/actor/ElButtonActor.ts +42 -0
- package/src/actor/ElCascaderActor.ts +43 -0
- package/src/actor/ElCheckboxActor.ts +46 -0
- package/src/actor/ElColActor.ts +36 -0
- package/src/actor/ElDatePickerActor.ts +42 -0
- package/src/actor/ElDialogActor.ts +38 -0
- package/src/actor/ElFormActor.ts +46 -0
- package/src/actor/ElFormItemActor.ts +81 -0
- package/src/actor/ElInputActor.ts +47 -0
- package/src/actor/ElInputNumberActor.ts +38 -0
- package/src/actor/ElMenuActor.ts +35 -0
- package/src/actor/ElMenuItemActor.ts +46 -0
- package/src/actor/ElPaginationActor.ts +83 -0
- package/src/actor/ElRadioActor.ts +46 -0
- package/src/actor/ElRowActor.ts +37 -0
- package/src/actor/ElSelectActor.ts +49 -0
- package/src/actor/ElSubMenuActor.ts +46 -0
- package/src/actor/ElSwitchActor.ts +26 -0
- package/src/actor/ElTableActor.ts +35 -0
- package/src/actor/ElTableColumnActor.ts +72 -0
- package/src/actor/index.ts +20 -0
- package/src/asset/index.ts +17 -0
- package/src/descriptor/ElButtonDescriptor.ts +36 -0
- package/src/descriptor/ElCascaderDescriptor.ts +43 -0
- package/src/descriptor/ElCheckboxDescriptor.ts +41 -0
- package/src/descriptor/ElColDescriptor.ts +20 -0
- package/src/descriptor/ElDatePickerDescriptor.ts +43 -0
- package/src/descriptor/ElDialogDescriptor.ts +24 -0
- package/src/descriptor/ElFormDescriptor.ts +60 -0
- package/src/descriptor/ElFormItemDescriptor.ts +14 -0
- package/src/descriptor/ElInputDescriptor.ts +56 -0
- package/src/descriptor/ElInputNumberDescriptor.ts +38 -0
- package/src/descriptor/ElMenuDescriptor.ts +26 -0
- package/src/descriptor/ElMenuItemDescriptor.ts +22 -0
- package/src/descriptor/ElPaginationDescriptor.ts +52 -0
- package/src/descriptor/ElRadioDescriptor.ts +41 -0
- package/src/descriptor/ElRowDescriptor.ts +22 -0
- package/src/descriptor/ElSelectDescriptor.ts +43 -0
- package/src/descriptor/ElSubMenuDescriptor.ts +20 -0
- package/src/descriptor/ElSwitchDescriptor.ts +35 -0
- package/src/descriptor/ElTableColumnDescriptor.ts +41 -0
- package/src/descriptor/ElTableDescriptor.ts +26 -0
- package/src/descriptor/index.ts +20 -0
- package/src/index.ts +7 -0
- package/src/interpreter/ElButtonInterpreter.ts +18 -0
- package/src/interpreter/ElCascaderInterpreter.ts +18 -0
- package/src/interpreter/ElCheckboxInterpreter.ts +18 -0
- package/src/interpreter/ElColInterpreter.ts +18 -0
- package/src/interpreter/ElDatePickerInterpreter.ts +18 -0
- package/src/interpreter/ElDialogInterpreter.ts +18 -0
- package/src/interpreter/ElFormInterpreter.ts +18 -0
- package/src/interpreter/ElInputInterpreter.ts +18 -0
- package/src/interpreter/ElInputNumberInterpreter.ts +18 -0
- package/src/interpreter/ElMenuInterpreter.ts +18 -0
- package/src/interpreter/ElMenuItemInterpreter.ts +18 -0
- package/src/interpreter/ElPaginationInterpreter.ts +18 -0
- package/src/interpreter/ElRadioInterpreter.ts +18 -0
- package/src/interpreter/ElRowInterpreter.ts +18 -0
- package/src/interpreter/ElSelectInterpreter.ts +18 -0
- package/src/interpreter/ElSubMenuInterpreter.ts +18 -0
- package/src/interpreter/ElSwitchInterpreter.ts +18 -0
- package/src/interpreter/ElTableColumnInterpreter.ts +18 -0
- package/src/interpreter/ElTableInterpreter.ts +18 -0
- package/src/interpreter/index.ts +33 -0
- package/src/locale/Language.ts +10 -0
- package/src/locale/LanguageProvider.ts +64 -0
- package/src/locale/index.ts +2 -0
- package/src/preset/execute/ElDialog/close.ts +48 -0
- package/src/preset/execute/ElDialog/index.ts +2 -0
- package/src/preset/execute/ElDialog/open.ts +51 -0
- package/src/preset/execute/ElForm/branch.ts +47 -0
- package/src/preset/execute/ElForm/create.ts +31 -0
- package/src/preset/execute/ElForm/edit.ts +31 -0
- package/src/preset/execute/ElForm/getData.ts +51 -0
- package/src/preset/execute/ElForm/index.ts +5 -0
- package/src/preset/execute/ElForm/reset.ts +55 -0
- package/src/preset/execute/ElPagination/getData.ts +48 -0
- package/src/preset/execute/ElPagination/index.ts +2 -0
- package/src/preset/execute/ElPagination/reset.ts +46 -0
- package/src/preset/execute/ElTable/create.ts +38 -0
- package/src/preset/execute/ElTable/delete.ts +53 -0
- package/src/preset/execute/ElTable/edit.ts +38 -0
- package/src/preset/execute/ElTable/index.ts +3 -0
- package/src/preset/execute/ElTableColumn/formatter.ts +74 -0
- package/src/preset/execute/ElTableColumn/index.ts +1 -0
- package/src/preset/execute/index.ts +5 -0
- package/src/preset/index.ts +7 -0
- package/src/preset/routine/ElDialog/close.ts +26 -0
- package/src/preset/routine/ElDialog/index.ts +1 -0
- package/src/preset/routine/ElTable/create.ts +31 -0
- package/src/preset/routine/ElTable/delete.ts +31 -0
- package/src/preset/routine/ElTable/edit.ts +33 -0
- package/src/preset/routine/ElTable/index.ts +6 -0
- package/src/preset/routine/ElTable/list.ts +32 -0
- package/src/preset/routine/ElTable/reset.ts +31 -0
- package/src/preset/routine/ElTable/submit.ts +45 -0
- package/src/preset/routine/index.ts +2 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/utils/form.ts +72 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/style.ts +9 -0
- package/src/utils/validator.ts +30 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Asset, Descriptor, Graphics, RoutineNode, Scriptable, UpdateArgs } from "@vyr/engine"
|
|
2
|
+
import { language } from '../../../locale'
|
|
3
|
+
import { ElPaginationDescriptor } from "../../../descriptor"
|
|
4
|
+
|
|
5
|
+
const scriptable = Asset.createVirtualUrl('preset/ElPagination/reset.ts')
|
|
6
|
+
class RoutineScriptable extends Scriptable {
|
|
7
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
8
|
+
//@ts-ignore
|
|
9
|
+
const { input } = args
|
|
10
|
+
const pagination = input?.user?.pagination.value ?? input.default.pagination.value
|
|
11
|
+
|
|
12
|
+
const paginationDescriptor = Descriptor.get<ElPaginationDescriptor>(pagination)
|
|
13
|
+
if (paginationDescriptor instanceof ElPaginationDescriptor) {
|
|
14
|
+
paginationDescriptor.reset(graphics)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
Asset.provider(scriptable, async () => ({ default: RoutineScriptable }))
|
|
19
|
+
|
|
20
|
+
const createExecuteInput = (args: any = {}) => {
|
|
21
|
+
const input = {
|
|
22
|
+
pagination: { value: args.pagination ?? '' },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return input
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
29
|
+
const executeNode: RoutineNode = {
|
|
30
|
+
id: options.id,
|
|
31
|
+
label: language.get(scriptable as any),
|
|
32
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
33
|
+
routine: 'Execute',
|
|
34
|
+
url: scriptable,
|
|
35
|
+
input: createExecuteInput(options.input)
|
|
36
|
+
}
|
|
37
|
+
return executeNode
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
scriptable,
|
|
42
|
+
createExecuteInput,
|
|
43
|
+
createExecuteNode,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Asset, Descriptor, Graphics, RoutineNode, Scriptable, UpdateArgs } from "@vyr/engine"
|
|
2
|
+
import { language } from '../../../locale'
|
|
3
|
+
|
|
4
|
+
const scriptable = Asset.createVirtualUrl('preset/ElTable/create.ts')
|
|
5
|
+
class RoutineScriptable extends Scriptable {
|
|
6
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
7
|
+
//@ts-ignore
|
|
8
|
+
|
|
9
|
+
return {}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
Asset.provider(scriptable, async () => ({ default: RoutineScriptable }))
|
|
13
|
+
|
|
14
|
+
const createExecuteInput = (args: any = {}) => {
|
|
15
|
+
const input = {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return input
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
22
|
+
const executeNode: RoutineNode = {
|
|
23
|
+
id: options.id,
|
|
24
|
+
label: language.get(scriptable as any),
|
|
25
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
26
|
+
routine: 'Execute',
|
|
27
|
+
url: scriptable,
|
|
28
|
+
input: createExecuteInput(options.input)
|
|
29
|
+
}
|
|
30
|
+
return executeNode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
scriptable,
|
|
35
|
+
createExecuteInput,
|
|
36
|
+
createExecuteNode,
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ElMessageBox } from "element-plus"
|
|
2
|
+
import { Asset, Descriptor, Graphics, RoutineNode, Scriptable, UpdateArgs } from "@vyr/engine"
|
|
3
|
+
import { ElTableColumnDescriptor } from "../../../descriptor"
|
|
4
|
+
import { language } from '../../../locale'
|
|
5
|
+
|
|
6
|
+
const scriptable = Asset.createVirtualUrl('preset/ElTable/delete.ts')
|
|
7
|
+
class RoutineScriptable extends Scriptable {
|
|
8
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
const { VYR_STORE, trigger } = args
|
|
11
|
+
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const { parent } = trigger.traceAncestor(false)
|
|
14
|
+
if (parent instanceof ElTableColumnDescriptor) {
|
|
15
|
+
ElMessageBox.confirm(language.get('preset.ElTable.delete.message'), { type: 'warning', title: language.get('preset.ElMessageBox.title'), }).then(() => {
|
|
16
|
+
resolve(VYR_STORE.slot.row)
|
|
17
|
+
}).catch(err => {
|
|
18
|
+
reject(err)
|
|
19
|
+
})
|
|
20
|
+
} else {
|
|
21
|
+
reject()
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
Asset.provider(scriptable, async () => ({ default: RoutineScriptable }))
|
|
27
|
+
|
|
28
|
+
const createExecuteInput = (args: any = {}) => {
|
|
29
|
+
const input = {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return input
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
36
|
+
const executeNode: RoutineNode = {
|
|
37
|
+
id: options.id,
|
|
38
|
+
label: language.get(scriptable as any),
|
|
39
|
+
position: { x: 20, y: 20 },
|
|
40
|
+
routine: 'Execute',
|
|
41
|
+
url: scriptable,
|
|
42
|
+
input: createExecuteInput(options.input)
|
|
43
|
+
}
|
|
44
|
+
return executeNode
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
scriptable,
|
|
49
|
+
createExecuteInput,
|
|
50
|
+
createExecuteNode,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Asset, Descriptor, Graphics, RoutineNode, Scriptable, UpdateArgs } from "@vyr/engine"
|
|
2
|
+
import { language } from '../../../locale'
|
|
3
|
+
|
|
4
|
+
const scriptable = Asset.createVirtualUrl('preset/ElTable/edit.ts')
|
|
5
|
+
class RoutineScriptable extends Scriptable {
|
|
6
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
7
|
+
//@ts-ignore
|
|
8
|
+
const { VYR_STORE } = args
|
|
9
|
+
return VYR_STORE.slot.row
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
Asset.provider(scriptable, async () => ({ default: RoutineScriptable }))
|
|
13
|
+
|
|
14
|
+
const createExecuteInput = (args: any = {}) => {
|
|
15
|
+
const input = {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return input
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
22
|
+
const executeNode: RoutineNode = {
|
|
23
|
+
id: options.id,
|
|
24
|
+
label: language.get(scriptable as any),
|
|
25
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
26
|
+
routine: 'Execute',
|
|
27
|
+
url: scriptable,
|
|
28
|
+
input: createExecuteInput(options.input)
|
|
29
|
+
}
|
|
30
|
+
return executeNode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
scriptable,
|
|
35
|
+
createExecuteInput,
|
|
36
|
+
createExecuteNode,
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Asset, Category, DatasetDescriptor, Descriptor, Graphics, RoutineNode, Scriptable, UpdateArgs } from "@vyr/engine"
|
|
2
|
+
import { language } from '../../../locale'
|
|
3
|
+
import { ElTableColumnDescriptor } from "../../../descriptor"
|
|
4
|
+
|
|
5
|
+
const scriptable = Asset.createVirtualUrl('preset/ElTableColumn/formatter.ts')
|
|
6
|
+
class RoutineScriptable extends Scriptable {
|
|
7
|
+
traverseData = (options: any[], col: ElTableColumnDescriptor, cache: Map<string, any>) => {
|
|
8
|
+
for (const option of options) {
|
|
9
|
+
cache.set(option[col.formattingValue], option[col.formattingLabel])
|
|
10
|
+
if (Array.isArray(option.children)) this.traverseData(option.children, col, cache)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
transformValue = (value: any, col: ElTableColumnDescriptor, cache: Map<string, any>) => {
|
|
15
|
+
if (value === undefined || value === null) return '-'
|
|
16
|
+
|
|
17
|
+
if (typeof value === 'boolean') {
|
|
18
|
+
return value ? '是' : '否'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const labels: string[] = []
|
|
22
|
+
for (const clip of value.split(',')) {
|
|
23
|
+
const label = cache.get(clip)
|
|
24
|
+
if (label) labels.push(label)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return labels.join(col.formattingSeparator)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
const { trigger, input, result } = args
|
|
33
|
+
const dataset = input?.user?.dataset.value
|
|
34
|
+
|
|
35
|
+
const collection = DatasetDescriptor.getCollection(dataset)
|
|
36
|
+
if (collection.length === 0) {
|
|
37
|
+
return null
|
|
38
|
+
} else {
|
|
39
|
+
const cellValue = result.get(input.previous)
|
|
40
|
+
const cache = new Map()
|
|
41
|
+
this.traverseData(collection, trigger, cache)
|
|
42
|
+
|
|
43
|
+
return this.transformValue(cellValue, trigger, cache)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Asset.provider(scriptable, async () => ({ default: RoutineScriptable }))
|
|
48
|
+
|
|
49
|
+
const createExecuteInput = (args: any = {}) => {
|
|
50
|
+
const input = {
|
|
51
|
+
dataset: { value: args.dataset ?? '', type: Category.dataset }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return input
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
58
|
+
const executeNode: RoutineNode = {
|
|
59
|
+
id: options.id,
|
|
60
|
+
label: language.get(scriptable as any),
|
|
61
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
62
|
+
routine: 'Execute',
|
|
63
|
+
url: scriptable,
|
|
64
|
+
input: createExecuteInput(options.input)
|
|
65
|
+
}
|
|
66
|
+
return executeNode
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
scriptable,
|
|
71
|
+
createExecuteInput,
|
|
72
|
+
createExecuteNode,
|
|
73
|
+
}
|
|
74
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as formatter from './formatter'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor } from "@vyr/engine"
|
|
2
|
+
import { ElDialog } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElDialog/close.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
dialog: 'dialog',
|
|
7
|
+
}
|
|
8
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
9
|
+
const routineProvider = async () => {
|
|
10
|
+
if (_currentRoutine === null) {
|
|
11
|
+
_currentRoutine = new RoutineDescriptor()
|
|
12
|
+
const dialogNode = ElDialog.close.createExecuteNode({ id: nodes.dialog })
|
|
13
|
+
_currentRoutine.addNode([dialogNode])
|
|
14
|
+
_currentRoutine.roots.push(dialogNode.id)
|
|
15
|
+
}
|
|
16
|
+
return _currentRoutine
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Asset.provider(url, routineProvider)
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
url,
|
|
23
|
+
nodes,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as close from './close'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor, executePreset } from "@vyr/engine"
|
|
2
|
+
import { ElDialog, ElTable } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElTable/create.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
create: 'create',
|
|
7
|
+
dataset: 'dataset',
|
|
8
|
+
dialog: 'dialog',
|
|
9
|
+
}
|
|
10
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
11
|
+
const routineProvider = async () => {
|
|
12
|
+
if (_currentRoutine === null) {
|
|
13
|
+
_currentRoutine = new RoutineDescriptor()
|
|
14
|
+
const createNode = ElTable.create.createExecuteNode({ id: nodes.create })
|
|
15
|
+
const datasetNode = executePreset.dataset.update.createExecuteNode({ id: nodes.dataset, position: { x: 250, y: 20 } })
|
|
16
|
+
const dialogNode = ElDialog.open.createExecuteNode({ id: nodes.dialog, position: { x: 500, y: 20 } })
|
|
17
|
+
|
|
18
|
+
_currentRoutine.addNode([createNode, datasetNode, dialogNode])
|
|
19
|
+
_currentRoutine.roots.push(createNode.id)
|
|
20
|
+
}
|
|
21
|
+
return _currentRoutine
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Asset.provider(url, routineProvider)
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
url,
|
|
28
|
+
nodes,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor, executePreset } from "@vyr/engine"
|
|
2
|
+
import { ElTable } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElTable/delete.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
delete: 'delete',
|
|
7
|
+
request: 'request',
|
|
8
|
+
refresh: 'refresh',
|
|
9
|
+
}
|
|
10
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
11
|
+
const routineProvider = async () => {
|
|
12
|
+
if (_currentRoutine === null) {
|
|
13
|
+
_currentRoutine = new RoutineDescriptor()
|
|
14
|
+
const deleteNode = ElTable.delete.createExecuteNode({ id: nodes.delete })
|
|
15
|
+
const requestNode = executePreset.net.request.createExecuteNode({ id: nodes.request, position: { x: 250, y: 20 } })
|
|
16
|
+
const refreshNode = executePreset.graphics.invoke.createExecuteNode({ id: nodes.refresh, position: { x: 500, y: 20 } })
|
|
17
|
+
|
|
18
|
+
_currentRoutine.addNode([deleteNode, requestNode, refreshNode])
|
|
19
|
+
_currentRoutine.roots.push(deleteNode.id)
|
|
20
|
+
}
|
|
21
|
+
return _currentRoutine
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Asset.provider(url, routineProvider)
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
url,
|
|
28
|
+
nodes,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor, executePreset } from "@vyr/engine"
|
|
2
|
+
import { ElDialog, ElTable } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElTable/edit.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
edit: 'edit',
|
|
7
|
+
request: 'request',
|
|
8
|
+
dataset: 'dataset',
|
|
9
|
+
dialog: 'dialog',
|
|
10
|
+
}
|
|
11
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
12
|
+
const routineProvider = async () => {
|
|
13
|
+
if (_currentRoutine === null) {
|
|
14
|
+
_currentRoutine = new RoutineDescriptor()
|
|
15
|
+
const editNode = ElTable.edit.createExecuteNode({ id: nodes.edit })
|
|
16
|
+
const requestNode = executePreset.net.request.createExecuteNode({ id: nodes.request, position: { x: 250, y: 20 } })
|
|
17
|
+
const datasetNode = executePreset.dataset.update.createExecuteNode({ id: nodes.dataset, position: { x: 500, y: 20 } })
|
|
18
|
+
const dialogNode = ElDialog.open.createExecuteNode({ id: nodes.dialog, position: { x: 750, y: 20 } })
|
|
19
|
+
|
|
20
|
+
_currentRoutine.addNode([editNode, requestNode, datasetNode, dialogNode])
|
|
21
|
+
_currentRoutine.roots.push(editNode.id)
|
|
22
|
+
}
|
|
23
|
+
return _currentRoutine
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Asset.provider(url, routineProvider)
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
url,
|
|
30
|
+
nodes,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor, executePreset } from "@vyr/engine"
|
|
2
|
+
import { ElForm, ElPagination } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElTable/list.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
form: 'form',
|
|
7
|
+
pagination: 'pagination',
|
|
8
|
+
request: 'request',
|
|
9
|
+
dataset: 'dataset',
|
|
10
|
+
}
|
|
11
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
12
|
+
const routineProvider = async () => {
|
|
13
|
+
if (_currentRoutine === null) {
|
|
14
|
+
_currentRoutine = new RoutineDescriptor()
|
|
15
|
+
const formNode = ElForm.getData.createExecuteNode({ id: nodes.form })
|
|
16
|
+
const paginationNode = ElPagination.getData.createExecuteNode({ id: nodes.pagination, position: { x: 250, y: 20 } })
|
|
17
|
+
const requestNode = executePreset.net.request.createExecuteNode({ id: nodes.request, position: { x: 500, y: 20 } })
|
|
18
|
+
const datasetNode = executePreset.dataset.update.createExecuteNode({ id: nodes.dataset, position: { x: 750, y: 20 } })
|
|
19
|
+
_currentRoutine.addNode([formNode, paginationNode, requestNode, datasetNode])
|
|
20
|
+
_currentRoutine.roots.push(formNode.id)
|
|
21
|
+
}
|
|
22
|
+
return _currentRoutine
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Asset.provider(url, routineProvider)
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
url,
|
|
29
|
+
nodes,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor, executePreset } from "@vyr/engine"
|
|
2
|
+
import { ElPagination, ElForm } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElTable/reset.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
pagination: 'pagination',
|
|
7
|
+
form: 'form',
|
|
8
|
+
refresh: 'refresh',
|
|
9
|
+
}
|
|
10
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
11
|
+
const routineProvider = async () => {
|
|
12
|
+
if (_currentRoutine === null) {
|
|
13
|
+
_currentRoutine = new RoutineDescriptor()
|
|
14
|
+
const formNode = ElForm.reset.createExecuteNode({ id: nodes.form, })
|
|
15
|
+
const paginationNode = ElPagination.reset.createExecuteNode({ id: nodes.pagination, position: { x: 250, y: 20 } })
|
|
16
|
+
const refreshNode = executePreset.graphics.invoke.createExecuteNode({ id: nodes.refresh, position: { x: 500, y: 20 } })
|
|
17
|
+
|
|
18
|
+
_currentRoutine.addNode([formNode, paginationNode, refreshNode])
|
|
19
|
+
_currentRoutine.roots.push(formNode.id)
|
|
20
|
+
}
|
|
21
|
+
return _currentRoutine
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Asset.provider(url, routineProvider)
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
url,
|
|
28
|
+
nodes,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Asset, RoutineDescriptor, executePreset } from "@vyr/engine"
|
|
2
|
+
import { ElDialog, ElForm } from '../../execute'
|
|
3
|
+
|
|
4
|
+
const url = Asset.createVirtualUrl('preset/ElTable/submit.routine.json')
|
|
5
|
+
const nodes = {
|
|
6
|
+
form: 'form',
|
|
7
|
+
branch: 'branch',
|
|
8
|
+
create: 'create',
|
|
9
|
+
edit: 'edit',
|
|
10
|
+
createRequest: 'createRequest',
|
|
11
|
+
editRequest: 'editRequest',
|
|
12
|
+
dialog: 'dialog',
|
|
13
|
+
refresh: 'refresh',
|
|
14
|
+
}
|
|
15
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
16
|
+
const routineProvider = async () => {
|
|
17
|
+
if (_currentRoutine === null) {
|
|
18
|
+
_currentRoutine = new RoutineDescriptor()
|
|
19
|
+
const formNode = ElForm.getData.createExecuteNode({ id: nodes.form })
|
|
20
|
+
const branchNode = ElForm.branch.createExecuteNode({ id: nodes.branch, position: { x: 250, y: 20 } })
|
|
21
|
+
const createNode = ElForm.create.createExecuteNode({ id: nodes.create, position: { x: 500, y: 20 } })
|
|
22
|
+
const editNode = ElForm.edit.createExecuteNode({ id: nodes.edit, position: { x: 500, y: 140 } })
|
|
23
|
+
const createRequestNode = executePreset.net.request.createExecuteNode({ id: nodes.createRequest, position: { x: 750, y: 20 } })
|
|
24
|
+
const editRequestNode = executePreset.net.request.createExecuteNode({ id: nodes.editRequest, position: { x: 750, y: 140 } })
|
|
25
|
+
const dialogNode = ElDialog.close.createExecuteNode({ id: nodes.dialog, position: { x: 1000, y: 20 } })
|
|
26
|
+
const refreshNode = executePreset.graphics.invoke.createExecuteNode({ id: nodes.refresh, position: { x: 1250, y: 20 } })
|
|
27
|
+
_currentRoutine.addNode([formNode, branchNode, createNode, createRequestNode, dialogNode, refreshNode])
|
|
28
|
+
_currentRoutine.addNode([editNode, editRequestNode])
|
|
29
|
+
_currentRoutine.mappers.push(
|
|
30
|
+
{ source: branchNode.id, target: editNode.id },
|
|
31
|
+
{ source: editRequestNode.id, target: dialogNode.id },
|
|
32
|
+
)
|
|
33
|
+
_currentRoutine.roots.push(formNode.id)
|
|
34
|
+
}
|
|
35
|
+
return _currentRoutine
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Asset.provider(url, routineProvider)
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
url,
|
|
42
|
+
nodes,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DatasetDescriptor, Descriptor } from "@vyr/engine"
|
|
2
|
+
import { ElCascaderDescriptor, ElCheckboxDescriptor, ElFormItemDescriptor, ElRadioDescriptor, ElSelectDescriptor, ElSwitchDescriptor } from "../descriptor"
|
|
3
|
+
|
|
4
|
+
interface Option extends ElFormItemDescriptor {
|
|
5
|
+
label: string
|
|
6
|
+
value: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const isOption = (option: ElFormItemDescriptor): option is Option => {
|
|
10
|
+
return [ElCascaderDescriptor.type, ElCheckboxDescriptor.type, ElRadioDescriptor.type, ElSelectDescriptor.type].includes(option.type)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const traverseOptions = (options: any[], col: Option, cache: Map<string, any>) => {
|
|
14
|
+
for (const option of options) {
|
|
15
|
+
cache.set(option[col.value], option[col.label])
|
|
16
|
+
if (Array.isArray(option.children)) traverseOptions(option.children, col, cache)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const useFormUtils = (descriptor: Descriptor) => {
|
|
21
|
+
const items: ElFormItemDescriptor[] = []
|
|
22
|
+
const dataCache = new Map<string, Map<string, any>>()
|
|
23
|
+
|
|
24
|
+
descriptor.traverse(item => {
|
|
25
|
+
if (item instanceof ElFormItemDescriptor) {
|
|
26
|
+
items.push(item)
|
|
27
|
+
if (isOption(item)) {
|
|
28
|
+
const options = DatasetDescriptor.getCollection(item.dataset)
|
|
29
|
+
if (options.length === 0) return
|
|
30
|
+
const cache = new Map()
|
|
31
|
+
traverseOptions(options, item, cache)
|
|
32
|
+
dataCache.set(item.columnName, cache)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const transformValue = (value: any, item: ElFormItemDescriptor) => {
|
|
38
|
+
if (value === undefined || value === null) return '-'
|
|
39
|
+
|
|
40
|
+
if (item.type === ElSwitchDescriptor.type) {
|
|
41
|
+
return value ? '是' : '否'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const cache = dataCache.get(item.columnName)
|
|
45
|
+
if (cache === undefined) return value
|
|
46
|
+
|
|
47
|
+
const labels: string[] = []
|
|
48
|
+
for (const clip of value.split(',')) {
|
|
49
|
+
const label = cache.get(clip)
|
|
50
|
+
if (label) labels.push(label)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if ([ElCascaderDescriptor.type].includes(item.type)) {
|
|
54
|
+
return labels.join('/')
|
|
55
|
+
} else if ([ElSelectDescriptor.type, ElCheckboxDescriptor.type, ElRadioDescriptor.type].includes(item.type)) {
|
|
56
|
+
return labels.join('、')
|
|
57
|
+
} else {
|
|
58
|
+
return labels.join('、')
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
items,
|
|
64
|
+
dataCache,
|
|
65
|
+
transformValue,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
traverseOptions,
|
|
71
|
+
useFormUtils,
|
|
72
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { language } from '../locale'
|
|
2
|
+
import { ElFormItemDescriptor } from "../descriptor"
|
|
3
|
+
import { ElFormItemActor } from "../actor"
|
|
4
|
+
|
|
5
|
+
const requiredValidator = (descriptor: ElFormItemDescriptor, actor: ElFormItemActor) => {
|
|
6
|
+
const validator = (rule: any, value: any, callback: any) => {
|
|
7
|
+
const modelValue = actor.getModelValue()
|
|
8
|
+
if (modelValue === undefined || modelValue === null || modelValue === '' || (Array.isArray(modelValue) && modelValue.length === 0)) {
|
|
9
|
+
callback(new Error(language.get('utils.validator.required', { name: descriptor.columnComment })))
|
|
10
|
+
} else {
|
|
11
|
+
callback()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return validator
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const getValidators = (descriptor: ElFormItemDescriptor, actor: ElFormItemActor) => {
|
|
18
|
+
const rules: { validator: (rule: any, value: any, callback: any) => void }[] = []
|
|
19
|
+
|
|
20
|
+
if (descriptor.visible === false) return rules
|
|
21
|
+
|
|
22
|
+
if (descriptor.required) rules.push({ validator: requiredValidator(descriptor, actor) })
|
|
23
|
+
|
|
24
|
+
return rules
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
requiredValidator,
|
|
29
|
+
getValidators,
|
|
30
|
+
}
|