@ -4,10 +4,10 @@
< a -spin :spinning ="loading" >
< a -form -model ref = "form" :model ="entity" :rules ="rules" v-bind ="layout" >
< a -form -model -item label = "一级类目" prop = "OneCat" >
< a -select v -model = " entity.OneCat " showSearch :filter-option ="filterOption" style = "width: 100%"
< a -select v -model = " entity.OneCat " label -in -value showSearch :filter-option ="filterOption" style = "width: 100%"
placeholder = "请选择或输入一级类目" >
< a -select -option v-for ="(cat,index) in catList" :key="index" :value ="cat" >
< a -select -option v-for ="(cat,index) in catList" :key="index" :value="cat.Id " >
{ { cat . Text } }
< / a - s e l e c t - o p t i o n >
@ -21,15 +21,15 @@
< / a - s e l e c t >
< / a - f o r m - m o d e l - i t e m >
< a -form -model -item label = "二级类目" prop = "TwoCat" >
< a -select v -if = " entity.OneCat " v -model = " entity.TwoCat " showSearch :filter-option ="filterOption "
< a -select label -in -value v -if = " entity.OneCat & & catList.find ( c = > c . Id == entity . OneCat . key ) " v-model=" entity . TwoCat " showSearch :filter-option=" filterOption "
style = "width: 100%" placeholder = "请选择或输入一级类目" >
< a -select -option v-for ="(cat,index) in entity.OneCat.Children" :key="index" :value ="cat" >
< a -select -option v-for ="(cat,index) in catList.find(c=>c.Id== entity.OneCat.key) .Children" :key="index" :value="cat.Id " >
{ { cat . Text } }
< / a - s e l e c t - o p t i o n >
< div slot = "dropdownRender" slot -scope = " menu " >
< v -nodes :vnodes ="menu" / >
< a -divider style = "margin: 4px 0;" / >
< div style = "padding: 4px 8px; cursor: pointer;" @ mousedown = "e => e.preventDefault()" @click ="()=>addItem(2,entity.OneCat.Children)" >
< div style = "padding: 4px 8px; cursor: pointer;" @ mousedown = "e => e.preventDefault()" @click ="()=>addItem(2,catList.find(c=>c.Id== entity.OneCat.key) .Children)" >
< a -icon type = "plus" / > 添加新类目
< / div >
< / div >
@ -37,15 +37,15 @@
< span v-else > 请选择一级类目 < / span >
< / a - f o r m - m o d e l - i t e m >
< a -form -model -item label = "三级类目" prop = "LastCat" >
< a -select v -if = " entity.TwoCat " v -model = " entity.LastCat " showSearch :filter-option ="filterOption "
< a -select label -in -value v -if = " entity.TwoCat & & entity.OneCat & & catList.find ( c = > c . Id == entity . OneCat . key ) . Children . find ( c => c . Id == entity . TwoCat . key ) " v-model=" entity . LastCat " showSearch :filter-option=" filterOption "
style = "width: 100%" placeholder = "请选择或输入一级类目" >
< a -select -option v-for ="(cat,index) in entity.TwoCat.Children" :key="index" :value ="cat" >
< a -select -option v-for ="(cat,index) in catList.find(c=>c.Id==entity.OneCat.key).Children.find(c=>c.Id== entity.TwoCat.key) .Children" :key="index" :value="cat.Id " >
{ { cat . Text } }
< / a - s e l e c t - o p t i o n >
< div slot = "dropdownRender" slot -scope = " menu " >
< v -nodes :vnodes ="menu" / >
< a -divider style = "margin: 4px 0;" / >
< div style = "padding: 4px 8px; cursor: pointer;" @ mousedown = "e => e.preventDefault()" @click ="()=>addItem(3,entity.TwoCat.Children)" >
< div style = "padding: 4px 8px; cursor: pointer;" @ mousedown = "e => e.preventDefault()" @click ="()=>addItem(3,catList.find(c=>c.Id==entity.OneCat.key).Children.find(c=>c.Id== entity.TwoCat.key) .Children)" >
< a -icon type = "plus" / > 添加新类目
< / div >
< / div >
@ -121,16 +121,33 @@
var push = { }
push . KeyWords = this . entity . KeyWords . split ( /[(\r\n)\r\n]+/ )
push . OneCat = {
Text : this . entity . OneCat . Text ,
Id : this . entity . OneCat . Id
Text : this . entity . OneCat . label . trim ( ) ,
Id : this . entity . OneCat . key
}
if ( push . OneCat . Id . indexOf ( "test" ) >= 0 )
{
push . OneCat . Id = undefined
}
push . TwoCat = {
Text : this . entity . TwoCat . Text ,
Id : this . entity . TwoCat . Id
Text : this . entity . TwoCat . label . trim ( ) ,
Id : this . entity . TwoCat . key
}
if ( push . TwoCat . Id . indexOf ( "test" ) >= 0 )
{
push . TwoCat . Id = undefined
}
push . LastCat = {
Text : this . entity . LastCat . Text ,
Id : this . entity . LastCat . Id
Text : this . entity . LastCat . label . trim ( ) ,
Id : this . entity . LastCat . key
}
if ( push . LastCat . Id . indexOf ( "test" ) >= 0 )
{
push . LastCat . Id = undefined
}
this . $http . post ( '/HuiYan/cats/AddKeyWord' , push ) . then ( resJson => {
@ -162,18 +179,19 @@
onOk ( e ) {
return new Promise ( ( resolve , reject ) => {
var text = document . getElementById ( 'newcattext' ) . value
var opt = { Text : text , Children : [ ] }
var key = "test" + Math . ceil ( Math . random ( ) * 10000 )
var opt = { Text : text , Children : [ ] , Id : key }
data . push ( opt )
switch ( type )
{
case 1 :
that . entity . OneCat = op t
that . entity . OneCat = { key : key , label : text }
break
case 2 :
that . entity . TwoCat = op t
that . entity . TwoCat = { key : key , label : text }
break
case 3 :
that . entity . LastCat = op t
that . entity . LastCat = { key : key , label : text }
break
}
e ( )