@yorha2b-lab/autodev 2.1.21 → 2.1.22

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "2.1.21",
3
+ "version": "2.1.22",
4
4
  "description": "基于视觉大模型的前端(react+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -5,11 +5,11 @@ import { MySearchForm } from './MySearchForm'
5
5
  import { useTableQuery } from '../hooks/useTableQuery'
6
6
 
7
7
 
8
- export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns, operate, setModal, formItems, setModalForm, rowSelection, formatResponse, functionButtons, extraParams = {}, modalPagination = true }) => {
8
+ export const MyModalTable = ({ api, onOk, title, width, footer, visible, operate, setModal, formItems, setModalForm, rowSelection, formatResponse, functionButtons, columns: modalColumns, initialParams = {}, modalPagination = true }) => {
9
9
 
10
10
  const [pending, setPending] = useState(false)
11
11
 
12
- const { total, loading, dataSource, search, refresh, setSearch, setDataSource } = useTableQuery(api, formatResponse, extraParams)
12
+ const { total, loading, columns, dataSource, search, refresh, setLoading, setSearch, setDataSource } = useTableQuery({ api, cols: modalColumns, initialParams, formatResponse })
13
13
 
14
14
  const handleSearch = values => setSearch({ ...search, ...values, pageNo: 1 })
15
15
 
@@ -20,7 +20,6 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
20
20
  try {
21
21
  setPending(true)
22
22
  await onOk()
23
- setPending(false)
24
23
  } catch (error) {
25
24
  console.log('操作失败:', error)
26
25
  } finally {
@@ -32,7 +31,7 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
32
31
  return (
33
32
  <Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })} confirmLoading={pending}>
34
33
  {formItems?.length > 0 && <MySearchForm search={search} formItems={formItems} setSearch={handleSearch} syncUrlParams={false} />}
35
- {functionButtons?.length > 0 && <Space>{functionButtons.map(item => <Button key={item.name} type={item.type} onClick={item.onClick}>{item.name}</Button>)}</Space>}
34
+ {functionButtons?.length > 0 && <Space>{functionButtons.map(item => <Button key={item.name} type={item.type} onClick={() => item.onClick({ refresh, setLoading, setSearch, setDataSource })}>{item.name}</Button>)}</Space>}
36
35
  <MyTable
37
36
  total={total}
38
37
  search={search}
@@ -101,7 +101,7 @@ export const formNode = ({ item }) => {
101
101
  case 'upload':
102
102
  return <Upload {...item.uploadProps} {...commonProps}>{item.content ?? '上传文件'}</Upload>
103
103
  case 'select':
104
- return <Select allowClear showSearch mode={item.mode} options={item.options} {...commonProps} />
104
+ return <Select allowClear showSearch mode={item.mode} options={item.options} optionFilterProp='label' {...commonProps} />
105
105
  default:
106
106
  return <Input allowClear {...commonProps} />
107
107
  }
@@ -21,7 +21,7 @@
21
21
  window.history.replaceState(null, '', `${window.location.pathname}?${params.toString()}`)
22
22
  setSearch(newSearch)
23
23
  } else {
24
- setSearch({ ...search, orderBy: undefined })
24
+ setSearch({ ...search,pageNo: pagination.current, pageSize: pagination.pageSize, orderBy: undefined })
25
25
  }
26
26
  }}
27
27
  {{{{/raw}}}}
@@ -1,6 +1,6 @@
1
1
  import { useRef, useState, useEffect, useCallback } from 'react'
2
2
 
3
- export const useTableQuery = ({ api, cols = [], initialParams = {}, formatResponse }) => {
3
+ export const useTableQuery = ({ api, cols, initialParams = {}, formatResponse }) => {
4
4
 
5
5
  const [total, setTotal] = useState(0)
6
6
  const [columns, setColumns] = useState(cols)