@yorha2b-lab/autodev 1.0.18 → 1.0.20

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/bin/autodev.js CHANGED
@@ -3,8 +3,8 @@ const fs = require('fs')
3
3
  const path = require('path')
4
4
  const chalk = require('chalk')
5
5
  const figlet = require('figlet')
6
- const pkg = require('../package.json')
7
6
  const { program } = require('commander')
7
+ const pkg = require(path.join(__dirname, '../package.json'))
8
8
 
9
9
  console.log(chalk.cyan(figlet.textSync('AutoDev', { horizontalLayout: 'full' })))
10
10
  console.log(chalk.gray('Booting System...'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "基于视觉大模型的前端(Umi+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -3,7 +3,7 @@ import { MyBaseForm } from './MyBaseForm'
3
3
  import { useState, useEffect } from 'react'
4
4
  import { Row, Col, Form, Modal, } from 'antd'
5
5
 
6
- export const MyModalForm = ({ width, title, submit, record, visible, setModal, labelCol, formItems, wrapperCol, dateSeparator = ',', onValuesChange }) => {
6
+ export const MyModalForm = ({ width, title, submit, record, visible, setModal, labelCol, formItems, wrapperCol, onValuesChange }) => {
7
7
 
8
8
  const [form] = Form.useForm()
9
9
  const [pending, setPending] = useState(false)
@@ -14,7 +14,7 @@ export const MyModalForm = ({ width, title, submit, record, visible, setModal, l
14
14
  if (record && Object.keys(record).length > 0) {
15
15
  const entries = Object.entries(record).map(([key, value]) => [
16
16
  key,
17
- formItems.find(item => item.name === key)?.type?.includes('date') ? value?.split(dateSeparator)?.map(item => dayjs(item)) : value
17
+ formItems.find(item => item.name === key)?.type?.includes('date') ? (value?.toString()?.includes(',') ? value?.split(',')?.map(item => dayjs(Number(item))) : dayjs(Number(value))) : value
18
18
  ])
19
19
  form.setFieldsValue(Object.fromEntries(entries))
20
20
  }
@@ -4,7 +4,7 @@ import { MyBaseForm } from './MyBaseForm'
4
4
  import { useState, useEffect } from 'react'
5
5
  import { Row, Col, Form, Button, Space } from 'antd'
6
6
 
7
- export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formItems, showLimit = 7, dateSeparator = '\GMT\,', initialValues, customReset, extraOperate, customFinish, onValuesChange, defaultPageSize = 10 }) => {
7
+ export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formItems, showLimit = 7, initialValues, customReset, extraOperate, customFinish, onValuesChange, defaultPageSize = 10 }) => {
8
8
 
9
9
  const [limit, setLimit] = useState(showLimit)
10
10
 
@@ -18,24 +18,36 @@ export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formI
18
18
  }
19
19
 
20
20
  const handleFinish = values => {
21
- const params = new URLSearchParams(Object.fromEntries(Object.entries(values).filter(([key, value]) => !['', null, undefined].includes(value))))
21
+ const formattedValues = { ...values }
22
+ Object.keys(formattedValues).forEach(key => {
23
+ const val = formattedValues[key]
24
+ const isDateType = formItems.find(item => item.name === key)?.type?.includes('date')
25
+ if (isDateType && val) {
26
+ if (Array.isArray(val)) {
27
+ formattedValues[key] = val.map((d, i) => i === 0 ? d.startOf('day').valueOf() : d.endOf('day').valueOf()).join(',')
28
+ } else {
29
+ formattedValues[key] = val.valueOf()
30
+ }
31
+ }
32
+ })
33
+ const params = new URLSearchParams(Object.fromEntries(Object.entries(formattedValues).filter(([key, value]) => !['', null, undefined].includes(value))))
22
34
  history.push({ search: params.toString() })
23
35
  if (customFinish) {
24
- customFinish(values)
36
+ customFinish(formattedValues)
25
37
  } else {
26
- setSearch({ ...search, ...values, pageNo: 1 })
38
+ setSearch({ ...search, ...formattedValues, pageNo: 1 })
27
39
  }
28
40
  }
29
41
 
30
42
  useEffect(() => {
31
- if (Object.values(initialValues).length > 0) {
43
+ if (Object.values(initialValues).length > 0 && formItems.length > 0) {
32
44
  const entries = Object.entries(initialValues).filter(([key]) => formItems.some(item => item.name === key)).map(([key, value]) => [
33
45
  key,
34
- formItems.find(item => item.name === key)?.type?.includes('date') ? value?.split(dateSeparator)?.map(item => dayjs(item)) : value
46
+ formItems.find(item => item.name === key)?.type?.includes('date') ? (value?.toString()?.includes(',') ? value?.split(',')?.map(item => dayjs(Number(item))) : dayjs(Number(value))) : value
35
47
  ])
36
48
  form.setFieldsValue(Object.fromEntries(entries))
37
49
  }
38
- }, [])
50
+ }, [initialValues, form, formItems])
39
51
 
40
52
  return (
41
53
  <Form form={form} onFinish={handleFinish} labelCol={labelCol} onValuesChange={onValuesChange}>