@yorha2b-lab/autodev 7.7.3 → 7.7.5
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 +1 -1
- package/src/headquarters/observer.js +11 -5
- package/src/workshop/react/blueprint/molds/handleBlock.hbs +1 -0
- package/src/workshop/react/standardParts/DraggableContainer.js +5 -2
- package/src/workshop/react/standardParts/MyModalForm.js +6 -2
- package/src/workshop/react/standardParts/MySearchForm.js +6 -2
- package/src/workshop/react/standardParts/MyTable.js +28 -16
package/package.json
CHANGED
|
@@ -19,9 +19,15 @@ module.exports = bunker => {
|
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
let rebootTimer = null
|
|
23
|
+
const debouncedReboot = file => {
|
|
24
|
+
clearTimeout(rebootTimer)
|
|
25
|
+
rebootTimer = setTimeout(() => {
|
|
26
|
+
if (file.endsWith('config.js')) {
|
|
27
|
+
bunker.reboot()
|
|
28
|
+
}
|
|
29
|
+
}, 300)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
settingObserver.on('change', file => debouncedReboot(file))
|
|
27
33
|
}
|
|
@@ -9,11 +9,14 @@ const arrayMoveImmutable = (array, oldIndex, newIndex) => {
|
|
|
9
9
|
return newArray
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const DraggableContainer = ({ props, setDataSource }) => {
|
|
12
|
+
export const DraggableContainer = ({ props, customSave, setDataSource, dataSourceRef }) => {
|
|
13
13
|
|
|
14
14
|
const onSortEnd = ({ oldIndex, newIndex }) => {
|
|
15
15
|
if (oldIndex !== newIndex) {
|
|
16
|
-
|
|
16
|
+
const currentData = dataSourceRef?.current || []
|
|
17
|
+
const sortedDataSource = arrayMoveImmutable(currentData.slice(), oldIndex, newIndex)
|
|
18
|
+
setDataSource(sortedDataSource)
|
|
19
|
+
customSave?.(sortedDataSource)
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -39,10 +39,14 @@ const flattenFormItems = items => {
|
|
|
39
39
|
* formItems={[{ label: '截止日期', name: 'deadline', type: 'date' }]}
|
|
40
40
|
* />
|
|
41
41
|
*/
|
|
42
|
-
export const MyModalForm = ({ extra, width, title, layout, okText, options, footer, submit, record, visible, setModal, labelCol, modalItems, wrapperCol, cancelText, tableConfig, okButtonProps, onValuesChange, handleModalTableOk }) => {
|
|
42
|
+
export const MyModalForm = ({ extra, width, title, layout, okText, options, footer, submit, record, visible, setModal, labelCol, modalItems, wrapperCol, cancelText, tableConfig, okButtonProps, renderAction, onValuesChange, handleModalTableOk }) => {
|
|
43
43
|
|
|
44
44
|
const rowKey = tableConfig?.rowKey || 'id'
|
|
45
|
-
const formItems = useMemo(() => modalItems.map(item => ({
|
|
45
|
+
const formItems = useMemo(() => modalItems.map(item => ({
|
|
46
|
+
...item,
|
|
47
|
+
...(item.renderAction ? { render: renderAction?.[item.name] } : {}),
|
|
48
|
+
...(['select'].includes(item.type) ? { options: item.options ?? options?.[item.name] ?? [] } : {})
|
|
49
|
+
})), [options, modalItems, renderAction])
|
|
46
50
|
|
|
47
51
|
const [form] = Form.useForm()
|
|
48
52
|
const [pending, setPending] = useState(false)
|
|
@@ -32,11 +32,15 @@ import { SearchOutlined, RedoOutlined } from '@ant-design/icons'
|
|
|
32
32
|
* formItems={[{ label: '状态', name: 'status', type: 'select', options: [...] }]}
|
|
33
33
|
* />
|
|
34
34
|
*/
|
|
35
|
-
export const MySearchForm = ({ form, search, options, loading, labelCol, setSearch, formItems, showLimit = 7, initialValues, initialParams, customReset,
|
|
35
|
+
export const MySearchForm = ({ form, extra, search, options, loading, labelCol, setSearch, formItems, showLimit = 7, initialValues, initialParams, customReset, customFinish, renderAction, onValuesChange, syncUrlParams = true, defaultPageSize = 10 }) => {
|
|
36
36
|
|
|
37
37
|
const [limit, setLimit] = useState(showLimit)
|
|
38
38
|
|
|
39
|
-
const searchItems = useMemo(() => formItems.map(item => ({
|
|
39
|
+
const searchItems = useMemo(() => formItems.map(item => ({
|
|
40
|
+
...item,
|
|
41
|
+
...(item.renderAction ? { render: renderAction?.[item.name] } : {}),
|
|
42
|
+
...(['select'].includes(item.type) ? { options: item.options ?? options?.[item.name] ?? [] } : {})
|
|
43
|
+
})), [options, formItems, renderAction])
|
|
40
44
|
|
|
41
45
|
/**
|
|
42
46
|
* @function handleReset
|
|
@@ -55,15 +55,18 @@ import { useRef, useMemo, useEffect, useCallback } from 'react'
|
|
|
55
55
|
* }}
|
|
56
56
|
* />
|
|
57
57
|
*/
|
|
58
|
-
export const MyTable = ({ size, query, total, search, autoScroll, onChange, pagination, renderAction, rowClassName, customSave, setDataSource, lineFormChange, columns = [], rowSelection, rowKey = 'id', loading = false, dataSource = [], scroll = { x: 'max-content' }, isLocalPaging = false, ...restProps }) => {
|
|
58
|
+
export const MyTable = ({ size, query, total, search, autoScroll, onChange, pagination, renderAction, rowClassName, customSave, setDataSource, lineFormChange, columns = [], rowSelection, rowKey = 'id', loading = false, dataSource = [], draggable = false, scroll = { x: 'max-content' }, isLocalPaging = false, ...restProps }) => {
|
|
59
59
|
|
|
60
60
|
const tableRef = useRef(null)
|
|
61
61
|
const hasScrolledRef = useRef(false)
|
|
62
|
+
const dataSourceRef = useRef(dataSource)
|
|
63
|
+
dataSourceRef.current = dataSource
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* @description [权限侦察] 自动扫描列配置。若存在 editType 型号,则激活“骇入模式(编辑模式)”。
|
|
65
67
|
*/
|
|
66
68
|
const isEditable = useMemo(() => columns.some(col => col.editType), [columns])
|
|
69
|
+
const hasCustomComponents = isEditable || draggable
|
|
67
70
|
|
|
68
71
|
/**
|
|
69
72
|
* @function handleSave
|
|
@@ -73,27 +76,36 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, pagi
|
|
|
73
76
|
* @param {Object} row - 修改后的行片段
|
|
74
77
|
*/
|
|
75
78
|
const handleSave = useCallback((row) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
const prev = dataSourceRef.current
|
|
80
|
+
const index = prev.findIndex(item => row[rowKey] === item[rowKey])
|
|
81
|
+
if (index === -1) return
|
|
82
|
+
const item = prev[index]
|
|
83
|
+
const updatedRow = { ...item, ...row }
|
|
84
|
+
const newData = [...prev]
|
|
85
|
+
newData.splice(index, 1, updatedRow)
|
|
86
|
+
setDataSource(newData)
|
|
87
|
+
customSave?.(updatedRow, newData)
|
|
84
88
|
}, [rowKey, customSave, setDataSource])
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
91
|
* @constant components
|
|
88
92
|
* @description [零部件注册] 注入地堡特有的可编辑 Row 和 Cell 单元。
|
|
89
93
|
*/
|
|
90
|
-
const components = useMemo(() =>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
const components = useMemo(() => {
|
|
95
|
+
if (!hasCustomComponents) return undefined
|
|
96
|
+
const c = { body: {} }
|
|
97
|
+
// 1. 只有有编辑列时,才挂载行内编辑单元
|
|
98
|
+
if (isEditable) {
|
|
99
|
+
c.body.row = EditableRow
|
|
100
|
+
c.body.cell = EditableCell
|
|
101
|
+
}
|
|
102
|
+
// 2. 只有开启了拖拽,才挂载拖拽容器
|
|
103
|
+
if (draggable) {
|
|
104
|
+
c.body.wrapper = props => <DraggableContainer props={props} customSave={customSave} setDataSource={setDataSource} dataSourceRef={dataSourceRef} />
|
|
95
105
|
}
|
|
96
|
-
|
|
106
|
+
return c
|
|
107
|
+
}, [isEditable, draggable, customSave, setDataSource])
|
|
108
|
+
|
|
97
109
|
|
|
98
110
|
/**
|
|
99
111
|
* @constant mergedColumns
|
|
@@ -183,9 +195,9 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, pagi
|
|
|
183
195
|
columns={mergedColumns}
|
|
184
196
|
dataSource={dataSource}
|
|
185
197
|
size={size ?? 'middle'}
|
|
198
|
+
components={components}
|
|
186
199
|
rowSelection={rowSelection}
|
|
187
200
|
pagination={paginationConfig}
|
|
188
|
-
components={isEditable ? components : undefined}
|
|
189
201
|
// 💡 信号注入:将行监听协议绑定至底层 tr
|
|
190
202
|
onRow={(record, index) => ({ record, index, ...(typeof lineFormChange === 'function' ? { onValuesChange: lineFormChange } : {}) })}
|
|
191
203
|
rowClassName={(record, index) => {
|