@yorha2b-lab/autodev 1.0.45 → 1.1.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/example/example.json +46 -50
- package/package.json +1 -1
- package/src/commands/watch-page.js +1 -1
- package/src/core/react-compiler.js +40 -13
- package/src/prompts/react/watch-page.js +6 -2
- package/src/prompts/react/watch-part.js +1 -0
- package/templates/react/components/MyModalTable.js +3 -2
- package/templates/react/handlebars/MySearchForm.hbs +1 -0
- package/templates/react/handlebars/MyTable.hbs +26 -0
- package/templates/react/handlebars/functionButtonsBlock.hbs +16 -0
- package/templates/react/handlebars/handleBlock.hbs +52 -0
- package/templates/react/handlebars/hookBlock.hbs +9 -0
- package/templates/react/handlebars/stateBlock.hbs +11 -0
- package/templates/react/handlebars/tableOperate.hbs +10 -0
- package/templates/react/index.hbs +6 -121
package/example/example.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"tabs": [
|
|
3
3
|
{
|
|
4
4
|
"tab": "鬼剑士",
|
|
5
|
-
"key": "
|
|
5
|
+
"key": "ghostSwordsman"
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"tab": "格斗家",
|
|
@@ -17,35 +17,6 @@
|
|
|
17
17
|
"key": "mage"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
|
-
"formItems": [
|
|
21
|
-
{
|
|
22
|
-
"label": "转职职业",
|
|
23
|
-
"name": "transferJob",
|
|
24
|
-
"type": "select",
|
|
25
|
-
"options": "_CODE_transferJobOptions_CODE_"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"label": "武器类型",
|
|
29
|
-
"name": "weaponType",
|
|
30
|
-
"type": "select",
|
|
31
|
-
"options": "_CODE_weaponTypeOptions_CODE_"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"label": "职业类型",
|
|
35
|
-
"name": "jobType",
|
|
36
|
-
"type": "select",
|
|
37
|
-
"options": "_CODE_jobTypeOptions_CODE_"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"label": "觉醒名称关键词",
|
|
41
|
-
"name": "awakeningNameKeyword"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"label": "登场时间",
|
|
45
|
-
"name": "releaseDateStart,releaseDateEnd",
|
|
46
|
-
"type": "daterange"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
20
|
"table": {
|
|
50
21
|
"pagination": true,
|
|
51
22
|
"expandable": true,
|
|
@@ -71,7 +42,7 @@
|
|
|
71
42
|
"columns": [
|
|
72
43
|
{
|
|
73
44
|
"title": "职业",
|
|
74
|
-
"dataIndex": "
|
|
45
|
+
"dataIndex": "job"
|
|
75
46
|
},
|
|
76
47
|
{
|
|
77
48
|
"title": "一觉",
|
|
@@ -102,17 +73,37 @@
|
|
|
102
73
|
}
|
|
103
74
|
]
|
|
104
75
|
},
|
|
76
|
+
"formItems": [
|
|
77
|
+
{
|
|
78
|
+
"label": "转职职业",
|
|
79
|
+
"name": "transferJob",
|
|
80
|
+
"type": "select",
|
|
81
|
+
"options": "_CODE_transferJobOptions_CODE_"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"label": "武器类型",
|
|
85
|
+
"name": "weaponType",
|
|
86
|
+
"type": "select",
|
|
87
|
+
"options": "_CODE_weaponTypeOptions_CODE_"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"label": "职业类型",
|
|
91
|
+
"name": "jobType",
|
|
92
|
+
"type": "select",
|
|
93
|
+
"options": "_CODE_jobTypeOptions_CODE_"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"label": "觉醒名称关键词",
|
|
97
|
+
"name": "awakeningKeyword"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"label": "登场时间",
|
|
101
|
+
"name": "releaseDateStart,releaseDateEnd",
|
|
102
|
+
"type": "daterange"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
105
|
"optionDict": {
|
|
106
|
-
"_CODE_transferJobOptions_CODE_": [
|
|
107
|
-
{
|
|
108
|
-
"label": "剑魂",
|
|
109
|
-
"value": "swordSoul"
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"label": "狂战士",
|
|
113
|
-
"value": "berserker"
|
|
114
|
-
}
|
|
115
|
-
],
|
|
106
|
+
"_CODE_transferJobOptions_CODE_": [],
|
|
116
107
|
"_CODE_weaponTypeOptions_CODE_": [
|
|
117
108
|
{
|
|
118
109
|
"label": "光剑",
|
|
@@ -134,26 +125,31 @@
|
|
|
134
125
|
},
|
|
135
126
|
{
|
|
136
127
|
"label": "魔法",
|
|
137
|
-
"value": "
|
|
128
|
+
"value": "magical"
|
|
138
129
|
}
|
|
139
130
|
]
|
|
140
131
|
},
|
|
141
132
|
"functionButton": [
|
|
142
133
|
{
|
|
143
|
-
"btn": "
|
|
144
|
-
"action": "
|
|
134
|
+
"btn": "批量删除",
|
|
135
|
+
"action": "batchDeleteBySelected"
|
|
145
136
|
},
|
|
146
137
|
{
|
|
147
|
-
"btn": "
|
|
148
|
-
"action": "
|
|
138
|
+
"btn": "批量导出",
|
|
139
|
+
"action": "exportData"
|
|
149
140
|
},
|
|
150
141
|
{
|
|
151
|
-
"btn": "
|
|
152
|
-
"action": "
|
|
142
|
+
"btn": "查询",
|
|
143
|
+
"action": "search"
|
|
153
144
|
},
|
|
154
145
|
{
|
|
155
|
-
"btn": "
|
|
156
|
-
"action": "
|
|
146
|
+
"btn": "重置",
|
|
147
|
+
"action": "reset"
|
|
157
148
|
}
|
|
149
|
+
],
|
|
150
|
+
"pageStruct": [
|
|
151
|
+
"MySearchForm",
|
|
152
|
+
"FunctionButtonsBlock",
|
|
153
|
+
"MyTable"
|
|
158
154
|
]
|
|
159
155
|
}
|
package/package.json
CHANGED
|
@@ -140,7 +140,7 @@ const watchPage = options => {
|
|
|
140
140
|
`🤖 Pod 042: [Report] Module [${fileName}] assembly complete! Elapsed time: ${(endTime - startTime) / 1000}s`
|
|
141
141
|
)))
|
|
142
142
|
if (fs.existsSync(filePath)) {
|
|
143
|
-
fs.unlinkSync(filePath)
|
|
143
|
+
//fs.unlinkSync(filePath)
|
|
144
144
|
}
|
|
145
145
|
} catch (error) {
|
|
146
146
|
spinner.fail(chalk.red(language(
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
1
3
|
const Handlebars = require('handlebars')
|
|
2
4
|
const stringify = require('json-stringify-pretty-compact')
|
|
3
5
|
const { cleanCode, generateSmartImports } = require('../utils/utils.js')
|
|
4
6
|
|
|
7
|
+
// 注册 Handlebars 辅助函数,用于将原始内容渲染到模板中,不进行任何处理
|
|
8
|
+
Handlebars.registerHelper('raw', options => options.fn())
|
|
5
9
|
// 注册 Handlebars 辅助函数,用于将对象格式化为 JSON 字符串
|
|
6
10
|
Handlebars.registerHelper('stringify', (context, maxLength = 200) => context ? new Handlebars.SafeString(stringify.default(context, { indent: 4, maxLength })) : '[]')
|
|
7
11
|
|
|
@@ -45,7 +49,9 @@ const resource = ({ pageConfig, resourceTpl }) => {
|
|
|
45
49
|
* @returns {string} 生成的 index.js 代码
|
|
46
50
|
*/
|
|
47
51
|
const index = ({ config, fileName, indexTpl, pageConfig }) => {
|
|
52
|
+
|
|
48
53
|
const hasTabs = pageConfig.tabs?.length > 0
|
|
54
|
+
const hasFormItems = pageConfig.formItems?.length > 0
|
|
49
55
|
const hasOperate = pageConfig.table.operation?.length > 0
|
|
50
56
|
|
|
51
57
|
// 动态确定 columns 引用方式:有标签页时使用 activeKey 索引,否则直接使用 columns
|
|
@@ -57,21 +63,42 @@ const index = ({ config, fileName, indexTpl, pageConfig }) => {
|
|
|
57
63
|
|
|
58
64
|
// 构建模板数据
|
|
59
65
|
const viewData = {
|
|
60
|
-
hasTabs,
|
|
61
|
-
fileName,
|
|
62
|
-
hasOperate,
|
|
63
|
-
columnsValue,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
hasTabs,
|
|
67
|
+
fileName,
|
|
68
|
+
hasOperate,
|
|
69
|
+
columnsValue,
|
|
70
|
+
hasFormItems,
|
|
71
|
+
tabs: pageConfig.tabs,
|
|
72
|
+
pageStruct: pageConfig.pageStruct,
|
|
73
|
+
responseSuccess: config.responseSuccess,
|
|
74
|
+
hasExpandable: pageConfig.table.expandable,
|
|
75
|
+
hasPagination: pageConfig.table.pagination,
|
|
76
|
+
operations: pageConfig.table.operation || [],
|
|
77
|
+
hasRowSelection: pageConfig.table.rowSelection,
|
|
78
|
+
hasStaticInfo: pageConfig.table.staticInfo?.has,
|
|
79
|
+
staticInfoText: pageConfig.table.staticInfo?.text,
|
|
80
|
+
formItems: hasTabs ? 'formItems[activeKey]' : 'formItems',
|
|
81
|
+
functionButtons: pageConfig.functionButton?.filter(item => !['查询', '重置'].includes(item.btn)) || []
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (viewData.hasOperate) {
|
|
85
|
+
Handlebars.registerPartial('tableOperate', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/tableOperate.hbs'), 'utf-8')}\n`)
|
|
73
86
|
}
|
|
74
87
|
|
|
88
|
+
if (viewData.hasFormItems) {
|
|
89
|
+
Handlebars.registerPartial('MySearchForm', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/MySearchForm.hbs'), 'utf-8')}\n`)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (viewData.hasStaticInfo) {
|
|
93
|
+
Handlebars.registerPartial('AlertInfo', `{{{{raw}}}}<Alert showIcon title='${pageConfig.table.staticInfo?.text}' type='info' style={{ marginBottom: 16 }} />\n{{{{/raw}}}}`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Handlebars.registerPartial('MyTable', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/MyTable.hbs'), 'utf-8')}\n`)
|
|
97
|
+
Handlebars.registerPartial('hookBlock', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/hookBlock.hbs'), 'utf-8')}\n`)
|
|
98
|
+
Handlebars.registerPartial('stateBlock', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/stateBlock.hbs'), 'utf-8')}\n`)
|
|
99
|
+
Handlebars.registerPartial('handleBlock', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/handleBlock.hbs'), 'utf-8')}\n`)
|
|
100
|
+
Handlebars.registerPartial('FunctionButtonsBlock', `${fs.readFileSync(path.join(__dirname, '../../templates/react/handlebars/functionButtonsBlock.hbs'), 'utf-8')}\n`)
|
|
101
|
+
|
|
75
102
|
// 渲染模板
|
|
76
103
|
const bodyCode = indexTpl(viewData)
|
|
77
104
|
// 生成智能导入语句
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module.exports = `
|
|
2
|
-
|
|
2
|
+
识别图片内容(搜索项,表格列,是否有勾选框,查询下拉选项,统计条等页面组件,并按照从上到下的结构把识别出来的组件按顺序组织成型)
|
|
3
3
|
⚠️⚠️⚠️注意:
|
|
4
4
|
1.变量使用驼峰命名法
|
|
5
5
|
【严禁中文】绝对不允许使用中文作为变量名或函数名
|
|
@@ -35,6 +35,10 @@ module.exports = `
|
|
|
35
35
|
6.下拉选项字典
|
|
36
36
|
optionDict:{_CODE_对应的英文名词Options_CODE_:[]]}
|
|
37
37
|
⚠️⚠️⚠️注意:数组值为对应列展示的内容组成的类似{label:'',value:''}的数组
|
|
38
|
+
7.pageStruct
|
|
39
|
+
从上至下的页面结构组成
|
|
40
|
+
⚠️⚠️⚠️注意:这里只能从AlertInfo,MySearchForm,FunctionButtonsBlock,MyTable中选择,并且只有真的存在才加入,绝对禁止加入其他组件
|
|
41
|
+
⚠️⚠️⚠️另外这里不要加入tabs组件
|
|
38
42
|
最后输出一个JSON对象,不要包含任何Markdown标签,格式如下
|
|
39
|
-
{ tabs: [], table: {}, formItems: [], optionDict: {}, functionButton: []}
|
|
43
|
+
{ tabs: [], table: {}, formItems: [], optionDict: {}, functionButton: [],pageStruct:[]}
|
|
40
44
|
`
|
|
@@ -22,5 +22,6 @@ module.exports = `
|
|
|
22
22
|
⚠️⚠️⚠️注意:
|
|
23
23
|
type:text/date/daterange/radio/checkbox/select/auto/textarea,如果是text可以省略
|
|
24
24
|
如果type是auto/radio/select/checkbox,请加入options:_CODE_对应的英文名词Options_CODE_
|
|
25
|
+
如果表单项末尾有文字描述,请将文字描述放在unit属性中
|
|
25
26
|
** 只输出modalItems就可以,不需要对应的formItems和columns **
|
|
26
27
|
`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Modal } from 'antd'
|
|
2
1
|
import { MyTable } from './MyTable'
|
|
2
|
+
import { Modal, Button } from 'antd'
|
|
3
3
|
import { MySearchForm } from './MySearchForm'
|
|
4
4
|
import { useTableQuery } from '../hooks/useTableQuery'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns, setModal, formItems, rowSelection, formatResponse, extraParams = {} }) => {
|
|
7
|
+
export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns, setModal, formItems, rowSelection, formatResponse, functionButtons, extraParams = {} }) => {
|
|
8
8
|
|
|
9
9
|
const { total, loading, dataSource, search, setSearch } = useTableQuery(api, formatResponse, extraParams)
|
|
10
10
|
|
|
@@ -22,6 +22,7 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
|
|
|
22
22
|
return (
|
|
23
23
|
<Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })}>
|
|
24
24
|
{formItems?.length > 0 && <MySearchForm search={search} formItems={formItems} setSearch={handleSearch} syncUrlParams={false} />}
|
|
25
|
+
{functionButtons?.length > 0 && functionButtons.map(item => <Button key={item.name} type={item.type} onClick={item.onClick}>{item.name}</Button>)}
|
|
25
26
|
<MyTable
|
|
26
27
|
loading={loading}
|
|
27
28
|
columns={columns}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<MySearchForm form={form} search={search} initialValues={query} loading={loading} setSearch={setSearch} formItems={ {{formItems}} } />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<MyTable
|
|
2
|
+
rowKey='id'
|
|
3
|
+
query={query}
|
|
4
|
+
loading={loading}
|
|
5
|
+
dataSource={dataSource}
|
|
6
|
+
columns={ {{columnsValue}} }
|
|
7
|
+
{{#if hasExpandable}}
|
|
8
|
+
{{{{raw}}}}
|
|
9
|
+
expandable={{ onExpand, expandedRowKeys, expandedRowRender, columnWidth: 24 }}
|
|
10
|
+
{{{{/raw}}}}
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if hasPagination}}
|
|
13
|
+
{{{{raw}}}}
|
|
14
|
+
pagination={{ total, showSizeChanger: true, current: search.pageNo, pageSize: search.pageSize }}
|
|
15
|
+
onChange={(pagination, filters, sorter) => setSearch({ ...search , pageNo: pagination.current, pageSize: pagination.pageSize, orderBy: sorter.column ? sorter.field : undefined })}
|
|
16
|
+
{{{{/raw}}}}
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{#if hasRowSelection}}
|
|
19
|
+
{{{{raw}}}}
|
|
20
|
+
rowSelection={{
|
|
21
|
+
selectedRowKeys: selectedRows.map(item => item.id),
|
|
22
|
+
onChange: (keys, rows) => setSelectedRows(rows)
|
|
23
|
+
}}
|
|
24
|
+
{{{{/raw}}}}
|
|
25
|
+
{{/if}}
|
|
26
|
+
/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{{#if hasTabs}}
|
|
2
|
+
{{#each tabs}}
|
|
3
|
+
{activeKey === '{{this.key}}' &&
|
|
4
|
+
<Space style=\{{ marginBottom: 16 }}>
|
|
5
|
+
{{#each ../functionButtons}}
|
|
6
|
+
<Button type='primary' onClick={ {{this.action}} }>{{this.btn}}</Button>
|
|
7
|
+
{{/each}}
|
|
8
|
+
</Space>}
|
|
9
|
+
{{/each}}
|
|
10
|
+
{{else}}
|
|
11
|
+
<Space style=\{{ marginBottom: 16 }}>
|
|
12
|
+
{{#each functionButtons}}
|
|
13
|
+
<Button type='primary' onClick={ {{this.action}} }>{{this.btn}}</Button>
|
|
14
|
+
{{/each}}
|
|
15
|
+
</Space>
|
|
16
|
+
{{/if}}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{{#each operations}}
|
|
2
|
+
const {{this.action}} = async record => {
|
|
3
|
+
const response = await request('/api')
|
|
4
|
+
if({{{../responseSuccess}}}){
|
|
5
|
+
refresh()
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
{{/each}}
|
|
10
|
+
|
|
11
|
+
{{#each functionButtons}}
|
|
12
|
+
const {{this.action}} = () => {
|
|
13
|
+
Modal.confirm({
|
|
14
|
+
title: '确认',
|
|
15
|
+
centered: true,
|
|
16
|
+
content: '确认{{this.btn}}吗?',
|
|
17
|
+
onOk: async () => {
|
|
18
|
+
const response = await request('/api')
|
|
19
|
+
if({{{../responseSuccess}}}){
|
|
20
|
+
refresh()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
{{/each}}
|
|
27
|
+
|
|
28
|
+
{{#if hasTabs}}
|
|
29
|
+
const onTabChange = key => {
|
|
30
|
+
setActiveKey(key)
|
|
31
|
+
{{#if hasRowSelection}}setSelectedRows([]){{/if}}
|
|
32
|
+
setSearch({ pageNo: 1, pageSize: 10, type: key })
|
|
33
|
+
}
|
|
34
|
+
{{/if}}
|
|
35
|
+
|
|
36
|
+
{{#if hasExpandable}}
|
|
37
|
+
const onExpand = async (expanded, record) => {
|
|
38
|
+
if (expanded) {
|
|
39
|
+
setExpandedRowKeys([...expandedRowKeys, record.key])
|
|
40
|
+
} else {
|
|
41
|
+
setExpandedRowKeys(expandedRowKeys.filter(item => item !== record.key))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const expandedRowRender = record => (<div>自定义渲染</div>)
|
|
46
|
+
|
|
47
|
+
{{/if}}
|
|
48
|
+
|
|
49
|
+
const modalSubmit = async values => {
|
|
50
|
+
const response = await request('/api')
|
|
51
|
+
refresh()
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const initParams = {{#if hasTabs}}{ type: tabs[0].key }{{else}}{}{{/if}}
|
|
2
|
+
|
|
3
|
+
const query = formatQuery(Object.fromEntries(new URLSearchParams(location.search).entries()), {{formItems}})
|
|
4
|
+
|
|
5
|
+
const { total, loading, dataSource, search, setSearch, refresh } = useTableQuery(
|
|
6
|
+
async params => await request('/api/{{fileName}}', { method: 'POST', body: params }),
|
|
7
|
+
response => ({ data: response?.data ?? [], total: response?.total ?? 0 }),
|
|
8
|
+
{...initParams, ...query},
|
|
9
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const [form] = Form.useForm()
|
|
2
|
+
const [modal, setModal] = useState({})
|
|
3
|
+
{{#if hasRowSelection}}
|
|
4
|
+
const [selectedRows, setSelectedRows] = useState([])
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if hasTabs}}
|
|
7
|
+
const [activeKey, setActiveKey] = useState(tabs[0].key)
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if hasExpandable}}
|
|
10
|
+
const [expandedRowKeys, setExpandedRowKeys] = useState([])
|
|
11
|
+
{{/if}}
|
|
@@ -1,91 +1,13 @@
|
|
|
1
1
|
export default props => {
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const [modal, setModal] = useState({})
|
|
5
|
-
{{#if hasTabs}}
|
|
6
|
-
const [activeKey, setActiveKey] = useState(tabs[0].key)
|
|
7
|
-
{{/if}}
|
|
8
|
-
{{#if hasExpandable}}
|
|
9
|
-
const [expandedRowKeys, setExpandedRowKeys] = useState([])
|
|
10
|
-
{{/if}}
|
|
11
|
-
{{#if hasRowSelection}}
|
|
12
|
-
const [selectedRows, setSelectedRows] = useState([])
|
|
13
|
-
{{/if}}
|
|
14
|
-
|
|
15
|
-
const initParams = {{#if hasTabs}}{ type: tabs[0].key }{{else}}{}{{/if}}
|
|
16
|
-
|
|
17
|
-
const query = formatQuery(Object.fromEntries(new URLSearchParams(location.search).entries()), {{#if hasTabs}}formItems[activeKey]{{else}}formItems{{/if}})
|
|
18
|
-
|
|
19
|
-
const { total, loading, dataSource, search, setSearch, refresh } = useTableQuery(
|
|
20
|
-
async params => await request('/api/{{fileName}}', { method: 'POST', body: params }),
|
|
21
|
-
response => ({ data: response?.data ?? [], total: response?.total ?? 0 }),
|
|
22
|
-
{...initParams, ...query},
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
{{#each operations}}
|
|
26
|
-
const {{this.action}} = async record => {
|
|
27
|
-
const response = await request('/api')
|
|
28
|
-
if({{{../responseSuccess}}}){
|
|
29
|
-
refresh()
|
|
30
|
-
}
|
|
31
|
-
}
|
|
3
|
+
{{> stateBlock }}
|
|
32
4
|
|
|
33
|
-
{{
|
|
34
|
-
|
|
35
|
-
{{#each functionButtons}}
|
|
36
|
-
const {{this.action}} = () => {
|
|
37
|
-
Modal.confirm({
|
|
38
|
-
title: '确认',
|
|
39
|
-
centered: true,
|
|
40
|
-
content: '确认{{this.btn}}吗?',
|
|
41
|
-
onOk: async () => {
|
|
42
|
-
const response = await request('/api')
|
|
43
|
-
if({{{../responseSuccess}}}){
|
|
44
|
-
refresh()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
{{/each}}
|
|
51
|
-
|
|
52
|
-
{{#if hasTabs}}
|
|
53
|
-
const onTabChange = key => {
|
|
54
|
-
setActiveKey(key)
|
|
55
|
-
{{#if hasRowSelection}}setSelectedRows([]){{/if}}
|
|
56
|
-
setSearch({ pageNo: 1, pageSize: 10, type: key })
|
|
57
|
-
}
|
|
58
|
-
{{/if}}
|
|
59
|
-
|
|
60
|
-
{{#if hasExpandable}}
|
|
61
|
-
const onExpand = async (expanded, record) => {
|
|
62
|
-
if (expanded) {
|
|
63
|
-
setExpandedRowKeys([...expandedRowKeys, record.key])
|
|
64
|
-
} else {
|
|
65
|
-
setExpandedRowKeys(expandedRowKeys.filter(item => item !== record.key))
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const expandedRowRender = record => (<div>自定义渲染</div>)
|
|
70
|
-
|
|
71
|
-
{{/if}}
|
|
5
|
+
{{> hookBlock }}
|
|
72
6
|
|
|
73
|
-
|
|
74
|
-
const response = await request('/api')
|
|
75
|
-
refresh()
|
|
76
|
-
}
|
|
7
|
+
{{> handleBlock }}
|
|
77
8
|
|
|
78
9
|
{{#if hasOperate}}
|
|
79
|
-
|
|
80
|
-
title: '操作',
|
|
81
|
-
render: (_, record) => (
|
|
82
|
-
<Space>
|
|
83
|
-
{{#each operations}}
|
|
84
|
-
<a onClick={()=> {{this.action}}(record)}>{{this.label}}</a>
|
|
85
|
-
{{/each}}
|
|
86
|
-
</Space>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
10
|
+
{{> tableOperate }}
|
|
89
11
|
{{/if}}
|
|
90
12
|
|
|
91
13
|
{{#if hasTabs}}
|
|
@@ -100,46 +22,9 @@ export default props => {
|
|
|
100
22
|
return (
|
|
101
23
|
<Card {{#if hasTabs}}tabList={tabs} activeTabKey={activeKey} onTabChange={onTabChange}{{/if}}>
|
|
102
24
|
{modal.visible && <MyModalForm {...modal} formItems={modalItems} submit={modalSubmit} setModal={setModal} />}
|
|
103
|
-
|
|
104
|
-
{{
|
|
105
|
-
{{#each tabs}}
|
|
106
|
-
{activeKey === '{{this.key}}' &&
|
|
107
|
-
<Space style=\{{ marginBottom: 16 }}>
|
|
108
|
-
{{#each ../functionButtons}}
|
|
109
|
-
<Button type='primary' onClick={ {{this.action}} }>{{this.btn}}</Button>
|
|
110
|
-
{{/each}}
|
|
111
|
-
</Space>}
|
|
25
|
+
{{#each pageStruct as |partialName|}}
|
|
26
|
+
{{> (partialName) @root }}
|
|
112
27
|
{{/each}}
|
|
113
|
-
{{else}}
|
|
114
|
-
<Space style=\{{ marginBottom: 16 }}>
|
|
115
|
-
{{#each functionButtons}}
|
|
116
|
-
<Button type='primary' onClick={ {{this.action}} }>{{this.btn}}</Button>
|
|
117
|
-
{{/each}}
|
|
118
|
-
</Space>
|
|
119
|
-
{{/if}}
|
|
120
|
-
{{#if hasStaticInfo}}
|
|
121
|
-
<Alert showIcon title='{{staticInfoText}}' type='info' style=\{{ marginBottom: 16 }} />
|
|
122
|
-
{{/if}}
|
|
123
|
-
<MyTable
|
|
124
|
-
rowKey='id'
|
|
125
|
-
query={query}
|
|
126
|
-
loading={loading}
|
|
127
|
-
dataSource={dataSource}
|
|
128
|
-
columns={ {{columnsValue}} }
|
|
129
|
-
{{#if hasExpandable}}
|
|
130
|
-
expandable=\{{ onExpand, expandedRowKeys, expandedRowRender, columnWidth: 24 }}
|
|
131
|
-
{{/if}}
|
|
132
|
-
{{#if hasPagination}}
|
|
133
|
-
pagination=\{{ total, showSizeChanger: true, current: search.pageNo, pageSize: search.pageSize }}
|
|
134
|
-
onChange={(pagination, filters, sorter) => setSearch({ ...search , pageNo: pagination.current, pageSize: pagination.pageSize, orderBy: sorter.column ? sorter.field : undefined })}
|
|
135
|
-
{{/if}}
|
|
136
|
-
{{#if hasRowSelection}}
|
|
137
|
-
rowSelection=\{{
|
|
138
|
-
selectedRowKeys: selectedRows.map(item => item.id),
|
|
139
|
-
onChange: (keys, rows) => setSelectedRows(rows)
|
|
140
|
-
}}
|
|
141
|
-
{{/if}}
|
|
142
|
-
/>
|
|
143
28
|
</Card>
|
|
144
29
|
)
|
|
145
30
|
}
|