Commit 0388a4d0 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20220705-customTemplate' of…

Merge branch 'feat-20220705-customTemplate' of http://120.77.149.83/sunyihao/bkunyun into feat-20220705-customTemplate
parents 25dc9d71 39c8dbc0
...@@ -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-06 17:05:13 * @LastEditTime: 2022-07-08 15:02:08
* @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
*/ */
...@@ -37,6 +37,7 @@ import MyPopconfirm from "@/components/mui/MyPopconfirm"; ...@@ -37,6 +37,7 @@ import MyPopconfirm from "@/components/mui/MyPopconfirm";
import { storageUnitFromB } from "@/utils/util"; import { storageUnitFromB } from "@/utils/util";
import styles from "./index.module.css"; import styles from "./index.module.css";
import usePass from "@/hooks/usePass";
const stateMap = { const stateMap = {
RUNNING: "正在运行", RUNNING: "正在运行",
...@@ -69,6 +70,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -69,6 +70,7 @@ const ProjectSubmitWork = observer(() => {
const location: any = useLocation(); const location: any = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
const message = useMessage(); const message = useMessage();
const isPass = usePass();
const [fullScreenShow, setFullScreenShow] = useState<boolean>(false); const [fullScreenShow, setFullScreenShow] = useState<boolean>(false);
const { name, state } = workFlowJobInfo || {}; const { name, state } = workFlowJobInfo || {};
...@@ -283,6 +285,14 @@ const ProjectSubmitWork = observer(() => { ...@@ -283,6 +285,14 @@ const ProjectSubmitWork = observer(() => {
}); });
}, [deleteWorkJob, workFlowJobInfo?.id]); }, [deleteWorkJob, workFlowJobInfo?.id]);
const returnPermission = useMemo(() => {
if (state === "RUNNING") {
return isPass("PROJECT_WORKBENCH_JOBS_STOP", "USER");
} else {
return isPass("PROJECT_WORKBENCH_JOBS_DELETE", "MANAGER");
}
}, [isPass, state]);
return ( return (
<div className={styles.swBox}> <div className={styles.swBox}>
{fullScreenShow ? null : ( {fullScreenShow ? null : (
...@@ -306,6 +316,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -306,6 +316,7 @@ const ProjectSubmitWork = observer(() => {
<div className={styles.swTemplateTitle}>{name}</div> <div className={styles.swTemplateTitle}>{name}</div>
</div> </div>
{returnPermission && (
<div className={styles.swHeaderRight}> <div className={styles.swHeaderRight}>
<MyPopconfirm <MyPopconfirm
title={ title={
...@@ -325,6 +336,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -325,6 +336,7 @@ const ProjectSubmitWork = observer(() => {
></ButtonComponent> ></ButtonComponent>
</MyPopconfirm> </MyPopconfirm>
</div> </div>
)}
</div> </div>
)} )}
<div className={styles.swContent}> <div className={styles.swContent}>
......
...@@ -36,6 +36,7 @@ interface IProps extends ReactFlowProps { ...@@ -36,6 +36,7 @@ interface IProps extends ReactFlowProps {
onBatchClick?: (val: string) => void; onBatchClick?: (val: string) => void;
setSelectedNodeId?: (val: string) => void; setSelectedNodeId?: (val: string) => void;
selectedNodeId?: string; selectedNodeId?: string;
type?: "edit" | "default";
} }
/** 获取imgUrl */ /** 获取imgUrl */
...@@ -133,7 +134,13 @@ const FlowNode = (props: any) => { ...@@ -133,7 +134,13 @@ const FlowNode = (props: any) => {
}; };
const Flow = (props: IProps) => { const Flow = (props: IProps) => {
const { tasks, onBatchClick, setSelectedNodeId, selectedNodeId } = props; const {
tasks,
onBatchClick,
setSelectedNodeId,
selectedNodeId,
type: flowType = "default",
} = props;
/** 自定义的节点类型 */ /** 自定义的节点类型 */
const nodeTypes = useMemo(() => { const nodeTypes = useMemo(() => {
return { batchNode: BatchNode, flowNode: FlowNode }; return { batchNode: BatchNode, flowNode: FlowNode };
...@@ -333,7 +340,7 @@ const Flow = (props: IProps) => { ...@@ -333,7 +340,7 @@ const Flow = (props: IProps) => {
<ReactFlow <ReactFlow
nodes={nodes} nodes={nodes}
edges={edges} edges={edges}
fitView fitView={flowType === "default" ? false : true}
proOptions={{ hideAttribution: true, account: "" }} proOptions={{ hideAttribution: true, account: "" }}
nodeTypes={nodeTypes} nodeTypes={nodeTypes}
onPaneClick={handlePaneClick} onPaneClick={handlePaneClick}
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
} }
.operatorListBox { .operatorListBox {
height: 100%; height: calc(100% - 84px);
} }
.listBox { .listBox {
......
...@@ -16,6 +16,7 @@ import { useStores } from "@/store"; ...@@ -16,6 +16,7 @@ import { useStores } from "@/store";
import { uuid } from "@/utils/util"; import { uuid } from "@/utils/util";
import styles from "./index.module.css"; import styles from "./index.module.css";
import MyMenu from "@/components/mui/MyMenu";
/* /*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
...@@ -42,25 +43,39 @@ const OperatorItem = (props: IOperatorItemProps) => { ...@@ -42,25 +43,39 @@ const OperatorItem = (props: IOperatorItemProps) => {
const onDragEnd = useCallback( const onDragEnd = useCallback(
(e: React.DragEvent<HTMLDivElement>) => { (e: React.DragEvent<HTMLDivElement>) => {
const dom = document.getElementById("workFlowEditRight"); const dom = document.getElementById("workFlowEditRight");
const clientX = e.clientX;
const clientY = e.clientY;
const upperLeftPointX = Number(dom?.offsetLeft); const upperLeftPointX = Number(dom?.offsetLeft);
const upperLeftPointY = Number(dom?.offsetTop); const upperLeftPointY = Number(dom?.offsetTop);
const lowerRightX = Number(upperLeftPointX) + Number(dom?.offsetWidth); const lowerRightX = Number(upperLeftPointX) + Number(dom?.offsetWidth);
const lowerRightY = Number(upperLeftPointY) + Number(dom?.offsetHeight); const lowerRightY = Number(upperLeftPointY) + Number(dom?.offsetHeight);
if ( if (
e.clientX > upperLeftPointX && clientX > upperLeftPointX &&
e.clientY > upperLeftPointY && clientY > upperLeftPointY &&
e.clientX < lowerRightX && clientX < lowerRightX &&
e.clientY < lowerRightY clientY < lowerRightY
) { ) {
console.log(
clientX - upperLeftPointX,
clientY - upperLeftPointY,
"0000000"
);
const newVal = [ const newVal = [
...cloneDeep(templateConfigInfo), ...cloneDeep(templateConfigInfo),
{ ...props.info, uuid: uuid() }, {
...props.info,
uuid: uuid(),
position: {
x: clientX - upperLeftPointX,
y: clientY - upperLeftPointY,
},
},
]; ];
setTemplateConfigInfo(newVal); setTemplateConfigInfo(newVal);
} }
setIsDragStyle(false); setIsDragStyle(false);
}, },
[setTemplateConfigInfo, templateConfigInfo] [props.info, setTemplateConfigInfo, templateConfigInfo]
); );
return ( return (
...@@ -90,7 +105,16 @@ const OperatorItem = (props: IOperatorItemProps) => { ...@@ -90,7 +105,16 @@ const OperatorItem = (props: IOperatorItemProps) => {
</span> </span>
); );
})} })}
{/* <MySelect options={[]} /> */} <MyMenu
options={[
{ label: "1.1.0", value: "1.1.0" },
{ label: "1.2.0", value: "1.2.0" },
{ label: "1.3.0", value: "1.3.0" },
]}
value="1.1.0"
>
<div>ddd</div>
</MyMenu>
</div> </div>
</div> </div>
); );
...@@ -102,15 +126,13 @@ const OperatorList = observer((props: IOperatorListProps) => { ...@@ -102,15 +126,13 @@ const OperatorList = observer((props: IOperatorListProps) => {
const { templateConfigInfo, setTemplateConfigInfo } = props; const { templateConfigInfo, setTemplateConfigInfo } = props;
const [operatorListData, setOperatorListData] = useState<ITask[]>( const [operatorListData, setOperatorListData] = useState<ITask[]>([]);
mockData as any const [keyword, setKeyword] = useState<string>("");
);
console.log(templateConfigInfo, "templateConfigInfo");
// 取消作业 // 取消作业
const { run } = useMyRequest(fetchOperatorList, { const { run } = useMyRequest(fetchOperatorList, {
onSuccess: (res: IResponse<any>) => { onSuccess: (res: IResponse<any>) => {
console.log(res, "1111"); setOperatorListData(res?.data || []);
}, },
}); });
...@@ -118,18 +140,29 @@ const OperatorList = observer((props: IOperatorListProps) => { ...@@ -118,18 +140,29 @@ const OperatorList = observer((props: IOperatorListProps) => {
run({ run({
owner: "root", owner: "root",
productId: "cadd" || "", productId: "cadd" || "",
// keyword : ''
}); });
}, [productId, run]); }, [productId, run]);
/** 处理回车键 */
const handleEnterCode = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.keyCode === 13) {
run({
owner: "root",
productId: "cadd" || "",
keyword,
});
}
};
return ( return (
<div className={styles.operatorListBox}> <div className={styles.operatorListBox}>
<div className={styles.searchBox}> <div className={styles.searchBox}>
<OutlinedInput <OutlinedInput
onChange={(e: any) => { onChange={(e) => {
console.log(e.target.value); setKeyword(e.target.value);
}} }}
placeholder="输入关键词搜索" placeholder="输入关键词搜索"
onKeyUp={handleEnterCode}
size="small" size="small"
sx={{ height: 32, width: "100%" }} sx={{ height: 32, width: "100%" }}
endAdornment={<SearchIcon style={{ color: "#8A9099" }} />} endAdornment={<SearchIcon style={{ color: "#8A9099" }} />}
...@@ -137,7 +170,7 @@ const OperatorList = observer((props: IOperatorListProps) => { ...@@ -137,7 +170,7 @@ const OperatorList = observer((props: IOperatorListProps) => {
</div> </div>
<div className={styles.listBox}> <div className={styles.listBox}>
{operatorListData {operatorListData
.filter((item) => item.type === "BATCH") // .filter((item) => item.type === "BATCH")
.map((item) => { .map((item) => {
return ( return (
<OperatorItem <OperatorItem
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
background-color: #fff; background-color: #fff;
border-right: 1xp solid rgba(235, 237, 240, 1); border-right: 1xp solid rgba(235, 237, 240, 1);
width: 360px; width: 360px;
height: 100%;
/* overflow-y: scroll; */ /* overflow-y: scroll; */
box-sizing: border-box; box-sizing: border-box;
} }
......
...@@ -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-08 09:25:42 * @LastEditTime: 2022-07-08 11:51:07
* @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
*/ */
...@@ -78,7 +78,7 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -78,7 +78,7 @@ const WorkFlowEdit = (props: IProps) => {
</div> </div>
</div> </div>
<div className={styles.swContent}> <div className={styles.swContent}>
<div> <div className={styles.swFormBox}>
<div className={styles.radiosBox}> <div className={styles.radiosBox}>
<RadioGroupOfButtonStyle <RadioGroupOfButtonStyle
radioOptions={radioOptions} radioOptions={radioOptions}
...@@ -95,12 +95,10 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -95,12 +95,10 @@ const WorkFlowEdit = (props: IProps) => {
></RadioGroupOfButtonStyle> ></RadioGroupOfButtonStyle>
</div> </div>
{leftContentType === "list" && ( {leftContentType === "list" && (
<div className={styles.swFormBox}>
<OperatorList <OperatorList
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setTemplateConfigInfo={setTemplateConfigInfo} setTemplateConfigInfo={setTemplateConfigInfo}
/> />
</div>
)} )}
{leftContentType !== "list" && ( {leftContentType !== "list" && (
<ParameterSetting <ParameterSetting
...@@ -109,8 +107,8 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -109,8 +107,8 @@ const WorkFlowEdit = (props: IProps) => {
/> />
)} )}
</div> </div>
<div id="workFlowEditRight"> <div className={styles.swFlowBox} id="workFlowEditRight">
<Flow tasks={templateConfigInfo} /> <Flow tasks={templateConfigInfo} type="edit" />
</div> </div>
</div> </div>
</div> </div>
......
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