@ -44,7 +44,7 @@
< m -list -box >
< div slot = "text" > { { $t ( 'Main jar package' ) } } < / div >
< div slot = "content" >
< treeselect v-model ="mainJar" :options="mainJarLists" :disable-branch-nodes="true" :normalizer="normalizer" :placeholder="$t('Please enter main jar package')" >
< treeselect v-model ="mainJar" :options="mainJarLists" :disable-branch-nodes="true" :normalizer="normalizer" :value-consists-of="valueConsistsOf" : placeholder="$t('Please enter main jar package')" >
< div slot = "value-label" slot -scope = " { node } " > { { node . raw . fullName } } < / div >
< / treeselect >
< / div >
@ -109,6 +109,7 @@
name : 'mr' ,
data ( ) {
return {
valueConsistsOf : 'LEAF_PRIORITY' ,
/ / M a i n f u n c t i o n c l a s s
mainClass : '' ,
/ / M a s t e r j a r p a c k a g e
@ -134,7 +135,9 @@
return {
label : node . name
}
}
} ,
allNoResources : [ ] ,
noRes : [ ]
}
} ,
props : {
@ -176,9 +179,76 @@
diGuiTree ( item ) { / / R e c u r s i v e c o n v e n i e n c e t r e e s t r u c t u r e
item . forEach ( item => {
item . children === '' || item . children === undefined || item . children === null || item . children . length === 0 ?
delete item . children : this . diGuiTree ( item . children ) ;
this . operationTree ( item ) : this . diGuiTree ( item . children ) ;
} )
} ,
operationTree ( item ) {
if ( item . dirctory ) {
item . isDisabled = true
}
delete item . children
} ,
searchTree ( element , id ) {
/ / 根 据 i d 查 找 节 点
if ( element . id == id ) {
return element ;
} else if ( element . children != null ) {
var i ;
var result = null ;
for ( i = 0 ; result == null && i < element . children . length ; i ++ ) {
result = this . searchTree ( element . children [ i ] , id ) ;
}
return result ;
}
return null ;
} ,
dataProcess ( backResource ) {
let isResourceId = [ ]
let resourceIdArr = [ ]
if ( this . resourceList . length > 0 ) {
this . resourceList . forEach ( v => {
this . mainJarList . forEach ( v1 => {
if ( this . searchTree ( v1 , v ) ) {
isResourceId . push ( this . searchTree ( v1 , v ) )
}
} )
} )
resourceIdArr = isResourceId . map ( item => {
return item . id
} )
Array . prototype . diff = function ( a ) {
return this . filter ( function ( i ) { return a . indexOf ( i ) < 0 ; } ) ;
} ;
let diffSet = this . resourceList . diff ( resourceIdArr ) ;
let optionsCmp = [ ]
if ( diffSet . length > 0 ) {
diffSet . forEach ( item => {
backResource . forEach ( item1 => {
if ( item == item1 . id || item == item1 . res ) {
optionsCmp . push ( item1 )
}
} )
} )
}
let noResources = [ {
id : - 1 ,
name : $t ( 'No resources' ) ,
fullName : '/' + $t ( 'No resources' ) ,
children : [ ]
} ]
if ( optionsCmp . length > 0 ) {
this . allNoResources = optionsCmp
optionsCmp = optionsCmp . map ( item => {
return { id : item . id , name : item . name , fullName : item . res }
} )
optionsCmp . forEach ( item => {
item . isNew = true
} )
noResources [ 0 ] . children = optionsCmp
this . mainJarList = this . mainJarList . concat ( noResources )
}
}
} ,
/ * *
* verification
* /
@ -193,6 +263,12 @@
return false
}
/ / n o R e s
if ( this . noRes . length > 0 ) {
this . $message . warning ( ` ${ i18n . $t ( 'Please delete all non-existent resources' ) } ` )
return false
}
/ / l o c a l P a r a m s S u b c o m p o n e n t v e r i f i c a t i o n
if ( ! this . $refs . refLocalParams . _verifProp ( ) ) {
return false
@ -231,14 +307,36 @@
} ,
computed : {
cacheParams ( ) {
let isResourceId = [ ]
let resourceIdArr = [ ]
if ( this . resourceList . length > 0 ) {
this . resourceList . forEach ( v => {
this . mainJarList . forEach ( v1 => {
if ( this . searchTree ( v1 , v ) ) {
isResourceId . push ( this . searchTree ( v1 , v ) )
}
} )
} )
resourceIdArr = isResourceId . map ( item => {
return { id : item . id , name : item . name , res : item . fullName }
} )
}
let result = [ ]
resourceIdArr . forEach ( item => {
this . allNoResources . forEach ( item1 => {
if ( item . id == item1 . id ) {
/ / r e s u l t B o o l = t r u e
result . push ( item1 )
}
} )
} )
this . noRes = result
return {
mainClass : this . mainClass ,
mainJar : {
id : this . mainJar
} ,
resourceList : _ . map ( this . resourceList , v => {
return { id : v }
} ) ,
resourceList : resourceIdArr ,
localParams : this . localParams ,
mainArgs : this . mainArgs ,
others : this . others ,
@ -273,23 +371,27 @@
let resourceList = o . params . resourceList || [ ]
if ( resourceList . length ) {
_ . map ( resourceList , v => {
if ( v . res ) {
if ( ! v . id ) {
this . store . dispatch ( 'dag/getResourceId' , {
type : 'FILE' ,
fullName : '/' + v . res
} ) . then ( res => {
this . resourceList . push ( res . id )
this . dataProcess ( backResource )
} ) . catch ( e => {
this . $message . error ( e . msg || '' )
this . resourceList . push ( v . res )
this . dataProcess ( backResource )
} )
} else {
this . resourceList . push ( v . id )
this . dataProcess ( backResource )
}
} )
this . cacheResourceList = resourceList
}
/ / b a c k f i l l l o c a l P a r a m s
let backResource = o . params . resourceList || [ ]
let localParams = o . params . localParams || [ ]
if ( localParams . length ) {
this . localParams = localParams