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