提交 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,7 +91,8 @@ export default class TableList extends React.Component { ...@@ -91,7 +91,8 @@ export default class TableList extends React.Component {
objCode={this.props.objCode} objCode={this.props.objCode}
isFormCom={true} isFormCom={true}
uuid={uuid} uuid={uuid}
sql={this.props.sql} obj={obj}
sql={this.props.sql}
/> />
) : ( ) : (
<FormList <FormList
...@@ -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,90 +3,99 @@ import { Button } from 'antd'; ...@@ -3,90 +3,99 @@ 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([]);
const { const {
btns, btns,
loading, loading,
importConfig, importConfig,
getPage, getPage,
objId, objId,
query, query,
custom, custom,
sql, sql,
exportConfig exportConfig,
} = props; selectedRows,
const Before = btns && btns.before || []; obj,
useEffect(() => { } = props;
let buttons = []; const Before = (btns && btns.before) || [];
buttons = Before.map((g) => { useEffect(
g.ButtonType = 'Normal'; () => {
return g; let buttons = [];
}); buttons = Before.map((g) => {
for (let item of importConfig) { g.ButtonType = 'Normal';
buttons.push({ return g;
...item, });
ButtonType: 'import', for (let item of importConfig) {
}); buttons.push({
} ...item,
let i = 0; ButtonType: 'import',
for (let item of exportConfig) { });
buttons.push({ }
...item, let i = 0;
ButtonType: 'export', for (let item of exportConfig) {
index: i++, buttons.push({
}); ...item,
} ButtonType: 'export',
buttons.sort((a, b) => { index: i++,
let priorityA = a.priority || 0; });
let priorityB = b.priority || 0; }
return priorityA - priorityB; buttons.sort((a, b) => {
}); let priorityA = a.priority || 0;
setConCatButtons(buttons); let priorityB = b.priority || 0;
}, [exportConfig, importConfig, btns]); return priorityA - priorityB;
if (!ConcatButtons || !ConcatButtons.length) { });
return null; setConCatButtons(buttons);
} },
[exportConfig, importConfig, btns],
);
return ConcatButtons.map((r, i) => { if (!ConcatButtons || !ConcatButtons.length) {
if (r.ButtonType === 'Normal') { return null;
const propsR = { ...r }; }
delete propsR.ButtonType;
return <Button {...propsR}
loading={loading}
key={r.children}
/>;
} else if (r.ButtonType === 'import') {
return (<ImportUtil
btn={r.btn}
key={r.btn?.name || '导入'}
ext={r.ext ? r.ext : 'xlsx'}
importConfig={r}
objId={objId}
callback={() => {
getPage();
if (r.callback && typeof r.callback === 'function') {
r.callback();
}
}}
/>);
} else if (r.ButtonType === 'export') {
return <ExportCurrentInfo
{...r}
objId={objId}
key={r.children || '到处'}
query={query}
custom={custom}
index={r.index}
btn={r.btn}
ext={r.ext ? r.ext : 'xlsx'}
openSelectFieldsModal={r.openSelectFieldsModal || false}
sql={Base16Encode(sql)}
/>;
}
});
return ConcatButtons.map((r, i) => {
if (r.ButtonType === 'Normal') {
const propsR = { ...r };
delete propsR.ButtonType;
return (
<SplitButton {...propsR} loading={loading} key={r.children} selectedRows={selectedRows} obj={obj}/>
);
} else if (r.ButtonType === 'import') {
return (
<ImportUtil
btn={r.btn}
key={r.btn?.name || '导入'}
ext={r.ext ? r.ext : 'xlsx'}
importConfig={r}
objId={objId}
callback={() => {
getPage();
if (r.callback && typeof r.callback === 'function') {
r.callback();
}
}}
/>
);
} else if (r.ButtonType === 'export') {
return (
<ExportCurrentInfo
{...r}
objId={objId}
key={r.children || '到处'}
query={query}
custom={custom}
index={r.index}
btn={r.btn}
ext={r.ext ? r.ext : 'xlsx'}
openSelectFieldsModal={r.openSelectFieldsModal || false}
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论