Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ems3.3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wuhao
ems3.3
Commits
bcfba169
Commit
bcfba169
authored
Nov 15, 2022
by
wuhao
🎯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aser
parent
33e12f4e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
89 deletions
+104
-89
mtable.jsx
src/components/AutoTable/mtable.jsx
+104
-89
No files found.
src/components/AutoTable/mtable.jsx
View file @
bcfba169
...
...
@@ -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
);
//设置全局表格规格缓存
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment