@yorha2b-lab/autodev 2.1.20 → 2.1.21
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
CHANGED
package/src/utils/utils.js
CHANGED
|
@@ -189,7 +189,7 @@ const generateSmartImports = (codeStr, hasTabs) => {
|
|
|
189
189
|
usedReact.length && `import { ${usedReact.join(', ')} } from 'react'`,
|
|
190
190
|
`import { request } from '../../utils/request'`,
|
|
191
191
|
`import { formatQuery } from '../../utils/utils'`,
|
|
192
|
-
`import { ${hasTabs ? 'tabs, ' : ''}
|
|
192
|
+
`import { ${hasTabs ? 'tabs, ' : ''}formItems, modalItems, tableColumns} from './resource'`,
|
|
193
193
|
...usedHooks.map(hook => `import { ${hook} } from '../../hooks/${hook}'`),
|
|
194
194
|
...usedComps.map(comp => `import { ${comp} } from '../../components/${comp}'`),
|
|
195
195
|
usedAntd.length && `import { Form, ${usedAntd.join(', ')} } from 'antd'`
|
|
@@ -14,7 +14,16 @@
|
|
|
14
14
|
{{/if}}
|
|
15
15
|
{{#if hasPagination}}
|
|
16
16
|
{{{{raw}}}}
|
|
17
|
-
onChange={(pagination, filters, sorter) =>
|
|
17
|
+
onChange={(pagination, filters, sorter) => {
|
|
18
|
+
if (sorter.column) {
|
|
19
|
+
const newSearch = { ...search, pageNo: pagination.current, pageSize: pagination.pageSize, orderBy: sorter.field }
|
|
20
|
+
const params = new URLSearchParams(Object.fromEntries(Object.entries({ ...query, ...newSearch }).filter(([key, value]) => !['', null, undefined].includes(value))))
|
|
21
|
+
window.history.replaceState(null, '', `${window.location.pathname}?${params.toString()}`)
|
|
22
|
+
setSearch(newSearch)
|
|
23
|
+
} else {
|
|
24
|
+
setSearch({ ...search, orderBy: undefined })
|
|
25
|
+
}
|
|
26
|
+
}}
|
|
18
27
|
{{{{/raw}}}}
|
|
19
28
|
{{/if}}
|
|
20
29
|
{{#if hasRowSelection}}
|
|
@@ -5,12 +5,12 @@ const query = formatQuery(Object.fromEntries(new URLSearchParams(location.search
|
|
|
5
5
|
const { total, columns, loading, dataSource, search, setSearch, setDataSource, refresh } = useTableQuery({
|
|
6
6
|
api: async params => await request('/api/{{fileName}}', { method: 'POST', body: params }),
|
|
7
7
|
initialParams: { pageNo: 1, pageSize: 10, ...query },
|
|
8
|
-
cols:
|
|
8
|
+
cols:tableColumns,//前端指定列数组
|
|
9
9
|
formatResponse: response => {
|
|
10
10
|
return {
|
|
11
11
|
data: response?.data ?? [],
|
|
12
12
|
total: response?.data?.total ?? 0,
|
|
13
|
-
columns:
|
|
13
|
+
columns: undefined,//可选,解析接口动态列;优先级高于cols
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
})
|
|
@@ -13,6 +13,6 @@ export const {{this.name}} = {{{stringify this.data 50}}}
|
|
|
13
13
|
export const formItems = {{{stringify formItemsData 150}}}
|
|
14
14
|
{{/if}}
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const tableColumns = {{{stringify columnsData 200}}}
|
|
17
17
|
|
|
18
18
|
export const modalItems = []
|