@kne/form-creator 0.1.30 → 0.1.32
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/README.md +623 -0
- package/dist/index.css +268 -13
- package/dist/index.css.map +1 -1
- package/dist/index.js +548 -76
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +551 -77
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1697,6 +1697,629 @@ render(<SchemaContentExample />);
|
|
|
1697
1697
|
|
|
1698
1698
|
```
|
|
1699
1699
|
|
|
1700
|
+
- 分步问卷填写与答卷展示(全屏)
|
|
1701
|
+
- 贴近业务:steps(focus) + matrixScale 选项矩阵 + list 逐条核对;左侧 SchemaRenderer 填写,右侧 SchemaContent 以矩阵表头/行列展示选中项(不是摊成普通字段列表)
|
|
1702
|
+
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],antd(antd)[import antd from "antd"]
|
|
1703
|
+
|
|
1704
|
+
```jsx
|
|
1705
|
+
const { SchemaRenderer, SchemaContent, createBlock, createField, createStep } = _FormCreator;
|
|
1706
|
+
const { useState } = React;
|
|
1707
|
+
const { Alert, Card, Col, Row, Space, Typography } = antd;
|
|
1708
|
+
const { Text } = Typography;
|
|
1709
|
+
|
|
1710
|
+
/** 贴近经理问卷:分步 + 矩阵量表 + 列表逐条核对;左侧填写,右侧 SchemaContent 展示 */
|
|
1711
|
+
const questionnaireSchema = {
|
|
1712
|
+
actions: {
|
|
1713
|
+
showSubmit: true,
|
|
1714
|
+
showReset: true,
|
|
1715
|
+
submitText: '提交本卷',
|
|
1716
|
+
resetText: '重置'
|
|
1717
|
+
},
|
|
1718
|
+
blocks: [
|
|
1719
|
+
createBlock('steps', {
|
|
1720
|
+
title: '岗位工作盘点',
|
|
1721
|
+
stepsStyle: 'focus',
|
|
1722
|
+
showIndex: true,
|
|
1723
|
+
bordered: true,
|
|
1724
|
+
items: [
|
|
1725
|
+
createStep({
|
|
1726
|
+
title: '开始前:确认基本信息',
|
|
1727
|
+
column: 1,
|
|
1728
|
+
list: [
|
|
1729
|
+
createField({
|
|
1730
|
+
type: 'RadioGroup',
|
|
1731
|
+
name: 'teamSize',
|
|
1732
|
+
label: '您管理的团队目前有多少人直接承担本岗位类工作?',
|
|
1733
|
+
rule: 'REQ',
|
|
1734
|
+
props: {
|
|
1735
|
+
options: [
|
|
1736
|
+
{ label: '5 人以下', value: 'lt5' },
|
|
1737
|
+
{ label: '5–20 人', value: '5to20' },
|
|
1738
|
+
{ label: '20 人以上', value: 'gt20' }
|
|
1739
|
+
]
|
|
1740
|
+
}
|
|
1741
|
+
}),
|
|
1742
|
+
createField({
|
|
1743
|
+
type: 'Input',
|
|
1744
|
+
name: 'workLocation',
|
|
1745
|
+
label: '请写出这些同事的主要工作地点',
|
|
1746
|
+
rule: 'REQ',
|
|
1747
|
+
props: { placeholder: '例如:上海 / 远程' }
|
|
1748
|
+
}),
|
|
1749
|
+
createField({
|
|
1750
|
+
type: 'CheckboxGroup',
|
|
1751
|
+
name: 'aiTools',
|
|
1752
|
+
label: '过去 6 个月,您或团队用过哪些 AI 工具处理工作?(没用的就不用勾)',
|
|
1753
|
+
props: {
|
|
1754
|
+
options: [
|
|
1755
|
+
{ label: '公司配的 AI 助手(Copilot / 企业版 ChatGPT 等)', value: 'company' },
|
|
1756
|
+
{ label: '个人常用的通用大模型', value: 'personal' },
|
|
1757
|
+
{ label: '业务系统内嵌的 AI 能力', value: 'embedded' }
|
|
1758
|
+
]
|
|
1759
|
+
}
|
|
1760
|
+
}),
|
|
1761
|
+
createField({
|
|
1762
|
+
type: 'RadioGroup',
|
|
1763
|
+
name: 'ack',
|
|
1764
|
+
label: '本次作答须知',
|
|
1765
|
+
rule: 'REQ',
|
|
1766
|
+
props: {
|
|
1767
|
+
options: [{ label: '我已了解,同意并开始', value: 'ok' }]
|
|
1768
|
+
}
|
|
1769
|
+
})
|
|
1770
|
+
]
|
|
1771
|
+
}),
|
|
1772
|
+
createStep({
|
|
1773
|
+
title: '先看大块:这块工作还做吗',
|
|
1774
|
+
column: 1,
|
|
1775
|
+
list: [],
|
|
1776
|
+
blocks: [
|
|
1777
|
+
createBlock('matrixScale', {
|
|
1778
|
+
name: 'workBlocks',
|
|
1779
|
+
title: '',
|
|
1780
|
+
rowTitle: '工作块',
|
|
1781
|
+
layout: 'options',
|
|
1782
|
+
fieldType: 'RadioGroup',
|
|
1783
|
+
rule: 'REQ',
|
|
1784
|
+
bordered: false,
|
|
1785
|
+
rows: [
|
|
1786
|
+
{ label: '获客与线索', name: 'leads' },
|
|
1787
|
+
{ label: '转化与成交', name: 'convert' },
|
|
1788
|
+
{ label: '客户成功与续约', name: 'success' },
|
|
1789
|
+
{ label: '团队管理与复盘', name: 'manage' }
|
|
1790
|
+
],
|
|
1791
|
+
options: [
|
|
1792
|
+
{ label: '在做(正常执行)', value: 'doing' },
|
|
1793
|
+
{ label: '很少做', value: 'rare' },
|
|
1794
|
+
{ label: '说不清', value: 'unclear' },
|
|
1795
|
+
{ label: '已不做了', value: 'stopped' }
|
|
1796
|
+
]
|
|
1797
|
+
})
|
|
1798
|
+
]
|
|
1799
|
+
}),
|
|
1800
|
+
createStep({
|
|
1801
|
+
title: '逐条核对:这些任务还在做吗',
|
|
1802
|
+
subtitle: '逐条确认团队的真实工作',
|
|
1803
|
+
column: 1,
|
|
1804
|
+
list: [],
|
|
1805
|
+
blocks: [
|
|
1806
|
+
createBlock('list', {
|
|
1807
|
+
name: 'tasks',
|
|
1808
|
+
title: '',
|
|
1809
|
+
bordered: false,
|
|
1810
|
+
minLength: 1,
|
|
1811
|
+
list: [
|
|
1812
|
+
createField({
|
|
1813
|
+
type: 'RadioGroup',
|
|
1814
|
+
name: 'status',
|
|
1815
|
+
label: '团队现在还做这件事吗?',
|
|
1816
|
+
rule: 'REQ',
|
|
1817
|
+
props: {
|
|
1818
|
+
options: [
|
|
1819
|
+
{ label: '在做(正常执行)', value: 'doing' },
|
|
1820
|
+
{ label: '很少做', value: 'rare' },
|
|
1821
|
+
{ label: '说不清', value: 'unclear' },
|
|
1822
|
+
{ label: '已不做了', value: 'stopped' }
|
|
1823
|
+
]
|
|
1824
|
+
}
|
|
1825
|
+
}),
|
|
1826
|
+
createField({
|
|
1827
|
+
type: 'RadioGroup',
|
|
1828
|
+
name: 'importance',
|
|
1829
|
+
label: '这件事对您团队有多重要?',
|
|
1830
|
+
props: {
|
|
1831
|
+
options: [
|
|
1832
|
+
{ label: '5 关键核心:谈砸了或做错直接影响年度业绩', value: '5' },
|
|
1833
|
+
{ label: '4 重要', value: '4' },
|
|
1834
|
+
{ label: '3 一般', value: '3' },
|
|
1835
|
+
{ label: '2 次要', value: '2' },
|
|
1836
|
+
{ label: '1 可有可无', value: '1' }
|
|
1837
|
+
]
|
|
1838
|
+
},
|
|
1839
|
+
visibleWhen: {
|
|
1840
|
+
logic: 'and',
|
|
1841
|
+
conditions: [{ field: 'status', op: 'in', value: ['doing', 'rare'] }]
|
|
1842
|
+
}
|
|
1843
|
+
}),
|
|
1844
|
+
createField({
|
|
1845
|
+
type: 'TextArea',
|
|
1846
|
+
name: 'reason',
|
|
1847
|
+
label: '用一句话说明为什么这么判断',
|
|
1848
|
+
block: true,
|
|
1849
|
+
props: { rows: 2, placeholder: '请输入' },
|
|
1850
|
+
visibleWhen: {
|
|
1851
|
+
logic: 'and',
|
|
1852
|
+
conditions: [{ field: 'status', op: 'in', value: ['doing', 'rare', 'unclear'] }]
|
|
1853
|
+
}
|
|
1854
|
+
})
|
|
1855
|
+
],
|
|
1856
|
+
itemBlocks: [
|
|
1857
|
+
createBlock('formInfo', {
|
|
1858
|
+
title: '任务名称',
|
|
1859
|
+
bordered: true,
|
|
1860
|
+
column: 1,
|
|
1861
|
+
list: [createField({ type: 'Input', name: 'taskName', label: '任务', rule: 'REQ', props: { placeholder: '例如:设计增长实验' } })]
|
|
1862
|
+
})
|
|
1863
|
+
]
|
|
1864
|
+
})
|
|
1865
|
+
]
|
|
1866
|
+
})
|
|
1867
|
+
]
|
|
1868
|
+
})
|
|
1869
|
+
]
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
const demoAnswers = {
|
|
1873
|
+
teamSize: 'gt20',
|
|
1874
|
+
workLocation: '上海 / 部分远程',
|
|
1875
|
+
aiTools: ['company', 'personal'],
|
|
1876
|
+
ack: 'ok',
|
|
1877
|
+
workBlocks: {
|
|
1878
|
+
leads: 'doing',
|
|
1879
|
+
convert: 'doing',
|
|
1880
|
+
success: 'rare',
|
|
1881
|
+
manage: 'doing'
|
|
1882
|
+
},
|
|
1883
|
+
tasks: [
|
|
1884
|
+
{
|
|
1885
|
+
taskName: '设计增长实验',
|
|
1886
|
+
status: 'doing',
|
|
1887
|
+
importance: '5',
|
|
1888
|
+
reason: '直接决定季度获客质量'
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
taskName: '输出月度增长机会清单',
|
|
1892
|
+
status: 'stopped'
|
|
1893
|
+
}
|
|
1894
|
+
]
|
|
1895
|
+
};
|
|
1896
|
+
|
|
1897
|
+
const QuestionnaireStepsContentExample = () => {
|
|
1898
|
+
const [data, setData] = useState(demoAnswers);
|
|
1899
|
+
|
|
1900
|
+
return (
|
|
1901
|
+
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
|
1902
|
+
<Alert
|
|
1903
|
+
type="info"
|
|
1904
|
+
showIcon
|
|
1905
|
+
message="分步问卷:填写与 SchemaContent 对照"
|
|
1906
|
+
description={
|
|
1907
|
+
<span>
|
|
1908
|
+
覆盖业务常见结构:<Text code>steps</Text>(focus)+ <Text code>matrixScale</Text> 选项矩阵 +{' '}
|
|
1909
|
+
<Text code>list</Text> 逐条核对。左侧可改答并提交,右侧 <Text code>SchemaContent</Text> 按矩阵表头/行列勾选展示,与填写态同构。
|
|
1910
|
+
</span>
|
|
1911
|
+
}
|
|
1912
|
+
/>
|
|
1913
|
+
<Row gutter={[16, 16]}>
|
|
1914
|
+
<Col xs={24} lg={12}>
|
|
1915
|
+
<Card size="small" title="填写(SchemaRenderer)" bordered>
|
|
1916
|
+
<SchemaRenderer
|
|
1917
|
+
schema={questionnaireSchema}
|
|
1918
|
+
formProps={{
|
|
1919
|
+
data: demoAnswers,
|
|
1920
|
+
onSubmit: values => setData(values)
|
|
1921
|
+
}}
|
|
1922
|
+
/>
|
|
1923
|
+
</Card>
|
|
1924
|
+
</Col>
|
|
1925
|
+
<Col xs={24} lg={12}>
|
|
1926
|
+
<Card size="small" title="答卷展示(SchemaContent)" bordered>
|
|
1927
|
+
<SchemaContent schema={questionnaireSchema} data={data} />
|
|
1928
|
+
</Card>
|
|
1929
|
+
</Col>
|
|
1930
|
+
</Row>
|
|
1931
|
+
</Space>
|
|
1932
|
+
);
|
|
1933
|
+
};
|
|
1934
|
+
|
|
1935
|
+
render(<QuestionnaireStepsContentExample />);
|
|
1936
|
+
|
|
1937
|
+
```
|
|
1938
|
+
|
|
1939
|
+
- 多层嵌套答卷展示(全屏)
|
|
1940
|
+
- formInfo→object→formInfo、list→itemBlocks 再套 list、choice→option.blocks→list、steps(focus)→matrix/list;可切换有边框/无边框,左右对照核对丢块、叠卡、非 card 间距与标题层级
|
|
1941
|
+
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],antd(antd)[import antd from "antd"]
|
|
1942
|
+
|
|
1943
|
+
```jsx
|
|
1944
|
+
const { SchemaRenderer, SchemaContent, createBlock, createField, createStep, createChoiceOption } = _FormCreator;
|
|
1945
|
+
const { useMemo, useState } = React;
|
|
1946
|
+
const { Alert, Card, Col, Row, Segmented, Space, Typography } = antd;
|
|
1947
|
+
const { Text } = Typography;
|
|
1948
|
+
|
|
1949
|
+
/**
|
|
1950
|
+
* 多层 block 嵌套:核对 SchemaContent 标题层级、嵌套 Part 拍平、list/choice/object/matrix/steps 组合是否丢块、叠卡。
|
|
1951
|
+
* 大致层级:
|
|
1952
|
+
* formInfo
|
|
1953
|
+
* └ object
|
|
1954
|
+
* └ formInfo
|
|
1955
|
+
* list
|
|
1956
|
+
* └ itemBlocks: object + list
|
|
1957
|
+
* └ itemBlocks: formInfo
|
|
1958
|
+
* choice
|
|
1959
|
+
* └ option.blocks: formInfo → blocks: list
|
|
1960
|
+
* steps(focus)
|
|
1961
|
+
* └ matrixScale
|
|
1962
|
+
* └ list → itemBlocks: formInfo
|
|
1963
|
+
*
|
|
1964
|
+
* 可用顶部 Segmented 切换「有边框 / 无边框」,专门查非 card 模式下的间距与层级。
|
|
1965
|
+
*/
|
|
1966
|
+
const withBordered = (node, bordered) => {
|
|
1967
|
+
if (!node || typeof node !== 'object') {
|
|
1968
|
+
return node;
|
|
1969
|
+
}
|
|
1970
|
+
if (Array.isArray(node)) {
|
|
1971
|
+
return node.map(item => withBordered(item, bordered));
|
|
1972
|
+
}
|
|
1973
|
+
const next = { ...node, bordered };
|
|
1974
|
+
if (Array.isArray(node.blocks)) {
|
|
1975
|
+
next.blocks = withBordered(node.blocks, bordered);
|
|
1976
|
+
}
|
|
1977
|
+
if (Array.isArray(node.itemBlocks)) {
|
|
1978
|
+
next.itemBlocks = withBordered(node.itemBlocks, bordered);
|
|
1979
|
+
}
|
|
1980
|
+
if (Array.isArray(node.items)) {
|
|
1981
|
+
next.items = node.items.map(step => {
|
|
1982
|
+
if (!step || typeof step !== 'object') {
|
|
1983
|
+
return step;
|
|
1984
|
+
}
|
|
1985
|
+
return {
|
|
1986
|
+
...step,
|
|
1987
|
+
blocks: Array.isArray(step.blocks) ? withBordered(step.blocks, bordered) : step.blocks
|
|
1988
|
+
};
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
if (Array.isArray(node.options)) {
|
|
1992
|
+
next.options = node.options.map(option => {
|
|
1993
|
+
if (!option || typeof option !== 'object') {
|
|
1994
|
+
return option;
|
|
1995
|
+
}
|
|
1996
|
+
return {
|
|
1997
|
+
...option,
|
|
1998
|
+
blocks: Array.isArray(option.blocks) ? withBordered(option.blocks, bordered) : option.blocks
|
|
1999
|
+
};
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
return next;
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
const nestedSchemaBase = {
|
|
2006
|
+
actions: {
|
|
2007
|
+
showSubmit: true,
|
|
2008
|
+
showReset: true,
|
|
2009
|
+
submitText: '提交并对照',
|
|
2010
|
+
resetText: '重置'
|
|
2011
|
+
},
|
|
2012
|
+
blocks: [
|
|
2013
|
+
createBlock('formInfo', {
|
|
2014
|
+
title: '项目概况(一级)',
|
|
2015
|
+
subtitle: '外层 formInfo,内嵌 object → formInfo;showIndex 时子模块字段连续编号',
|
|
2016
|
+
column: 2,
|
|
2017
|
+
showIndex: true,
|
|
2018
|
+
list: [
|
|
2019
|
+
createField({ type: 'Input', name: 'projectName', label: '项目名称', rule: 'REQ', props: { placeholder: '例如:增长实验平台' } }),
|
|
2020
|
+
createField({
|
|
2021
|
+
type: 'Select',
|
|
2022
|
+
name: 'priority',
|
|
2023
|
+
label: '优先级',
|
|
2024
|
+
rule: 'REQ',
|
|
2025
|
+
props: {
|
|
2026
|
+
placeholder: '请选择',
|
|
2027
|
+
options: [
|
|
2028
|
+
{ label: 'P0', value: 'p0' },
|
|
2029
|
+
{ label: 'P1', value: 'p1' },
|
|
2030
|
+
{ label: 'P2', value: 'p2' }
|
|
2031
|
+
]
|
|
2032
|
+
}
|
|
2033
|
+
})
|
|
2034
|
+
],
|
|
2035
|
+
blocks: [
|
|
2036
|
+
createBlock('object', {
|
|
2037
|
+
name: 'owner',
|
|
2038
|
+
title: '负责人信息(二级 object)',
|
|
2039
|
+
column: 2,
|
|
2040
|
+
list: [
|
|
2041
|
+
createField({ type: 'Input', name: 'name', label: '姓名', rule: 'REQ', props: { placeholder: '负责人' } }),
|
|
2042
|
+
createField({ type: 'Input', name: 'email', label: '邮箱', rule: 'EMAIL', props: { placeholder: 'name@company.com' } })
|
|
2043
|
+
],
|
|
2044
|
+
blocks: [
|
|
2045
|
+
createBlock('formInfo', {
|
|
2046
|
+
title: '协作备注(三级 formInfo)',
|
|
2047
|
+
column: 1,
|
|
2048
|
+
list: [createField({ type: 'TextArea', name: 'collabNote', label: '协作说明', block: true, props: { rows: 2, placeholder: '跨部门协作注意点' } })]
|
|
2049
|
+
})
|
|
2050
|
+
]
|
|
2051
|
+
})
|
|
2052
|
+
]
|
|
2053
|
+
}),
|
|
2054
|
+
createBlock('list', {
|
|
2055
|
+
title: '交付里程碑(list → itemBlocks)',
|
|
2056
|
+
name: 'milestones',
|
|
2057
|
+
addText: '添加里程碑',
|
|
2058
|
+
minLength: 1,
|
|
2059
|
+
list: [
|
|
2060
|
+
createField({ type: 'Input', name: 'title', label: '里程碑', rule: 'REQ', props: { placeholder: '例如:一期上线' } }),
|
|
2061
|
+
createField({
|
|
2062
|
+
type: 'RadioGroup',
|
|
2063
|
+
name: 'status',
|
|
2064
|
+
label: '状态',
|
|
2065
|
+
rule: 'REQ',
|
|
2066
|
+
props: {
|
|
2067
|
+
options: [
|
|
2068
|
+
{ label: '进行中', value: 'doing' },
|
|
2069
|
+
{ label: '已完成', value: 'done' },
|
|
2070
|
+
{ label: '延期', value: 'delayed' }
|
|
2071
|
+
]
|
|
2072
|
+
}
|
|
2073
|
+
})
|
|
2074
|
+
],
|
|
2075
|
+
itemBlocks: [
|
|
2076
|
+
createBlock('object', {
|
|
2077
|
+
name: 'window',
|
|
2078
|
+
title: '时间窗口(item 内 object)',
|
|
2079
|
+
column: 2,
|
|
2080
|
+
list: [
|
|
2081
|
+
createField({ type: 'Input', name: 'start', label: '开始', props: { placeholder: '2026-01' } }),
|
|
2082
|
+
createField({ type: 'Input', name: 'end', label: '结束', props: { placeholder: '2026-03' } })
|
|
2083
|
+
]
|
|
2084
|
+
}),
|
|
2085
|
+
createBlock('list', {
|
|
2086
|
+
title: '检查项(item 内再套 list)',
|
|
2087
|
+
name: 'checks',
|
|
2088
|
+
addText: '添加检查项',
|
|
2089
|
+
list: [createField({ type: 'Input', name: 'item', label: '检查项', rule: 'REQ', props: { placeholder: '例如:灰度开关' } })],
|
|
2090
|
+
itemBlocks: [
|
|
2091
|
+
createBlock('formInfo', {
|
|
2092
|
+
title: '检查说明(第四层 formInfo)',
|
|
2093
|
+
column: 1,
|
|
2094
|
+
list: [createField({ type: 'TextArea', name: 'detail', label: '说明', block: true, props: { rows: 2, placeholder: '验收标准' } })]
|
|
2095
|
+
})
|
|
2096
|
+
]
|
|
2097
|
+
})
|
|
2098
|
+
]
|
|
2099
|
+
}),
|
|
2100
|
+
createBlock('choice', {
|
|
2101
|
+
title: '交付对象类型(choice → option.blocks)',
|
|
2102
|
+
mode: 'single',
|
|
2103
|
+
selectorName: 'deliveryTarget',
|
|
2104
|
+
selectorInData: true,
|
|
2105
|
+
options: [
|
|
2106
|
+
createChoiceOption({
|
|
2107
|
+
id: 'internal',
|
|
2108
|
+
title: '内部团队',
|
|
2109
|
+
blocks: [
|
|
2110
|
+
createBlock('formInfo', {
|
|
2111
|
+
title: '内部对接',
|
|
2112
|
+
column: 2,
|
|
2113
|
+
list: [
|
|
2114
|
+
createField({ type: 'Input', name: 'teamName', label: '团队', rule: 'REQ', props: { placeholder: '例如:增长研发' } }),
|
|
2115
|
+
createField({ type: 'Input', name: 'slackChannel', label: '频道', props: { placeholder: '#growth' } })
|
|
2116
|
+
],
|
|
2117
|
+
blocks: [
|
|
2118
|
+
createBlock('list', {
|
|
2119
|
+
title: '对接人',
|
|
2120
|
+
name: 'contacts',
|
|
2121
|
+
addText: '添加对接人',
|
|
2122
|
+
list: [
|
|
2123
|
+
createField({ type: 'Input', name: 'contactName', label: '姓名', rule: 'REQ', props: { placeholder: '对接人' } }),
|
|
2124
|
+
createField({ type: 'Input', name: 'role', label: '角色', props: { placeholder: '例如:产品' } })
|
|
2125
|
+
]
|
|
2126
|
+
})
|
|
2127
|
+
]
|
|
2128
|
+
})
|
|
2129
|
+
]
|
|
2130
|
+
}),
|
|
2131
|
+
createChoiceOption({
|
|
2132
|
+
id: 'external',
|
|
2133
|
+
title: '外部客户',
|
|
2134
|
+
blocks: [
|
|
2135
|
+
createBlock('formInfo', {
|
|
2136
|
+
title: '客户信息',
|
|
2137
|
+
column: 2,
|
|
2138
|
+
list: [
|
|
2139
|
+
createField({ type: 'Input', name: 'customerName', label: '客户名', rule: 'REQ', props: { placeholder: '客户名称' } }),
|
|
2140
|
+
createField({ type: 'Input', name: 'contractNo', label: '合同号', props: { placeholder: '合同编号' } })
|
|
2141
|
+
]
|
|
2142
|
+
})
|
|
2143
|
+
]
|
|
2144
|
+
})
|
|
2145
|
+
]
|
|
2146
|
+
}),
|
|
2147
|
+
createBlock('steps', {
|
|
2148
|
+
title: '验收确认',
|
|
2149
|
+
stepsStyle: 'focus',
|
|
2150
|
+
showIndex: true,
|
|
2151
|
+
items: [
|
|
2152
|
+
createStep({
|
|
2153
|
+
title: '能力成熟度矩阵',
|
|
2154
|
+
column: 1,
|
|
2155
|
+
list: [],
|
|
2156
|
+
blocks: [
|
|
2157
|
+
createBlock('matrixScale', {
|
|
2158
|
+
name: 'maturity',
|
|
2159
|
+
title: '',
|
|
2160
|
+
rowTitle: '能力项',
|
|
2161
|
+
layout: 'options',
|
|
2162
|
+
fieldType: 'RadioGroup',
|
|
2163
|
+
rows: [
|
|
2164
|
+
{ label: '需求澄清', name: 'clarify' },
|
|
2165
|
+
{ label: '联调质量', name: 'qa' },
|
|
2166
|
+
{ label: '上线复盘', name: 'retro' }
|
|
2167
|
+
],
|
|
2168
|
+
options: [
|
|
2169
|
+
{ label: '较弱', value: 'low' },
|
|
2170
|
+
{ label: '一般', value: 'mid' },
|
|
2171
|
+
{ label: '较强', value: 'high' }
|
|
2172
|
+
]
|
|
2173
|
+
})
|
|
2174
|
+
]
|
|
2175
|
+
}),
|
|
2176
|
+
createStep({
|
|
2177
|
+
title: '遗留问题清单',
|
|
2178
|
+
subtitle: '可再嵌套一层说明',
|
|
2179
|
+
column: 1,
|
|
2180
|
+
list: [],
|
|
2181
|
+
blocks: [
|
|
2182
|
+
createBlock('list', {
|
|
2183
|
+
name: 'openIssues',
|
|
2184
|
+
title: '',
|
|
2185
|
+
minLength: 1,
|
|
2186
|
+
list: [
|
|
2187
|
+
createField({ type: 'Input', name: 'issue', label: '问题', rule: 'REQ', props: { placeholder: '遗留问题' } }),
|
|
2188
|
+
createField({
|
|
2189
|
+
type: 'RadioGroup',
|
|
2190
|
+
name: 'severity',
|
|
2191
|
+
label: '严重度',
|
|
2192
|
+
props: {
|
|
2193
|
+
options: [
|
|
2194
|
+
{ label: '高', value: 'high' },
|
|
2195
|
+
{ label: '中', value: 'mid' },
|
|
2196
|
+
{ label: '低', value: 'low' }
|
|
2197
|
+
]
|
|
2198
|
+
}
|
|
2199
|
+
})
|
|
2200
|
+
],
|
|
2201
|
+
itemBlocks: [
|
|
2202
|
+
createBlock('formInfo', {
|
|
2203
|
+
title: '跟进计划',
|
|
2204
|
+
column: 1,
|
|
2205
|
+
list: [createField({ type: 'TextArea', name: 'plan', label: '计划', block: true, props: { rows: 2, placeholder: '负责人 / 截止时间' } })]
|
|
2206
|
+
})
|
|
2207
|
+
]
|
|
2208
|
+
})
|
|
2209
|
+
]
|
|
2210
|
+
})
|
|
2211
|
+
]
|
|
2212
|
+
})
|
|
2213
|
+
]
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2216
|
+
const demoAnswers = {
|
|
2217
|
+
projectName: '增长实验平台',
|
|
2218
|
+
priority: 'p0',
|
|
2219
|
+
owner: {
|
|
2220
|
+
name: '张三',
|
|
2221
|
+
email: 'zhangsan@company.com',
|
|
2222
|
+
collabNote: '需与数据组周会同步实验口径'
|
|
2223
|
+
},
|
|
2224
|
+
milestones: [
|
|
2225
|
+
{
|
|
2226
|
+
title: '一期上线',
|
|
2227
|
+
status: 'doing',
|
|
2228
|
+
window: { start: '2026-01', end: '2026-03' },
|
|
2229
|
+
checks: [
|
|
2230
|
+
{
|
|
2231
|
+
item: '灰度开关',
|
|
2232
|
+
detail: '按租户白名单放量,回滚预案已评审'
|
|
2233
|
+
}
|
|
2234
|
+
]
|
|
2235
|
+
},
|
|
2236
|
+
{
|
|
2237
|
+
title: '二期报表',
|
|
2238
|
+
status: 'delayed',
|
|
2239
|
+
window: { start: '2026-04', end: '2026-05' },
|
|
2240
|
+
checks: [{ item: '指标口径', detail: '与 BI 确认留存定义' }]
|
|
2241
|
+
}
|
|
2242
|
+
],
|
|
2243
|
+
deliveryTarget: 'internal',
|
|
2244
|
+
teamName: '增长研发',
|
|
2245
|
+
slackChannel: '#growth',
|
|
2246
|
+
contacts: [
|
|
2247
|
+
{ contactName: '李四', role: '产品' },
|
|
2248
|
+
{ contactName: '王五', role: '后端' }
|
|
2249
|
+
],
|
|
2250
|
+
maturity: {
|
|
2251
|
+
clarify: 'high',
|
|
2252
|
+
qa: 'mid',
|
|
2253
|
+
retro: 'low'
|
|
2254
|
+
},
|
|
2255
|
+
openIssues: [
|
|
2256
|
+
{
|
|
2257
|
+
issue: '移动端矩阵表头在窄屏折行',
|
|
2258
|
+
severity: 'mid',
|
|
2259
|
+
plan: '下周跟进 form-creator SchemaContent 样式'
|
|
2260
|
+
}
|
|
2261
|
+
]
|
|
2262
|
+
};
|
|
2263
|
+
|
|
2264
|
+
const NestedBlocksContentExample = () => {
|
|
2265
|
+
const [data, setData] = useState(demoAnswers);
|
|
2266
|
+
const [cardMode, setCardMode] = useState('plain');
|
|
2267
|
+
const bordered = cardMode === 'card';
|
|
2268
|
+
const nestedSchema = useMemo(() => withBordered(nestedSchemaBase, bordered), [bordered]);
|
|
2269
|
+
|
|
2270
|
+
return (
|
|
2271
|
+
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
|
2272
|
+
<Alert
|
|
2273
|
+
type="info"
|
|
2274
|
+
showIcon
|
|
2275
|
+
message="多层 block 嵌套:填写 ↔ SchemaContent"
|
|
2276
|
+
description={
|
|
2277
|
+
<span>
|
|
2278
|
+
覆盖 <Text code>formInfo→object→formInfo</Text>、<Text code>list→itemBlocks→list→itemBlocks</Text>、
|
|
2279
|
+
<Text code>choice→option.blocks→formInfo→list</Text>、<Text code>steps(focus)→matrixScale / list</Text>
|
|
2280
|
+
。「项目概况」与「验收确认」已开 showIndex:填写与答卷展示应为同一套连续序号(子模块不从 1
|
|
2281
|
+
重起;steps 每步独立)。可用下方开关切换有边框 / 无边框查样式。
|
|
2282
|
+
</span>
|
|
2283
|
+
}
|
|
2284
|
+
/>
|
|
2285
|
+
<Space wrap align="center">
|
|
2286
|
+
<Text type="secondary">模块边框:</Text>
|
|
2287
|
+
<Segmented
|
|
2288
|
+
value={cardMode}
|
|
2289
|
+
onChange={setCardMode}
|
|
2290
|
+
options={[
|
|
2291
|
+
{ label: '无边框(非 card)', value: 'plain' },
|
|
2292
|
+
{ label: '有边框(card)', value: 'card' }
|
|
2293
|
+
]}
|
|
2294
|
+
/>
|
|
2295
|
+
</Space>
|
|
2296
|
+
<Row gutter={[16, 16]}>
|
|
2297
|
+
<Col xs={24} lg={12}>
|
|
2298
|
+
<Card size="small" title={`填写(SchemaRenderer · ${bordered ? '有边框' : '无边框'})`} bordered>
|
|
2299
|
+
<SchemaRenderer
|
|
2300
|
+
key={cardMode}
|
|
2301
|
+
schema={nestedSchema}
|
|
2302
|
+
formProps={{
|
|
2303
|
+
data: demoAnswers,
|
|
2304
|
+
onSubmit: values => setData(values)
|
|
2305
|
+
}}
|
|
2306
|
+
/>
|
|
2307
|
+
</Card>
|
|
2308
|
+
</Col>
|
|
2309
|
+
<Col xs={24} lg={12}>
|
|
2310
|
+
<Card size="small" title={`答卷展示(SchemaContent · ${bordered ? '有边框' : '无边框'})`} bordered>
|
|
2311
|
+
<SchemaContent key={cardMode} schema={nestedSchema} data={data} />
|
|
2312
|
+
</Card>
|
|
2313
|
+
</Col>
|
|
2314
|
+
</Row>
|
|
2315
|
+
</Space>
|
|
2316
|
+
);
|
|
2317
|
+
};
|
|
2318
|
+
|
|
2319
|
+
render(<NestedBlocksContentExample />);
|
|
2320
|
+
|
|
2321
|
+
```
|
|
2322
|
+
|
|
1700
2323
|
- FormInfo 包装为表单字段
|
|
1701
2324
|
- 用 form-info 的 FormModal + useDecorator 把 FormCreator 做成字段;复现外层 Part 嵌套导致模块标题变成二级标签
|
|
1702
2325
|
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],_FormInfo(@kne/form-info)[import * as _FormInfo from "@kne/form-info"],(@kne/form-info/dist/index.css)[import "@kne/form-info/dist/index.css"],antd(antd)[import antd from "antd"]
|