@yorha2b-lab/autodev 1.0.8 → 1.0.9
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/README.md
CHANGED
package/package.json
CHANGED
|
@@ -37,6 +37,7 @@ const index = ({ fileName, indexTpl, pageConfig }) => {
|
|
|
37
37
|
hasOperate,
|
|
38
38
|
columnsValue,
|
|
39
39
|
tabs: pageConfig.tabs,
|
|
40
|
+
hasExpandable: pageConfig.table.expandable,
|
|
40
41
|
hasPagination: pageConfig.table.pagination,
|
|
41
42
|
operations: pageConfig.table.operation || [],
|
|
42
43
|
hasRowSelection: pageConfig.table.rowSelection,
|
|
@@ -15,6 +15,7 @@ module.exports = `
|
|
|
15
15
|
4.表格:
|
|
16
16
|
{
|
|
17
17
|
pagination: true/false,
|
|
18
|
+
expandable: true/false,
|
|
18
19
|
rowSelection: true/false,
|
|
19
20
|
staticInfo:{has:true/false,text:''},
|
|
20
21
|
operation: [{label:'操作',action:'操作动词+ByRecord'}],
|
|
@@ -28,7 +29,7 @@ module.exports = `
|
|
|
28
29
|
如果是下拉框列(所对应的查询项明确是下拉框),请加入render:_CODE_text=>对应的options.find(item=>item.value===text)?.label_CODE_
|
|
29
30
|
如果列需要过滤请加上filters:[],onFilter: _CODE_(value, record) => record[对应的英文名词].includes(value)_CODE_
|
|
30
31
|
5.功能按钮
|
|
31
|
-
functionButtion:[{btn:'btn',action:'
|
|
32
|
+
functionButtion:[{btn:'btn',action:'操作动词+模块英文名词'}]
|
|
32
33
|
如果和表格行操作重复请在action加上BySelected前缀
|
|
33
34
|
如果是导出功能,对应的动词为export+对应的英文名词,没有名词则为exportData
|
|
34
35
|
6.下拉选项字典
|
|
@@ -49,7 +49,7 @@ export const EditableCell = ({ title, record, editable, children, dataIndex, han
|
|
|
49
49
|
inputNode = <InputNumber ref={inputRef} onPressEnter={save} onBlur={save} />
|
|
50
50
|
break
|
|
51
51
|
case 'select':
|
|
52
|
-
inputNode = <Select ref={inputRef} options={options} onBlur={save}
|
|
52
|
+
inputNode = <Select ref={inputRef} options={options} onBlur={save} />
|
|
53
53
|
break;
|
|
54
54
|
case 'checkbox':
|
|
55
55
|
inputNode = <Checkbox.Group options={options} onChange={save} />
|
|
@@ -8,7 +8,7 @@ const components = {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const MyTable = ({ size, onSave, onChange, pagination, columns = [], rowSelection, rowKey = 'id', loading = false, dataSource = [], editable = false, scroll = { x: 'max-content' }, ...restProps }) => {
|
|
11
|
+
export const MyTable = ({ size, onSave, onChange, pagination, rowClassName, columns = [], rowSelection, rowKey = 'id', loading = false, dataSource = [], editable = false, scroll = { x: 'max-content' }, ...restProps }) => {
|
|
12
12
|
|
|
13
13
|
const mergedColumns = columns.map(col => {
|
|
14
14
|
if (!col.editable) {
|
|
@@ -42,7 +42,7 @@ export const MyTable = ({ size, onSave, onChange, pagination, columns = [], rowS
|
|
|
42
42
|
size={size ?? 'middle'}
|
|
43
43
|
rowSelection={rowSelection}
|
|
44
44
|
components={editable ? components : undefined}
|
|
45
|
-
rowClassName={editable ? () => 'editable-row' :
|
|
45
|
+
rowClassName={editable ? () => 'editable-row' : rowClassName}
|
|
46
46
|
/>
|
|
47
47
|
)
|
|
48
48
|
}
|
|
@@ -5,6 +5,9 @@ export default props => {
|
|
|
5
5
|
{{#if hasTabs}}
|
|
6
6
|
const [activeKey, setActiveKey] = useState(tabs[0].key)
|
|
7
7
|
{{/if}}
|
|
8
|
+
{{#if hasExpandable}}
|
|
9
|
+
const [expandedRowKeys, setExpandedRowKeys] = useState([])
|
|
10
|
+
{{/if}}
|
|
8
11
|
{{#if hasRowSelection}}
|
|
9
12
|
const [selectedRows, setSelectedRows] = useState([])
|
|
10
13
|
{{/if}}
|
|
@@ -48,6 +51,19 @@ export default props => {
|
|
|
48
51
|
}
|
|
49
52
|
{{/if}}
|
|
50
53
|
|
|
54
|
+
{{#if hasExpandable}}
|
|
55
|
+
const onExpand = async (expanded, record) => {
|
|
56
|
+
if (expanded) {
|
|
57
|
+
setExpandedRowKeys([...expandedRowKeys, record.key])
|
|
58
|
+
} else {
|
|
59
|
+
setExpandedRowKeys(expandedRowKeys.filter(item => item !== record.key))
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const expandedRowRender = record => (<div>自定义渲染</div>)
|
|
64
|
+
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
51
67
|
const modalSubmit = async values => {
|
|
52
68
|
const response = await request('/api')
|
|
53
69
|
refresh()
|
|
@@ -94,6 +110,9 @@ export default props => {
|
|
|
94
110
|
loading={loading}
|
|
95
111
|
dataSource={dataSource}
|
|
96
112
|
columns={ {{columnsValue}} }
|
|
113
|
+
{{#if hasExpandable}}
|
|
114
|
+
expandable=\{{ onExpand, expandedRowKeys, expandedRowRender, columnWidth: 24 }}
|
|
115
|
+
{{/if}}
|
|
97
116
|
{{#if hasPagination}}
|
|
98
117
|
pagination=\{{ total, showSizeChanger: true, current: search.pageNo, pageSize: search.pageSize }}
|
|
99
118
|
onChange={(pagination, filters, sorter) => setSearch({ ...search , pageNo: pagination.current, pageSize: pagination.pageSize, orderBy: sorter.column ? sorter.field : undefined })}
|