From 39ad7597fa0e19cc1f7631bbd6fea0a9e05a62c9 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 28 May 2024 17:07:20 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/component/step-form/index.vue | 18 +++++-- .../pipeline/component/task-form/index.vue | 24 +++++++--- .../views/certd/pipeline/pipeline/index.vue | 47 ++++++++++++++----- 3 files changed, 68 insertions(+), 21 deletions(-) diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue index 08e76ddaf..b5e7ed28e 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue @@ -68,6 +68,7 @@ { value: 1, label: '成功后跳过' } ] }, + helper:'该任务运行成功一次之后下次运行是否跳过,证书申请任务务必选择正常运行', rules: [{ required: true, message: '此项必填' }] }" :get-context-fn="blankFn" @@ -89,9 +90,10 @@ import { message, Modal } from "ant-design-vue"; import { computed, inject, Ref, ref } from "vue"; import _ from "lodash-es"; import { nanoid } from "nanoid"; -import { compute } from "@fast-crud/fast-crud"; +import {CopyOutlined} from "@ant-design/icons-vue"; export default { name: "PiStepForm", + components:{CopyOutlined}, props: { editMode: { type: Boolean, @@ -171,7 +173,7 @@ export default { stepDrawerShow(); }; - const stepAdd = (emit: any) => { + const stepAdd = (emit: any,stepDef:any) => { mode.value = "add"; const step: any = { id: nanoid(), @@ -181,6 +183,7 @@ export default { input: {}, status: null }; + _.merge(step,stepDef) stepOpen(step, emit); }; @@ -250,6 +253,14 @@ export default { }); }; + const stepCopy = () => { + const step = _.cloneDeep(currentStep.value); + step.id = nanoid(); + step.title = `${step.title}-copy`; + callback.value("copy", step); + stepDrawerClose(); + }; + const blankFn = () => { return {}; }; @@ -270,7 +281,8 @@ export default { stepSave, stepDelete, rules, - blankFn + blankFn, + stepCopy }; } diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue index 93b6237bb..03ea3e785 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue @@ -35,6 +35,7 @@ @@ -70,10 +71,11 @@ import _ from "lodash-es"; import { nanoid } from "nanoid"; import PiStepForm from "../step-form/index.vue"; import { message, Modal } from "ant-design-vue"; +import {CopyOutlined} from "@ant-design/icons-vue"; export default { name: "PiTaskForm", - components: { PiStepForm }, + components: {CopyOutlined, PiStepForm }, props: { editMode: { type: Boolean, @@ -86,7 +88,7 @@ export default { const stepFormRef: Ref = ref(null); const currentStepIndex = ref(0); provide("currentStepIndex", currentStepIndex); - const stepAdd = (task: any) => { + const stepAdd = (task: any,stepDef:any) => { currentStepIndex.value = task.steps.length; stepFormRef.value.stepAdd((type: any, value: any) => { if (type === "save") { @@ -95,7 +97,14 @@ export default { task.title = value.title; } } - }); + },stepDef); + }; + + const stepCopy = (task: any, step: any, stepIndex: any) => { + step = _.cloneDeep(step) + step.id = nanoid() + step.title = step.title +"_copy" + stepAdd(task,step) }; const stepEdit = (task: any, step: any, stepIndex: any) => { currentStepIndex.value = stepIndex; @@ -126,7 +135,7 @@ export default { }); }; - return { stepAdd, stepEdit, stepDelete, stepFormRef }; + return { stepAdd, stepEdit,stepCopy, stepDelete, stepFormRef }; } /** @@ -168,9 +177,10 @@ export default { taskDrawerShow(); }; - const taskAdd = (emit: any) => { + const taskAdd = (emit: any,taskMerge:any) => { mode.value = "add"; - const task: any = { id: nanoid(), title: "新任务", steps: [], status: null }; + const blankTask = { id: nanoid(), title: "新任务", steps: [], status: null } + const task: any = _.merge(blankTask,taskMerge) ; taskOpen(task, emit); }; @@ -224,7 +234,7 @@ export default { taskSave, taskDelete, rules, - blankFn + blankFn, }; } return { diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue index 6e7f7b1b5..fecdc43db 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue @@ -81,10 +81,11 @@
- - {{ task.title }} - - + + {{ task.title }} + + +
@@ -92,10 +93,13 @@
- - - 并行任务 - + + + + 并行任务 + + +
@@ -369,7 +373,7 @@ export default defineComponent({ const taskView = useTaskView(); - const taskAdd = (stage: any, stageIndex: number, onSuccess?: any) => { + const taskAdd = (stage: any, stageIndex: number, onSuccess?: any,taskDef?:any) => { currentStageIndex.value = stageIndex; currentTaskIndex.value = stage.tasks.length; taskFormRef.value.taskAdd((type: any, value: any) => { @@ -379,8 +383,19 @@ export default defineComponent({ onSuccess(); } } - }); + },taskDef); }; + + const taskCopy = (stage: any, stageIndex: number, task: any ) => { + task = _.cloneDeep(task) + task.id = nanoid() + task.title= task.title+"_copy" + for (const step of task.steps) { + step.id = nanoid() + } + taskAdd(stage,stageIndex,null,task) + }; + const taskEdit = (stage: any, stageIndex: number, task: any, taskIndex: number, onSuccess?: any) => { currentStageIndex.value = stageIndex; currentTaskIndex.value = taskIndex; @@ -408,7 +423,7 @@ export default defineComponent({ } }; - return { taskAdd, taskEdit, taskFormRef, ...taskView }; + return { taskAdd, taskEdit, taskCopy,taskFormRef, ...taskView }; } function useStage(useTaskRet: any) { @@ -745,6 +760,16 @@ export default defineComponent({ height: 100%; z-index: 2; + .copy{ + position: absolute; + right:60px; + top:18px; + cursor: pointer; + &:hover { + color: #1890ff; + } + } + .ant-btn { width: 200px; }