Commit 6997ea3f authored by 吴永生#A02208's avatar 吴永生#A02208

fix: 右侧点击添加锚点

parent 92ced994
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-07-05 14:00:37
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-06 13:52:48
* @FilePath: /bkunyun/src/components/mui/MyCheckBox.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import * as React from "react"; import * as React from "react";
import FormGroup from "@mui/material/FormGroup"; import FormGroup, { FormGroupProps } from "@mui/material/FormGroup";
import FormControlLabel from "@mui/material/FormControlLabel"; import FormControlLabel from "@mui/material/FormControlLabel";
import Checkbox from "@mui/material/Checkbox"; import Checkbox from "@mui/material/Checkbox";
import FormControl from "@mui/material/FormControl"; import FormControl from "@mui/material/FormControl";
import FormHelperText from '@mui/material/FormHelperText'; import FormHelperText from '@mui/material/FormHelperText';
import _ from "lodash"; import _ from "lodash";
type IMyCheckBoxProps = { interface IMyCheckBoxProps extends FormGroupProps{
value: Array<any>; value: Array<any>;
options: Array<ICheckBoxOption>; options: Array<ICheckBoxOption>;
onChange: any; // 直接返回选中项的数组 onChange: any; // 直接返回选中项的数组
...@@ -62,7 +70,7 @@ export default function MyCheckBox(props: IMyCheckBoxProps) { ...@@ -62,7 +70,7 @@ export default function MyCheckBox(props: IMyCheckBoxProps) {
return ( return (
<FormControl fullWidth variant={variant} error={error}> <FormControl fullWidth variant={variant} error={error}>
<FormGroup row> <FormGroup {...props} row>
{options.map((option) => { {options.map((option) => {
return ( return (
<FormControlLabel <FormControlLabel
......
import TextField from "@mui/material/TextField"; /*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-07-05 14:00:37
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-06 11:45:10
* @FilePath: /bkunyun/src/components/mui/MyInput.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import TextField, { TextFieldProps } from "@mui/material/TextField";
type MyInputProps = { interface MyInputProps extends Omit<TextFieldProps, "value"> {
value: any; value: any;
inputSx?: any; inputSx?: any;
onChange?: any; onChange?: any;
...@@ -35,9 +43,9 @@ const MyInput = (props: MyInputProps) => { ...@@ -35,9 +43,9 @@ const MyInput = (props: MyInputProps) => {
return ( return (
<TextField <TextField
{...props}
error={error} error={error}
helperText={helperText} helperText={helperText}
value={value}
sx={{ ...inputSx }} sx={{ ...inputSx }}
id={id} id={id}
label={label} label={label}
...@@ -50,6 +58,7 @@ const MyInput = (props: MyInputProps) => { ...@@ -50,6 +58,7 @@ const MyInput = (props: MyInputProps) => {
InputProps={{ InputProps={{
...InputProps, ...InputProps,
}} }}
value={value}
/> />
); );
}; };
......
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-07-05 14:00:37
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-06 13:49:25
* @FilePath: /bkunyun/src/components/mui/MyRadio.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import * as React from "react"; import * as React from "react";
import Radio from "@mui/material/Radio"; import Radio from "@mui/material/Radio";
import RadioGroup from "@mui/material/RadioGroup"; import RadioGroup, { RadioGroupProps } from "@mui/material/RadioGroup";
import FormControlLabel from "@mui/material/FormControlLabel"; import FormControlLabel from "@mui/material/FormControlLabel";
import FormControl from "@mui/material/FormControl"; import FormControl from "@mui/material/FormControl";
import FormHelperText from '@mui/material/FormHelperText'; import FormHelperText from '@mui/material/FormHelperText';
type IMyRadioProps = { interface IMyRadioProps extends RadioGroupProps {
value: any; value: any;
options: Array<ICheckBoxOption>; options: Array<ICheckBoxOption>;
onChange: any; onChange: any;
...@@ -42,6 +50,7 @@ export default function MyRadio(props: IMyRadioProps) { ...@@ -42,6 +50,7 @@ export default function MyRadio(props: IMyRadioProps) {
return ( return (
<FormControl fullWidth variant={variant} error={error}> <FormControl fullWidth variant={variant} error={error}>
<RadioGroup <RadioGroup
{...props}
row row
aria-labelledby="demo-row-radio-buttons-group-label" aria-labelledby="demo-row-radio-buttons-group-label"
name="row-radio-buttons-group" name="row-radio-buttons-group"
......
...@@ -21,10 +21,11 @@ type ConfigFormProps = { ...@@ -21,10 +21,11 @@ type ConfigFormProps = {
templateConfigInfo?: ITemplateConfig; templateConfigInfo?: ITemplateConfig;
setParameter: any; setParameter: any;
onRef?: React.Ref<any>; onRef?: React.Ref<any>;
setSelectedNodeId: (val: string) => void;
}; };
const ConfigForm = (props: ConfigFormProps) => { const ConfigForm = (props: ConfigFormProps) => {
const { templateConfigInfo, setParameter } = props; const { templateConfigInfo, setParameter,setSelectedNodeId } = props;
const [name, setName] = useState<string>(""); // 任务名称 const [name, setName] = useState<string>(""); // 任务名称
const [nameHelp, setNameHelp] = useState({ const [nameHelp, setNameHelp] = useState({
...@@ -185,7 +186,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -185,7 +186,7 @@ const ConfigForm = (props: ConfigFormProps) => {
setParameter(e.target.value, taskId, parameterName); setParameter(e.target.value, taskId, parameterName);
}; };
const randerParameters = (parameters: Array<IParameter>, taskId: string) => { const randerParameters = (parameters: Array<IParameter>, taskId: string, batchId?: string) => {
return parameters return parameters
.filter((parameter) => parameter.hidden === false) .filter((parameter) => parameter.hidden === false)
.map((parameter, parameterIndex) => { .map((parameter, parameterIndex) => {
...@@ -208,6 +209,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -208,6 +209,8 @@ const ConfigForm = (props: ConfigFormProps) => {
<div className={styles.parameterContent}> <div className={styles.parameterContent}>
{parameter.domType.toLowerCase() === "file" && ( {parameter.domType.toLowerCase() === "file" && (
<MyInput <MyInput
onFocus={()=> setSelectedNodeId(batchId || '')}
onBlur={()=> setSelectedNodeId('')}
value={parameter.value || ""} value={parameter.value || ""}
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
...@@ -228,6 +231,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -228,6 +231,8 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
{parameter.domType.toLowerCase() === "path" && ( {parameter.domType.toLowerCase() === "path" && (
<MyInput <MyInput
onFocus={()=> setSelectedNodeId(batchId || '')}
onBlur={()=> setSelectedNodeId('')}
value={parameter.value || ""} value={parameter.value || ""}
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
...@@ -248,6 +253,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -248,6 +253,8 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
{parameter.domType.toLowerCase() === "dataset" && ( {parameter.domType.toLowerCase() === "dataset" && (
<MyInput <MyInput
onFocus={()=> setSelectedNodeId(taskId)}
onBlur={()=> setSelectedNodeId('')}
value={parameter.value || ""} value={parameter.value || ""}
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
...@@ -268,6 +275,9 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -268,6 +275,9 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
{parameter.domType.toLowerCase() === "input" && ( {parameter.domType.toLowerCase() === "input" && (
<MyInput <MyInput
onFocus={()=> {setSelectedNodeId(batchId || ''); console.log(batchId,'111')}}
onBlur={()=> setSelectedNodeId('')}
value={parameter.value || ""} value={parameter.value || ""}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(e, taskId, parameter.name || "")
...@@ -279,6 +289,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -279,6 +289,8 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
{parameter.domType.toLowerCase() === "select" && ( {parameter.domType.toLowerCase() === "select" && (
<MySelect <MySelect
onFocus={()=> setSelectedNodeId(batchId || '')}
onBlur={()=> setSelectedNodeId('')}
value={parameter.value} value={parameter.value}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(e, taskId, parameter.name || "")
...@@ -290,6 +302,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -290,6 +302,8 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
{parameter.domType.toLowerCase() === "multipleselect" && ( {parameter.domType.toLowerCase() === "multipleselect" && (
<MySelect <MySelect
onFocus={()=> setSelectedNodeId(batchId || '')}
onBlur={()=> setSelectedNodeId('')}
value={parameter.value} value={parameter.value}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(e, taskId, parameter.name || "")
...@@ -306,6 +320,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -306,6 +320,8 @@ const ConfigForm = (props: ConfigFormProps) => {
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(e, taskId, parameter.name || "")
} }
onFocus={()=> setSelectedNodeId(batchId || '')}
onBlur={()=> setSelectedNodeId('')}
options={optionsTransform(parameter.choices, "label")} options={optionsTransform(parameter.choices, "label")}
error={parameter.error || false} error={parameter.error || false}
helperText={parameter.helperText} helperText={parameter.helperText}
...@@ -326,6 +342,8 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -326,6 +342,8 @@ const ConfigForm = (props: ConfigFormProps) => {
) )
} }
options={optionsTransform(parameter.choices, "label")} options={optionsTransform(parameter.choices, "label")}
onFocus={()=> setSelectedNodeId(batchId || '')}
onBlur={()=> setSelectedNodeId('')}
error={parameter.error || false} error={parameter.error || false}
helperText={parameter.helperText} helperText={parameter.helperText}
></MyCheckBox> ></MyCheckBox>
...@@ -427,7 +445,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -427,7 +445,7 @@ const ConfigForm = (props: ConfigFormProps) => {
src={jobSueIcon} src={jobSueIcon}
alt="" alt=""
/> />
<span className={styles.backgroundTitleText}>{task.title}</span> <span id={`point${task.id}`} className={styles.backgroundTitleText}>{task.title}</span>
{task.description && ( {task.description && (
<Tooltip title={task.description} placement="top"> <Tooltip title={task.description} placement="top">
<img className={styles.taskDescIcon} src={tipsIcon} alt="" /> <img className={styles.taskDescIcon} src={tipsIcon} alt="" />
...@@ -435,7 +453,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -435,7 +453,7 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
</div> </div>
<div className={styles.taskConfigBox}> <div className={styles.taskConfigBox}>
{randerParameters(task.parameters, task.id)} {randerParameters(task.parameters, task.id, task.id)}
{task.flows.map((flow) => { {task.flows.map((flow) => {
return ( return (
<div className={styles.flowConfigBox} key={flow.id}> <div className={styles.flowConfigBox} key={flow.id}>
...@@ -451,7 +469,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -451,7 +469,7 @@ const ConfigForm = (props: ConfigFormProps) => {
</Tooltip> </Tooltip>
)} )}
</div> </div>
{randerParameters(flow.parameters, flow.id)} {randerParameters(flow.parameters, flow.id, flow.parentNode ? flow.parentNode : flow.id )}
</div> </div>
); );
})} })}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-21 15:25:25 * @Date: 2022-06-21 15:25:25
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-27 20:50:36 * @LastEditTime: 2022-07-06 11:55:41
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/WorkFlow/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/WorkFlow/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -11,10 +11,12 @@ import { ITemplateConfig } from "../interface"; ...@@ -11,10 +11,12 @@ import { ITemplateConfig } from "../interface";
interface IProps { interface IProps {
templateConfigInfo?: ITemplateConfig; templateConfigInfo?: ITemplateConfig;
setSelectedNodeId?: (val:string) => void;
selectedNodeId?: string;
} }
const WorkFlow = (props: IProps) => { const WorkFlow = (props: IProps) => {
const { templateConfigInfo } = props; const { templateConfigInfo,setSelectedNodeId, selectedNodeId } = props;
return <Flow tasks={templateConfigInfo?.tasks} />; return <Flow tasks={templateConfigInfo?.tasks} setSelectedNodeId={setSelectedNodeId} selectedNodeId={selectedNodeId}/>;
}; };
export default WorkFlow; export default WorkFlow;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-21 20:03:56 * @Date: 2022-06-21 20:03:56
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-05 18:14:13 * @LastEditTime: 2022-07-06 11:55:03
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -42,6 +42,7 @@ const ProjectSubmitWork = () => { ...@@ -42,6 +42,7 @@ const ProjectSubmitWork = () => {
let configFormRef: any = React.createRef(); let configFormRef: any = React.createRef();
/** 是否全屏 */ /** 是否全屏 */
const [fullScreenShow, setFullScreenShow] = useState<boolean>(false); const [fullScreenShow, setFullScreenShow] = useState<boolean>(false);
const [selectedNodeId, setSelectedNodeId] = useState<string>("");
// 前往工作台 // 前往工作台
const goToWorkbench = (toWorkbenchList = false) => { const goToWorkbench = (toWorkbenchList = false) => {
...@@ -254,10 +255,11 @@ const ProjectSubmitWork = () => { ...@@ -254,10 +255,11 @@ const ProjectSubmitWork = () => {
onRef={configFormRef} onRef={configFormRef}
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setParameter={setParameter} setParameter={setParameter}
setSelectedNodeId={setSelectedNodeId}
/> />
</div>} </div>}
<div className={styles.swFlowBox} style={fullScreenShow ? { height: "100vh" } : undefined}> <div className={styles.swFlowBox} style={fullScreenShow ? { height: "100vh" } : undefined}>
<WorkFlow templateConfigInfo={templateConfigInfo} /> <WorkFlow templateConfigInfo={templateConfigInfo} setSelectedNodeId={setSelectedNodeId} selectedNodeId={selectedNodeId}/>
</div> </div>
</div> </div>
<img <img
......
...@@ -30,6 +30,8 @@ interface IProps extends ReactFlowProps { ...@@ -30,6 +30,8 @@ interface IProps extends ReactFlowProps {
tasks?: ITask[]; tasks?: ITask[];
/** 点击batch事件 */ /** 点击batch事件 */
onBatchClick?: (val: string) => void; onBatchClick?: (val: string) => void;
setSelectedNodeId?: (val:string) => void;
selectedNodeId?: string;
} }
/** 获取imgUrl */ /** 获取imgUrl */
...@@ -119,8 +121,7 @@ const FlowNode = (props: any) => { ...@@ -119,8 +121,7 @@ const FlowNode = (props: any) => {
}; };
const Flow = (props: IProps) => { const Flow = (props: IProps) => {
const { tasks, onBatchClick } = props; const { tasks, onBatchClick, setSelectedNodeId, selectedNodeId } = props;
const [selectedNodeId, setSelectedNodeId] = useState<string>("");
/** 自定义的节点类型 */ /** 自定义的节点类型 */
const nodeTypes = useMemo(() => { const nodeTypes = useMemo(() => {
return { batchNode: BatchNode, flowNode: FlowNode }; return { batchNode: BatchNode, flowNode: FlowNode };
...@@ -271,21 +272,24 @@ const Flow = (props: IProps) => { ...@@ -271,21 +272,24 @@ const Flow = (props: IProps) => {
/** flowNode点击事件 */ /** flowNode点击事件 */
const onNodeClick = (e: any, node: Node) => { const onNodeClick = (e: any, node: Node) => {
tasks?.forEach((item) => { tasks?.forEach((item) => {
if (item.id === node.id) { if (item.id === node.id) {
if (item.parentNode) { if (item.parentNode) {
setSelectedNodeId(item.parentNode); setSelectedNodeId && setSelectedNodeId(item.parentNode);
onBatchClick && onBatchClick(item.parentNode); onBatchClick && onBatchClick(item.parentNode);
document.getElementById(`point${item.parentNode}`)?.scrollIntoView(true)
} else { } else {
setSelectedNodeId(node.id); setSelectedNodeId && setSelectedNodeId(node.id);
onBatchClick && onBatchClick(node.id || ""); onBatchClick && onBatchClick(node.id || "");
document.getElementById(`point${node.id}`)?.scrollIntoView(true)
} }
} }
}); });
}; };
const handlePaneClick = () => { const handlePaneClick = () => {
setSelectedNodeId(''); setSelectedNodeId && setSelectedNodeId('');
onBatchClick && onBatchClick(''); onBatchClick && onBatchClick('');
} }
......
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