perf: history增加触发类型显示

pull/436/head
xiaojunnuo 2025-06-09 11:13:51 +08:00
parent 0aea9c129c
commit 7f6070c960
5 changed files with 54 additions and 3 deletions

View File

@ -2,9 +2,10 @@ import * as api from "./api";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { computed, Ref, ref } from "vue"; import { computed, Ref, ref } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes, utils } from "@fast-crud/fast-crud"; import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, utils } from "@fast-crud/fast-crud";
import { useUserStore } from "/@/store/user"; import { useUserStore } from "/@/store/user";
import { useSettingStore } from "/@/store/settings"; import { useSettingStore } from "/@/store/settings";
import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter(); const router = useRouter();
@ -143,6 +144,50 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
}, },
}, },
}, },
triggerType: {
title: "触发类型",
type: "dict-select",
search: {
show: true,
},
dict: dict({
data: [
{ value: "user", label: "手动执行" },
{ value: "timer", label: "定时执行" },
],
}),
form: {
show: false,
value: "custom",
},
column: {
sorter: true,
width: 90,
align: "center",
show: true,
component: {
color: "auto",
},
},
},
status: {
title: "状态",
type: "dict-select",
search: {
show: true,
},
dict: dict({
data: statusUtil.getOptions(),
}),
form: {
show: false,
},
column: {
sorter: true,
width: 120,
align: "center",
},
},
createTime: { createTime: {
title: "创建时间", title: "创建时间",
type: "datetime", type: "datetime",

View File

@ -0,0 +1,2 @@
ALTER TABLE pi_history ADD COLUMN "trigger_type" varchar(100);

View File

@ -16,6 +16,9 @@ export class HistoryEntity {
@Column({ comment: '结果状态', length: 20, nullable: true }) @Column({ comment: '结果状态', length: 20, nullable: true })
status: string; status: string;
@Column({ name: 'trigger_type',comment: '触发类型', length: 20, nullable: true })
triggerType: string;
@Column({ @Column({
name: 'end_time', name: 'end_time',
comment: '结束时间', comment: '结束时间',

View File

@ -60,12 +60,13 @@ export class HistoryService extends BaseService<HistoryEntity> {
return new HistoryDetail(entity, log); return new HistoryDetail(entity, log);
} }
async start(pipeline: PipelineEntity) { async start(pipeline: PipelineEntity,triggerType:string) {
const bean = { const bean = {
userId: pipeline.userId, userId: pipeline.userId,
pipelineId: pipeline.id, pipelineId: pipeline.id,
title: pipeline.title, title: pipeline.title,
status: 'start', status: 'start',
triggerType
}; };
const { id } = await this.add(bean); const { id } = await this.add(bean);
//清除大于pipeline.keepHistoryCount的历史记录 //清除大于pipeline.keepHistoryCount的历史记录

View File

@ -497,7 +497,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
}; };
const userId = entity.userId; const userId = entity.userId;
const historyId = await this.historyService.start(entity); const historyId = await this.historyService.start(entity,triggerType);
const userIsAdmin = await this.userService.isAdmin(userId); const userIsAdmin = await this.userService.isAdmin(userId);
const user: UserInfo = { const user: UserInfo = {
id: userId, id: userId,