Commit bcfba169 authored by wuhao's avatar wuhao 🎯

aser

parent 33e12f4e
......@@ -48,6 +48,7 @@ const Mtable = (props) => {
[size, setsize] = useState('small'),
[valueColumns, setvalueColumns] = useState({});
const [columnes, setcolumnes] = useState(columns ?? []);
const [newparames, setnewparams] = useState({});
//调用接口
const request = async (params, sort, filter) => {
......@@ -94,11 +95,7 @@ const Mtable = (props) => {
? 160
: 'auto';
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)) {
options = {
fieldProps: {
......@@ -115,7 +112,6 @@ const Mtable = (props) => {
};
}
}
if (it.valueType == 'option') {
options = {
key: 'option',
......@@ -160,7 +156,7 @@ const Mtable = (props) => {
let it = { ...item };
let itemwidth = it.width ? it.width : resizeable ? 160 : 'auto';
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)) {
options = {
fieldProps: {
......@@ -169,10 +165,17 @@ const Mtable = (props) => {
};
} else if (it.options) {
options = {
params: newparames,
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 });
const res = list.data.dataList;
return it.valueType == 'treeSelect' ? handlEmptyChild(res) : res;
}
},
};
}
......@@ -208,7 +211,7 @@ const Mtable = (props) => {
...options,
};
});
}, [columns]);
}, [columns, newparames]);
//初始化操作数据
const initDrage = async () => {
......@@ -252,8 +255,6 @@ const Mtable = (props) => {
});
setvalueColumns(allcol);
}
actionRefs?.current?.reload();
actionRefs?.current?.reset();
};
//调用重新渲染表格
......@@ -261,6 +262,8 @@ const Mtable = (props) => {
if (resizeable) {
await initDrage();
}
actionRefs?.current?.reload();
actionRefs?.current?.reset();
}, [columns, extraparams, path, activeTabKey, refreshDep]);
//缩放表格
......@@ -346,7 +349,19 @@ const Mtable = (props) => {
{...components}
size={size}
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) => {
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