|
@@ -61,19 +61,31 @@ function AuditForm(props) {
|
|
|
return newItem;
|
|
|
};
|
|
|
|
|
|
- const onChangeAttribute = (newItem) => {
|
|
|
- let oldValue = formList.find((item) => item.props.id === select);
|
|
|
- const newFormList = [];
|
|
|
- for (const item of formList) {
|
|
|
- if (item.props.id === select) {
|
|
|
- item.props = { ...oldValue, newItem };
|
|
|
+ const onChangeAttribute = (newItemProps) => {
|
|
|
+ let oldFormItem = findFormItem();
|
|
|
+ let newFormList = [];
|
|
|
+ // 是列
|
|
|
+ if (oldFormItem.isColumn) {
|
|
|
+ // 找到表格和col然后改掉属性
|
|
|
+ for (const item of formList) {
|
|
|
+ if (item.isTable) {
|
|
|
+ for (const column of item.columns) {
|
|
|
+ if (column.props.id === selectList[selectList.length - 1]) {
|
|
|
+ column.props = { ...column.props, ...newItemProps };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newFormList.push(item);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (const item of formList) {
|
|
|
+ if (item.props.id === select) {
|
|
|
+ item.props = { ...item.props, ...newItemProps };
|
|
|
+ }
|
|
|
+ newFormList.push(item);
|
|
|
}
|
|
|
- newFormList.push(item);
|
|
|
}
|
|
|
handleChangeList(newFormList);
|
|
|
- // let oldValue = formList[select].props;
|
|
|
- // formList[select].props = { ...oldValue, ...newItem };
|
|
|
- // handleChangeList([...formList]);
|
|
|
};
|
|
|
|
|
|
const handleChangeList = (list) => {
|
|
@@ -108,12 +120,10 @@ function AuditForm(props) {
|
|
|
};
|
|
|
|
|
|
const findFormItem = () => {
|
|
|
- console.log();
|
|
|
let formItem = formList.find((item) => item.props.id === selectList[0]);
|
|
|
|
|
|
if (formItem?.isTable) {
|
|
|
// 如果是表格的话,还要寻找内部的被点击的col
|
|
|
-
|
|
|
return (
|
|
|
formItem.columns.find(
|
|
|
(item) => item.props.id === selectList[selectList.length - 1],
|