@ -1,11 +1,25 @@
import { shortcut , extend , i18nText , createWidget , toPix , isNumeric , AbsoluteLayout , isEmptyString , isNotNull , isNull , isIE , getIEVersion } from "@/core" ;
import {
HorizontalFillLayout ,
shortcut ,
extend ,
i18nText ,
createWidget ,
toPix ,
isNumeric ,
AbsoluteLayout ,
isEmptyString ,
isNotNull ,
isNull ,
isIE ,
getIEVersion ,
} from "@/core" ;
import { Single , Label , Bubbles } from "@/base" ;
import { IconCombo } from "@/case" ;
import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor" ;
@ shortcut ( )
export class NumberInterval extends Single {
static xtype = "bi.number_interval"
static xtype = "bi.number_interval" ;
constants = {
typeError : "typeBubble" ,
@ -23,16 +37,16 @@ export class NumberInterval extends Single {
adjustYOffset : 2 ,
} ;
static EVENT _CHANGE = "EVENT_CHANGE"
static EVENT _CONFIRM = "EVENT_CONFIRM"
static EVENT _VALID = "EVENT_VALID"
static EVENT _ERROR = "EVENT_ERROR"
static EVENT _CHANGE = "EVENT_CHANGE" ;
static EVENT _CONFIRM = "EVENT_CONFIRM" ;
static EVENT _VALID = "EVENT_VALID" ;
static EVENT _ERROR = "EVENT_ERROR" ;
_defaultConfig ( ) {
const conf = super . _defaultConfig ( ... arguments ) ;
return extend ( conf , {
extraCls : ` bi-number-interval ${ ( isIE ( ) && getIEVersion ( ) < 10 ) ? " hack" : "" } ` ,
extraCls : ` bi-number-interval ${ isIE ( ) && getIEVersion ( ) < 10 ? " hack" : "" } ` ,
height : 24 ,
validation : "valid" ,
closeMin : true ,
@ -47,20 +61,20 @@ export class NumberInterval extends Single {
o = this . options ;
super . _init ( ... arguments ) ;
this . smallEditor = createWidget ( {
type : "bi.number_interval_single_editor" ,
type : NumberIntervalSingleEidtor . xtype ,
height : toPix ( o . height , o . simple ? 1 : 2 ) ,
watermark : o . watermark ,
allowBlank : o . allowBlank ,
value : o . min ,
level : "warning" ,
tipType : "success" ,
title ( ) {
title ( ) {
return self . smallEditor && self . smallEditor . getValue ( ) ;
} ,
quitChecker ( ) {
quitChecker ( ) {
return false ;
} ,
validationChecker ( v ) {
validationChecker ( v ) {
if ( ! isNumeric ( v ) ) {
self . smallEditorBubbleType = c . typeError ;
@ -69,7 +83,9 @@ export class NumberInterval extends Single {
return true ;
} ,
cls : ` number-interval-small-editor bi-focus-shadow ${ o . simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius" } ` ,
cls : ` number-interval-small-editor bi-focus-shadow ${
o . simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"
} ` ,
} ) ;
this . smallTip = createWidget ( {
@ -81,26 +97,28 @@ export class NumberInterval extends Single {
createWidget ( {
type : AbsoluteLayout . xtype ,
element : this . smallEditor ,
items : [ {
el : this . smallTip ,
top : 0 ,
right : 5 ,
} ] ,
items : [
{
el : this . smallTip ,
top : 0 ,
right : 5 ,
} ,
] ,
} ) ;
this . bigEditor = createWidget ( {
type : "bi.number_interval_single_editor" ,
type : NumberIntervalSingleEidtor . xtype ,
height : toPix ( o . height , o . simple ? 1 : 2 ) ,
watermark : o . watermark ,
allowBlank : o . allowBlank ,
value : o . max ,
title ( ) {
title ( ) {
return self . bigEditor && self . bigEditor . getValue ( ) ;
} ,
quitChecker ( ) {
quitChecker ( ) {
return false ;
} ,
validationChecker ( v ) {
validationChecker ( v ) {
if ( ! isNumeric ( v ) ) {
self . bigEditorBubbleType = c . typeError ;
@ -109,7 +127,9 @@ export class NumberInterval extends Single {
return true ;
} ,
cls : ` number-interval-big-editor bi-focus-shadow ${ o . simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius" } ` ,
cls : ` number-interval-big-editor bi-focus-shadow ${
o . simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"
} ` ,
} ) ;
this . bigTip = createWidget ( {
@ -121,26 +141,33 @@ export class NumberInterval extends Single {
createWidget ( {
type : AbsoluteLayout . xtype ,
element : this . bigEditor ,
items : [ {
el : this . bigTip ,
top : 0 ,
right : 5 ,
} ] ,
items : [
{
el : this . bigTip ,
top : 0 ,
right : 5 ,
} ,
] ,
} ) ;
this . smallCombo = createWidget ( {
type : IconCombo . xtype ,
cls : ` number-interval-small-combo ${ o . simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius" } ` ,
cls : ` number-interval-small-combo ${
o . simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"
} ` ,
height : toPix ( o . height , o . simple ? 0 : 2 ) ,
width : toPix ( c . width , c . border ) ,
items : [ {
text : ` ( ${ i18nText ( "BI-Less_Than" ) } ) ` ,
iconCls : "less-font" ,
value : 0 ,
} , {
text : ` ( ${ i18nText ( "BI-Less_And_Equal" ) } ) ` ,
value : 1 ,
iconCls : "less-equal-font" ,
} ] ,
items : [
{
text : ` ( ${ i18nText ( "BI-Less_Than" ) } ) ` ,
iconCls : "less-font" ,
value : 0 ,
} ,
{
text : ` ( ${ i18nText ( "BI-Less_And_Equal" ) } ) ` ,
value : 1 ,
iconCls : "less-equal-font" ,
} ,
] ,
} ) ;
if ( o . closeMin === true ) {
this . smallCombo . setValue ( 1 ) ;
@ -149,18 +176,23 @@ export class NumberInterval extends Single {
}
this . bigCombo = createWidget ( {
type : IconCombo . xtype ,
cls : ` number-interval-big-combo ${ o . simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius" } ` ,
cls : ` number-interval-big-combo ${
o . simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"
} ` ,
height : toPix ( o . height , o . simple ? 0 : 2 ) ,
width : toPix ( c . width , c . border ) ,
items : [ {
text : ` ( ${ i18nText ( "BI-Less_Than" ) } ) ` ,
iconCls : "less-font" ,
value : 0 ,
} , {
text : ` ( ${ i18nText ( "BI-Less_And_Equal" ) } ) ` ,
value : 1 ,
iconCls : "less-equal-font" ,
} ] ,
items : [
{
text : ` ( ${ i18nText ( "BI-Less_Than" ) } ) ` ,
iconCls : "less-font" ,
value : 0 ,
} ,
{
text : ` ( ${ i18nText ( "BI-Less_And_Equal" ) } ) ` ,
value : 1 ,
iconCls : "less-equal-font" ,
} ,
] ,
} ) ;
if ( o . closeMax === true ) {
this . bigCombo . setValue ( 1 ) ;
@ -178,38 +210,47 @@ export class NumberInterval extends Single {
tipType : "warning" ,
} ) ;
this . left = createWidget ( {
type : "bi.horizontal_fill" ,
type : HorizontalFillLayout . xtype ,
columnSize : [ "fill" , "" ] ,
items : [ {
el : self . smallEditor ,
} , {
el : self . smallCombo ,
} ] ,
items : [
{
el : self . smallEditor ,
} ,
{
el : self . smallCombo ,
} ,
] ,
} ) ;
this . right = createWidget ( {
type : "bi.horizontal_fill" ,
type : HorizontalFillLayout . xtype ,
columnSize : [ "" , "fill" ] ,
items : [ {
el : self . bigCombo ,
} , {
el : self . bigEditor ,
// BI-23883 间距考虑边框
// lgap: 1
} ] ,
items : [
{
el : self . bigCombo ,
} ,
{
el : self . bigEditor ,
// BI-23883 间距考虑边框
// lgap: 1
} ,
] ,
} ) ;
createWidget ( {
element : self ,
type : "bi.horizontal_fill" ,
type : HorizontalFillLayout . xtype ,
columnSize : [ "fill" , "" , "fill" ] ,
items : [ {
el : self . left ,
} , {
el : self . label ,
} , {
el : self . right ,
} ] ,
items : [
{
el : self . left ,
} ,
{
el : self . label ,
} ,
{
el : self . right ,
} ,
] ,
} ) ;
// createWidget({
@ -327,26 +368,26 @@ export class NumberInterval extends Single {
w . on ( NumberIntervalSingleEidtor . EVENT _FOCUS , ( ) => {
self . _setTitle ( "" ) ;
switch ( self . _checkValidation ( ) ) {
case c . typeError :
Bubbles . show ( c . typeError , i18nText ( "BI-Numerical_Interval_Input_Data" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . numberError :
Bubbles . show ( c . numberError , i18nText ( "BI-Numerical_Interval_Number_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . signalError :
Bubbles . show ( c . signalError , i18nText ( "BI-Numerical_Interval_Signal_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
default :
return ;
case c . typeError :
Bubbles . show ( c . typeError , i18nText ( "BI-Numerical_Interval_Input_Data" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . numberError :
Bubbles . show ( c . numberError , i18nText ( "BI-Numerical_Interval_Number_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . signalError :
Bubbles . show ( c . signalError , i18nText ( "BI-Numerical_Interval_Signal_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
default :
return ;
}
} ) ;
}
@ -359,17 +400,17 @@ export class NumberInterval extends Single {
Bubbles . hide ( c . numberError ) ;
Bubbles . hide ( c . signalError ) ;
switch ( self . _checkValidation ( ) ) {
case c . typeError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Input_Data" ) ) ;
break ;
case c . numberError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Number_Value" ) ) ;
break ;
case c . signalError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Signal_Value" ) ) ;
break ;
default :
self . _setTitle ( "" ) ;
case c . typeError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Input_Data" ) ) ;
break ;
case c . numberError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Number_Value" ) ) ;
break ;
case c . signalError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Signal_Value" ) ) ;
break ;
default :
self . _setTitle ( "" ) ;
}
} ) ;
}
@ -392,22 +433,22 @@ export class NumberInterval extends Single {
c = this . constants ;
w . on ( NumberIntervalSingleEidtor . EVENT _VALID , ( ) => {
switch ( self . _checkValidation ( ) ) {
case c . numberError :
Bubbles . show ( c . numberError , i18nText ( "BI-Numerical_Interval_Number_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
case c . signalError :
Bubbles . show ( c . signalError , i18nText ( "BI-Numerical_Interval_Signal_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
default :
self . fireEvent ( NumberInterval . EVENT _VALID ) ;
case c . numberError :
Bubbles . show ( c . numberError , i18nText ( "BI-Numerical_Interval_Number_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
case c . signalError :
Bubbles . show ( c . signalError , i18nText ( "BI-Numerical_Interval_Signal_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
default :
self . fireEvent ( NumberInterval . EVENT _VALID ) ;
}
} ) ;
}
@ -417,26 +458,26 @@ export class NumberInterval extends Single {
c = this . constants ;
w . on ( NumberIntervalSingleEidtor . EVENT _CHANGE , ( ) => {
switch ( self . _checkValidation ( ) ) {
case c . typeError :
Bubbles . show ( c . typeError , i18nText ( "BI-Numerical_Interval_Input_Data" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . numberError :
Bubbles . show ( c . numberError , i18nText ( "BI-Numerical_Interval_Number_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . signalError :
Bubbles . show ( c . signalError , i18nText ( "BI-Numerical_Interval_Signal_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
default :
break ;
case c . typeError :
Bubbles . show ( c . typeError , i18nText ( "BI-Numerical_Interval_Input_Data" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . numberError :
Bubbles . show ( c . numberError , i18nText ( "BI-Numerical_Interval_Number_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
case c . signalError :
Bubbles . show ( c . signalError , i18nText ( "BI-Numerical_Interval_Signal_Value" ) , self , {
offsetStyle : "left" ,
adjustYOffset : c . adjustYOffset ,
} ) ;
break ;
default :
break ;
}
self . fireEvent ( NumberInterval . EVENT _CHANGE ) ;
} ) ;
@ -450,22 +491,22 @@ export class NumberInterval extends Single {
c = this . constants ;
w . on ( IconCombo . EVENT _CHANGE , ( ) => {
switch ( self . _checkValidation ( ) ) {
case c . typeError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Input_Data" ) ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
case c . numberError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Number_Value" ) ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
case c . signalError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Signal_Value" ) ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
default :
self . fireEvent ( NumberInterval . EVENT _CHANGE ) ;
self . fireEvent ( NumberInterval . EVENT _CONFIRM ) ;
self . fireEvent ( NumberInterval . EVENT _VALID ) ;
case c . typeError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Input_Data" ) ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
case c . numberError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Number_Value" ) ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
case c . signalError :
self . _setTitle ( i18nText ( "BI-Numerical_Interval_Signal_Value" ) ) ;
self . fireEvent ( NumberInterval . EVENT _ERROR ) ;
break ;
default :
self . fireEvent ( NumberInterval . EVENT _CHANGE ) ;
self . fireEvent ( NumberInterval . EVENT _CONFIRM ) ;
self . fireEvent ( NumberInterval . EVENT _VALID ) ;
}
} ) ;
}