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
b61e13e4
Commit
b61e13e4
authored
2 years ago
by
TZW
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ccc
parent
260121e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
7 deletions
+84
-7
ColumnsTrans.jsx
src/components/InitForm/ColumnsTrans.jsx
+83
-0
columns.js
src/pages/spare/userecord/columns.js
+1
-7
No files found.
src/components/InitForm/ColumnsTrans.jsx
0 → 100644
View file @
b61e13e4
import
{
CopyOutlined
}
from
'@ant-design/icons'
;
import
{
Input
,
Button
,
message
,
Divider
}
from
'antd'
;
import
copy
from
'copy-to-clipboard'
;
import
{
useState
}
from
'react'
;
const
ColumnsTrans
=
()
=>
{
const
[
requestMsg
,
setrequestMsg
]
=
useState
(
''
);
const
[
newRequest
,
setnewRequest
]
=
useState
(
''
);
const
[
borderColor
,
setborderColor
]
=
useState
(
null
);
const
translateHandler
=
()
=>
{
try
{
let
newString
=
JSON
.
parse
(
requestMsg
);
// let newString = eval('('+requestMsg+')');
const
newRequestArr
=
formatPrettier
(
newString
);
setnewRequest
(
newRequestArr
);
setborderColor
(
'green'
);
}
catch
(
error
)
{
message
.
error
(
'“request”内容的格式不符合JSON字符串格式!'
);
setborderColor
(
'red'
);
}
};
const
formatPrettier
=
(
jsonObj
)
=>
{
// debugger
// {
// title: '文本',
// key: 'text',
// dataIndex: 'id',
// },
let
arr
=
[];
for
(
let
key
in
jsonObj
)
{
if
(
key
.
toLowerCase
()
==
'id'
)
continue
;
const
newObj
=
{
title
:
jsonObj
[
key
],
key
:
key
,
dataIndex
:
key
,
};
arr
=
[...
arr
,
newObj
];
}
const
newRequestString
=
JSON
.
stringify
(
arr
)
.
replace
(
/
\[
/g
,
'[
\
n
\
t'
)
.
replace
(
/
\]
/g
,
']'
)
.
replace
(
/
\,
/g
,
',
\
n
\
t'
)
.
replace
(
/
\{
/g
,
'{
\
n
\
t'
)
.
replace
(
/
\}\,
/g
,
'
\
n
\
t},'
)
.
replace
(
/
\}\]
/g
,
'
\
n
\
t}
\
n]'
);
return
newRequestString
;
};
return
(
<
div
>
<
Divider
orientation=
"left"
>
Request
</
Divider
>
<
Input
.
TextArea
name=
"text"
placeholder=
"请输入Request内容,须符合JSON字符串格式"
allowClear=
{
true
}
value=
{
requestMsg
}
autoSize=
{
{
minRows
:
10
}
}
onChange=
{
(
value
)
=>
{
let
newValue
=
value
?.
target
?.
value
;
setrequestMsg
(
newValue
);
}
}
style=
{
{
borderColor
:
borderColor
}
}
/>
<
Button
type=
"primary"
onClick=
{
translateHandler
}
style=
{
{
margin
:
6
}
}
>
转换
</
Button
>
<
Input
.
TextArea
name=
"beautify"
autoSize=
{
{
minRows
:
8
,
maxRows
:
16
}
}
value=
{
newRequest
}
/>
<
Button
style=
{
{
margin
:
6
}
}
onClick=
{
()
=>
{
copy
(
newRequest
);
message
.
success
(
'已成功复制到剪切板!'
);
}
}
>
复制
</
Button
>
</
div
>
);
};
export
default
ColumnsTrans
;
This diff is collapsed.
Click to expand it.
src/pages/spare/userecord/columns.js
View file @
b61e13e4
...
@@ -5,13 +5,7 @@ function getcolumns(setdrawer) {
...
@@ -5,13 +5,7 @@ function getcolumns(setdrawer) {
title
:
'操作时间'
,
title
:
'操作时间'
,
dataIndex
:
'operateTime'
,
dataIndex
:
'operateTime'
,
key
:
'operateTimeList'
,
key
:
'operateTimeList'
,
valueType
:
'dateTimeRange'
,
valueType
:
'dateRange'
,
// fieldProps: {
// showTime: {
// format: 'HH:mm',
// },
// format: 'YYYY-MM-DD HH:mm',
// },
},
},
{
{
title
:
'操作人'
,
title
:
'操作人'
,
...
...
This diff is collapsed.
Click to expand it.
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