|
|
@ -24,14 +24,17 @@ import { |
|
|
|
nextTick, |
|
|
|
nextTick, |
|
|
|
provide, |
|
|
|
provide, |
|
|
|
computed, |
|
|
|
computed, |
|
|
|
onMounted |
|
|
|
h |
|
|
|
} from 'vue' |
|
|
|
} from 'vue' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { omit } from 'lodash' |
|
|
|
|
|
|
|
import Modal from '@/components/modal' |
|
|
|
import Modal from '@/components/modal' |
|
|
|
import Detail from './detail' |
|
|
|
import Detail from './detail' |
|
|
|
import { formatModel } from './format-data' |
|
|
|
import { formatModel } from './format-data' |
|
|
|
import type { ITaskData, ITaskType } from './types' |
|
|
|
import type { ITaskData, ITaskType } from './types' |
|
|
|
|
|
|
|
import { HistoryOutlined, ProfileOutlined } from '@vicons/antd' |
|
|
|
|
|
|
|
import { NIcon } from 'naive-ui' |
|
|
|
|
|
|
|
import { Router, useRouter } from 'vue-router' |
|
|
|
|
|
|
|
import { IWorkflowTaskInstance } from '@/views/projects/workflow/components/dag/types' |
|
|
|
|
|
|
|
|
|
|
|
const props = { |
|
|
|
const props = { |
|
|
|
show: { |
|
|
|
show: { |
|
|
@ -53,22 +56,26 @@ const props = { |
|
|
|
from: { |
|
|
|
from: { |
|
|
|
type: Number as PropType<number>, |
|
|
|
type: Number as PropType<number>, |
|
|
|
default: 0 |
|
|
|
default: 0 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
processInstance: { |
|
|
|
|
|
|
|
type: Object as PropType<any> |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
taskInstance: { |
|
|
|
|
|
|
|
type: Object as PropType<IWorkflowTaskInstance> |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const NodeDetailModal = defineComponent({ |
|
|
|
const NodeDetailModal = defineComponent({ |
|
|
|
name: 'NodeDetailModal', |
|
|
|
name: 'NodeDetailModal', |
|
|
|
props, |
|
|
|
props, |
|
|
|
emits: ['cancel', 'submit'], |
|
|
|
emits: ['cancel', 'submit', 'viewLog'], |
|
|
|
setup(props, { emit }) { |
|
|
|
setup(props, { emit }) { |
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
const router: Router = useRouter() |
|
|
|
|
|
|
|
const renderIcon = (icon: any) => { |
|
|
|
|
|
|
|
return () => h(NIcon, null, { default: () => h(icon) }) |
|
|
|
|
|
|
|
} |
|
|
|
const detailRef = ref() |
|
|
|
const detailRef = ref() |
|
|
|
const state = reactive({ |
|
|
|
|
|
|
|
saving: false, |
|
|
|
|
|
|
|
linkEventShowRef: ref(), |
|
|
|
|
|
|
|
linkEventTextRef: ref(), |
|
|
|
|
|
|
|
linkUrlRef: ref() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onConfirm = async () => { |
|
|
|
const onConfirm = async () => { |
|
|
|
await detailRef.value.value.validate() |
|
|
|
await detailRef.value.value.validate() |
|
|
@ -78,14 +85,36 @@ const NodeDetailModal = defineComponent({ |
|
|
|
emit('cancel') |
|
|
|
emit('cancel') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onJumpLink = () => { |
|
|
|
const headerLinks = ref([] as any) |
|
|
|
// TODO: onJumpLink
|
|
|
|
|
|
|
|
|
|
|
|
const handleViewLog = () => { |
|
|
|
|
|
|
|
if (props.taskInstance) { |
|
|
|
|
|
|
|
emit('viewLog', props.taskInstance.id, props.taskInstance.taskType) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getLinkEventText = (status: boolean, text: string, url: 'string') => { |
|
|
|
const initHeaderLinks = (processInstance: any) => { |
|
|
|
state.linkEventShowRef = status |
|
|
|
headerLinks.value = [ |
|
|
|
state.linkEventTextRef = text |
|
|
|
{ |
|
|
|
state.linkUrlRef = url |
|
|
|
text: t('project.node.view_history'), |
|
|
|
|
|
|
|
show: true, |
|
|
|
|
|
|
|
action: () => { |
|
|
|
|
|
|
|
router.push({ |
|
|
|
|
|
|
|
name: 'task-instance', |
|
|
|
|
|
|
|
params: { processInstanceId: processInstance.id } |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
icon: renderIcon(HistoryOutlined) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
text: t('project.node.view_log'), |
|
|
|
|
|
|
|
show: props.taskInstance ? true : false, |
|
|
|
|
|
|
|
action: () => { |
|
|
|
|
|
|
|
handleViewLog() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
icon: renderIcon(ProfileOutlined) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onTaskTypeChange = (taskType: ITaskType) => { |
|
|
|
const onTaskTypeChange = (taskType: ITaskType) => { |
|
|
@ -103,12 +132,15 @@ const NodeDetailModal = defineComponent({ |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
watch( |
|
|
|
() => [props.show, props.data], |
|
|
|
() => [props.show, props.data], |
|
|
|
async () => { |
|
|
|
async () => { |
|
|
|
if (!props.show) return |
|
|
|
if (!props.show) return |
|
|
|
await nextTick() |
|
|
|
if (props.processInstance) { |
|
|
|
detailRef.value.value.setValues(formatModel(props.data)) |
|
|
|
initHeaderLinks(props.processInstance) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await nextTick() |
|
|
|
|
|
|
|
detailRef.value.value.setValues(formatModel(props.data)) |
|
|
|
|
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return () => ( |
|
|
|
return () => ( |
|
|
@ -119,9 +151,7 @@ const NodeDetailModal = defineComponent({ |
|
|
|
confirmLoading={false} |
|
|
|
confirmLoading={false} |
|
|
|
confirmDisabled={props.readonly} |
|
|
|
confirmDisabled={props.readonly} |
|
|
|
onCancel={onCancel} |
|
|
|
onCancel={onCancel} |
|
|
|
linkEventShow={state.linkEventShowRef} |
|
|
|
headerLinks={headerLinks} |
|
|
|
linkEventText={state.linkEventTextRef} |
|
|
|
|
|
|
|
onJumpLink={onJumpLink} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<Detail |
|
|
|
<Detail |
|
|
|
ref={detailRef} |
|
|
|
ref={detailRef} |
|
|
|