in dolphinscheduler-ui/src/views/projects/workflow/instance/components/workflow-instance-condition.tsx [40:144]
setup(props, ctx) {
const router: Router = useRouter()
const searchValRef = ref('')
const executorNameRef = ref('')
const hostRef = ref('')
const stateTypeRef = ref('')
const startEndTimeRef = ref()
const projectCode = ref(
Number(router.currentRoute.value.params.projectCode)
)
const workflowDefinitionCodeRef = router.currentRoute.value.query
.workflowDefineCode
? ref(Number(router.currentRoute.value.query.workflowDefineCode))
: ref()
const workflowDefinitionOptions = ref<Array<SelectMixedOption>>([])
const initWorkflowList = (code: number) => {
queryWorkflowDefinitionList(code).then((result: any) => {
result.map((item: { code: number; name: string }) => {
const option: SelectMixedOption = {
value: item.code,
label: () => h(NEllipsis, null, item.name),
filterLabel: item.name
}
workflowDefinitionOptions.value.push(option)
})
})
}
initWorkflowList(projectCode.value)
const handleSearch = () => {
let startDate = ''
let endDate = ''
if (startEndTimeRef.value) {
startDate = format(
new Date(startEndTimeRef.value[0]),
'yyyy-MM-dd HH:mm:ss'
)
endDate = format(
new Date(startEndTimeRef.value[1]),
'yyyy-MM-dd HH:mm:ss'
)
}
ctx.emit('handleSearch', {
searchVal: searchValRef.value,
executorName: executorNameRef.value,
host: hostRef.value,
stateType: stateTypeRef.value,
startDate,
endDate,
workflowDefinitionCode: workflowDefinitionCodeRef.value
})
}
const onClearSearchVal = () => {
searchValRef.value = ''
handleSearch()
}
const onClearSearchHost = () => {
hostRef.value = ''
handleSearch()
}
const onClearSearchExecutor = () => {
executorNameRef.value = ''
handleSearch()
}
const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
const selectFilter = (query: string, option: SelectOption) => {
return option.filterLabel
? option.filterLabel
.toString()
.toLowerCase()
.includes(query.toLowerCase())
: false
}
const updateValue = (value: number) => {
workflowDefinitionCodeRef.value = value
}
return {
searchValRef,
executorNameRef,
hostRef,
stateTypeRef,
startEndTimeRef,
handleSearch,
onClearSearchVal,
onClearSearchExecutor,
onClearSearchHost,
trim,
workflowDefinitionOptions: workflowDefinitionOptions,
workflowDefineCodeRef: workflowDefinitionCodeRef,
selectFilter,
updateValue
}
},