@yorha2b-lab/autodev 7.4.4 → 7.4.6

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": "7.4.4",
3
+ "version": "7.4.6",
4
4
  "description": "基于 AI 视觉与语义协议的前端 (React+Antd) 代码构筑与旧系统重构引擎",
5
5
  "bin": {
6
6
  "bunker": "bin/bunker.js"
@@ -40,7 +40,7 @@ module.exports = {
40
40
  let { tabs = [] } = pageConfig
41
41
  tabs = tabs.map(tab => ({ ...tab, children: `<${tab.key.at(0).toUpperCase()}${tab.key.slice(1)}/>` }))
42
42
 
43
- let { formItems, dictBlocks, processedColumns } = formatPageconfig({ pageConfig })
43
+ let { formItems, processedColumns } = formatPageconfig({ pageConfig })
44
44
  processedColumns = processedColumns.map(col => {
45
45
  delete col.type
46
46
  return col
@@ -51,7 +51,7 @@ module.exports = {
51
51
  let mainConfigStr = cleanCode(contextStringify({ context: result }))
52
52
 
53
53
  let optionsCodeStr = ''
54
- dictBlocks.forEach(key => {
54
+ Object.keys(pageConfig.optionDict ?? {}).forEach(key => {
55
55
  const optionsArray = pageConfig.optionDict?.[key] ?? []
56
56
  const arrayItemsStr = optionsArray.map(opt => ` { label: '${opt.label}', value: '${opt.value}' }`).join(',\n')
57
57
  optionsCodeStr += `\nexport const ${key} = [\n${arrayItemsStr}\n]\n`
@@ -69,7 +69,7 @@ const modalSubmit = async params => {
69
69
  {{this.action}}:()=> {{this.request}},
70
70
  {{/each}}
71
71
  }
72
- const response = await requestMap[modal.type]
72
+ const response = await requestMap[modal.type]?.()
73
73
  if({{{responseSuccess}}}){
74
74
  setModal({ visible: false })
75
75
  refresh()
@@ -1,7 +1,7 @@
1
1
  import dayjs from 'dayjs'
2
2
  import { MyBaseForm } from './MyBaseForm'
3
3
  import { MyModalTable } from './MyModalTable'
4
- import { useMemo, useState, useEffect } from 'react'
4
+ import { useRef, useMemo, useState, useEffect } from 'react'
5
5
  import { Row, Col, Form, Modal, Button, Collapse } from 'antd'
6
6
 
7
7
  const LAYOUT_PROCESSORS = {
@@ -93,6 +93,16 @@ const FormRenderer = ({ form, formItems, tableConfig, setModalTable, setSelected
93
93
  })
94
94
  }
95
95
 
96
+ const flattenFormItems = items => {
97
+ if (!Array.isArray(items)) return []
98
+ return items.flatMap(item => {
99
+ if (item.childItems) {
100
+ return flattenFormItems(item.childItems)
101
+ }
102
+ return item
103
+ })
104
+ }
105
+
96
106
  /**
97
107
  * @component MyModalForm
98
108
  * @description [地堡核心构筑舱] 通用弹窗表单组件。
@@ -127,22 +137,14 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
127
137
  const [modalTable, setModalTable] = useState({})
128
138
  const [selectedTableRows, setSelectedTableRows] = useState([])
129
139
 
130
- const flattenFormItems = items => {
131
- if (!Array.isArray(items)) return []
132
- return items.flatMap(item => {
133
- if (item.childItems) {
134
- return flattenFormItems(item.childItems)
135
- }
136
- return item
137
- })
138
- }
140
+ const prevVisibleRef = useRef(false)
139
141
 
140
142
  /**
141
143
  * @description [数据回显协议] 当构筑舱开启时,自动对初始物资进行“语义格式化”。
142
144
  * 将后端传输的字符串/数字时间戳重新转化为地堡可读的 `dayjs` 对象。
143
145
  */
144
146
  useEffect(() => {
145
- if (visible) {
147
+ if (visible && !prevVisibleRef.current) {
146
148
  form.resetFields()
147
149
  if (record && Object.keys(record).length > 0) {
148
150
  const itemMap = new Map(flattenFormItems(formItems).map(i => [i.name, i]))
@@ -168,6 +170,7 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
168
170
  form.setFieldsValue(initialData)
169
171
  }
170
172
  }
173
+ prevVisibleRef.current = visible
171
174
  }, [visible, record, form, formItems])
172
175
 
173
176
  /**
@@ -203,7 +206,7 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
203
206
  }
204
207
  }
205
208
 
206
- const modalTableOk = () => handleModalTableOk({ form, selectedTableRows, setModalTable })
209
+ const modalTableOk = () => handleModalTableOk?.({ form, selectedTableRows, setModalTable })
207
210
 
208
211
  /**
209
212
  * @function handleCancel
@@ -145,7 +145,7 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, pagi
145
145
  }),
146
146
  ...(typeof pagination === 'object' ? pagination : {})
147
147
  }
148
- }, [total, search, pagination])
148
+ }, [total, search, pagination, isLocalPaging])
149
149
 
150
150
  /**
151
151
  * @description [视觉追踪协议] 当检测到 query.rowIndex 信号时,执行“物理重定向”。