提交 a24b229e authored 作者: 钟是志's avatar 钟是志

FormList组件修改

上级 9fa780bd
......@@ -116,7 +116,6 @@ function ActiveMenuComponent({ routerConfig, ...otherProps }) {
default:
break;
}
console.log('112233');
return (
<CreateC.Provider
value={{
......
......@@ -68,9 +68,9 @@ export default class TableList extends React.Component {
}
render() {
const { isTree, json, uuid } = this.props;
const { isTree, json, uuid, obj } = this.props;
const { showNo } = this.state;
// console.log(showNo);
// console.log(obj);
if (showNo) {
return null;
}
......@@ -91,6 +91,7 @@ export default class TableList extends React.Component {
objCode={this.props.objCode}
isFormCom={true}
uuid={uuid}
obj={obj}
sql={this.props.sql}
/>
) : (
......@@ -108,6 +109,7 @@ export default class TableList extends React.Component {
notShowBack={true}
rights={this.props.rights || []}
objCode={this.props.objCode}
obj={obj}
isFormCom={true}
uuid={uuid}
sql={this.props.sql}
......
import React, { useEffect, useState } from 'react';
import { Button } from 'antd';
export default function SplitButton(props) {
const [stateProps, setProps] = useState({ ...props });
// useEffect(() => {
// setProps({
// ...stateProps,
// onClick: props.onClick && typeof props.onClick === 'function' && props.onClick.bind(this, props.selectedRows, props.obj),
// });
// }, [props.selectedRows, props.obj]);
useEffect(() => {
if(props.changeButtonProps && typeof props.changeButtonProps === 'function'){
props.changeButtonProps({
selectedRows: props.selectedRows,
setProps,
stateProps,
});
}
}, [props.selectedRows]);
const handleClick = (e) => {
if(props.onClick && typeof props.onClick === 'function'){
props.onClick(e, props.selectedRows, props.obj);
}
};
return <Button {...stateProps} onClick={handleClick}/>;
}
......@@ -3,6 +3,7 @@ import { Button } from 'antd';
import ImportUtil from '@/webPublic/one_stop_public/App/ImportUtil';
import ExportCurrentInfo from '@/webPublic/one_stop_public/App/ExportCurrentInfo';
import { Base16Encode } from '@/webPublic/one_stop_public/Base16';
import SplitButton from '@/webPublic/one_stop_public/libs/formList/SplitButton';
export function FormListButtons(props) {
const [ConcatButtons, setConCatButtons] = useState([]);
......@@ -15,10 +16,13 @@ export function FormListButtons(props) {
query,
custom,
sql,
exportConfig
exportConfig,
selectedRows,
obj,
} = props;
const Before = btns && btns.before || [];
useEffect(() => {
const Before = (btns && btns.before) || [];
useEffect(
() => {
let buttons = [];
buttons = Before.map((g) => {
g.ButtonType = 'Normal';
......@@ -44,7 +48,10 @@ export function FormListButtons(props) {
return priorityA - priorityB;
});
setConCatButtons(buttons);
}, [exportConfig, importConfig, btns]);
},
[exportConfig, importConfig, btns],
);
if (!ConcatButtons || !ConcatButtons.length) {
return null;
}
......@@ -53,12 +60,12 @@ export function FormListButtons(props) {
if (r.ButtonType === 'Normal') {
const propsR = { ...r };
delete propsR.ButtonType;
return <Button {...propsR}
loading={loading}
key={r.children}
/>;
return (
<SplitButton {...propsR} loading={loading} key={r.children} selectedRows={selectedRows} obj={obj}/>
);
} else if (r.ButtonType === 'import') {
return (<ImportUtil
return (
<ImportUtil
btn={r.btn}
key={r.btn?.name || '导入'}
ext={r.ext ? r.ext : 'xlsx'}
......@@ -70,9 +77,11 @@ export function FormListButtons(props) {
r.callback();
}
}}
/>);
/>
);
} else if (r.ButtonType === 'export') {
return <ExportCurrentInfo
return (
<ExportCurrentInfo
{...r}
objId={objId}
key={r.children || '到处'}
......@@ -83,10 +92,10 @@ export function FormListButtons(props) {
ext={r.ext ? r.ext : 'xlsx'}
openSelectFieldsModal={r.openSelectFieldsModal || false}
sql={Base16Encode(sql)}
/>;
/>
);
}
});
// return Before.map((r) => <Button {...r} loading={loading} key={r.children} />);
}
......@@ -1181,6 +1181,7 @@ class FormList extends React.Component {
istableCom, // 是否有模板设计器调用
value: { btns },
uuid,
obj,
} = this.props;
const { showMobileDiv, isView, loading } = this.state;
......@@ -1351,6 +1352,8 @@ class FormList extends React.Component {
query={JSON.stringify(this.state.formValues)}
custom={this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null}
sql={Base16Encode(this.props.sql)}
selectedRows={selectedRows}
obj={obj}
/>
{rights && !rights.includes('add') ? (
''
......
......@@ -1045,6 +1045,27 @@ export default class TableCom extends Component {
return 'norefeshxxxxxxxxxxxxxxxxxxxx';
};
getObjValues = () => {
const { isEdit, fatherObj, defaultValues, formKey, form, fatherCode } = this.props;
let obj = {};
if (!isEdit && fatherCode) {
obj = {
...fatherObj,
...form.getFieldsValue(),
...defaultValues[formKey],
};
} else {
obj = {
...(fatherObj ? fatherObj : {}),
...this.props.obj,
...form.getFieldsValue(),
...defaultValues[formKey],
};
}
return obj;
}
functionArguments = (column, callback) => {
const base52 = column.base52;
const {
......@@ -1078,21 +1099,7 @@ export default class TableCom extends Component {
};
}
let obj = {};
if (!isEdit && fatherCode) {
obj = {
...fatherObj,
...form.getFieldsValue(),
...defaultValues[formKey],
};
} else {
obj = {
...(fatherObj ? fatherObj : {}),
...this.props.obj,
...form.getFieldsValue(),
...defaultValues[this.props.formKey],
};
}
let obj = this.getObjValues();
/**
* 中台函数库注入
......@@ -2692,6 +2699,7 @@ ${obj[dataColumn.base52]}
objCode={json.objCode}
sql={json.filterSql}
rights={json.rights}
obj={this.getObjValues()}
/>
);
break;
......@@ -3963,6 +3971,7 @@ ${obj[dataColumn.base52]}
sql={json.filterSql}
rights={json.rights}
get={get}
obj={this.getObjValues()}
/>,
)}
</>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论