Commit bcfba169 authored by wuhao's avatar wuhao 🎯

aser

parent 33e12f4e
...@@ -48,6 +48,7 @@ const Mtable = (props) => { ...@@ -48,6 +48,7 @@ const Mtable = (props) => {
[size, setsize] = useState('small'), [size, setsize] = useState('small'),
[valueColumns, setvalueColumns] = useState({}); [valueColumns, setvalueColumns] = useState({});
const [columnes, setcolumnes] = useState(columns ?? []); const [columnes, setcolumnes] = useState(columns ?? []);
const [newparames, setnewparams] = useState({});
//调用接口 //调用接口
const request = async (params, sort, filter) => { const request = async (params, sort, filter) => {
...@@ -94,11 +95,7 @@ const Mtable = (props) => { ...@@ -94,11 +95,7 @@ const Mtable = (props) => {
? 160 ? 160
: 'auto'; : 'auto';
let options = {}; let options = {};
if ( if (['select', 'treeSelect', 'radio', 'checkbox', 'cascader'].includes(it?.valueType)) {
it.valueType == 'select' ||
it.valueType == 'checkbox' ||
it.valueType == 'treeSelect'
) {
if (Array.isArray(it.options)) { if (Array.isArray(it.options)) {
options = { options = {
fieldProps: { fieldProps: {
...@@ -115,7 +112,6 @@ const Mtable = (props) => { ...@@ -115,7 +112,6 @@ const Mtable = (props) => {
}; };
} }
} }
if (it.valueType == 'option') { if (it.valueType == 'option') {
options = { options = {
key: 'option', key: 'option',
...@@ -160,7 +156,7 @@ const Mtable = (props) => { ...@@ -160,7 +156,7 @@ const Mtable = (props) => {
let it = { ...item }; let it = { ...item };
let itemwidth = it.width ? it.width : resizeable ? 160 : 'auto'; let itemwidth = it.width ? it.width : resizeable ? 160 : 'auto';
let options = {}; let options = {};
if (it.valueType == 'select' || it.valueType == 'checkbox' || it.valueType == 'treeSelect') { if (['select', 'treeSelect', 'radio', 'checkbox', 'cascader'].includes(it?.valueType)) {
if (Array.isArray(it.options)) { if (Array.isArray(it.options)) {
options = { options = {
fieldProps: { fieldProps: {
...@@ -169,10 +165,17 @@ const Mtable = (props) => { ...@@ -169,10 +165,17 @@ const Mtable = (props) => {
}; };
} else if (it.options) { } else if (it.options) {
options = { options = {
params: newparames,
request: async (params) => { request: async (params) => {
if (Object.keys(it?.options).includes('linkParams')) {
let list = await doFetch({ url: it?.options?.path, params: newparames });
const res = list.data.dataList;
return it.valueType == 'treeSelect' ? handlEmptyChild(res) : res;
} else {
let list = await doFetch({ url: it?.options?.path, params: it?.options?.params }); let list = await doFetch({ url: it?.options?.path, params: it?.options?.params });
const res = list.data.dataList; const res = list.data.dataList;
return it.valueType == 'treeSelect' ? handlEmptyChild(res) : res; return it.valueType == 'treeSelect' ? handlEmptyChild(res) : res;
}
}, },
}; };
} }
...@@ -208,7 +211,7 @@ const Mtable = (props) => { ...@@ -208,7 +211,7 @@ const Mtable = (props) => {
...options, ...options,
}; };
}); });
}, [columns]); }, [columns, newparames]);
//初始化操作数据 //初始化操作数据
const initDrage = async () => { const initDrage = async () => {
...@@ -252,8 +255,6 @@ const Mtable = (props) => { ...@@ -252,8 +255,6 @@ const Mtable = (props) => {
}); });
setvalueColumns(allcol); setvalueColumns(allcol);
} }
actionRefs?.current?.reload();
actionRefs?.current?.reset();
}; };
//调用重新渲染表格 //调用重新渲染表格
...@@ -261,6 +262,8 @@ const Mtable = (props) => { ...@@ -261,6 +262,8 @@ const Mtable = (props) => {
if (resizeable) { if (resizeable) {
await initDrage(); await initDrage();
} }
actionRefs?.current?.reload();
actionRefs?.current?.reset();
}, [columns, extraparams, path, activeTabKey, refreshDep]); }, [columns, extraparams, path, activeTabKey, refreshDep]);
//缩放表格 //缩放表格
...@@ -346,7 +349,19 @@ const Mtable = (props) => { ...@@ -346,7 +349,19 @@ const Mtable = (props) => {
{...components} {...components}
size={size} size={size}
onSubmit={(params) => { onSubmit={(params) => {
console.log(params, 'onSubmit'); //console.log(params, 'onSubmit');
let newparams = {};
columns.map((it, i) => {
if (
it?.options?.linkParams &&
Object.keys(it?.options?.linkParams).includes(Object.keys(params)[0])
) {
for (let dataindex in it?.options?.linkParams) {
newparams[dataindex] = formRefs?.current?.getFieldValue?.(dataindex);
}
}
});
setnewparams(newparams);
}} }}
onSizeChange={(size) => { onSizeChange={(size) => {
localStorage.setItem('size', size); //设置全局表格规格缓存 localStorage.setItem('size', size); //设置全局表格规格缓存
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment