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

FormList组件修改

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