-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.js
145 lines (144 loc) · 3.73 KB
/
data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
export function getMeta() {
return {
name: 'root',
component: 'Layout',
className: 'mk-app-editable-table',
onMouseDown: '{{$mousedown}}',
children: [{
name: 'header',
component: 'Layout',
className: 'mk-app-editable-table-header',
children: [{
name: 'save',
component: 'Button',
type: 'softly',
onClick: '{{$save}}',
children: '保存'
}]
}, {
name: 'table',
component: 'DataGrid',
headerHeight: 50,
rowsCount: '{{data.list.length}}',
rowHeight: 50,
readonly: false,
enableSequence: true,
enableAddDelrow: true,
startSequence: 1,
onAddrow: "{{$addRow('table')}}",
onDelrow: "{{$delRow('table')}}",
onKeyDown: '{{$gridKeydown}}',
scrollToColumn: '{{data.other.tableScrollToColumn}}',
scrollToRow: '{{data.other.tableScrollToRow}}',
columns: [{
name: 'name',
component: 'DataGrid.Column',
columnKey: 'name',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '姓名'
},
cell: {
name: 'cell',
component: "{{$isFocus(_ctrlPath) ? 'Input' : 'DataGrid.TextCell'}}",
className: "{{$getCellClassName(_ctrlPath)}}",
value: "{{data.list[_rowIndex].name}}",
onChange: "{{(e)=>$sf('data.list.' + _rowIndex + '.name', e.target.value)}}",
_power: '({rowIndex})=>rowIndex',
}
}, {
name: 'mobile',
component: 'DataGrid.Column',
columnKey: 'mobile',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '手机'
},
cell: {
name: 'cell',
component: "{{$isFocus(_ctrlPath) ? 'Input.Number' : 'DataGrid.TextCell'}}",
className: "{{$getCellClassName(_ctrlPath)}}",
value: "{{data.list[_rowIndex].mobile}}",
onChange: "{{(v)=>$sf('data.list.' + _rowIndex + '.mobile', v)}}",
_power: '({rowIndex})=>rowIndex',
}
}, {
name: 'birthday',
component: 'DataGrid.Column',
columnKey: 'birthday',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '生日'
},
cell: "{{$cellGetter('birthday')}}",
cell: {
name: 'cell',
component: "{{$isFocus(_ctrlPath) ? 'DatePicker' : 'DataGrid.TextCell'}}",
className: "{{$getCellClassName(_ctrlPath)}}",
value: `{{{
return $isFocus(_ctrlPath)
? $stringToMoment(data.list[_rowIndex].birthday)
: data.list[_rowIndex].birthday
}}}`,
onChange: "{{(v)=>$sf('data.list.' + _rowIndex + '.birthday', $momentToString(v,'YYYY-MM-DD'))}}",
onOpenChange: "{{$dateOpenChange}}",
_power: '({rowIndex})=>rowIndex',
}
}, {
name: 'sex',
component: 'DataGrid.Column',
columnKey: 'sex',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '性别'
},
cell: {
name: 'cell',
component: "{{$isFocus(_ctrlPath) ? 'Select' : 'DataGrid.TextCell'}}",
className: "{{$getCellClassName(_ctrlPath)}}",
showSearch: false,
value: `{{{
if(!data.list[_rowIndex].sex) return undefined
return $isFocus(_ctrlPath)
? data.list[_rowIndex].sex
: (data.list[_rowIndex].sex == 0 ? '男' : '女')
}}}`,
onChange: `{{(v)=>$sf('data.list.'+ _rowIndex + '.sex', v)}}`,
_excludeProps: "{{$isFocus(_ctrlPath)? ['onClick'] : ['children'] }}",
_power: '({rowIndex})=>rowIndex',
children: [{
name: 'man',
component: 'Select.Option',
value: '0',
children: '男'
}, {
name: 'woman',
component: 'Select.Option',
value: '1',
children: '女'
}],
}
}]
}]
}
}
export function getInitState() {
return {
data: {
list: [],
other: {}
}
}
}