@yorha2b-lab/autodev 7.7.2 → 7.7.4
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 +21 -0
- package/src/workshop/react/standardParts/EditableCell.js +4 -1
- package/src/workshop/react/standardParts/MyForm.js +1 -1
- 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 +18 -45
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
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SortableContainer } from 'react-sortable-hoc'
|
|
2
|
+
|
|
3
|
+
const SortableBody = SortableContainer(props => <tbody {...props} />)
|
|
4
|
+
|
|
5
|
+
const arrayMoveImmutable = (array, oldIndex, newIndex) => {
|
|
6
|
+
const newArray = [...array]
|
|
7
|
+
const [item] = newArray.splice(oldIndex, 1)
|
|
8
|
+
newArray.splice(newIndex, 0, item)
|
|
9
|
+
return newArray
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const DraggableContainer = ({ props, setDataSource }) => {
|
|
13
|
+
|
|
14
|
+
const onSortEnd = ({ oldIndex, newIndex }) => {
|
|
15
|
+
if (oldIndex !== newIndex) {
|
|
16
|
+
setDataSource(prev => arrayMoveImmutable(prev.slice(), oldIndex, newIndex))
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return <SortableBody useDragHandle disableAutoscroll helperClass='row-dragging' onSortEnd={onSortEnd} {...props} />
|
|
21
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SortableElement } from 'react-sortable-hoc'
|
|
1
2
|
import { Form, Input, InputNumber, Select, Checkbox } from 'antd'
|
|
2
3
|
import React, { useRef, useState, useEffect, useContext } from 'react'
|
|
3
4
|
|
|
@@ -7,6 +8,8 @@ import React, { useRef, useState, useEffect, useContext } from 'react'
|
|
|
7
8
|
*/
|
|
8
9
|
const EditableContext = React.createContext(null)
|
|
9
10
|
|
|
11
|
+
const SortableItem = SortableElement((props) => <tr {...props} />)
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* @component EditableRow
|
|
12
15
|
* @description [地堡战术行容器] 每一行都是一个独立的逻辑闭环。
|
|
@@ -33,7 +36,7 @@ export const EditableRow = ({ index, record, ...props }) => {
|
|
|
33
36
|
return (
|
|
34
37
|
<Form form={form} component={false} onValuesChange={(changedValue, allValue) => props?.onValuesChange?.({ changedValue, allValue, form })}>
|
|
35
38
|
<EditableContext.Provider value={form}>
|
|
36
|
-
<
|
|
39
|
+
<SortableItem index={index} {...props} />
|
|
37
40
|
</EditableContext.Provider>
|
|
38
41
|
</Form>
|
|
39
42
|
)
|
|
@@ -88,7 +88,7 @@ export const MyForm = ({ formItems, externalForm, labelCol, wrapperCol, tablePro
|
|
|
88
88
|
const form = externalForm || internalForm
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
|
-
<Form form={form} layout={layout} preserve={false} labelCol={labelCol} wrapperCol={wrapperCol} onValuesChange={onValuesChange}>
|
|
91
|
+
<Form form={form} layout={layout} preserve={false} labelCol={labelCol} wrapperCol={wrapperCol} onValuesChange={onValuesChange} scrollToFirstError={{ behavior: 'smooth', block: 'center' }}>
|
|
92
92
|
<Row gutter={[24, 0]}>
|
|
93
93
|
<FormRenderer form={form} formItems={formItems} tableProps={tableProps} />
|
|
94
94
|
</Row>
|
|
@@ -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
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table } from 'antd'
|
|
2
|
+
import { DraggableContainer } from './DraggableContainer'
|
|
2
3
|
import { EditableRow, EditableCell } from './EditableCell'
|
|
3
4
|
import { useRef, useMemo, useEffect, useCallback } from 'react'
|
|
4
5
|
|
|
@@ -54,12 +55,10 @@ import { useRef, useMemo, useEffect, useCallback } from 'react'
|
|
|
54
55
|
* }}
|
|
55
56
|
* />
|
|
56
57
|
*/
|
|
57
|
-
export const MyTable = ({ size, query, total, search, autoScroll, onChange,
|
|
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
59
|
|
|
59
60
|
const tableRef = useRef(null)
|
|
60
61
|
const hasScrolledRef = useRef(false)
|
|
61
|
-
const dataSourceRef = useRef(dataSource)
|
|
62
|
-
dataSourceRef.current = dataSource
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
64
|
* @description [权限侦察] 自动扫描列配置。若存在 editType 型号,则激活“骇入模式(编辑模式)”。
|
|
@@ -69,18 +68,19 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, setS
|
|
|
69
68
|
/**
|
|
70
69
|
* @function handleSave
|
|
71
70
|
* @description [原子级物理封存] 执行数据更新协议。
|
|
71
|
+
* 采用函数式状态更新(prev => ...)以彻底消除闭航陷阱(Stale Closure),确保数据高频修改时的绝对准确。
|
|
72
|
+
*
|
|
72
73
|
* @param {Object} row - 修改后的行片段
|
|
73
74
|
*/
|
|
74
75
|
const handleSave = useCallback((row) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
customSave?.(updatedRow, newData)
|
|
76
|
+
setDataSource(prev => {
|
|
77
|
+
const newData = [...prev]
|
|
78
|
+
const index = newData.findIndex(item => row[rowKey] === item[rowKey])
|
|
79
|
+
const item = newData[index]
|
|
80
|
+
newData.splice(index, 1, { ...item, ...row })
|
|
81
|
+
customSave?.({ ...item, ...row }, newData)
|
|
82
|
+
return newData
|
|
83
|
+
})
|
|
84
84
|
}, [rowKey, customSave, setDataSource])
|
|
85
85
|
|
|
86
86
|
/**
|
|
@@ -91,8 +91,9 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, setS
|
|
|
91
91
|
body: {
|
|
92
92
|
row: EditableRow,
|
|
93
93
|
cell: EditableCell,
|
|
94
|
+
wrapper: props => <DraggableContainer props={props} setDataSource={setDataSource} />,
|
|
94
95
|
}
|
|
95
|
-
}), [])
|
|
96
|
+
}), [setDataSource])
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* @constant mergedColumns
|
|
@@ -102,37 +103,10 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, setS
|
|
|
102
103
|
const mergedColumns = useMemo(() => {
|
|
103
104
|
return columns.map(col => {
|
|
104
105
|
if (!col.editType) {
|
|
105
|
-
let currentCol = { ...col }
|
|
106
106
|
if (col.renderAction && renderAction?.[col.dataIndex]) {
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
if (col.search) {
|
|
110
|
-
currentCol = {
|
|
111
|
-
...currentCol,
|
|
112
|
-
filterSearch: true,
|
|
113
|
-
onFilter: (value, record) => col.remote ? undefined : col.customFilter({ value, record, dataIndex: col.dataIndex }),
|
|
114
|
-
filterDropdown: ({ close, confirm, selectedKeys, clearFilters, setSelectedKeys }) => (
|
|
115
|
-
<Space direction='vertical' style={{ padding: 12 }}>
|
|
116
|
-
{col.customFilterDropdown({ dataIndex: col.dataIndex, selectedKeys, setSelectedKeys })}
|
|
117
|
-
<div style={{ display: 'flex' }}>
|
|
118
|
-
<a style={{ marginLeft: 'auto', marginRight: 8 }} onClick={() => {
|
|
119
|
-
if (col.remote) {
|
|
120
|
-
setSearch(prev => ({ ...prev, pageNo: 1, [col.dataIndex]: col.formatFilter?.(selectedKeys) ?? selectedKeys?.toString() }))
|
|
121
|
-
}
|
|
122
|
-
confirm()
|
|
123
|
-
}}>确定</a>
|
|
124
|
-
<a onClick={() => {
|
|
125
|
-
if (col.remote) {
|
|
126
|
-
setSearch(prev => ({ ...prev, pageNo: 1, [col.dataIndex]: undefined }))
|
|
127
|
-
}
|
|
128
|
-
clearFilters()
|
|
129
|
-
}}>重置</a>
|
|
130
|
-
</div>
|
|
131
|
-
</Space>
|
|
132
|
-
),
|
|
133
|
-
}
|
|
107
|
+
return { ...col, render: renderAction[col.dataIndex] }
|
|
134
108
|
}
|
|
135
|
-
return
|
|
109
|
+
return col
|
|
136
110
|
}
|
|
137
111
|
return {
|
|
138
112
|
...col,
|
|
@@ -141,7 +115,6 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, setS
|
|
|
141
115
|
handleSave,
|
|
142
116
|
title: col.title,
|
|
143
117
|
rules: col.rules,
|
|
144
|
-
extra: col.extra,
|
|
145
118
|
options: col.options,
|
|
146
119
|
editType: col.editType,
|
|
147
120
|
dataIndex: col.dataIndex,
|
|
@@ -174,7 +147,7 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, setS
|
|
|
174
147
|
}),
|
|
175
148
|
...(typeof pagination === 'object' ? pagination : {})
|
|
176
149
|
}
|
|
177
|
-
}, [total, search, pagination])
|
|
150
|
+
}, [total, search, pagination, isLocalPaging])
|
|
178
151
|
|
|
179
152
|
/**
|
|
180
153
|
* @description [视觉追踪协议] 当检测到 query.rowIndex 信号时,执行“物理重定向”。
|