perf: 当步骤全部都禁用时,任务本身显示删除线

pull/265/head
xiaojunnuo 2024-11-19 11:19:40 +08:00
parent 67ccff3e86
commit 9ab9a6e8b0
2 changed files with 21 additions and 4 deletions

View File

@ -56,7 +56,7 @@
<a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a> <a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a>
<a key="edit" @click="stepCopy(currentTask, element, index)">复制</a> <a key="edit" @click="stepCopy(currentTask, element, index)">复制</a>
<a key="remove" @click="stepDelete(currentTask, index)">删除</a> <a key="remove" @click="stepDelete(currentTask, index)">删除</a>
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a> <a key="disabled" @click="toggleDisabled(currentTask, element)">{{ element.disabled ? "启用" : "禁用" }}</a>
<fs-icon v-plus class="icon-button handle cursor-move" title="拖动排序" icon="ion:move-outline"></fs-icon> <fs-icon v-plus class="icon-button handle cursor-move" title="拖动排序" icon="ion:move-outline"></fs-icon>
</div> </div>
</div> </div>
@ -88,6 +88,7 @@ import { CopyOutlined } from "@ant-design/icons-vue";
import VDraggable from "vuedraggable"; import VDraggable from "vuedraggable";
import { useUserStore } from "/@/store/modules/user"; import { useUserStore } from "/@/store/modules/user";
import { useSettingStore } from "/@/store/modules/settings"; import { useSettingStore } from "/@/store/modules/settings";
import { filter } from "lodash-es";
export default { export default {
name: "PiTaskForm", name: "PiTaskForm",
components: { CopyOutlined, PiStepForm, VDraggable }, components: { CopyOutlined, PiStepForm, VDraggable },
@ -152,7 +153,11 @@ export default {
}); });
}; };
return { stepAdd, stepEdit, stepCopy, stepDelete, stepFormRef }; const toggleDisabled = (task: any, step: any) => {
step.disabled = !!!step.disabled;
};
return { stepAdd, stepEdit, stepCopy, stepDelete, toggleDisabled, stepFormRef };
} }
/** /**
@ -162,7 +167,7 @@ export default {
function useTaskForm() { function useTaskForm() {
const mode = ref("add"); const mode = ref("add");
const callback = ref(); const callback = ref();
const currentTask = ref({ title: undefined, steps: [] }); const currentTask = ref({ title: undefined, steps: [], disabled: false });
provide("currentTask", currentTask); provide("currentTask", currentTask);
const taskFormRef: Ref<any> = ref(null); const taskFormRef: Ref<any> = ref(null);
const taskDrawerVisible = ref(false); const taskDrawerVisible = ref(false);
@ -219,6 +224,15 @@ export default {
console.error("表单验证失败:", e); console.error("表单验证失败:", e);
return; return;
} }
const task: any = currentTask.value;
const allDisabled = filter(task.steps, (item: any) => {
return item.disabled;
});
if (task.steps.length > 0 && task.steps.length === allDisabled.length) {
task.disabled = true;
} else {
task.disabled = false;
}
callback.value("save", currentTask.value); callback.value("save", currentTask.value);
taskDrawerClose(); taskDrawerClose();

View File

@ -109,7 +109,7 @@
</div> </div>
</template> </template>
<span class="flex-o w-100"> <span class="flex-o w-100">
<span class="ellipsis flex-1 task-title" :class="{ 'in-edit': editMode }">{{ task.title }}</span> <span class="ellipsis flex-1 task-title" :class="{ 'in-edit': editMode, deleted: task.disabled }">{{ task.title }}</span>
<pi-status-show :status="task.status?.result"></pi-status-show> <pi-status-show :status="task.status?.result"></pi-status-show>
</span> </span>
</a-popover> </a-popover>
@ -883,6 +883,9 @@ export default defineComponent({
&.in-edit { &.in-edit {
margin-right: 28px; margin-right: 28px;
} }
&.disabled{
}
} }
.action { .action {