@ -15,7 +15,7 @@
* limitations under the License .
* limitations under the License .
* /
* /
import { ref , onMounted , watch , h } from 'vue'
import { ref , onMounted , watch , h , computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useI18n } from 'vue-i18n'
import { NEllipsis , NIcon } from 'naive-ui'
import { NEllipsis , NIcon } from 'naive-ui'
import { useRelationCustomParams , useDependentTimeout } from '.'
import { useRelationCustomParams , useDependentTimeout } from '.'
@ -36,13 +36,28 @@ import type {
ITaskState ,
ITaskState ,
IDateType
IDateType
} from '../types'
} from '../types'
import { IRenderOption } from "../types" ;
import { IRenderOption } from '../types'
export function useDependent ( model : { [ field : string ] : any } ) : IJsonItem [ ] {
export function useDependent ( model : { [ field : string ] : any } ) : IJsonItem [ ] {
const { t } = useI18n ( )
const { t } = useI18n ( )
const router : Router = useRouter ( )
const router : Router = useRouter ( )
const nodeStore = useTaskNodeStore ( )
const nodeStore = useTaskNodeStore ( )
const dependentFailurePolicyOptions = computed ( ( ) = > {
return [
{
label : t ( 'project.node.dependent_failure_policy_failure' ) ,
value : 'DEPENDENT_FAILURE_FAILURE'
} ,
{
label : t ( 'project.node.dependent_failure_policy_waiting' ) ,
value : 'DEPENDENT_FAILURE_WAITING'
}
]
} )
const failureWaitingTimeSpan = computed ( ( ) = >
model . failurePolicy === 'DEPENDENT_FAILURE_WAITING' ? 12 : 0
)
const dependentResult = nodeStore . getDependentResult
const dependentResult = nodeStore . getDependentResult
const TasksStateConfig = tasksState ( t )
const TasksStateConfig = tasksState ( t )
const projectList = ref ( [ ] as IRenderOption [ ] )
const projectList = ref ( [ ] as IRenderOption [ ] )
@ -248,23 +263,26 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
if ( ! item . dependItemList ? . length ) return
if ( ! item . dependItemList ? . length ) return
const itemListOptions = ref ( [ ] as IDependentItemOptions [ ] )
const itemListOptions = ref ( [ ] as IDependentItemOptions [ ] )
item . dependItemList ? . forEach ( async ( dependItem : IDependentItem , itemIndex : number ) = > {
item . dependItemList ? . forEach (
async ( dependItem : IDependentItem , itemIndex : number ) = > {
itemListOptions . value [ itemIndex ] = { }
itemListOptions . value [ itemIndex ] = { }
if ( dependItem . projectCode ) {
if ( dependItem . projectCode ) {
itemListOptions . value [ itemIndex ] . definitionCodeOptions = await getProcessList (
itemListOptions . value [ itemIndex ] . definitionCodeOptions =
dependItem . projectCode
await getProcessList ( dependItem . projectCode )
)
}
}
if ( dependItem . projectCode && dependItem . definitionCode ) {
if ( dependItem . projectCode && dependItem . definitionCode ) {
itemListOptions . value [ itemIndex ] . depTaskCodeOptions = await getTaskList (
itemListOptions . value [ itemIndex ] . depTaskCodeOptions =
await getTaskList (
dependItem . projectCode ,
dependItem . projectCode ,
dependItem . definitionCode
dependItem . definitionCode
)
)
}
}
if ( dependItem . cycle ) {
if ( dependItem . cycle ) {
itemListOptions . value [ itemIndex ] . dateOptions = DATE_LIST [ dependItem . cycle ]
itemListOptions . value [ itemIndex ] . dateOptions =
DATE_LIST [ dependItem . cycle ]
}
}
} )
}
)
selectOptions . value [ taskIndex ] = { } as IDependTaskOptions
selectOptions . value [ taskIndex ] = { } as IDependTaskOptions
selectOptions . value [ taskIndex ] . dependItemList = itemListOptions . value
selectOptions . value [ taskIndex ] . dependItemList = itemListOptions . value
} )
} )
@ -297,7 +315,9 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
const options = selectOptions ? . value [ i ] || { }
const options = selectOptions ? . value [ i ] || { }
const itemListOptions = options ? . dependItemList || [ ]
const itemListOptions = options ? . dependItemList || [ ]
const itemOptions = { } as IDependentItemOptions
const itemOptions = { } as IDependentItemOptions
itemOptions . definitionCodeOptions = await getProcessList ( projectCode )
itemOptions . definitionCodeOptions = await getProcessList (
projectCode
)
itemListOptions [ j ] = itemOptions
itemListOptions [ j ] = itemOptions
options . dependItemList = itemListOptions
options . dependItemList = itemListOptions
selectOptions . value [ i ] = options
selectOptions . value [ i ] = options
@ -331,14 +351,13 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
} ,
} ,
onUpdateValue : async ( processCode : number ) = > {
onUpdateValue : async ( processCode : number ) = > {
const item = model . dependTaskList [ i ] . dependItemList [ j ]
const item = model . dependTaskList [ i ] . dependItemList [ j ]
selectOptions . value [ i ] . dependItemList [ j ] . depTaskCodeOptions = await getTaskList (
selectOptions . value [ i ] . dependItemList [ j ] . depTaskCodeOptions =
item . projectCode ,
await getTaskList ( item . projectCode , processCode )
processCode
)
item . depTaskCode = 0
item . depTaskCode = 0
}
}
} ,
} ,
options : selectOptions.value [ i ] ? . dependItemList [ j ]
options :
selectOptions . value [ i ] ? . dependItemList [ j ]
? . definitionCodeOptions || [ ] ,
? . definitionCodeOptions || [ ] ,
path : ` dependTaskList. ${ i } .dependItemList. ${ j } .definitionCode ` ,
path : ` dependTaskList. ${ i } .dependItemList. ${ j } .definitionCode ` ,
rule : {
rule : {
@ -430,6 +449,56 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
} ) ,
} ) ,
childrenField : 'dependItemList' ,
childrenField : 'dependItemList' ,
name : 'add_dependency'
name : 'add_dependency'
} )
} ) ,
{
type : 'input-number' ,
field : 'checkInterval' ,
name : t ( 'project.node.check_interval' ) ,
span : 12 ,
props : {
max : Math.pow ( 9 , 10 ) - 1
} ,
slots : {
suffix : ( ) = > t ( 'project.node.second' )
} ,
validate : {
trigger : [ 'input' ] ,
validator ( validate : any , value : number ) {
if ( ! value && ! /^[1-9]\d*$/ . test ( String ( value ) ) ) {
return new Error ( t ( 'project.node.check_interval_tips' ) )
}
}
}
} ,
{
type : 'radio' ,
field : 'failurePolicy' ,
name : t ( 'project.node.dependent_failure_policy' ) ,
options : dependentFailurePolicyOptions ,
span : 24
} ,
{
type : 'input-number' ,
field : 'failureWaitingTime' ,
name : t ( 'project.node.dependent_failure_waiting_time' ) ,
span : failureWaitingTimeSpan ,
props : {
max : Math.pow ( 9 , 10 ) - 1
} ,
slots : {
suffix : ( ) = > t ( 'project.node.minute' )
} ,
validate : {
trigger : [ 'input' ] ,
required : true ,
validator ( validate : any , value : number ) {
if ( model . timeoutFlag && ! /^[1-9]\d*$/ . test ( String ( value ) ) ) {
return new Error (
t ( 'project.node.dependent_failure_waiting_time_tips' )
)
}
}
}
}
]
]
}
}