Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
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
Administrator
bkunyun
Commits
ca93d0f2
Commit
ca93d0f2
authored
Jul 11, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 代码整理
parent
2489ece8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
125 deletions
+49
-125
MyMenu.tsx
src/components/mui/MyMenu.tsx
+0
-1
MyPopconfirm.tsx
src/components/mui/MyPopconfirm.tsx
+0
-104
interface.ts
src/views/Project/ProjectSubmitWork/interface.ts
+1
-1
index.tsx
src/views/WorkFlowEdit/components/ParameterSetting/index.tsx
+44
-14
util.ts
src/views/WorkFlowEdit/util.ts
+4
-5
No files found.
src/components/mui/MyMenu.tsx
View file @
ca93d0f2
...
...
@@ -21,7 +21,6 @@ const theme = createTheme({
MuiMenu
:
{
styleOverrides
:
{
root
:
{
// maxHeight: "260px",
overflowY
:
"scroll"
,
},
},
...
...
src/components/mui/MyPopconfirm.tsx
View file @
ca93d0f2
// import * as React from "react";
// import { ReactNode, useEffect } from "react";
// import Box from "@mui/material/Box";
// import ButtonComponent from "./Button";
// import tipsIcon from "@/assets/project/information-outline.svg";
// import Popper from "@mui/material/Popper";
// type IMyPopconfirmProps = {
// title: string | ReactNode;
// cancelText?: string;
// okText?: string;
// showCancel?: boolean;
// onCancel?: any;
// onConfirm?: any;
// children: ReactNode;
// };
// const MyPopconfirm = (props: IMyPopconfirmProps) => {
// const {
// title,
// cancelText = "取消",
// okText = "确认",
// showCancel = true,
// onCancel,
// onConfirm,
// } = props;
// const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
// const handleClick = (event: React.MouseEvent<HTMLElement>) => {
// event.nativeEvent.stopImmediatePropagation();
// setAnchorEl(anchorEl ? null : event.currentTarget);
// };
// const open = Boolean(anchorEl);
// const id = open ? "simple-popper" : undefined;
// const handleCancel = () => {
// setAnchorEl(null);
// onCancel && onCancel();
// };
// const handleOk = () => {
// setAnchorEl(null);
// onConfirm && onConfirm();
// };
// useEffect(() => {
// document.addEventListener("click", (e) => {
// setAnchorEl(null);
// });
// }, []);
// return (
// <div>
// <div aria-describedby={id} onClick={handleClick}>
// {props.children && props.children}
// </div>
// <Popper
// id={id}
// open={open}
// anchorEl={anchorEl}
// sx={{
// zIndex: 2000,
// bgcolor: "#fff",
// minWidth: "200px",
// borderRadius: "2px",
// padding: "20px 16px",
// boxShadow: "0px 3px 10px 0px rgba(0, 24, 57, 0.14)",
// }}
// >
// {/* "0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d", */}
// <Box sx={{ marginBottom: "16px" }}>
// <img
// style={{ marginRight: "12px", position: "relative", top: "3px" }}
// src={tipsIcon}
// alt=""
// />
// {title}
// </Box>
// <Box sx={{ display: "flex", justifyContent: "flex-end" }}>
// {showCancel && (
// <ButtonComponent
// text={cancelText}
// // variant="text"
// size="small"
// color="inherit"
// click={handleCancel}
// style={{ marginRight: "12px" }}
// ></ButtonComponent>
// )}
// <ButtonComponent
// text={okText}
// // variant="text"
// size="small"
// click={handleOk}
// ></ButtonComponent>
// </Box>
// </Popper>
// </div>
// );
// };
// export default MyPopconfirm;
// 确认提示框, 支持同一页面多个提示框
import
*
as
React
from
"react"
;
import
{
ReactNode
,
useMemo
}
from
"react"
;
...
...
src/views/Project/ProjectSubmitWork/interface.ts
View file @
ca93d0f2
...
...
@@ -83,7 +83,7 @@ export type IValidator = {
};
export
interface
IChoice
{
key
:
string
;
label
:
string
;
value
:
boolean
|
string
|
number
;
}
...
...
src/views/WorkFlowEdit/components/ParameterSetting/index.tsx
View file @
ca93d0f2
...
...
@@ -151,7 +151,7 @@ const templateConfigInfoMock = [
name
:
"senior"
,
required
:
true
,
defaultValue
:
""
,
domType
:
"
select
"
,
domType
:
"
checkbox
"
,
classType
:
"STRING"
,
classTypeName
:
"String"
,
value
:
""
,
...
...
@@ -168,7 +168,20 @@ const templateConfigInfoMock = [
regex
:
"^.[s][m][i]$"
,
},
],
choices
:
[],
choices
:
[
{
label
:
"123"
,
value
:
"123"
,
},
{
label
:
"456"
,
value
:
"456"
,
},
{
label
:
"789"
,
value
:
"789"
,
},
],
parameterGroup
:
"senior"
,
},
{
...
...
@@ -177,7 +190,7 @@ const templateConfigInfoMock = [
name
:
"hardware"
,
required
:
true
,
defaultValue
:
""
,
domType
:
"
select
"
,
domType
:
"
radio
"
,
classType
:
"STRING"
,
classTypeName
:
"String"
,
value
:
""
,
...
...
@@ -194,7 +207,20 @@ const templateConfigInfoMock = [
regex
:
"^.[s][m][i]$"
,
},
],
choices
:
[],
choices
:
[
{
label
:
"123"
,
value
:
"123"
,
},
{
label
:
"456"
,
value
:
"456"
,
},
{
label
:
"789"
,
value
:
"789"
,
},
],
parameterGroup
:
"hardware"
,
},
],
...
...
@@ -251,18 +277,21 @@ const ParameterSetting = (props: IParameterSettingProps) => {
return
item
.
id
===
taskId
;
});
if
(
taskIndex
!==
-
1
)
{
let
isCheck
=
true
;
result
[
taskIndex
].
parameters
.
forEach
((
parameter
)
=>
{
if
(
parameter
.
id
===
parameterId
)
{
console
.
log
(
e
.
target
.
checked
);
parameter
.
hidden
=
!
e
.
target
.
checked
;
const
checkResult
=
getCustomTemplateParameterCheckResult
(
parameter
,
parameter
.
defaultValue
);
const
checkResult
=
getCustomTemplateParameterCheckResult
(
parameter
);
parameter
.
error
=
checkResult
.
error
;
parameter
.
helperText
=
checkResult
.
helperText
;
}
if
(
getCustomTemplateParameterCheckResult
(
parameter
).
error
===
true
)
{
isCheck
=
false
;
}
});
result
[
taskIndex
].
isCheck
=
isCheck
;
}
setTemplateConfigInfo
(
result
);
},
...
...
@@ -271,24 +300,25 @@ const ParameterSetting = (props: IParameterSettingProps) => {
const
handleParameterChange
=
useCallback
(
(
e
:
any
,
parameterId
:
string
)
=>
{
console
.
log
(
e
.
target
.
value
,
taskId
,
parameterId
);
const
result
:
ITask
[]
=
_
.
cloneDeep
(
templateConfigInfo
);
console
.
log
(
result
);
const
taskIndex
=
result
.
findIndex
((
item
)
=>
{
return
item
.
id
===
taskId
;
});
if
(
taskIndex
!==
-
1
)
{
let
isCheck
=
true
;
result
[
taskIndex
].
parameters
.
forEach
((
parameter
)
=>
{
if
(
parameter
.
id
===
parameterId
)
{
parameter
.
defaultValue
=
e
.
target
.
value
;
const
checkResult
=
getCustomTemplateParameterCheckResult
(
parameter
,
e
.
target
.
value
);
const
checkResult
=
getCustomTemplateParameterCheckResult
(
parameter
);
parameter
.
error
=
checkResult
.
error
;
parameter
.
helperText
=
checkResult
.
helperText
;
}
if
(
getCustomTemplateParameterCheckResult
(
parameter
).
error
===
true
)
{
isCheck
=
false
;
}
});
result
[
taskIndex
].
isCheck
=
isCheck
;
}
setTemplateConfigInfo
(
result
);
},
...
...
src/views/WorkFlowEdit/util.ts
View file @
ca93d0f2
import
{
IParameter
}
from
"../Project/ProjectSubmitWork/interface"
;
export
const
getCustomTemplateParameterCheckResult
=
(
parameter
:
IParameter
,
value
:
string
):
{
error
:
boolean
;
helperText
:
string
;
...
...
@@ -12,12 +11,12 @@ export const getCustomTemplateParameterCheckResult = (
if
(
parameter
.
required
)
{
// 提交任务时不展示
if
(
parameter
.
hidden
)
{
if
(
Array
.
isArray
(
v
alue
))
{
if
(
v
alue
.
length
===
0
)
{
if
(
Array
.
isArray
(
parameter
.
defaultV
alue
))
{
if
(
parameter
.
defaultV
alue
.
length
===
0
)
{
error
=
true
;
helperText
=
"该参数为必填,您必须为该参数赋予默认值"
;
}
}
else
if
(
value
===
""
||
value
===
null
||
v
alue
===
undefined
)
{
}
else
if
(
parameter
.
defaultValue
===
""
||
parameter
.
defaultValue
===
null
||
parameter
.
defaultV
alue
===
undefined
)
{
error
=
true
;
helperText
=
"该参数为必填,您必须为该参数赋予默认值"
;
}
...
...
@@ -32,7 +31,7 @@ export const getCustomTemplateParameterCheckResult = (
if
(
parameter
.
validators
.
length
>
0
)
{
parameter
.
validators
.
forEach
((
validator
)
=>
{
const
reg
=
new
RegExp
(
validator
.
regex
);
if
(
!
reg
.
test
(
v
alue
))
{
if
(
!
reg
.
test
(
parameter
.
defaultV
alue
))
{
error
=
true
;
helperText
=
validator
.
message
;
}
...
...
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