Commit ba102be9 authored by chenshouchao's avatar chenshouchao

feat: 编辑联调

parent 1378e838
......@@ -110,6 +110,14 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
});
};
// 编辑模板
const handleEditTemplate = (item: any) => {
setCustomTemplateInfo({
show: true,
id: item.id,
});
};
// 获取模板列表
const getAddTemplateListFun = useCallback(() => {
const userName = JSON.parse(localStorage.getItem("userInfo") || "{}")?.name;
......@@ -117,13 +125,13 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
setAddTemplateList([]);
if (templateType === "public") {
getAddTemplateList({
projectId: projectId as string,
// projectId: projectId as string,
productId: productId as string,
title,
});
} else {
getAddTemplateList({
projectId: projectId as string,
// projectId: projectId as string,
productId: productId as string,
creator: userName,
title,
......@@ -132,11 +140,12 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
}, [
setSelectTemplateData,
getAddTemplateList,
projectId,
productId,
templateType,
title,
]);
// projectId,
// title,
useEffect(() => {
getAddTemplateListFun();
......@@ -286,7 +295,7 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
{templateType !== "public" && (
<div className={style.templateLiEditBox}>
<Button
click={handleAddTemplate}
click={() => handleEditTemplate(item)}
size={"small"}
style={{
height: "32px",
......@@ -316,6 +325,7 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
</div>
{customTemplateInfo?.show ? (
<WorkFlowEdit
id={customTemplateInfo.id || ""}
onBack={() => {
setCustomTemplateInfo({
id: "",
......
......@@ -6,7 +6,7 @@
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React, { useCallback, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";
import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew";
import IconButton from "@mui/material/IconButton";
......@@ -19,6 +19,7 @@ import ParameterSetting from "./components/ParameterSetting";
import { useMessage } from "@/components/MySnackbar";
import { ITask } from "../Project/ProjectSubmitWork/interface";
import _ from "lodash";
import { fetchTemplateConfigInfo } from "@/api/project_api";
import { saveUserSpec } from "@/api/workbench_api";
import useMyRequest from "@/hooks/useMyRequest";
import MyDialog from "@/components/mui/Dialog";
......@@ -44,21 +45,17 @@ const radioOptions = [
interface IProps {
onBack?: () => void;
id?: string;
}
const WorkFlowEdit = observer((props: IProps) => {
const { onBack } = props;
const { onBack, id } = props;
const { currentProjectStore } = useStores();
const Message = useMessage();
const [templateConfigInfo, setTemplateConfigInfo] = useState<ITask[]>([]);
// const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const productId = toJS(currentProjectStore.currentProductInfo.id);
const [saveFormDialog, setSaveFormDialog] = useState(false);
// const [formValue, setFormValue] = useState({
// title: "",
// version: "1.0.0",
// description: "",
// });
const [showFlow, setShowFlow] = useState(true);
const [title, setTitle] = useState("");
const [version, setVersion] = useState("1.0.0");
......@@ -76,6 +73,30 @@ const WorkFlowEdit = observer((props: IProps) => {
"返回后,当前页面已填写内容将不保存,确认返回吗?"
);
const { run: fetchTemplateConfigInfoRun } = useMyRequest(
fetchTemplateConfigInfo,
{
onSuccess: (res: any) => {
console.log(res);
if (res.data) {
setTemplateConfigInfo(res.data.tasks);
setTitle(res.data.title);
let version = res.data.version;
let arr = version.split(".");
arr[2] = String(Number(arr[2]) + 1);
setVersion(arr.join("."));
setDescription(res.data.description);
}
},
}
);
useEffect(() => {
if (id) {
fetchTemplateConfigInfoRun({ id });
}
}, [id, fetchTemplateConfigInfoRun]);
const checkTitle = (title: string) => {
if (!title) {
setTitleHelper({
......@@ -216,11 +237,13 @@ const WorkFlowEdit = observer((props: IProps) => {
};
const handleCloseDialog = () => {
setShowFlow(true);
setSaveFormDialog(false);
};
const handleOncofirm = () => {
checkTitle(title);
setShowFlow(true);
checkVersion(version);
if (!titleHelper.error && !versionHelper.error) {
saveUserSpecRun({
......
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